1.7.9 Support
This commit is contained in:
parent
7d252edda1
commit
858b4e5fd1
125
src/com/massivecraft/factions/EngineIdUpdate.java
Normal file
125
src/com/massivecraft/factions/EngineIdUpdate.java
Normal 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;
|
||||
}
|
||||
|
||||
}
|
@ -128,6 +128,7 @@ public class Factions extends MPlugin
|
||||
this.outerCmdFactions.register();
|
||||
|
||||
// Setup Listeners
|
||||
EngineIdUpdate.get().activate();
|
||||
FactionsListenerMain.get().setup();
|
||||
FactionsListenerChat.get().setup();
|
||||
FactionsListenerExploit.get().setup();
|
||||
|
@ -32,8 +32,9 @@ public class TerritoryAccess
|
||||
private final Set<String> factionIds;
|
||||
public Set<String> getFactionIds() { return this.factionIds; }
|
||||
|
||||
// TODO: remate private final
|
||||
// default is empty
|
||||
private final Set<String> playerIds;
|
||||
public Set<String> playerIds;
|
||||
public Set<String> getPlayerIds() { return this.playerIds; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
|
@ -9,6 +9,7 @@ import com.massivecraft.factions.entity.FactionColl;
|
||||
import com.massivecraft.factions.entity.FactionColls;
|
||||
import com.massivecraft.mcore.cmd.arg.ArgReaderAbstract;
|
||||
import com.massivecraft.mcore.cmd.arg.ArgResult;
|
||||
import com.massivecraft.mcore.util.IdUtil;
|
||||
import com.massivecraft.mcore.util.Txt;
|
||||
|
||||
public class ARFaction extends ArgReaderAbstract<Faction>
|
||||
@ -48,7 +49,8 @@ public class ARFaction extends ArgReaderAbstract<Faction>
|
||||
if (result.hasResult()) return result;
|
||||
|
||||
// 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)
|
||||
{
|
||||
result.setResult(uplayer.getFaction());
|
||||
|
@ -21,8 +21,8 @@ import com.massivecraft.mcore.mixin.Mixin;
|
||||
import com.massivecraft.mcore.money.Money;
|
||||
import com.massivecraft.mcore.ps.PS;
|
||||
import com.massivecraft.mcore.store.Entity;
|
||||
import com.massivecraft.mcore.util.IdUtil;
|
||||
import com.massivecraft.mcore.util.MUtil;
|
||||
import com.massivecraft.mcore.util.SenderUtil;
|
||||
import com.massivecraft.mcore.util.Txt;
|
||||
|
||||
public class Faction extends Entity<Faction> implements EconomyParticipator
|
||||
@ -931,7 +931,7 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
|
||||
public List<CommandSender> getOnlineCommandSenders()
|
||||
{
|
||||
List<CommandSender> ret = new ArrayList<CommandSender>();
|
||||
for (CommandSender player : SenderUtil.getOnlineSenders())
|
||||
for (CommandSender player : IdUtil.getOnlineSenders())
|
||||
{
|
||||
UPlayer uplayer = UPlayer.get(player);
|
||||
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)
|
||||
{
|
||||
return Mixin.message(new FactionEqualsPredictate(this), message);
|
||||
return Mixin.messagePredictate(new FactionEqualsPredictate(this), message);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
return Mixin.message(new FactionEqualsPredictate(this), messages);
|
||||
return Mixin.messagePredictate(new FactionEqualsPredictate(this), messages);
|
||||
}
|
||||
|
||||
// CONVENIENCE 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)
|
||||
{
|
||||
return Mixin.msg(new FactionEqualsPredictate(this), msg, args);
|
||||
return Mixin.msgPredictate(new FactionEqualsPredictate(this), msg, args);
|
||||
}
|
||||
|
||||
public boolean msg(Collection<String> msgs)
|
||||
{
|
||||
return Mixin.msg(new FactionEqualsPredictate(this), msgs);
|
||||
return Mixin.msgPredictate(new FactionEqualsPredictate(this), msgs);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,8 +21,8 @@ import com.massivecraft.mcore.mixin.Mixin;
|
||||
import com.massivecraft.mcore.ps.PS;
|
||||
import com.massivecraft.mcore.ps.PSFormatHumanSpace;
|
||||
import com.massivecraft.mcore.store.SenderEntity;
|
||||
import com.massivecraft.mcore.util.IdUtil;
|
||||
import com.massivecraft.mcore.util.MUtil;
|
||||
import com.massivecraft.mcore.util.SenderUtil;
|
||||
import com.massivecraft.mcore.util.Txt;
|
||||
|
||||
|
||||
@ -74,7 +74,7 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
|
||||
Faction faction = this.getFaction();
|
||||
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
|
||||
@ -87,7 +87,7 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
|
||||
Faction faction = this.getFaction();
|
||||
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
|
||||
// -------------------------------------------- //
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return this.getFixedId();
|
||||
}
|
||||
|
||||
public String getFactionName()
|
||||
{
|
||||
Faction faction = this.getFaction();
|
||||
@ -785,7 +780,7 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
|
||||
}
|
||||
if (MConf.get().logLandClaims)
|
||||
{
|
||||
informees.add(UPlayer.get(SenderUtil.getConsole()));
|
||||
informees.add(UPlayer.get(IdUtil.getConsole()));
|
||||
}
|
||||
|
||||
String chunkString = chunk.toString(PSFormatHumanSpace.get());
|
||||
|
@ -1,12 +1,13 @@
|
||||
package com.massivecraft.factions.entity;
|
||||
|
||||
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.Colls;
|
||||
import com.massivecraft.mcore.store.Entity;
|
||||
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>
|
||||
{
|
||||
@ -29,7 +30,7 @@ public abstract class XColls<C extends Coll<E>, E> extends Colls<C, E>
|
||||
return this.getForUniverse(universe);
|
||||
}
|
||||
|
||||
if (SenderUtil.isNonplayer(o))
|
||||
if ((o instanceof CommandSender) && !(o instanceof Player))
|
||||
{
|
||||
return this.getForWorld(Bukkit.getWorlds().get(0).getName());
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
@ -17,18 +18,18 @@ import org.bukkit.entity.Player;
|
||||
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
ret = new HashSet<Location>();
|
||||
playerLocations.put(playerName, ret);
|
||||
playerLocations.put(uuid, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user