diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/C.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/C.java index bab76df51..cbaa6ea16 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/C.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/C.java @@ -75,6 +75,8 @@ public class C public static String chatAdminHead = "" + ChatColor.DARK_PURPLE; public static String chatAdminBody = "" + ChatColor.LIGHT_PURPLE; + public static String cClansNether = "" + ChatColor.RED; + public static String listTitle = "" + ChatColor.WHITE; public static String listValue = "" + ChatColor.YELLOW; public static String listValueOn = "" + ChatColor.GREEN; diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/F.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/F.java index 998b57d7c..2c06ace26 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/F.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/F.java @@ -215,4 +215,9 @@ public class F ? "an" : "a"; } + public static String clansNether(String word) + { + return C.cClansNether + word + C.mBody; + } + } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java index 978ff1812..ef41e9450 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java @@ -218,7 +218,7 @@ public class UtilAlg return cross(vec, getRight(vec)); } - public static Location getAverageLocation(ArrayList locs) + public static Location getAverageLocation(List locs) { if (locs.isEmpty()) return null; @@ -236,8 +236,27 @@ public class UtilAlg return vec.toLocation(locs.get(0).getWorld()); } + + public static Location getAverageBlockLocation(List locs) + { + if (locs.isEmpty()) + return null; + + Vector vec = new Vector(0,0,0); + double amount = 0; + + for (Block loc : locs) + { + vec.add(loc.getLocation().toVector()); + amount++; + } + + vec.multiply(1d/amount); + + return vec.toLocation(locs.get(0).getWorld()); + } - public static Vector getAverageBump(Location source, ArrayList locs) + public static Vector getAverageBump(Location source, List locs) { if (locs.isEmpty()) return null; @@ -543,20 +562,4 @@ public class UtilAlg return new Location(location.getWorld(), x, location.getY(), z, location.getYaw(), location.getPitch()); } - - public static Location moveForward(Location location, double strength, float yaw, float pitch, boolean reverse) - { - double x = location.getX(); - double y = location.getY(); - double z = location.getZ(); - - double yawAngle = Math.toRadians(yaw); - double pitchAngle = Math.toRadians(pitch); - - x = reverse ? (x + strength * Math.sin(yawAngle)) : (x - strength * Math.sin(yawAngle)); - y = reverse ? (y + strength * Math.sin(pitchAngle)) : (y - strength * Math.sin(pitchAngle)); - z = reverse ? (z - strength * Math.cos(yawAngle)) : (z + strength * Math.cos(yawAngle)); - - return new Location(location.getWorld(), x, y, z); - } } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilCollections.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilCollections.java index b88a66880..f6f7543bc 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilCollections.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilCollections.java @@ -1,7 +1,13 @@ package mineplex.core.common.util; +import java.util.Arrays; import java.util.Collection; +import java.util.List; import java.util.function.Consumer; +import java.util.function.Function; + +import org.bukkit.Location; +import org.bukkit.block.Block; public class UtilCollections { @@ -26,6 +32,45 @@ public class UtilCollections return new NautHashMap(); } + public static T getLast(List list) + { + return list.isEmpty() ? null : list.get(list.size() - 1); + } + + public static T getFirst(List list) + { + return list.isEmpty() ? null : list.get(0); + } + + public static T getLast(NautArrayList list) + { + return list.isEmpty() ? null : list.get(list.size() - 1); + } + + public static T getFirst(NautArrayList list) + { + return list.isEmpty() ? null : list.get(0); + } + + public static void forEach(E[] elements, Function filter, Consumer consumer) + { + for (int i = 0; i < elements.length; i++) + { + consumer.accept(filter.apply(elements[i])); + } + } + + public static void forEachFilter(E[] elements, Function filter, Consumer consumer) + { + for (int i = 0; i < elements.length; i++) + { + if (filter.apply(elements[i]).booleanValue()) + { + consumer.accept(elements[i]); + } + } + } + public static void forEach(E[] elements, Consumer consumer) { for (int i = 0; i < elements.length; i++) @@ -38,6 +83,11 @@ public class UtilCollections { forEach(elements, collection::add); } + + public static void addAll(E[] elements, Function filter, Collection collection) + { + forEachFilter(elements, filter, collection::add); + } public static void loop(int min, int max, Consumer consumer) { @@ -47,4 +97,93 @@ public class UtilCollections } } + public static byte[] ensureSize(byte[] array, int size) + { + if (array.length <= size) + { + return array; + } + + return Arrays.copyOf(array, size); + } + + public static boolean[] ensureSize(boolean[] array, int size) + { + if (array.length <= size) + { + return array; + } + + return Arrays.copyOf(array, size); + } + + public static int[] ensureSize(int[] array, int size) + { + if (array.length <= size) + { + return array; + } + + return Arrays.copyOf(array, size); + } + + public static long[] ensureSize(long[] array, int size) + { + if (array.length <= size) + { + return array; + } + + return Arrays.copyOf(array, size); + } + + public static short[] ensureSize(short[] array, int size) + { + if (array.length <= size) + { + return array; + } + + return Arrays.copyOf(array, size); + } + + public static char[] ensureSize(char[] array, int size) + { + if (array.length <= size) + { + return array; + } + + return Arrays.copyOf(array, size); + } + + public static float[] ensureSize(float[] array, int size) + { + if (array.length <= size) + { + return array; + } + + return Arrays.copyOf(array, size); + } + + public static double[] ensureSize(double[] array, int size) + { + if (array.length <= size) + { + return array; + } + + return Arrays.copyOf(array, size); + } + + public static Object[] ensureSize(Object[] array, int size) + { + if (array.length <= size) + { + return array; + } + + return Arrays.copyOf(array, size); + } } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilFile.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilFile.java new file mode 100644 index 000000000..1a02a7110 --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilFile.java @@ -0,0 +1,54 @@ +package mineplex.core.common.util; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; + +public class UtilFile +{ + public static String read(File file) + { + try + { + return new String(readBytes(file)); + } + catch (IOException e) + { + return null; + } + } + + /** + * @param file + * @return + * @throws IOException + */ + public static byte[] readBytes(File file) throws IOException + { + FileInputStream stream = new FileInputStream(file); + + byte[] bytes = new byte[stream.available() /* estimated bytes available */]; + + int pointer = 0; + while (true) + { + int read = stream.read(); + + if (read == -1) + { + break; + } + + bytes = UtilCollections.ensureSize(bytes, bytes.length + 1); + + bytes[pointer] = (byte) read; + + ++pointer; + } + + stream.close(); + + return bytes; + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/MiniPlugin.java b/Plugins/Mineplex.Core/src/mineplex/core/MiniPlugin.java index 732c13816..863ec5462 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/MiniPlugin.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/MiniPlugin.java @@ -1,5 +1,6 @@ package mineplex.core; +import org.bukkit.Bukkit; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; import org.bukkit.plugin.PluginManager; @@ -100,7 +101,7 @@ public abstract class MiniPlugin implements Listener public void log(String message) { - System.out.println(F.main(_moduleName, message)); + Bukkit.getConsoleSender().sendMessage(F.main(_moduleName, message)); } public void runAsync(Runnable runnable) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/task/TaskManager.java b/Plugins/Mineplex.Core/src/mineplex/core/task/TaskManager.java index 85608613e..0427cb53e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/task/TaskManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/task/TaskManager.java @@ -118,7 +118,7 @@ public class TaskManager extends MiniDbClientPlugin { public void run(Boolean success) { - if (!success) + if (!success.booleanValue()) { System.out.println("Add task FAILED for " + player.getName()); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanTips.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanTips.java index cc941f8fa..4f2c6e166 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanTips.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanTips.java @@ -224,6 +224,11 @@ public class ClanTips extends MiniPlugin C.cDAqua + "Meownon", C.cAqua + "Congratulations on your new purchase! You are now in possesion, of the one, and only, Meownon 3000.24! " + C.Italics + "we are not responsible for any injuries caused by the meownon, or any related products. stay safe kids." }), + ENTER_NETHER( + new String[] { + C.cDAqua + "The Nether", + C.cAqua + "Welcome to the Nether. This is a very scary place full of fire and is a place for people to battle to the death! TODO: Write something better about the nether here" + }), ; // this is only LinkedList because UtilPlayer.message wants it diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDisplay.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDisplay.java index 46f5a3708..284264f3b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDisplay.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDisplay.java @@ -24,13 +24,13 @@ import mineplex.game.clans.core.repository.ClanTerritory; public class ClansDisplay extends MiniPlugin { - private ClansManager Clans; + private ClansManager _clansManager; public ClansDisplay(JavaPlugin plugin, ClansManager clans) { super("Clans Display", plugin); - Clans = clans; + _clansManager = clans; } @EventHandler @@ -46,7 +46,7 @@ public class ClansDisplay extends MiniPlugin { if (player.getWorld().getEnvironment() != Environment.NORMAL) return; - ClientClan client = Clans.Get(player); + ClientClan client = _clansManager.Get(player); if (client == null) return; // Same Chunk @@ -56,16 +56,16 @@ public class ClansDisplay extends MiniPlugin client.setTerritory(UtilWorld.chunkToStr(player.getLocation().getChunk())); // AutoClaim - if (client.isAutoClaim()) Clans.getClanAdmin().claim(player); + if (client.isAutoClaim()) _clansManager.getClanAdmin().claim(player); // Map String owner = "Wilderness"; - ClanInfo ownerClan = Clans.getClanUtility().getOwner(player.getLocation()); + ClanInfo ownerClan = _clansManager.getClanUtility().getOwner(player.getLocation()); if (ownerClan != null) owner = ownerClan.getName(); - boolean safe = Clans.getClanUtility().isSafe(player); + boolean safe = _clansManager.getClanUtility().isSafe(player); - PlayerEnterTerritoryEvent event = new PlayerEnterTerritoryEvent(player, client.getOwner(), owner, owner.equals("Wilderness") ? false : Clans.getClanUtility().getClaim(player.getLocation()).isSafe(player.getLocation()), true); + PlayerEnterTerritoryEvent event = new PlayerEnterTerritoryEvent(player, client.getOwner(), owner, owner.equals("Wilderness") ? false : _clansManager.getClanUtility().getClaim(player.getLocation()).isSafe(player.getLocation()), true); UtilServer.getServer().getPluginManager().callEvent(event); @@ -105,19 +105,26 @@ public class ClansDisplay extends MiniPlugin // Name String ownerString = C.xWilderness + "Wilderness"; - ClanTerritory claim = Clans.getClanUtility().getClaim(player.getLocation()); + ClanTerritory claim = _clansManager.getClanUtility().getClaim(player.getLocation()); if (claim != null) { // Relation - ClanRelation relation = Clans.getClanUtility().relPT(player, claim.Chunk); + ClanRelation relation = _clansManager.getClanUtility().relPT(player, claim.Chunk); // Name - ownerString = Clans.getClanUtility().mRel(relation, claim.Owner, false); + ownerString = _clansManager.getClanUtility().mRel(relation, claim.Owner, false); // Trust if (relation == ClanRelation.ALLY_TRUST) ownerString += " " + C.mBody + "(" + C.mElem + "Trusted" + C.mBody + ")"; } + if (_clansManager.getNetherManager().isInNether(player)) + { + _clansManager.message(player, "You are not allowed to claim territory in " + F.clansNether("The Nether") + "."); + + ownerString = C.cRed + "The Nether"; + } + UtilTextMiddle.display("", ownerString, 0, 25, 10, player); UtilPlayer.message(player, F.main("Territory", ownerString)); } @@ -137,7 +144,7 @@ public class ClansDisplay extends MiniPlugin if (player.getItemInHand().getType() == Material.MAP) { - ClanInfo clan = Clans.getClanUtility().getClanByPlayer(player); + ClanInfo clan = _clansManager.getClanUtility().getClanByPlayer(player); if (clan != null) if (clan.getHome() != null) home = mLocalMap(player, clan.getHome().getChunk(), false); } @@ -177,14 +184,14 @@ public class ClansDisplay extends MiniPlugin } // Get Data - ClanInfo curOwner = Clans.getClanUtility().getOwner(UtilWorld.chunkToStr(curChunk)); - ClanTerritory curClaim = Clans.getClanUtility().getClaim(UtilWorld.chunkToStr(curChunk)); + ClanInfo curOwner = _clansManager.getClanUtility().getOwner(UtilWorld.chunkToStr(curChunk)); + ClanTerritory curClaim = _clansManager.getClanUtility().getClaim(UtilWorld.chunkToStr(curChunk)); // Add Icon if (i == chunk.getX() && j == chunk.getZ()) - output += getMapIcon(Clans.getClanUtility().relPC(player, curOwner), curClaim, curOwner, curChunk, pCount, true, local); + output += getMapIcon(_clansManager.getClanUtility().relPC(player, curOwner), curClaim, curOwner, curChunk, pCount, true, local); else - output += getMapIcon(Clans.getClanUtility().relPC(player, curOwner), curClaim, curOwner, curChunk, pCount, false, local); + output += getMapIcon(_clansManager.getClanUtility().relPC(player, curOwner), curClaim, curOwner, curChunk, pCount, false, local); } output += ">"; @@ -236,7 +243,7 @@ public class ClansDisplay extends MiniPlugin { if (players > 0) return "" + C.xSelf + players; - else if (Clans.getClanUtility().isChunkHome(owner, chunk)) + else if (_clansManager.getClanUtility().isChunkHome(owner, chunk)) return "" + C.xSelf + "H"; else return "" + C.xSelf + "#"; @@ -246,7 +253,7 @@ public class ClansDisplay extends MiniPlugin { if (players > 0) return "" + C.xAlly + players; - else if (Clans.getClanUtility().isChunkHome(owner, chunk)) + else if (_clansManager.getClanUtility().isChunkHome(owner, chunk)) return "" + C.xAlly + "H"; else return "" + C.xAlly + "#"; @@ -256,7 +263,7 @@ public class ClansDisplay extends MiniPlugin { if (players > 0) return "" + C.xdAlly + players; - else if (Clans.getClanUtility().isChunkHome(owner, chunk)) + else if (_clansManager.getClanUtility().isChunkHome(owner, chunk)) return "" + C.xdAlly + "H"; else return "" + C.xdAlly + "#"; @@ -264,7 +271,7 @@ public class ClansDisplay extends MiniPlugin if (players > 0) return "" + C.xEnemy + players; - else if (Clans.getClanUtility().isChunkHome(owner, chunk)) + else if (_clansManager.getClanUtility().isChunkHome(owner, chunk)) return "" + C.xEnemy + "H"; else return "" + C.xEnemy + "#"; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index ff4aa3648..fdd9d2293 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -84,6 +84,7 @@ import mineplex.game.clans.clans.event.ClansPlayerDeathEvent; import mineplex.game.clans.clans.gui.ClanShop; import mineplex.game.clans.clans.loot.LootManager; import mineplex.game.clans.clans.map.ItemMapManager; +import mineplex.game.clans.clans.nether.NetherManager; import mineplex.game.clans.clans.observer.ObserverManager; import mineplex.game.clans.clans.playtime.Playtime; import mineplex.game.clans.clans.potato.PotatoManager; @@ -162,6 +163,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati private GearManager _gearManager; private LootManager _lootManager; private DonationManager _donationManager; + private NetherManager _netherManager; private Playtime _playTracker; @@ -384,6 +386,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "Replay|Restrict"); new SiegeManager(this); + _netherManager = new NetherManager(this); } @Override @@ -1180,4 +1183,19 @@ public class ClansManager extends MiniClientPluginimplements IRelati { return _clanDataAccess.getRepository().getServerId(); } + + public NetherManager getNetherManager() + { + return _netherManager; + } + + public void message(Player player, String message) + { + UtilPlayer.message(player, F.main("Clans", message)); + } + + public boolean masterBypass(Player player) + { + return player.getName().equals("NewGarbo"); + } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java index a57f0470e..33cabdc98 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java @@ -28,11 +28,11 @@ import mineplex.game.clans.spawn.Spawn; public class ClansUtility { - private ClansManager Clans; + private ClansManager _clansManager; public ClansUtility(ClansManager clans) { - Clans = clans; + _clansManager = clans; } public enum ClanRelation @@ -115,7 +115,7 @@ public class ClansUtility // CLAN LinkedList clanMatchList = new LinkedList(); - for (ClanInfo cur : Clans.getClanMap().values()) + for (ClanInfo cur : _clansManager.getClanMap().values()) { if (cur.getName().equalsIgnoreCase(name)) return cur; @@ -135,7 +135,7 @@ public class ClansUtility // PLAYER LinkedList playerMatchList = new LinkedList(); - for (ClanInfo clanInfo : Clans.getClanMap().values()) + for (ClanInfo clanInfo : _clansManager.getClanMap().values()) { for (ClansPlayer player : clanInfo.getMembers().values()) { @@ -158,10 +158,10 @@ public class ClansUtility if (inform) { - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clan Search", "" + C.mCount + (clanMatchList.size() + playerMatchList.size()) + C.mBody + " matches for [" + C.mElem + name + C.mBody + "].")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clan Search", "" + C.mCount + (clanMatchList.size() + playerMatchList.size()) + C.mBody + " matches for [" + C.mElem + name + C.mBody + "].")); - Clans.getTutorials().sendTutorialMsg(caller, F.desc("Matches via Clan", clanMatchString)); - Clans.getTutorials().sendTutorialMsg(caller, F.desc("Matches via Player", playerMatchString)); + _clansManager.getTutorials().sendTutorialMsg(caller, F.desc("Matches via Clan", clanMatchString)); + _clansManager.getTutorials().sendTutorialMsg(caller, F.desc("Matches via Player", playerMatchString)); } return null; @@ -171,7 +171,7 @@ public class ClansUtility { LinkedList matchList = new LinkedList(); - for (ClanInfo cur : Clans.getClanMap().values()) + for (ClanInfo cur : _clansManager.getClanMap().values()) { if (cur.getName().equalsIgnoreCase(name)) return cur; @@ -184,7 +184,7 @@ public class ClansUtility if (!inform) return null; // Inform - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clan Search", "" + C.mCount + matchList.size() + C.mBody + " matches for [" + C.mElem + name + C.mBody + "].")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clan Search", "" + C.mCount + matchList.size() + C.mBody + " matches for [" + C.mElem + name + C.mBody + "].")); if (matchList.size() > 0) { @@ -192,7 +192,7 @@ public class ClansUtility for (ClanInfo cur : matchList) matchString += cur.getName() + " "; - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clan Search", "" + C.mBody + " Matches [" + C.mElem + matchString + C.mBody + "].")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clan Search", "" + C.mBody + " Matches [" + C.mElem + matchString + C.mBody + "].")); } return null; @@ -203,12 +203,12 @@ public class ClansUtility public ClanInfo getClanByClanName(String clan) { - return Clans.getClan(clan); + return _clansManager.getClan(clan); } public ClanInfo getClanById(int id) { - for (ClanInfo clan : Clans.getClanMap().values()) + for (ClanInfo clan : _clansManager.getClanMap().values()) { if (clan.getId() == id) { @@ -226,7 +226,7 @@ public class ClansUtility public ClanInfo getClanByUUID(UUID uuid) { - return Clans.getClanMemberUuidMap().get(uuid); + return _clansManager.getClanMemberUuidMap().get(uuid); } // @Deprecated @@ -252,16 +252,16 @@ public class ClansUtility public boolean isSafe(Player player) { - if (!UtilTime.elapsed(Clans.getCombatManager().Get(player).GetLastDamaged(), Spawn.COMBAT_TAG_DURATION)) return false; + if (!UtilTime.elapsed(_clansManager.getCombatManager().Get(player).GetLastDamaged(), Spawn.COMBAT_TAG_DURATION)) return false; return isSafe(player.getLocation()); } public boolean isSafe(Location loc) { - if (!Clans.getClaimMap().containsKey(UtilWorld.chunkToStr(loc.getChunk()))) return false; + if (!_clansManager.getClaimMap().containsKey(UtilWorld.chunkToStr(loc.getChunk()))) return false; - return Clans.getClaimMap().get(UtilWorld.chunkToStr(loc.getChunk())).isSafe(loc); + return _clansManager.getClaimMap().get(UtilWorld.chunkToStr(loc.getChunk())).isSafe(loc); } public boolean isChunkHome(ClanInfo clan, Chunk chunk) @@ -276,7 +276,7 @@ public class ClansUtility public ClanTerritory getClaim(Chunk chunk) { String chunkTag = UtilWorld.chunkToStr(chunk); - return Clans.getClaimMap().get(chunkTag); + return _clansManager.getClaimMap().get(chunkTag); } /** @@ -294,7 +294,7 @@ public class ClansUtility public ClanTerritory getClaim(String chunk) { - return Clans.getClaimMap().get(chunk); + return _clansManager.getClaimMap().get(chunk); } public ClanInfo getOwner(String chunk) @@ -361,7 +361,7 @@ public class ClansUtility { String chunk = UtilWorld.chunkToStr(loc.getChunk()); - return Clans.getClaimMap().containsKey(chunk); + return _clansManager.getClaimMap().containsKey(chunk); } // public boolean isAlliance(String player, Location loc) @@ -378,7 +378,7 @@ public class ClansUtility public boolean isSelf(Player player, Location loc) { - ClanInfo clan = Clans.getClan(player); + ClanInfo clan = _clansManager.getClan(player); if (clan == null) return false; @@ -408,9 +408,9 @@ public class ClansUtility ClanInfo owner = getOwner(loc); ClanInfo clan = getClanByPlayer(player); - String mimic = Clans.Get(player).getMimic(); + String mimic = _clansManager.Get(player).getMimic(); - if (mimic.length() != 0) clan = Clans.getClanUtility().searchClanPlayer(player, mimic, false); + if (mimic.length() != 0) clan = _clansManager.getClanUtility().searchClanPlayer(player, mimic, false); if (owner == null) return ClanRelation.SELF; @@ -566,38 +566,38 @@ public class ClansUtility public void join(final Player caller, final ClanInfo clanInfo) { - if (Clans.getClanMemberUuidMap().containsKey(caller.getUniqueId())) + if (_clansManager.getClanMemberUuidMap().containsKey(caller.getUniqueId())) { - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are already in a Clan.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are already in a Clan.")); return; } - if (!Clans.Get(caller).canJoin()) + if (!_clansManager.Get(caller).canJoin()) { - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot join a Clan for " + C.mTime + UtilTime.convertString(System.currentTimeMillis() - Clans.Get(caller).getDelay(), 1, UtilTime.TimeUnit.FIT) + C.mBody + ".")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot join a Clan for " + C.mTime + UtilTime.convertString(System.currentTimeMillis() - _clansManager.Get(caller).getDelay(), 1, UtilTime.TimeUnit.FIT) + C.mBody + ".")); return; } if (clanInfo == null) { - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Error: Clan does not exist")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Error: Clan does not exist")); return; } if (!clanInfo.isInvited(caller.getName())) { - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not invited to " + F.elem("Clan " + clanInfo.getName()) + ".")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not invited to " + F.elem("Clan " + clanInfo.getName()) + ".")); return; } if (clanInfo.getSize() >= clanInfo.getMaxSize()) { - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "The clan " + F.elem("Clan " + clanInfo.getName()) + " is full and cannot be joined!")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "The clan " + F.elem("Clan " + clanInfo.getName()) + " is full and cannot be joined!")); return; } // Task - Clans.getClanDataAccess().join(clanInfo, caller, ClanRole.RECRUIT, new Callback() + _clansManager.getClanDataAccess().join(clanInfo, caller, ClanRole.RECRUIT, new Callback() { @Override public void run(Boolean data) @@ -605,12 +605,12 @@ public class ClansUtility if (data) { // Inform - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You joined " + F.elem("Clan " + clanInfo.getName()) + ".")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You joined " + F.elem("Clan " + clanInfo.getName()) + ".")); clanInfo.inform(F.name(caller.getName()) + " has joined your Clan.", caller.getName()); } else { - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "There was an error processing your request")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "There was an error processing your request")); } } }); @@ -623,13 +623,13 @@ public class ClansUtility if (clan == null) { - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); return; } if (clan.getMembers().get(caller.getUniqueId()).getRole() == ClanRole.LEADER && clan.getMembers().size() > 1) { - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You must pass on " + F.elem("Leadership") + " before leaving.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You must pass on " + F.elem("Leadership") + " before leaving.")); return; } @@ -637,13 +637,13 @@ public class ClansUtility if (clan.getMembers().size() > 1) { // Task - Clans.getClanDataAccess().leave(clan, caller, new Callback() + _clansManager.getClanDataAccess().leave(clan, caller, new Callback() { @Override public void run(Boolean data) { // Inform - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You left " + F.elem("Clan " + clan.getName()) + ".")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You left " + F.elem("Clan " + clan.getName()) + ".")); clan.inform(F.name(caller.getName()) + " has left your Clan.", null); clan.left(caller.getName()); @@ -662,13 +662,13 @@ public class ClansUtility if (clan == null) { - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); return; } if (getRole(caller) != ClanRole.LEADER) { - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Only the Clan Leader can disband the Clan.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Only the Clan Leader can disband the Clan.")); return; } @@ -681,21 +681,21 @@ public class ClansUtility return; } - Clans.messageClan(clan, C.cYellow + caller.getName() + C.cGray + " has disbanded the Clan."); + _clansManager.messageClan(clan, C.cYellow + caller.getName() + C.cGray + " has disbanded the Clan."); // Task - Clans.getClanDataAccess().delete(clan, new Callback() + _clansManager.getClanDataAccess().delete(clan, new Callback() { @Override public void run(Boolean data) { - if (!data) + if (!data.booleanValue()) { - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "There was an error processing your request. Try again later")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "There was an error processing your request. Try again later")); } else { - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You disbanded your Clan.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You disbanded your Clan.")); } } }); @@ -714,28 +714,28 @@ public class ClansUtility { return false; } - + if (clan == null) { - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); return false; } if (clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER && clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.ADMIN) { - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Only the Clan Leader and Admins can claim Territory.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Only the Clan Leader and Admins can claim Territory.")); return false; } if (!ClansManager.isClaimable(caller.getLocation())) { - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot claim territory at this location!")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot claim territory at this location!")); return false; } if (clan.getEnergy() == 0) { - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You must purchase energy at a shop before you can claim land.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You must purchase energy at a shop before you can claim land.")); return false; } @@ -751,14 +751,14 @@ public class ClansUtility } else { - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "This Territory is owned by " + mRel(Clans.getClanUtility().relPC(caller, ownerClan), ownerClan.getName(), true) + ".")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "This Territory is owned by " + mRel(_clansManager.getClanUtility().relPC(caller, ownerClan), ownerClan.getName(), true) + ".")); return false; } } if (clan.getClaims() >= clan.getClaimsMax()) { - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Your Clan cannot claim more Territory.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Your Clan cannot claim more Territory.")); return false; } @@ -784,8 +784,8 @@ public class ClansUtility if (checkBox(caller.getWorld().getChunkAt(caller.getLocation().getChunk().getX() + x, caller.getLocation().getChunk().getZ() + z), 3)) { - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot claim this Territory, it causes a box.")); - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "This means a Territory has all sides claimed.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot claim this Territory, it causes a box.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "This means a Territory has all sides claimed.")); return false; } @@ -795,7 +795,7 @@ public class ClansUtility } else if (rel(clan, adjClan) != ClanRelation.SELF) { - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot claim Territory next to " + mRel(rel(ownerClan, adjClan), adjClan.getName(), true) + ".")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot claim Territory next to " + mRel(rel(ownerClan, adjClan), adjClan.getName(), true) + ".")); return false; } } @@ -804,36 +804,36 @@ public class ClansUtility // Boxed if (checkBox(caller.getLocation().getChunk(), 4)) { - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot claim this Territory, it causes a box.")); - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "This means a Territory has all sides claimed.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot claim this Territory, it causes a box.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "This means a Territory has all sides claimed.")); return false; } if (isNearAdminClaim(caller.getLocation())) { - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot claim so close to administrative territory!")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot claim so close to administrative territory!")); return false; } // Not Next to Self if (!selfAdj && !clan.getClaimSet().isEmpty()) { - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You must claim next to your other Territory.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You must claim next to your other Territory.")); return false; } // Claim Timer - if (Clans.getUnclaimMap().containsKey(chunk)) + if (_clansManager.getUnclaimMap().containsKey(chunk)) { - if (!UtilTime.elapsed(Clans.getUnclaimMap().get(chunk), Clans.getReclaimTime())) + if (!UtilTime.elapsed(_clansManager.getUnclaimMap().get(chunk).longValue(), _clansManager.getReclaimTime())) { - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "This Territory cannot be claimed for " + F.time(UtilTime.convertString(Clans.getReclaimTime() - (System.currentTimeMillis() - Clans.getUnclaimMap().get(chunk)), 1, UtilTime.TimeUnit.FIT)) + ".")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "This Territory cannot be claimed for " + F.time(UtilTime.convertString(_clansManager.getReclaimTime() - (System.currentTimeMillis() - _clansManager.getUnclaimMap().get(chunk).longValue()), 1, UtilTime.TimeUnit.FIT)) + ".")); return false; } else { - Clans.getUnclaimMap().remove(chunk); + _clansManager.getUnclaimMap().remove(chunk); } } @@ -842,7 +842,7 @@ public class ClansUtility { if (UtilMath.offset(cur, caller) < 16) if (playerEnemy(caller, cur)) { - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot claim while enemies are nearby.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot claim while enemies are nearby.")); return false; } } @@ -861,10 +861,10 @@ public class ClansUtility } // Task - Clans.getClanDataAccess().claim(clan.getName(), chunk, caller.getName(), false); + _clansManager.getClanDataAccess().claim(clan.getName(), chunk, caller.getName(), false); // Inform - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You claimed Territory " + F.elem(UtilWorld.chunkToStrClean(caller.getLocation().getChunk())) + ".")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You claimed Territory " + F.elem(UtilWorld.chunkToStrClean(caller.getLocation().getChunk())) + ".")); clan.inform(F.name(caller.getName()) + " claimed Territory " + F.elem(UtilWorld.chunkToStrClean(caller.getLocation().getChunk())) + ".", caller.getName()); return true; @@ -895,19 +895,19 @@ public class ClansUtility public boolean unclaimSteal(Player caller, ClanInfo clientClan, ClanInfo ownerClan) { - if (!Clans.canUnclaimChunk(clientClan, ownerClan)) + if (!_clansManager.canUnclaimChunk(clientClan, ownerClan)) { return false; } // Change Inform - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You can no longer 'steal' territory. " + "You simply unclaim it and it can not be reclaimed by anyone for 30 mintes." + "This was done to improve gameplay. Enjoy!")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You can no longer 'steal' territory. " + "You simply unclaim it and it can not be reclaimed by anyone for 30 mintes." + "This was done to improve gameplay. Enjoy!")); // Inform UtilServer.broadcast(F.main("Clans", F.elem(clientClan.getName()) + " unclaimed from " + F.elem(ownerClan.getName()) + " at " + F.elem(UtilWorld.locToStrClean(caller.getLocation())) + ".")); // Unclaim - Clans.getClanDataAccess().unclaim(UtilWorld.chunkToStr(caller.getLocation().getChunk()), caller.getName(), true); + _clansManager.getClanDataAccess().unclaim(UtilWorld.chunkToStr(caller.getLocation().getChunk()), caller.getName(), true); return true; } @@ -918,7 +918,7 @@ public class ClansUtility if (clan == null) { - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); return; } @@ -929,13 +929,13 @@ public class ClansUtility if (target.equals(caller.getName())) { - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot promote yourself.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot promote yourself.")); return; } if (self.getRole().ordinal() <= target.getRole().ordinal()) { - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You do not outrank " + F.name(other) + ".")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You do not outrank " + F.name(other) + ".")); return; } @@ -943,21 +943,21 @@ public class ClansUtility String newRank = "?"; if (target.getRole() == ClanRole.RECRUIT) { - Clans.getClanDataAccess().role(clan, target.getUuid(), ClanRole.MEMBER); + _clansManager.getClanDataAccess().role(clan, target.getUuid(), ClanRole.MEMBER); newRank = "Member"; } else if (target.getRole() == ClanRole.MEMBER) { - Clans.getClanDataAccess().role(clan, target.getUuid(), ClanRole.ADMIN); + _clansManager.getClanDataAccess().role(clan, target.getUuid(), ClanRole.ADMIN); newRank = "Admin"; } else if (target.getRole() == ClanRole.ADMIN) { - Clans.getClanDataAccess().role(clan, target.getUuid(), ClanRole.LEADER); + _clansManager.getClanDataAccess().role(clan, target.getUuid(), ClanRole.LEADER); newRank = "Leader"; // Give Leader - Clans.getClanDataAccess().role(clan, caller.getUniqueId(), ClanRole.ADMIN); + _clansManager.getClanDataAccess().role(clan, caller.getUniqueId(), ClanRole.ADMIN); } // Inform @@ -970,7 +970,7 @@ public class ClansUtility if (clan == null) { - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); return; } @@ -981,19 +981,19 @@ public class ClansUtility if (target.equals(caller.getName())) { - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot demote yourself.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot demote yourself.")); return; } if (self.getRole().ordinal() <= target.getRole().ordinal()) { - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You do not outrank " + F.name(other) + ".")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You do not outrank " + F.name(other) + ".")); return; } if (target.getRole() == ClanRole.RECRUIT) { - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot demote " + F.name(other) + " any further.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot demote " + F.name(other) + " any further.")); return; } @@ -1001,12 +1001,12 @@ public class ClansUtility String newRank = "?"; if (target.getRole() == ClanRole.MEMBER) { - Clans.getClanDataAccess().role(clan, target.getUuid(), ClanRole.RECRUIT); + _clansManager.getClanDataAccess().role(clan, target.getUuid(), ClanRole.RECRUIT); newRank = "Recruit"; } else if (target.getRole() == ClanRole.ADMIN) { - Clans.getClanDataAccess().role(clan, target.getUuid(), ClanRole.MEMBER); + _clansManager.getClanDataAccess().role(clan, target.getUuid(), ClanRole.MEMBER); newRank = "Member"; } @@ -1020,7 +1020,7 @@ public class ClansUtility if (clan == null) { - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); return; } @@ -1031,20 +1031,20 @@ public class ClansUtility if (self.getRole() != ClanRole.LEADER && self.getRole() != ClanRole.ADMIN) { - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Only the Clan Leader and Admins can kick members.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Only the Clan Leader and Admins can kick members.")); return; } if (clansPlayer.getRole() == ClanRole.LEADER) { - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Clan leaders cannot be kicked.")); - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "To disband a clan, use /c disband")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Clan leaders cannot be kicked.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "To disband a clan, use /c disband")); return; } if ((clansPlayer.getRole() == ClanRole.LEADER && self.getRole() == ClanRole.ADMIN) || (clansPlayer.getRole() == ClanRole.ADMIN && self.getRole() == ClanRole.ADMIN)) { - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You do not outrank " + F.name(other) + ".")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You do not outrank " + F.name(other) + ".")); return; } @@ -1056,17 +1056,17 @@ public class ClansUtility public void run(Boolean data) { // Inform - if (player != null) Clans.getTutorials().sendTutorialMsg(player, F.main("Clans", F.name(caller.getName()) + " kicked you from " + F.elem("Clan " + clan.getName()) + ".")); - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You kicked " + F.name(other) + " from your Clan.")); + if (player != null) _clansManager.getTutorials().sendTutorialMsg(player, F.main("Clans", F.name(caller.getName()) + " kicked you from " + F.elem("Clan " + clan.getName()) + ".")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You kicked " + F.name(other) + " from your Clan.")); clan.inform(F.main("Clans", F.name(caller.getName()) + " kicked " + F.name(other) + " from your Clan."), caller.getName()); } }; // Task if (player != null) - Clans.getClanDataAccess().leave(clan, player, callback); + _clansManager.getClanDataAccess().leave(clan, player, callback); else - Clans.getClanDataAccess().leave(clan, clansPlayer, callback); + _clansManager.getClanDataAccess().leave(clan, clansPlayer, callback); } public boolean unclaim(final Player caller, final Chunk c) @@ -1075,7 +1075,7 @@ public class ClansUtility if (clan == null) { - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); return false; } @@ -1088,14 +1088,14 @@ public class ClansUtility // Role if (clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER && clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.ADMIN) { - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Only the Clan Leader and Admins can unclaim Territory.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Only the Clan Leader and Admins can unclaim Territory.")); return false; } // Not Claimed if (ownerClan == null || !ownerClan.equals(clan)) { - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "This Territory is not owned by you.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "This Territory is not owned by you.")); return false; } @@ -1110,10 +1110,10 @@ public class ClansUtility } // Task - Clans.getClanDataAccess().unclaim(chunk, caller.getName(), true); + _clansManager.getClanDataAccess().unclaim(chunk, caller.getName(), true); // Inform - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You unclaimed Territory " + F.elem(UtilWorld.chunkToStrClean(caller.getLocation().getChunk())) + ".")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You unclaimed Territory " + F.elem(UtilWorld.chunkToStrClean(caller.getLocation().getChunk())) + ".")); clan.inform(F.name(caller.getName()) + " unclaimed Territory " + F.elem(UtilWorld.chunkToStrClean(caller.getLocation().getChunk())) + ".", caller.getName()); return true; @@ -1125,13 +1125,13 @@ public class ClansUtility if (clan == null) { - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); return false; } if (clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER) { - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Only the Clan Leader can unclaim all Territory.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Only the Clan Leader can unclaim all Territory.")); return false; } @@ -1145,11 +1145,11 @@ public class ClansUtility for (String chunk : toUnclaim) { - Clans.getClanDataAccess().unclaim(chunk, caller.getName(), true); + _clansManager.getClanDataAccess().unclaim(chunk, caller.getName(), true); } // Inform - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You unclaimed all your Clans Territory.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You unclaimed all your Clans Territory.")); clan.inform(F.name(caller.getName()) + " unclaimed all your Clans Territory.", caller.getName()); return true; @@ -1159,24 +1159,24 @@ public class ClansUtility { if (clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER && clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.ADMIN) { - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Only the Clan Leader and Admins can send invites.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Only the Clan Leader and Admins can send invites.")); return; } if (target.getName().equals(caller.getName())) { - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot invite yourself.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot invite yourself.")); return; } // Inform clan.inform(F.name(caller.getName()) + " invited " + F.name(target.getName()) + " to join your Clan.", caller.getName()); - Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You invited " + F.name(target.getName()) + " to join your Clan.")); - Clans.getTutorials().sendTutorialMsg(target, F.main("Clans", F.name(caller.getName()) + " invited you to join " + F.elem("Clan " + clan.getName()) + ".")); - Clans.getTutorials().sendTutorialMsg(target, F.main("Clans", "Type " + F.elem("/c join " + clan.getName()) + " to accept!")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You invited " + F.name(target.getName()) + " to join your Clan.")); + _clansManager.getTutorials().sendTutorialMsg(target, F.main("Clans", F.name(caller.getName()) + " invited you to join " + F.elem("Clan " + clan.getName()) + ".")); + _clansManager.getTutorials().sendTutorialMsg(target, F.main("Clans", "Type " + F.elem("/c join " + clan.getName()) + " to accept!")); // Task - Clans.getClanDataAccess().invite(clan, target.getName(), caller.getName()); + _clansManager.getClanDataAccess().invite(clan, target.getName(), caller.getName()); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/Test.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/Test.java index 46daab300..8b3dde1d7 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/Test.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/Test.java @@ -1,23 +1,16 @@ package mineplex.game.clans.clans; -import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; import java.io.IOException; -public class Test { +import org.bukkit.Location; + +import mineplex.core.common.util.UtilWorld; + +public class Test +{ public static void main(String[] args) throws IOException { - ByteArrayOutputStream stream = new ByteArrayOutputStream(); - DataOutputStream dos = new DataOutputStream(stream); - - dos.writeByte(91); - dos.flush(); - stream.flush(); - - System.out.println(new String(stream.toByteArray())); - - dos.close(); - stream.close(); + System.out.println(UtilWorld.locToStr(new Location(null, 30, 30, 30))); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java index ee20486a9..176320170 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java @@ -43,12 +43,12 @@ import net.minecraft.server.v1_8_R3.EnumDirection; public class ClansCommand extends CommandBase { - private ClansManager _manager; + private ClansManager _clansManager; public ClansCommand(ClansManager plugin) { super(plugin, Rank.ALL, "c", "clan", "clans", "factions"); - _manager = plugin; + _clansManager = plugin; } @Override @@ -56,7 +56,7 @@ public class ClansCommand extends CommandBase { if (args == null || args.length == 0) { - _manager.getClanShop().attemptShopOpen(caller); + _clansManager.getClanShop().attemptShopOpen(caller); return; } @@ -140,7 +140,7 @@ public class ClansCommand extends CommandBase { if (!Plugin.getClientManager().hasRank(caller, Rank.ADMIN) && !caller.getUniqueId().toString().equals("d8646a35-33a8-43c6-9e7c-2e871a6b86c9") /* My UUID (NewGarbo) */) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "This requires ADMIN+ permission.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "This requires ADMIN+ permission.")); return; } @@ -150,18 +150,18 @@ public class ClansCommand extends CommandBase if (clan != null) { - _manager.getClanUtility().join(caller, clan); - _manager.getClanDataAccess().role(clan, caller.getUniqueId(), ClanRole.LEADER); - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You have successfully joined " + F.elem(clan.getName()) + " and are now Leader Role.")); + _clansManager.getClanUtility().join(caller, clan); + _clansManager.getClanDataAccess().role(clan, caller.getUniqueId(), ClanRole.LEADER); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You have successfully joined " + F.elem(clan.getName()) + " and are now Leader Role.")); } else { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Clan provided does not exist.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Clan provided does not exist.")); } } else { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "No clan provided.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "No clan provided.")); } } @@ -170,7 +170,7 @@ public class ClansCommand extends CommandBase if (args.length == 0) { Plugin.Get(caller).setClanChat(!Plugin.Get(caller).isClanChat()); - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Clan Chat: " + F.oo(Plugin.Get(caller).isClanChat()))); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Clan Chat: " + F.oo(Plugin.Get(caller).isClanChat()))); return; } @@ -179,7 +179,7 @@ public class ClansCommand extends CommandBase { ClanInfo clan = Plugin.getClanUtility().getClanByPlayer(caller); if (clan == null) - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); else Plugin.chatClan(clan, caller, F.combine(args, 0, null, false)); } @@ -190,7 +190,7 @@ public class ClansCommand extends CommandBase if (args.length == 0) { Plugin.Get(caller).setAllyChat(!Plugin.Get(caller).isAllyChat()); - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Ally Chat: " + F.oo(Plugin.Get(caller).isAllyChat()))); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Ally Chat: " + F.oo(Plugin.Get(caller).isAllyChat()))); return; } @@ -199,7 +199,7 @@ public class ClansCommand extends CommandBase { ClanInfo clan = Plugin.getClanUtility().getClanByPlayer(caller); if (clan == null) - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); else Plugin.chatAlly(clan, caller, F.combine(args, 0, null, false)); } @@ -215,32 +215,32 @@ public class ClansCommand extends CommandBase return; } - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Commands List;")); - _manager.getTutorials().sendTutorialMsg(caller, F.help("/c create ", "Create new Clan", Rank.ALL)); - _manager.getTutorials().sendTutorialMsg(caller, F.help("/c join ", "Join a Clan", Rank.ALL)); - _manager.getTutorials().sendTutorialMsg(caller, F.help("/c leave ", "Leave your Clan", Rank.ALL)); - _manager.getTutorials().sendTutorialMsg(caller, F.help("/c map ", "View Clan Map", Rank.ALL)); - _manager.getTutorials().sendTutorialMsg(caller, F.help("/cc (Message)", "Clan Chat (Toggle)", Rank.ALL)); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Commands List;")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.help("/c create ", "Create new Clan", Rank.ALL)); + _clansManager.getTutorials().sendTutorialMsg(caller, F.help("/c join ", "Join a Clan", Rank.ALL)); + _clansManager.getTutorials().sendTutorialMsg(caller, F.help("/c leave ", "Leave your Clan", Rank.ALL)); + _clansManager.getTutorials().sendTutorialMsg(caller, F.help("/c map ", "View Clan Map", Rank.ALL)); + _clansManager.getTutorials().sendTutorialMsg(caller, F.help("/cc (Message)", "Clan Chat (Toggle)", Rank.ALL)); - _manager.getTutorials().sendTutorialMsg(caller, F.help("/c stuck", "Teleports you to the nearest Wilderness location", Rank.ALL)); + _clansManager.getTutorials().sendTutorialMsg(caller, F.help("/c stuck", "Teleports you to the nearest Wilderness location", Rank.ALL)); - _manager.getTutorials().sendTutorialMsg(caller, F.help("/c promote ", "Promote Player in Clan", Rank.MODERATOR)); - _manager.getTutorials().sendTutorialMsg(caller, F.help("/c demote ", "Demote Player in Clan", Rank.MODERATOR)); + _clansManager.getTutorials().sendTutorialMsg(caller, F.help("/c promote ", "Promote Player in Clan", Rank.MODERATOR)); + _clansManager.getTutorials().sendTutorialMsg(caller, F.help("/c demote ", "Demote Player in Clan", Rank.MODERATOR)); - _manager.getTutorials().sendTutorialMsg(caller, F.help("/c home (set)", "Teleport to Clan Home", Rank.MODERATOR)); + _clansManager.getTutorials().sendTutorialMsg(caller, F.help("/c home (set)", "Teleport to Clan Home", Rank.MODERATOR)); - _manager.getTutorials().sendTutorialMsg(caller, F.help("/c invite ", "Invite Player to Clan", Rank.ADMIN)); - _manager.getTutorials().sendTutorialMsg(caller, F.help("/c kick ", "Kick Player from Clan", Rank.ADMIN)); - _manager.getTutorials().sendTutorialMsg(caller, F.help("/c neutral ", "Request Neutrality with Clan", Rank.ADMIN)); - _manager.getTutorials().sendTutorialMsg(caller, F.help("/c enemy ", "Declare ClanWar with Clan", Rank.ADMIN)); - _manager.getTutorials().sendTutorialMsg(caller, F.help("/c ally ", "Send Alliance to Clan", Rank.ADMIN)); - _manager.getTutorials().sendTutorialMsg(caller, F.help("/c trust ", "Give Trust to Clan", Rank.ADMIN)); - _manager.getTutorials().sendTutorialMsg(caller, F.help("/c claim", "Claim Territory", Rank.ADMIN)); - _manager.getTutorials().sendTutorialMsg(caller, F.help("/c unclaim (all)", "Unclaim Territory", Rank.ADMIN)); + _clansManager.getTutorials().sendTutorialMsg(caller, F.help("/c invite ", "Invite Player to Clan", Rank.ADMIN)); + _clansManager.getTutorials().sendTutorialMsg(caller, F.help("/c kick ", "Kick Player from Clan", Rank.ADMIN)); + _clansManager.getTutorials().sendTutorialMsg(caller, F.help("/c neutral ", "Request Neutrality with Clan", Rank.ADMIN)); + _clansManager.getTutorials().sendTutorialMsg(caller, F.help("/c enemy ", "Declare ClanWar with Clan", Rank.ADMIN)); + _clansManager.getTutorials().sendTutorialMsg(caller, F.help("/c ally ", "Send Alliance to Clan", Rank.ADMIN)); + _clansManager.getTutorials().sendTutorialMsg(caller, F.help("/c trust ", "Give Trust to Clan", Rank.ADMIN)); + _clansManager.getTutorials().sendTutorialMsg(caller, F.help("/c claim", "Claim Territory", Rank.ADMIN)); + _clansManager.getTutorials().sendTutorialMsg(caller, F.help("/c unclaim (all)", "Unclaim Territory", Rank.ADMIN)); - _manager.getTutorials().sendTutorialMsg(caller, F.help("/c delete", "Delete your Clan", Rank.OWNER)); + _clansManager.getTutorials().sendTutorialMsg(caller, F.help("/c delete", "Delete your Clan", Rank.OWNER)); - _manager.getTutorials().sendTutorialMsg(caller, F.help("/c ", "View Clan Information", Rank.ALL)); + _clansManager.getTutorials().sendTutorialMsg(caller, F.help("/c ", "View Clan Information", Rank.ALL)); } public void create(final Player caller, final String[] args) @@ -251,13 +251,13 @@ public class ClansCommand extends CommandBase if (Plugin.getClanMemberUuidMap().containsKey(caller.getUniqueId())) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are already in a Clan.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are already in a Clan.")); return; } if (Plugin.leftRecently(caller.getUniqueId(), 5 * 60 * 1000) != null) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot create a Clan for " + C.mTime + UtilTime.MakeStr(Plugin.leftRecently(caller.getUniqueId(), 20 * 60 * 1000).getRight()) + C.mBody + ".")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot create a Clan for " + C.mTime + UtilTime.MakeStr(Plugin.leftRecently(caller.getUniqueId(), 20 * 60 * 1000).getRight()) + C.mBody + ".")); return; } @@ -270,37 +270,37 @@ public class ClansCommand extends CommandBase if (args.length < 2) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input a Clan name.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input a Clan name.")); return; } if (!UtilInput.valid(args[1])) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Invalid characters in Clan name.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Invalid characters in Clan name.")); return; } if (args[1].length() < Plugin.getNameMin()) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Clan name too short. Minimum length is " + (Plugin.getNameMin()) + ".")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Clan name too short. Minimum length is " + (Plugin.getNameMin()) + ".")); return; } if (args[1].length() > Plugin.getNameMax()) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Clan name too long. Maximum length is " + (Plugin.getNameMax()) + ".")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Clan name too long. Maximum length is " + (Plugin.getNameMax()) + ".")); return; } if (Plugin.getChat().getFilteredMessage(caller, args[1]).contains("*")) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Clan name inappropriate. Please try a different name")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Clan name inappropriate. Please try a different name")); return; } if (!ClansBlacklist.isValidClanName(args[1])) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Clan name is blacklisted! Please try a different name.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Clan name is blacklisted! Please try a different name.")); return; } @@ -311,7 +311,7 @@ public class ClansCommand extends CommandBase { if (clanExists) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Clan name is already in use by another Clan.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Clan name is already in use by another Clan.")); } else { @@ -323,11 +323,11 @@ public class ClansCommand extends CommandBase if (data == null) { // Hopefully shouldn't happen! - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "There was an error creating the clan. Please try again")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "There was an error creating the clan. Please try again")); } else { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You created Clan " + C.cYellow + data.getName() + C.cGray + ".")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You created Clan " + C.cYellow + data.getName() + C.cGray + ".")); } } }); @@ -347,13 +347,13 @@ public class ClansCommand extends CommandBase if (clan == null) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); return; } if (args.length < 2) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input an invitee.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input an invitee.")); return; } @@ -365,13 +365,20 @@ public class ClansCommand extends CommandBase public void stuck(final Player caller) { + if (_clansManager.getNetherManager().isInNether(caller)) + { + _clansManager.message(caller, "You are not allowed to free yourself in " + F.clansNether("The Nether") + "."); + + return; + } + ClanTerritory territory = Plugin.getClanUtility().getClaim(caller.getLocation()); String clanName = Plugin.getClanUtility().getClanByPlayer(caller) == null ? null : Plugin.getClanUtility().getClanByPlayer(caller).getName(); if (territory == null || territory.Safe || territory.Owner.equals(clanName)) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You must be in another Clan's territory to use this.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You must be in another Clan's territory to use this.")); return; } @@ -384,14 +391,14 @@ public class ClansCommand extends CommandBase if (loc == null) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Error whilst finding location to teleport to.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Error whilst finding location to teleport to.")); return; } player.getPlayer().teleport(loc); // Inform - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You have been teleported to the Wilderness.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You have been teleported to the Wilderness.")); } }, new Callback() { public void run(DelayedTaskClient client) @@ -444,31 +451,31 @@ public class ClansCommand extends CommandBase { if (Plugin.getClanMemberUuidMap().containsKey(caller.getUniqueId())) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are already in a Clan.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are already in a Clan.")); return; } if (Plugin.leftRecently(caller.getUniqueId(), 20 * 60 * 1000) != null) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot join a Clan for " + C.mTime + UtilTime.MakeStr(Plugin.leftRecently(caller.getUniqueId(), 20 * 60 * 1000).getRight()) + C.mBody + ".")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot join a Clan for " + C.mTime + UtilTime.MakeStr(Plugin.leftRecently(caller.getUniqueId(), 20 * 60 * 1000).getRight()) + C.mBody + ".")); return; } if (!Plugin.Get(caller).canJoin()) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot join a Clan for " + C.mTime + UtilTime.convertString(System.currentTimeMillis() - Plugin.Get(caller).getDelay(), 1, TimeUnit.FIT) + C.mBody + ".")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot join a Clan for " + C.mTime + UtilTime.convertString(System.currentTimeMillis() - Plugin.Get(caller).getDelay(), 1, TimeUnit.FIT) + C.mBody + ".")); return; } if (args.length < 2) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input a Clan name.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input a Clan name.")); return; } if (!UtilInput.valid(args[1])) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Invalid characters in Clan name.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Invalid characters in Clan name.")); return; } @@ -477,13 +484,13 @@ public class ClansCommand extends CommandBase if (!clan.isInvited(caller.getName())) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not invited to " + F.elem("Clan " + clan.getName()) + ".")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not invited to " + F.elem("Clan " + clan.getName()) + ".")); return; } if (clan.getSize() >= clan.getMaxSize()) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "The clan " + F.elem("Clan " + clan.getName()) + " is full and cannot be joined!")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "The clan " + F.elem("Clan " + clan.getName()) + " is full and cannot be joined!")); return; } @@ -500,12 +507,12 @@ public class ClansCommand extends CommandBase if (data) { // Inform - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You joined " + F.elem("Clan " + clan.getName()) + ".")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You joined " + F.elem("Clan " + clan.getName()) + ".")); clan.inform(F.name(caller.getName()) + " has joined your Clan.", caller.getName()); } else { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "There was an error processing your request")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "There was an error processing your request")); } } }); @@ -518,13 +525,13 @@ public class ClansCommand extends CommandBase if (clan == null) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); return; } if (clan.getMembers().get(caller.getUniqueId()).getRole() == ClanRole.LEADER && clan.getMembers().size() > 1) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You must pass on " + F.elem("Leadership") + " before leaving.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You must pass on " + F.elem("Leadership") + " before leaving.")); return; } @@ -538,7 +545,7 @@ public class ClansCommand extends CommandBase public void run(Boolean data) { // Inform - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You left " + F.elem("Clan " + clan.getName()) + ".")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You left " + F.elem("Clan " + clan.getName()) + ".")); clan.inform(F.name(caller.getName()) + " has left your Clan.", null); } }); @@ -555,19 +562,19 @@ public class ClansCommand extends CommandBase if (clan == null) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); return; } if (args.length < 2) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input a Player to kick.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input a Player to kick.")); return; } final String target = UtilPlayer.searchCollection(caller, args[1], clan.getMemberNameSet(), "Clan Member", true); - _manager.getClanUtility().kick(caller, target); + _clansManager.getClanUtility().kick(caller, target); } public void promote(Player caller, String[] args) @@ -576,19 +583,19 @@ public class ClansCommand extends CommandBase if (clan == null) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); return; } if (args.length < 2) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input player to promote.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input player to promote.")); return; } final String targetName = UtilPlayer.searchCollection(caller, args[1], clan.getMemberNameSet(), "Clan Member", true); - _manager.getClanUtility().promote(caller, targetName); + _clansManager.getClanUtility().promote(caller, targetName); } public void demote(Player caller, String[] args) @@ -597,19 +604,19 @@ public class ClansCommand extends CommandBase if (clan == null) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); return; } if (args.length < 2) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input player to demote.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input player to demote.")); return; } final String targetName = UtilPlayer.searchCollection(caller, args[1], clan.getMemberNameSet(), "Clan Member", true); - _manager.getClanUtility().demote(caller, targetName); + _clansManager.getClanUtility().demote(caller, targetName); } public void ally(Player caller, String[] args) @@ -618,19 +625,19 @@ public class ClansCommand extends CommandBase if (cA == null) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); return; } if (cA.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER && cA.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.ADMIN) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Only the Clan Leader and Admins can manage Alliances.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Only the Clan Leader and Admins can manage Alliances.")); return; } if (args.length < 2) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input a Clan to ally.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input a Clan to ally.")); return; } @@ -640,31 +647,31 @@ public class ClansCommand extends CommandBase if (cA.isSelf(cB.getName())) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot ally with yourself.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot ally with yourself.")); return; } if (cA.isAlly(cB.getName())) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are already allies with Clan" + F.elem(cB.getName())) + "."); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are already allies with Clan" + F.elem(cB.getName())) + "."); return; } if (cA.getAllies() >= cA.getAlliesMax()) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot have any more allies.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot have any more allies.")); return; } if (cB.getAllies() >= cB.getAlliesMax()) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Clan " + F.elem(cB.getName()) + " cannot have any more allies.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Clan " + F.elem(cB.getName()) + " cannot have any more allies.")); return; } if (!Recharge.Instance.usable(caller, "AllyReq" + cB.getName())) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Please do not spam alliance requests.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Please do not spam alliance requests.")); return; } @@ -674,7 +681,7 @@ public class ClansCommand extends CommandBase Plugin.getClanDataAccess().ally(cA, cB, caller.getName()); // Inform - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You accepted alliance with Clan " + F.elem(cB.getName()) + ".")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You accepted alliance with Clan " + F.elem(cB.getName()) + ".")); cA.inform(F.name(caller.getName()) + " accepted alliance with Clan " + F.elem(cB.getName()) + ".", caller.getName()); cB.inform("Clan " + F.elem(cA.getName()) + " has accepted alliance with you.", null); } @@ -684,7 +691,7 @@ public class ClansCommand extends CommandBase Plugin.getClanDataAccess().requestAlly(cA, cB, caller.getName()); // Inform - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You requested alliance with Clan " + F.elem(cB.getName()) + ".")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You requested alliance with Clan " + F.elem(cB.getName()) + ".")); cA.inform(F.name(caller.getName()) + " has requested alliance with Clan " + F.elem(cB.getName()) + ".", caller.getName()); cB.inform("Clan " + F.elem(cA.getName()) + " has requested alliance with you.", null); @@ -747,19 +754,19 @@ public class ClansCommand extends CommandBase if (cA == null) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); return; } if (cA.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER && cA.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.ADMIN) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Only the Clan Leader and Admins can manage relationships.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Only the Clan Leader and Admins can manage relationships.")); return; } if (args.length < 2) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input a Clan to set neutrality with.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input a Clan to set neutrality with.")); return; } @@ -769,11 +776,11 @@ public class ClansCommand extends CommandBase if (cB.isSelf(cA.getName())) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You prefer to think of yourself positively...")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You prefer to think of yourself positively...")); } else if (cB.isNeutral(cA.getName())) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are already neutral with " + F.elem("Clan " + cB.getName()) + ".")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are already neutral with " + F.elem("Clan " + cB.getName()) + ".")); } else if (cB.isAlly(cA.getName())) { @@ -781,7 +788,7 @@ public class ClansCommand extends CommandBase Plugin.getClanDataAccess().neutral(cA, cB, caller.getName(), true); // Inform - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You revoked alliance with " + F.elem("Clan " + cB.getName()) + ".")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You revoked alliance with " + F.elem("Clan " + cB.getName()) + ".")); cA.inform(F.name(caller.getName()) + " revoked alliance with " + F.elem("Clan " + cB.getName()) + ".", caller.getName()); cB.inform(F.elem("Clan " + cA.getName()) + " has revoked alliance with you.", null); } @@ -797,11 +804,25 @@ public class ClansCommand extends CommandBase return; } + if (_clansManager.getNetherManager().isInNether(caller)) + { + _clansManager.message(caller, "You are not allowed to claim territory in " + F.clansNether("The Nether") + "."); + + return; + } + Plugin.getClanUtility().claim(caller); } public void unclaim(Player caller, String[] args) { + if (_clansManager.getNetherManager().isInNether(caller)) + { + _clansManager.message(caller, "You are not allowed to unclaim territory in " + F.clansNether("The Nether") + "."); + + return; + } + if (args.length > 1) { if (args[1].equalsIgnoreCase("all") || args[1].equalsIgnoreCase("a")) @@ -816,13 +837,13 @@ public class ClansCommand extends CommandBase public boolean unclaimSteal(Player caller, ClanInfo clientClan, ClanInfo ownerClan) { - if (!_manager.canUnclaimChunk(clientClan, ownerClan)) + if (!_clansManager.canUnclaimChunk(clientClan, ownerClan)) { return false; } // Change Inform - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You can no longer 'steal' territory. " + "You simply unclaim it and it can not be reclaimed by anyone for 30 mintes." + "This was done to improve gameplay. Enjoy!")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You can no longer 'steal' territory. " + "You simply unclaim it and it can not be reclaimed by anyone for 30 mintes." + "This was done to improve gameplay. Enjoy!")); // Inform UtilServer.broadcast(F.main("Clans", F.elem(clientClan.getName()) + " unclaimed from " + F.elem(ownerClan.getName()) + " at " + F.elem(UtilWorld.locToStrClean(caller.getLocation())) + ".")); @@ -858,19 +879,19 @@ public class ClansCommand extends CommandBase if (clan == null) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); return; } if (clan.getHome() == null) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Your Clan has not set a Home")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Your Clan has not set a Home")); return; } if (!clan.getClaimSet().contains(UtilWorld.chunkToStr(clan.getHome().getChunk()))) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Your Clan has lost its Home Territory.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Your Clan has lost its Home Territory.")); return; } @@ -878,7 +899,7 @@ public class ClansCommand extends CommandBase if (!(home.getBlock().getType().equals(Material.BED_BLOCK) && home.add(0, 1, 0).getBlock().getType().equals(Material.AIR)) && home.add(0, 2, 0).getBlock().getType().equals(Material.AIR)) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Your Clan's bed has been destroyed, or is obstructed.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Your Clan's bed has been destroyed, or is obstructed.")); return; } @@ -904,7 +925,7 @@ public class ClansCommand extends CommandBase Plugin.getTeleport().TP(caller, clan.getHome().add(0, 1, 0)); // Inform - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You teleported to your Clan Home " + UtilWorld.locToStrClean(caller.getLocation()) + ".")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You teleported to your Clan Home " + UtilWorld.locToStrClean(caller.getLocation()) + ".")); } }, new Callback() { public void run(DelayedTaskClient client) @@ -934,31 +955,38 @@ public class ClansCommand extends CommandBase if (clan == null) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); + return; + } + + if (_clansManager.getNetherManager().isInNether(caller)) + { + _clansManager.message(caller, "You are not allowed to set your Clan Home in " + F.clansNether("The Nether") + "."); + return; } if (clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER && clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.ADMIN) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Only the Clan Leader and Admins can manage Clan Home.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Only the Clan Leader and Admins can manage Clan Home.")); return; } if (Plugin.getClanUtility().getOwner(caller.getLocation()) == null) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You must set your Clan Home in your own Territory.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You must set your Clan Home in your own Territory.")); return; } if (!Plugin.getClanUtility().getOwner(caller.getLocation()).isSelf(clan.getName())) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You must set your Clan Home in your own Territory.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You must set your Clan Home in your own Territory.")); return; } if (!(caller.getLocation().add(0, 1, 0).getBlock().getType().equals(Material.AIR) && caller.getLocation().add(0, 2, 0).getBlock().getType().equals(Material.AIR))) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "This is not a suitable place for a bed.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "This is not a suitable place for a bed.")); return; } @@ -967,7 +995,7 @@ public class ClansCommand extends CommandBase if (!bedPlaced) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "This is not a suitable place for a bed.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "This is not a suitable place for a bed.")); return; } @@ -983,7 +1011,7 @@ public class ClansCommand extends CommandBase Plugin.ClanTips.displayTip(TipType.SETHOME, caller); // Inform - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You set Clan Home to " + F.elem(UtilWorld.locToStrClean(caller.getLocation())) + ".")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You set Clan Home to " + F.elem(UtilWorld.locToStrClean(caller.getLocation())) + ".")); clan.inform(caller.getName() + " set Clan Home to " + F.elem(UtilWorld.locToStrClean(caller.getLocation())) + ".", caller.getName()); } @@ -993,7 +1021,7 @@ public class ClansCommand extends CommandBase if (search == null) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input a search parameter.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input a search parameter.")); return; } @@ -1008,20 +1036,20 @@ public class ClansCommand extends CommandBase ClanInfo clan = Plugin.getClanUtility().searchClanPlayer(caller, search, true); if (clan == null) return; - _manager.getClanShop().openClanWho(caller, clan); + _clansManager.getClanShop().openClanWho(caller, clan); } public void forceJoinClan(Player caller, String search) { - if (_manager.getClientManager().hasRank(caller, Rank.ADMIN)) + if (_clansManager.getClientManager().hasRank(caller, Rank.ADMIN)) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "No no no, this command is not for you ;-)")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "No no no, this command is not for you ;-)")); return; } if (search == null) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input a search parameter.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input a search parameter.")); return; } @@ -1036,8 +1064,8 @@ public class ClansCommand extends CommandBase ClanInfo clan = Plugin.getClanUtility().searchClanPlayer(caller, search, true); if (clan == null) return; - _manager.getClanUtility().join(caller, clan); - _manager.getClanDataAccess().role(clan, caller.getUniqueId(), ClanRole.LEADER); + _clansManager.getClanUtility().join(caller, clan); + _clansManager.getClanDataAccess().role(clan, caller.getUniqueId(), ClanRole.LEADER); } @@ -1050,7 +1078,7 @@ public class ClansCommand extends CommandBase if (clan == null) { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); + _clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); return; } } @@ -1060,6 +1088,13 @@ public class ClansCommand extends CommandBase if (clan == null) return; - _manager.getTutorials().sendTutorialMsg(caller, clan.mTerritory()); + if (_clansManager.getNetherManager().isInNether(caller)) + { + _clansManager.message(caller, "You are currently in " + F.clansNether("The Nether") + "."); + + return; + } + + _clansManager.getTutorials().sendTutorialMsg(caller, clan.mTerritory()); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/button/ClanButton.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/button/ClanButton.java index 1abdda431..055a4eed2 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/button/ClanButton.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/button/ClanButton.java @@ -12,7 +12,7 @@ import mineplex.game.clans.clans.gui.ClanShop; public abstract class ClanButton implements IButton { private ClanShop _shop; - private ClansManager _clansManager; + protected ClansManager _clansManager; private Player _player; private ClanInfo _clanInfo; private ClanRole _clanRole; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/button/ClanTerritoryButton.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/button/ClanTerritoryButton.java index b718a5132..a18156e4c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/button/ClanTerritoryButton.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/button/ClanTerritoryButton.java @@ -6,6 +6,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import mineplex.core.common.util.C; +import mineplex.core.common.util.F; import mineplex.core.common.util.UtilWorld; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClanRole; @@ -22,6 +23,13 @@ public class ClanTerritoryButton extends ClanButton @Override public void onClick(Player player, ClickType clickType) { + if (_clansManager.getNetherManager().isInNether(player)) + { + _clansManager.message(player, "You are not allowed to do anything with Territory while in " + F.clansNether("The Nether") + "."); + player.closeInventory(); + return; + } + if (clickType == ClickType.LEFT) { player.closeInventory(); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/page/ClanMainPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/page/ClanMainPage.java index e9738de3f..f85de461b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/page/ClanMainPage.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/page/ClanMainPage.java @@ -44,7 +44,7 @@ public class ClanMainPage extends ClanPageBase public ClanMainPage(ClansManager plugin, ClanShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player) { super(plugin, shop, clientManager, donationManager, "Manage Clan", player, 54); - + buildPage(); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java new file mode 100644 index 000000000..f3bffa07a --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java @@ -0,0 +1,195 @@ +package mineplex.game.clans.clans.nether; + +import java.io.File; +import java.util.List; + +import org.bukkit.Bukkit; +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.WorldBorder; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.player.PlayerPortalEvent; +import org.bukkit.inventory.ItemStack; + +import com.google.common.collect.Lists; + +import mineplex.core.MiniPlugin; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilCollections; +import mineplex.core.common.util.UtilFile; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilWorld; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClanTips.TipType; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.core.repository.ClanTerritory; + +public class NetherManager extends MiniPlugin +{ + private ClansManager _clansManager; + + private World _netherWorld; + + private List _portals = Lists.newArrayList(); + + private File _portalCfg; + + public NetherManager(ClansManager clansManager) + { + super("Nether Manager", clansManager.getPlugin()); + _clansManager = clansManager; + + _portalCfg = new File(UtilServer.getServer().getWorlds().get(0).getWorldFolder().getPath() + File.separator + ".." + File.separator + "nether.cfg"); + + begin(); + } + + public void begin() + { + _netherWorld = Bukkit.getWorld("world_nether"); + + WorldBorder worldBorder = _netherWorld.getWorldBorder(); + worldBorder.setCenter(0, 0); + worldBorder.setSize(200 * 2); + + parsePortals(); + } + + private void parsePortals() + { + String data = UtilFile.read(_portalCfg); + + if (data.length() < 5) + { + return; + } + + UtilCollections.forEach(data.split("\n"), string -> string.trim(), sPortal -> { + + String[] destinations = sPortal.split(">>"); + + Location from = UtilWorld.strToLoc(destinations[0]); + Location to = UtilWorld.strToLoc(destinations[1].split(":")[0]); + + Portal portal = Portal.create(from, to, UtilWorld.strToLoc(to.getWorld().getName() + "," + destinations[1].split(":")[1])); + + if (portal == null) + { + log("FAILED TO LOAD PORTAL [" + sPortal + "]"); + } + else + { + _portals.add(portal); + } + }); + } + + @EventHandler + public void breakBlock(BlockBreakEvent event) + { + Block block = event.getBlock(); + Player player = event.getPlayer(); + ItemStack item = player.getItemInHand(); + + if (!block.getWorld().equals(_netherWorld)) + { + return; + } + + if (player.getGameMode() == GameMode.CREATIVE) + { + return; + } + + if (!item.getType().equals(Material.GOLD_PICKAXE)) + { + UtilPlayer.message(player, F.main("Clans", "You can only break blocks in the Nether with a " + F.elem("Golden Pickaxe") + ".")); + event.setCancelled(true); + return; + } + + if (block.getType().equals(Material.OBSIDIAN) || block.getType().equals(Material.PORTAL)) + { + UtilPlayer.message(player, F.main("Clans", "You are not allowed to break this block.")); + event.setCancelled(true); + return; + } + } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() == UpdateType.SEC_08) + { + _portals.forEach(portal -> { + portal.getFromObsidianBlocks().forEach(block -> block.setType(Material.OBSIDIAN)); + portal.getFromPortalBlocks().forEach(block -> block.setType(Material.PORTAL)); + + portal.getToObsidianBlocks().forEach(block -> block.setType(Material.OBSIDIAN)); + portal.getToPortalBlocks().forEach(block -> block.setType(Material.PORTAL)); + }); + } + } + + @EventHandler + public void onPortal(PlayerPortalEvent event) + { + Player player = event.getPlayer(); + Location location = player.getLocation(); + + ClanTerritory territory = _clansManager.getClanUtility().getClaim(location); + + event.setCancelled(true); + + if (territory != null && territory.Owner.equals("Borderlands")) + { + if (event.getTo().getWorld().equals(_netherWorld)) + { + _portals + .stream() + .filter(portal -> + portal.getToPortalBlocks() + .stream() + .filter(block -> player.getLocation().distance(block.getLocation()) <= 2) + .iterator().hasNext() + ).limit(1) + .forEach(portal -> { + player.teleport(portal.getToOut()); + _clansManager.ClanTips.displayTip(TipType.ENTER_NETHER, player); + }); + } + else + { + _portals + .stream() + .filter(portal -> + portal.getFromPortalBlocks() + .stream() + .filter(block -> player.getLocation().distance(block.getLocation()) <= 2) + .iterator().hasNext() + ).limit(1) + .forEach(portal -> { + player.teleport(UtilAlg.getAverageBlockLocation(portal.getToPortalBlocks())); + }); + } + } + } + + public World getNetherWorld() + { + return _netherWorld; + } + + public boolean isInNether(Player player) + { + return player.getWorld().equals(_netherWorld); + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/Portal.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/Portal.java new file mode 100644 index 000000000..ba3396aee --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/Portal.java @@ -0,0 +1,112 @@ +package mineplex.game.clans.clans.nether; + +import java.util.List; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; + +import com.google.common.collect.Lists; + +import mineplex.core.common.util.UtilBlock; + +public class Portal +{ + private List _fromPortalBlocks; + private List _fromObsidianBlocks; + + private List _toPortalBlocks; + private List _toObsidianBlocks; + + private Location _toOut; + + public final boolean Success; + + public Portal(Location from, Location to, Location toOut) + { + _fromPortalBlocks = Lists.newArrayList(); + _fromObsidianBlocks = Lists.newArrayList(); + + _toPortalBlocks = Lists.newArrayList(); + _toObsidianBlocks = Lists.newArrayList(); + + _toOut = toOut; + + if (!isValidPortalBlock(from.getBlock()) || !isValidPortalBlock(to.getBlock())) + { + System.out.println("[PORTAL] INVALID PORTAL PROVIDED (" + from + " --> " + to + ")"); + + Success = false; + + return; + } + + for (Block other : UtilBlock.getInRadius(from, 7.5d).keySet()) + { + if (other.getType() == Material.OBSIDIAN) + { + _fromObsidianBlocks.add(other); + } + else if (other.getType() == Material.PORTAL) + { + _fromPortalBlocks.add(other); + } + } + + for (Block other : UtilBlock.getInRadius(to, 7.5d).keySet()) + { + if (other.getType() == Material.OBSIDIAN) + { + _toObsidianBlocks.add(other); + } + else if (other.getType() == Material.PORTAL) + { + _toPortalBlocks.add(other); + } + } + + Success = true; + } + + public Location getToOut() + { + return _toOut; + } + + public List getFromPortalBlocks() + { + return _fromPortalBlocks; + } + + public List getFromObsidianBlocks() + { + return _fromObsidianBlocks; + } + + public List getToPortalBlocks() + { + return _toPortalBlocks; + } + + public List getToObsidianBlocks() + { + return _toObsidianBlocks; + } + + private boolean isValidPortalBlock(Block block) + { + return block.getType() == Material.OBSIDIAN || block.getType() == Material.PORTAL; + } + + public static Portal create(Location from, Location to, Location toOut) + { + Portal portal = new Portal(from, to, toOut); + + if (!portal.Success) + { + return null; + } + + return portal; + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java index b8cbfadce..a814a1439 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java @@ -66,14 +66,10 @@ public class PvpTimer extends MiniClientPlugin public void disableFor(final Player caller) { - TaskManager.Instance.completedTask(new Callback() { - @Override - public void run(Boolean data) - { - Get(caller).Skipped = true; - caller.playSound(caller.getLocation(), Sound.ENDERDRAGON_GROWL, 1f, 0.75f); - } - }, caller, "PvpTimer.Skipped"); + Get(caller).Skipped = true; + caller.playSound(caller.getLocation(), Sound.ENDERDRAGON_GROWL, 1f, 0.75f); + + TaskManager.Instance.completedTask(null, caller, "PvpTimer.Skipped"); } @EventHandler diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/regions/ClansRegions.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/regions/ClansRegions.java index bb80a711e..f79aba758 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/regions/ClansRegions.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/regions/ClansRegions.java @@ -137,7 +137,7 @@ public class ClansRegions extends MiniPlugin * @param claimOffset - the initial offset in claim (creating a 'hole' with chunk offset radius) * @param safe - whether the chunk claimed is considered a 'safe' (pvp-free) region. */ - private void claimArea(final String clanName, final int chunkRadius, final int claimOffset, final boolean safe, final boolean addNegative, final Location... locations) + public void claimArea(final String clanName, final int chunkRadius, final int claimOffset, final boolean safe, final boolean addNegative, final Location... locations) { final ClanInfo clan = _manager.getClan(clanName); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java index d0d710721..ec93dc660 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java @@ -44,6 +44,12 @@ public class ScoreboardElementPlayer implements ScoreboardElement regionString += C.mBody + "(" + C.mElem + "Trusted" + C.mBody + ")"; } + + if (_clansManager.getNetherManager().isInNether(player)) + { + regionString = C.cRed + "The Nether"; + } + output.add(regionString); return output; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java index 95b8733e7..03b8d45b2 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java @@ -10,6 +10,7 @@ import org.bukkit.event.block.BlockPlaceEvent; import com.google.gson.Gson; import mineplex.core.MiniPlugin; +import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilInv; @@ -17,10 +18,8 @@ import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import mineplex.game.clans.clans.ClansBlacklist; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.siege.commands.CommandSiegeSupplies; -import mineplex.game.clans.clans.siege.events.SiegeWeaponExplodeEvent; import mineplex.game.clans.clans.siege.outpost.OutpostManager; import mineplex.game.clans.clans.siege.repository.SiegeWeaponRepository; import mineplex.game.clans.clans.siege.repository.tokens.SiegeWeaponToken; @@ -45,7 +44,7 @@ public class SiegeManager extends MiniPlugin public SiegeManager(ClansManager clans) { - super("Siege", clans.getPlugin()); + super("Siege Manager", clans.getPlugin()); _gson = new Gson(); @@ -171,6 +170,13 @@ public class SiegeManager extends MiniPlugin public boolean trySpawnCannon(Player player, Location location) { + if (_clansManager.getNetherManager().isInNether(player)) + { + _clansManager.message(player, "You are not allowed to place this in " + F.clansNether("The Nether") + "."); + + return false; + } + if (!_clansManager.isInClan(player)) { UtilPlayer.message(player, F.main("Clans", "You must be in a Clan to place a Cannon.")); @@ -199,6 +205,13 @@ public class SiegeManager extends MiniPlugin public boolean trySpawnCatapult(Player player, Location location) { + if (_clansManager.getNetherManager().isInNether(player)) + { + _clansManager.message(player, "You are not allowed to place this in " + F.clansNether("The Nether") + "."); + + return false; + } + if (!_clansManager.isInClan(player)) { UtilPlayer.message(player, F.main("Clans", "You must be in a Clan to place a Catapult.")); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/OutpostManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/OutpostManager.java index ceb0f4c36..e600554c1 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/OutpostManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/OutpostManager.java @@ -18,6 +18,7 @@ import org.bukkit.inventory.ItemStack; import com.google.common.collect.Lists; import mineplex.core.MiniPlugin; +import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilAlg; @@ -79,6 +80,13 @@ public class OutpostManager extends MiniPlugin public boolean spawnOutpost(Player player, Location location, OutpostType type) { + if (_clansManager.getNetherManager().isInNether(player)) + { + _clansManager.message(player, "You are not allowed to place this in " + F.clansNether("The Nether") + "."); + + return false; + } + if (!_clansManager.isInClan(player)) { UtilPlayer.message(player, F.main("Clans", "You must be in a Clan to place an Outpost.")); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java index 6235642cd..693d0b2ff 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java @@ -246,6 +246,11 @@ public class Gameplay extends MiniPlugin @EventHandler(priority = EventPriority.LOWEST) public void ObsidianCancel(BlockPlaceEvent event) { + if (_clansManager.masterBypass(event.getPlayer())) + { + return; + } + if (event.getBlock().getType() == Material.OBSIDIAN) { UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot place " + F.item("Obsidian") + ".")); diff --git a/Plugins/Mineplex.Game.Clans/src/test/Test.java b/Plugins/Mineplex.Game.Clans/src/test/Test.java new file mode 100644 index 000000000..2ae94a373 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/test/Test.java @@ -0,0 +1,25 @@ +package test; + + +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; +import java.io.IOException; + +public class Test { + public static void main(String[] args) throws IOException + { + ByteArrayOutputStream stream = new ByteArrayOutputStream(); + DataOutputStream dos = new DataOutputStream(stream); + + dos.writeByte(91); + dos.flush(); + stream.flush(); + + System.out.println(new String(stream.toByteArray())); + + dos.close(); + stream.close(); + + + } +}