1.7.9 Support

This commit is contained in:
Olof Larsson 2014-05-14 15:27:27 +02:00
parent 7d252edda1
commit 858b4e5fd1
8 changed files with 152 additions and 26 deletions

View File

@ -0,0 +1,125 @@
package com.massivecraft.factions;
import java.util.Set;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.plugin.Plugin;
import com.massivecraft.factions.entity.Board;
import com.massivecraft.factions.entity.BoardColl;
import com.massivecraft.factions.entity.BoardColls;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.FactionColl;
import com.massivecraft.factions.entity.FactionColls;
import com.massivecraft.factions.entity.MPlayerColl;
import com.massivecraft.factions.entity.UPlayerColl;
import com.massivecraft.factions.entity.UPlayerColls;
import com.massivecraft.mcore.EngineAbstract;
import com.massivecraft.mcore.event.MCoreUuidUpdateEvent;
import com.massivecraft.mcore.util.IdUpdateUtil;
import com.massivecraft.mcore.util.MUtil;
public class EngineIdUpdate extends EngineAbstract
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static EngineIdUpdate i = new EngineIdUpdate();
public static EngineIdUpdate get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public Plugin getPlugin()
{
return Factions.get();
}
// -------------------------------------------- //
// LISTENER
// -------------------------------------------- //
@EventHandler(priority = EventPriority.MONITOR)
public void update(MCoreUuidUpdateEvent event)
{
for (FactionColl coll : FactionColls.get().getColls())
{
for (Faction entity : coll.getAll())
{
update(coll, entity);
}
}
IdUpdateUtil.update(MPlayerColl.get());
for (UPlayerColl coll : UPlayerColls.get().getColls())
{
IdUpdateUtil.update(coll);
}
for (BoardColl coll : BoardColls.get().getColls())
{
update(coll);
}
}
public static void update(FactionColl coll, Faction entity)
{
// Before and After
Set<String> before = entity.getInvitedPlayerIds();
if (before == null) return;
Set<String> after = IdUpdateUtil.update(before, true);
if (after == null) return;
// NoChange
if (MUtil.equals(before, after)) return;
// Apply
entity.setInvitedPlayerIds(after);
entity.sync();
}
public static void update(BoardColl coll)
{
for (Board board : coll.getAll())
{
update(board);
}
}
public static void update(Board board)
{
boolean changed = false;
for (TerritoryAccess ta : board.getMap().values())
{
changed |= update(ta);
}
if (changed)
{
board.changed();
board.sync();
}
}
public static boolean update(TerritoryAccess entity)
{
// Before and After
Set<String> before = entity.playerIds;
if (before == null) return false;
Set<String> after = IdUpdateUtil.update(before, true);
if (after == null) return false;
// NoChange
if (MUtil.equals(before, after)) return false;
// Apply
entity.playerIds = after;
//entity.sync();
return true;
}
}

View File

@ -128,6 +128,7 @@ public class Factions extends MPlugin
this.outerCmdFactions.register(); this.outerCmdFactions.register();
// Setup Listeners // Setup Listeners
EngineIdUpdate.get().activate();
FactionsListenerMain.get().setup(); FactionsListenerMain.get().setup();
FactionsListenerChat.get().setup(); FactionsListenerChat.get().setup();
FactionsListenerExploit.get().setup(); FactionsListenerExploit.get().setup();

View File

@ -32,8 +32,9 @@ public class TerritoryAccess
private final Set<String> factionIds; private final Set<String> factionIds;
public Set<String> getFactionIds() { return this.factionIds; } public Set<String> getFactionIds() { return this.factionIds; }
// TODO: remate private final
// default is empty // default is empty
private final Set<String> playerIds; public Set<String> playerIds;
public Set<String> getPlayerIds() { return this.playerIds; } public Set<String> getPlayerIds() { return this.playerIds; }
// -------------------------------------------- // // -------------------------------------------- //

View File

