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 9dc33ddeb..5e615a9ab 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 @@ -4,8 +4,12 @@ import java.util.Arrays; import java.util.Collection; import java.util.List; import java.util.Random; +import java.util.function.BiConsumer; import java.util.function.Consumer; import java.util.function.Function; +import java.util.stream.Stream; + +import org.bukkit.inventory.ItemStack; import com.google.common.collect.Lists; @@ -62,17 +66,6 @@ public class UtilCollections } } - 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++) @@ -80,17 +73,20 @@ public class UtilCollections consumer.accept(elements[i]); } } + + public static void forEach(E[] elements, BiConsumer consumer) + { + for (int i = 0; i < elements.length; i++) + { + consumer.accept(Integer.valueOf(i), elements[i]); + } + } public static void addAll(E[] elements, Collection collection) { 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) { for (int i = min; i < max; i++) @@ -233,9 +229,15 @@ public class UtilCollections { return array[Random.nextInt(array.length)]; } - + public static Collection toList(T[] array) { return Lists.newArrayList(array); } + + public static boolean equal(T1[] array1, T2[] array2) + { + return Arrays.equals(array1, array2); + } + } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilServer.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilServer.java index 0b01e4bb0..08315ef41 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilServer.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilServer.java @@ -8,14 +8,15 @@ import java.util.LinkedList; import java.util.List; import org.bukkit.Bukkit; +import org.bukkit.OfflinePlayer; import org.bukkit.Server; import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; -import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitRunnable; public class UtilServer @@ -92,11 +93,16 @@ public class UtilServer return (double)getPlayers().length / (double)UtilServer.getServer().getMaxPlayers(); } - public static void registerEvents(Listener listener) + public static void RegisterEvents(Listener listener) { getPluginManager().registerEvents(listener, getPlugin()); } + public static void Unregister(Listener listener) + { + HandlerList.unregisterAll(listener); + } + public static Plugin getPlugin() { return getPluginManager().getPlugins()[0]; @@ -116,4 +122,19 @@ public class UtilServer { runnable.runTaskTimer(getPlugin(), time, time); } + + public static boolean IsOnline(String name) + { + return !UtilStreams.IsEmpty(getPlayersCollection().stream().filter(player -> player.getName().equals(name))); + } + + public static Player GetPlayer(String name) + { + return UtilStreams.GetFirst(getPlayersCollection().stream().filter(player -> player.getName().equals(name))); + } + + public static OfflinePlayer GetOffline(String player) + { + return getServer().getOfflinePlayer(player); + } } 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 5a30b025f..33896b83b 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 @@ -82,9 +82,9 @@ import mineplex.game.clans.clans.commands.RegionsCommand; import mineplex.game.clans.clans.data.PlayerClan; import mineplex.game.clans.clans.event.ClansPlayerDeathEvent; import mineplex.game.clans.clans.gui.ClanShop; +import mineplex.game.clans.clans.invsee.Invsee; 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; @@ -260,6 +260,8 @@ public class ClansManager extends MiniClientPluginimplements IRelati new TntGeneratorManager(plugin, this); new SupplyDropManager(plugin, this); + new Invsee(this); + _explosion = new Explosion(plugin, blockRestore); _warPointEvasion = new WarPointEvasion(plugin); 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 8b3dde1d7..96de74f98 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,17 +1,15 @@ package mineplex.game.clans.clans; +import java.io.File; import java.io.IOException; -import org.bukkit.Location; - -import mineplex.core.common.util.UtilWorld; +import mineplex.core.common.util.UtilOfflinePlayer; public class Test { public static void main(String[] args) throws IOException { - System.out.println(UtilWorld.locToStr(new Location(null, 30, 30, 30))); - - + System.out.println("wtf"); + UtilOfflinePlayer.loadOfflineInventory(new File("M:/Clans/a797d3ef-dd25-4e18-a002-6537b19b3603.dat")); } } 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 2997af3b7..a10f9498d 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 @@ -927,7 +927,7 @@ public class ClansCommand extends CommandBase DelayedTask.Instance.doDelay(caller, "Home Teleport", new Callback() { public void run(DelayedTaskClient player) { - Recharge.Instance.use(caller, "Home Teleport", 5 * 60 * 1000, true, false); + Recharge.Instance.use(caller, "Home Teleport", 30 * 60 * 1000, true, false); // Do Plugin.getTeleport().TP(caller, clan.getHome().add(0, 1, 0)); @@ -945,7 +945,7 @@ public class ClansCommand extends CommandBase { UtilPlayer.message(client.getPlayer(), F.main("Clans", "Teleport has been cancelled due to movement.")); } - }, (Plugin.getClanUtility().getClaim(caller.getLocation()) != null ? 30 : 20) * 1000, false); + }, 15 * 1000, false); } public void homeSet(Player caller) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java index a80c02da9..332ec8f47 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java @@ -229,7 +229,7 @@ public class Outpost implements Listener Collections.reverse(reverse); _reverseCircleStages = new LoopIterator(reverse); - UtilServer.registerEvents(this); + UtilServer.RegisterEvents(this); _lifetimeLeft = new Hologram(outpostManager.getClansManager().getHologramManager(), _origin.clone().add(0.5, 1.5, 0.5), "Despawning in " + F.time(UtilTime.MakeStr(MAX_LIFETIME))); _lifetimeLeft.setInteraction(new HologramInteraction() diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/SiegeWeapon.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/SiegeWeapon.java index 150bc4d45..b5edf7e9c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/SiegeWeapon.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/SiegeWeapon.java @@ -144,7 +144,7 @@ public abstract class SiegeWeapon implements Listener _infoHologram = new Hologram(ClansManager.getInstance().getHologramManager(), _location.clone().add(.5, 3, .5), _name + " Health", getDisplayHealth()); _infoHologram.start(); - UtilServer.registerEvents(this); + UtilServer.RegisterEvents(this); _clans = clansManager; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/util/BarrierCollisionBox.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/util/BarrierCollisionBox.java index 3d5dcb0cf..f450df88a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/util/BarrierCollisionBox.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/util/BarrierCollisionBox.java @@ -54,7 +54,7 @@ public class BarrierCollisionBox implements Listener { setBlocks(); - UtilServer.registerEvents(this); + UtilServer.RegisterEvents(this); } public void Destruct() diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/stuck/StuckClient.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/stuck/StuckClient.java deleted file mode 100644 index ab5a8b285..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/stuck/StuckClient.java +++ /dev/null @@ -1,15 +0,0 @@ -package mineplex.game.clans.clans.stuck; - -import org.bukkit.Location; - -public class StuckClient -{ - public Location StartLoc = null; - public long UnstickStartTime = -1; - public long UnstickEndTime = -1; - - public long getTimeLeft() - { - return UnstickEndTime - System.currentTimeMillis(); - } -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/stuck/commands/ClansSpawnCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/stuck/commands/ClansSpawnCommand.java deleted file mode 100644 index c060a8000..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/stuck/commands/ClansSpawnCommand.java +++ /dev/null @@ -1,79 +0,0 @@ -package mineplex.game.clans.clans.stuck.commands; - -import org.bukkit.entity.Player; - -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.util.Callback; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilTextMiddle; -import mineplex.core.common.util.UtilTime; -import mineplex.core.delayedtask.DelayedTask; -import mineplex.core.delayedtask.DelayedTaskClient; -import mineplex.core.recharge.Recharge; -import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.spawn.Spawn; - -public class ClansSpawnCommand extends CommandBase -{ - public ClansSpawnCommand(Spawn spawn) - { - super(spawn, Rank.ALL, "spawn", "stuck", "unstick", "unstuck"); - } - - @Override - public void Execute(Player caller, String[] args) - { - if (DelayedTask.Instance.HasTask(caller, "Spawn Teleport")) - { - UtilPlayer.message(caller, F.main("Clans", "You are already teleporting to Spawn.")); - - return; - } - - if (!Recharge.Instance.usable(caller, "Spawn Teleport", true)) - { - return; - } - - if(ClansManager.getInstance().getClanUtility().getClaim(caller.getLocation()) != null && !ClansManager.getInstance().getClanUtility().getClaim(caller.getLocation()).Owner.equals("Borderlands") && - !ClansManager.getInstance().getClanUtility().getClaim(caller.getLocation()).Owner.equals("Shops") && !ClansManager.getInstance().getClanUtility().getClaim(caller.getLocation()).Owner.equals("Spawn")) - { - UtilPlayer.message(caller, F.main("Clans", "You must be in the Wilderness/Borderlands/Shops/Spawn to use this command.")); - - return; - } - - DelayedTask.Instance.doDelay(caller, "Spawn Teleport", new Callback() { - public void run(DelayedTaskClient player) - { - // Do - - if (Math.random() < .5) - { - caller.teleport(Spawn.getEastSpawn()); - } - else - { - caller.teleport(Spawn.getWestSpawn()); - } - - Recharge.Instance.use(caller, "Spawn Teleport", 13 * 60 * 1000, false, false); - - // Inform - Plugin.getClansManager().getTutorials().sendTutorialMsg(caller, F.main("Clans", "You have been teleported to Spawn.")); - } - }, new Callback() { - public void run(DelayedTaskClient client) - { - UtilTextMiddle.display("", "Teleporting to Spawn in " + F.elem(UtilTime.MakeStr(Math.max(0, client.getTimeLeft("Spawn Teleport")))), 0, 5, 0, client.getPlayer()); - } - }, new Callback() { - public void run(DelayedTaskClient client) - { - UtilPlayer.message(client.getPlayer(), F.main("Clans", "Teleport has been cancelled due to movement.")); - } - }, 35 * 1000, false); - } -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/CustomItem.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/CustomItem.java index 37cacd5f2..0f3a4f696 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/CustomItem.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/CustomItem.java @@ -69,7 +69,7 @@ public class CustomItem implements Listener _attributes = new AttributeContainer(); _uuid = UUID.randomUUID().toString(); - UtilServer.registerEvents(this); + UtilServer.RegisterEvents(this); } public CustomItem(Material material) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/EnergyCrossbow.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/EnergyCrossbow.java index cd9b4d7a2..473627884 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/EnergyCrossbow.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/EnergyCrossbow.java @@ -73,7 +73,7 @@ public class EnergyCrossbow extends LegendaryItem private void fire(final Player player) { - UtilServer.registerEvents(new Listener() { + UtilServer.RegisterEvents(new Listener() { private Location _lastLoc; private Arrow _arrow; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java index 7ae590aa5..5cb9ed898 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java @@ -39,11 +39,10 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.common.weight.WeightSet; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.clans.stuck.commands.ClansSpawnCommand; -import mineplex.core.common.weight.WeightSet; import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; import mineplex.minecraft.game.classcombat.item.event.WebTossEvent; import mineplex.minecraft.game.core.condition.Condition.ConditionType; @@ -78,8 +77,6 @@ public class Spawn extends MiniPlugin _spawns = new WeightSet(getEastSpawn(), getWestSpawn()); _shops = new WeightSet(getNorthTown(), getSouthTown()); _clansManager = clansManager; - - addCommand(new ClansSpawnCommand(this)); } /**