@ -9,6 +9,7 @@ import com.massivecraft.factions.entity.FactionColl;
import com.massivecraft.factions.entity.FactionColls; import com.massivecraft.factions.entity.FactionColls;
import com.massivecraft.mcore.cmd.arg.ArgReaderAbstract; import com.massivecraft.mcore.cmd.arg.ArgReaderAbstract;
import com.massivecraft.mcore.cmd.arg.ArgResult; import com.massivecraft.mcore.cmd.arg.ArgResult;
import com.massivecraft.mcore.util.IdUtil;
import com.massivecraft.mcore.util.Txt; import com.massivecraft.mcore.util.Txt;
public class ARFaction extends ArgReaderAbstract<Faction> public class ARFaction extends ArgReaderAbstract<Faction>
@ -48,7 +49,8 @@ public class ARFaction extends ArgReaderAbstract<Faction>
if (result.hasResult()) return result; if (result.hasResult()) return result;
// UPlayer Name Exact // UPlayer Name Exact
UPlayer uplayer = UPlayerColls.get().get(this.getColl()).get(str); String id = IdUtil.getId(str);
UPlayer uplayer = UPlayerColls.get().get(this.getColl()).get(id);
if (uplayer != null) if (uplayer != null)
{ {
result.setResult(uplayer.getFaction()); result.setResult(uplayer.getFaction());

View File

@ -21,8 +21,8 @@ import com.massivecraft.mcore.mixin.Mixin;
import com.massivecraft.mcore.money.Money; import com.massivecraft.mcore.money.Money;
import com.massivecraft.mcore.ps.PS; import com.massivecraft.mcore.ps.PS;
import com.massivecraft.mcore.store.Entity; import com.massivecraft.mcore.store.Entity;
import com.massivecraft.mcore.util.IdUtil;
import com.massivecraft.mcore.util.MUtil; import com.massivecraft.mcore.util.MUtil;
import com.massivecraft.mcore.util.SenderUtil;
import com.massivecraft.mcore.util.Txt; import com.massivecraft.mcore.util.Txt;
public class Faction extends Entity<Faction> implements EconomyParticipator public class Faction extends Entity<Faction> implements EconomyParticipator
@ -931,7 +931,7 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
public List<CommandSender> getOnlineCommandSenders() public List<CommandSender> getOnlineCommandSenders()
{ {
List<CommandSender> ret = new ArrayList<CommandSender>(); List<CommandSender> ret = new ArrayList<CommandSender>();
for (CommandSender player : SenderUtil.getOnlineSenders()) for (CommandSender player : IdUtil.getOnlineSenders())
{ {
UPlayer uplayer = UPlayer.get(player); UPlayer uplayer = UPlayer.get(player);
if (!MUtil.equals(uplayer.getUniverse(), this.getUniverse())) continue; if (!MUtil.equals(uplayer.getUniverse(), this.getUniverse())) continue;
@ -1050,34 +1050,34 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
public boolean sendMessage(String message) public boolean sendMessage(String message)
{ {
return Mixin.message(new FactionEqualsPredictate(this), message); return Mixin.messagePredictate(new FactionEqualsPredictate(this), message);
} }
public boolean sendMessage(String... messages) public boolean sendMessage(String... messages)
{ {
return Mixin.message(new FactionEqualsPredictate(this), messages); return Mixin.messagePredictate(new FactionEqualsPredictate(this), messages);
} }
public boolean sendMessage(Collection<String> messages) public boolean sendMessage(Collection<String> messages)
{ {
return Mixin.message(new FactionEqualsPredictate(this), messages); return Mixin.messagePredictate(new FactionEqualsPredictate(this), messages);
} }
// CONVENIENCE MSG // CONVENIENCE MSG
public boolean msg(String msg) public boolean msg(String msg)
{ {
return Mixin.msg(new FactionEqualsPredictate(this), msg); return Mixin.msgPredictate(new FactionEqualsPredictate(this), msg);
} }
public boolean msg(String msg, Object... args) public boolean msg(String msg, Object... args)
{ {
return Mixin.msg(new FactionEqualsPredictate(this), msg, args); return Mixin.msgPredictate(new FactionEqualsPredictate(this), msg, args);
} }
public boolean msg(Collection<String> msgs) public boolean msg(Collection<String> msgs)
{ {
return Mixin.msg(new FactionEqualsPredictate(this), msgs); return Mixin.msgPredictate(new FactionEqualsPredictate(this), msgs);
} }
} }

View File

@ -21,8 +21,8 @@ import com.massivecraft.mcore.mixin.Mixin;
import com.massivecraft.mcore.ps.PS; import com.massivecraft.mcore.ps.PS;
import com.massivecraft.mcore.ps.PSFormatHumanSpace; import com.massivecraft.mcore.ps.PSFormatHumanSpace;
import com.massivecraft.mcore.store.SenderEntity; import com.massivecraft.mcore.store.SenderEntity;
import com.massivecraft.mcore.util.IdUtil;
import com.massivecraft.mcore.util.MUtil; import com.massivecraft.mcore.util.MUtil;
import com.massivecraft.mcore.util.SenderUtil;
import com.massivecraft.mcore.util.Txt; import com.massivecraft.mcore.util.Txt;
@ -74,7 +74,7 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
Faction faction = this.getFaction(); Faction faction = this.getFaction();
faction.uplayers.add(this); faction.uplayers.add(this);
Factions.get().log(Txt.parse("<g>postAttach added <h>%s <i>aka <h>%s <i>to <h>%s <i>aka <h>%s<i>.", id, Mixin.getDisplayName(id), faction.getId(), faction.getName())); //Factions.get().log(Txt.parse("<g>postAttach added <h>%s <i>aka <h>%s <i>to <h>%s <i>aka <h>%s<i>.", id, Mixin.getDisplayName(id), faction.getId(), faction.getName()));
} }
@Override @Override
@ -87,7 +87,7 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
Faction faction = this.getFaction(); Faction faction = this.getFaction();
faction.uplayers.remove(this); faction.uplayers.remove(this);
Factions.get().log(Txt.parse("<b>preDetach removed <h>%s <i>aka <h>%s <i>to <h>%s <i>aka <h>%s<i>.", id, Mixin.getDisplayName(id), faction.getId(), faction.getName())); //Factions.get().log(Txt.parse("<b>preDetach removed <h>%s <i>aka <h>%s <i>to <h>%s <i>aka <h>%s<i>.", id, Mixin.getDisplayName(id), faction.getId(), faction.getName()));
} }
// -------------------------------------------- // // -------------------------------------------- //
@ -475,11 +475,6 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
// TITLE, NAME, FACTION NAME AND CHAT // TITLE, NAME, FACTION NAME AND CHAT
// -------------------------------------------- // // -------------------------------------------- //
public String getName()
{
return this.getFixedId();
}
public String getFactionName() public String getFactionName()
{ {
Faction faction = this.getFaction(); Faction faction = this.getFaction();
@ -785,7 +780,7 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
} }
if (MConf.get().logLandClaims) if (MConf.get().logLandClaims)
{ {
informees.add(UPlayer.get(SenderUtil.getConsole())); informees.add(UPlayer.get(IdUtil.getConsole()));
} }
String chunkString = chunk.toString(PSFormatHumanSpace.get()); String chunkString = chunk.toString(PSFormatHumanSpace.get());

View File

@ -1,12 +1,13 @@
package com.massivecraft.factions.entity; package com.massivecraft.factions.entity;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.massivecraft.mcore.store.Coll; import com.massivecraft.mcore.store.Coll;
import com.massivecraft.mcore.store.Colls; import com.massivecraft.mcore.store.Colls;
import com.massivecraft.mcore.store.Entity; import com.massivecraft.mcore.store.Entity;
import com.massivecraft.mcore.util.MUtil; import com.massivecraft.mcore.util.MUtil;
import com.massivecraft.mcore.util.SenderUtil;
public abstract class XColls<C extends Coll<E>, E> extends Colls<C, E> public abstract class XColls<C extends Coll<E>, E> extends Colls<C, E>
{ {
@ -29,7 +30,7 @@ public abstract class XColls<C extends Coll<E>, E> extends Colls<C, E>
return this.getForUniverse(universe); return this.getForUniverse(universe);
} }
if (SenderUtil.isNonplayer(o)) if ((o instanceof CommandSender) && !(o instanceof Player))
{ {
return this.getForWorld(Bukkit.getWorlds().get(0).getName()); return this.getForWorld(Bukkit.getWorlds().get(0).getName());
} }

View File

@ -6,6 +6,7 @@ import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import java.util.UUID;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -17,18 +18,18 @@ import org.bukkit.entity.Player;
public class VisualizeUtil public class VisualizeUtil
{ {
protected static Map<String, Set<Location>> playerLocations = new HashMap<String, Set<Location>>(); protected static Map<UUID, Set<Location>> playerLocations = new HashMap<UUID, Set<Location>>();
public static Set<Location> getPlayerLocations(Player player) public static Set<Location> getPlayerLocations(Player player)
{ {
return getPlayerLocations(player.getName()); return getPlayerLocations(player.getUniqueId());
} }
public static Set<Location> getPlayerLocations(String playerName) public static Set<Location> getPlayerLocations(UUID uuid)
{ {
Set<Location> ret = playerLocations.get(playerName); Set<Location> ret = playerLocations.get(uuid);
if (ret == null) if (ret == null)
{ {
ret = new HashSet<Location>(); ret = new HashSet<Location>();
playerLocations.put(playerName, ret); playerLocations.put(uuid, ret);
} }
return ret; return ret;
} }