diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/lobbyBalancer/LobbyBalancer.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/lobbyBalancer/LobbyBalancer.java index 0c57abfea..de8602e07 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/lobbyBalancer/LobbyBalancer.java +++ b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/lobbyBalancer/LobbyBalancer.java @@ -106,14 +106,14 @@ public class LobbyBalancer implements Listener, Runnable InetSocketAddress socketAddress = new InetSocketAddress(server.getPublicAddress(), server.getPort()); _plugin.getProxy().getServers().put(server.getName(), _plugin.getProxy().constructServerInfo(server.getName(), socketAddress, "LobbyBalancer", false)); - if (server.getName().toUpperCase().startsWith("LOBBY")) + if (server.getName().toUpperCase().startsWith("LOBBY-")) { if (server.getMotd() == null || !server.getMotd().contains("Restarting")) { _sortedLobbies.add(server); } } - if (server.getName().toUpperCase().startsWith("CLANSHUB")) + if (server.getName().toUpperCase().startsWith("CLANSHUB-")) { if (server.getMotd() == null || !server.getMotd().contains("Restarting")) { diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerTracker/PlayerJoinHandler.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerTracker/PlayerJoinHandler.java index 36c4f37c8..19c52c0a0 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerTracker/PlayerJoinHandler.java +++ b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerTracker/PlayerJoinHandler.java @@ -14,14 +14,12 @@ public class PlayerJoinHandler implements CommandCallback _playerTracker = playerTracker; } - @SuppressWarnings("deprecation") @Override public void run(ServerCommand command) { if (command instanceof PlayerJoinCommand) { PlayerJoinCommand joinCommand = (PlayerJoinCommand)command; - _playerTracker.kickPlayerIfOnline(UUID.fromString(joinCommand.getUuid())); } } diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerTracker/PlayerTracker.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerTracker/PlayerTracker.java index a7b2d004e..09c11dfff 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerTracker/PlayerTracker.java +++ b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerTracker/PlayerTracker.java @@ -1,17 +1,18 @@ package mineplex.bungee.playerTracker; -import java.io.File; -import java.util.HashSet; -import java.util.Set; +import java.util.List; import java.util.UUID; -import java.util.concurrent.TimeUnit; + +import com.google.common.collect.Lists; import mineplex.serverdata.Region; +import mineplex.serverdata.commands.PlayerJoinCommand; import mineplex.serverdata.commands.ServerCommandManager; import mineplex.serverdata.data.DataRepository; import mineplex.serverdata.data.PlayerStatus; import mineplex.serverdata.redis.RedisDataRepository; import mineplex.serverdata.servers.ServerManager; +import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.event.PlayerDisconnectEvent; import net.md_5.bungee.api.event.PostLoginEvent; @@ -20,7 +21,7 @@ import net.md_5.bungee.api.plugin.Listener; import net.md_5.bungee.api.plugin.Plugin; import net.md_5.bungee.event.EventHandler; -public class PlayerTracker implements Listener, Runnable +public class PlayerTracker implements Listener { // Default period before status expiry (8 hours) private static final int DEFAULT_STATUS_TIMEOUT = 60 * 60 * 8; @@ -28,24 +29,29 @@ public class PlayerTracker implements Listener, Runnable // Repository storing player status' across network. private DataRepository _repository; - private Set _onlineUUIDs = new HashSet<>(); - private Plugin _plugin; + private final List _ignoreKick = Lists.newArrayList(); + public PlayerTracker(Plugin plugin) { _plugin = plugin; _plugin.getProxy().getPluginManager().registerListener(_plugin, this); - _plugin.getProxy().getScheduler().schedule(_plugin, this, 1L, 1L, TimeUnit.MINUTES); _repository = new RedisDataRepository(ServerManager.getMasterConnection(), ServerManager.getSlaveConnection(), Region.currentRegion(), PlayerStatus.class, "playerStatus"); - ServerCommandManager.getInstance().registerCommandType("PlayerJoinCommand", mineplex.serverdata.commands.PlayerJoinCommand.class, new PlayerJoinHandler(this)); + ServerCommandManager.getInstance().initializeServer("BUNGEE ENABLE - " + System.currentTimeMillis()); + ServerCommandManager.getInstance().registerCommandType(mineplex.serverdata.commands.PlayerJoinCommand.class, new PlayerJoinHandler(this)); System.out.println("Initialized PlayerTracker."); } + + public Plugin getPlugin() + { + return _plugin; + } @EventHandler public void playerConnect(final ServerConnectedEvent event) @@ -70,42 +76,32 @@ public class PlayerTracker implements Listener, Runnable _repository.removeElement(event.getPlayer().getName().toLowerCase()); } }); - - _onlineUUIDs.remove(event.getPlayer().getUniqueId()); } @EventHandler public void playerConnect(final PostLoginEvent event) { - _onlineUUIDs.add(event.getPlayer().getUniqueId()); - } - - @Override - public void run() - { - Set onlineUUIDs = new HashSet<>(); - - for (ProxiedPlayer player : _plugin.getProxy().getPlayers()) - { - onlineUUIDs.add(player.getUniqueId()); - } - - _onlineUUIDs = onlineUUIDs; + _ignoreKick.add(event.getPlayer().getUniqueId()); + PlayerJoinCommand command = new PlayerJoinCommand(event.getPlayer().getUniqueId()); + command.publish(); } public boolean isPlayerOnline(UUID uuid) { - return _onlineUUIDs.contains(uuid); + return _plugin.getProxy().getPlayer(uuid) != null; } public void kickPlayerIfOnline(UUID uuid) { - if (_onlineUUIDs.contains(uuid)) + if (_ignoreKick.remove(uuid)) + { + return; + } + if (isPlayerOnline(uuid)) { ProxiedPlayer player = _plugin.getProxy().getPlayer(uuid); - if (player != null) - player.disconnect("You have logged in from another location."); + player.disconnect(new TextComponent("You have logged in from another location.")); } } } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/animation/AnimationPoint.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/animation/AnimationPoint.java index 82d819295..a02e78796 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/animation/AnimationPoint.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/animation/AnimationPoint.java @@ -33,6 +33,12 @@ public class AnimationPoint return _tick; } + @Override + public String toString() + { + return "AnimationPoint[tick" + _tick + ", motion:[" + _move + "], dir:[" + _dir + "]]"; + } + @Override public boolean equals(Object obj) { diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/animation/Animator.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/animation/Animator.java index 2e2461fda..335f327a4 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/animation/Animator.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/animation/Animator.java @@ -1,5 +1,6 @@ package mineplex.core.common.animation; +import java.util.Collection; import java.util.HashSet; import java.util.PriorityQueue; import java.util.Set; @@ -36,6 +37,11 @@ public abstract class Animator _plugin = plugin; } + public void addPoints(Collection points) + { + for(AnimationPoint p : points) _points.add(p); + } + public void addPoint(AnimationPoint point) { _points.add(point); } @@ -48,7 +54,9 @@ public abstract class Animator * @return Returns a cloned list of the animator points for this instance. */ public Set getSet() { - return new HashSet(_points); + Set set = new HashSet<>(); + set.addAll(_points); + return set; } /** @@ -110,6 +118,7 @@ public abstract class Animator prev.setDirection(_prev.getDirection()); double diff = ((double)_tick-_prev.getTick())/(_next.getTick()-_prev.getTick()); + if(!Double.isFinite(diff)) diff = 0; prev.add(next.clone().subtract(prev).toVector().multiply(diff)); Vector dirDiff = _next.getDirection().subtract(prev.getDirection()); diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/animation/AnimatorEntity.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/animation/AnimatorEntity.java index d418a337c..9f4aa27c6 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/animation/AnimatorEntity.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/animation/AnimatorEntity.java @@ -35,5 +35,10 @@ public class AnimatorEntity extends Animator @Override protected void finish(Location loc) {} + + public Entity getEntity() + { + return _ent; + } } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/animation/AnimatorFactory.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/animation/AnimatorFactory.java new file mode 100644 index 000000000..8f23274c0 --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/animation/AnimatorFactory.java @@ -0,0 +1,48 @@ +package mineplex.core.common.animation; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import org.bukkit.Location; +import org.bukkit.util.Vector; + +/** + * A small factory class to build animations using location inputs with embedded directions. It then calculates the vector difference + * between the locations in an ordered fashion when building the list. + */ +public class AnimatorFactory +{ + + private Map _locations = new HashMap<>(); + + public void addLocation(Location loc, int tick) + { + _locations.put(tick, loc.clone()); + } + + public List getBuildList(Location base) + { + List list = new ArrayList<>(); + + Iterator> it = _locations.entrySet().stream() + .sorted((e1, e2) + -> Integer.compare(e1.getKey(), e2.getKey()) + ) + .iterator(); + + while(it.hasNext()) + { + Entry e = it.next(); + Vector diff = e.getValue().clone().subtract(base).toVector(); + + list.add(new AnimationPoint(e.getKey(), diff, e.getValue().getDirection())); + } + + return list; + } + +} diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/block/schematic/Schematic.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/block/schematic/Schematic.java index e08a70c0d..0ab1c909f 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/block/schematic/Schematic.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/block/schematic/Schematic.java @@ -5,12 +5,17 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.bukkit.Bukkit; +import net.minecraft.server.v1_8_R3.Entity; +import net.minecraft.server.v1_8_R3.EntityTypes; +import net.minecraft.server.v1_8_R3.NBTTagCompound; +import net.minecraft.server.v1_8_R3.NBTTagInt; +import net.minecraft.server.v1_8_R3.TileEntity; +import net.minecraft.server.v1_8_R3.WorldServer; + import org.bukkit.DyeColor; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; -import org.bukkit.entity.Player; import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; import org.bukkit.util.BlockVector; import org.bukkit.util.Vector; @@ -23,12 +28,6 @@ import com.java.sk89q.jnbt.Tag; import mineplex.core.common.block.DataLocationMap; import mineplex.core.common.util.MapUtil; import mineplex.core.common.util.UtilBlock; -import net.minecraft.server.v1_8_R3.Entity; -import net.minecraft.server.v1_8_R3.EntityTypes; -import net.minecraft.server.v1_8_R3.NBTTagCompound; -import net.minecraft.server.v1_8_R3.NBTTagInt; -import net.minecraft.server.v1_8_R3.TileEntity; -import net.minecraft.server.v1_8_R3.WorldServer; public class Schematic { diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java index 29abc2b86..910849f06 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java @@ -5,19 +5,20 @@ import java.util.List; import java.util.Map; import java.util.UUID; -import com.google.common.collect.Maps; -import com.mojang.authlib.minecraft.InsecureTextureException; -import com.mojang.authlib.minecraft.MinecraftProfileTexture; -import mineplex.core.common.util.UtilPlayer; import net.minecraft.server.v1_8_R3.MinecraftServer; + import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.inventory.meta.SkullMeta; +import com.google.common.collect.Maps; import com.mojang.authlib.GameProfile; +import com.mojang.authlib.minecraft.InsecureTextureException; +import com.mojang.authlib.minecraft.MinecraftProfileTexture; import com.mojang.authlib.properties.Property; -import org.bukkit.inventory.meta.SkullMeta; +import mineplex.core.common.util.UtilPlayer; public class SkinData { @@ -57,10 +58,10 @@ public class SkinData public final static SkinData UNCLE_SAM = new SkinData("eyJ0aW1lc3RhbXAiOjE0NjYxODA0NjY4NTcsInByb2ZpbGVJZCI6IjlmY2FlZDhiMTRiNTRmN2ZhNjRjYjYwNDBlNzA1MjcyIiwicHJvZmlsZU5hbWUiOiJMQ2FzdHIxIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS9jYzM1YWRmZTQ3ODBjNmU2NTk4YTJlYzk2ZjdhZGQ5ZDc4NjljMjBlZjRmYjEyNjk2NmJhOGFlMDRlOWRhIn19fQ==", "NmJ+hXmvwQlYFYY7YVQWRr11yBbAfJP+jk11SQ91gUUtJJjb4v8RFbNu5UXNCKxYj3BPtldqshG1maNB0NWJRud7ZyAdHc0JMmR1vtHEge9Hhet4fLyyaZ9rZn4BvD9Guqgv9H/mZzUzrft9TIho0Qbu/U++lVsbZXC2GrJDDMyLnYr9C7f+FUnr0z4WvkNcg23SHBOYkOYT95NSdykIka3c3v+/HvSvuwOnMsfVxqLyCZLpo20vamBJ1uK1dmx2+TVGnUPlofFHRdOXOpJc+YmicJvrsQR6a9zlvnTbU4MYClMOKvjLe6aX5Af+n8Gw3oKcm0PuR8CPLyf9kjcmUF6XMiEXAWWJtCgvhCiFV5/mQQH3cQ1kqk4BDLUxMVhG5tzjKLoQQy39cFM32ee+QFjXlzy59meC8jgvPmOVU3GpJ32XWOtaXMCyeJrhz2QVKRLEr2KZgz8Pd8VrHARXVZsNYEasj8z0cHjgSJqTU9kD90CC+4YpvdyRBRqbNQig5KuGCqUHKgflsEsM7YrFRKP5As1LgqYQfqRAMmLSo47eW0onOwchC9wCqqisPlYSuDRt4Mun/KFGqYh1Sghn8/gzu49La8BpwlekjVEoPEcDaIIgnFzOvgmmgMANkoJ3PzhHoHMoXtObe3eSTi+eYp4qAQVzkTxfF3WXY2fui1M="); public final static SkinData METAL_MAN = new SkinData("eyJ0aW1lc3RhbXAiOjE0NzM5OTExNTk3OTQsInByb2ZpbGVJZCI6IjlmY2FlZDhiMTRiNTRmN2ZhNjRjYjYwNDBlNzA1MjcyIiwicHJvZmlsZU5hbWUiOiJMQ2FzdHIxIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS84ZDdlOGQ3MmI0MzI3MjIzZmI1ZjI5OWViN2NiNTVhMTU4OTM4MGYxMWE2ZDIzYmVmZTQ1OWFjNzg3YWY2YTcifX19", "EYXUVtnqtDhaSjBE313TpxriRtW0X7wNdmVR0ARa9qvE8CtP//AhnNxyKkERue1XIyefrYApzM4DWGzU5ZvzraOXg98p/3PSFW5p0PAp14ud/1uJWoq0FuEiJDn7Qo/+K0cuoCVsAn6Bx8nWexxr0XB8ANq/0vpRZpDOPO+irFFGwF8CPbt+7sh09glaHD9q7CM4JzPXrNjLt+ZkhYt7wEuevCXuOONT50tH0BlmfHajs9ai0IiwEwC3R+o0DooMVdCViuVEKWQfMnBDNHN4ZLwEazAcRiFO4VXOG0k/+dbKfX0EwnnygN0qmHKyhQeuR7PUumaRUMHn7sCvWmvgpNzzJMv4f9Biw2SWSI2gpaxHdCoCfFMjCdal+/BbXue6jCvDYq6yQEu+C9BjB3vT633/mbXZZMCl7bRjBzqG/jfeI1ove9o0oSqc4Nx3aA1cOnRE2iMEE74ChgY/sVk4aRVx+GTxKtyRGSzt2V7AvOVlfJh17FQhT/PkiztJ6L1RFLsFKaxQxyiCPgZSXpQ4Dz0iPonxFZl0FjAluElHYb3zn4Uop9sPBqOIeskVUl9zbdlRb7CgDG8a57YkUfs7ZyzzYYmZyt6t08H/PQr++cflY0kfy9eOBDmf9gtes7FLrHHRTE6GJ1+xAkLi5gNEkEUZKZy2embgI5JzuwCIIY8="); public final static SkinData OMEGA_CHEST = new SkinData("eyJ0aW1lc3RhbXAiOjE0NzI1MTAzNzAwOTksInByb2ZpbGVJZCI6IjlmY2FlZDhiMTRiNTRmN2ZhNjRjYjYwNDBlNzA1MjcyIiwicHJvZmlsZU5hbWUiOiJMQ2FzdHIxIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS85MDM2MjNjMmRkMjdhNWM0Y2NlYzY5MWY3NjM0YTNkMzVkNTRiNDg0YjIzNTdhNWQ1ZWFmYmYwNTRkY2NlIn19fQ==", "cQty4zNF2QgzNuVOHTGGX5YVofApKr01KkQ70bO1n+I9nlkc9qqhcigA+uBYdw4THANFsTRwIrskgTS3TTmuaXYmMUoNnj7gr2Gp7D2t7L53QyJJhIw0hHNDvQucf19SOxhtR9FvW+xnh1JcgOTF3VZxIeRaN4bCtqkeFitCJwts4Z7SlDxB4EFZVsifM+gK4iel9YWYGNnZiQm48lxU+dMFd0cCa4L00ngBExQoWC8zbJc3K9LGdqI1YOMh3bCt81F4jcrPnDycxWwOTj/tBri4yeXK1htq5dAixHwq1EF86gQMnfeIIk6D/BREtVKoXK9K4lstYPHLFiBqkwpijArbC0sZp8s/j88NYUz9PgSJ2z/b5jhPChH2OkoGQOL0/QrxqUZUet+WHaIQtvFoqmcFRCKJQembgJGZV0X86XQxEEtevkNgXPigJVyQ5GVuDCeowRkMGfSadQCBsnmdOVZNshS60tBSDcbd2oWeQUJn1+OJkmz+OktbMbP4ttN6x3+MPMSZoGT1bc1BSRNFRYOBZuNz1zLWsHFRyNLaVS3ep/ktE+Rt5sbapo+r4GjrKGV7Unx6pbfoxcnMVxWZ9X/sMgztQdwYEQlnvAxGvCY/1ZIm3/izqB2zAgG7ZfWzKjU2P5VseKokMjHXrzZX9Uqtn0zpITEaG5HjUpRSaJg="); - public final static SkinData HEADLESS_HORSEMAN = new SkinData("eyJ0aW1lc3RhbXAiOjE0NzM4ODc2MjAzODksInByb2ZpbGVJZCI6IjlmY2FlZDhiMTRiNTRmN2ZhNjRjYjYwNDBlNzA1MjcyIiwicHJvZmlsZU5hbWUiOiJMQ2FzdHIxIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS8zZGM2M2M5NWFjOTA1YjEyMWU5YTE3NmY5ZDFiN2M0MDc2ZGJjMTk3NzhkYjgzMzBlOWIzNTdhOTQ3MzMxZCJ9fX0=", "pQgM6o3nO6+NaxEmkoK33gQefe726HeVA5TVcbnGRY99S8l1UVlTu1W9Unc4IczHRYZ29I75aXUz6UDA7kIRQj4NOQHBXOxlw4cah34WkDECXYwKbgcM3HkRI/JGQf6Uooe5Mz/IaWlisEdXp9i7+WPeqz1qvzwuJ2jUqF8gaJyCbgKSWE8135k+YwinFVA78+so5meRZ6qBNfSeU48Bhf9j3H+Jmq/vwi9EJGDXKAzjYSufdYWQA7gXJQHiUFVgVKSC0wBAMHBVK7ABE2g5GIaLxOfjhOKN8Gdea9dqOUN+uXrGvg7uHxJd9Obw7MbBDVPgXnYDWYDU18DAWJcGVA8tnuPnN2a+mQrbTn9UPftYReUYJA4zpkfEKkljW6lkQ5DkVN/ueQg9QDYjxvjLblSyKHV8lX/ATt4aGiQrCcaQn6c8EeLWijPwozO+pI3MX26ydF8l+B9lTvGvQOqfUS4+TgEI5SEKlKFF4i6rTBAYCHAH8uXry7fZQDoIkcpWiB5b+e7Tr29WoScyFNuR3BMIh0Nky1TPadLxxhkqht8o9AXtccYOmtoMMh06kKWZK5m8w16j+VTUNDYwTV+jxtSFBMh4FPuiH+TzpeHY6P2Cb4gT2UlozWj8ZxZHYIGbYXAFOlDT8IQmRh5zyrXeAZrwoXJPP2OoXl31roChTxw="); public final static SkinData GHOST = new SkinData("eyJ0aW1lc3RhbXAiOjE0NzM5NjQxOTY3ODYsInByb2ZpbGVJZCI6IjlmY2FlZDhiMTRiNTRmN2ZhNjRjYjYwNDBlNzA1MjcyIiwicHJvZmlsZU5hbWUiOiJMQ2FzdHIxIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS84NjViODU3N2NlNmFhYzY4N2IxNGQ0ZGIzYmQ1MGU1NjdlZGY4Njc4MDU3ZWM2NjMyZDcxMDQ4MzFhNDk3MmIifX19", "J3nw3OIZYuYxbhOKgPGL+Kn4kWv9cjEB9ygBD07xVJUY/rdPW/BeE15qKpZQt5d8kjj0VGp1Q7g3uIS24NuiQxDZ82l1GT4dLyUN2eOj0im6VGA2yXrnGPaedfu1oPAiG+STFq0ST2IYQKYuOcncsdovxHLrpNHF6ud3WJMnSOYSfAX5NOny1UNkswzCN2OCX+QzW9hwQ+gKOc2U6g47hIcpBcTNlmD3lqXjP7OTn0Ul3kJG5J3lnwBkPnNI5OV9+oI9OWs/fbTee3pK6UVHjgH2w+fO/0jlRnShw7o1BKv/ILBkWZYuq31YiAMWKRm508SS3+kjqU37t6mqBc9AUcAeKfR4G6UiW18+eRfDPaaSnY2mTBwD3boWHYI7fM7pnPF1LmSxwSa9QSu3wsrYF9ID0QI7vyyrPIeZU/eUXE+WbFZ+Nuo/2LlZMjUmcLWa/SuuPo6lA5zJtgkVc/Rgkph+s/sZnPwgeHTFmCr2VJqgWg+J9dnO/fLPkddgzjoy5uOCAO70E/cwbpqGxKD+0iQU0Vk9TzQnCMAUDtzeoyNkuk204cDSqPKtH5JIoQHa6wFAEgaKZoSETBJMZmKzZhne5pVr+NVkmGHOuZ/uE6JH1F4T+vTeeLSEroPDhrNfwVtrrqBFnI/xijfEHdPmtP9OTSDju7MHnEZu4RS7y6Q="); public final static SkinData HAUNTED_CHEST = new SkinData("eyJ0aW1lc3RhbXAiOjE0NzUyNTUzOTE3OTcsInByb2ZpbGVJZCI6IjlmY2FlZDhiMTRiNTRmN2ZhNjRjYjYwNDBlNzA1MjcyIiwicHJvZmlsZU5hbWUiOiJMQ2FzdHIxIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS9lZWM5MmU4ODNiOGFjODI0MDU5YTk5NGM5NTNjNTQ0NDQ0Yjk3ZWFkZDdhNWFjNGY3ZTZhOTUxOGQ5YTkxMSJ9fX0=", "GqycEQvWoZeXDLAJ6ricUx3coA4Y6AswL0GV1KebetoTkd9XNtkJJ9eUf6ViwpSgmL0H89sdMjghThHKczUEmjaFeNl2Z9cwGnR1WOK3KpD+v8C7f10l2DNd7z8s1clJfkVay/5KkgNMneu+ZStF8mCt+uyOSfZX4toLRBba6ZDaz4RlmcNt3e6h+dCaB/npbrWxddX7YZWsAMEKxmMKrG/Rm1Gx7ZOchmd4l6+pypA3Vrjoc0LVjqDV/TsePiNxV9LWFB7Rc6YGkIyz2+z5m168iLnn4+qMMXOYndwH7RGcTLEJDPRfNjawuPNcRlYZ6bf30S540MQdC0dJbRLu0uT9CAyi1vjxezdKjGJZSiY5WmtWrhkiRRtCMr9fGxBRNxPDdf5bs7IgWClFgafkGFZKZjLlOV8qtlMrPQSduPtGBCM64veJchSMFS6MfxgE2O/+4EZ246ZN1bdV6KiLRDIzFmy9PBn2o6MNtcdFc/G5XdD7aCTwuGD6sbG2T97Aiai56CN1vYsc6yXUfeZafSm6qviXAx3zTEd1aw1oAZLj3PAt0uZRHggsBEKvwPVKsgHsOVFj5vu0BfHFbdaSdhL3GFotk06Ilr5cLxOrTwqoVNp/hiIJ8pu7T0AEWy1pMYD1+RszsTjJ76l305cQ3UHvinjnbXllsFQIIVE899s="); public final static SkinData WITCH = new SkinData("eyJ0aW1lc3RhbXAiOjE0NzM5OTEyMTE1NDQsInByb2ZpbGVJZCI6IjlmY2FlZDhiMTRiNTRmN2ZhNjRjYjYwNDBlNzA1MjcyIiwicHJvZmlsZU5hbWUiOiJMQ2FzdHIxIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS81NDg1ZDZlMTBhNmNmMmY3Mzg2NmZhMGRiNjEzOWQ5NWViZDM0ZGZiMGY0YzAxMmRkM2YzYWYxMWQ5ZjQxYyJ9fX0=", "cojkGLflVWxwnhDXmHMke7crkeA78iUYOWY7H3YvMJFD+VZi9E7vUahLTTx5ELH+PvcaHJerSDmuV+Nasc3K2n6zlXXb0B7RB/ose/kdPxHAIJee7IbZX0iFNDn6irUSOS4wOYF/BwaqG3HmpoSxV52SGMs6kqTer2Rjg3X+XwYFFiDHAR/gwhfXLzrM1iBc171vgu6T+kx65iBHa/YB/V/mj8FSxwM0f5IsLpgAEdxDL9PvEKQWgWeZ1CAqEXlGnjPkd9oGzW0TgDz2MksBbYZ2kmn/S53kK9vCrVB7egZPS4VBtKpq1P7Jeu8rtgjnAKVFQJZ2lMHnVRuvGTd8JKoPHarUPpU2LURUMaCtHzSv9v/4gjkafnDhqxG4TTcr5hxFV+ho72HQchoeaUXzIO+Yo71zrVqkrS0hw6OtgMIBlvaGaEUsFvGiCZePBEiHojO43AKqJcJAVeT2RAzHcAaBAO79ACGjNKw/oj02rOurLha9i+99bKui96Eg7SS/nPchbmu5YQ9nSpkW+JeYXnBzGGzNG4y02VWgz15L718+8161zXobhuK07qlY9i1nipFbEJedqG0cfS+AUzauETFvS9nMtxhtftYPCIxm40GQj6e77asNCAEElGssaUGKO3bjm348+oF9tR/eBOYWJQ8kL46IQLDRoop7UhG4ewY="); + public final static SkinData TURKEY = new SkinData("eyJ0aW1lc3RhbXAiOjE0NzU3NzM2MTc5MDQsInByb2ZpbGVJZCI6IjlmY2FlZDhiMTRiNTRmN2ZhNjRjYjYwNDBlNzA1MjcyIiwicHJvZmlsZU5hbWUiOiJMQ2FzdHIxIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS8xYzdmYjczMTRkNmY1ZTMzNmVjN2ViNTI1ZGM0ODMzOWNhMjI4ZDk3ODU1MDM3ZDZhNDIwOGZjNzYwNDc1NiJ9fX0=", "eZWi1LOD8ke7MCUAfhspBCnyfCoGM8suFLKtbW6b27CURoRBG3eKIfwLYYeMp3ObjoZ8gCB90s28Qyw5XMzwvvowy9W/b5cYC0OzQ8+GR7tDZoWc28tGqGBM8cmDJIFQgZdceBIIr2lXeAvEJfLbyrus46hPjk8YTiQW2DsBq88BhKIy6Igb1rGqJ1goVERF07b6+/yMdLKCaT8OZFzKLXfo5rY5gr6HLnvsQiNL9aTrl74agXn1GUcP+QVNe7/c9lYmv5vLCBst1YiIPq27NZASZ++Fwyv6+PRlaFZZYtMHVd4UZeYPl7ak1Cdi/1sUcRpkBbJM8AHIrqq0iuXxrLbc6ldQ2cYQKHg9ljIpW/EZanuf6Wgm/LK1JnxXne9GUb/xPzB1EnZ95i8/u9WJa+NixEcfc3pAzDPYncIR8lishFwyBRta6BCG76U3UY2lQr3YD/48AJ49r7+WVU0gOP/h2SDSdAZHEdvkpVJ0w/xA+SevJ7Y7xA5EJ655YMQ0F8f3WUFTf1pFklE5E+fwkMVCWOPw7UMy558IcRSpdWAPPyf8sc7CpDqRk37/vXWRDa+7YBfgskK6B2eXowrzThUOBx+AmDTF3Rv8ZSr1Un0FWGi+GQ5ny7W9dJBMomzyMUbzz9stsCml5XB+6xLP2MD+9lO1bHipKS6qkhtZChE="); // Comments this out for now, so it doesn't load the player profile // A better way to do this would check for the properties when getting the skull or the skin diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/PlayerMap.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/PlayerMap.java new file mode 100644 index 000000000..426d2fd20 --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/PlayerMap.java @@ -0,0 +1,233 @@ +package mineplex.core.common.util; + +import com.google.common.collect.Sets; +import org.apache.commons.lang3.Validate; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerQuitEvent; + +import javax.annotation.Nonnull; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import java.util.WeakHashMap; +import java.util.concurrent.ConcurrentHashMap; + +public class PlayerMap implements Map +{ + private static final Object LOCK = new Object(); + + private static final RemovalListener REMOVAL_LISTENER = new RemovalListener(); + private static final Set> ALL_PLAYER_MAPS = Sets.newSetFromMap(new WeakHashMap<>()); + + static + { + UtilServer.RegisterEvents(REMOVAL_LISTENER); + } + + private final Map _backingMap; + + private PlayerMap(Map backingMap) + { + this._backingMap = backingMap; + + synchronized (LOCK) + { + ALL_PLAYER_MAPS.add(this); + } + } + + public static PlayerMap newMap() + { + return new PlayerMap<>(new HashMap<>()); + } + + public static PlayerMap newConcurrentMap() + { + return new PlayerMap<>(new ConcurrentHashMap<>()); + } + + @Override + public int size() + { + return _backingMap.size(); + } + + @Override + public boolean isEmpty() + { + return _backingMap.isEmpty(); + } + + @Override + @Deprecated + public boolean containsKey(Object key) + { + Validate.notNull(key, "Key cannot be null"); + if (key instanceof Player) + { + return containsKey((Player) key); + } + else if (key instanceof UUID) + { + return containsKey((UUID) key); + } + throw new UnsupportedOperationException("Unknown key type: " + key.getClass().getName()); + } + + public boolean containsKey(Player key) + { + Validate.notNull(key, "Player cannot be null"); + return _backingMap.containsKey(key.getUniqueId()); + } + + public boolean containsKey(UUID key) + { + return _backingMap.containsKey(key); + } + + @Override + public boolean containsValue(Object value) + { + return _backingMap.containsValue(value); + } + + @Override + @Deprecated + public V get(Object key) + { + Validate.notNull(key, "Key cannot be null"); + if (key instanceof Player) + { + return get((Player) key); + } + else if (key instanceof UUID) + { + return get((UUID) key); + } + throw new UnsupportedOperationException("Unknown key type: " + key.getClass().getName()); + } + + public V get(Player key) + { + return _backingMap.get(key.getUniqueId()); + } + + public V get(UUID key) + { + return _backingMap.get(key); + } + + @Override + public V put(UUID key, V value) + { + return _backingMap.put(key, value); + } + + public V put(Player key, V value) + { + Validate.notNull(key, "Player cannot be null"); + return put(key.getUniqueId(), value); + } + + @Override + @Deprecated + public V remove(Object key) + { + Validate.notNull(key, "Key cannot be null"); + if (key instanceof Player) + { + return remove((Player) key); + } + else if (key instanceof UUID) + { + return remove((UUID) key); + } + throw new UnsupportedOperationException("Unknown key type: " + key.getClass().getName()); + } + + public V remove(Player key) + { + return _backingMap.remove(key.getUniqueId()); + } + + public V remove(UUID key) + { + return _backingMap.remove(key); + } + + @Override + public void putAll(@Nonnull Map m) + { + _backingMap.putAll(m); + } + + @Override + public void clear() + { + _backingMap.clear(); + } + + @Override + @Nonnull + public Set keySet() + { + return _backingMap.keySet(); + } + + @Override + @Nonnull + public Collection values() + { + return _backingMap.values(); + } + + @Override + @Nonnull + public Set> entrySet() + { + return _backingMap.entrySet(); + } + + @Override + public String toString() + { + return _backingMap.toString(); + } + + @Override + public boolean equals(Object o) + { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + PlayerMap playerMap = (PlayerMap) o; + + return _backingMap.equals(playerMap._backingMap); + + } + + @Override + public int hashCode() + { + return _backingMap.hashCode(); + } + + private static class RemovalListener implements Listener + { + @EventHandler + public void onQuit(PlayerQuitEvent event) + { + synchronized (LOCK) + { + for (PlayerMap map : ALL_PLAYER_MAPS) + { + map.remove(event.getPlayer()); + } + } + } + } +} diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java index 0e78782db..ee6eed0df 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java @@ -1,6 +1,7 @@ package mineplex.core.common.util; import java.lang.reflect.Field; +import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedList; import java.util.List; @@ -132,6 +133,64 @@ public class UtilEnt } + /** + * See {@link #getEntitiesInsideEntity(Entity, List)} + * Uses all players in the same world as the entity as input + */ + public static List getPlayersInsideEntity(Entity ent) + { + return getEntitiesInsideEntity(ent, ent.getWorld().getPlayers()); + } + + /** + * See {@link #getEntitiesInsideEntity(Entity, List)} + * Uses all entities in the same world as the entity as input + */ + public static List getEntitiesInsideEntity(Entity ent) + { + return getEntitiesInsideEntity(ent, ent.getWorld().getEntities()); + } + + /** + * See {@link #getEntitiesInsideEntity(Entity, List)} + * Auto cast to list of players + */ + public static List getPlayersInsideEntity(Entity ent, List players) + { + return getEntitiesInsideEntity(ent, players); + } + + /** + * Returns entities which are inside the provided entity's boundingbox + * @param ent The entity to check inside + * @param entities List of entities to check + * @return Returns a sublist of entities which are inside the entity's boundingbox + */ + public static List getEntitiesInsideEntity(Entity ent, List entities) + { + AxisAlignedBB box = ((CraftEntity)ent).getHandle().getBoundingBox(); + + List list = new ArrayList<>(); + + for(T e : entities) + { + AxisAlignedBB box2 = ((CraftEntity)e).getHandle().getBoundingBox(); + if(box2.b(box)) list.add(e); + } + return list; + } + + /** + * @return Returns true if the entities boundinbox collides or is inside the given bounding box + */ + public static boolean isInsideBoundingBox(Entity ent, Vector a, Vector b) + { + AxisAlignedBB box = ((CraftEntity)ent).getHandle().getBoundingBox(); + AxisAlignedBB box2 = new AxisAlignedBB(a.getX(), a.getY(), a.getZ(), b.getX(), b.getY(), b.getZ()); + + return box.b(box2); + } + public static void Vegetate(Entity entity) { Vegetate(entity, false); @@ -345,6 +404,35 @@ public class UtilEnt } } + /** + * Set whether this entity should be ticked normally when far away. By default entities are only ticked once every 20 ticks + * when they are outside the activation range. + * + * Default ranges are calculated in a AABB fashion from their closest player: + * animalActivationRange = 32 + * monsterActivationRange = 32 + * miscActivationRange = 16 + * + * Entities that are unaffected by range (always active): + * Players, Projectiles, Enderdragon, Wither, Fireballs, Lightning strikes, TNT, Ender Crystals and Fireworks. + * + * You can make entities which are by default active (Projectiles etc) not load when far away + * or make entities that are not active by default (mobs, animals etc) load when far away + */ + public static void setTickWhenFarAway(Entity ent, boolean loadWhenFar) + { + try + { + Field state = net.minecraft.server.v1_8_R3.Entity.class.getDeclaredField("defaultActivationState"); + state.setAccessible(true); + state.setBoolean(((CraftEntity)ent).getHandle(), loadWhenFar); + } + catch(Exception e) + { + e.printStackTrace(); + } + } + public static String getName(Entity ent) { if (ent == null) @@ -578,6 +666,16 @@ public class UtilEnt return false; } + public static float getStepHeight(Entity ent) + { + return ((CraftEntity)ent).getHandle().S; + } + + public static void setStepHeight(Entity ent, float stepHeight) + { + ((CraftEntity)ent).getHandle().S = stepHeight; + } + public static boolean isGrounded(Entity ent) { @@ -813,6 +911,18 @@ public class UtilEnt return true; } + + /** + * Returns true if the entity got a path that will lead it closer to the current navigation path finding target. + * It will return false, it it is as close as it can get. Using this got an advantage compared to distance checking, as the target + * might be inside blocks, leaving the entity unable to get any closer. + * @param ent The entity to check + * @return Returns whether the entity can walk any closer to the current navigation target. + */ + public static boolean canEntityWalkCloserToNavigationTarget(Creature ent) + { + return ((CraftCreature)ent).getHandle().getNavigation().m(); + } public static int getNewEntityId() { @@ -887,7 +997,17 @@ public class UtilEnt { ((CraftEntity)ent).getHandle().setSize((float) width, (float)height); } - + + public static double getHeight(Entity ent) + { + return ((CraftEntity)ent).getHandle().length; + } + + public static double getWidth(Entity ent) + { + return ((CraftEntity)ent).getHandle().width; + } + public static void SetMetadata(Entity entity, String key, Object value) { entity.setMetadata(key, new FixedMetadataValue(UtilServer.getPlugin(), value)); diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilFuture.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilFuture.java index 2b25f9a5e..d7906385b 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilFuture.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilFuture.java @@ -86,7 +86,7 @@ public class UtilFuture CompletableFuture.allOf(values.toArray(new CompletableFuture[values.size()])); return futuresCompleted.thenApply(v -> - seqValues.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().join()))); + (Map>) seqValues.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry -> (Collection) entry.getValue().join()))); } /** diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java index 773fcf442..5f7e00ddc 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java @@ -1,16 +1,17 @@ package mineplex.core.common.util; -import mineplex.core.common.MinecraftVersion; -import mineplex.core.common.events.PlayerMessageEvent; -import net.md_5.bungee.api.chat.ClickEvent; -import net.md_5.bungee.api.chat.ClickEvent.Action; -import net.md_5.bungee.api.chat.HoverEvent; -import net.md_5.bungee.api.chat.TextComponent; -import net.minecraft.server.v1_8_R3.EntityPlayer; -import net.minecraft.server.v1_8_R3.Packet; -import net.minecraft.server.v1_8_R3.PacketPlayOutWorldBorder; -import net.minecraft.server.v1_8_R3.PlayerConnection; -import net.minecraft.server.v1_8_R3.WorldBorder; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.UUID; + import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.Location; @@ -26,9 +27,23 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryView; import org.bukkit.potion.PotionEffect; +import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.util.BlockIterator; import org.bukkit.util.Vector; +import mineplex.core.common.MinecraftVersion; +import mineplex.core.common.events.PlayerMessageEvent; +import net.md_5.bungee.api.chat.ClickEvent; +import net.md_5.bungee.api.chat.ClickEvent.Action; +import net.md_5.bungee.api.chat.HoverEvent; +import net.md_5.bungee.api.chat.TextComponent; +import net.minecraft.server.v1_8_R3.EntityPlayer; +import net.minecraft.server.v1_8_R3.EntityTracker; +import net.minecraft.server.v1_8_R3.EntityTrackerEntry; +import net.minecraft.server.v1_8_R3.Packet; +import net.minecraft.server.v1_8_R3.PacketPlayOutWorldBorder; +import net.minecraft.server.v1_8_R3.PlayerConnection; +import net.minecraft.server.v1_8_R3.WorldBorder; import java.util.*; public class UtilPlayer @@ -73,6 +88,49 @@ public class UtilPlayer return true; } + public static void setSpectating(Player player, Entity ent) + { + if(!ent.isValid()) return; + + player.setGameMode(GameMode.SPECTATOR); + + if(player.getSpectatorTarget() != null) + { + player.setSpectatorTarget(null); + } + + player.teleport(ent); + + if(isTracked(player, ent)) + { + player.setSpectatorTarget(ent); + } + else + { + new BukkitRunnable() + { + public void run() + { + setSpectating(player, ent); + } + }.runTaskLater(UtilServer.getPlugin(), 1); + } + } + + /** + * Returns true if the given player is tracking the given target, meaning that the player + * got the entity loaded and knows about the entity. + */ + public static boolean isTracked(Player player, Entity target) + { + EntityPlayer ep = ((CraftPlayer) player).getHandle(); + + EntityTracker tracker = ep.u().getTracker(); + EntityTrackerEntry entry = tracker.trackedEntities.get(target.getEntityId()); + + return entry.trackedPlayers.contains(ep); + } + public static void hideFrom(Player player, Collection players) { players.stream().forEach(p->p.hidePlayer(player)); } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilReflection.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilReflection.java new file mode 100644 index 000000000..079182304 --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilReflection.java @@ -0,0 +1,33 @@ +package mineplex.core.common.util; + +import java.lang.reflect.Field; + +public class UtilReflection +{ + /** + * Returns the value of the field from the given object instance + */ + public static Object getValueOfField(Object object, String fieldName) + { + return getValueOfField(object.getClass(), object, fieldName); + } + + /** + * Returns the value of the field from the given object instance + */ + public static Object getValueOfField(Class className, Object object, String fieldName) + { + try + { + Field f = className.getDeclaredField(fieldName); + f.setAccessible(true); + return f.get(object); + } + catch (Exception e) + { + e.printStackTrace(); + return null; + } + } + +} diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/particles/effects/LineParticle.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/particles/effects/LineParticle.java index a19623df1..5eb91a337 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/particles/effects/LineParticle.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/particles/effects/LineParticle.java @@ -75,12 +75,7 @@ public class LineParticle if (!(UtilBlock.airFoliage(newTarget.getBlock()) || UtilBlock.airFoliage(newTarget.getBlock().getRelative(BlockFace.UP)))) { - if (_ignoredTypes == null) - { - done = true; - } - - if (!_ignoredTypes.contains(newTarget.getBlock().getType())) + if (_ignoredTypes == null || !_ignoredTypes.contains(newTarget.getBlock().getType())) { done = true; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java index 5db45158f..b8bd978f1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java @@ -68,6 +68,8 @@ public class AntiHack extends MiniPlugin .put("Killaura (Type B)", new CheckThresholds("High CPS", 0, 0, Integer.MAX_VALUE)) .put("Killaura (Type C)", new CheckThresholds("Reach", 0, Integer.MAX_VALUE, Integer.MAX_VALUE)) .put("Killaura (Type D)", new CheckThresholds("Kill Aura", 500, 1000, 1500)) + .put("Killaura (Type E)", new CheckThresholds("Kill Aura", 300, 700, 2000)) + .put("Killaura (Type F)", new CheckThresholds("Kill Aura", 150, 250, 350)) .put("BadPackets", new CheckThresholds("Regen", 500, 1000, 2000)) .put("Glide", new CheckThresholds("Flying", 50, 100, 200)) // TODO: specific VL levels .put("Speed", new CheckThresholds("Speed", 50, 100, 200)) // TODO: specific VL levels diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHackGuardian.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHackGuardian.java index 8535483a9..9cff0ce43 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHackGuardian.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHackGuardian.java @@ -376,9 +376,13 @@ public class AntiHackGuardian implements Listener public void remove() { - this._armorStand.remove(); this._target = null; + UtilServer.Unregister(this); Managers.get(DisguiseManager.class).undisguise(this._disguise); + this._armorStand.remove(); + this._nmsEntity = null; + this._armorStand = null; + this._center = null; } public ArmorStand getEntity() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java index 9c692c7d1..d609f656b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java @@ -14,8 +14,6 @@ import mineplex.core.bonuses.event.CarlSpinnerEvent; import mineplex.core.bonuses.gui.BonusGui; import mineplex.core.bonuses.gui.SpinGui; import mineplex.core.bonuses.gui.buttons.PowerPlayClubButton; -import mineplex.core.bonuses.redis.VoteHandler; -import mineplex.core.bonuses.redis.VotifierCommand; import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; @@ -48,8 +46,6 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.core.youtube.YoutubeManager; import mineplex.database.Tables; -import mineplex.database.tables.records.BonusRecord; -import mineplex.serverdata.commands.ServerCommandManager; import mineplex.serverdata.database.DBPool; import net.minecraft.server.v1_8_R3.DataWatcher; import net.minecraft.server.v1_8_R3.EntityCreeper; @@ -93,7 +89,7 @@ public class BonusManager extends MiniClientPlugin implements I private ArrayList _pendingExplosionsPlayers = new ArrayList<>(); private HashMap _showCarl = new HashMap<>(); private long _explode; - private boolean _canVote; + private boolean _animationRunning; public static long getSqlTime() { @@ -140,43 +136,10 @@ public class BonusManager extends MiniClientPlugin implements I private AnimationCarl _animation; private int _visualTick; - // Streak -// private StreakRecord _dailyStreak; -// private StreakRecord _voteStreak; - - private ArrayList _voteList; - // Donor Queues private Queue _coinQueue; private Queue _gemQueue; - /** - * THIS SHOULD ONLY BE USED FOR VOTIFIER! - */ - public BonusManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager) - { - super("Bonus", plugin); - _enabled = false; - - _repository = new BonusRepository(plugin, this, donationManager); - _clientManager = clientManager; - _donationManager = donationManager; - _powerPlayClubRepository = new PowerPlayClubRepository(plugin, clientManager, donationManager); - - System.out.print("VOTIFIER: "); - System.out.print("DONATION MANAGER - > " + _donationManager.toString()); - - _voteList = new ArrayList<>(); - _voteList.add("http://vote1.mineplex.com"); - _voteList.add("http://vote2.mineplex.com"); - _voteList.add("http://vote3.mineplex.com"); - - _coinQueue = new LinkedList<>(); - _gemQueue = new LinkedList<>(); - - updateOffSet(); - } - public BonusManager(JavaPlugin plugin, Location carlLocation, PlayWireManager playWireManager, CoreClientManager clientManager, DonationManager donationManager, PollManager pollManager, NpcManager npcManager, HologramManager hologramManager, StatsManager statsManager, InventoryManager inventoryManager, PetManager petManager, FacebookManager facebookManager, YoutubeManager youtubeManager, GadgetManager gadgetManager, ThankManager thankManager) { super("Bonus", plugin); @@ -204,12 +167,6 @@ public class BonusManager extends MiniClientPlugin implements I _powerPlayClubRepository = new PowerPlayClubRepository(plugin, _clientManager, _donationManager); - _voteList = new ArrayList<>(); - _voteList.add("http://vote1.mineplex.com"); - _voteList.add("http://vote2.mineplex.com"); - _voteList.add("http://vote3.mineplex.com"); - - _canVote = true; _coinQueue = new LinkedList<>(); _gemQueue = new LinkedList<>(); @@ -239,10 +196,7 @@ public class BonusManager extends MiniClientPlugin implements I clientManager.addStoredProcedureLoginProcessor(this); - ServerCommandManager.getInstance().registerCommandType("VotifierCommand", VotifierCommand.class, new VoteHandler(this)); - updateOffSet(); -// updateStreakRecord(); } @@ -263,25 +217,6 @@ public class BonusManager extends MiniClientPlugin implements I return; updateOffSet(); } - - - public void handleVote(final Player player, final int shardsReceived) - { - final int accountId = _clientManager.getAccountId(player); - - runAsync(() -> _repository.getClientData(accountId, data -> runSync(() -> - { - BonusClientData oldData = Get(player); - if (oldData != null) data.setHologram(oldData.getHologram()); - Set(player, data); - - _statsManager.incrementStat(player, "Global.DailyVote", 1); - addPendingExplosion(player, player.getName()); - UtilPlayer.message(player, F.main("Carl", "Thanks for voting for Mineplex!")); - UtilPlayer.message(player, F.main("Carl", "You received " + F.elem("1 Carl Spinner Ticket") + "!")); - }))); - - } @EventHandler public void fireCreeper(UpdateEvent event) @@ -291,16 +226,16 @@ public class BonusManager extends MiniClientPlugin implements I if(_pendingExplosions.isEmpty()) return; - - if(!_canVote) - return; + if (_animationRunning) + return; + if (!_enabled) return; - + + _animationRunning = true; _explode = System.currentTimeMillis(); _animation.setTicks(0); - _canVote = false; } @EventHandler @@ -311,10 +246,10 @@ public class BonusManager extends MiniClientPlugin implements I _animation.itemClean(); - if(_canVote) + if (!_enabled) return; - if (!_enabled) + if (!_animationRunning) return; Entity creeper = _carlNpc.getEntity(); @@ -344,10 +279,10 @@ public class BonusManager extends MiniClientPlugin implements I if(!_animation.isDone()) return; + _animationRunning = false; DecreaseSize(creeper); _pendingExplosions.remove(0); _pendingExplosionsPlayers.remove(0); - _canVote = true; } @EventHandler @@ -385,7 +320,6 @@ public class BonusManager extends MiniClientPlugin implements I public static final long TIME_BETWEEN_BONUSES = 1000 * 60 * 60 * 20; public static final long DAILY_STREAK_RESET_TIME = 1000 * 60 * 60 * 12; - public static final long VOTE_STREAK_RESET_TIME = 1000 * 60 * 60 * 24; public void attemptDailyBonus(final Player player, final BonusAmount amount, final Callback result) @@ -509,20 +443,6 @@ public class BonusManager extends MiniClientPlugin implements I } } - public void updateVoteStreak(BonusRecord client) - { - if (client.getVoteStreak() > 0 && client.getVotetime() != null) - { - long lastBonus = getLocalTime(client.getVotetime().getTime()); - long timeLeft = getStreakTimeRemaining(lastBonus, BonusManager.VOTE_STREAK_RESET_TIME); - - if (timeLeft < 0) - { - client.setVoteStreak(0); - } - } - } - public void incrementDailyStreak(Player player) { BonusClientData data = Get(player); @@ -533,14 +453,6 @@ public class BonusManager extends MiniClientPlugin implements I data.setMaxDailyStreak(data.getDailyStreak()); } - public void incrementVoteStreak(BonusRecord client) - { - client.setVoteStreak(client.getVoteStreak() + 1); - - if (client.getVoteStreak() > client.getMaxVoteStreak()) - client.setMaxVoteStreak(client.getVoteStreak()); - } - public boolean continueStreak(long localLastBonus, long extendTime) { long maxTime = localLastBonus + TIME_BETWEEN_BONUSES + extendTime; @@ -581,13 +493,6 @@ public class BonusManager extends MiniClientPlugin implements I return multiplier; } - public int getVoteMultiplier(int streak) - { - int multiplier = Math.min(100, 5 * streak); - if (streak >= 20) multiplier += (1 * (streak - 40)); - return multiplier; - } - public BonusAmount getDailyBonusAmount(Player player) { double mult = getDailyMultiplier(player) / 100.0; @@ -607,21 +512,6 @@ public class BonusManager extends MiniClientPlugin implements I return amount; } - public BonusAmount getVoteBonusAmount(Player player) - { - return getVoteBonusAmount(Get(player).getVoteStreak()); - } - - public BonusAmount getVoteBonusAmount(int voteStreak) - { - double mult = getVoteMultiplier(voteStreak) / 100.0; - - BonusAmount amount = new BonusAmount(); - amount.setTickets(1); - - return amount; - } - public BonusAmount getRankBonusAmount(Player player) { Rank rank = _clientManager.Get(player).GetRank(); @@ -648,25 +538,6 @@ public class BonusManager extends MiniClientPlugin implements I return data; } - //VOTE - - public long timeTillVoteBonus(Player player) - { - return nextVoteTime(player) - getLocalTime(); - } - - // This calculates the the next vote bonus, IT HAS TO MATCH THE MYSQL STORED FUNCTION. - public long nextVoteTime(Player player) - { - Date date = Get(player).getVoteTime(); - if (date == null) - return 0; - long lastBonus = date.getTime(); - - return getNextVoteTime(getLocalTime(lastBonus)); - - } - public void awardBonus(final Player player, BonusAmount amount) { final BonusClientData bonusClient = Get(player); @@ -774,27 +645,6 @@ public class BonusManager extends MiniClientPlugin implements I } } - public static long getNextVoteTime(long time) { - - Calendar calendar = Calendar.getInstance(); - calendar.setTimeZone(TIMEZONE); - calendar.setTimeInMillis(time); - - calendar.add(Calendar.DAY_OF_YEAR, 1); - calendar.set(Calendar.HOUR_OF_DAY, 0); - calendar.set(Calendar.MINUTE, 0); - calendar.set(Calendar.SECOND, 0); - calendar.set(Calendar.MILLISECOND, 0); - - return calendar.getTimeInMillis(); - } - - public boolean canVote(Player player) - { - long nextVoteTime = nextVoteTime(player); - return System.currentTimeMillis() >= nextVoteTime; - } - public boolean canDaily(Player player) { long nextDailyTime = nextDailyBonus(player); @@ -826,7 +676,7 @@ public class BonusManager extends MiniClientPlugin implements I int availableRewards = 0; - if (canVote(player)) availableRewards++; + if (_playWireManager.canRedeem(player)) availableRewards++; if (_youtubeManager.canYoutube(player)) availableRewards++; if (canRank(player) && _clientManager.hasRank(player, Rank.ULTRA) && isPastAugust()) availableRewards++; if (canDaily(player)) availableRewards++; @@ -991,7 +841,7 @@ public class BonusManager extends MiniClientPlugin implements I { if (Recharge.Instance.use(player, "Carl Inform", 240000, false, false)) { - if(_pollManager.hasPoll(player) || canVote(player) || (canRank(player) && _clientManager.hasRank(player, Rank.ULTRA) && isPastAugust()) || canDaily(player) || PowerPlayClubButton.isAvailable(player, _powerPlayClubRepository)) + if(_pollManager.hasPoll(player) || _playWireManager.canRedeem(player) || (canRank(player) && _clientManager.hasRank(player, Rank.ULTRA) && isPastAugust()) || canDaily(player) || PowerPlayClubButton.isAvailable(player, _powerPlayClubRepository)) { if(_showCarl.containsKey(player.getName())) { @@ -1048,16 +898,6 @@ public class BonusManager extends MiniClientPlugin implements I } } - public String getVoteLink() - { - long sqlTime = getSqlTime(); - Calendar calendar = Calendar.getInstance(); - calendar.setTimeInMillis(sqlTime); - int date = calendar.get(Calendar.DAY_OF_YEAR); - int index = date % _voteList.size(); - return _voteList.get(index); - } - /** * Used for disabling rank rewards during first month of release * @return @@ -1120,4 +960,4 @@ public class BonusManager extends MiniClientPlugin implements I { _carlLocation = carlLocation; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/animations/AnimationCarl.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/animations/AnimationCarl.java index 6c966aedf..5e2fb892a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/animations/AnimationCarl.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/animations/AnimationCarl.java @@ -158,6 +158,7 @@ public class AnimationCarl extends Animation @Override protected void onFinish() { _isDone = true; + _player = null; setTicks(0); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/BonusGui.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/BonusGui.java index 9a6125254..99faaa17a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/BonusGui.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/BonusGui.java @@ -14,10 +14,10 @@ import org.bukkit.plugin.Plugin; public class BonusGui extends SimpleGui { - private final int VOTE_SLOT = 10; - private final int RANK_BONUS_SLOT = 12; - private final int DAILY_BONUS_SLOT = 14; - private final int POLL_SLOT = 16; + //private final int VOTE_SLOT = 10; + private final int RANK_BONUS_SLOT = 11; + private final int DAILY_BONUS_SLOT = 13; + private final int POLL_SLOT = 15; private final int FACEBOOK_SLOT = 19; private final int CLAIM_TIPS_SLOT = 25; private final int POWER_PLAY_SLOT = 21; @@ -32,7 +32,7 @@ public class BonusGui extends SimpleGui { super(plugin, player, player.getName() + "'s Bonuses", INV_SIZE); - setItem(VOTE_SLOT, new VoteButton(plugin, player, this, manager)); + //setItem(VOTE_SLOT, new VoteButton(plugin, player, this, manager)); setItem(RANK_BONUS_SLOT, new RankBonusButton(getPlugin(), player, this, manager)); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/FacebookButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/FacebookButton.java index 9b9d41350..d6d54a6aa 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/FacebookButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/FacebookButton.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import org.bukkit.ChatColor; import org.bukkit.Material; +import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; @@ -12,6 +13,7 @@ import mineplex.core.bonuses.BonusAmount; import mineplex.core.common.jsonchat.ClickEvent; import mineplex.core.common.jsonchat.JsonMessage; import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilPlayer; import mineplex.core.facebook.FacebookManager; import mineplex.core.gui.GuiItem; import mineplex.core.itemstack.ItemStackFactory; @@ -43,8 +45,31 @@ public class FacebookButton implements GuiItem public void click(ClickType clickType) { _player.closeInventory(); + + _player.playSound(_player.getLocation(), Sound.NOTE_PLING, 1, 1.6f); + + final String message; + if (isAvailable()) + { + message = "claim Facebook Prize!"; + } + else + { + message = "visit our Facebook page!"; + } + + UtilPlayer.message(_player, C.cGold + C.Bold + C.Strike + "============================================="); + UtilPlayer.message(_player, ""); - new JsonMessage(C.cAquaB + "Click here to claim Facebook Prize!").click(ClickEvent.OPEN_URL, "https://www.facebook.com/MineplexGames/app/185301094822359/").sendToPlayer(_player); + new JsonMessage(" " + C.Bold + "Click to Open in Web Browser and " + message).click(ClickEvent.OPEN_URL, "https://www.facebook.com/MineplexGames/app/185301094822359/").sendToPlayer(_player); + new JsonMessage(" " + C.cGreen + C.Line + "https://www.facebook.com/MineplexGames").click(ClickEvent.OPEN_URL, "https://www.facebook.com/MineplexGames/app/185301094822359/").sendToPlayer(_player); + UtilPlayer.message(_player, ""); + if (isAvailable()) + { + UtilPlayer.message(_player, " Please be patient. Prizes may take a few minutes to register."); + UtilPlayer.message(_player, ""); + } + UtilPlayer.message(_player, C.cGold + C.Bold + C.Strike + "============================================="); } private boolean isAvailable() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PlayWireButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PlayWireButton.java index b877b1bb1..a427b793b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PlayWireButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PlayWireButton.java @@ -20,7 +20,7 @@ public class PlayWireButton implements GuiItem .setTitle(C.cGreen + C.Bold + "Watch an Ad!") .addLore( C.cWhite + "You have already redeemed your", - C.cWhite + "100 Shards for watching the Ad!", + C.cWhite + "rewards for watching the Ad!", " ", C.cWhite + "You can watch it again, but you won't earn any shards!", " ", @@ -37,6 +37,7 @@ public class PlayWireButton implements GuiItem .setTitle(C.cGreen + C.Bold + "Watch an Ad!") .addLore( C.cYellow + "Earn a 100 Shard Reward", + C.cYellow + "and 1 Carl Spin Ticket", C.cWhite + "by checking out our partner's Advertisement", " ", C.cWhite + "You can watch the Ad once every hour.", diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/TwitterButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/TwitterButton.java similarity index 59% rename from Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/TwitterButton.java rename to Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/TwitterButton.java index fd9804d5d..4700bad1c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/TwitterButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/TwitterButton.java @@ -1,11 +1,13 @@ -package mineplex.core.bonuses.gui; +package mineplex.core.bonuses.gui.buttons; import mineplex.core.common.jsonchat.ClickEvent; import mineplex.core.common.jsonchat.JsonMessage; import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilPlayer; import mineplex.core.gui.GuiItem; import mineplex.core.itemstack.ItemBuilder; import org.bukkit.Material; +import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; @@ -39,8 +41,16 @@ public class TwitterButton implements GuiItem public void click(ClickType clickType) { _player.closeInventory(); + + _player.playSound(_player.getLocation(), Sound.NOTE_PLING, 1, 1.6f); + + UtilPlayer.message(_player, C.cGold + C.Bold + C.Strike + "============================================="); + UtilPlayer.message(_player, ""); - new JsonMessage(C.cAquaB + "Click here to visit our Twitter page!").click(ClickEvent.OPEN_URL, "https://www.twitter.com/Mineplex").sendToPlayer(_player); + new JsonMessage(" " + C.Bold + "Click to Open in Web Browser").click(ClickEvent.OPEN_URL, "https://www.twitter.com/Mineplex").sendToPlayer(_player); + new JsonMessage(" " + C.cGreen + C.Line + "https://www.twitter.com/Mineplex").click(ClickEvent.OPEN_URL, "https://www.twitter.com/Mineplex").sendToPlayer(_player); + UtilPlayer.message(_player, ""); + UtilPlayer.message(_player, C.cGold + C.Bold + C.Strike + "============================================="); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/VoteButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/VoteButton.java deleted file mode 100644 index 2d758624e..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/VoteButton.java +++ /dev/null @@ -1,185 +0,0 @@ -package mineplex.core.bonuses.gui.buttons; - -import java.util.ArrayList; - -import mineplex.core.bonuses.BonusAmount; -import mineplex.core.bonuses.BonusClientData; -import mineplex.core.bonuses.BonusManager; -import mineplex.core.common.jsonchat.ClickEvent; -import mineplex.core.common.jsonchat.JsonMessage; -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilTime.TimeUnit; -import mineplex.core.gui.GuiItem; -import mineplex.core.gui.ItemRefresher; -import mineplex.core.shop.item.ShopItem; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.Player; -import org.bukkit.event.HandlerList; -import org.bukkit.event.Listener; -import org.bukkit.event.inventory.ClickType; -import org.bukkit.inventory.ItemStack; -import org.bukkit.plugin.Plugin; - -public class VoteButton implements GuiItem, Listener { - - private ItemStack _item; - - private String _url; - - private Player _player; - private Plugin _plugin; - private ItemRefresher _gui; - - private BonusManager _bonusManager; - - public VoteButton(Plugin plugin, Player player, ItemRefresher gui, BonusManager bonusManager) - { - this._bonusManager = bonusManager; - this._player = player; - this._plugin = plugin; - this._gui = gui; - } - - @Override - public void setup() - { - //TODO get url from db - _url = _bonusManager.getVoteLink(); - - setItem(); - Bukkit.getPluginManager().registerEvents(this, getPlugin()); - } - - @Override - public void close() - { - HandlerList.unregisterAll(this); - } - - @Override - public void click(ClickType clickType) - { - if (isAvailable()) - { - getPlayer().closeInventory(); - - getPlayer().playSound(getPlayer().getLocation(), Sound.NOTE_PLING, 1, 1.6f); - - UtilPlayer.message(getPlayer(), C.cGold + C.Bold + C.Strike + "============================================="); - UtilPlayer.message(getPlayer(), ""); - - new JsonMessage(" " + C.Bold + "Click to Open in Web Browser").click(ClickEvent.OPEN_URL, _url).sendToPlayer(getPlayer()); - new JsonMessage( " " + C.cGreen + C.Line + _url).click(ClickEvent.OPEN_URL, _url).sendToPlayer(getPlayer()); - UtilPlayer.message(getPlayer(), ""); - UtilPlayer.message(getPlayer(), " Please be patient. Votes may take a few minutes to register."); - UtilPlayer.message(getPlayer(), ""); - UtilPlayer.message(getPlayer(), C.cGold + C.Bold + C.Strike + "============================================="); - - getPlayer().closeInventory(); - - } - else - { - getPlayer().playSound(getPlayer().getLocation(), Sound.ITEM_BREAK, 1, 10); - } - } - - @Override - public ItemStack getObject() - { - return _item; - } - - private void setItem() - { - ArrayList lore = new ArrayList(); - Material material; - String itemName; - byte data = 0; - - if (isAvailable()) - { - material = Material.JUKEBOX; - itemName = C.cGreen + C.Bold + "Vote for Mineplex"; - - lore.add(" "); - lore.add(ChatColor.RESET + "Click to Vote!"); - } - else - { - material = Material.REDSTONE_BLOCK; - itemName = C.cRed + C.Bold + "Vote for Mineplex"; - - lore.add(" "); - lore.add(ChatColor.RESET + "Next vote in " + UtilTime.convertString(timeLeft(), 0, TimeUnit.FIT) + "!"); - } - - lore.add(" "); - - BonusClientData client = _bonusManager.Get(_player); - - BonusAmount bonusAmount = _bonusManager.getVoteBonusAmount(_player); - bonusAmount.addLore(lore); - lore.add(" "); - - lore.add(C.cYellow + "Current Streak: " + C.cWhite + client.getVoteStreak()); - lore.add(C.cYellow + "Streak Bonus: " + C.cWhite + "+" + _bonusManager.getVoteMultiplier(client.getVoteStreak()) + "%"); - if (client.getVoteTime() != null) - { - long lastBonus = _bonusManager.getLocalTime(client.getVoteTime().getTime()); - long timeLeft = _bonusManager.getStreakTimeRemaining(lastBonus, BonusManager.VOTE_STREAK_RESET_TIME); - - if (timeLeft > 0) - { - lore.add(C.cYellow + "Streak Reset: " + C.cWhite + UtilTime.convertString(timeLeft, 1, TimeUnit.FIT)); - } - } - - lore.add(" "); - lore.add(C.cYellow + "Highest Streak: " + C.cWhite + client.getMaxVoteStreak()); - -// StreakRecord streakRecord = _bonusManager.getVoteStreak(); -// if (streakRecord != null) -// { -// lore.add(" "); -// lore.add(C.cYellow + "Record: " + C.cWhite + streakRecord.getPlayerName()); -// lore.add(C.cYellow + "Streak: " + C.cWhite + streakRecord.getStreak()); -// } - - _item = new ShopItem(material, itemName, lore.toArray(new String[0]), 1, false, false); - } - - public long timeLeft() - { - return _bonusManager.nextVoteTime(getPlayer()) - System.currentTimeMillis(); - } - - public boolean isAvailable() - { - if (_url == null) - return false; - - return (timeLeft() <= 0); - } - - public Plugin getPlugin() - { - return _plugin; - } - - public Player getPlayer() - { - return _player; - } - - public ItemRefresher getGui() - { - return _gui; - } -} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/YoutubeButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/YoutubeButton.java index 4a7b1b10e..477fa382d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/YoutubeButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/YoutubeButton.java @@ -3,11 +3,13 @@ package mineplex.core.bonuses.gui.buttons; import mineplex.core.common.jsonchat.ClickEvent; import mineplex.core.common.jsonchat.JsonMessage; import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilPlayer; import mineplex.core.gui.GuiItem; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.recharge.Recharge; import mineplex.core.youtube.YoutubeManager; import org.bukkit.Material; +import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; @@ -66,18 +68,27 @@ public class YoutubeButton implements GuiItem } _player.closeInventory(); - + + _player.playSound(_player.getLocation(), Sound.NOTE_PLING, 1, 1.6f); + final String message; if (_youtubeManager.canYoutube(_player)) { - message = "Click here to claim YouTube Prize!"; + message = "claim YouTube Prize!"; _youtubeManager.attemptYoutube(_player); - } else - { - message = "Click here to visit our YouTube page!"; } + else + { + message = "visit our YouTube page!"; + } + + UtilPlayer.message(_player, C.cGold + C.Bold + C.Strike + "============================================="); + UtilPlayer.message(_player, ""); - new JsonMessage(C.cAquaB + message).click(ClickEvent.OPEN_URL, "http://youtube.com/mineplexgamesofficial?sub_confirmation=1").sendToPlayer(_player); + new JsonMessage(" " + C.Bold + "Click to Open in Web Browser and " + message).click(ClickEvent.OPEN_URL, "https://www.youtube.com/embed/RW3sOmkiEG-A?list=UU1MtBclG_aHPd0nLmUupCKg&controls=0&showinfo=0&autoplay=1").sendToPlayer(_player); + new JsonMessage( " " + C.cGreen + C.Line + "http://youtube.com/mineplexgamesofficial").click(ClickEvent.OPEN_URL, "https://www.youtube.com/embed/RW3sOmkiEG-A?list=UU1MtBclG_aHPd0nLmUupCKg&controls=0&showinfo=0&autoplay=1").sendToPlayer(_player); + UtilPlayer.message(_player, ""); + UtilPlayer.message(_player, C.cGold + C.Bold + C.Strike + "============================================="); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/redis/VoteHandler.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/redis/VoteHandler.java deleted file mode 100644 index 0a2d370ba..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/redis/VoteHandler.java +++ /dev/null @@ -1,31 +0,0 @@ -package mineplex.core.bonuses.redis; - -import org.bukkit.entity.Player; - -import mineplex.core.bonuses.BonusManager; -import mineplex.core.common.util.UtilPlayer; -import mineplex.serverdata.commands.CommandCallback; -import mineplex.serverdata.commands.ServerCommand; - -public class VoteHandler implements CommandCallback -{ - private BonusManager _bonusManager; - - public VoteHandler(BonusManager bonusManager) - { - _bonusManager = bonusManager; - } - - @Override - public void run(ServerCommand command) - { - VotifierCommand v = ((VotifierCommand) command); - - Player player = UtilPlayer.searchExact(v.getPlayerName()); - - if (player != null) - { - _bonusManager.handleVote(player, v.getShardsReceived()); - } - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/redis/VotifierCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/redis/VotifierCommand.java deleted file mode 100644 index 7281d5805..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/redis/VotifierCommand.java +++ /dev/null @@ -1,28 +0,0 @@ -package mineplex.core.bonuses.redis; - -import mineplex.serverdata.commands.ServerCommand; - -public class VotifierCommand extends ServerCommand -{ - private String _playerName; - private int _shardsReceived; - - public VotifierCommand(String playerName, int shardsReceived, String... targetServer) - { - super(targetServer); - - _playerName = playerName; - _shardsReceived = shardsReceived; - } - - public String getPlayerName() - { - return _playerName; - } - - public int getShardsReceived() - { - return _shardsReceived; - } - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotManager.java b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotManager.java index ab1824174..7f063cf6a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotManager.java @@ -132,15 +132,15 @@ public class SnapshotManager .collect(Collectors.toCollection(TreeSet::new)); } - public CompletableFuture saveReportSnapshot(Report report, Collection messages) + public CompletableFuture saveReportSnapshot(Report report, Collection messages) { return _snapshotRepository .saveReportSnapshot(report, messages) - .whenComplete((snapshotId, throwable) -> + .whenComplete((snapshotMetadata, throwable) -> { if (throwable == null) { - report.setSnapshotId(snapshotId); + report.setSnapshotMetadata(snapshotMetadata); } else { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotMetadata.java b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotMetadata.java new file mode 100644 index 000000000..d46cc2796 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotMetadata.java @@ -0,0 +1,43 @@ +package mineplex.core.chatsnap; + +import java.util.Optional; + +public class SnapshotMetadata +{ + private final int _id; + protected String _token = null; + protected Integer _creatorId = null; + + public SnapshotMetadata(int id, String token, Integer creatorId) + { + _id = id; + _token = token; + _creatorId = creatorId; + } + + public SnapshotMetadata(int id, Integer creatorId) + { + _id = id; + _creatorId = creatorId; + } + + public SnapshotMetadata(int id) + { + _id = id; + } + + public int getId() + { + return _id; + } + + public Optional getToken() + { + return Optional.ofNullable(_token); + } + + public Optional getCreatorId() + { + return Optional.ofNullable(_creatorId); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotRepository.java index 2b055cca1..e832cd8b6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotRepository.java @@ -1,10 +1,12 @@ package mineplex.core.chatsnap; +import java.security.SecureRandom; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Types; +import java.util.Base64; import java.util.Collection; import java.util.Optional; import java.util.concurrent.CompletableFuture; @@ -20,17 +22,56 @@ import mineplex.serverdata.database.DBPool; */ public class SnapshotRepository { - public static String getURL(long reportId) + private static final String URL_PREFIX = "http://report.mineplex.com/chatsnap/view.php?token="; + + private static final int TOKEN_CHARS = 8; + private static final SecureRandom SECURE_RANDOM = new SecureRandom(); + + public static String getURL(String token) { - return URL_PREFIX + reportId; + return URL_PREFIX + token; } - private static final String URL_PREFIX = "http://report.mineplex.com/chatsnap/view.php?id="; + public static String generateToken() + { + // 6 bits per character, round to nearest byte + int byteAmount = (int) Math.ceil((TOKEN_CHARS * 6) / 8.0); + byte[] bytes = new byte[byteAmount]; + SECURE_RANDOM.nextBytes(bytes); - private static final String INSERT_SNAPSHOT = "INSERT INTO snapshots (creator) VALUES (?);"; + String token = Base64.getUrlEncoder().encodeToString(bytes); + token = replaceDashes(token); + + return token; + } + + private static String replaceDashes(String token) + { + for (int i = 0; i < token.length(); i++) + { + char originalChar = token.charAt(i); + char newChar = originalChar; + + while (newChar == '-') + { + byte[] replacementBytes = new byte[1]; + SECURE_RANDOM.nextBytes(replacementBytes); + newChar = Base64.getUrlEncoder().encodeToString(replacementBytes).charAt(0); + } + + token = token.replaceFirst(String.valueOf(originalChar), String.valueOf(newChar)); + } + + return token; + } + + private static final String INSERT_SNAPSHOT = "INSERT INTO snapshots (token, creator) VALUES (?, ?);"; private static final String INSERT_MESSAGE = "INSERT INTO snapshotMessages (senderId, `server`, `time`, message, snapshotType) VALUES (?, ?, ?, ?, ?);"; private static final String INSERT_MESSAGE_RECIPIENT = "INSERT INTO snapshotRecipients (messageId, recipientId) VALUES (?, ?);"; private static final String INSERT_MESSAGE_MAPPING = "INSERT INTO snapshotMessageMap (snapshotId, messageId) VALUES (?, ?);"; + private static final String GET_ID_FROM_TOKEN = "SELECT snapshots.id FROM snapshots WHERE snapshots.token = ?;"; + private static final String GET_METADATA = "SELECT token, creator FROM snapshots WHERE id = ?;"; + private static final String SET_TOKEN = "UPDATE snapshots SET token = ? WHERE id = ?;"; private final String _serverName; private final Logger _logger; @@ -41,17 +82,17 @@ public class SnapshotRepository _logger = logger; } - public CompletableFuture saveReportSnapshot(Report report, Collection messages) + public CompletableFuture saveReportSnapshot(Report report, Collection messages) { return CompletableFuture.supplyAsync(() -> { try (Connection connection = DBPool.getAccount().getConnection()) { - int snapshotId = report.getSnapshotId().orElseThrow(() -> - new IllegalStateException("Report does not have associated snapshot id.")); + SnapshotMetadata snapshotMetadata = report.getSnapshotMetadata().orElseThrow(() -> + new IllegalStateException("Report does not have associated snapshot.")); - insertMessages(snapshotId, messages, connection); - return snapshotId; + insertMessages(snapshotMetadata.getId(), messages, connection); + return snapshotMetadata; } catch (SQLException e) { @@ -60,15 +101,15 @@ public class SnapshotRepository }); } - public CompletableFuture saveSnapshot(Collection messages) + public CompletableFuture saveSnapshot(Collection messages) { return CompletableFuture.supplyAsync(() -> { try (Connection connection = DBPool.getAccount().getConnection()) { - int snapshotId = createSnapshot(connection, null); - insertMessages(snapshotId, messages, connection); - return snapshotId; + SnapshotMetadata snapshotMetadata = createSnapshot(connection, null); + insertMessages(snapshotMetadata.getId(), messages, connection); + return snapshotMetadata; } catch (SQLException e) { @@ -77,7 +118,7 @@ public class SnapshotRepository }); } - public CompletableFuture createSnapshot(Integer creatorAccountId) + public CompletableFuture createSnapshot(Integer creatorAccountId) { return CompletableFuture.supplyAsync(() -> { @@ -92,17 +133,19 @@ public class SnapshotRepository }); } - private int createSnapshot(Connection connection, Integer creatorAccount) throws SQLException + private SnapshotMetadata createSnapshot(Connection connection, Integer creatorAccount) throws SQLException { + String token = getUnusedToken(connection); PreparedStatement insertSnapshotStatement = connection.prepareStatement(INSERT_SNAPSHOT, new String[]{"id"}); + insertSnapshotStatement.setString(1, token); if (creatorAccount != null) { - insertSnapshotStatement.setInt(1, creatorAccount); + insertSnapshotStatement.setInt(2, creatorAccount); } else { - insertSnapshotStatement.setNull(1, Types.INTEGER); + insertSnapshotStatement.setNull(2, Types.INTEGER); } insertSnapshotStatement.execute(); @@ -111,7 +154,7 @@ public class SnapshotRepository { if (resultSet.next()) { - return resultSet.getInt(1); + return new SnapshotMetadata(resultSet.getInt(1), token, creatorAccount); } else { @@ -120,6 +163,97 @@ public class SnapshotRepository } } + private String getUnusedToken(Connection connection) throws SQLException + { + String token; + + do + { + token = generateToken(); + } + while(getByToken(connection, token).isPresent()); + + return token; + } + + private Optional getByToken(Connection connection, String token) throws SQLException + { + try (PreparedStatement statement = connection.prepareStatement(GET_ID_FROM_TOKEN)) + { + statement.setString(1, token); + + try (ResultSet resultSet = statement.executeQuery()) + { + if (resultSet.next()) + { + int snapshotId = resultSet.getInt("id"); + return Optional.of(snapshotId); + } + else + { + return Optional.empty(); + } + } + } + } + + public CompletableFuture getSnapshotMetadata(int snapshotId) + { + CompletableFuture future = CompletableFuture.supplyAsync(() -> + { + try (Connection connection = DBPool.getAccount().getConnection()) + { + try (PreparedStatement statement = connection.prepareStatement(GET_METADATA)) + { + statement.setInt(1, snapshotId); + + ResultSet resultSet = statement.executeQuery(); + if (resultSet.next()) + { + String token = resultSet.getString("token"); + if (resultSet.wasNull()) + { + // assign token to snapshot if it doesn't have one + token = getUnusedToken(connection); + setToken(connection, snapshotId, token); + } + + Integer creatorId = resultSet.getInt("creator"); + if (resultSet.wasNull()) creatorId = null; + + return new SnapshotMetadata(snapshotId, token, creatorId); + } + else + { + return null; + } + } + } + catch (SQLException e) + { + throw new RuntimeException(e); + } + }); + + future.exceptionally(throwable -> + { + _logger.log(Level.SEVERE, "Error whilst getting snapshot metadata for id: " + snapshotId, throwable); + return null; + }); + + return future; + } + + private void setToken(Connection connection, int snapshotId, String token) throws SQLException + { + try (PreparedStatement setTokenStatement = connection.prepareStatement(SET_TOKEN)) + { + setTokenStatement.setString(1, token); + setTokenStatement.setInt(2, snapshotId); + setTokenStatement.execute(); + } + } + private void insertMessages(int snapshotId, Collection messages, Connection connection) throws SQLException { try (PreparedStatement insertSnapshotStatement = connection.prepareStatement(INSERT_MESSAGE, new String[]{"id"})) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java index 9a7030ed7..bd55b33f0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java @@ -1,15 +1,28 @@ package mineplex.core.cosmetic.ui.page; +import java.time.Month; +import java.time.YearMonth; +import java.time.format.TextStyle; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Locale; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.BannerMeta; +import org.bukkit.inventory.meta.ItemMeta; import mineplex.core.account.CoreClientManager; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; import mineplex.core.common.util.F; +import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilText; import mineplex.core.common.util.banner.CountryFlag; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.cosmetic.ui.CosmeticShop; @@ -28,12 +41,6 @@ import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.SalesPackageProcessor; import mineplex.core.shop.item.ShopItem; import mineplex.core.shop.page.ShopPageBase; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.BannerMeta; -import org.bukkit.inventory.meta.ItemMeta; public class GadgetPage extends ShopPageBase { @@ -145,6 +152,22 @@ public class GadgetPage extends ShopPageBase itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Haunted Chests"); } + else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -14) + { + itemLore.add(C.cBlack); + YearMonth yearMonth = gadget.getYearMonth(); + if (yearMonth != null) + { + int year = yearMonth.getYear(); + Month month = yearMonth.getMonth(); + String monthName = month.getDisplayName(TextStyle.FULL, Locale.US); + itemLore.addAll(UtilText.splitLine(C.cBlue + "Monthly Power Play Club Reward for " + monthName + " " + year, LineFormat.LORE)); + } + else + { + itemLore.add(C.cBlue + "Found in Power Play Club"); + } + } //Rank Unlocks else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -10) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java index 9f39b1322..86638709d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java @@ -1,12 +1,22 @@ package mineplex.core.cosmetic.ui.page; +import java.time.Month; +import java.time.YearMonth; +import java.time.format.TextStyle; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Locale; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; import mineplex.core.account.CoreClientManager; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilText; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.cosmetic.ui.CosmeticShop; import mineplex.core.cosmetic.ui.button.MountButton; @@ -17,9 +27,6 @@ import mineplex.core.mount.Mount; import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.ShopItem; import mineplex.core.shop.page.ShopPageBase; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; public class MountPage extends ShopPageBase { @@ -99,8 +106,25 @@ public class MountPage extends ShopPageBase else if (mount.getCost(GlobalCurrency.TREASURE_SHARD) == -9) { itemLore.add(C.cBlack); - itemLore.add(C.cBlue + "Found in Halloween Chests"); + itemLore.add(C.cBlue + "Found in Haunted Chests"); } + else if (mount.getCost(GlobalCurrency.TREASURE_SHARD) == -14) + { + itemLore.add(C.cBlack); + YearMonth yearMonth = mount.getYearMonth(); + if (yearMonth != null) + { + int year = yearMonth.getYear(); + Month month = yearMonth.getMonth(); + String monthName = month.getDisplayName(TextStyle.FULL, Locale.US); + itemLore.addAll(UtilText.splitLine(C.cBlue + "Monthly Power Play Club Reward for " + monthName + " " + year, LineFormat.LORE)); + } + else + { + itemLore.add(C.cBlue + "Found in Power Play Club"); + } + } + //Rank Unlocks else if (mount.getCost(GlobalCurrency.TREASURE_SHARD) == -10) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java index 57cc96538..30bd7bf8c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java @@ -4,6 +4,19 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import net.minecraft.server.v1_8_R3.Blocks; +import net.minecraft.server.v1_8_R3.ChatMessage; +import net.minecraft.server.v1_8_R3.EntityPlayer; +import net.minecraft.server.v1_8_R3.Items; +import net.minecraft.server.v1_8_R3.PacketPlayOutOpenWindow; +import net.minecraft.server.v1_8_R3.PacketPlayOutSetSlot; + +import org.bukkit.Material; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + import mineplex.core.account.CoreClientManager; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; @@ -24,12 +37,6 @@ import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.ShopItem; import mineplex.core.shop.page.AnvilContainer; import mineplex.core.shop.page.ShopPageBase; -import net.minecraft.server.v1_8_R3.*; -import org.bukkit.Material; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; public class PetPage extends ShopPageBase { @@ -98,7 +105,12 @@ public class PetPage extends ShopPageBase else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -9) { itemLore.add(C.cBlack); - itemLore.add(C.cBlue + "Found in Halloween Chests"); + itemLore.add(C.cBlue + "Found in Haunted Chests"); + } + else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -14) + { + itemLore.add(C.cBlack); + itemLore.add(C.cBlue + "Found in Power Play Club"); } //Rank Unlocks diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java index 57bf4a047..6e1e32169 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java @@ -109,6 +109,19 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler createBedChunk(); } + @EventHandler + public void cleanupLazyCallers(UpdateEvent event) + { + if (event.getType() != UpdateType.SLOW) + return; + + _spawnPacketMap.values().forEach(list -> list.removeIf(base -> base.getEntity() == null)); + _spawnPacketMap.values().removeIf(list -> list.size() == 0); + _entityDisguiseMap.values().forEach(list -> list.removeIf(base -> base.getEntity() == null)); + _entityDisguiseMap.values().removeIf(list -> list.size() == 0); + _disguisePlayerMap.keySet().removeIf(base -> base.getEntity() == null); + } + // We want to re-register entities that were reloaded by chunk loading @EventHandler public void onEntityAdd(ChunkAddEntityEvent event) @@ -261,7 +274,11 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler entityPlayer.playerConnection.networkManager.handle(((DisguisePlayer) originalDisguise).getUndisguiseInfoPackets(true)); if (reason != UndisguiseReason.QUIT) { - entityPlayer.playerConnection.networkManager.handle(((DisguisePlayer) originalDisguise).getUndisguiseInfoPackets(false)); + Packet add = ((DisguisePlayer) originalDisguise).getUndisguiseInfoPackets(false); + if (add != null) + { + entityPlayer.playerConnection.networkManager.handle(add); + } } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseArmorStand.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseArmorStand.java index ed3cade7d..79695ec61 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseArmorStand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseArmorStand.java @@ -51,15 +51,15 @@ public class DisguiseArmorStand extends DisguiseInsentient public Packet getSpawnPacket() { PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(); - packet.a = Entity.getId(); + packet.a = getEntity().getId(); packet.b = (byte) 30; - packet.c = (int) MathHelper.floor(Entity.locX * 32.0D); - packet.d = (int) MathHelper.floor(Entity.locY * 32.0D); - packet.e = (int) MathHelper.floor(Entity.locZ * 32.0D); - packet.i = (byte) ((int) (Entity.yaw * 256.0F / 360.0F)); - packet.j = (byte) ((int) (Entity.pitch * 256.0F / 360.0F)); - packet.k = (byte) ((int) (Entity.yaw * 256.0F / 360.0F)); - packet.uuid = Entity.getUniqueID(); + packet.c = (int) MathHelper.floor(getEntity().locX * 32.0D); + packet.d = (int) MathHelper.floor(getEntity().locY * 32.0D); + packet.e = (int) MathHelper.floor(getEntity().locZ * 32.0D); + packet.i = (byte) ((int) (getEntity().yaw * 256.0F / 360.0F)); + packet.j = (byte) ((int) (getEntity().pitch * 256.0F / 360.0F)); + packet.k = (byte) ((int) (getEntity().yaw * 256.0F / 360.0F)); + packet.uuid = getEntity().getUniqueID(); double var2 = 3.9D; double var4 = 0; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBase.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBase.java index 7c742b3c4..2d0334abc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBase.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBase.java @@ -17,13 +17,15 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.event.entity.CreatureSpawnEvent; +import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Collections; import java.util.List; public abstract class DisguiseBase { - protected Entity Entity; + private WeakReference _entity = new WeakReference<>(null); + protected DataWatcher DataWatcher; private DisguiseBase _soundDisguise; @@ -56,18 +58,18 @@ public abstract class DisguiseBase public void attemptToSpawn() { - this.Entity.world.addEntity(this.Entity, CreatureSpawnEvent.SpawnReason.CUSTOM); + this.getEntity().world.addEntity(this.getEntity(), CreatureSpawnEvent.SpawnReason.CUSTOM); } public void setEntity(org.bukkit.entity.Entity entity) { - Entity = ((CraftEntity) entity).getHandle(); + setEntity(((CraftEntity) entity).getHandle()); } public void UpdateDataWatcher() { - DataWatcher.watch(0, Entity.getDataWatcher().getByte(0), net.minecraft.server.v1_8_R3.Entity.META_ENTITYDATA, Entity.getDataWatcher().getByte(0)); - DataWatcher.watch(1, Entity.getDataWatcher().getShort(1), net.minecraft.server.v1_8_R3.Entity.META_AIR, (int) Entity.getDataWatcher().getShort(1)); + DataWatcher.watch(0, getEntity().getDataWatcher().getByte(0), net.minecraft.server.v1_8_R3.Entity.META_ENTITYDATA, getEntity().getDataWatcher().getByte(0)); + DataWatcher.watch(1, getEntity().getDataWatcher().getShort(1), net.minecraft.server.v1_8_R3.Entity.META_AIR, (int) getEntity().getDataWatcher().getShort(1)); } public abstract Packet getSpawnPacket(); @@ -75,22 +77,22 @@ public abstract class DisguiseBase public Packet getMetadataPacket() { UpdateDataWatcher(); - return new PacketPlayOutEntityMetadata(Entity.getId(), DataWatcher, true); + return new PacketPlayOutEntityMetadata(getEntity().getId(), DataWatcher, true); } public void resendMetadata() { - if (Entity == null || !Entity.getBukkitEntity().isValid() || !(Entity.world instanceof WorldServer)) + if (getEntity() == null || !getEntity().getBukkitEntity().isValid() || !(getEntity().world instanceof WorldServer)) return; - IntHashMap tracker = ((WorldServer) Entity.world).tracker.trackedEntities; + IntHashMap tracker = ((WorldServer) getEntity().world).tracker.trackedEntities; - if (tracker.get(Entity.getId()) == null) + if (tracker.get(getEntity().getId()) == null) return; Packet packet = getMetadataPacket(); - for (EntityPlayer player : tracker.get(Entity.getId()).trackedPlayers) + for (EntityPlayer player : tracker.get(getEntity().getId()).trackedPlayers) { UtilPlayer.sendPacket(player.getBukkitEntity(), packet); } @@ -106,17 +108,17 @@ public abstract class DisguiseBase public void playHurtSound() { - Entity.world.makeSound(Entity, _soundDisguise.getHurtSound(), _soundDisguise.getVolume(), _soundDisguise.getPitch()); + getEntity().world.makeSound(getEntity(), _soundDisguise.getHurtSound(), _soundDisguise.getVolume(), _soundDisguise.getPitch()); } public Entity getEntity() { - return Entity; + return _entity.get(); } public int getEntityId() { - return Entity.getId(); + return getEntity().getId(); } protected abstract String getHurtSound(); @@ -128,13 +130,13 @@ public abstract class DisguiseBase public List getTrackedPlayers() { List players = new ArrayList<>(); - IntHashMap tracker = ((WorldServer) Entity.world).tracker.trackedEntities; - if (tracker.get(Entity.getId()) == null) + IntHashMap tracker = ((WorldServer) getEntity().world).tracker.trackedEntities; + if (tracker.get(getEntity().getId()) == null) { - System.out.println("Tracker did not contain " + Entity.getId() + " " + Entity.getCustomName() + " " + Entity.dead + " " + Entity.locX + " " + Entity.locY + " " + Entity.locZ); + System.out.println("Tracker did not contain " + getEntity().getId() + " " + getEntity().getCustomName() + " " + getEntity().dead + " " + getEntity().locX + " " + getEntity().locY + " " + getEntity().locZ); return Collections.emptyList(); } - for (EntityPlayer ep : tracker.get(Entity.getId()).trackedPlayers) + for (EntityPlayer ep : tracker.get(getEntity().getId()).trackedPlayers) { players.add(ep.getBukkitEntity()); } @@ -194,4 +196,10 @@ public abstract class DisguiseBase { return this._disguiseType; } + + public void setEntity(net.minecraft.server.v1_8_R3.Entity entity) + { + _entity.clear(); + _entity = new WeakReference<>(entity); + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBlock.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBlock.java index 735ae8914..387208c51 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBlock.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBlock.java @@ -36,19 +36,19 @@ public class DisguiseBlock extends DisguiseBase public Packet getSpawnPacket() { PacketPlayOutSpawnEntity packet = new PacketPlayOutSpawnEntity(); - packet.a = Entity.getId(); - packet.b = MathHelper.floor(Entity.locX * 32.0D); - packet.c = MathHelper.floor(Entity.locY * 32.0D); - packet.d = MathHelper.floor(Entity.locZ * 32.0D); - packet.h = MathHelper.d(Entity.pitch * 256.0F / 360.0F); - packet.i = MathHelper.d(Entity.yaw * 256.0F / 360.0F); + packet.a = getEntity().getId(); + packet.b = MathHelper.floor(getEntity().locX * 32.0D); + packet.c = MathHelper.floor(getEntity().locY * 32.0D); + packet.d = MathHelper.floor(getEntity().locZ * 32.0D); + packet.h = MathHelper.d(getEntity().pitch * 256.0F / 360.0F); + packet.i = MathHelper.d(getEntity().yaw * 256.0F / 360.0F); packet.j = 70; packet.k = _blockId | _blockData << 12; - packet.uuid = Entity.getUniqueID(); + packet.uuid = getEntity().getUniqueID(); - double d1 = Entity.motX; - double d2 = Entity.motY; - double d3 = Entity.motZ; + double d1 = getEntity().motX; + double d2 = getEntity().motY; + double d3 = getEntity().motZ; double d4 = 3.9D; if (d1 < -d4) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreature.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreature.java index 2e00319f0..d477ab3bc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreature.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreature.java @@ -16,15 +16,15 @@ public abstract class DisguiseCreature extends DisguiseInsentient public Packet getSpawnPacket() { PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(); - packet.a = Entity.getId(); + packet.a = getEntity().getId(); packet.b = (byte) getDisguiseType().getTypeId(); - packet.c = (int) MathHelper.floor(Entity.locX*32D); - packet.d = (int) MathHelper.floor(Entity.locY * 32.0D); - packet.e = (int) MathHelper.floor(Entity.locZ*32D); - packet.i = (byte) ((int) (Entity.yaw * 256.0F / 360.0F)); - packet.j = (byte) ((int) (Entity.pitch * 256.0F / 360.0F)); - packet.k = (byte) ((int) (Entity.yaw * 256.0F / 360.0F)); - packet.uuid = Entity.getUniqueID(); + packet.c = (int) MathHelper.floor(getEntity().locX*32D); + packet.d = (int) MathHelper.floor(getEntity().locY * 32.0D); + packet.e = (int) MathHelper.floor(getEntity().locZ*32D); + packet.i = (byte) ((int) (getEntity().yaw * 256.0F / 360.0F)); + packet.j = (byte) ((int) (getEntity().pitch * 256.0F / 360.0F)); + packet.k = (byte) ((int) (getEntity().yaw * 256.0F / 360.0F)); + packet.uuid = getEntity().getUniqueID(); double var2 = 3.9D; double var4 = 0; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseEnderman.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseEnderman.java index 55964abc2..d8d9703c4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseEnderman.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseEnderman.java @@ -36,7 +36,7 @@ public class DisguiseEnderman extends DisguiseMonster { super.UpdateDataWatcher(); - DataWatcher.watch(0, Byte.valueOf((byte) (DataWatcher.getByte(0) & ~(1 << 0))), Entity.META_ENTITYDATA, + DataWatcher.watch(0, Byte.valueOf((byte) (DataWatcher.getByte(0) & ~(1 << 0))), getEntity().META_ENTITYDATA, (byte) (DataWatcher.getByte(0) & ~(1 << 0))); DataWatcher.watch(16, DataWatcher.getShort(16), EntityEnderman.META_BLOCK, getBlock(DataWatcher.getShort(16))); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseLiving.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseLiving.java index 2a1dd6ea2..dc3608873 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseLiving.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseLiving.java @@ -80,9 +80,9 @@ public abstract class DisguiseLiving extends DisguiseBase { ItemStack item = null; - if (Entity instanceof EntityLiving) + if (getEntity() instanceof EntityLiving) { - item = CraftItemStack.asBukkitCopy(((EntityLiving) Entity).getEquipment()[nmsSlot]); + item = CraftItemStack.asBukkitCopy(((EntityLiving) getEntity()).getEquipment()[nmsSlot]); } if (item == null || item.getType() == Material.AIR) @@ -111,15 +111,15 @@ public abstract class DisguiseLiving extends DisguiseBase else DataWatcher.watch(0, Byte.valueOf((byte) (b0 & ~(1 << 5))), EntityLiving.META_ENTITYDATA, (byte) (b0 & ~(1 << 5))); - if (Entity instanceof EntityLiving) + if (getEntity() instanceof EntityLiving) { - DataWatcher.watch(6, Entity.getDataWatcher().getFloat(6), EntityLiving.META_HEALTH, - Entity.getDataWatcher().getFloat(6)); - DataWatcher.watch(7, Entity.getDataWatcher().getInt(7), EntityLiving.META_POTION_COLOR, Entity.getDataWatcher() + DataWatcher.watch(6, getEntity().getDataWatcher().getFloat(6), EntityLiving.META_HEALTH, + getEntity().getDataWatcher().getFloat(6)); + DataWatcher.watch(7, getEntity().getDataWatcher().getInt(7), EntityLiving.META_POTION_COLOR, getEntity().getDataWatcher() .getInt(7)); - DataWatcher.watch(8, Entity.getDataWatcher().getByte(8), EntityLiving.META_AMBIENT_POTION, Entity.getDataWatcher() + DataWatcher.watch(8, getEntity().getDataWatcher().getByte(8), EntityLiving.META_AMBIENT_POTION, getEntity().getDataWatcher() .getByte(8) == 1); - DataWatcher.watch(9, Entity.getDataWatcher().getByte(9), EntityLiving.META_ARROWS, (int) Entity.getDataWatcher() + DataWatcher.watch(9, getEntity().getDataWatcher().getByte(9), EntityLiving.META_ARROWS, (int) getEntity().getDataWatcher() .getByte(9)); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMagmaCube.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMagmaCube.java index e39715d04..904835bba 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMagmaCube.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMagmaCube.java @@ -28,15 +28,15 @@ public class DisguiseMagmaCube extends DisguiseInsentient public Packet getSpawnPacket() { PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(); - packet.a = Entity.getId(); + packet.a = getEntity().getId(); packet.b = (byte) 62; - packet.c = (int) MathHelper.floor(Entity.locX * 32D); - packet.d = (int) MathHelper.floor(Entity.locY * 32.0D); - packet.e = (int) MathHelper.floor(Entity.locZ * 32D); - packet.i = (byte) ((int) (Entity.yaw * 256.0F / 360.0F)); - packet.j = (byte) ((int) (Entity.pitch * 256.0F / 360.0F)); - packet.k = (byte) ((int) (Entity.yaw * 256.0F / 360.0F)); - packet.uuid = Entity.getUniqueID(); + packet.c = (int) MathHelper.floor(getEntity().locX * 32D); + packet.d = (int) MathHelper.floor(getEntity().locY * 32.0D); + packet.e = (int) MathHelper.floor(getEntity().locZ * 32D); + packet.i = (byte) ((int) (getEntity().yaw * 256.0F / 360.0F)); + packet.j = (byte) ((int) (getEntity().pitch * 256.0F / 360.0F)); + packet.k = (byte) ((int) (getEntity().yaw * 256.0F / 360.0F)); + packet.uuid = getEntity().getUniqueID(); double var2 = 3.9D; double var4 = 0; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePlayer.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePlayer.java index 7b45bada6..abfced0a4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePlayer.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePlayer.java @@ -202,7 +202,7 @@ public class DisguisePlayer extends DisguiseHuman byte b0 = DataWatcher.getByte(0); - if (Entity.isSneaking()) + if (getEntity().isSneaking()) { DataWatcher.watch(0, Byte.valueOf((byte) (b0 | 1 << 1)), EntityHuman.META_ENTITYDATA, (byte) (b0 | 1 << 1)); } @@ -211,9 +211,9 @@ public class DisguisePlayer extends DisguiseHuman DataWatcher.watch(0, Byte.valueOf((byte) (b0 & ~(1 << 1))), EntityHuman.META_ENTITYDATA, (byte) (b0 & ~(1 << 1))); } - if (Entity instanceof EntityPlayer) + if (getEntity() instanceof EntityPlayer) { - EntityPlayer entityPlayer = (EntityPlayer) Entity; + EntityPlayer entityPlayer = (EntityPlayer) getEntity(); DataWatcher.watch(10, entityPlayer.getDataWatcher().getByte(10), EntityPlayer.META_SKIN, entityPlayer.getDataWatcher().getByte(10)); DataWatcher.watch(16, (byte) 0, EntityPlayer.META_CAPE, (byte) 1); @@ -224,13 +224,13 @@ public class DisguisePlayer extends DisguiseHuman public PacketPlayOutNamedEntitySpawn getSpawnPacket() { PacketPlayOutNamedEntitySpawn packet = new PacketPlayOutNamedEntitySpawn(); - packet.a = Entity.getId(); + packet.a = getEntity().getId(); packet.b = _profile.getId(); - packet.c = MathHelper.floor(Entity.locX * 32.0D); - packet.d = MathHelper.floor(Entity.locY * 32.0D); - packet.e = MathHelper.floor(Entity.locZ * 32.0D); - packet.f = (byte) ((int) ((Entity.isFakeHead() ? Entity.fakePitch : Entity.pitch) * 256.0F / 360.0F)); - packet.g = (byte) ((int) ((Entity.isFakeHead() ? Entity.fakePitch : Entity.pitch) * 256.0F / 360.0F)); + packet.c = MathHelper.floor(getEntity().locX * 32.0D); + packet.d = MathHelper.floor(getEntity().locY * 32.0D); + packet.e = MathHelper.floor(getEntity().locZ * 32.0D); + packet.f = (byte) ((int) ((getEntity().isFakeHead() ? getEntity().fakePitch : getEntity().pitch) * 256.0F / 360.0F)); + packet.g = (byte) ((int) ((getEntity().isFakeHead() ? getEntity().fakePitch : getEntity().pitch) * 256.0F / 360.0F)); packet.i = DataWatcher; return packet; @@ -253,11 +253,11 @@ public class DisguisePlayer extends DisguiseHuman @Override public void onDisguise(boolean isActive) { - if (this.Entity instanceof EntityPlayer) + if (this.getEntity() instanceof EntityPlayer) { if (_sendSkinToSelf) { - EntityPlayer entityPlayer = ((EntityPlayer) this.Entity); + EntityPlayer entityPlayer = ((EntityPlayer) this.getEntity()); // First construct the packet which will remove the previous disguise from the tab list PacketPlayOutPlayerInfo playerInfoPacketRemove = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.REMOVE_PLAYER); @@ -285,11 +285,11 @@ public class DisguisePlayer extends DisguiseHuman @Override public void onUndisguise(boolean wasActive) { - if (this.Entity instanceof EntityPlayer) + if (this.getEntity() instanceof EntityPlayer) { if (_sendSkinToSelf) { - EntityPlayer entityPlayer = ((EntityPlayer) this.Entity); + EntityPlayer entityPlayer = ((EntityPlayer) this.getEntity()); // First construct the packet which will remove the previous disguise from the tab list PacketPlayOutPlayerInfo playerInfoPacketRemove = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.REMOVE_PLAYER); @@ -320,9 +320,9 @@ public class DisguisePlayer extends DisguiseHuman { if (disguise instanceof DisguisePlayer) { - if (((DisguisePlayer) disguise).getSendSkinDataToSelf() && _sendSkinToSelf && this.Entity instanceof EntityPlayer) + if (((DisguisePlayer) disguise).getSendSkinDataToSelf() && _sendSkinToSelf && this.getEntity() instanceof EntityPlayer) { - EntityPlayer entityPlayer = ((EntityPlayer) this.Entity); + EntityPlayer entityPlayer = ((EntityPlayer) this.getEntity()); PacketPlayOutPlayerInfo playerInfoRemove = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.REMOVE_PLAYER); PacketPlayOutPlayerInfo.PlayerInfoData data = playerInfoRemove.new PlayerInfoData(getSelfProfile(), entityPlayer.ping, getAppropriateGamemode(), null); @@ -338,9 +338,9 @@ public class DisguisePlayer extends DisguiseHuman { if (disguise instanceof DisguisePlayer) { - if (((DisguisePlayer) disguise).getSendSkinDataToSelf() && _sendSkinToSelf && this.Entity instanceof EntityPlayer) + if (((DisguisePlayer) disguise).getSendSkinDataToSelf() && _sendSkinToSelf && this.getEntity() instanceof EntityPlayer) { - EntityPlayer entityPlayer = ((EntityPlayer) this.Entity); + EntityPlayer entityPlayer = ((EntityPlayer) this.getEntity()); PacketPlayOutPlayerInfo playerInfoPacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.REMOVE_PLAYER); PacketPlayOutPlayerInfo.PlayerInfoData data = playerInfoPacket.new PlayerInfoData(((DisguisePlayer) disguise)._originalProfile, entityPlayer.ping, entityPlayer.playerInteractManager.getGameMode(), null); @@ -421,9 +421,9 @@ public class DisguisePlayer extends DisguiseHuman private WorldSettings.EnumGamemode getAppropriateGamemode() { - if (Entity instanceof EntityPlayer) + if (getEntity() instanceof EntityPlayer) { - return ((EntityPlayer) Entity).playerInteractManager.getGameMode(); + return ((EntityPlayer) getEntity()).playerInteractManager.getGameMode(); } return WorldSettings.EnumGamemode.SURVIVAL; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseRabbit.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseRabbit.java index 1ebe31ae6..3facd4fe2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseRabbit.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseRabbit.java @@ -21,15 +21,15 @@ public class DisguiseRabbit extends DisguiseAnimal public Packet getSpawnPacket() { PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(); - packet.a = Entity.getId(); + packet.a = getEntity().getId(); packet.b = (byte) 101; - packet.c = (int) MathHelper.floor(Entity.locX * 32D); - packet.d = (int) MathHelper.floor(Entity.locY * 32.0D); - packet.e = (int) MathHelper.floor(Entity.locZ * 32D); - packet.i = (byte) ((int) (Entity.yaw * 256.0F / 360.0F)); - packet.j = (byte) ((int) (Entity.pitch * 256.0F / 360.0F)); - packet.k = (byte) ((int) (Entity.yaw * 256.0F / 360.0F)); - packet.uuid = Entity.getUniqueID(); + packet.c = (int) MathHelper.floor(getEntity().locX * 32D); + packet.d = (int) MathHelper.floor(getEntity().locY * 32.0D); + packet.e = (int) MathHelper.floor(getEntity().locZ * 32D); + packet.i = (byte) ((int) (getEntity().yaw * 256.0F / 360.0F)); + packet.j = (byte) ((int) (getEntity().pitch * 256.0F / 360.0F)); + packet.k = (byte) ((int) (getEntity().yaw * 256.0F / 360.0F)); + packet.uuid = getEntity().getUniqueID(); double var2 = 3.9D; double var4 = 0; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSlime.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSlime.java index a9f0b44f5..96bb78cd9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSlime.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSlime.java @@ -28,15 +28,15 @@ public class DisguiseSlime extends DisguiseInsentient public Packet getSpawnPacket() { PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(); - packet.a = Entity.getId(); + packet.a = getEntity().getId(); packet.b = (byte) 55; - packet.c = (int) MathHelper.floor(Entity.locX * 32D); - packet.d = (int) MathHelper.floor(Entity.locY * 32.0D); - packet.e = (int) MathHelper.floor(Entity.locZ * 32D); - packet.i = (byte) ((int) (Entity.yaw * 256.0F / 360.0F)); - packet.j = (byte) ((int) (Entity.pitch * 256.0F / 360.0F)); - packet.k = (byte) ((int) (Entity.yaw * 256.0F / 360.0F)); - packet.uuid = Entity.getUniqueID(); + packet.c = (int) MathHelper.floor(getEntity().locX * 32D); + packet.d = (int) MathHelper.floor(getEntity().locY * 32.0D); + packet.e = (int) MathHelper.floor(getEntity().locZ * 32D); + packet.i = (byte) ((int) (getEntity().yaw * 256.0F / 360.0F)); + packet.j = (byte) ((int) (getEntity().pitch * 256.0F / 360.0F)); + packet.k = (byte) ((int) (getEntity().yaw * 256.0F / 360.0F)); + packet.uuid = getEntity().getUniqueID(); double var2 = 3.9D; double var4 = 0; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index 1958205ae..419576874 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -38,7 +38,6 @@ import mineplex.core.donation.DonationManager; import mineplex.core.gadget.commands.AmmoCommand; import mineplex.core.gadget.commands.LockCosmeticsCommand; import mineplex.core.gadget.commands.UnlockCosmeticsCommand; -import mineplex.core.gadget.commands.WinRoomTestCommand; import mineplex.core.gadget.event.GadgetChangeEvent; import mineplex.core.gadget.event.GadgetCollideEntityEvent; import mineplex.core.gadget.event.GadgetEnableEvent; @@ -121,6 +120,7 @@ import mineplex.core.gadget.gadgets.morph.MorphSlime; import mineplex.core.gadget.gadgets.morph.MorphSnowman; import mineplex.core.gadget.gadgets.morph.MorphSquid; import mineplex.core.gadget.gadgets.morph.MorphTitan; +import mineplex.core.gadget.gadgets.morph.MorphTurkey; import mineplex.core.gadget.gadgets.morph.MorphUncleSam; import mineplex.core.gadget.gadgets.morph.MorphVillager; import mineplex.core.gadget.gadgets.morph.MorphWitch; @@ -276,7 +276,6 @@ public class GadgetManager extends MiniPlugin addCommand(new UnlockCosmeticsCommand(this)); addCommand(new LockCosmeticsCommand(this)); addCommand(new AmmoCommand(this)); - addCommand(new WinRoomTestCommand(this)); } private void createSets() @@ -289,6 +288,7 @@ public class GadgetManager extends MiniPlugin //Costumes addSet(new SetRaveSuit(this)); addSet(new SetSpaceSuit(this)); + // Hidden in this update //addSet(new SetWindUpSuit(this)); addSet(new SetParty(this)); addSet(new SetCupidsLove(this)); @@ -335,6 +335,7 @@ public class GadgetManager extends MiniPlugin addGadget(new OutfitSpaceSuitLeggings(this)); addGadget(new OutfitSpaceSuitBoots(this)); + // Hidden in this update /*addGadget(new OutfitWindUpSuitHelmet(this)); addGadget(new OutfitWindUpSuitChestplate(this)); addGadget(new OutfitWindUpSuitLeggings(this)); @@ -365,9 +366,11 @@ public class GadgetManager extends MiniPlugin addGadget(new MorphSquid(this)); addGadget(new MorphWitch(this)); addGadget(new MorphGrimReaper(this)); - // Not being added in this update! + addGadget(new MorphTurkey(this)); + // Hidden in this update + //addGadget(new MorphSleigh(this)); //addGadget(new MorphMetalMan(this)); - + // Particles addGadget(new ParticleFoot(this)); addGadget(new ParticleFireRings(this)); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/ReindeerTestCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/ReindeerTestCommand.java new file mode 100644 index 000000000..b8af63074 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/ReindeerTestCommand.java @@ -0,0 +1,85 @@ +package mineplex.core.gadget.commands; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.Horse; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.EulerAngle; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilServer; +import mineplex.core.gadget.GadgetManager; + +public class ReindeerTestCommand extends CommandBase +{ + + private GadgetManager _plugin; + private Horse _horse; + private ArmorStand _armorStand; + + public ReindeerTestCommand(GadgetManager plugin) + { + super(plugin, Rank.JNR_DEV, "reindeer"); + _plugin = plugin; + } + + @Override + public void Execute(Player caller, String[] args) + { + if (_horse == null) + { + Location testHorse = new Location(caller.getWorld(), 8.5, 71, 0.5, 0, 0); + testHorse.setYaw(180); + Horse horse = testHorse.getWorld().spawn(testHorse, Horse.class); + horse.setVariant(Horse.Variant.HORSE); + horse.setColor(Horse.Color.BROWN); + horse.setStyle(Horse.Style.NONE); + + UtilEnt.Vegetate(horse, true); + UtilEnt.ghost(horse, true, false); + + /** + * South + * .4 1 .6 + * .2 1 .7 + * 0 4 0 + * 0 2 0 + * + * North + */ + + Location hornALoc = horse.getLocation().clone().add(-.3, 1, -.5); + Location hornBLoc = horse.getLocation().clone().add(-.25, 1, -.6); + + ArmorStand hornA = hornALoc.getWorld().spawn(hornALoc, ArmorStand.class); + hornA.setVisible(false); + hornA.setGravity(false); + hornA.getEquipment().setItemInHand(new ItemStack(Material.DEAD_BUSH)); + hornA.setRightArmPose(new EulerAngle(0, 4, 0)); + + ArmorStand hornB = hornBLoc.getWorld().spawn(hornBLoc, ArmorStand.class); + hornB.setVisible(false); + hornB.setGravity(false); + hornB.getEquipment().setItemInHand(new ItemStack(Material.DEAD_BUSH)); + hornB.setRightArmPose(new EulerAngle(0, 2, 0)); + + _horse = horse; + + Bukkit.getScheduler().scheduleSyncRepeatingTask(UtilServer.getPlugin(), new Runnable() + { + @Override + public void run() + { + Location location = _horse.getLocation(); + location.setYaw(180); + _horse.teleport(location); + } + }, 1l, 1l); + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/WinRoomTestCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/WinRoomTestCommand.java deleted file mode 100644 index a6a029bc5..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/WinRoomTestCommand.java +++ /dev/null @@ -1,72 +0,0 @@ -package mineplex.core.gadget.commands; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.wineffect.*; -import mineplex.core.gadget.types.WinEffectGadget; -import org.bukkit.entity.Player; - -public class WinRoomTestCommand extends CommandBase -{ - - private GadgetManager _manager; - - public WinRoomTestCommand(GadgetManager manager) - { - super(manager, Rank.JNR_DEV, "winroomtest"); - _manager = manager; - } - - @Override - public void Execute(Player player, String[] args) - { - if (args.length < 1 || args.length > 2) - { - UtilPlayer.message(player, F.main("Win Rooms", "Usage: /winroomtest [play]")); - return; - } - boolean play = false; - if (args.length == 2) - { - if (args[1].equalsIgnoreCase("true")) - { - play = true; - } - } - loadWinRoom(args[0], player, play); - } - - private void loadWinRoom(String roomName, Player player, boolean play) - { - List names = Arrays.asList("BabyChicken", "DragonRider", "Fireworks", "Flames", "Halloween", "LavaTrap", - "LightningStrike", "MrPunchMan", "Podium", "RiseOfTheElderGuardian", "SnowTrails"); - List winClasses = Arrays.asList(WinEffectBabyChicken.class, WinEffectDragonRider.class, - WinEffectFireworks.class, WinEffectFlames.class, WinEffectHalloween.class, WinEffectLavaTrap.class, - WinEffectLightningStrike.class, WinEffectMrPunchMan.class, WinEffectPodium.class, - WinEffectRiseOfTheElderGuardian.class, WinEffectSnowTrails.class); - if (names.contains(roomName)) - { - int index = names.indexOf(roomName); - WinEffectGadget gadget = (WinEffectGadget) _manager.getGadget(winClasses.get(index)); - gadget.setup(player, new ArrayList<>(), new ArrayList<>(), player.getLocation().clone().add(100, 0, 100)); - gadget.buildWinnerRoom(); - gadget.teleport(); - if (play) - { - gadget.runPlay(); - } - } - else - { - UtilPlayer.message(player, F.main("Win Rooms", "Wrong room name!")); - } - } - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemSnowball.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemSnowball.java index eeaf89b60..fd6e988e8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemSnowball.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemSnowball.java @@ -16,6 +16,8 @@ import mineplex.core.common.util.UtilText; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.Ammo; import mineplex.core.gadget.types.ItemGadget; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; public class ItemSnowball extends ItemGadget { @@ -59,4 +61,12 @@ public class ItemSnowball extends ItemGadget event.getDamager().getWorld().playSound(event.getDamager().getLocation(), Sound.STEP_SNOW, 1, 0.5f); } + @EventHandler + public void cleanup(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + return; + + _snowballs.entrySet().removeIf(ent -> !ent.getKey().isValid()); + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBat.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBat.java index ae9608fe1..4225b2c6b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBat.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBat.java @@ -1,6 +1,5 @@ package mineplex.core.gadget.gadgets.morph; -import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; import org.bukkit.EntityEffect; import org.bukkit.GameMode; import org.bukkit.Material; @@ -24,18 +23,19 @@ import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilText; -import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.disguise.disguises.DisguiseBat; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; +import mineplex.core.gadget.types.MorphGadget; +import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.projectile.IThrown; import mineplex.core.projectile.ProjectileUser; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.types.MorphGadget; -import mineplex.core.itemstack.ItemStackFactory; public class MorphBat extends MorphGadget implements IThrown { @@ -60,9 +60,6 @@ public class MorphBat extends MorphGadget implements IThrown this.applyArmor(player, message); DisguiseBat disguise = new DisguiseBat(player); - //disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank()); - //disguise.setCustomNameVisible(true); - //Manager.getDisguiseManager().disguise(disguise); UtilMorph.disguise(player, disguise, Manager); } @@ -70,7 +67,6 @@ public class MorphBat extends MorphGadget implements IThrown public void disableCustom(Player player, boolean message) { this.removeArmor(player); - //Manager.getDisguiseManager().undisguise(player); UtilMorph.undisguise(player, Manager.getDisguiseManager()); player.setAllowFlight(false); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBlaze.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBlaze.java index a0c3dad2a..c7f1f5b01 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBlaze.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBlaze.java @@ -1,6 +1,5 @@ package mineplex.core.gadget.gadgets.morph; -import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.Player; @@ -12,12 +11,13 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilText; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilText; import mineplex.core.disguise.disguises.DisguiseBlaze; import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; import mineplex.core.gadget.types.MorphGadget; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -43,9 +43,6 @@ public class MorphBlaze extends MorphGadget this.applyArmor(player, message); DisguiseBlaze disguise = new DisguiseBlaze(player); - //disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank()); - //disguise.setCustomNameVisible(true); - //Manager.getDisguiseManager().disguise(disguise); UtilMorph.disguise(player, disguise, Manager); } @@ -53,7 +50,6 @@ public class MorphBlaze extends MorphGadget public void disableCustom(Player player, boolean message) { this.removeArmor(player); - //Manager.getDisguiseManager().undisguise(player); UtilMorph.undisguise(player, Manager.getDisguiseManager()); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBunny.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBunny.java index 08252f554..7516326f1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBunny.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBunny.java @@ -4,21 +4,12 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; -import mineplex.core.common.currency.GlobalCurrency; -import mineplex.core.common.util.*; -import mineplex.core.common.util.UtilEvent.ActionType; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.disguise.disguises.DisguiseRabbit; -import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; -import mineplex.core.gadget.types.MorphGadget; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.recharge.Recharge; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import org.bukkit.*; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Color; import org.bukkit.FireworkEffect.Type; +import org.bukkit.Material; +import org.bukkit.Sound; import org.bukkit.entity.Item; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -30,6 +21,30 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; +import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilText; +import mineplex.core.disguise.disguises.DisguiseRabbit; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; +import mineplex.core.gadget.types.MorphGadget; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + public class MorphBunny extends MorphGadget { private HashSet _jumpCharge = new HashSet(); @@ -56,9 +71,6 @@ public class MorphBunny extends MorphGadget this.applyArmor(player, message); DisguiseRabbit disguise = new DisguiseRabbit(player); - //disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank()); - //disguise.setCustomNameVisible(true); - //Manager.getDisguiseManager().disguise(disguise); UtilMorph.disguise(player, disguise, Manager); player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 999999999, 1)); @@ -70,7 +82,6 @@ public class MorphBunny extends MorphGadget { _jumpCharge.remove(player); this.removeArmor(player); - //Manager.getDisguiseManager().undisguise(player); UtilMorph.undisguise(player, Manager.getDisguiseManager()); player.removePotionEffect(PotionEffectType.SPEED); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphChicken.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphChicken.java index 1b033eabb..ce37ddde3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphChicken.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphChicken.java @@ -1,6 +1,5 @@ package mineplex.core.gadget.gadgets.morph; -import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; import org.bukkit.GameMode; import org.bukkit.Material; import org.bukkit.Sound; @@ -19,14 +18,15 @@ import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEvent; -import mineplex.core.common.util.UtilText; import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilText; import mineplex.core.disguise.disguises.DisguiseChicken; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; +import mineplex.core.gadget.types.MorphGadget; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.types.MorphGadget; public class MorphChicken extends MorphGadget { @@ -49,9 +49,6 @@ public class MorphChicken extends MorphGadget this.applyArmor(player, message); DisguiseChicken disguise = new DisguiseChicken(player); - //disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank()); - //disguise.setCustomNameVisible(true); - //Manager.getDisguiseManager().disguise(disguise); UtilMorph.disguise(player, disguise, Manager); } @@ -59,7 +56,6 @@ public class MorphChicken extends MorphGadget public void disableCustom(Player player, boolean message) { this.removeArmor(player); - //Manager.getDisguiseManager().undisguise(player); UtilMorph.undisguise(player, Manager.getDisguiseManager()); player.setAllowFlight(false); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphCow.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphCow.java index c8597bc3e..f8d334a12 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphCow.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphCow.java @@ -1,21 +1,21 @@ package mineplex.core.gadget.gadgets.morph; -import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.player.*; +import org.bukkit.event.player.PlayerInteractEvent; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilEvent; -import mineplex.core.common.util.UtilText; import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilText; import mineplex.core.disguise.disguises.DisguiseCow; -import mineplex.core.recharge.Recharge; import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; import mineplex.core.gadget.types.MorphGadget; +import mineplex.core.recharge.Recharge; public class MorphCow extends MorphGadget { @@ -37,9 +37,6 @@ public class MorphCow extends MorphGadget this.applyArmor(player, message); DisguiseCow disguise = new DisguiseCow(player); - //disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank()); - //disguise.setCustomNameVisible(true); - //Manager.getDisguiseManager().disguise(disguise); UtilMorph.disguise(player, disguise, Manager); } @@ -47,7 +44,6 @@ public class MorphCow extends MorphGadget public void disableCustom(Player player, boolean message) { this.removeArmor(player); - //Manager.getDisguiseManager().undisguise(player); UtilMorph.undisguise(player, Manager.getDisguiseManager()); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphCreeper.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphCreeper.java index af1aa5cb6..13f6a91b4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphCreeper.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphCreeper.java @@ -2,7 +2,6 @@ package mineplex.core.gadget.gadgets.morph; import java.util.HashMap; -import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; import org.bukkit.EntityEffect; import org.bukkit.Material; import org.bukkit.Sound; @@ -17,17 +16,18 @@ import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilText; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguiseCreeper; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; +import mineplex.core.gadget.types.MorphGadget; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.types.MorphGadget; public class MorphCreeper extends MorphGadget { @@ -51,9 +51,6 @@ public class MorphCreeper extends MorphGadget this.applyArmor(player, message); DisguiseCreeper disguise = new DisguiseCreeper(player); - //disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank()); - //disguise.setCustomNameVisible(true); - //Manager.getDisguiseManager().disguise(disguise); UtilMorph.disguise(player, disguise, Manager); } @@ -61,7 +58,6 @@ public class MorphCreeper extends MorphGadget public void disableCustom(Player player, boolean message) { this.removeArmor(player); - //Manager.getDisguiseManager().undisguise(player); UtilMorph.undisguise(player, Manager.getDisguiseManager()); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphEnderman.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphEnderman.java index 616364633..761003e4d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphEnderman.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphEnderman.java @@ -1,14 +1,13 @@ package mineplex.core.gadget.gadgets.morph; -import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; import org.bukkit.Color; import org.bukkit.Effect; import org.bukkit.FireworkEffect; +import org.bukkit.FireworkEffect.Type; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; -import org.bukkit.FireworkEffect.Type; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; @@ -23,6 +22,7 @@ import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilText; import mineplex.core.disguise.disguises.DisguiseEnderman; import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; import mineplex.core.gadget.types.MorphGadget; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; @@ -48,9 +48,6 @@ public class MorphEnderman extends MorphGadget this.applyArmor(player, message); DisguiseEnderman disguise = new DisguiseEnderman(player); - //disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank()); - //disguise.setCustomNameVisible(true); - //Manager.getDisguiseManager().disguise(disguise); UtilMorph.disguise(player, disguise, Manager); } @@ -58,7 +55,6 @@ public class MorphEnderman extends MorphGadget public void disableCustom(Player player, boolean message) { this.removeArmor(player); - //Manager.getDisguiseManager().undisguise(player); UtilMorph.undisguise(player, Manager.getDisguiseManager()); player.setAllowFlight(false); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphMetalMan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphMetalMan.java index 3722be911..fbed219e4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphMetalMan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphMetalMan.java @@ -5,16 +5,6 @@ import java.util.HashSet; import java.util.Map; import java.util.UUID; -import com.mojang.authlib.GameProfile; -import mineplex.core.common.skin.SkinData; -import mineplex.core.common.util.*; -import mineplex.core.disguise.disguises.DisguisePlayer; -import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.event.GadgetSelectLocationEvent; -import mineplex.core.gadget.gadgets.particle.unrelated.MetalManEffect; -import mineplex.core.gadget.types.MorphGadget; -import mineplex.core.recharge.Recharge; -import mineplex.core.utils.UtilGameProfile; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -22,6 +12,24 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerInteractEvent; +import com.mojang.authlib.GameProfile; + +import mineplex.core.common.skin.SkinData; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilText; +import mineplex.core.disguise.disguises.DisguisePlayer; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.event.GadgetSelectLocationEvent; +import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; +import mineplex.core.gadget.gadgets.particle.unrelated.MetalManEffect; +import mineplex.core.gadget.types.MorphGadget; +import mineplex.core.recharge.Recharge; +import mineplex.core.utils.UtilGameProfile; + public class MorphMetalMan extends MorphGadget { @@ -29,9 +37,12 @@ public class MorphMetalMan extends MorphGadget public MorphMetalMan(GadgetManager manager) { - super(manager, "Metal Man Morph", UtilText.splitLinesToArray(new String[]{C.cGray + "This powerful suit forged of metal makes the wearer strong enough to even battle the gods", - "", C.cWhite + "Left-click to shoot laser beam"}, LineFormat.LORE), - 0, Material.IRON_INGOT, (byte) 0); + super(manager, "Metal Man Morph", UtilText.splitLinesToArray(new String[]{ + C.cGray + "This powerful suit forged of metal makes the wearer strong enough to even battle the gods", + "", + C.cWhite + "Left-click to shoot laser beam" + }, LineFormat.LORE), + -14, Material.IRON_INGOT, (byte) 0); } @Override @@ -45,7 +56,7 @@ public class MorphMetalMan extends MorphGadget DisguisePlayer disguisePlayer = new DisguisePlayer(player, gameProfile); disguisePlayer.showInTabList(true, 0); - Manager.getDisguiseManager().disguise(disguisePlayer); + UtilMorph.disguise(player, disguisePlayer, Manager); } @Override @@ -53,7 +64,7 @@ public class MorphMetalMan extends MorphGadget { removeArmor(player); - Manager.getDisguiseManager().undisguise(player); + UtilMorph.undisguise(player, Manager.getDisguiseManager()); } @EventHandler diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPig.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPig.java index f4584bcee..5ca077a14 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPig.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPig.java @@ -2,12 +2,14 @@ package mineplex.core.gadget.gadgets.morph; import java.util.HashSet; -import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.player.*; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerToggleFlightEvent; import mineplex.core.common.Rank; import mineplex.core.common.util.C; @@ -16,16 +18,17 @@ import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEvent; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilText; import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilText; import mineplex.core.disguise.disguises.DisguisePig; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; +import mineplex.core.gadget.types.MorphGadget; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.types.MorphGadget; public class MorphPig extends MorphGadget { @@ -50,9 +53,6 @@ public class MorphPig extends MorphGadget this.applyArmor(player, message); DisguisePig disguise = new DisguisePig(player); - //disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank()); - //disguise.setCustomNameVisible(true); - //Manager.getDisguiseManager().disguise(disguise); UtilMorph.disguise(player, disguise, Manager); } @@ -60,7 +60,6 @@ public class MorphPig extends MorphGadget public void disableCustom(Player player, boolean message) { this.removeArmor(player); - //Manager.getDisguiseManager().undisguise(player); UtilMorph.undisguise(player, Manager.getDisguiseManager()); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPumpkinKing.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPumpkinKing.java index 21c28ec95..2da37bc5d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPumpkinKing.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPumpkinKing.java @@ -1,6 +1,5 @@ package mineplex.core.gadget.gadgets.morph; -import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.entity.Skeleton.SkeletonType; @@ -12,6 +11,7 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilText; import mineplex.core.disguise.disguises.DisguiseSkeleton; import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; import mineplex.core.gadget.types.MorphGadget; import mineplex.core.visibility.VisibilityManager; @@ -38,10 +38,7 @@ public class MorphPumpkinKing extends MorphGadget DisguiseSkeleton disguise = new DisguiseSkeleton(player); disguise.showArmor(); - //disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank()); - //disguise.setCustomNameVisible(true); disguise.SetSkeletonType(SkeletonType.WITHER); - //Manager.getDisguiseManager().disguise(disguise); UtilMorph.disguise(player, disguise, Manager); player.getInventory().setHelmet(new ItemStack(Material.JACK_O_LANTERN)); @@ -54,7 +51,6 @@ public class MorphPumpkinKing extends MorphGadget public void disableCustom(Player player, boolean message) { this.removeArmor(player); - //Manager.getDisguiseManager().undisguise(player); UtilMorph.undisguise(player, Manager.getDisguiseManager()); player.getInventory().setHelmet(null); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSleigh.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSleigh.java new file mode 100644 index 000000000..9f6bb794c --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSleigh.java @@ -0,0 +1,238 @@ +package mineplex.core.gadget.gadgets.morph; + +import java.io.File; +import java.io.IOException; +import java.time.Month; +import java.time.YearMonth; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.vehicle.VehicleExitEvent; + +import mineplex.core.common.block.schematic.Schematic; +import mineplex.core.common.block.schematic.UtilSchematic; +import mineplex.core.common.util.F; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilText; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.morph.managers.sleigh.Sleigh; +import mineplex.core.gadget.gadgets.morph.managers.sleigh.SleighPosition; +import mineplex.core.gadget.types.MorphGadget; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +public class MorphSleigh extends MorphGadget +{ + + /** + * Directions of the Sleigh, with the correct coord for the player to be teleported and the schematic name + */ + public enum SleighDirection + { + NORTH("SleighMorphNorth.schematic", 0.5, 4.5), + SOUTH("SleighMorphSouth.schematic", 0.5, 1.5), + EAST("SleighMorphEast.schematic", 1.5, 1.5), + WEST("SleighMorphWest.schematic", 4.5, 1.5); + + private String _schematic; + private double _fixedX; + private double _fixedZ; + + SleighDirection(String schematic, double fixedX, double fixedZ) + { + _schematic = schematic; + _fixedX = fixedX; + _fixedZ = fixedZ; + } + + public String getSchematic() + { + return _schematic; + } + + public double getFixedX() + { + return _fixedX; + } + + public double getFixedZ() + { + return _fixedZ; + } + + } + + private Map _sleighs = new HashMap<>(); + private Map _schematics = new HashMap<>(); + + private List _positions = new ArrayList<>(); + + private Long _rightClickStart = null; + + public MorphSleigh(GadgetManager manager) + { + super(manager, "Sleigh Morph", UtilText.splitLinesToArray(new String[]{"Placeholder"}, LineFormat.LORE), -14, Material.STAINED_CLAY, (byte) 14, YearMonth.of(2016, Month.DECEMBER)); + // Loads sleigh schematics + for (SleighDirection sleighDirection : SleighDirection.values()) + { + try + { + Schematic schematic = UtilSchematic.loadSchematic(new File("../../update/schematic/" + sleighDirection.getSchematic())); + _schematics.put(sleighDirection, schematic); + } catch (IOException e) + { + e.printStackTrace(); + } + } + buildPositions(); + } + + @Override + public void enableCustom(Player player, boolean message) + { + applyArmor(player, message); + + // TODO DISGUISE + } + + @Override + public void disableCustom(Player player, boolean message) + { + removeArmor(player); + + // TODO UNDISGUISE + if (_sleighs.containsKey(player)) + { + _sleighs.get(player).stopEffect(); + _sleighs.remove(player); + } + } + + /** + * Activates the sleigh effect when left-clicking + * This will be changed in the next releases + * @param event + */ + @EventHandler + public void activateSleigh(PlayerInteractEvent event) + { + if (!isActive(event.getPlayer())) + return; + + if (!UtilEvent.isAction(event, UtilEvent.ActionType.L)) + return; + + Player player = event.getPlayer(); + + if (player.getItemInHand().getType() != Material.AIR) + return; + + //if (!Recharge.Instance.use(player, getName(), 150000, true, false, "Cosmetics")) + //return; + + List freePositions = _positions.stream().filter(position -> !position.isUsed()).collect(Collectors.toList()); + + if (freePositions.size() == 0) + { + UtilPlayer.message(player, F.main("Sleigh Ride", "There are too many sleighs in the sky right now! Please wait a minute and try again!")); + return; + } + + int randomPosition = UtilMath.random.nextInt(freePositions.size()); + SleighPosition position = freePositions.get(randomPosition); + position.setUsed(true); + SleighDirection direction = position.getDirection(); + Schematic schematic = _schematics.get(direction); + if (schematic == null) + { + try + { + schematic = UtilSchematic.loadSchematic(new File("../../update/schematic/SleighMorph.schematic")); + Location fixYaw = player.getLocation().clone(); + fixYaw.setYaw(90); + player.teleport(fixYaw); + } + catch (IOException e) + { + e.printStackTrace(); + } + } + Sleigh sleigh = new Sleigh(player, schematic, position); + sleigh.startEffect(); + _sleighs.put(player, sleigh); + } + + /** + * Stops player from leaving the sleigh if it's activte + * @param event + */ + @EventHandler + public void onLeaveVehicle(VehicleExitEvent event) + { + if (event.getExited() instanceof Player) + { + Player player = (Player) event.getExited(); + if (isActive(player)) + { + event.setCancelled(true); + } + } + } + + /** + * Creates positions in the hub map + * TODO add arcade positions + */ + private void buildPositions() + { + _positions.add(new SleighPosition(-11, 143, -30, SleighDirection.SOUTH, -9.5, 145.5, -28.5)); + _positions.add(new SleighPosition(57, 109, -150, SleighDirection.SOUTH, 58.5, 111.5, -148.5)); + _positions.add(new SleighPosition(141, 101, 80, SleighDirection.NORTH, 142.5, 103.5, 84.5)); + _positions.add(new SleighPosition(-12, 88, 85, SleighDirection.NORTH, -10.5, 90.5, 89.5)); + _positions.add(new SleighPosition(-95, 90, 70, SleighDirection.NORTH, -93.5, 92.5, 74.5)); + _positions.add(new SleighPosition(-105, 115, -80, SleighDirection.EAST, -103.5, 117.5, -78.5)); + _positions.add(new SleighPosition(-135, 97, -8, SleighDirection.EAST, -133.5, 99.5, -6.5)); + _positions.add(new SleighPosition(-45, 97, 15, SleighDirection.EAST, -43.5, 99.5, 16.5)); + _positions.add(new SleighPosition(136, 116, 85, SleighDirection.WEST, 140.5, 118.5, 86.5)); + } + + /** + * Removes sleighs if they run out of time, or moves them if they still have time + * @param event + */ + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() == UpdateType.FASTER) + { + _sleighs.values().forEach(Sleigh::playSound); + } + + if (event.getType() != UpdateType.TICK) + return; + + Iterator> iterator = _sleighs.entrySet().iterator(); + while (iterator.hasNext()) + { + Map.Entry entry = iterator.next(); + Sleigh sleigh = entry.getValue(); + if (!sleigh.update()) + { + iterator.remove(); + } + } + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSlime.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSlime.java index 0c41fc0a2..925934a72 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSlime.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSlime.java @@ -1,11 +1,10 @@ package mineplex.core.gadget.gadgets.morph; -import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.player.*; +import org.bukkit.event.player.PlayerInteractEvent; import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; @@ -14,12 +13,13 @@ import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEvent; -import mineplex.core.common.util.UtilText; import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilText; import mineplex.core.disguise.disguises.DisguiseSlime; -import mineplex.core.recharge.Recharge; import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; import mineplex.core.gadget.types.MorphGadget; +import mineplex.core.recharge.Recharge; public class MorphSlime extends MorphGadget { @@ -49,8 +49,6 @@ public class MorphSlime extends MorphGadget this.applyArmor(player, message); DisguiseSlime disguise = new DisguiseSlime(player); - //disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank()); - //disguise.setCustomNameVisible(true); int size = 1 + (_achievementManager.getMineplexLevelNumber(player, _clientManager.Get(player).GetRank())) / 8; @@ -61,8 +59,7 @@ public class MorphSlime extends MorphGadget size = 12; disguise.SetSize(size); - - //Manager.getDisguiseManager().disguise(disguise); + UtilMorph.disguise(player, disguise, Manager); } @@ -70,7 +67,6 @@ public class MorphSlime extends MorphGadget public void disableCustom(Player player, boolean message) { this.removeArmor(player); - //Manager.getDisguiseManager().undisguise(player); UtilMorph.undisguise(player, Manager.getDisguiseManager()); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSnowman.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSnowman.java index e103f0d0c..25326feff 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSnowman.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSnowman.java @@ -2,7 +2,6 @@ package mineplex.core.gadget.gadgets.morph; import java.util.WeakHashMap; -import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.Player; @@ -28,6 +27,7 @@ import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilText; import mineplex.core.disguise.disguises.DisguiseSnowman; import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; import mineplex.core.gadget.types.MorphGadget; import mineplex.core.recharge.Recharge; import mineplex.core.recharge.RechargeData; @@ -60,9 +60,6 @@ public class MorphSnowman extends MorphGadget this.applyArmor(player, message); DisguiseSnowman disguise = new DisguiseSnowman(player); - //disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank()); - //disguise.setCustomNameVisible(true); - //Manager.getDisguiseManager().disguise(disguise); UtilMorph.disguise(player, disguise, Manager); } @@ -70,7 +67,6 @@ public class MorphSnowman extends MorphGadget public void disableCustom(Player player, boolean message) { this.removeArmor(player); - //Manager.getDisguiseManager().undisguise(player); UtilMorph.undisguise(player, Manager.getDisguiseManager()); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSquid.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSquid.java index 618e48fd9..b7a4fba03 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSquid.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSquid.java @@ -1,19 +1,8 @@ package mineplex.core.gadget.gadgets.morph; -import mineplex.core.common.util.*; -import mineplex.core.disguise.disguises.DisguiseSquid; -import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.event.PlayerToggleSwimEvent; -import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; -import mineplex.core.gadget.gadgets.morph.managers.SwimManager; -import mineplex.core.gadget.types.MorphGadget; -import mineplex.core.gadget.types.OutfitGadget; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.projectile.IThrown; -import mineplex.core.projectile.ProjectileUser; -import mineplex.core.recharge.Recharge; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; +import java.time.Month; +import java.time.YearMonth; + import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.enchantments.Enchantment; @@ -26,6 +15,26 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilText; +import mineplex.core.disguise.disguises.DisguiseSquid; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.event.PlayerToggleSwimEvent; +import mineplex.core.gadget.gadgets.morph.managers.SwimManager; +import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; +import mineplex.core.gadget.types.MorphGadget; +import mineplex.core.gadget.types.OutfitGadget; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.projectile.IThrown; +import mineplex.core.projectile.ProjectileUser; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + public class MorphSquid extends MorphGadget implements IThrown { @@ -37,7 +46,7 @@ public class MorphSquid extends MorphGadget implements IThrown C.cWhite + "Swim to enable Fast Swimming", C.cWhite + "Sneak to shoot a fish above you" }, LineFormat.LORE), - 0, Material.INK_SACK, (byte) 0); + -14, Material.INK_SACK, (byte) 0, YearMonth.of(2016, Month.SEPTEMBER)); } @Override @@ -45,9 +54,6 @@ public class MorphSquid extends MorphGadget implements IThrown { applyArmor(player, message); DisguiseSquid disguiseSquid = new DisguiseSquid(player); - //disguiseSquid.setName(player.getName(), Manager.getClientManager().Get(player).GetRank()); - //disguiseSquid.setCustomNameVisible(true); - //Manager.getDisguiseManager().disguise(disguiseSquid); UtilMorph.disguise(player, disguiseSquid, Manager); onToggleSwim(new PlayerToggleSwimEvent(player, SwimManager.isSwimming(player.getUniqueId()))); } @@ -56,7 +62,6 @@ public class MorphSquid extends MorphGadget implements IThrown public void disableCustom(Player player, boolean message) { removeArmor(player); - //Manager.getDisguiseManager().undisguise(player); UtilMorph.undisguise(player, Manager.getDisguiseManager()); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphTitan.java index d175ef849..03076725c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphTitan.java @@ -4,7 +4,6 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; -import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -25,17 +24,18 @@ import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilText; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilText; import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguiseGuardian; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.event.GadgetSelectLocationEvent; +import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; import mineplex.core.gadget.types.MorphGadget; import mineplex.core.recharge.Recharge; import mineplex.core.recharge.RechargedEvent; @@ -64,10 +64,7 @@ public class MorphTitan extends MorphGadget this.applyArmor(player, message); DisguiseGuardian disguise = new DisguiseGuardian(player); - //disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank()); - //disguise.setCustomNameVisible(true); disguise.setElder(true); - //Manager.getDisguiseManager().disguise(disguise); UtilMorph.disguise(player, disguise, Manager); } @@ -75,7 +72,6 @@ public class MorphTitan extends MorphGadget public void disableCustom(Player player, boolean message) { this.removeArmor(player); - //Manager.getDisguiseManager().undisguise(player); UtilMorph.undisguise(player, Manager.getDisguiseManager()); player.setAllowFlight(false); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphTurkey.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphTurkey.java new file mode 100644 index 000000000..6fc6a2f90 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphTurkey.java @@ -0,0 +1,72 @@ +package mineplex.core.gadget.gadgets.morph; + +import java.time.Month; +import java.time.YearMonth; + +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerToggleSneakEvent; + +import com.mojang.authlib.GameProfile; + +import mineplex.core.common.skin.SkinData; +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilText; +import mineplex.core.disguise.disguises.DisguisePlayer; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; +import mineplex.core.gadget.types.MorphGadget; +import mineplex.core.utils.UtilGameProfile; + +public class MorphTurkey extends MorphGadget +{ + + public MorphTurkey(GadgetManager manager) + { + super(manager, "Turkey Morph", UtilText.splitLinesToArray(new String[] + { + C.cGray + "Gobble, Gobble, please don't stuff me!", + C.blankLine, + C.cWhite + "Sneak to gobble." + }, + LineFormat.LORE), -14, Material.COOKED_CHICKEN, (byte) 0, YearMonth.of(2016, Month.NOVEMBER)); + } + + @Override + public void enableCustom(Player player, boolean message) + { + applyArmor(player, message); + + GameProfile profile = UtilGameProfile.getGameProfile(player); + profile.getProperties().clear(); + profile.getProperties().put("textures", SkinData.TURKEY.getProperty()); + + DisguisePlayer disguisePlayer = new DisguisePlayer(player, profile); + disguisePlayer.showInTabList(true, 0); + UtilMorph.disguise(player, disguisePlayer, Manager); + } + + @Override + public void disableCustom(Player player, boolean message) + { + removeArmor(player); + UtilMorph.undisguise(player, Manager.getDisguiseManager()); + } + + @EventHandler + public void onSneak(PlayerToggleSneakEvent event) + { + if (!isActive(event.getPlayer())) + return; + + if (!event.isSneaking()) + return; + + Player player = event.getPlayer(); + player.getWorld().playSound(player.getLocation(), Sound.CHICKEN_IDLE, 1f, 1.25f); + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphUncleSam.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphUncleSam.java index fd47f1695..55ea3a9ba 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphUncleSam.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphUncleSam.java @@ -1,6 +1,13 @@ package mineplex.core.gadget.gadgets.morph; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; + import com.mojang.authlib.GameProfile; + import mineplex.core.common.skin.SkinData; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; @@ -9,24 +16,13 @@ import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilText; import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; import mineplex.core.gadget.types.MorphGadget; import mineplex.core.recharge.Recharge; import mineplex.core.utils.UtilGameProfile; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerQuitEvent; - -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; -import java.util.WeakHashMap; public class MorphUncleSam extends MorphGadget { - private Map _disguises = new HashMap<>(); public MorphUncleSam(GadgetManager manager) { @@ -53,9 +49,7 @@ public class MorphUncleSam extends MorphGadget DisguisePlayer disguisePlayer = new DisguisePlayer(player, profile); disguisePlayer.showInTabList(true, 0); - Manager.getDisguiseManager().disguise(disguisePlayer); - - this._disguises.put(player.getUniqueId(), disguisePlayer); + UtilMorph.disguise(player, disguisePlayer, Manager); } @Override @@ -63,7 +57,7 @@ public class MorphUncleSam extends MorphGadget { this.removeArmor(player); - Manager.getDisguiseManager().undisguise(this._disguises.remove(player.getUniqueId())); + UtilMorph.undisguise(player, Manager.getDisguiseManager()); } @EventHandler @@ -84,9 +78,4 @@ public class MorphUncleSam extends MorphGadget UtilFirework.playFreedomFirework(player.getLocation().clone().add(0, 2, 0)); } - @EventHandler - public void quit(PlayerQuitEvent event) - { - this._disguises.remove(event.getPlayer().getUniqueId()); - } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphVillager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphVillager.java index f50043402..9c0777d38 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphVillager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphVillager.java @@ -3,18 +3,6 @@ package mineplex.core.gadget.gadgets.morph; import java.util.HashSet; import java.util.Iterator; -import mineplex.core.common.currency.GlobalCurrency; -import mineplex.core.common.util.*; -import mineplex.core.common.util.UtilEvent.ActionType; -import mineplex.core.disguise.disguises.DisguiseVillager; -import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; -import mineplex.core.gadget.types.MorphGadget; -import mineplex.core.projectile.IThrown; -import mineplex.core.projectile.ProjectileUser; -import mineplex.core.recharge.Recharge; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; import org.bukkit.ChatColor; import org.bukkit.EntityEffect; import org.bukkit.Material; @@ -28,6 +16,26 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.inventory.ItemStack; +import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilText; +import mineplex.core.disguise.disguises.DisguiseVillager; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; +import mineplex.core.gadget.types.MorphGadget; +import mineplex.core.projectile.IThrown; +import mineplex.core.projectile.ProjectileUser; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + public class MorphVillager extends MorphGadget implements IThrown { private HashSet _gems = new HashSet(); @@ -52,9 +60,6 @@ public class MorphVillager extends MorphGadget implements IThrown this.applyArmor(player, message); DisguiseVillager disguise = new DisguiseVillager(player); - //disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank()); - //disguise.setCustomNameVisible(true); - //Manager.getDisguiseManager().disguise(disguise); UtilMorph.disguise(player, disguise, Manager); } @@ -62,7 +67,6 @@ public class MorphVillager extends MorphGadget implements IThrown public void disableCustom(Player player, boolean message) { this.removeArmor(player); - //Manager.getDisguiseManager().undisguise(player); UtilMorph.undisguise(player, Manager.getDisguiseManager()); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphWitch.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphWitch.java index 3b457ee01..d394b3e87 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphWitch.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphWitch.java @@ -1,5 +1,8 @@ package mineplex.core.gadget.gadgets.morph; +import java.time.Month; +import java.time.YearMonth; + import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -17,6 +20,7 @@ import mineplex.core.common.util.UtilText; import mineplex.core.disguise.disguises.DisguiseWitch; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.event.GadgetSelectLocationEvent; +import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; import mineplex.core.gadget.types.MorphGadget; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; @@ -27,7 +31,10 @@ public class MorphWitch extends MorphGadget public MorphWitch(GadgetManager manager) { - super(manager, "Witch Morph", UtilText.splitLinesToArray(new String[]{C.cWhite + "Press sneak to summon your trusty bat and start brewing"}, LineFormat.LORE), 0, Material.SKULL_ITEM, (byte) 3); + super(manager, "Witch Morph", UtilText.splitLinesToArray(new String[]{ + C.cWhite + "Press sneak to summon your trusty bat and start brewing" + }, LineFormat.LORE), + -14, Material.SKULL_ITEM, (byte) 3, YearMonth.of(2016, Month.OCTOBER)); } @Override @@ -35,9 +42,7 @@ public class MorphWitch extends MorphGadget { this.applyArmor(player, message); DisguiseWitch disguiseWitch = new DisguiseWitch(player); - disguiseWitch.setName(player.getName(), Manager.getClientManager().Get(player).GetRank()); - disguiseWitch.setCustomNameVisible(true); - Manager.getDisguiseManager().disguise(disguiseWitch); + UtilMorph.disguise(player, disguiseWitch, Manager); } @Override @@ -49,7 +54,7 @@ public class MorphWitch extends MorphGadget { witchEffectManager.stop(); } - Manager.getDisguiseManager().undisguise(player); + UtilMorph.undisguise(player, Manager.getDisguiseManager()); } public ItemStack getWitchItem() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphWither.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphWither.java index 6bca2d624..59f9bcb46 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphWither.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphWither.java @@ -4,31 +4,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; -import mineplex.core.common.Rank; -import mineplex.core.common.util.C; -import mineplex.core.common.util.LineFormat; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilEvent; -import mineplex.core.common.util.UtilText; -import mineplex.core.common.util.UtilEvent.ActionType; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.disguise.disguises.DisguiseBase; -import mineplex.core.disguise.disguises.DisguiseWither; -import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; -import mineplex.core.gadget.types.MorphGadget; -import mineplex.core.inventory.ClientItem; -import mineplex.core.inventory.data.Item; -import mineplex.core.recharge.Recharge; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; - import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.Player; @@ -40,6 +15,31 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.util.Vector; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilText; +import mineplex.core.disguise.disguises.DisguiseBase; +import mineplex.core.disguise.disguises.DisguiseWither; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; +import mineplex.core.gadget.types.MorphGadget; +import mineplex.core.inventory.ClientItem; +import mineplex.core.inventory.data.Item; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + public class MorphWither extends MorphGadget { private ArrayList _skulls = new ArrayList(); @@ -65,9 +65,6 @@ public class MorphWither extends MorphGadget player.setHealth(300); DisguiseWither disguise = new DisguiseWither(player); - //disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank()); - //disguise.setCustomNameVisible(true); - //Manager.getDisguiseManager().disguise(disguise); UtilMorph.disguise(player, disguise, Manager, true); player.setMaxHealth(20); @@ -78,7 +75,6 @@ public class MorphWither extends MorphGadget public void disableCustom(Player player, boolean message) { this.removeArmor(player); - //Manager.getDisguiseManager().undisguise(player); UtilMorph.undisguise(player, Manager.getDisguiseManager()); player.setAllowFlight(false); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/managers/UtilMorph.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/managers/UtilMorph.java index 828e096eb..e186e7845 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/managers/UtilMorph.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/managers/UtilMorph.java @@ -4,11 +4,12 @@ import java.util.HashMap; import java.util.Map; import java.util.UUID; +import org.bukkit.entity.Player; + import mineplex.core.disguise.DisguiseManager; import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguiseInsentient; import mineplex.core.gadget.GadgetManager; -import org.bukkit.entity.Player; public class UtilMorph { @@ -17,38 +18,54 @@ public class UtilMorph * UtilMorph helps disguising and undisguising players, avoiding the use of deprecated methods */ - private static Map _disguises = new HashMap<>(); + private static Map _disguises = new HashMap<>(); /** * Disguises a player with custom name * @param player The player that will be disguised - * @param disguiseInsentient The disguise that will be applied + * @param disguiseBase The disguise that will be applied * @param gadgetManager The gadget manager */ - public static void disguise(Player player, DisguiseInsentient disguiseInsentient, GadgetManager gadgetManager) + public static void disguise(Player player, DisguiseBase disguiseBase, GadgetManager gadgetManager) { - _disguises.put(player.getUniqueId(), disguiseInsentient); - disguiseInsentient.setName(player.getName(), gadgetManager.getClientManager().Get(player).getRealOrDisguisedRank()); - disguiseInsentient.setCustomNameVisible(true); - gadgetManager.getDisguiseManager().disguise(disguiseInsentient); + _disguises.put(player.getUniqueId(), disguiseBase); + if (disguiseBase instanceof DisguiseInsentient) + { + DisguiseInsentient disguiseInsentient = (DisguiseInsentient) disguiseBase; + disguiseInsentient.setName(player.getName(), gadgetManager.getClientManager().Get(player).getRealOrDisguisedRank()); + disguiseInsentient.setCustomNameVisible(true); + gadgetManager.getDisguiseManager().disguise(disguiseInsentient); + } + else + { + gadgetManager.getDisguiseManager().disguise(disguiseBase); + } } /** * Disguises a player with custom name (special case for the Wither Morph) * @param player The player that will be disguised - * @param disguiseInsentient The disguise that will be applied + * @param disguiseBase The disguise that will be applied * @param gadgetManager The gadget manager * @param wither */ - public static void disguise(Player player, DisguiseInsentient disguiseInsentient, GadgetManager gadgetManager, boolean wither) + public static void disguise(Player player, DisguiseBase disguiseBase, GadgetManager gadgetManager, boolean wither) { - _disguises.put(player.getUniqueId(), disguiseInsentient); - disguiseInsentient.setName(player.getName(), gadgetManager.getClientManager().Get(player).getRealOrDisguisedRank()); - if (!wither) + _disguises.put(player.getUniqueId(), disguiseBase); + if (disguiseBase instanceof DisguiseInsentient) { - disguiseInsentient.setCustomNameVisible(true); + DisguiseInsentient disguiseInsentient = (DisguiseInsentient) disguiseBase; + disguiseInsentient.setName(player.getName(), gadgetManager.getClientManager().Get(player).getRealOrDisguisedRank()); + if (!wither) + { + disguiseInsentient.setCustomNameVisible(true); + } + gadgetManager.getDisguiseManager().disguise(disguiseInsentient); + } + else + { + gadgetManager.getDisguiseManager().disguise(disguiseBase); } - gadgetManager.getDisguiseManager().disguise(disguiseInsentient); } /** diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/managers/sleigh/Sleigh.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/managers/sleigh/Sleigh.java new file mode 100644 index 000000000..07a32faaf --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/managers/sleigh/Sleigh.java @@ -0,0 +1,187 @@ +package mineplex.core.gadget.gadgets.morph.managers.sleigh; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.Player; + +import mineplex.core.common.block.schematic.Schematic; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; +import mineplex.core.gadget.gadgets.morph.MorphSleigh; + +/** + * Creates the sleigh effect for the Sleigh Morph + */ +public class Sleigh +{ + + private Map _oldBlockMaterials = new HashMap<>(); + private Map _oldBlockDatas = new HashMap<>(); + + private Player _player; + private Location _originalLocation; + private Schematic _schematic; + private SleighPosition _sleighPosition; + private Arrow _arrow; + private float _yaw; + + private int _moves = 0; + + public Sleigh(Player player, Schematic schematic, SleighPosition sleighPosition) + { + _player = player; + _schematic = schematic; + _sleighPosition = sleighPosition; + _yaw = (sleighPosition.getDirection() == MorphSleigh.SleighDirection.SOUTH) ? 0f : + (sleighPosition.getDirection() == MorphSleigh.SleighDirection.NORTH) ? 180f : + (sleighPosition.getDirection() == MorphSleigh.SleighDirection.WEST) ? 90f : -90f; + } + + /** + * Starts the sleigh effect + */ + public void startEffect() + { + _originalLocation = _player.getLocation().clone(); + Location origin = new Location(_originalLocation.getWorld(), _sleighPosition.getX(), + _sleighPosition.getY(), _sleighPosition.getZ()); + try + { + pasteSchematic(origin, 0, 0); + } catch (IOException e) + { + e.printStackTrace(); + } + } + + /** + * Stops the sleigh effect + */ + public void stopEffect() + { + restoreBlocks(); + _arrow.remove(); + _player.teleport(_originalLocation.clone().add(0, 5, 0)); + _sleighPosition.setUsed(false); + } + + /** + * Pastes the schematic for the sleigh + * @param origin The location where the sleigh schematic will be placed + * @param playerX The X coord where player will be teleported + * @param playerZ The Z coord where player will be teleported + * @throws IOException + */ + private void pasteSchematic(Location origin, int playerX, int playerZ) throws IOException + { + restoreBlocks(); + short width = _schematic.getWidth(); + short height = _schematic.getHeight(); + short length = _schematic.getLength(); + for (short x = 0; x < width; x++) + { + for (short y = 0; y < height; y++) + { + for (short z = 0; z < length; z++) + { + Location location = origin.clone().add(x, y, z); + _oldBlockMaterials.put(location, location.getBlock().getType()); + _oldBlockDatas.put(location, location.getBlock().getData()); + } + } + } + _schematic.paste(origin); + Location playerLoc = new Location(_originalLocation.getWorld(), _sleighPosition.getPlayerX() + playerX, + _sleighPosition.getPlayerY(), _sleighPosition.getPlayerZ() + playerZ); + // Spawns arrow so it looks like player is sitting on the sleigh + if (_arrow != null) + { + _arrow.remove(); + } + _arrow = playerLoc.getWorld().spawn(playerLoc, Arrow.class); + UtilEnt.ghost(_arrow, true, true); + playerLoc.setYaw(_yaw); + playerLoc.setPitch(0.0f); + _player.teleport(playerLoc); + _arrow.setPassenger(_player); + } + + /** + * Updates sleigh to look like its moving + * @return true if the sleigh was moved, false if the time is over (3 seconds) + */ + public boolean update() + { + _moves++; + int x = 0, z = 0; + switch (_sleighPosition.getDirection()) + { + case NORTH: + z = -1 * _moves; + break; + case SOUTH: + z = _moves; + break; + case WEST: + x = -1 * _moves; + break; + case EAST: + x = _moves; + } + Location newOrigin = new Location(_originalLocation.getWorld(), _sleighPosition.getX() + x, + _sleighPosition.getY(), _sleighPosition.getZ() + z); + restoreBlocks(); + UtilParticle.PlayParticle(UtilParticle.ParticleType.SNOW_SHOVEL, _player.getLocation(), 0f, 0f, 0f, 0.6f, 100, + UtilParticle.ViewDist.LONGER, UtilServer.getPlayers()); + try + { + pasteSchematic(newOrigin, x, z); + } catch (IOException e) + { + e.printStackTrace(); + } + if (_moves >= 20 * 3) + { + stopEffect(); + return false; + } + return true; + } + + /** + * Plays sleigh sound to the player + */ + public void playSound() + { + _player.playSound(_player.getLocation(), Sound.ORB_PICKUP, 1f, 1f); + } + + /** + * Restores the blocks that were changed from pasting the schematic + */ + private void restoreBlocks() + { + for (Map.Entry entry : _oldBlockMaterials.entrySet()) + { + Location location = entry.getKey(); + Material material = entry.getValue(); + byte data = 0; + if (_oldBlockDatas.containsKey(location)) + { + data = _oldBlockDatas.get(location); + } + location.getBlock().setType(material); + location.getBlock().setData(data); + } + _oldBlockMaterials.clear(); + _oldBlockDatas.clear(); + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/managers/sleigh/SleighPosition.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/managers/sleigh/SleighPosition.java new file mode 100644 index 000000000..f8d76bd3d --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/managers/sleigh/SleighPosition.java @@ -0,0 +1,76 @@ +package mineplex.core.gadget.gadgets.morph.managers.sleigh; + +import mineplex.core.gadget.gadgets.morph.MorphSleigh; + +/** + * Handles positions from Sleigh and player, and the direction of the sleigh and player + */ +public class SleighPosition +{ + + private int _x; + private int _y; + private int _z; + private MorphSleigh.SleighDirection _direction; + private double _playerX; + private double _playerY; + private double _playerZ; + private boolean _used; + + public SleighPosition(int x, int y, int z, MorphSleigh.SleighDirection direction, double playerX, double playerY, double playerZ) + { + _x = x; + _y = y; + _z = z; + _direction = direction; + _playerX = playerX; + _playerY = playerY; + _playerZ = playerZ; + _used = false; + } + + public int getX() + { + return _x; + } + + public int getY() + { + return _y; + } + + public int getZ() + { + return _z; + } + + public MorphSleigh.SleighDirection getDirection() + { + return _direction; + } + + public double getPlayerX() + { + return _playerX; + } + + public double getPlayerY() + { + return _playerY; + } + + public double getPlayerZ() + { + return _playerZ; + } + + public void setUsed(boolean used) + { + _used = used; + } + + public boolean isUsed() + { + return _used; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/windupsuit/OutfitWindUpSuit.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/windupsuit/OutfitWindUpSuit.java index 974ff360a..201eab634 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/windupsuit/OutfitWindUpSuit.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/windupsuit/OutfitWindUpSuit.java @@ -1,11 +1,12 @@ package mineplex.core.gadget.gadgets.outfit.windupsuit; -import mineplex.core.common.util.*; -import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.types.OutfitGadget; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import org.bukkit.*; +import java.util.HashMap; +import java.util.Iterator; + +import org.bukkit.ChatColor; +import org.bukkit.Color; +import org.bukkit.Material; +import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerMoveEvent; @@ -13,8 +14,17 @@ import org.bukkit.event.player.PlayerToggleSneakEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffectType; -import java.util.HashMap; -import java.util.Iterator; +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilColor; +import mineplex.core.common.util.UtilGear; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.UtilTextBottom; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.OutfitGadget; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; public class OutfitWindUpSuit extends OutfitGadget { @@ -94,17 +104,17 @@ public class OutfitWindUpSuit extends OutfitGadget if (phase == 0) { updateNextColor(color, colors[phase], player, phase); - percentage += 5; + percentage += 1; } else if (phase == 1) { updateNextColor(color, colors[phase], player, phase); - percentage += 5; + percentage += 1; } else if (phase == 2) { updateNextColor(color, colors[phase], player, phase); - percentage += 5; + percentage += 1; } else if (phase == 3) { @@ -153,6 +163,10 @@ public class OutfitWindUpSuit extends OutfitGadget if (_boosterManager.getTicks(player) >= 1800) { _boosterManager.removeEffects(player); + for (ItemStack itemStack : player.getEquipment().getArmorContents()) + { + UtilColor.applyColor(itemStack, UtilColor.DEFAULT_LEATHER_COLOR); + } } else { @@ -204,9 +218,9 @@ public class OutfitWindUpSuit extends OutfitGadget private void updateNextColor(Color original, Color finalColor, Player player, int phase) { // Makes a really smooth transition between colors - Color nextColor = UtilColor.getNextColor(original, finalColor, 5); + Color nextColor = UtilColor.getNextColor(original, finalColor, 1); - if (nextColor.getRed() == finalColor.getRed() && nextColor.getGreen() == finalColor.getGreen() && nextColor.getBlue() == finalColor.getBlue()) + if (compareColors(finalColor, nextColor)) _colorPhase.put(player, phase + 1); updateColor(player, nextColor); @@ -247,4 +261,27 @@ public class OutfitWindUpSuit extends OutfitGadget double percent = ((_percentage.get(player) * 100d) / 888d) / 100d; UtilTextBottom.displayProgress(C.Bold + getSet().getName(), percent, "", player); } + + private boolean compareColors(Color colorA, Color colorB) + { + int rA = colorA.getRed(), rB = colorB.getRed(); + int gA = colorA.getGreen(), gB = colorB.getGreen(); + int bA = colorA.getBlue(), bB = colorB.getBlue(); + int minR = Math.min(rA, rB), maxR = Math.max(rA, rB); + int minG = Math.min(gA, gB), maxG = Math.max(gA, gB); + int minB = Math.min(bA, bB), maxB = Math.max(bA, bB); + if (maxR - minR > 2) + { + return false; + } + if (maxG - minG > 2) + { + return false; + } + if (maxB - minB > 2) + { + return false; + } + return true; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/windupsuit/OutfitWindUpSuitBoosterManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/windupsuit/OutfitWindUpSuitBoosterManager.java index 265cc7d3d..abf360737 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/windupsuit/OutfitWindUpSuitBoosterManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/windupsuit/OutfitWindUpSuitBoosterManager.java @@ -1,19 +1,5 @@ package mineplex.core.gadget.gadgets.outfit.windupsuit; -import mineplex.core.common.util.UtilFirework; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.types.OutfitGadget; -import mineplex.core.noteblock.INoteVerifier; -import mineplex.core.noteblock.NBSReader; -import mineplex.core.noteblock.NotePlayer; -import mineplex.core.noteblock.NoteSong; -import org.bukkit.Color; -import org.bukkit.FireworkEffect; -import org.bukkit.entity.Player; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; - import java.io.DataInputStream; import java.io.File; import java.io.FileInputStream; @@ -21,7 +7,28 @@ import java.io.FileNotFoundException; import java.util.HashMap; import java.util.Set; -public class OutfitWindUpSuitBoosterManager +import org.bukkit.Bukkit; +import org.bukkit.Color; +import org.bukkit.FireworkEffect; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.LeatherArmorMeta; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +import mineplex.core.common.util.UtilColor; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.noteblock.NBSReader; +import mineplex.core.noteblock.NotePlayer; +import mineplex.core.noteblock.NoteSong; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +public class OutfitWindUpSuitBoosterManager implements Listener { private GadgetManager _gadget; @@ -32,6 +39,7 @@ public class OutfitWindUpSuitBoosterManager public OutfitWindUpSuitBoosterManager(GadgetManager gadget) { _gadget = gadget; + Bukkit.getPluginManager().registerEvents(this, gadget.getPlugin()); } public void applyEffects(Player player) @@ -121,4 +129,36 @@ public class OutfitWindUpSuitBoosterManager } } + /** + * Flickers colors between yellow and red to mimic the invulnerability star from mario + */ + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + return; + + _notePlayers.keySet().forEach(player -> flickerColor(player)); + } + + private void flickerColor(Player player) + { + ItemStack[] playerArmor = player.getEquipment().getArmorContents(); + for (ItemStack item : playerArmor) + { + if (item != null) + { + LeatherArmorMeta leatherMeta = (LeatherArmorMeta) item.getItemMeta(); + if (leatherMeta.getColor().getRed() == 255 && leatherMeta.getColor().getGreen() == 255) + { + UtilColor.applyColor(item, Color.fromRGB(255, 0, 0)); + } + else + { + UtilColor.applyColor(item, Color.fromRGB(255, 255, 0)); + } + } + } + } + } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFairy.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFairy.java index 2116e7604..452410209 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFairy.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFairy.java @@ -32,7 +32,18 @@ public class ParticleFairy extends ParticleGadget // Create if (!_fairy.containsKey(player)) _fairy.put(player, new ParticleFairyData(player)); - _fairy.get(player).Update(); + ParticleFairyData data = _fairy.get(player); + + if (!data.Fairy.getWorld().equals(player.getWorld())) + { + data.Fairy = null; + data.Player = null; + data.Target = null; + data = new ParticleFairyData(player); + _fairy.put(player, data); + } + + data.Update(); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleFreedom.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleFreedom.java index 68c253c4a..65b2525cf 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleFreedom.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleFreedom.java @@ -43,7 +43,7 @@ public class ParticleFreedom extends ParticleGadget public void stopEffect(Player player) { if (_effects.containsKey(player.getUniqueId())) - _effects.get(player.getUniqueId()).stop(); + _effects.remove(player.getUniqueId()).stop(); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/shadow/ParticleFoot.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/shadow/ParticleFoot.java index e44905184..9c3b8be54 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/shadow/ParticleFoot.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/shadow/ParticleFoot.java @@ -50,8 +50,6 @@ public class ParticleFoot extends ParticleGadget _foot = !_foot; - cleanSteps(); - if (!Manager.isMoving(player)) return; if (!UtilEnt.isGrounded(player)) return; @@ -85,6 +83,15 @@ public class ParticleFoot extends ParticleGadget UtilServer.getPlayers()); } + @EventHandler + public void cleanup(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTEST) + return; + + cleanSteps(); + } + public void cleanSteps() { if (_steps.isEmpty()) return; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectHalloween.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectHalloween.java index 038495d65..ffd1e29be 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectHalloween.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectHalloween.java @@ -26,7 +26,6 @@ public class WinEffectHalloween extends WinEffectGadget { private DisguisePlayer _npc; - private Skeleton _skeleton; private List _disguisePlayers = new ArrayList<>(); private int _tick; @@ -68,8 +67,6 @@ public class WinEffectHalloween extends WinEffectGadget _nonTeam.forEach(p -> UtilPlayer.showForAll(p)); _disguisePlayers.forEach(d -> d.getEntity().getBukkitEntity().remove()); _disguisePlayers.clear(); - _skeleton.remove(); - _skeleton = null; } @EventHandler diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectPodium.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectPodium.java index 34b7077e4..3dc52ff95 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectPodium.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectPodium.java @@ -78,6 +78,7 @@ public class WinEffectPodium extends WinEffectGadget @Override public void finish() { + Manager.getDisguiseManager().undisguise(_npc); _npc = null; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/Gadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/Gadget.java index ba38e4d5f..a39d7b46b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/Gadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/Gadget.java @@ -1,5 +1,6 @@ package mineplex.core.gadget.types; +import java.time.YearMonth; import java.util.HashSet; import org.bukkit.Bukkit; @@ -31,19 +32,43 @@ public abstract class Gadget extends SalesPackageBase implements Listener private String[] _alternativePackageNames; private boolean _free; + + private YearMonth _yearMonth = null; public Gadget(GadgetManager manager, GadgetType gadgetType, String name, String[] desc, int cost, Material mat, byte data) { this(manager, gadgetType, name, desc, cost, mat, data, 1); } + + public Gadget(GadgetManager manager, GadgetType gadgetType, String name, String[] desc, int cost, Material mat, byte data, YearMonth yearMonth) + { + this(manager, gadgetType, name, desc, cost, mat, data, yearMonth, 1); + } + + public Gadget(GadgetManager manager, GadgetType gadgetType, String name, String[] desc, int cost, Material mat, byte data, int quantity, String... alternativesalepackageNames) + { + super(name, mat, data, desc, cost, quantity); + + _gadgetType = gadgetType; + KnownPackage = false; + _free = false; + + _alternativePackageNames = alternativesalepackageNames; + if(_alternativePackageNames == null) { _alternativePackageNames = new String[0]; } + + Manager = manager; + + Manager.getPlugin().getServer().getPluginManager().registerEvents(this, Manager.getPlugin()); + } - public Gadget(GadgetManager manager, GadgetType gadgetType, String name, String[] desc, int cost, Material mat, byte data, int quantity, String... alternativesalepackageNames) + public Gadget(GadgetManager manager, GadgetType gadgetType, String name, String[] desc, int cost, Material mat, byte data, YearMonth yearMonth, int quantity, String... alternativesalepackageNames) { super(name, mat, data, desc, cost, quantity); _gadgetType = gadgetType; KnownPackage = false; _free = false; + _yearMonth = yearMonth; _alternativePackageNames = alternativesalepackageNames; if(_alternativePackageNames == null) { _alternativePackageNames = new String[0]; } @@ -83,6 +108,11 @@ public abstract class Gadget extends SalesPackageBase implements Listener { return _active.contains(player); } + + public YearMonth getYearMonth() + { + return _yearMonth; + } @EventHandler public void onPlayerQuit(PlayerQuitEvent event) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/MorphGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/MorphGadget.java index 335f9d0ff..ff08e8152 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/MorphGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/MorphGadget.java @@ -1,5 +1,7 @@ package mineplex.core.gadget.types; +import java.time.YearMonth; + import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -15,6 +17,11 @@ public abstract class MorphGadget extends Gadget { super(manager, GadgetType.MORPH, name, desc, cost, mat, data); } + + public MorphGadget(GadgetManager manager, String name, String[] desc, int cost, Material mat, byte data, YearMonth yearMonth) + { + super(manager, GadgetType.MORPH, name, desc, cost, mat, data, yearMonth); + } public void applyArmor(Player player, boolean message) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/WinEffectGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/WinEffectGadget.java index e2857ec77..0ab922d9d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/WinEffectGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/WinEffectGadget.java @@ -94,21 +94,27 @@ public abstract class WinEffectGadget extends Gadget public void runFinish() { - finish(); - _player = null; - _baseLocation = null; - _team.clear(); - _team = null; - _nonTeam.clear(); - _nonTeam = null; - _other.clear(); - _other = null; - _allPlayers.clear(); - _allPlayers = null; - // Loads gadgets back when players are teleported to the arcade hub, after the win effect - for (Player player : UtilServer.getPlayers()) + try { - Manager.getUserGadgetPersistence().load(player); + finish(); + } + finally + { + _player = null; + _baseLocation = null; + _team.clear(); + _team = null; + _nonTeam.clear(); + _nonTeam = null; + _other.clear(); + _other = null; + _allPlayers.clear(); + _allPlayers = null; + // Loads gadgets back when players are teleported to the arcade hub, after the win effect + for (Player player : UtilServer.getPlayers()) + { + Manager.getUserGadgetPersistence().load(player); + } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java index c7ae4e7e3..8038a84e1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java @@ -25,6 +25,7 @@ public enum GameDisplay Evolution("Evolution", Material.EMERALD, (byte)0, GameCategory.ARCADE, 16), Gravity("Gravity", Material.ENDER_PORTAL_FRAME, (byte)0, GameCategory.EXTRA, 18), Halloween("Halloween Horror", Material.PUMPKIN, (byte)0, GameCategory.CLASSICS, 19), + Halloween2016("Pumpkin's Revenge", Material.PUMPKIN, (byte)0, GameCategory.CLASSICS, 63), HideSeek("Block Hunt", Material.GRASS, (byte)0, GameCategory.CLASSICS, 20), HoleInTheWall("Hole in the Wall", Material.STAINED_GLASS, (byte) 2, GameCategory.ARCADE, 52), Horse("Horseback", Material.IRON_BARDING, (byte)0, GameCategory.ARCADE, 21), diff --git a/Plugins/Mineplex.Core/src/mineplex/core/memory/MemoryFix.java b/Plugins/Mineplex.Core/src/mineplex/core/memory/MemoryFix.java index b801e7759..5ac6c423f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/memory/MemoryFix.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/memory/MemoryFix.java @@ -1,52 +1,334 @@ package mineplex.core.memory; import java.lang.reflect.Field; +import java.util.HashSet; import java.util.Iterator; +import java.util.List; +import java.util.Set; import mineplex.core.MiniPlugin; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import net.minecraft.server.v1_8_R3.CraftingManager; +import net.minecraft.server.v1_8_R3.EnchantmentManager; +import net.minecraft.server.v1_8_R3.EntityInsentient; import net.minecraft.server.v1_8_R3.IInventory; +import net.minecraft.server.v1_8_R3.PathfinderGoal; +import net.minecraft.server.v1_8_R3.PathfinderGoalNearestAttackableTarget; +import net.minecraft.server.v1_8_R3.PathfinderGoalSelector; +import net.minecraft.server.v1_8_R3.WorldServer; import org.bukkit.Bukkit; import org.bukkit.World; +import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; +import org.bukkit.entity.Entity; import org.bukkit.entity.HumanEntity; import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageByBlockEvent; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.plugin.java.JavaPlugin; public class MemoryFix extends MiniPlugin { private static Field _intHashMap; - + public MemoryFix(JavaPlugin plugin) { super("Memory Fix", plugin); - + //_intHashMap = IntHashMap.class. } - + + @EventHandler + public void fixLastDamageEventLeaks(UpdateEvent event) + { + if (event.getType() != UpdateType.SLOW) + return; + + List worldList = Bukkit.getWorlds(); + Set worlds = new HashSet<>(worldList); + + // Sanity check + if (worlds.size() != worldList.size()) + throw new RuntimeException("Error: Duplicated worlds?!?!"); + + for (World world : worlds) + { + WorldServer worldServer = ((CraftWorld) world).getHandle(); + + for (net.minecraft.server.v1_8_R3.Entity nmsentity : worldServer.entityList) + { + Entity entity = nmsentity.getBukkitEntity(); + EntityDamageEvent lastDamageCause = entity.getLastDamageCause(); + if (lastDamageCause != null) + { + Entity damaged = lastDamageCause.getEntity(); + Entity damagerEntity = null; + Block damagerBlock = null; + if (lastDamageCause instanceof EntityDamageByEntityEvent) + damagerEntity = ((EntityDamageByEntityEvent) lastDamageCause).getDamager(); + if (lastDamageCause instanceof EntityDamageByBlockEvent) + damagerBlock = ((EntityDamageByBlockEvent) lastDamageCause).getDamager(); + + boolean shouldRemove = false; + + if (!damaged.isValid()) + shouldRemove = true; + else if (damagerEntity != null) + { + if (!damagerEntity.isValid()) + shouldRemove = true; + else if (!worlds.contains(damagerEntity.getWorld())) + shouldRemove = true; + } + else if (damagerBlock != null) + { + if (!worlds.contains(damagerBlock.getWorld())) + shouldRemove = true; + } + + if (shouldRemove) + entity.setLastDamageCause(null); + } + } + } + } + + private static Field PATHFINDER_GOAL_SELECTOR_B; + private static boolean PATHFINDER_GOAL_SELECTOR_B_SUCCESSFUL; + + private static Field PATHFINDER_GOAL_SELECTOR_C; + private static boolean PATHFINDER_GOAL_SELECTOR_C_SUCCESSFUL; + + private static Field PATHFINDER_GOAL_SELECTOR_ITEM_A; + private static boolean PATHFINDER_GOAL_SELECTOR_ITEM_A_SUCCESSFUL; + + private static Field PATHFINDER_GOAL_NEAREST_ATTACKABLE_TARGET_D; + private static boolean PATHFINDER_GOAL_NEAREST_ATTACKABLE_TARGET_D_SUCCESSFUL; + + static + { + try + { + PATHFINDER_GOAL_SELECTOR_ITEM_A = Class.forName(PathfinderGoalSelector.class.getName() + "$PathfinderGoalSelectorItem").getDeclaredField("a"); + PATHFINDER_GOAL_SELECTOR_ITEM_A.setAccessible(true); + PATHFINDER_GOAL_SELECTOR_ITEM_A_SUCCESSFUL = true; + } + catch (ReflectiveOperationException e) + { + e.printStackTrace(); + } + try + { + PATHFINDER_GOAL_SELECTOR_B = PathfinderGoalSelector.class.getDeclaredField("b"); + PATHFINDER_GOAL_SELECTOR_B.setAccessible(true); + PATHFINDER_GOAL_SELECTOR_B_SUCCESSFUL = true; + } + catch (ReflectiveOperationException e) + { + e.printStackTrace(); + } + try + { + PATHFINDER_GOAL_SELECTOR_C = PathfinderGoalSelector.class.getDeclaredField("c"); + PATHFINDER_GOAL_SELECTOR_C.setAccessible(true); + PATHFINDER_GOAL_SELECTOR_C_SUCCESSFUL = true; + } + catch (ReflectiveOperationException e) + { + e.printStackTrace(); + } + try + { + PATHFINDER_GOAL_NEAREST_ATTACKABLE_TARGET_D = PathfinderGoalNearestAttackableTarget.class.getDeclaredField("d"); + PATHFINDER_GOAL_NEAREST_ATTACKABLE_TARGET_D.setAccessible(true); + PATHFINDER_GOAL_NEAREST_ATTACKABLE_TARGET_D_SUCCESSFUL = true; + } + catch (ReflectiveOperationException e) + { + e.printStackTrace(); + } + } + + @SuppressWarnings("unchecked") + @EventHandler + public void fixPathfinderGoalLeaks(UpdateEvent event) + { + if (event.getType() != UpdateType.SLOW) + return; + + List worldList = Bukkit.getWorlds(); + Set worlds = new HashSet<>(worldList); + + // Sanity check + if (worlds.size() != worldList.size()) + throw new RuntimeException("Error: Duplicated worlds?!?!"); + + for (World world : worlds) + { + WorldServer worldServer = ((CraftWorld) world).getHandle(); + + for (net.minecraft.server.v1_8_R3.Entity nmsentity : worldServer.entityList) + { + if (nmsentity instanceof EntityInsentient) + { + EntityInsentient ei = (EntityInsentient) nmsentity; + if (PATHFINDER_GOAL_SELECTOR_ITEM_A_SUCCESSFUL) + { + if (PATHFINDER_GOAL_SELECTOR_B_SUCCESSFUL) + { + try + { + PathfinderGoalSelector targetSelector = ei.targetSelector; + List list = (List) PATHFINDER_GOAL_SELECTOR_B.get(targetSelector); + for (Object object : list) + { + try + { + PathfinderGoal goal = (PathfinderGoal) PATHFINDER_GOAL_SELECTOR_ITEM_A.get(object); + if (goal instanceof PathfinderGoalNearestAttackableTarget && PATHFINDER_GOAL_NEAREST_ATTACKABLE_TARGET_D_SUCCESSFUL) + { + net.minecraft.server.v1_8_R3.Entity original = (net.minecraft.server.v1_8_R3.Entity) PATHFINDER_GOAL_NEAREST_ATTACKABLE_TARGET_D.get(goal); + boolean shouldClear = false; + + if (original != null) + { + if (!original.valid) + shouldClear = true; + } + + if (shouldClear) + PATHFINDER_GOAL_NEAREST_ATTACKABLE_TARGET_D.set(goal, null); + } + } + catch (ReflectiveOperationException ex) + { + ex.printStackTrace(); + } + } + } + catch (ReflectiveOperationException e) + { + e.printStackTrace(); + } + } + } + } + } + } + } + + private static Object ENCHANTMENTMANAGER_D; + private static Field ENCHANTMENT_MODIFIER_THORNS_A; + private static Field ENCHANTMENT_MODIFIER_THORNS_B; + private static boolean ENCHANTMENTMANAGER_D_SUCCESSFUL; + + private static Object ENCHANTMENTMANAGER_E; + private static Field ENCHANTMENT_MODIFIER_ARTHROPODS_A; + private static Field ENCHANTMENT_MODIFIER_ARTHROPODS_B; + private static boolean ENCHANTMENTMANAGER_E_SUCCESSFUL; + + static + { + try + { + Field field = EnchantmentManager.class.getDeclaredField("d"); + field.setAccessible(true); + ENCHANTMENTMANAGER_D = field.get(null); + ENCHANTMENT_MODIFIER_THORNS_A = ENCHANTMENTMANAGER_D.getClass().getDeclaredField("a"); + ENCHANTMENT_MODIFIER_THORNS_A.setAccessible(true); + ENCHANTMENT_MODIFIER_THORNS_B = ENCHANTMENTMANAGER_D.getClass().getDeclaredField("b"); + ENCHANTMENT_MODIFIER_THORNS_B.setAccessible(true); + ENCHANTMENTMANAGER_D_SUCCESSFUL = true; + } + catch (ReflectiveOperationException e) + { + e.printStackTrace(); + } + try + { + Field field = EnchantmentManager.class.getDeclaredField("e"); + field.setAccessible(true); + ENCHANTMENTMANAGER_E = field.get(null); + ENCHANTMENT_MODIFIER_ARTHROPODS_A = ENCHANTMENTMANAGER_E.getClass().getDeclaredField("a"); + ENCHANTMENT_MODIFIER_ARTHROPODS_A.setAccessible(true); + ENCHANTMENT_MODIFIER_ARTHROPODS_B = ENCHANTMENTMANAGER_E.getClass().getDeclaredField("b"); + ENCHANTMENT_MODIFIER_ARTHROPODS_B.setAccessible(true); + ENCHANTMENTMANAGER_E_SUCCESSFUL = true; + } + catch (ReflectiveOperationException e) + { + e.printStackTrace(); + } + } + + @EventHandler + public void fixEnchantmentManager(UpdateEvent event) + { + if (event.getType() != UpdateType.SLOW) + return; + + if (ENCHANTMENTMANAGER_D_SUCCESSFUL) + { + try + { + net.minecraft.server.v1_8_R3.Entity a = (net.minecraft.server.v1_8_R3.Entity) ENCHANTMENT_MODIFIER_THORNS_A.get(ENCHANTMENTMANAGER_D); + net.minecraft.server.v1_8_R3.Entity b = (net.minecraft.server.v1_8_R3.Entity) ENCHANTMENT_MODIFIER_THORNS_B.get(ENCHANTMENTMANAGER_D); + + if ((a != null && !a.valid) || (b != null && !b.valid)) + { + ENCHANTMENT_MODIFIER_THORNS_A.set(ENCHANTMENTMANAGER_D, null); + ENCHANTMENT_MODIFIER_THORNS_B.set(ENCHANTMENTMANAGER_D, null); + } + } + catch (ReflectiveOperationException e) + { + e.printStackTrace(); + } + } + + if (ENCHANTMENTMANAGER_E_SUCCESSFUL) + { + try + { + net.minecraft.server.v1_8_R3.Entity a = (net.minecraft.server.v1_8_R3.Entity) ENCHANTMENT_MODIFIER_ARTHROPODS_A.get(ENCHANTMENTMANAGER_E); + net.minecraft.server.v1_8_R3.Entity b = (net.minecraft.server.v1_8_R3.Entity) ENCHANTMENT_MODIFIER_ARTHROPODS_B.get(ENCHANTMENTMANAGER_E); + + if ((a != null && !a.valid) || (b != null && !b.valid)) + { + ENCHANTMENT_MODIFIER_ARTHROPODS_A.set(ENCHANTMENTMANAGER_E, null); + ENCHANTMENT_MODIFIER_ARTHROPODS_B.set(ENCHANTMENTMANAGER_E, null); + } + } + catch (ReflectiveOperationException e) + { + e.printStackTrace(); + } + } + } + @EventHandler public void fixInventoryLeaks(UpdateEvent event) { if (event.getType() != UpdateType.SLOW) return; - + for (World world : Bukkit.getWorlds()) { - for (Object tileEntity : ((CraftWorld)world).getHandle().tileEntityList) + for (Object tileEntity : ((CraftWorld) world).getHandle().tileEntityList) { if (tileEntity instanceof IInventory) { - Iterator entityIterator = ((IInventory)tileEntity).getViewers().iterator(); - + Iterator entityIterator = ((IInventory) tileEntity).getViewers().iterator(); + while (entityIterator.hasNext()) { HumanEntity entity = entityIterator.next(); - - if (entity instanceof CraftPlayer && !((CraftPlayer)entity).isOnline()) + + if (entity instanceof CraftPlayer && !((CraftPlayer) entity).isOnline()) { entityIterator.remove(); } @@ -54,17 +336,17 @@ public class MemoryFix extends MiniPlugin } } } - + CraftingManager.getInstance().lastCraftView = null; CraftingManager.getInstance().lastRecipe = null; } - + @EventHandler public void fixEntityTrackerLeak(UpdateEvent event) { if (event.getType() != UpdateType.SLOW) return; - + // NEED TO FIX STUCK NETWORKMANAGERS..... /* for (World world : Bukkit.getWorlds()) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/HorseMount.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/HorseMount.java index 232084feb..05a85e24d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/HorseMount.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/HorseMount.java @@ -1,26 +1,28 @@ package mineplex.core.mount; +import java.time.YearMonth; import java.util.Iterator; +import net.minecraft.server.v1_8_R3.EntityCreature; +import net.minecraft.server.v1_8_R3.NavigationAbstract; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftCreature; +import org.bukkit.entity.Horse; +import org.bukkit.entity.Horse.Color; +import org.bukkit.entity.Horse.Style; +import org.bukkit.entity.Horse.Variant; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.inventory.ItemStack; + import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import net.minecraft.server.v1_8_R3.EntityCreature; -import net.minecraft.server.v1_8_R3.NavigationAbstract; - -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftCreature; -import org.bukkit.entity.Horse.Variant; -import org.bukkit.entity.Horse; -import org.bukkit.entity.Player; -import org.bukkit.entity.Horse.Color; -import org.bukkit.entity.Horse.Style; -import org.bukkit.event.EventHandler; -import org.bukkit.inventory.ItemStack; public class HorseMount extends Mount> { @@ -29,7 +31,7 @@ public class HorseMount extends Mount> protected Variant _variant; protected double _jump; protected Material _armor; - + public HorseMount(MountManager manager, String name, String[] desc, Material displayMaterial, byte displayData, int cost, Color color, Style style, Variant variant, double jump, Material armor) { super (manager, name, displayMaterial, displayData, desc, cost); @@ -41,6 +43,18 @@ public class HorseMount extends Mount> _jump = jump; _armor = armor; } + + public HorseMount(MountManager manager, String name, String[] desc, Material displayMaterial, byte displayData, int cost, Color color, Style style, Variant variant, double jump, Material armor, YearMonth yearMonth) + { + super (manager, name, displayMaterial, displayData, desc, cost, yearMonth); + KnownPackage = false; + + _color = color; + _style = style; + _variant = variant; + _jump = jump; + _armor = armor; + } @EventHandler public void UpdateHorse(UpdateEvent event) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/Mount.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/Mount.java index 9735c3a20..a978fd69f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/Mount.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/Mount.java @@ -1,10 +1,9 @@ package mineplex.core.mount; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.mount.event.MountActivateEvent; -import mineplex.core.shop.item.SalesPackageBase; +import java.time.YearMonth; +import java.util.HashMap; +import java.util.HashSet; + import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Entity; @@ -14,8 +13,11 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; -import java.util.HashMap; -import java.util.HashSet; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.mount.event.MountActivateEvent; +import mineplex.core.shop.item.SalesPackageBase; public abstract class Mount extends SalesPackageBase implements Listener { @@ -23,6 +25,8 @@ public abstract class Mount extends SalesPackageBase implem protected HashMap _active = new HashMap(); public MountManager Manager; + + private YearMonth _yearMonth = null; public Mount(MountManager manager, String name, Material material, byte displayData, String[] description, int coins) { @@ -33,6 +37,17 @@ public abstract class Mount extends SalesPackageBase implem Manager.getPlugin().getServer().getPluginManager().registerEvents(this, Manager.getPlugin()); } + public Mount(MountManager manager, String name, Material material, byte displayData, String[] description, int coins, YearMonth yearMonth) + { + super(name, material, displayData, description, coins); + + Manager = manager; + + _yearMonth = yearMonth; + + Manager.getPlugin().getServer().getPluginManager().registerEvents(this, Manager.getPlugin()); + } + public final void enable(Player player) { MountActivateEvent gadgetEvent = new MountActivateEvent(player, this); @@ -99,4 +114,9 @@ public abstract class Mount extends SalesPackageBase implem } return null; } + + public YearMonth getYearMonth() + { + return _yearMonth; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/MountManager.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/MountManager.java index 399bbd25c..bbd78a15e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/MountManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/MountManager.java @@ -3,7 +3,6 @@ package mineplex.core.mount; import java.util.ArrayList; import java.util.List; -import mineplex.core.mount.types.*; import org.bukkit.Material; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; @@ -24,6 +23,19 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.disguise.DisguiseManager; import mineplex.core.donation.DonationManager; +import mineplex.core.mount.types.MountBabyReindeer; +import mineplex.core.mount.types.MountCart; +import mineplex.core.mount.types.MountDragon; +import mineplex.core.mount.types.MountFreedomHorse; +import mineplex.core.mount.types.MountFrost; +import mineplex.core.mount.types.MountMule; +import mineplex.core.mount.types.MountNightmareSteed; +import mineplex.core.mount.types.MountSlime; +import mineplex.core.mount.types.MountSpider; +import mineplex.core.mount.types.MountTitan; +import mineplex.core.mount.types.MountUndead; +import mineplex.core.mount.types.MountValentinesSheep; +import mineplex.core.mount.types.MountZombie; public class MountManager extends MiniPlugin { @@ -49,7 +61,7 @@ public class MountManager extends MiniPlugin private void CreateGadgets() { - _types = new ArrayList>(); + _types = new ArrayList<>(); _types.add(new MountUndead(this)); _types.add(new MountFrost(this)); @@ -64,6 +76,8 @@ public class MountManager extends MiniPlugin _types.add(new MountValentinesSheep(this)); _types.add(new MountFreedomHorse(this)); _types.add(new MountNightmareSteed(this)); + // Hidden in this update + //_types.add(new MountChicken(this)); //_types.add(new MountSheep(this)); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountChicken.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountChicken.java new file mode 100644 index 000000000..68b439005 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountChicken.java @@ -0,0 +1,149 @@ +package mineplex.core.mount.types; + +import java.lang.reflect.Field; +import java.time.Month; +import java.time.YearMonth; + +import net.minecraft.server.v1_8_R3.EntityLiving; + +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; +import org.bukkit.entity.Horse; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilText; +import mineplex.core.disguise.disguises.DisguiseChicken; +import mineplex.core.mount.HorseMount; +import mineplex.core.mount.MountManager; +import mineplex.core.mount.SingleEntityMountData; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +public class MountChicken extends HorseMount +{ + + private static Field _jumpField; + + public MountChicken(MountManager manager) + { + super(manager, "Chicken Mount", + UtilText.splitLinesToArray(new String[] + { + "This isn't flying! It is falling with style." + }, LineFormat.LORE), + Material.FEATHER, (byte) 0, -1, Horse.Color.BLACK, Horse.Style.NONE, Horse.Variant.HORSE, 2.0, Material.AIR, YearMonth.of(2017, Month.JANUARY)); + try + { + _jumpField = EntityLiving.class.getDeclaredField("aY"); + _jumpField.setAccessible(false); + } catch (NoSuchFieldException e) + { + e.printStackTrace(); + } + } + + @Override + public void enableCustom(Player player) + { + player.leaveVehicle(); + player.eject(); + + //Remove other mounts + Manager.DeregisterAll(player); + + Horse horse = player.getWorld().spawn(player.getLocation(), Horse.class); + horse.setAdult(); + horse.setAgeLock(true); + horse.setColor(_color); + horse.setStyle(_style); + horse.setVariant(_variant); + horse.setOwner(player); + horse.setMaxDomestication(1); + horse.setJumpStrength(_jump); + horse.setMaxHealth(20); + horse.setHealth(horse.getMaxHealth()); + horse.getInventory().setSaddle(new ItemStack(Material.SADDLE)); + + if (horse.getVariant() == Horse.Variant.MULE) + horse.setCarryingChest(true); + + if (_armor != null) + horse.getInventory().setArmor(new ItemStack(_armor)); + + horse.setCustomName(player.getName() + "'s " + getName()); + + //Inform + UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(getName()) + ".")); + + //Store + SingleEntityMountData mount = new SingleEntityMountData<>(player, horse); + _active.put(player, mount); + + DisguiseChicken chicken = new DisguiseChicken(horse); + chicken.setName(player.getName() + "'s Chicken Mount"); + Manager.getDisguiseManager().disguise(chicken); + + UtilEnt.silence(horse, true); + } + + @EventHandler + public void jump(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + for (Player player : getActive().keySet()) + { + final Horse horse = getActive().get(player).getEntity(); + + // Slows down falling + if (!horse.isOnGround() && horse.getVelocity().getY() < 0) + { + Vector velocity = horse.getVelocity(); + velocity.setY(velocity.getY() * 0.6); + horse.setVelocity(velocity); + } + + if (horse.getPassenger() != player) + continue; + + if (!UtilEnt.isGrounded(horse)) + continue; + + if (!Recharge.Instance.use(player, "Chicken Mount Jump", 100, false, false)) + continue; + + try + { + boolean isJumping = _jumpField.getBoolean(((CraftPlayer) player).getHandle()); + + if (!isJumping) + continue; + + //Not jumping anymore + ((CraftPlayer) player).getHandle().i(false); + + //Velocity + UtilAction.velocity(horse, 1.4, 0.38, .8, true); + + //Sound + player.playSound(horse.getLocation(), Sound.CHICKEN_IDLE, .4F, 1.0F); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + } + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSpider.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSpider.java index 4ee91ff52..90b7ab87c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSpider.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSpider.java @@ -4,6 +4,8 @@ import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Map.Entry; +import net.minecraft.server.v1_8_R3.EntityLiving; + import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.block.Block; @@ -33,13 +35,14 @@ import mineplex.core.mount.SingleEntityMountData; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import net.minecraft.server.v1_8_R3.EntityLiving; public class MountSpider extends HorseMount { /** * @author Mysticate */ + + private static Field _jumpField; public MountSpider(MountManager manager) { @@ -54,6 +57,14 @@ public class MountSpider extends HorseMount C.cBlue + "Only buyable during Halloween 2015" }, LineFormat.LORE), Material.WEB, (byte) 0, -1, Color.BLACK, Style.NONE, Variant.HORSE, 2.0, Material.AIR); + try + { + _jumpField = EntityLiving.class.getDeclaredField("aY"); + _jumpField.setAccessible(true); + } catch (NoSuchFieldException e) + { + e.printStackTrace(); + } } @Override @@ -152,43 +163,6 @@ public class MountSpider extends HorseMount } } } - -// @EventHandler(priority = EventPriority.LOW) -// public void doubleJump(PlayerToggleFlightEvent event) -// { -// Player player = event.getPlayer(); -// -// if (player.getGameMode() == GameMode.CREATIVE) -// return; -// -// if (!getActive().containsKey(player)) -// return; -// -// if (getActive().get(player).getPassenger() != event.getPlayer()) -// return; -// -// //Chicken Cancel -// DisguiseBase disguise = Manager.getDisguiseManager().getDisguise(player); -// if (disguise != null && ((disguise instanceof DisguiseChicken && !((DisguiseChicken)disguise).isBaby()) || disguise instanceof DisguiseBat || disguise instanceof DisguiseEnderman || disguise instanceof DisguiseWither)) -// return; -// -// Horse horse = getActive().get(event.getPlayer()); -// -// if (!UtilEnt.isGrounded(horse)) -// return; -// -// event.setCancelled(true); -// player.setFlying(false); -// -// //Disable Flight -// player.setAllowFlight(false); -// -// //Velocity -// UtilAction.velocity(horse, 1.4, 0.38, 1, true); -// -// //Sound -// player.playSound(horse.getLocation(), Sound.SPIDER_IDLE, .4F, 1.0F); -// } @EventHandler public void jump(UpdateEvent event) @@ -211,13 +185,7 @@ public class MountSpider extends HorseMount try { - Field jump = EntityLiving.class.getDeclaredField("aY"); - final boolean accessable = jump.isAccessible(); - - jump.setAccessible(true); - boolean isJumping = jump.getBoolean(((CraftPlayer) player).getHandle()); - - jump.setAccessible(accessable); + boolean isJumping = _jumpField.getBoolean(((CraftPlayer) player).getHandle()); if (!isJumping) continue; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/playwire/PlayWireCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/playwire/PlayWireCommand.java index 5a2a56d10..709804c93 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/playwire/PlayWireCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/playwire/PlayWireCommand.java @@ -3,6 +3,7 @@ package mineplex.core.playwire; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; /** * @@ -20,7 +21,14 @@ public class PlayWireCommand implements CommandExecutor @Override public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args) { - _manager.onCommand(args); + if (commandSender instanceof Player) + { + commandSender.sendMessage("Unknown command. Type \"/help\" for help."); + } + else + { + _manager.onCommand(args); + } return true; } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/playwire/PlayWireManager.java b/Plugins/Mineplex.Core/src/mineplex/core/playwire/PlayWireManager.java index 8f54c7b57..631ffc7ec 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/playwire/PlayWireManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/playwire/PlayWireManager.java @@ -1,20 +1,27 @@ package mineplex.core.playwire; +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.UUID; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; + import mineplex.core.Managers; import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; +import mineplex.core.bonuses.BonusManager; +import mineplex.core.common.util.C; +import mineplex.core.common.util.Callback; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.donation.DonationManager; import mineplex.core.inventory.InventoryManager; import mineplex.core.treasure.TreasureType; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; -import org.bukkit.plugin.java.JavaPlugin; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.UUID; +import mineplex.serverdata.database.DBPool; /** * @@ -24,13 +31,15 @@ public class PlayWireManager extends MiniDbClientPlugin private final long COOL_DOWN = TimeUnit.HOURS.getMilliseconds(); private static final int REWARD_MESSAGE_DELAY_SECONDS = 10; - + + private final CoreClientManager _clientManager; private final DonationManager _donationManager; private final PlayWireRepository _repository; public PlayWireManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager) { super("PlayWire", plugin, clientManager); + _clientManager = clientManager; _donationManager = donationManager; _repository = new PlayWireRepository(this); getPlugin().getCommand("playwire").setExecutor(new PlayWireCommand(this)); @@ -73,6 +82,42 @@ public class PlayWireManager extends MiniDbClientPlugin _repository.attemptPlayWire(player, client, () -> { _donationManager.RewardCoinsLater("Watching Ad", player, 100); + final int accountId = _clientManager.Get(player).getAccountId(); + final Callback ticketCallback = new Callback() + { + public void run(Integer newTickets) + { + Managers.get(BonusManager.class).Get(player).setTickets(newTickets); + Managers.get(BonusManager.class).updateCreeperVisual(player, true, C.cAqua); + } + }; + runAsync(() -> + { + try (Connection c = DBPool.getAccount().getConnection(); Statement statement = c.createStatement()) + { + final String query = "UPDATE bonus SET tickets = tickets + 1 WHERE accountId = " + accountId + ";SELECT tickets FROM bonus WHERE accountId = " + accountId; + + statement.execute(query); + statement.getUpdateCount(); + statement.getMoreResults(); + + ResultSet rs = statement.getResultSet(); + if (rs.next()) + { + final int newTickets = rs.getInt(1); + runSync(() -> + { + ticketCallback.run(newTickets); + }); + } + } + catch (Exception e) + { + System.out.println("Failed to award ticket to player: " + player); + e.printStackTrace(); + } + }); + Managers.get(BonusManager.class).addPendingExplosion(player, player.getName()); Bukkit.getScheduler().runTaskLater(getClientManager().getPlugin(), () -> UtilPlayer.message(player, ResponseType.COUNTED.getMessage()), REWARD_MESSAGE_DELAY_SECONDS * 20L); }); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/playwire/ResponseType.java b/Plugins/Mineplex.Core/src/mineplex/core/playwire/ResponseType.java index a4f096bde..e35d18c62 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/playwire/ResponseType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/playwire/ResponseType.java @@ -8,8 +8,8 @@ import mineplex.core.common.util.F; public enum ResponseType { - COUNTED(F.main("Carl", "Rewarded " + F.elem("250 Treasure Shards") + " for watching the Ad")), - UNCOUNTED(F.main("Carl", "You already watched the Ad within the past 12 hours!")), + COUNTED(F.main("Carl", "Rewarded " + F.elem("100 Treasure Shards") + " and " + F.elem("1 Carl Spin Ticket") + " for watching the Ad")), + UNCOUNTED(F.main("Carl", "You already watched the Ad within the past hour!")), BLOCKED(F.main("Carl", "You have an AdBlocker on, but tried to watch the Ad! Ssssssslight problem there!")), UNFILLED(F.main("Carl", "Ssssomething went wrong with the Ad, we'll get it sorted ASAP.")),; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java index 66a2d3d5c..1d7606146 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java @@ -2,22 +2,24 @@ package mineplex.core.powerplayclub; import java.time.Month; import java.time.YearMonth; -import java.util.*; +import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.stream.Collectors; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + import com.google.common.collect.ImmutableMap; -import mineplex.core.common.currency.GlobalCurrency; + import mineplex.core.common.skin.SkinData; import mineplex.core.common.util.BukkitFuture; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; -import mineplex.core.donation.DonationManager; import mineplex.core.inventory.InventoryManager; import mineplex.core.inventory.data.Item; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; public class PowerPlayClubRewards { @@ -27,6 +29,8 @@ public class PowerPlayClubRewards private static final Map rewards = ImmutableMap.builder() .put(YearMonth.of(2016, Month.SEPTEMBER), new PowerPlayClubItem("Squid Morph", new ItemStack(Material.INK_SACK))) .put(YearMonth.of(2016, Month.OCTOBER), new PowerPlayClubItem("Witch Morph", SkinData.WITCH.getSkull())) + .put(YearMonth.of(2016, Month.NOVEMBER), new PowerPlayClubItem("Turkey Morph", SkinData.TURKEY.getSkull())) + .put(YearMonth.of(2017, Month.JANUARY), new PowerPlayClubItem("Chicken Mount", new ItemStack(Material.GLASS))) .build(); public static class PowerPlayClubItem diff --git a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayData.java b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayData.java index 09b4b30f2..178916f39 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayData.java @@ -36,6 +36,9 @@ public class PowerPlayData return new PowerPlayData(Optional.empty(), Collections.emptySet(), Collections.emptySet()); } + final LocalDate today = LocalDate.now(); + final YearMonth thisMonth = YearMonth.now(); + // Build the list of potential claim dates from subscriptions // Note that it's a LinkedList with dates in ascending order List claimDates = subscriptions.stream() @@ -49,7 +52,7 @@ public class PowerPlayData // In the case of a yearly subscription, they're likely to have a claim date scheduled // (this is not the case for the last month) - Optional nextSubClaim = claimDates.stream().filter(date -> date.isAfter(LocalDate.now())).findFirst(); + Optional nextSubClaim = claimDates.stream().filter(date -> date.isAfter(today)).findFirst(); if (nextSubClaim.isPresent()) { nextClaimDate = nextSubClaim; @@ -59,14 +62,14 @@ public class PowerPlayData // In the case of a monthly subscription, we need to extrapolate the next claim date nextClaimDate = Optional.of(claimDates.get(claimDates.size() - 1)) .map(date -> date.plusMonths(1)) - .filter(date -> date.isAfter(LocalDate.now())); // and make sure it's after today + .filter(date -> date.equals(today) || date.isAfter(today)); // and make sure it's today or later nextClaimDate.ifPresent(claimDates::add); } // Determine the months whose cosmetics can be used by this player Set cosmeticMonths = claimDates.stream() .map(YearMonth::from) - .filter(yearMonth -> yearMonth.isBefore(YearMonth.now()) || yearMonth.equals(YearMonth.now())) + .filter(yearMonth -> yearMonth.isBefore(thisMonth) || yearMonth.equals(thisMonth)) .collect(Collectors.toSet()); // Remove already-claimed months @@ -89,7 +92,7 @@ public class PowerPlayData }); Set unclaimedMonths = claimDates.stream() - .filter(date -> date.isBefore(LocalDate.now()) || date.equals(LocalDate.now())) // Filter dates yet to come + .filter(date -> date.isBefore(today) || date.equals(today)) // Filter dates yet to come .map(YearMonth::from) .collect(Collectors.toSet()); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/recharge/Recharge.java b/Plugins/Mineplex.Core/src/mineplex/core/recharge/Recharge.java index e9d4e2e63..6422651d6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/recharge/Recharge.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/recharge/Recharge.java @@ -243,13 +243,7 @@ public class Recharge extends MiniPlugin @EventHandler public void clearPlayer(final ClientUnloadEvent event) { - UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(_plugin, new Runnable() { - public void run() - { - _recharge.remove(event.GetName()); - } - } - , 20 * 60 * 2); // Retain info for 2 minutes + _recharge.remove(event.GetName()); } public void setDisplayForce(Player player, String ability, boolean displayForce) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportCategory.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportCategory.java index ea271ba0a..f48ca9b16 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportCategory.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportCategory.java @@ -10,27 +10,27 @@ public enum ReportCategory /** * Global category, used for representing values which aren't tied to a specific category (such as abusive report statistics). */ - GLOBAL(0), + GLOBAL((short) 0), /** * Hacking category, for reports involving cheats of any sort. */ - HACKING(1), + HACKING((short) 1), /** * Chat Abuse category, for reports involving offensive comments made in chat. */ - CHAT_ABUSE(2), + CHAT_ABUSE((short) 2), /** * Gameplay category, for reports specific to gameplay (such as bug exploits or issues with the map). */ - GAMEPLAY(3); + GAMEPLAY((short) 3); - private final int _id; + private final short _id; private final String _name; - ReportCategory(int id) + ReportCategory(short id) { _id = id; _name = WordUtils.capitalizeFully(name().replace('_', ' ')); @@ -41,7 +41,7 @@ public enum ReportCategory * * @return the id */ - public int getId() + public short getId() { return _id; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportHandlerTask.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportHandlerTask.java index b68907c23..f8d4974ba 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportHandlerTask.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportHandlerTask.java @@ -11,6 +11,7 @@ import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitRunnable; +import mineplex.core.chatsnap.SnapshotMetadata; import mineplex.core.chatsnap.SnapshotRepository; import mineplex.core.common.jsonchat.ChildJsonMessage; import mineplex.core.common.jsonchat.ClickEvent; @@ -80,19 +81,31 @@ public class ReportHandlerTask extends BukkitRunnable .add(prefix + C.cAqua + "Suspect - " + C.cGold + suspectName) .add("\n") .add(prefix + C.cAqua + "Type - " + C.cGold + report.getCategory().getName()) + .add("\n") + .add(prefix + C.cAqua + "Team - " + C.cGold + report.getAssignedTeam().map(ReportTeam::getName).orElse("None")) .add("\n" + prefix + "\n") .add(prefix + C.cGold + report.getMessages().size() + C.cAqua + " total reports") .add("\n") .add(Arrays.stream(getReportReasons(report)).map(s -> prefix + s).collect(Collectors.joining("\n"))) .add("\n" + prefix + "\n"); - if (report.getCategory() == ReportCategory.CHAT_ABUSE) + Optional snapshotMetadataOptional = report.getSnapshotMetadata(); + + if (snapshotMetadataOptional.isPresent()) { - jsonMessage = jsonMessage - .add(prefix + C.cAqua + "View chat log") - .hover(HoverEvent.SHOW_TEXT, C.cGray + "Opens the chat log in your default browser") - .click(ClickEvent.OPEN_URL, SnapshotRepository.getURL(reportId)) - .add("\n"); + SnapshotMetadata snapshotMetadata = snapshotMetadataOptional.get(); + Optional tokenOptional = snapshotMetadata.getToken(); + + if (tokenOptional.isPresent()) + { + String token = tokenOptional.get(); + + jsonMessage = jsonMessage + .add(prefix + C.cAqua + "View chat log") + .hover(HoverEvent.SHOW_TEXT, C.cGray + "Opens the chat log in your default browser") + .click(ClickEvent.OPEN_URL, SnapshotRepository.getURL(token)) + .add("\n"); + } } jsonMessage = jsonMessage diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java index 34b92a4f7..69002af2b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java @@ -19,6 +19,7 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; import mineplex.core.chatsnap.SnapshotManager; +import mineplex.core.chatsnap.SnapshotMetadata; import mineplex.core.chatsnap.command.PushSnapshotsCommand; import mineplex.core.chatsnap.command.PushSnapshotsHandler; import mineplex.core.command.CommandCenter; @@ -148,8 +149,8 @@ public class ReportManager // create snapshot id ahead of time if (category == ReportCategory.CHAT_ABUSE) { - int snapshotId = _snapshotManager.getSnapshotRepository().createSnapshot(null).join(); - report.setSnapshotId(snapshotId); + SnapshotMetadata snapshotMetadata = _snapshotManager.getSnapshotRepository().createSnapshot(null).join(); + report.setSnapshotMetadata(snapshotMetadata); } saveReport(report).join(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportPlugin.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportPlugin.java index 0a0e1ff18..7f960f1a7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportPlugin.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportPlugin.java @@ -6,7 +6,6 @@ import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; -import mineplex.core.report.command.ReportAbortCommand; import mineplex.core.report.command.ReportCloseCommand; import mineplex.core.report.command.ReportCommand; import mineplex.core.report.command.ReportHandleCommand; @@ -38,7 +37,6 @@ public class ReportPlugin extends MiniPlugin addCommand(new ReportHandleCommand(this)); addCommand(new ReportCloseCommand(this)); addCommand(new ReportStatsCommand(this)); - addCommand(new ReportAbortCommand(this)); addCommand(new ReportInfoCommand(this)); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportTeam.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportTeam.java index 1a6cc4f06..bb6f060b2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportTeam.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportTeam.java @@ -16,6 +16,11 @@ public enum ReportTeam _initialPriority = initialPriority; } + public String getName() + { + return name(); + } + public short getDatabaseId() { return _databaseId; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportAbortCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportAbortCommand.java deleted file mode 100644 index 67450ea61..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportAbortCommand.java +++ /dev/null @@ -1,64 +0,0 @@ -package mineplex.core.report.command; - -import java.util.logging.Level; - -import org.bukkit.entity.Player; - -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.util.BukkitFuture; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.report.ReportManager; -import mineplex.core.report.ReportPlugin; -import mineplex.core.report.data.Report; - -/** - * A command which allows a staff member to abort the report which they are currently handling. - * Another staff member may be given this report when executing {@link ReportHandleCommand}. - */ -public class ReportAbortCommand extends CommandBase -{ - public ReportAbortCommand(ReportPlugin plugin) - { - super(plugin, Rank.MODERATOR, "reportabort"); - } - - @Override - public void Execute(Player player, String[] args) - { - if (args == null || args.length == 0) - { - ReportManager reportManager = Plugin.getReportManager(); - - reportManager.getReportHandling(player).whenComplete(BukkitFuture.complete((reportOptional, throwable) -> - { - if (throwable == null) - { - if (reportOptional.isPresent()) - { - Report report = reportOptional.get(); - - reportManager.abortReport(report).thenApply(BukkitFuture.accept(voidValue -> - UtilPlayer.message(player, F.main(ReportManager.getReportPrefix(report), - "Report has been aborted and may be handled by another staff member.")))); - } - else - { - UtilPlayer.message(player, F.main(Plugin.getName(), "You aren't currently handling a report.")); - } - } - else - { - UtilPlayer.message(player, F.main(Plugin.getName(), C.cRed + "An error occurred, please try again later.")); - Plugin.getPlugin().getLogger().log(Level.SEVERE, "Error whilst aborting report for player " + player.getName(), throwable); - } - })); - } - else - { - UtilPlayer.message(player, F.main(Plugin.getName(), C.cRed + "Invalid Usage: " + F.elem("/" + _aliasUsed))); - } - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportCommand.java index 6587db136..ac1e5ec34 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportCommand.java @@ -6,13 +6,12 @@ import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; -import mineplex.core.common.util.BukkitFuture; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.report.ReportManager; import mineplex.core.report.ReportPlugin; -import mineplex.core.report.ui.ReportCategoryPage; +import mineplex.core.report.ui.ReportCreatePage; /** * The command used by players to create a report. @@ -62,7 +61,7 @@ public class ReportCommand extends CommandBase else { CoreClient suspectClient = clientManager.Get(suspect); - new ReportCategoryPage(Plugin, reporter, reporterId, suspectClient, reason).openInventory(); + new ReportCreatePage(Plugin, reporter, reporterId, suspectClient, reason).openInventory(); } } else @@ -71,7 +70,7 @@ public class ReportCommand extends CommandBase { if (suspectClient != null) { - new ReportCategoryPage(Plugin, reporter, reporterId, suspectClient, reason).openInventory(); + new ReportCreatePage(Plugin, reporter, reporterId, suspectClient, reason).openInventory(); } else { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportHandleCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportHandleCommand.java index a988ab3d5..4241202b2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportHandleCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportHandleCommand.java @@ -1,24 +1,14 @@ package mineplex.core.report.command; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.CompletableFuture; -import java.util.logging.Level; - -import org.bukkit.Bukkit; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; -import mineplex.core.common.util.BukkitFuture; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; -import mineplex.core.report.ReportManager; import mineplex.core.report.ReportPlugin; -import mineplex.core.report.data.Report; -import mineplex.core.report.data.ReportRepository; +import mineplex.core.report.ui.ReportHandlePage; /** * When executed, the user is appointed handler of the most important report in the report queue (if any). @@ -36,76 +26,9 @@ public class ReportHandleCommand extends CommandBase { if (args == null || args.length == 0) { - ReportManager reportManager = Plugin.getReportManager(); - ReportRepository reportRepository = reportManager.getReportRepository(); int accountId = _commandCenter.GetClientManager().getAccountId(player); - - reportManager.isHandlingReport(player).whenComplete((handlingReport, throwable) -> - { - if (throwable == null) - { - if (!handlingReport) - { - Map reportPriorities = Collections.synchronizedMap(new HashMap<>()); - boolean devMode = reportManager.isDevMode(player.getUniqueId()); - - // the below fetches the ids of all unhandled reports and gets a Report object for each of these ids - // the priority of the report is then calculated and the results placed in a map - reportRepository.getUnhandledReports(accountId, devMode).thenCompose(reportRepository::getReports).thenAccept(reports -> - CompletableFuture.allOf(reports.stream().map(report -> - reportManager.calculatePriority(report).thenAccept(priority -> - { - if (priority > 0) - { - reportPriorities.put(report, priority); - } - else - { - // mark the report as expired to keep the database clean - // and reduce future query time - reportManager.expireReport(report); - } - } - ) - ).toArray(CompletableFuture[]::new)).join() - ).thenApply(aVoid -> - { - Map.Entry mostImportant = null; - - for (Map.Entry entry : reportPriorities.entrySet()) - { - if (mostImportant == null || (double) entry.getValue() > mostImportant.getValue()) - { - mostImportant = entry; - } - } - - return mostImportant == null ? null : mostImportant.getKey(); - }).thenCompose(BukkitFuture.accept(report -> - { - if (report != null) - { - reportManager.handleReport(report, player); - } - else - { - UtilPlayer.message(player, F.main(Plugin.getName(), C.cRed + "No report found, report queue is empty.")); - } - })); - } - else - { - Bukkit.getScheduler().runTask(Plugin.getPlugin(), () -> - UtilPlayer.message(player, F.main(Plugin.getName(), C.cRed + "You are already handling a report."))); - - } - } - else - { - UtilPlayer.message(player, F.main(Plugin.getName(), C.cRed + "An error occurred, please try again later.")); - Plugin.getPlugin().getLogger().log(Level.SEVERE, "Error whilst checking for reports being handled by " + player.getName(), throwable); - } - }); + ReportHandlePage reportHandlePage = new ReportHandlePage(Plugin, player, accountId); + reportHandlePage.openInventory(); } else { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportInfoCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportInfoCommand.java index feb465dc5..4f5b92b46 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportInfoCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportInfoCommand.java @@ -6,8 +6,13 @@ import java.util.logging.Level; import org.bukkit.entity.Player; +import mineplex.core.chatsnap.SnapshotMetadata; +import mineplex.core.chatsnap.SnapshotRepository; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; +import mineplex.core.common.jsonchat.ClickEvent; +import mineplex.core.common.jsonchat.HoverEvent; +import mineplex.core.common.jsonchat.JsonMessage; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -48,6 +53,7 @@ public class ReportInfoCommand extends CommandBase String prefix = ReportManager.getReportPrefix(report); String suspect = repository.getAccountName(report.getSuspectId()).join(); String handler = report.getHandlerId().map(handlerId -> repository.getAccountName(handlerId).join()).orElse("None"); + Optional snapshotMetadataOptional = report.getSnapshotMetadata(); UtilPlayer.message(player, F.main(prefix, "Type: " + F.elem(report.getCategory().getName()))); UtilPlayer.message(player, F.main(prefix, "Suspect: " + F.elem(suspect))); @@ -76,6 +82,23 @@ public class ReportInfoCommand extends CommandBase String handlerMessage = result.getReason().orElse("None specified."); UtilPlayer.message(player, F.main(prefix, "Handler Message: " + F.elem(handlerMessage))); } + + if (snapshotMetadataOptional.isPresent()) + { + SnapshotMetadata snapshotMetadata = snapshotMetadataOptional.get(); + Optional tokenOptional = snapshotMetadata.getToken(); + + if (tokenOptional.isPresent()) + { + String token = tokenOptional.get(); + UtilPlayer.message(player, F.main(prefix, "")); + + new JsonMessage(F.main(prefix, F.elem("View chat log"))) + .hover(HoverEvent.SHOW_TEXT, C.cGray + "Opens the chat log in your default browser") + .click(ClickEvent.OPEN_URL, SnapshotRepository.getURL(token)) + .sendToPlayer(player); + } + } } else { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportStatsCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportStatsCommand.java index 2ba759f95..e02de3ae1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportStatsCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportStatsCommand.java @@ -1,6 +1,5 @@ package mineplex.core.report.command; -import org.bukkit.Bukkit; import org.bukkit.entity.Player; import com.google.common.primitives.Longs; @@ -32,53 +31,62 @@ public class ReportStatsCommand extends CommandBase if (args != null && args.length == 1) { String playerName = args[0]; - Player target = Bukkit.getPlayer(playerName); - if (target != null) + Plugin.getReportManager().getReportRepository().getAccountId(playerName).thenAccept(accountIdOptional -> { - int accountId = _commandCenter.GetClientManager().getAccountId(target); + if (accountIdOptional.isPresent()) + { + int accountId = accountIdOptional.get(); - Plugin.getReportManager().getReportRepository().getAccountStatistics(accountId).thenCompose(BukkitFuture.accept(stats -> - stats.keySet().forEach(role -> - { - long[] idArray = stats.get(role).stream() - .sorted((l1, l2) -> Longs.compare(l2, l1)) - .mapToLong(l -> l) - .toArray(); - int reportCount = idArray.length; - - // don't show handler statistics if user has never handled a report - if (role != ReportRole.HANDLER || reportCount > 0) + Plugin.getReportManager().getReportRepository().getAccountStatistics(accountId).thenCompose(BukkitFuture.accept(stats -> { - // create clickable report ids - ChildJsonMessage jsonMessage = new JsonMessage(F.main(Plugin.getName(), "")) - .extra(C.mElem); + UtilPlayer.message(player, F.main(Plugin.getName(), "Report Statistics for " + F.elem(playerName))); - int displayAmount = 5; - - for (int i = 0; i < displayAmount; i++) + for (ReportRole role : ReportRole.values()) { - long reportId = idArray[i]; + long[] idArray = stats.get(role).stream() + .sorted((l1, l2) -> Longs.compare(l2, l1)) + .mapToLong(l -> l) + .toArray(); + int reportCount = idArray.length; - jsonMessage = jsonMessage.add(String.valueOf(reportId)) - .click(ClickEvent.RUN_COMMAND, "/reportinfo " + reportId); + // create clickable report ids + ChildJsonMessage jsonMessage = new JsonMessage(F.main(Plugin.getName(), "")) + .extra(C.mElem); - if (reportId != displayAmount) + int displayAmount = Math.min(idArray.length, 5); + + if (displayAmount > 0) { - jsonMessage = jsonMessage.add(", "); - } - } + for (int i = 0; i < displayAmount; i++) + { + long reportId = idArray[i]; - UtilPlayer.message(player, F.main(Plugin.getName(), F.elem(role.getHumanName()) + " (" + reportCount + ")")); - jsonMessage.sendToPlayer(player); + jsonMessage = jsonMessage.add(String.valueOf(reportId)) + .click(ClickEvent.RUN_COMMAND, "/reportinfo " + reportId); + + if (i != displayAmount - 1) + { + jsonMessage = jsonMessage.add(", "); + } + } + } + else + { + jsonMessage = jsonMessage.add("N/A"); + } + + UtilPlayer.message(player, F.main(Plugin.getName(), F.elem(role.getHumanName()) + " (" + reportCount + ")")); + jsonMessage.sendToPlayer(player); + } } - }) - )); - } - else - { - UtilPlayer.message(player, F.main(Plugin.getName(), C.cRed + "Player not found.")); - } + )); + } + else + { + UtilPlayer.message(player, F.main(Plugin.getName(), C.cRed + "Player not found.")); + } + }); } else { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/data/Report.java b/Plugins/Mineplex.Core/src/mineplex/core/report/data/Report.java index 4a8d8e969..6fd4af9f6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/data/Report.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/data/Report.java @@ -5,6 +5,7 @@ import java.util.Map; import java.util.Optional; import java.util.Set; +import mineplex.core.chatsnap.SnapshotMetadata; import mineplex.core.report.ReportCategory; import mineplex.core.report.ReportHandlerTask; import mineplex.core.report.ReportResult; @@ -21,7 +22,7 @@ public class Report // set of player account ids and the reason they reported this player private final Map _reportMessages = new HashMap<>(); private Integer _handlerId = null; - private Integer _snapshotId = null; + private SnapshotMetadata _snapshotMetadata = null; private ReportResult _reportResult = null; private ReportTeam _assignedTeam = null; @@ -89,14 +90,14 @@ public class Report _handlerId = handlerId; } - public Optional getSnapshotId() + public Optional getSnapshotMetadata() { - return Optional.ofNullable(_snapshotId); + return Optional.ofNullable(_snapshotMetadata); } - public void setSnapshotId(Integer snapshotId) + public void setSnapshotMetadata(SnapshotMetadata snapshotMetadata) { - _snapshotId = snapshotId; + _snapshotMetadata = snapshotMetadata; } public Optional getResult() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java index 2f7373bac..57f553921 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java @@ -30,6 +30,7 @@ import com.google.common.cache.CacheBuilder; import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; import com.mysql.jdbc.Statement; +import mineplex.core.chatsnap.SnapshotMetadata; import mineplex.core.common.util.UtilTime; import mineplex.core.report.ReportCategory; import mineplex.core.report.ReportManager; @@ -53,7 +54,7 @@ public class ReportRepository private static final String SET_REPORT_MESSAGE = "REPLACE INTO reportReasons (reportId, reporterId, reason, `server`, weight, `time`)" + " VALUES (?, ?, ?, ?, ?, ?);"; - private static final String SET_REPORT_HANDLER = "REPLACE INTO reportHandlers (reportId, handlerId)" + + private static final String INSERT_REPORT_HANDLER = "INSERT IGNORE INTO reportHandlers (reportId, handlerId)" + " VALUES (?, ?);"; private static final String SET_REPORT_RESULT = "REPLACE INTO reportResults (reportId, resultId, reason, closedTime)" + @@ -77,7 +78,8 @@ public class ReportRepository " LEFT JOIN reportResults ON reports.id = reportResults.reportId\n" + " LEFT JOIN reportHandlers ON reports.id = reportHandlers.reportId\n" + " LEFT JOIN reportReasons ON reports.id = reportReasons.reportId\n" + - "WHERE reportResults.reportId IS NULL\n" + + "WHERE reports.categoryId = ?\n" + + " AND reportResults.reportId IS NULL\n" + " /* Bypass for testing purposes or check player isn't suspect */\n" + " AND (? IS TRUE OR reports.suspectId != ?)\n" + " /* If team is assigned, make sure user is member of team */\n" + @@ -122,6 +124,9 @@ public class ReportRepository private static final String GET_ACCOUNT_UUID = "SELECT id, uuid FROM accounts" + " WHERE id IN (%s);"; + private static final String GET_ACCOUNT_ID = "SELECT id, `name` FROM accounts\n" + + "WHERE `name` = ?;"; + /** STATISTICS **/ private static final String STATISTICS_GET_REPORTS_MADE = "SELECT reports.id FROM reports, reportReasons\n" + @@ -157,7 +162,7 @@ public class ReportRepository * @param devMode if true, allows various restrictions to be bypassed * @return the ids of unhandled reports the supplied account is allowed to handle */ - public CompletableFuture> getUnhandledReports(int accountId, boolean devMode) + public CompletableFuture> getUnhandledReports(int accountId, ReportCategory category, boolean devMode) { CompletableFuture> future = CompletableFuture.supplyAsync(() -> { @@ -166,12 +171,13 @@ public class ReportRepository try (Connection connection = DBPool.getAccount().getConnection()) { PreparedStatement preparedStatement = connection.prepareStatement(GET_UNHANDLED_REPORTS); - preparedStatement.setBoolean(1, devMode); - preparedStatement.setInt(2, accountId); + preparedStatement.setShort(1, category.getId()); + preparedStatement.setBoolean(2, devMode); preparedStatement.setInt(3, accountId); preparedStatement.setInt(4, accountId); - preparedStatement.setBoolean(5, devMode); - preparedStatement.setInt(6, accountId); + preparedStatement.setInt(5, accountId); + preparedStatement.setBoolean(6, devMode); + preparedStatement.setInt(7, accountId); ResultSet resultSet = preparedStatement.executeQuery(); while (resultSet.next()) @@ -333,7 +339,10 @@ public class ReportRepository int snapshotId = resultSet.getInt("snapshotId"); if (!resultSet.wasNull()) { - report.setSnapshotId(snapshotId); + SnapshotMetadata snapshotMetadata = _reportManager.getSnapshotManager().getSnapshotRepository() + .getSnapshotMetadata(snapshotId).join(); + + report.setSnapshotMetadata(snapshotMetadata); } int handlerId = resultSet.getInt("handlerId"); @@ -537,7 +546,7 @@ public class ReportRepository try (Connection connection = DBPool.getAccount().getConnection()) { Optional reportIdOptional = report.getId(); - Optional snapshotIdOptional = report.getSnapshotId(); + Optional snapshotIdOptional = report.getSnapshotMetadata().map(SnapshotMetadata::getId); Optional teamOptional = report.getAssignedTeam(); long reportId; @@ -628,7 +637,7 @@ public class ReportRepository Optional handlerIdOptional = report.getHandlerId(); if (handlerIdOptional.isPresent()) { - PreparedStatement setReportHandlerStatement = connection.prepareStatement(SET_REPORT_HANDLER); + PreparedStatement setReportHandlerStatement = connection.prepareStatement(INSERT_REPORT_HANDLER); setReportHandlerStatement.setLong(1, reportId); // report id setReportHandlerStatement.setInt(2, handlerIdOptional.get()); // handler id setReportHandlerStatement.execute(); @@ -823,13 +832,17 @@ public class ReportRepository { try (Connection connection = DBPool.getAccount().getConnection()) { - PreparedStatement preparedStatement = connection.prepareStatement(GET_ACCOUNT_NAME); - preparedStatement.setInt(1, accountId); - - ResultSet resultSet = preparedStatement.executeQuery(); - if (resultSet.next()) + try (PreparedStatement preparedStatement = connection.prepareStatement(GET_ACCOUNT_NAME)) { - return resultSet.getString("name"); + preparedStatement.setInt(1, accountId); + + try (ResultSet resultSet = preparedStatement.executeQuery()) + { + if (resultSet.next()) + { + return resultSet.getString("name"); + } + } } } catch (SQLException e) @@ -864,14 +877,18 @@ public class ReportRepository try (Connection connection = DBPool.getAccount().getConnection()) { String query = String.format(GET_ACCOUNT_UUID, StringUtils.join(accountIds, ", ")); - PreparedStatement preparedStatement = connection.prepareStatement(query); - ResultSet resultSet = preparedStatement.executeQuery(); - while (resultSet.next()) + try (PreparedStatement preparedStatement = connection.prepareStatement(query)) { - int accountId = resultSet.getInt("id"); - UUID accountUUID = UUID.fromString(resultSet.getString("uuid")); - accountUUIDs.put(accountId, accountUUID); + try (ResultSet resultSet = preparedStatement.executeQuery()) + { + while (resultSet.next()) + { + int accountId = resultSet.getInt("id"); + UUID accountUUID = UUID.fromString(resultSet.getString("uuid")); + accountUUIDs.put(accountId, accountUUID); + } + } } } catch (SQLException e) @@ -891,4 +908,41 @@ public class ReportRepository return future; } + public CompletableFuture> getAccountId(String name) + { + CompletableFuture> future = CompletableFuture.supplyAsync(() -> + { + try (Connection connection = DBPool.getAccount().getConnection()) + { + try (PreparedStatement statement = connection.prepareStatement(GET_ACCOUNT_ID)) + { + statement.setString(1, name); + + try (ResultSet resultSet = statement.executeQuery()) + { + if (resultSet.next()) + { + return Optional.of(resultSet.getInt("id")); + } + else + { + return Optional.empty(); + } + } + } + } + catch (SQLException e) + { + throw new RuntimeException(e); + } + }); + + future.exceptionally(throwable -> + { + _logger.log(Level.SEVERE, "Error whilst fetching id from name: " + name, throwable); + return Optional.empty(); + }); + + return future; + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportAbortButton.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportAbortButton.java new file mode 100644 index 000000000..ccecffbe1 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportAbortButton.java @@ -0,0 +1,34 @@ +package mineplex.core.report.ui; + +import org.bukkit.Material; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.gui.SimpleGuiItem; +import mineplex.core.itemstack.ItemBuilder; + +/** + * A gui button which when clicked aborts the report the user is currently handling + */ +public class ReportAbortButton extends SimpleGuiItem +{ + private static final ItemStack ITEM = new ItemBuilder(Material.BEDROCK) + .setTitle(C.cRed + "Abort") + .addLore("Another member of staff may handle this report instead.") + .build(); + + private final ReportResultPage _page; + + public ReportAbortButton(ReportResultPage page) + { + super(ITEM); + _page = page; + } + + @Override + public void click(ClickType clickType) + { + _page.abortReport(); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportCategoryButton.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportCategoryButton.java index 21e6a0df9..d38229f39 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportCategoryButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportCategoryButton.java @@ -13,7 +13,7 @@ import mineplex.core.itemstack.ItemBuilder; import mineplex.core.report.ReportCategory; /** - * Represents a clickable button in a {@link ReportCategoryPage} which determines the type of infraction a player has committed. + * Represents a clickable button in a {@link ReportCreatePage} which determines the type of infraction a player has committed. */ public class ReportCategoryButton extends SimpleGuiItem { @@ -39,24 +39,29 @@ public class ReportCategoryButton extends SimpleGuiItem put(ReportCategory.GAMEPLAY, itemGameplay); }}; - private final ReportCategoryPage _reportCategoryPage; + private final ReportCategoryCallback _callback; private final ReportCategory _category; - public ReportCategoryButton(ReportCategoryPage reportCategoryPage, ReportCategory reportCategory) + public ReportCategoryButton(ReportCategoryCallback callback, ReportCategory reportCategory) { - this(reportCategoryPage, reportCategory, ITEM_STACKS.get(reportCategory)); + this(callback, reportCategory, ITEM_STACKS.get(reportCategory)); } - public ReportCategoryButton(ReportCategoryPage reportCategoryPage, ReportCategory reportCategory, ItemStack itemStack) + public ReportCategoryButton(ReportCategoryCallback callback, ReportCategory reportCategory, ItemStack itemStack) { super(itemStack); - _reportCategoryPage = reportCategoryPage; + _callback = callback; _category = reportCategory; } + public ReportCategory getCategory() + { + return _category; + } + @Override public void click(ClickType clickType) { - _reportCategoryPage.addReport(_category); + _callback.click(this); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportCategoryCallback.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportCategoryCallback.java new file mode 100644 index 000000000..ad8f2ff4c --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportCategoryCallback.java @@ -0,0 +1,13 @@ +package mineplex.core.report.ui; + +/** + * Allows re-use of the {@link ReportCategoryButton} class. + */ +public interface ReportCategoryCallback +{ + /** + * Invoked when a category button is clicked. + * @param button The button that was clicked + */ + void click(ReportCategoryButton button); +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportCategoryPage.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportCreatePage.java similarity index 90% rename from Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportCategoryPage.java rename to Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportCreatePage.java index d7d1dbfd5..4ee980e93 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportCategoryPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportCreatePage.java @@ -5,7 +5,6 @@ import java.util.Optional; import java.util.stream.Collectors; import org.bukkit.entity.Player; -import org.bukkit.event.HandlerList; import mineplex.core.account.CoreClient; import mineplex.core.chatsnap.SnapshotManager; @@ -21,7 +20,7 @@ import mineplex.core.report.ReportPlugin; /** * User interface shown to a player when reporting another player. */ -public class ReportCategoryPage extends SimpleGui +public class ReportCreatePage extends SimpleGui implements ReportCategoryCallback { private final ReportPlugin _plugin; private final Player _reporter; @@ -29,7 +28,7 @@ public class ReportCategoryPage extends SimpleGui private final CoreClient _suspect; private final String _reason; - public ReportCategoryPage(ReportPlugin plugin, Player reporter, int reporterId, CoreClient suspect, String reason) + public ReportCreatePage(ReportPlugin plugin, Player reporter, int reporterId, CoreClient suspect, String reason) { super(plugin.getPlugin(), reporter, "Report " + suspect.getName(), 9 * 3); @@ -51,9 +50,6 @@ public class ReportCategoryPage extends SimpleGui public void addReport(ReportCategory category) { - _reporter.closeInventory(); - unregisterListener(); - if (category == ReportCategory.CHAT_ABUSE) { if (hasSentMessage(_suspect.getAccountId())) @@ -106,9 +102,10 @@ public class ReportCategoryPage extends SimpleGui }); } - public void unregisterListener() + @Override + public void click(ReportCategoryButton button) { - HandlerList.unregisterAll(this); + _reporter.closeInventory(); + addReport(button.getCategory()); } - } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportHandlePage.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportHandlePage.java new file mode 100644 index 000000000..830085fa5 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportHandlePage.java @@ -0,0 +1,129 @@ +package mineplex.core.report.ui; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import java.util.logging.Level; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + +import mineplex.core.common.util.BukkitFuture; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.gui.SimpleGui; +import mineplex.core.report.ReportCategory; +import mineplex.core.report.ReportManager; +import mineplex.core.report.ReportPlugin; +import mineplex.core.report.data.Report; +import mineplex.core.report.data.ReportRepository; + +/** + * An interface which allows the user to select the type of report they'd like to handle. + */ +public class ReportHandlePage extends SimpleGui implements ReportCategoryCallback +{ + private final ReportPlugin _plugin; + private final Player _handler; + private final int _handlerId; + + public ReportHandlePage(ReportPlugin plugin, Player handler, int handlerId) + { + super(plugin.getPlugin(), handler, "Report Type Selection", 9 * 3); + + _plugin = plugin; + _handler = handler; + _handlerId = handlerId; + + buildPage(); + } + + private void buildPage() + { + setItem(11, new ReportCategoryButton(this, ReportCategory.HACKING)); + setItem(13, new ReportCategoryButton(this, ReportCategory.CHAT_ABUSE)); + setItem(15, new ReportCategoryButton(this, ReportCategory.GAMEPLAY)); + } + + @Override + public void click(ReportCategoryButton button) + { + _handler.closeInventory(); + handleReport(button.getCategory()); + } + + public void handleReport(ReportCategory category) + { + ReportManager reportManager = _plugin.getReportManager(); + ReportRepository reportRepository = reportManager.getReportRepository(); + + reportManager.isHandlingReport(_handler).whenComplete((handlingReport, throwable) -> + { + if (throwable == null) + { + if (!handlingReport) + { + Map reportPriorities = Collections.synchronizedMap(new HashMap<>()); + boolean devMode = reportManager.isDevMode(_handler.getUniqueId()); + + // the below fetches the ids of all unhandled reports and gets a Report object for each of these ids + // the priority of the report is then calculated and the results placed in a map + reportRepository.getUnhandledReports(_handlerId, category, devMode).thenCompose(reportRepository::getReports).thenAccept(reports -> + CompletableFuture.allOf(reports.stream().map(report -> + reportManager.calculatePriority(report).thenAccept(priority -> + { + if (priority > 0) + { + reportPriorities.put(report, priority); + } + else + { + // mark the report as expired to keep the database clean + // and reduce future query time + reportManager.expireReport(report); + } + } + ) + ).toArray(CompletableFuture[]::new)).join() + ).thenApply(aVoid -> + { + Map.Entry mostImportant = null; + + for (Map.Entry entry : reportPriorities.entrySet()) + { + if (mostImportant == null || (double) entry.getValue() > mostImportant.getValue()) + { + mostImportant = entry; + } + } + + return mostImportant == null ? null : mostImportant.getKey(); + }).thenCompose(BukkitFuture.accept(report -> + { + if (report != null) + { + reportManager.handleReport(report, _handler); + } + else + { + UtilPlayer.message(_handler, F.main(_plugin.getName(), "No open " + F.elem(category.getName()) + " report(s) found.")); + } + })); + } + else + { + Bukkit.getScheduler().runTask(_plugin.getPlugin(), () -> + UtilPlayer.message(_handler, F.main(_plugin.getName(), C.cRed + "You are already handling a report."))); + + } + } + else + { + UtilPlayer.message(_handler, F.main(_plugin.getName(), C.cRed + "An error occurred, please try again later.")); + _plugin.getPlugin().getLogger().log(Level.SEVERE, "Error whilst checking for reports being handled by " + _handler.getName(), throwable); + } + }); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportResultPage.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportResultPage.java index 127f78114..113e4b728 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportResultPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportResultPage.java @@ -1,8 +1,11 @@ package mineplex.core.report.ui; -import org.bukkit.entity.Player; -import org.bukkit.event.HandlerList; +import java.util.logging.Level; +import org.bukkit.entity.Player; + +import mineplex.core.common.util.BukkitFuture; +import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.gui.SimpleGui; @@ -18,15 +21,17 @@ import mineplex.core.report.data.Report; */ public class ReportResultPage extends SimpleGui { - private ReportManager _reportManager; - private Report _report; - private String _suspectName; - private String _reason; + private final ReportPlugin _plugin; + private final ReportManager _reportManager; + private final Report _report; + private final String _suspectName; + private final String _reason; - public ReportResultPage(ReportPlugin reportPlugin, Report report, Player reportCloser, String suspectName, String reason) + public ReportResultPage(ReportPlugin plugin, Report report, Player reportCloser, String suspectName, String reason) { - super(reportPlugin.getPlugin(), reportCloser, "Close Report", 9 * 4); - _reportManager = reportPlugin.getReportManager(); + super(plugin.getPlugin(), reportCloser, "Close Report", 9 * 4); + _plugin = plugin; + _reportManager = plugin.getReportManager(); _report = report; _suspectName = suspectName; _reason = reason; @@ -44,14 +49,13 @@ public class ReportResultPage extends SimpleGui setItem(11, new ReportResultButton(this, ReportResultType.ACCEPTED)); setItem(13, new ReportResultButton(this, ReportResultType.DENIED)); setItem(15, new ReportResultButton(this, ReportResultType.ABUSIVE)); - //setItem(34, ); + setItem(27, new ReportAbortButton(this)); setItem(35, new ReportAssignTeamButton(this, ReportTeam.RC)); } public void closeReport(ReportResultType result) { getPlayer().closeInventory(); - unregisterListener(); ReportResult reportResult = new ReportResult(result, _reason); _reportManager.closeReport(_report, getPlayer(), reportResult); @@ -60,7 +64,6 @@ public class ReportResultPage extends SimpleGui public void assignTeam(ReportTeam team) { getPlayer().closeInventory(); - unregisterListener(); _reportManager.assignTeam(_report, team).thenAccept(aVoid -> UtilPlayer.message(getPlayer(), @@ -68,8 +71,32 @@ public class ReportResultPage extends SimpleGui "Report forwarded to " + F.elem(team.name()) + " team"))); } - public void unregisterListener() + public void abortReport() { - HandlerList.unregisterAll(this); + getPlayer().closeInventory(); + + _reportManager.getReportHandling(getPlayer()).whenComplete(BukkitFuture.complete((reportOptional, throwable) -> + { + if (throwable == null) + { + if (reportOptional.isPresent()) + { + Report report = reportOptional.get(); + + _reportManager.abortReport(report).thenApply(BukkitFuture.accept(voidValue -> + UtilPlayer.message(getPlayer(), F.main(ReportManager.getReportPrefix(report), + "Report has been aborted and may be handled by another staff member.")))); + } + else + { + UtilPlayer.message(getPlayer(), F.main(_plugin.getName(), "You aren't currently handling a report.")); + } + } + else + { + UtilPlayer.message(getPlayer(), F.main(_plugin.getName(), C.cRed + "An error occurred, please try again later.")); + _plugin.getPlugin().getLogger().log(Level.SEVERE, "Error whilst aborting report for player " + getPlayer().getName(), throwable); + } + })); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java index 48fce2012..01e9cde68 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java @@ -5,6 +5,7 @@ import java.util.EnumMap; import java.util.List; import java.util.Random; +import org.bukkit.Material; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -131,12 +132,17 @@ import mineplex.core.mount.types.MountZombie; import mineplex.core.pet.Pet; import mineplex.core.pet.PetManager; import mineplex.core.reward.RewardPool.Type; +import mineplex.core.reward.rewards.ChestReward; +import mineplex.core.reward.rewards.GameAmplifierReward; import mineplex.core.reward.rewards.InventoryReward; import mineplex.core.reward.rewards.PetReward; import mineplex.core.reward.rewards.RankReward; +import mineplex.core.reward.rewards.RuneAmplifierReward; +import mineplex.core.reward.rewards.SpinTicketReward; import mineplex.core.reward.rewards.TreasureShardReward; import mineplex.core.reward.rewards.UnknownPackageReward; import mineplex.core.stats.StatsManager; +import mineplex.core.treasure.TreasureType; public class RewardManager { @@ -443,6 +449,14 @@ public class RewardManager addGadget(Type.HAUNTED, getGadget(DoubleJumpHalloween.class), rarity, 10); addHat(Type.HAUNTED, HatType.PUMPKIN, rarity, 10); addGadget(Type.HAUNTED, getGadget(ArrowTrailHalloween.class), rarity, 100); + + //TRICK OR TREAT + addReward(Type.TRICK_OR_TREAT, new SpinTicketReward(_clientManager, 1, 3, rarity, 150, 0)); + addReward(Type.TRICK_OR_TREAT, new GameAmplifierReward(_inventoryManager, 1, 2, rarity, 150, 0)); + addReward(Type.TRICK_OR_TREAT, new RuneAmplifierReward(_inventoryManager, 20, 1, 3, rarity, 120, 0)); + addReward(Type.TRICK_OR_TREAT, new UnknownPackageReward(_donationManager, "Clan Banner Access", "Wear/Place Clan Banner", "Clan Banner Usage", new ItemStack(Material.BANNER), rarity, 110, 0)); + addReward(Type.TRICK_OR_TREAT, new ChestReward(_inventoryManager, TreasureType.OLD, 1, 5, rarity, 150, 0)); + addReward(Type.TRICK_OR_TREAT, new ChestReward(_inventoryManager, TreasureType.ANCIENT, 1, 5, rarity, 80, 0)); } public void addLegendary() @@ -595,6 +609,13 @@ public class RewardManager addGadget(Type.HAUNTED, getGadget(MorphGrimReaper.class), rarity, 25); addGadget(Type.HAUNTED, getGadget(WinEffectHalloween.class), rarity, 50); addMount(Type.HAUNTED, getMount(MountNightmareSteed.class), rarity, 60); + + //TRICK OR TREAT + addReward(Type.TRICK_OR_TREAT, new ChestReward(_inventoryManager, TreasureType.MYTHICAL, 1, 3, rarity, 50, 0)); + addReward(Type.TRICK_OR_TREAT, new ChestReward(_inventoryManager, TreasureType.ILLUMINATED, 1, 1, rarity, 30, 0)); + addMount(Type.TRICK_OR_TREAT, getMount(MountZombie.class), rarity, 25); + addPetReward(Type.HAUNTED, EntityType.ZOMBIE, rarity, 10); + addGadget(Type.TRICK_OR_TREAT, getGadget(MorphPumpkinKing.class), rarity, 5); } public UnknownPackageReward addMount(Type type, Mount mount, RewardRarity rarity, int weight) @@ -885,7 +906,7 @@ public class RewardManager //Dont give Rank Upgrade if already has Titan if (rarity == RewardRarity.MYTHICAL) { - if (canGiveMythical && type == RewardType.MYTHICAL_CHEST && !_clientManager.Get(player).GetRank().has(Rank.TITAN)) + if (canGiveMythical && (type == RewardType.MYTHICAL_CHEST || type == RewardType.TRICK_OR_TREAT_CHEST) && !_clientManager.Get(player).GetRank().has(Rank.TITAN)) { return new RankReward(_clientManager, 0, 0, rarity); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardPool.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardPool.java index 2ccd852ab..086909b66 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardPool.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardPool.java @@ -57,6 +57,7 @@ public class RewardPool FREEDOM(false), OMEGA(false), HAUNTED(false), + TRICK_OR_TREAT(false), CARL_SPINNER(true); private boolean _useDuplicates; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardType.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardType.java index ecd9ab3a2..9c6550cb9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardType.java @@ -15,6 +15,7 @@ public enum RewardType FREEDOM_CHEST( 0, 5, 18, 0), HAUNTED_CHEST( 0, 5, 18, 0), OMEGA_CHEST( 0, 2, 16, 32), + TRICK_OR_TREAT_CHEST(0.1, 2, 16, 0), VALENTINES_GIFT( 0, 7, 20, 20), SPINNER_FILLER( 0.1, 1, 4, 20), diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/ChestReward.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/ChestReward.java new file mode 100644 index 000000000..21b038228 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/ChestReward.java @@ -0,0 +1,80 @@ +package mineplex.core.reward.rewards; + +import java.util.Random; + +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.inventory.InventoryManager; +import mineplex.core.reward.Reward; +import mineplex.core.reward.RewardData; +import mineplex.core.reward.RewardRarity; +import mineplex.core.reward.RewardType; +import mineplex.core.treasure.TreasureType; + +public class ChestReward extends Reward +{ + private Random _random; + + private InventoryManager _inventoryManager; + private int _max, _min; + private TreasureType _type; + + public ChestReward(InventoryManager inventoryManager, TreasureType type, int min, int max, RewardRarity rarity, int weight, int shardValue) + { + this(RANDOM, inventoryManager, type, min, max, rarity, weight, shardValue); + } + + public ChestReward(Random random, InventoryManager inventoryManager, TreasureType type, int min, int max, RewardRarity rarity, int weight, int shardValue) + { + super(rarity, weight, shardValue); + + _random = random; + _inventoryManager = inventoryManager; + _max = max; + _min = min; + _type = type; + } + + @Override + public RewardData giveRewardCustom(Player player, RewardType rewardType) + { + int amountToGive; + + if (_min != _max) + { + amountToGive = _random.nextInt(_max - _min) + _min; + } + else + { + amountToGive = _min; + } + + _inventoryManager.addItemToInventory(player, _type.getItemName(), amountToGive); + + return new RewardData(getRarity().getDarkColor() + "Treasure Chest", getRarity().getColor() + amountToGive + " " + ChatColor.stripColor(_type.getName()), new ItemStack(_type.getMaterial()), getRarity()); + } + + @Override + public RewardData getFakeRewardData(Player player) + { + return new RewardData(getRarity().getDarkColor() + "Treasure Chest", getRarity().getColor() + ChatColor.stripColor(_type.getName()), new ItemStack(_type.getMaterial()), getRarity()); + } + + @Override + public boolean canGiveReward(Player player) + { + return true; + } + + @Override + public boolean equals(Object obj) + { + if (obj instanceof ChestReward) + { + return ((ChestReward) obj)._type.getName().equals(_type.getName()); + } + return false; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/GameAmplifierReward.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/GameAmplifierReward.java new file mode 100644 index 000000000..cabff6482 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/GameAmplifierReward.java @@ -0,0 +1,78 @@ +package mineplex.core.reward.rewards; + +import java.util.Random; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.boosters.BoosterManager; +import mineplex.core.inventory.InventoryManager; +import mineplex.core.reward.Reward; +import mineplex.core.reward.RewardData; +import mineplex.core.reward.RewardRarity; +import mineplex.core.reward.RewardType; + +public class GameAmplifierReward extends Reward +{ + private Random _random; + + private InventoryManager _inventoryManager; + private int _max, _min; + + public GameAmplifierReward(InventoryManager inventoryManager, int min, int max, RewardRarity rarity, int weight, int shardValue) + { + this(RANDOM, inventoryManager, min, max, rarity, weight, shardValue); + } + + public GameAmplifierReward(Random random, InventoryManager inventoryManager, int min, int max, RewardRarity rarity, int weight, int shardValue) + { + super(rarity, weight, shardValue); + + _random = random; + _inventoryManager = inventoryManager; + _max = max; + _min = min; + } + + @Override + public RewardData giveRewardCustom(Player player, RewardType rewardType) + { + int amountToGive; + + if (_min != _max) + { + amountToGive = _random.nextInt(_max - _min) + _min; + } + else + { + amountToGive = _min; + } + + _inventoryManager.addItemToInventory(player, BoosterManager.BOOSTER_ITEM, amountToGive); + + return new RewardData(getRarity().getDarkColor() + "Game Amplifier", getRarity().getColor() + amountToGive + " Game Amplifier", new ItemStack(Material.EMERALD), getRarity()); + } + + @Override + public RewardData getFakeRewardData(Player player) + { + return new RewardData(getRarity().getDarkColor() + "Game Amplifier", getRarity().getColor() + "Game Amplifier", new ItemStack(Material.EMERALD), getRarity()); + } + + @Override + public boolean canGiveReward(Player player) + { + return true; + } + + @Override + public boolean equals(Object obj) + { + if (obj instanceof GameAmplifierReward) + { + return true; + } + return false; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/RankReward.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/RankReward.java index 9dcb1f070..c42b26dd1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/RankReward.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/RankReward.java @@ -34,7 +34,7 @@ public class RankReward extends Reward if (_clientManager.Get(player).GetRank() == Rank.ALL) rank = Rank.ULTRA; else if (_clientManager.Get(player).GetRank() == Rank.ULTRA) rank = Rank.HERO; else if (_clientManager.Get(player).GetRank() == Rank.HERO) rank = Rank.LEGEND; - else if (rewardType == RewardType.MYTHICAL_CHEST && _clientManager.Get(player).GetRank() == Rank.LEGEND) rank = Rank.TITAN; + else if ((rewardType == RewardType.MYTHICAL_CHEST || rewardType == RewardType.TRICK_OR_TREAT_CHEST) && _clientManager.Get(player).GetRank() == Rank.LEGEND) rank = Rank.TITAN; if (rewardType == RewardType.MYTHICAL_CHEST && _random.nextDouble() < 0.01) // 1 Percent rank = Rank.TITAN; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/RuneAmplifierReward.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/RuneAmplifierReward.java new file mode 100644 index 000000000..96ac448ee --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/RuneAmplifierReward.java @@ -0,0 +1,78 @@ +package mineplex.core.reward.rewards; + +import java.util.Random; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.inventory.InventoryManager; +import mineplex.core.reward.Reward; +import mineplex.core.reward.RewardData; +import mineplex.core.reward.RewardRarity; +import mineplex.core.reward.RewardType; + +public class RuneAmplifierReward extends Reward +{ + private Random _random; + + private InventoryManager _inventoryManager; + private int _max, _min, _minutes; + + public RuneAmplifierReward(InventoryManager inventoryManager, int minutes, int min, int max, RewardRarity rarity, int weight, int shardValue) + { + this(RANDOM, inventoryManager, minutes, min, max, rarity, weight, shardValue); + } + + public RuneAmplifierReward(Random random, InventoryManager inventoryManager, int minutes, int min, int max, RewardRarity rarity, int weight, int shardValue) + { + super(rarity, weight, shardValue); + + _random = random; + _inventoryManager = inventoryManager; + _max = max; + _min = min; + _minutes = minutes; + } + + @Override + public RewardData giveRewardCustom(Player player, RewardType rewardType) + { + int amountToGive; + + if (_min != _max) + { + amountToGive = _random.nextInt(_max - _min) + _min; + } + else + { + amountToGive = _min; + } + + _inventoryManager.addItemToInventory(player, "Rune Amplifier " + _minutes, amountToGive); + + return new RewardData(getRarity().getDarkColor() + "Rune Amplifier", getRarity().getColor() + amountToGive + " " + _minutes + " minute Amplifier", new ItemStack(Material.NETHER_STAR), getRarity()); + } + + @Override + public RewardData getFakeRewardData(Player player) + { + return new RewardData(getRarity().getDarkColor() + "Rune Amplifier", getRarity().getColor() + _minutes + " minute Amplifier", new ItemStack(Material.NETHER_STAR), getRarity()); + } + + @Override + public boolean canGiveReward(Player player) + { + return true; + } + + @Override + public boolean equals(Object obj) + { + if (obj instanceof RuneAmplifierReward) + { + return ((RuneAmplifierReward) obj)._minutes == _minutes; + } + return false; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/SpinTicketReward.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/SpinTicketReward.java new file mode 100644 index 000000000..eefa2085a --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/SpinTicketReward.java @@ -0,0 +1,122 @@ +package mineplex.core.reward.rewards; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.Statement; +import java.util.Random; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.Managers; +import mineplex.core.account.CoreClientManager; +import mineplex.core.bonuses.BonusManager; +import mineplex.core.common.util.Callback; +import mineplex.core.reward.Reward; +import mineplex.core.reward.RewardData; +import mineplex.core.reward.RewardRarity; +import mineplex.core.reward.RewardType; +import mineplex.serverdata.database.DBPool; + +public class SpinTicketReward extends Reward +{ + private Random _random; + + private CoreClientManager _clientManager; + private int _max, _min; + + public SpinTicketReward(CoreClientManager clientManager, int min, int max, RewardRarity rarity, int weight, int shardValue) + { + this(RANDOM, clientManager, min, max, rarity, weight, shardValue); + } + + public SpinTicketReward(Random random, CoreClientManager clientManager, int min, int max, RewardRarity rarity, int weight, int shardValue) + { + super(rarity, weight, shardValue); + + _random = random; + _clientManager = clientManager; + _max = max; + _min = min; + } + + @Override + public RewardData giveRewardCustom(Player player, RewardType rewardType) + { + if (_clientManager.getAccountId(player) == -1) + { + return getFakeRewardData(player); + } + + final int amountToGive; + + if (_min != _max) + { + amountToGive = _random.nextInt(_max - _min) + _min; + } + else + { + amountToGive = _min; + } + + final int accountId = _clientManager.getAccountId(player); + final Callback ticketCallback = new Callback() + { + public void run(Integer newTickets) + { + Managers.get(BonusManager.class).Get(player).setTickets(newTickets); + } + }; + _clientManager.runAsync(() -> + { + try (Connection c = DBPool.getAccount().getConnection(); Statement statement = c.createStatement()) + { + final String query = "UPDATE bonus SET tickets = tickets + " + amountToGive + " WHERE accountId = " + accountId + ";SELECT tickets FROM bonus WHERE accountId = " + accountId; + + statement.execute(query); + statement.getUpdateCount(); + statement.getMoreResults(); + + ResultSet rs = statement.getResultSet(); + if (rs.next()) + { + final int newTickets = rs.getInt(1); + _clientManager.runSync(() -> + { + ticketCallback.run(newTickets); + }); + } + } + catch (Exception e) + { + System.out.println("Failed to award ticket to player: " + player); + e.printStackTrace(); + } + }); + + return new RewardData(getRarity().getDarkColor() + "Carl Spin Ticket", getRarity().getColor() + amountToGive + " Carl Spin Ticket", new ItemStack(Material.PAPER), getRarity()); + } + + @Override + public RewardData getFakeRewardData(Player player) + { + return new RewardData(getRarity().getDarkColor() + "Carl Spin Ticket", getRarity().getColor() + "Carl Spin ticket", new ItemStack(Material.PAPER), getRarity()); + } + + @Override + public boolean canGiveReward(Player player) + { + return true; + } + + @Override + public boolean equals(Object obj) + { + if (obj instanceof SpinTicketReward) + { + return true; + } + return false; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java index 6d6094c31..8b52886cb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java @@ -5,6 +5,8 @@ import java.sql.SQLException; import java.util.Iterator; import java.util.UUID; +import mineplex.cache.player.PlayerInfo; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerJoinEvent; @@ -22,13 +24,13 @@ import mineplex.core.stats.event.StatChangeEvent; public class StatsManager extends MiniDbClientPlugin { - private static Object _statSync = new Object(); + private static final Object _statSync = new Object(); private StatsRepository _repository; private NautHashMap _stats = new NautHashMap(); - private NautHashMap> _statUploadQueue = new NautHashMap>(); - private NautHashMap> _statUploadQueueOverRidable = new NautHashMap>(); + private NautHashMap> _statUploadQueue = new NautHashMap<>(); + private NautHashMap> _statUploadQueueOverRidable = new NautHashMap<>(); private Runnable _saveRunnable; @@ -122,13 +124,13 @@ public class StatsManager extends MiniDbClientPlugin { synchronized (_statSync) { - if (!_statUploadQueueOverRidable.containsKey(player)) - _statUploadQueueOverRidable.put(player, new NautHashMap()); + if (!_statUploadQueueOverRidable.containsKey(player.getUniqueId())) + _statUploadQueueOverRidable.put(player.getUniqueId(), new NautHashMap()); - if (!_statUploadQueueOverRidable.get(player).containsKey(statName)) - _statUploadQueueOverRidable.get(player).put(statName, 0L); + if (!_statUploadQueueOverRidable.get(player.getUniqueId()).containsKey(statName)) + _statUploadQueueOverRidable.get(player.getUniqueId()).put(statName, 0L); - _statUploadQueueOverRidable.get(player).put(statName, _statUploadQueueOverRidable.get(player).get(statName) + value); + _statUploadQueueOverRidable.get(player.getUniqueId()).put(statName, _statUploadQueueOverRidable.get(player.getUniqueId()).get(statName) + value); } } @@ -143,24 +145,24 @@ public class StatsManager extends MiniDbClientPlugin synchronized (_statSync) { - for (Iterator statIterator = _statUploadQueueOverRidable.keySet().iterator(); statIterator.hasNext();) + for (Iterator statIterator = _statUploadQueueOverRidable.keySet().iterator(); statIterator.hasNext();) { - Player player = statIterator.next(); + UUID player = statIterator.next(); - if (player.isOnline()) + if (Bukkit.getPlayer(player) != null) continue; try { - int uploadKey = PlayerCache.getInstance().getPlayer(player.getUniqueId()).getAccountId(); + PlayerInfo info = PlayerCache.getInstance().getPlayer(player); - uploadQueue.put(uploadKey, new NautHashMap()); + uploadQueue.put(info.getAccountId(), new NautHashMap<>()); for (String statName : _statUploadQueueOverRidable.get(player).keySet()) { int statId = _stats.get(statName); - uploadQueue.get(uploadKey).put(statId, _statUploadQueueOverRidable.get(player).get(statName)); - System.out.println(player.getName() + " saving stat : " + statName + " overriding " + _statUploadQueueOverRidable.get(player).get(statName)); + uploadQueue.get(info.getAccountId()).put(statId, _statUploadQueueOverRidable.get(player).get(statName)); + System.out.println(info.getName() + " saving stat : " + statName + " overriding " + _statUploadQueueOverRidable.get(player).get(statName)); } statIterator.remove(); @@ -184,13 +186,13 @@ public class StatsManager extends MiniDbClientPlugin { synchronized (_statSync) { - if (!_statUploadQueue.containsKey(player)) - _statUploadQueue.put(player, new NautHashMap()); + if (!_statUploadQueue.containsKey(player.getUniqueId())) + _statUploadQueue.put(player.getUniqueId(), new NautHashMap()); - if (!_statUploadQueue.get(player).containsKey(statName)) - _statUploadQueue.get(player).put(statName, 0L); + if (!_statUploadQueue.get(player.getUniqueId()).containsKey(statName)) + _statUploadQueue.get(player.getUniqueId()).put(statName, 0L); - _statUploadQueue.get(player).put(statName, _statUploadQueue.get(player).get(statName) + value); + _statUploadQueue.get(player.getUniqueId()).put(statName, _statUploadQueue.get(player.getUniqueId()).get(statName) + value); } } @@ -205,24 +207,24 @@ public class StatsManager extends MiniDbClientPlugin synchronized (_statSync) { - for (Iterator statIterator = _statUploadQueue.keySet().iterator(); statIterator.hasNext();) + for (Iterator statIterator = _statUploadQueue.keySet().iterator(); statIterator.hasNext();) { - Player player = statIterator.next(); - - if (player.isOnline()) + UUID player = statIterator.next(); + + if (Bukkit.getPlayer(player) != null) continue; try { - int uploadKey = PlayerCache.getInstance().getPlayer(player.getUniqueId()).getAccountId(); + PlayerInfo info = PlayerCache.getInstance().getPlayer(player); - uploadQueue.put(uploadKey, new NautHashMap()); + uploadQueue.put(info.getAccountId(), new NautHashMap()); for (String statName : _statUploadQueue.get(player).keySet()) { int statId = _stats.get(statName); - uploadQueue.get(uploadKey).put(statId, _statUploadQueue.get(player).get(statName)); - System.out.println(player.getName() + " saving stat : " + statName + " adding " + _statUploadQueue.get(player).get(statName)); + uploadQueue.get(info.getAccountId()).put(statId, _statUploadQueue.get(player).get(statName)); + System.out.println(info.getName() + " saving stat : " + statName + " adding " + _statUploadQueue.get(player).get(statName)); } statIterator.remove(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/teleport/Teleport.java b/Plugins/Mineplex.Core/src/mineplex/core/teleport/Teleport.java index 0b7ba2cfa..d93abe6e9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/teleport/Teleport.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/teleport/Teleport.java @@ -25,6 +25,7 @@ import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.world.WorldUnloadEvent; import org.bukkit.plugin.java.JavaPlugin; import java.util.HashMap; @@ -117,6 +118,12 @@ public class Teleport extends MiniPlugin _tpHistory.remove(event.GetName()); } + @EventHandler + public void on(WorldUnloadEvent event) + { + _tpHistory.values().forEach(list -> list.removeIf(location -> location.getWorld() == event.getWorld())); + } + @EventHandler public void update(UpdateEvent event) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureLocation.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureLocation.java index af260b310..7bf4ec023 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureLocation.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureLocation.java @@ -2,22 +2,6 @@ package mineplex.core.treasure; import java.util.List; -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.util.*; -import mineplex.core.donation.DonationManager; -import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.event.GadgetBlockEvent; -import mineplex.core.hologram.Hologram; -import mineplex.core.hologram.HologramInteraction; -import mineplex.core.hologram.HologramManager; -import mineplex.core.inventory.InventoryManager; -import mineplex.core.reward.Reward; -import mineplex.core.status.ServerStatusManager; -import mineplex.core.treasure.event.TreasureFinishEvent; -import mineplex.core.treasure.event.TreasureStartEvent; -import mineplex.core.treasure.gui.TreasureShop; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -33,8 +17,33 @@ import org.bukkit.event.inventory.InventoryOpenEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerVelocityEvent; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.C; +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.donation.DonationManager; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.event.GadgetBlockEvent; +import mineplex.core.hologram.Hologram; +import mineplex.core.hologram.HologramInteraction; +import mineplex.core.hologram.HologramManager; +import mineplex.core.inventory.InventoryManager; +import mineplex.core.reward.Reward; +import mineplex.core.status.ServerStatusManager; +import mineplex.core.treasure.event.TreasureFinishEvent; +import mineplex.core.treasure.event.TreasureStartEvent; +import mineplex.core.treasure.gui.TreasureShop; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + public class TreasureLocation implements Listener { private TreasureManager _treasureManager; @@ -314,10 +323,9 @@ public class TreasureLocation implements Listener { Location fromLocation = event.getFrom(); Location toLocation = event.getTo(); - if (fromLocation.getWorld().equals(toLocation.getWorld())) return; + if (!fromLocation.getWorld().equals(toLocation.getWorld())) return; Location centerLocation = _currentTreasure.getCenterBlock().getLocation().add(0.5, 1.5, 0.5); double toDistanceFromCenter = centerLocation.distanceSquared(toLocation); - if (toDistanceFromCenter <= 16) { // Only cancel movement if they are moving towards the center @@ -326,13 +334,31 @@ public class TreasureLocation implements Listener { Location spawnLocation = new Location(player.getWorld(), 0, 64, 0); UtilAction.velocity(player, UtilAlg.getTrajectory(player.getLocation(), spawnLocation).multiply(-1), 1.5, true, 0.8, 0, 1.0, true); -// event.setTo(event.getFrom()); } } } } } + @EventHandler + public void cancelTeleport(PlayerTeleportEvent event) + { + Player player = event.getPlayer(); + if (isTreasureInProgress()) + { + if (_currentTreasure.getPlayer().equals(player)) + { + return; + } + double toDistanceFromCenter = _currentTreasure.getCenterBlock().getLocation().add(0.5, 1.5, 0.5).distanceSquared(event.getTo()); + if (toDistanceFromCenter <= 16) + { + Location spawnLocation = new Location(player.getWorld(), 0, 64, 0); + UtilAction.velocity(player, UtilAlg.getTrajectory(player.getLocation(), spawnLocation).multiply(-1), 1.5, true, 0.8, 0, 1.0, true); + } + } + } + @EventHandler public void cancelVelocity(PlayerVelocityEvent event) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureType.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureType.java index 3e3549344..80cfff9fd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureType.java @@ -22,7 +22,9 @@ public enum TreasureType OMEGA(C.cAqua + "Omega Chest", "Omega Chest", "Omega", RewardType.OMEGA_CHEST, Material.ENDER_CHEST, TreasureStyle.OMEGA, RewardPool.Type.OMEGA, false, 50000), - HAUNTED(C.cGold + "Haunted Chest", "Haunted Chest", "Haunted", RewardType.HAUNTED_CHEST, Material.CHEST, TreasureStyle.HALLOWEEN, RewardPool.Type.HAUNTED, true, 35000); + HAUNTED(C.cGold + "Haunted Chest", "Haunted Chest", "Haunted", RewardType.HAUNTED_CHEST, Material.CHEST, TreasureStyle.HALLOWEEN, RewardPool.Type.HAUNTED, true, 35000), + + TRICK_OR_TREAT(C.cGold + "Trick or Treat Treasure", "Trick or Treat Chest", "TrickOrTreat", RewardType.TRICK_OR_TREAT_CHEST, Material.CHEST, TreasureStyle.HALLOWEEN, RewardPool.Type.TRICK_OR_TREAT, true, 20000); private final String _name; private final RewardType _rewardType; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/BlockChangeAnimation.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/BlockChangeAnimation.java index c058974b2..5dbc7ebd4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/BlockChangeAnimation.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/BlockChangeAnimation.java @@ -2,13 +2,14 @@ package mineplex.core.treasure.animation; import java.util.List; -import mineplex.core.treasure.BlockInfo; -import mineplex.core.treasure.Treasure; -import mineplex.core.treasure.TreasureType; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import mineplex.core.treasure.BlockInfo; +import mineplex.core.treasure.Treasure; +import mineplex.core.treasure.TreasureType; + public class BlockChangeAnimation extends Animation { private static final int MAX_RADIUS = 4; @@ -75,7 +76,7 @@ public class BlockChangeAnimation extends Animation mat = Material.ENDER_STONE; data = 0; } - else if (getTreasure().getTreasureType() == TreasureType.HAUNTED) + else if (getTreasure().getTreasureType() == TreasureType.HAUNTED || getTreasure().getTreasureType() == TreasureType.TRICK_OR_TREAT) { mat = Material.WOOL; data = 1; @@ -112,7 +113,7 @@ public class BlockChangeAnimation extends Animation mat = Material.ENDER_STONE; data = 0; } - else if (getTreasure().getTreasureType() == TreasureType.HAUNTED) + else if (getTreasure().getTreasureType() == TreasureType.HAUNTED || getTreasure().getTreasureType() == TreasureType.TRICK_OR_TREAT) { mat = Material.WOOL; data = 15; @@ -161,6 +162,18 @@ public class BlockChangeAnimation extends Animation } } } + else if (getTreasure().getTreasureType() == TreasureType.TRICK_OR_TREAT) + { + for (Block c : _chests) + { + if (c.equals(b)) + { + _blockInfoList.add(new BlockInfo(b)); + b.setType(Material.CAULDRON); + b.setData((byte)3); + } + } + } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ChestOpenAnimation.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ChestOpenAnimation.java index 6b723e8f2..8e65a6da1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ChestOpenAnimation.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ChestOpenAnimation.java @@ -1,6 +1,5 @@ package mineplex.core.treasure.animation; -import mineplex.core.common.util.banner.CountryFlag; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -19,13 +18,14 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.hologram.Hologram; import mineplex.core.hologram.HologramManager; +import mineplex.core.reward.RankRewardData; import mineplex.core.reward.RewardData; import mineplex.core.treasure.ChestData; import mineplex.core.treasure.Treasure; +import mineplex.core.treasure.TreasureType; import net.minecraft.server.v1_8_R3.BlockPosition; import net.minecraft.server.v1_8_R3.PacketPlayOutBlockAction; import net.minecraft.server.v1_8_R3.TileEntity; -import net.minecraft.server.v1_8_R3.TileEntityChest; import net.minecraft.server.v1_8_R3.TileEntityEnderChest; /** @@ -47,6 +47,15 @@ public class ChestOpenAnimation extends Animation _chestData = chestData; _rewardData = rewardData; + if (treasure.getTreasureType() == TreasureType.TRICK_OR_TREAT && rewardData instanceof RankRewardData) + { + Block block = chestData.getBlock(); + for (Player other : UtilServer.getPlayers()) + { + other.sendBlockChange(block.getLocation(), Material.DRAGON_EGG, (byte)0); + } + return; + } // Send chest open packet Block block = chestData.getBlock(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ChestSpawnAnimation.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ChestSpawnAnimation.java index eff9e7d70..2b17df518 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ChestSpawnAnimation.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ChestSpawnAnimation.java @@ -2,23 +2,37 @@ package mineplex.core.treasure.animation; import java.util.List; -import mineplex.core.common.util.*; +import org.bukkit.Color; +import org.bukkit.Location; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.EntityType; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.util.Vector; + +import com.google.common.collect.Lists; + +import mineplex.core.Managers; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.particles.ColoredParticle; import mineplex.core.common.util.particles.DustSpellColor; +import mineplex.core.disguise.DisguiseManager; +import mineplex.core.disguise.disguises.DisguiseBat; import mineplex.core.gadget.gadgets.particle.unrelated.BabyFireworkEffect; import mineplex.core.treasure.BlockInfo; import mineplex.core.treasure.Treasure; import mineplex.core.treasure.TreasureType; import net.minecraft.server.v1_8_R3.BlockPosition; import net.minecraft.server.v1_8_R3.MathHelper; -import org.bukkit.Color; -import org.bukkit.Location; -import org.bukkit.block.Block; -import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; -import org.bukkit.plugin.java.JavaPlugin; -import org.bukkit.util.Vector; /** * Created by Shaun on 8/29/2014. @@ -43,6 +57,8 @@ public class ChestSpawnAnimation extends Animation private int _circleAmount = 0; private int _currentHauntedColor = 0; + + private List _bats = Lists.newArrayList(); public ChestSpawnAnimation(Treasure treasure, Block block, List chestBlockInfo, Block openingCenter, double radialOffset, JavaPlugin javaPlugin) { @@ -73,6 +89,17 @@ public class ChestSpawnAnimation extends Animation _particleDirection = UtilAlg.getTrajectory(_particleLocation, _centerLocation); _particleDirection.multiply(UtilMath.offset(_particleLocation, _centerLocation) / (double)ANIMATION_DURATION); + if (treasure.getTreasureType() == TreasureType.TRICK_OR_TREAT) + { + for (int i = 0; i < 5; i++) + { + ArmorStand stand = (ArmorStand)_centerLocation.getWorld().spawnEntity(_centerLocation, EntityType.ARMOR_STAND); + stand.setGravity(false); + stand.setVisible(false); + _bats.add(stand); + } + doBats(true, _centerLocation.clone().add(0, 6, 0), _bats); + } _radialOffset = radialOffset; @@ -176,7 +203,7 @@ public class ChestSpawnAnimation extends Animation _circleAmount++; } - else if (getTreasure().getTreasureType() == TreasureType.HAUNTED) + else if (getTreasure().getTreasureType() == TreasureType.HAUNTED || getTreasure().getTreasureType() == TreasureType.TRICK_OR_TREAT) { float x = (float) (Math.sin(getTicks()/4D)); float z = (float) (Math.cos(getTicks()/4D)); @@ -196,6 +223,11 @@ public class ChestSpawnAnimation extends Animation { _currentHauntedColor = 0; } + + if (getTreasure().getTreasureType() == TreasureType.TRICK_OR_TREAT) + { + doBats(true, _centerLocation.clone().add(0, 6, 0), _bats); + } } //Spawn Chest @@ -217,7 +249,12 @@ public class ChestSpawnAnimation extends Animation UtilParticle.PlayParticle(getTreasure().getTreasureType().getStyle().getSecondaryParticle(), loc, 0.7f, 0.7f, 0.7f, 1, 50, ViewDist.NORMAL, UtilServer.getPlayers()); } - + + if (getTreasure().getTreasureType() == TreasureType.TRICK_OR_TREAT) + { + _bats.forEach(bat -> bat.remove()); + _bats.clear(); + } UtilParticle.ParticleType particleType = getTreasure().getTreasureType().getStyle().getChestSpawnParticle(); @@ -262,4 +299,36 @@ public class ChestSpawnAnimation extends Animation { } + + private void doBats(boolean initial, Location center, List bats) + { + for (int i = 0; i < bats.size(); i++) + { + ArmorStand bat = bats.get(i); + double lead = i * ((2d * Math.PI)/bats.size()); + + double sizeMod = 2; + + //Orbit + double speed = 10d; + double oX = -Math.sin(getTicks()/speed + lead) * 2 * sizeMod; + double oY = 0; + double oZ = Math.cos(getTicks()/speed + lead) * 2 * sizeMod; + + if (initial) + { + DisguiseManager disguiseMan = Managers.get(DisguiseManager.class); + DisguiseBat disguise = new DisguiseBat(bat); + disguise.setSitting(false); + disguiseMan.disguise(disguise); + bat.teleport(center.clone().add(oX, oY, oZ)); + } + else + { + Location to = center.clone().add(oX, oY, oZ); + UtilEnt.LookAt(bat, to); + UtilAction.velocity(bat, UtilAlg.getTrajectory(bat.getLocation(), to), 0.4, false, 0, 0.1, 1, true); + } + } + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java index 9256bc7a0..8194799c8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java @@ -1,5 +1,11 @@ package mineplex.core.treasure.gui; +import java.io.File; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.F; import mineplex.core.inventory.InventoryManager; @@ -10,28 +16,25 @@ import mineplex.core.shop.item.SalesPackageBase; import mineplex.core.shop.item.SalesPackageProcessor; import mineplex.core.treasure.ChestPackage; import mineplex.core.treasure.TreasureType; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; public class BuyChestButton implements IButton { private InventoryManager _inventoryManager; private TreasurePage _page; - + private String _chestName; private Material _chestMat; private int _chestCost; private TreasureType _chestType; - + public BuyChestButton(InventoryManager inventoryManager, TreasurePage page, String chestName, Material chestMat, int chestCost, TreasureType chestType) { _inventoryManager = inventoryManager; _page = page; - + _chestName = chestName; _chestMat = chestMat; _chestCost = chestCost; @@ -45,7 +48,15 @@ public class BuyChestButton implements IButton { return; } - + + if (_chestType == TreasureType.TRICK_OR_TREAT) + { + if (!new File("../../update/files/EnableTrickOrTreat.dat").exists()) + { + player.sendMessage(F.main("Treasure", "That chest is no longer available for purchase!")); + return; + } + } if (_chestType == TreasureType.FREEDOM) { if (!_page.getPlugin().hasItemsToGivePlayer(_chestType.getRewardPool(), player)) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java index ca64c99c2..9121bc794 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java @@ -8,6 +8,8 @@ import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import com.google.common.collect.Lists; + import mineplex.core.account.CoreClientManager; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.skin.SkinData; @@ -60,6 +62,7 @@ public class TreasurePage extends ShopPageBase int freedomCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.FREEDOM.getItemName()); int omegaCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.OMEGA.getItemName()); int hauntedCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.HAUNTED.getItemName()); + int trickCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.TRICK_OR_TREAT.getItemName()); List shardLore = new ArrayList<>(); shardLore.add(" "); @@ -211,6 +214,25 @@ public class TreasurePage extends ShopPageBase hauntedLore.add(" "); hauntedLore.add(ChatColor.RESET + "or Purchase at: " + C.cYellow + "www.mineplex.com/shop"); } + + List trickLore = Lists.newArrayList(); + trickLore.add(" "); + trickLore.add(F.value("Trick or Treat Chests Owned", "" + trickCount)); + trickLore.add(" "); + trickLore.add(C.cGray + "The Trick or Treat Chest contains all"); + trickLore.add(C.cGray + "sorts of surprises, from Rank Upgrades to"); + trickLore.add(C.cGray + "long lost Halloween items, and even other chests!"); + trickLore.add(" "); + if (trickCount > 0) + { + trickLore.add(ChatColor.RESET + C.cGreen + "Click to Open!"); + } + else + { + trickLore.add(ChatColor.RESET + "Click to craft for " + C.cAqua + "20000 Treasure Shards"); + trickLore.add(" "); + hauntedLore.add(ChatColor.RESET + "or Purchase at: " + C.cYellow + "www.mineplex.com/shop"); + } ShopItem shards = new ShopItem(Material.PRISMARINE_SHARD, C.cAqua + C.Bold + treasureShards + " Treasure Shards", shardLore.toArray(new String[0]), 0, false); ShopItem basic = new ShopItem(Material.CHEST, C.cGreen + C.Bold + "Old Treasure", basicLore.toArray(new String[0]), 0, false, false); @@ -221,9 +243,11 @@ public class TreasurePage extends ShopPageBase ItemStack freedom = SkinData.FREEDOM_CHEST.getSkull(C.cRedB + "Freedom " + C.cBlueB + "Treasure", freedomLore); ItemStack omega = SkinData.OMEGA_CHEST.getSkull(C.cAquaB + "Omega Treasure", omegaLore); ItemStack haunted = SkinData.HAUNTED_CHEST.getSkull(C.cGoldB + "Haunted Treasure", hauntedLore); + ItemStack trick = new ShopItem(Material.SKULL_ITEM, C.cGoldB + "Trick or Treat Treasure", trickLore.toArray(new String[0]), 0, false, false); addItem(49, shards); + addChest(4, trick, TreasureType.TRICK_OR_TREAT, trickCount); addChest(10, christmas, TreasureType.CHRISTMAS, christmasCount); addChest(12, freedom, TreasureType.FREEDOM, freedomCount); addChest(14, haunted, TreasureType.HAUNTED, hauntedCount); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java index 7956c676a..5ff84a246 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java @@ -65,6 +65,7 @@ import org.bukkit.Material; import org.bukkit.World; import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; import org.bukkit.plugin.java.JavaPlugin; +import org.spigotmc.SpigotConfig; import static mineplex.core.Managers.require; @@ -265,7 +266,8 @@ public class Clans extends JavaPlugin //Updates new Updater(this); - MinecraftServer.getServer().getPropertyManager().setProperty("debug", true); + MinecraftServer.getServer().getPropertyManager().setProperty("debug", false); + SpigotConfig.debug = false; } public static String prettifyName(Material material) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java index c7dbf9104..e1bf068c2 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java @@ -29,6 +29,7 @@ import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.event.inventory.InventoryPickupItemEvent; import org.bukkit.event.player.PlayerBucketEmptyEvent; +import org.bukkit.event.player.PlayerBucketFillEvent; import org.bukkit.event.player.PlayerFishEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerPickupItemEvent; @@ -229,15 +230,18 @@ public class ClansGame extends MiniPlugin } } + @SuppressWarnings("deprecation") @EventHandler - public void onPlayerFillBucket(PlayerInteractEvent event) + public void onPlayerFillBucket(PlayerBucketFillEvent event) { - ItemStack itemInHand = event.getPlayer().getItemInHand(); - - if (UtilItem.matchesMaterial(itemInHand, Material.BUCKET) && UtilEvent.isAction(event, ActionType.R)) + event.setCancelled(true); + UtilPlayer.message(event.getPlayer(), F.main("Clans", "You cannot fill buckets!")); + _clans.runSyncLater(() -> { - event.setCancelled(true); - } + event.getPlayer().updateInventory(); + Block block = event.getBlockClicked().getRelative(event.getBlockFace()); + event.getPlayer().sendBlockChange(block.getLocation(), block.getType(), block.getData()); + }, 1L); } @EventHandler 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 df5d6e2cb..2c7a971f1 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 @@ -86,8 +86,6 @@ public class Gameplay extends MiniPlugin private WeightSet _foodDecrease; // Weighted probability sets for // food decrease event outcomes - private Map _bucketWater = new HashMap(); - public Gameplay(JavaPlugin plugin, ClansManager clansManager, BlockRestore blockRestore, DamageManager damageManager) { super("PvP Gameplay", plugin); @@ -179,29 +177,6 @@ public class Gameplay extends MiniPlugin } } } - @EventHandler - public void BucketEmpty(PlayerBucketEmptyEvent event) - { - event.setCancelled(true); - - Block block = event.getBlockClicked().getRelative(event.getBlockFace()); - - if (event.getBucket() == Material.WATER_BUCKET) - { - block.setTypeIdAndData(8, (byte) 1, true); - _blockRestore.add(event.getBlockClicked().getRelative(event.getBlockFace()), 8, (byte) 0, 1000); - _bucketWater.put(block, System.currentTimeMillis()); - } - - if (event.getBucket() == Material.LAVA_BUCKET) - { - block.setTypeIdAndData(10, (byte) 6, true); - _blockRestore.add(event.getBlockClicked().getRelative(event.getBlockFace()), 10, (byte) 0, 2000); - } - - event.getPlayer().setItemInHand(ItemStackFactory.Instance.CreateStack(Material.BUCKET)); - UtilInv.Update(event.getPlayer()); - } /** * Decreases the hunger rate decrease speed by arbitrarily canceling a @@ -222,30 +197,6 @@ public class Gameplay extends MiniPlugin } } - @EventHandler - public void BucketFill(PlayerBucketFillEvent event) - { - event.setCancelled(true); - - if (event.getItemStack().getType() == Material.WATER_BUCKET) if (!_bucketWater.containsKey(event.getBlockClicked())) event.getPlayer().setItemInHand(ItemStackFactory.Instance.CreateStack(Material.WATER_BUCKET)); - - UtilInv.Update(event.getPlayer()); - } - - @EventHandler - public void BucketWaterExpire(UpdateEvent event) - { - if (event.getType() != UpdateType.FAST) return; - - HashSet remove = new HashSet(); - - for (Block cur : _bucketWater.keySet()) - if (UtilTime.elapsed(_bucketWater.get(cur).longValue(), 2000)) remove.add(cur); - - for (Block cur : remove) - _bucketWater.remove(cur); - } - @EventHandler(priority = EventPriority.LOWEST) public void ObsidianCancel(BlockPlaceEvent event) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/rares/RunedPickaxe.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/rares/RunedPickaxe.java index 8905742d1..9072d0dfe 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/rares/RunedPickaxe.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/rares/RunedPickaxe.java @@ -87,12 +87,15 @@ public class RunedPickaxe extends RareItem if (territory != null && !territory.Owner.equals(playerClan)) return; - if (event.getBlock().getType() == Material.BEDROCK) + if (event.getBlock().getType() == Material.BEDROCK || event.getBlock().getType() == Material.BARRIER) return; if (ClansManager.getInstance().getNetherManager().getNetherWorld().equals(event.getBlock().getWorld())) return; + if (ClansManager.getInstance().getBlockRestore().contains(event.getBlock())) + return; + if (!UtilTime.elapsed(pick._instamineEnabled, 12000)) { event.getBlock().breakNaturally(); diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/GameType.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/GameType.java index 006d485b0..1f4262d28 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/GameType.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/GameType.java @@ -31,6 +31,7 @@ public enum GameType Gladiators("Gladiators"), Gravity("Gravity"), Halloween("Halloween Horror"), + Halloween2016("Halloween Horror 2016"), HideSeek("Block Hunt"), Horse("Horseback"), Lobbers("Bomb Lobbers"), diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapData.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapData.java index a87e4e8b9..978d282e6 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapData.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapData.java @@ -72,7 +72,7 @@ public class MapData continue; } - if(tokens[0].equalsIgnoreCase("locked")) + if(tokens[0].equalsIgnoreCase("LOCKED")) { _locked = tokens[1].equalsIgnoreCase("true"); continue; @@ -159,6 +159,8 @@ public class MapData out.write("currentlyLive:" + _currentlyLive); out.write("\n"); out.write("warps:" + warpsToString()); + out.write("\n"); + out.write("LOCKED:" + _locked); out.close(); } catch (Exception e) diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapParser.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapParser.java index 9105e8ea6..6fa838da5 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapParser.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapParser.java @@ -1,8 +1,26 @@ package mineplex.mapparser; +import java.io.File; +import java.io.IOException; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.block.Block; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; + import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; + import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilBlock; @@ -30,6 +48,7 @@ import mineplex.mapparser.command.PMCommand; import mineplex.mapparser.command.ParseCommand200; import mineplex.mapparser.command.ParseCommand400; import mineplex.mapparser.command.ParseCommand600; +import mineplex.mapparser.command.ParseCommand1000; import mineplex.mapparser.command.PlayerHeadCommand; import mineplex.mapparser.command.RefreshWorldEditCommand; import mineplex.mapparser.command.RenameCommand; @@ -44,22 +63,6 @@ import mineplex.mapparser.module.modules.EventModule; import mineplex.mapparser.module.modules.MMMazeModule; import mineplex.mapparser.module.modules.SignModule; import mineplex.mapparser.module.modules.TreeToolModule; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.block.Block; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.entity.Player; -import org.bukkit.plugin.java.JavaPlugin; - -import java.io.File; -import java.io.IOException; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; public class MapParser extends JavaPlugin { @@ -104,6 +107,7 @@ public class MapParser extends JavaPlugin commandModule.add(new ParseCommand200(this)); commandModule.add(new ParseCommand400(this)); commandModule.add(new ParseCommand600(this)); + commandModule.add(new ParseCommand1000(this)); commandModule.add(new RenameCommand(this)); commandModule.add(new SaveCommand(this)); commandModule.add(new WorldsCommand(this)); diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/AdminCommand.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/AdminCommand.java index ad52b7f98..962a5813a 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/AdminCommand.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/AdminCommand.java @@ -29,7 +29,7 @@ public class AdminCommand extends BaseCommand World world = player.getWorld(); - if (world.getName().equals("world")) + if (world.getName().equals("world_lobby")) { message(player, "Cannot change Admin-List for Lobby."); return true; diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/AuthorCommand.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/AuthorCommand.java index c267e7d4d..48a23c693 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/AuthorCommand.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/AuthorCommand.java @@ -33,7 +33,7 @@ public class AuthorCommand extends BaseCommand authorName += arg + " "; authorName = authorName.trim(); - if (world.getName().equals("world")) + if (world.getName().equals("world_lobby")) { message(player, "Cannot set author for Lobby."); return true; diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/CurrentlyLiveCommand.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/CurrentlyLiveCommand.java index 7244346b9..746945b23 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/CurrentlyLiveCommand.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/CurrentlyLiveCommand.java @@ -19,6 +19,11 @@ public class CurrentlyLiveCommand extends BaseCommand @Override public boolean execute(Player player, String alias, String[] args) { + if (player.getWorld().getName().equals("world_lobby")) + { + message(player, "Cannot set live status for Lobby."); + return true; + } MapData data = getPlugin().getData(player.getWorld().getName()); if(data == null) diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/GameTypeCommand.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/GameTypeCommand.java index edf2482a9..4b01a03c9 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/GameTypeCommand.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/GameTypeCommand.java @@ -32,7 +32,7 @@ public class GameTypeCommand extends BaseCommand return true; } - if (world.getName().equals("world")) + if (world.getName().equals("world_lobby")) { message(player, "Cannot set GameType for Lobby."); return true; diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/LockCommand.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/LockCommand.java index a8dd0082d..9af13bbea 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/LockCommand.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/LockCommand.java @@ -20,16 +20,27 @@ public class LockCommand extends BaseCommand @Override public boolean execute(Player player, String alias, String[] args) { + if (!player.isOp()) + { + message(player, "Only OPs can toggle map locks!"); + return true; + } + if (player.getWorld().getName().equals("world_lobby")) + { + message(player, "Cannot toggle lock for Lobby."); + return true; + } MapData data = getPlugin().getData(player.getWorld().getName()); - if(data == null) + if (data == null) { player.sendMessage(C.cRed + "There was an error with your map."); return true; } data._locked = !data._locked; - player.sendMessage(F.tf(data._locked) + " lock for world " + player.getWorld().getName()); + data.Write(); + message(player, "Lock for world " + F.elem(player.getWorld().getName()) + ": " + F.tf(data._locked)); return true; } } diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/NameCommand.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/NameCommand.java index a7988c3ff..5e63f92a5 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/NameCommand.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/NameCommand.java @@ -29,7 +29,7 @@ public class NameCommand extends BaseCommand return true; } - if (world.equals("world")) + if (world.getName().equals("world_lobby")) { message(player, "Cannot set name for Lobby."); return true; diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/PMCommand.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/PMCommand.java index 82a72b071..86c4db4f2 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/PMCommand.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/PMCommand.java @@ -20,26 +20,27 @@ public class PMCommand extends BaseCommand @Override public boolean execute(Player player, String alias, String[] args) { - if(!player.isOp()) + if (!player.isOp()) { player.sendMessage(C.cRed + "You are not allowed to do that!"); return true; } - if(args.length == 0) + if (args.length == 0) { player.sendMessage(C.cRed + "Please put a message in!"); return true; } StringBuilder builder = new StringBuilder(); - for(String s : args) + builder.append(player.getName() + ": "); + for (String s : args) { builder.append(s).append(" "); } - for(Player ops : UtilServer.getPlayers()) + for (Player ops : UtilServer.getPlayers()) { - if(!ops.isOp()) + if (!ops.isOp()) { continue; } @@ -49,4 +50,4 @@ public class PMCommand extends BaseCommand return true; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/ParseCommand1000.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/ParseCommand1000.java new file mode 100644 index 000000000..8cfb3d5f3 --- /dev/null +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/ParseCommand1000.java @@ -0,0 +1,70 @@ +package mineplex.mapparser.command; + +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.entity.Player; + +import mineplex.core.common.util.F; +import mineplex.mapparser.MapData; +import mineplex.mapparser.MapParser; +import mineplex.mapparser.Parse; + +/** + * Larger parse command + */ +public class ParseCommand1000 extends BaseCommand +{ + public ParseCommand1000(MapParser plugin) + { + super(plugin, "parse1000"); + } + + @Override + public boolean execute(Player player, String alias, String[] args) + { + if (!player.isOp()) + { + message(player, "Only OPs can parse maps!"); + return true; + } + + Location parseLoc = player.getLocation(); + + World world = parseLoc.getWorld(); + + if (world.getName().equals("world_lobby")) + { + message(player, "Cannot parse Lobby."); + return true; + } + + MapData data = getPlugin().getData(world.getName()); + + if (data.MapName.equals("null") || data.MapCreator.equals("null") || data.MapGameType.equals("null")) + { + message(player, "Map Name/Author/GameType are not set!"); + return true; + } + + //Teleport Players Out + for (Player worldPlayer : world.getPlayers()) + { + worldPlayer.teleport(getPlugin().getSpawnLocation()); + message(player, "World " + F.elem(world.getName()) + " is preparing to be parsed."); + } + + //Unload World > Copy + World parseableWorld = getPlugin().getWorldManager().prepMapParse(world); + + if (parseableWorld == null) + { + message(player, "Could not prepare world for parsing!"); + return true; + } + + //Parse the World + getPlugin().setCurrentParse(new Parse(getPlugin(), parseableWorld, args, parseLoc, getPlugin().getData(parseLoc.getWorld().getName()), 1000)); + + return true; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/ParseCommand200.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/ParseCommand200.java index 9cd58144b..7ac10132c 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/ParseCommand200.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/ParseCommand200.java @@ -31,6 +31,12 @@ public class ParseCommand200 extends BaseCommand Location parseLoc = player.getLocation(); World world = parseLoc.getWorld(); + + if (world.getName().equals("world_lobby")) + { + message(player, "Cannot parse Lobby."); + return true; + } MapData data = getPlugin().getData(world.getName()); diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/ParseCommand400.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/ParseCommand400.java index d08d60103..efb416dc5 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/ParseCommand400.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/ParseCommand400.java @@ -31,6 +31,12 @@ public class ParseCommand400 extends BaseCommand Location parseLoc = player.getLocation(); World world = parseLoc.getWorld(); + + if (world.getName().equals("world_lobby")) + { + message(player, "Cannot parse Lobby."); + return true; + } MapData data = getPlugin().getData(world.getName()); diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/ParseCommand600.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/ParseCommand600.java index daa28b4fa..07dd1deb2 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/ParseCommand600.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/ParseCommand600.java @@ -31,6 +31,12 @@ public class ParseCommand600 extends BaseCommand Location parseLoc = player.getLocation(); World world = parseLoc.getWorld(); + + if (world.getName().equals("world_lobby")) + { + message(player, "Cannot parse Lobby."); + return true; + } MapData data = getPlugin().getData(world.getName()); diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/RenameCommand.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/RenameCommand.java index b2e539bb4..2f66500c2 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/RenameCommand.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/RenameCommand.java @@ -24,6 +24,13 @@ public class RenameCommand extends BaseCommand public boolean execute(Player player, String alias, String[] args) { World world = player.getWorld(); + + if (world.getName().equals("world_lobby")) + { + message(player, "Cannot rename Lobby."); + return true; + } + MapData data = getPlugin().getData(world.getName()); if (data == null) diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/WarpCommand.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/WarpCommand.java index dd533e4d8..ca99aa881 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/WarpCommand.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/WarpCommand.java @@ -25,6 +25,11 @@ public class WarpCommand extends BaseCommand @Override public boolean execute(Player player, String alias, String[] args) { + if (player.getWorld().getName().equals("world_lobby")) + { + message(player, "Cannot use warps in Lobby."); + return true; + } MapData data = getPlugin().getData(player.getWorld().getName()); if(data == null) diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/module/modules/EventModule.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/module/modules/EventModule.java index 3f62f9337..1595b9886 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/module/modules/EventModule.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/module/modules/EventModule.java @@ -1,19 +1,8 @@ package mineplex.mapparser.module.modules; -import com.google.common.collect.Lists; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.MapUtil; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.mapparser.BackupTask; -import mineplex.mapparser.MapData; -import mineplex.mapparser.MapParser; -import mineplex.mapparser.Parse; -import mineplex.mapparser.TickEvent; -import mineplex.mapparser.module.Module; +import java.util.List; + import org.bukkit.ChatColor; -import org.bukkit.Sound; import org.bukkit.World; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; @@ -32,8 +21,21 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.weather.WeatherChangeEvent; -import java.util.List; +import com.google.common.collect.Lists; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.MapUtil; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.mapparser.BackupTask; +import mineplex.mapparser.MapData; +import mineplex.mapparser.MapParser; +import mineplex.mapparser.Parse; +import mineplex.mapparser.TickEvent; +import mineplex.mapparser.module.Module; /** * @@ -70,13 +72,14 @@ public class EventModule extends Module if (world.getName().toLowerCase().contains("halloween")) { world.setTime(16000); - } else + } + else { world.setTime(8000); } - _updated.add(world); world.setStorm(false); world.setGameRuleValue("doDaylightCycle", "false"); + _updated.add(world); } } @@ -114,7 +117,7 @@ public class EventModule extends Module { for (World world : getPlugin().getServer().getWorlds()) { - if (world.getName().equalsIgnoreCase("world")) + if (world.getName().equalsIgnoreCase("world_lobby")) { continue; } @@ -212,11 +215,14 @@ public class EventModule extends Module Player target = UtilPlayer.searchOnline(player, tokens[1], true); if (target != null) { - MapData data = getPlugin().getData(target.getWorld().getName()); - if(!data.CanJoin(player)) + if (!target.getWorld().getName().equals("world")) { - player.sendMessage(C.cRed + "That server is currently locked, and you don't have access to it."); - return; + MapData data = getPlugin().getData(target.getWorld().getName()); + if(!data.CanJoin(player)) + { + player.sendMessage(C.cRed + "That world is currently locked, and you don't have access to it."); + return; + } } UtilPlayer.message(player, F.main("Game", "You teleported to " + F.name(target.getName()) + ".")); player.teleport(target); @@ -287,13 +293,6 @@ public class EventModule extends Module @EventHandler public void Join(PlayerJoinEvent event) { - Player player = event.getPlayer(); - if (player.getName().equalsIgnoreCase("TadahTech")) - { - event.setJoinMessage(C.cGreenB + "Your build server Saviour, TIMOTHY! has arrived, please take a moment to thank him."); - getPlugin().getServer().getOnlinePlayers().forEach(o -> o.playSound(o.getLocation(), Sound.AMBIENCE_THUNDER, 1.0F, 1.0F)); - return; - } event.setJoinMessage(F.sys("Player Join", event.getPlayer().getName())); } @@ -351,4 +350,15 @@ public class EventModule extends Module { event.setCancelled(true); } + + @EventHandler + public void DisableWeather(WeatherChangeEvent event) + { + if (!_updated.contains(event.getWorld())) + { + return; + } + + event.setCancelled(true); + } } diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatManager.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatManager.java index 24a848c3e..b6591802f 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatManager.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatManager.java @@ -6,6 +6,7 @@ import java.util.Iterator; import java.util.Map; import java.util.UUID; +import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; import org.bukkit.entity.Arrow; @@ -46,10 +47,10 @@ public class CombatManager extends MiniPlugin DefaultWeaponName } - private NautHashMap _active = new NautHashMap(); + private NautHashMap _active = new NautHashMap<>(); private Map _combatClients = new HashMap<>(); - private HashSet _removeList = new HashSet(); + private HashSet _removeList = new HashSet<>(); protected long ExpireTime = 15000; @@ -63,7 +64,7 @@ public class CombatManager extends MiniPlugin @EventHandler public void UnloadDonor(ClientUnloadEvent event) { - _combatClients.remove(event.GetName()); + _combatClients.remove(event.getUniqueId()); } public ClientCombat Get(UUID uuid) @@ -419,10 +420,10 @@ public class CombatManager extends MiniPlugin { event.setDeathMessage(null); - if (!_active.containsKey(event.getEntity())) + if (!_active.containsKey(event.getEntity().getUniqueId())) return; - CombatLog log = _active.remove(event.getEntity()); + CombatLog log = _active.remove(event.getEntity().getUniqueId()); log.SetDeathTime(System.currentTimeMillis()); // Save Death @@ -592,24 +593,24 @@ public class CombatManager extends MiniPlugin public void Add(Player player) { - _active.put(player, new CombatLog(player, 15000)); + _active.put(player.getUniqueId(), new CombatLog(player, 15000)); } @EventHandler(priority = EventPriority.HIGHEST) public void Clear(ClearCombatEvent event) { - _active.remove(event.GetPlayer()); + _active.remove(event.GetPlayer().getUniqueId()); } public CombatLog Get(Player player) { - if (!_active.containsKey(player)) + if (!_active.containsKey(player.getUniqueId())) { Add(player); } - return _active.get(player); + return _active.get(player.getUniqueId()); } public long GetExpireTime() @@ -623,44 +624,27 @@ public class CombatManager extends MiniPlugin if (event.getType() == UpdateType.MIN_02) { // Remove already marked inactives if still offline - Iterator removeIterator = _removeList.iterator(); + Iterator removeIterator = _removeList.iterator(); while (removeIterator.hasNext()) { - Player player = removeIterator.next(); + UUID uuid = removeIterator.next(); + Player player = Bukkit.getPlayer(uuid); - if (!player.isOnline()) - _active.remove(player); + if (player == null) + _active.remove(uuid); removeIterator.remove(); } // Mark inactives for cleanup next go around - for (Player player : _active.keySet()) + for (UUID player : _active.keySet()) { - if (!player.isOnline()) + if (Bukkit.getPlayer(player) == null) _removeList.add(player); } } } - - public void DebugInfo(Player player) - { - StringBuilder nameBuilder = new StringBuilder(); - - for (Player combats : _active.keySet()) - { - if (!combats.isOnline()) - { - if (nameBuilder.length() != 0) - nameBuilder.append(", "); - - nameBuilder.append(combats.getName()); - } - } - - player.sendMessage(F.main(getName(), nameBuilder.toString())); - } public void setUseWeaponName(AttackReason var) { diff --git a/Plugins/Mineplex.ReportSite/report.php b/Plugins/Mineplex.ReportSite/report.php index fe1b1a216..c38325d2a 100644 --- a/Plugins/Mineplex.ReportSite/report.php +++ b/Plugins/Mineplex.ReportSite/report.php @@ -15,9 +15,6 @@ /** @var Int */ private $category; - /** @var Snapshot */ - private $snapshot; - /** * Report constructor. * @param Int $id @@ -25,16 +22,14 @@ * @param User $suspect * @param UserReport[] $reporters * @param Int $category - * @param Snapshot $snapshot */ - function __construct($id, $handler, $suspect, $reporters, $category, $snapshot) + function __construct($id, $handler, $suspect, $reporters, $category) { $this->id = $id; $this->handler = $handler; $this->suspect = $suspect; $this->reporters = $reporters; $this->category = $category; - $this->snapshot = $snapshot; } /** @@ -103,12 +98,4 @@ { return $this->category; } - - /** - * @return Snapshot - */ - public function getSnapshot() - { - return $this->snapshot; - } } \ No newline at end of file diff --git a/Plugins/Mineplex.ReportSite/sql/snapshot-tokens.sql b/Plugins/Mineplex.ReportSite/sql/snapshot-tokens.sql new file mode 100644 index 000000000..d0522a91c --- /dev/null +++ b/Plugins/Mineplex.ReportSite/sql/snapshot-tokens.sql @@ -0,0 +1,4 @@ +ALTER TABLE Account.snapshots ADD token CHAR(8); +CREATE UNIQUE INDEX snapshots_token_uindex ON snapshots (token); +ALTER TABLE Account.snapshots + MODIFY COLUMN creator INT(11) AFTER token; \ No newline at end of file diff --git a/Plugins/Mineplex.ReportSite/view.php b/Plugins/Mineplex.ReportSite/view.php index 846d901f1..c039365a8 100644 --- a/Plugins/Mineplex.ReportSite/view.php +++ b/Plugins/Mineplex.ReportSite/view.php @@ -89,7 +89,7 @@ function getReport($reportId) { $connection = getConnection("ACCOUNT"); - $statement = $connection->prepare('SELECT reports.suspectId, reports.categoryId, reports.snapshotId, reportHandlers.handlerId FROM reports + $statement = $connection->prepare('SELECT reports.suspectId, reports.categoryId, reportHandlers.handlerId FROM reports LEFT JOIN reportHandlers ON reports.id = reportHandlers.reportId AND reportHandlers.aborted IS FALSE LEFT JOIN reportResults ON reports.id = reportResults.reportId WHERE reports.id = ?;'); @@ -97,26 +97,20 @@ $statement->bind_param('i', $reportId); $statement->execute(); $statement->store_result(); - $statement->bind_result($suspectId, $categoryId, $snapshotId, $handlerId); + $statement->bind_result($suspectId, $categoryId, $handlerId); if ($statement->fetch()) { $suspectUser = getUser($suspectId); $reportReasons = getReporters($reportId); - $snapshot = null; $handlerUser = null; - if (!is_null($snapshotId)) - { - $snapshot = getSnapshot($snapshotId); - } - if (!is_null($handlerId)) { $handlerUser = getUser($handlerId); } - return new Report($reportId, $handlerUser, $suspectUser, $reportReasons, $categoryId, $snapshot); + return new Report($reportId, $handlerUser, $suspectUser, $reportReasons, $categoryId); } $statement->close(); @@ -124,7 +118,39 @@ return null; } - function getSnapshot($messageId) + /** + * @param string $token + * @return int|null + */ + function getSnapshotId($token) + { + $connection = getConnection('ACCOUNT'); + $statement = $connection->prepare('SELECT id FROM snapshots WHERE token = ?;'); + $statement->bind_param('s', $token); // TODO: correct data type + $statement->execute(); + $statement->bind_result($snapshotId); + $statement->store_result(); + $statement->fetch(); + return $snapshotId; + } + + /** + * @param int $snapshotId + * @return int|null + */ + function getSnapshotReportId($snapshotId) + { + $connection = getConnection('ACCOUNT'); + $statement = $connection->prepare('SELECT id FROM reports WHERE snapshotId = ?;'); + $statement->bind_param('i', $snapshotId); + $statement->execute(); + $statement->bind_result($reportId); + $statement->store_result(); + $statement->fetch(); + return $reportId; + } + + function getSnapshot($snapshotId) { /** @var $messages Message[] */ $messages = array(); @@ -135,14 +161,14 @@ WHERE snapshotMessageMap.snapshotId = snapshots.id AND snapshotMessages.id = snapshotMessageMap.messageId AND snapshots.id = ?;"); - $statement->bind_param('i', $messageId); + $statement->bind_param('i', $snapshotId); $statement->execute(); - $statement->bind_result($messageId, $senderId, $snapshotType, $server, $time, $message); + $statement->bind_result($snapshotId, $senderId, $snapshotType, $server, $time, $message); $statement->store_result(); while ($statement->fetch()) { - $recipients = getUsers(getMessageRecipients($messageId)); + $recipients = getUsers(getMessageRecipients($snapshotId)); $message = new Message(getUser($senderId), $recipients, $time, $snapshotType, $message, $server); array_push($messages, $message); } @@ -161,20 +187,20 @@ WHERE snapshotMessageMap.snapshotId = snapshots.id } } - return new Snapshot($messageId, $messages, $snapshotUsers); + return new Snapshot($snapshotId, $messages, $snapshotUsers); } /** - * @param $messageId + * @param $snapshotId * @return Integer[] array */ - function getMessageRecipients($messageId) + function getMessageRecipients($snapshotId) { $recipientIds = array(); $connection = getConnection("ACCOUNT"); $statement = $connection->prepare("SELECT recipientId FROM snapshotRecipients WHERE messageId = ?"); - $statement->bind_param('i', $messageId); + $statement->bind_param('i', $snapshotId); $statement->execute(); $statement->bind_result($recipientId); @@ -355,38 +381,41 @@ WHERE snapshotMessageMap.snapshotId = snapshots.id return '?' . http_build_query($vars); } - $validId = isset($_GET['id']); + $validToken = isset($_GET['token']); $errorMsg = ""; - $id = null; + $token = null; $expanded = null; $report = null; $snapshot = null; $messages = null; - if ($validId) + if ($validToken) { - $id = $_GET['id']; + $token = $_GET['token']; $expanded = isset($_GET['expanded']) && $_GET['expanded']; - $report = getReport($id); + $snapshotId = getSnapshotId($token); - if ($report) + if ($snapshotId != null) { - $snapshot = $report->getSnapshot(); + $snapshot = getSnapshot($snapshotId); + $messages = $snapshot->getMessages(); + $reportId = getSnapshotReportId($snapshotId); - if ($snapshot != null) + if ($reportId) { - $messages = $snapshot->getMessages(); + $report = getReport($reportId); } else { - $errorMsg = 'No associated snapshot found for report.'; + $validToken = false; + $errorMsg = 'Associated report not found.'; // TODO: Allow snapshots without reports in future } } else { - $validId = false; - $errorMsg = "Invalid id."; + $validToken = false; + $errorMsg = 'Invalid token.'; } } ?> @@ -399,7 +428,7 @@ WHERE snapshotMessageMap.snapshotId = snapshots.id - <?php if ($validId): ?> + <?php if ($validToken): ?> Report #<?= $report->getId() ?> <?php else: ?> Report System @@ -415,17 +444,17 @@ WHERE snapshotMessageMap.snapshotId = snapshots.id <h1>Report System</h1> </div> <div id="search"> - <form id="id-input" name="id-input" action="view.php" method="get"> + <form id="token-input" name="token-input" action="view.php" method="get"> <div class="input-group"> - <input name="id" type="text" class="form-control" placeholder="Enter snapshot id..."> + <input name="token" type="text" class="form-control" placeholder="Enter snapshot token..."> <span class="input-group-btn"> - <button class="btn btn-secondary" type="submit" form="id-input"><i class="fa fa-search"></i> Search</button> + <button class="btn btn-secondary" type="submit" form="token-input"><i class="fa fa-search"></i> Search</button> </span> </div> </form> </div> - <?php if ((isset($_GET['id']) && !$validId) || !empty($errorMsg)): ?> + <?php if ((isset($_GET['token']) && !$validToken) || !empty($errorMsg)): ?> <div id="content" class="center-block" style="text-align: center; background-color: rgba(204, 34, 42, 0.52);"> <p class="error-oh-no" style="font-size: 60px;">What did you do?!?!?</p> <img src="img/shaun.gif" /> @@ -436,7 +465,7 @@ WHERE snapshotMessageMap.snapshotId = snapshots.id <?php endif; ?> </div> <?php else: ?> - <?php if (!isset($_GET['id'])) exit(); ?> + <?php if (!isset($_GET['token'])) exit(); ?> <div id="content"> <div> diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java index 44251149e..5d84a00fd 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java @@ -31,6 +31,7 @@ import net.minecraft.server.v1_8_R3.MinecraftServer; import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v1_8_R3.CraftServer; import org.bukkit.plugin.java.JavaPlugin; +import org.spigotmc.SpigotConfig; import java.util.UUID; @@ -80,7 +81,8 @@ public class StaffServer extends JavaPlugin //Updates getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1); - MinecraftServer.getServer().getPropertyManager().setProperty("debug", true); + MinecraftServer.getServer().getPropertyManager().setProperty("debug", false); + SpigotConfig.debug = false; Bukkit.getWorlds().get(0).setSpawnLocation(0, 102, 0); diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java index df73cbcfc..fa2d4c7bf 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java @@ -2,14 +2,16 @@ package mineplex.staffServer.customerSupport; import java.sql.ResultSet; import java.sql.SQLException; +import java.time.LocalDate; import java.time.YearMonth; +import java.time.format.TextStyle; import java.util.ArrayList; -import java.util.Calendar; import java.util.HashSet; import java.util.List; import java.util.Locale; import java.util.UUID; +import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -20,6 +22,7 @@ import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.weather.WeatherChangeEvent; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.Managers; @@ -52,6 +55,8 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable private NautHashMap<Player, HashSet<String>> _agentCacheMap = new NautHashMap<Player, HashSet<String>>(); private NautHashMap<Integer, List<String>> _accountBonusLog = new NautHashMap<>(); + + private boolean _allowWeatherChange = false; public CustomerSupport(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, SalesPackageManager salesPackageManager, PowerPlayClubRepository powerPlayRepo) { @@ -62,6 +67,10 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable _salesPackageManager = salesPackageManager; _repository = new CustomerSupportRepository(getPlugin()); _powerPlayRepo = powerPlayRepo; + + _allowWeatherChange = true; + Bukkit.getWorlds().get(0).setStorm(false); + _allowWeatherChange = false; } @EventHandler @@ -124,9 +133,7 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable _repository.loadBonusLogForAccountId(client.getAccountId(), instance); PowerPlayData powerPlayData = _powerPlayRepo.loadData(client.getAccountId()).join(); - boolean powerPlaySub = powerPlayData.isSubscribed(); - boolean powerPlayClaim = powerPlaySub && !powerPlayData.getUnclaimedMonths().contains(YearMonth.now()); - + runSync(new Runnable() { public void run() @@ -151,6 +158,7 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable int omegaChestsReceived = 0; int hauntedChestsReceived = 0; int hauntedChestsOpened = 0; + int trickOrTreatChestsReceived = 0; for (CoinTransactionToken transaction : donor.getCoinTransactions()) { @@ -250,6 +258,17 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable hauntedChestsReceived += 1; } + } + if (transaction.SalesPackageName.startsWith("Trick or Treat Chest")) + { + if (transaction.Coins == 0 && transaction.Gems == 0) + { + if (transaction.SalesPackageName.split(" ").length == 3) + trickOrTreatChestsReceived += Integer.parseInt(transaction.SalesPackageName.split(" ")[2]); + else if (transaction.SalesPackageName.split(" ").length == 2) + trickOrTreatChestsReceived += 1; + } + } if (transaction.SalesPackageName.startsWith("Valentines Gift")) { @@ -319,6 +338,7 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable caller.sendMessage(C.cBlue + "Omega Chests Received: " + C.cYellow + omegaChestsReceived); caller.sendMessage(C.cBlue + "Haunted Chests Received: " + C.cYellow + hauntedChestsReceived); caller.sendMessage(C.cBlue + "Haunted Chests Opened: " + C.cYellow + hauntedChestsOpened); + caller.sendMessage(C.cBlue + "Trick or Treat Chests Received: " + C.cYellow + trickOrTreatChestsReceived); caller.sendMessage(C.cBlue + "Game Amplifiers Received: " + C.cYellow + boostersReceived); caller.sendMessage(C.cBlue + "Rune Amplifiers (20 min) Received: " + C.cYellow + runeAmplifier20); caller.sendMessage(C.cBlue + "Rune Amplifiers (60 min) Received: " + C.cYellow + runeAmplifier60); @@ -338,8 +358,14 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable caller.sendMessage(C.cBlue + "Clan Banner Usage: " + getLockedFreedomStr(client.getUniqueId(), "Clan Banner Usage")); caller.sendMessage(C.cBlue + "Clan Banner Editor: " + getLockedFreedomStr(client.getUniqueId(), "Clan Banner Editor")); caller.sendMessage(C.cDGreen + C.Strike + "============================================="); - caller.sendMessage(C.cBlue + "Power Play Subscription (" + Calendar.getInstance().getDisplayName(Calendar.MONTH, Calendar.LONG, Locale.getDefault()) + "): " + (powerPlaySub ? C.cGreen + "Active" : C.cRed + "Inactive")); - caller.sendMessage(C.cBlue + "Power Play Monthly Reward (" + Calendar.getInstance().getDisplayName(Calendar.MONTH, Calendar.LONG, Locale.getDefault()) + "): " + (powerPlayClaim ? C.cRed + "Unavailable" : C.cGreen + "Available")); + YearMonth yearMonth = YearMonth.now(); + caller.sendMessage(C.cBlue + "Power Play Subscription (" + yearMonth.getMonth().getDisplayName(TextStyle.FULL, Locale.US) + ") " + (powerPlayData.isSubscribed() ? C.cGreen + "Active" : C.cRed + "Inactive")); + if (powerPlayData.isSubscribed()) + { + caller.sendMessage(C.cBlue + "Power Play Chest/Amplifiers (" + yearMonth.getMonth().getDisplayName(TextStyle.FULL, Locale.US) + ") " + (powerPlayData.getUnclaimedMonths().contains(YearMonth.now()) ? C.cGreen + "Unclaimed" : C.cRed + "Claimed")); + LocalDate nextClaimDate = powerPlayData.getNextClaimDate().get(); // Guaranteed by isSubscribed() + caller.sendMessage(C.cBlue + "Power Play Next Claim Date " + C.cYellow + nextClaimDate.getMonth().getDisplayName(TextStyle.FULL, Locale.US) + " " + nextClaimDate.getDayOfMonth()); + } _accountBonusLog.remove(client.getAccountId()); } @@ -396,6 +422,15 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable event.setCancelled(true); } + + @EventHandler + public void stopRain(WeatherChangeEvent event) + { + if (!_allowWeatherChange) + { + event.setCancelled(true); + } + } @Override public void processResultSet(ResultSet resultSet) throws SQLException diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java index 897af4562..aed398e97 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java @@ -1,6 +1,5 @@ package mineplex.staffServer.salespackage; -import mineplex.staffServer.salespackage.salespackages.*; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; @@ -10,10 +9,33 @@ import mineplex.core.common.jsonchat.JsonMessage; import mineplex.core.common.util.NautHashMap; import mineplex.core.donation.DonationManager; import mineplex.core.inventory.InventoryManager; +import mineplex.core.pet.PetFactory; +import mineplex.core.pet.repository.PetRepository; import mineplex.core.powerplayclub.PowerPlayClubRepository; import mineplex.core.stats.StatsManager; import mineplex.staffServer.salespackage.command.DisplayPackageCommand; import mineplex.staffServer.salespackage.command.Sales; +import mineplex.staffServer.salespackage.salespackages.AncientChest; +import mineplex.staffServer.salespackage.salespackages.ApplyKits; +import mineplex.staffServer.salespackage.salespackages.ClanBannerEditor; +import mineplex.staffServer.salespackage.salespackages.ClanBannerUsage; +import mineplex.staffServer.salespackage.salespackages.Coins; +import mineplex.staffServer.salespackage.salespackages.DefaultRank; +import mineplex.staffServer.salespackage.salespackages.FreedomChest; +import mineplex.staffServer.salespackage.salespackages.HauntedChest; +import mineplex.staffServer.salespackage.salespackages.IlluminatedChest; +import mineplex.staffServer.salespackage.salespackages.LifetimeHero; +import mineplex.staffServer.salespackage.salespackages.LifetimeLegend; +import mineplex.staffServer.salespackage.salespackages.LifetimeTitan; +import mineplex.staffServer.salespackage.salespackages.LifetimeUltra; +import mineplex.staffServer.salespackage.salespackages.MythicalChest; +import mineplex.staffServer.salespackage.salespackages.OldChest; +import mineplex.staffServer.salespackage.salespackages.OmegaChest; +import mineplex.staffServer.salespackage.salespackages.Pet; +import mineplex.staffServer.salespackage.salespackages.PowerPlayClub; +import mineplex.staffServer.salespackage.salespackages.RuneAmplifier; +import mineplex.staffServer.salespackage.salespackages.SalesPackageBase; +import mineplex.staffServer.salespackage.salespackages.TrickOrTreatChest; public class SalesPackageManager extends MiniPlugin { @@ -22,6 +44,8 @@ public class SalesPackageManager extends MiniPlugin private InventoryManager _inventoryManager; private StatsManager _statsManager; private PowerPlayClubRepository _powerPlayRepo; + private PetRepository _petRepo; + private PetFactory _petFactory; private NautHashMap<String, SalesPackageBase> _salesPackages = new NautHashMap<String, SalesPackageBase>(); @@ -34,6 +58,10 @@ public class SalesPackageManager extends MiniPlugin _inventoryManager = inventoryManager; _statsManager = statsManager; _powerPlayRepo = powerPlayRepo; + + _petRepo = new PetRepository(plugin, plugin.getConfig().getString("webServer")); + _petFactory = new PetFactory(_petRepo); + //Strutt20 asked me to remove some of the stuff from the menu AddSalesPackage(new Coins(this, 5000)); @@ -65,6 +93,12 @@ public class SalesPackageManager extends MiniPlugin AddSalesPackage(new PowerPlayClub(this, true)); AddSalesPackage(new OmegaChest(this)); AddSalesPackage(new HauntedChest(this)); + AddSalesPackage(new TrickOrTreatChest(this)); + + for (mineplex.core.pet.Pet pet : _petFactory.GetPets()) + { + AddSalesPackage(new Pet(this, pet.getName(), pet.getPetType())); + } } private void AddSalesPackage(SalesPackageBase salesPackage) @@ -98,6 +132,16 @@ public class SalesPackageManager extends MiniPlugin { return _powerPlayRepo; } + + public PetRepository getPetRepo() + { + return _petRepo; + } + + public PetFactory getPetFactory() + { + return _petFactory; + } public void help(Player player) { @@ -115,6 +159,7 @@ public class SalesPackageManager extends MiniPlugin JsonMessage chestBuilder = new JsonMessage("Chest Packages : ").color("blue"); JsonMessage clanBuilder = new JsonMessage("Clan Packages : ").color("blue"); JsonMessage powerPlayBuilder = new JsonMessage("Power Play Club Packages : ").color("blue"); + JsonMessage petBuilder = new JsonMessage("Pet Packages : ").color("blue"); for (SalesPackageBase salesPackage : _salesPackages.values()) { @@ -122,7 +167,7 @@ public class SalesPackageManager extends MiniPlugin { coinBuilder = coinBuilder.extra("[").color("gray").extra(salesPackage.getName()).color("green").click("run_command", "/display " + playerName + " " + salesPackage.getName()).extra("] ").color("gray"); } - else if (salesPackage instanceof MythicalChest || salesPackage instanceof AncientChest || salesPackage instanceof OldChest || salesPackage instanceof IlluminatedChest || salesPackage instanceof FreedomChest) + else if (salesPackage instanceof MythicalChest || salesPackage instanceof AncientChest || salesPackage instanceof OldChest || salesPackage instanceof IlluminatedChest || salesPackage instanceof FreedomChest || salesPackage instanceof HauntedChest || salesPackage instanceof TrickOrTreatChest) { chestBuilder = chestBuilder.extra("[").color("gray").extra(salesPackage.getName()).color("green").click("run_command", "/display " + playerName + " " + salesPackage.getName()).extra("] ").color("gray"); } @@ -134,6 +179,10 @@ public class SalesPackageManager extends MiniPlugin { powerPlayBuilder = powerPlayBuilder.extra("[").color("gray").extra(salesPackage.getName()).color("green").click("run_command", "/display " + playerName + " " + salesPackage.getName()).extra("] ").color("gray"); } + else if (salesPackage instanceof Pet) + { + petBuilder = petBuilder.extra("[").color("gray").extra(salesPackage.getName()).color("green").click("run_command", "/display " + playerName + " " + salesPackage.getName()).extra("] ").color("gray"); + } else { packageBuilder = packageBuilder.extra("[").color("gray").extra(salesPackage.getName()).color("green").click("run_command", "/display " + playerName + " " + salesPackage.getName()).extra("] ").color("gray"); @@ -145,6 +194,7 @@ public class SalesPackageManager extends MiniPlugin packageBuilder.sendToPlayer(caller); clanBuilder.sendToPlayer(caller); powerPlayBuilder.sendToPlayer(caller); + petBuilder.sendToPlayer(caller); } public StatsManager getStatsManager() diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/PetCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/PetCommand.java new file mode 100644 index 000000000..69c5d6aac --- /dev/null +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/PetCommand.java @@ -0,0 +1,102 @@ +package mineplex.staffServer.salespackage.command; + +import java.util.UUID; + +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; + +import com.google.gson.Gson; + +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.pet.Pet; +import mineplex.core.pet.PetClient; +import mineplex.core.pet.repository.token.ClientPetTokenWrapper; +import mineplex.core.pet.repository.token.PetChangeToken; +import mineplex.staffServer.salespackage.SalesPackageManager; + +public class PetCommand extends CommandBase<SalesPackageManager> +{ + public PetCommand(SalesPackageManager plugin) + { + super(plugin, Rank.MODERATOR, "pet"); + } + + @Override + public void Execute(final Player caller, String[] args) + { + if (args.length < 2) + return; + + final String playerName = args[0]; + int petId = Integer.parseInt(args[1]); + + if ((petId < 0 || petId >= EntityType.values().length) || Plugin.getPetFactory().getPet(EntityType.values()[petId]) == null) + { + caller.sendMessage(F.main(Plugin.getName(), "You have entered an invalid Pet Type.")); + return; + } + + final EntityType petType = EntityType.values()[petId]; + + Plugin.getClientManager().loadClientByName(playerName, client -> + { + final UUID uuid = Plugin.getClientManager().loadUUIDFromDB(playerName); + + if (uuid != null) + { + final Callback<PetClient> clientCallback = new Callback<PetClient>() + { + public void run(PetClient petClient) + { + if (petClient.getPets().containsKey(petType)) + { + caller.sendMessage(F.main(Plugin.getName(), F.elem(playerName) + " already has that Pet!")); + } + else + { + Pet pet = Plugin.getPetFactory().getPet(petType); + PetChangeToken token = new PetChangeToken(); + token.AccountId = client.getAccountId(); + token.Name = playerName; + token.PetType = petType.toString(); + token.PetName = pet.getName(); + + Plugin.getPetRepo().AddPet(token); + Plugin.getInventoryManager().addItemToInventoryForOffline(success -> + { + if (success) + { + caller.sendMessage(F.main(Plugin.getName(), F.elem(playerName) + " has been given their Pet!")); + } + else + { + caller.sendMessage(F.main(Plugin.getName(), "Attempt to give Pet has failed!")); + } + }, client.getAccountId(), petType.toString(), 1); + } + } + }; + + Plugin.runAsync(() -> + { + Gson gson = new Gson(); + ClientPetTokenWrapper token = null; + String response = Plugin.getClientManager().getRepository().getClientByUUID(uuid); + token = gson.fromJson(response, ClientPetTokenWrapper.class); + + PetClient petClient = new PetClient(); + petClient.load(token.DonorToken); + + clientCallback.run(petClient); + }); + } + else + { + caller.sendMessage(F.main(Plugin.getName(), "Couldn't find " + playerName + "'s account!")); + } + }); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/Sales.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/Sales.java index 4a1bfc4c7..40040e1d0 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/Sales.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/Sales.java @@ -24,6 +24,7 @@ public class Sales extends MultiCommandBase<SalesPackageManager> AddCommand(new LifetimeTitanCommand(plugin)); AddCommand(new KitsCommand(plugin)); AddCommand(new PowerPlayCommand(plugin)); + AddCommand(new PetCommand(plugin)); } @Override diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/Pet.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/Pet.java new file mode 100644 index 000000000..add8d52ae --- /dev/null +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/Pet.java @@ -0,0 +1,26 @@ +package mineplex.staffServer.salespackage.salespackages; + +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; + +import mineplex.staffServer.salespackage.SalesPackageManager; + +public class Pet extends SalesPackageBase +{ + private String _petName; + private EntityType _petType; + + public Pet(SalesPackageManager manager, String petName, EntityType petType) + { + super(manager, "1 " + petName + " Pet"); + _petName = petName; + _petType = petType; + } + + public void displayToAgent(Player agent, String playerName) + { + addButton(agent, "/sales pet " + playerName + " " + _petType.ordinal(), "Give 1 " + _petName + " Pet."); + agent.sendMessage(" "); + addBackButton(agent, playerName); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/TrickOrTreatChest.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/TrickOrTreatChest.java new file mode 100644 index 000000000..315dd6151 --- /dev/null +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/TrickOrTreatChest.java @@ -0,0 +1,19 @@ +package mineplex.staffServer.salespackage.salespackages; + +import mineplex.staffServer.salespackage.SalesPackageManager; +import org.bukkit.entity.Player; + +public class TrickOrTreatChest extends SalesPackageBase +{ + public TrickOrTreatChest(SalesPackageManager manager) + { + super(manager, "1 Trick or Treat Chest"); + } + + public void displayToAgent(Player agent, String playerName) + { + addButton(agent, "/sales item " + playerName + " 1 Item Trick or Treat Chest", "Give 1 Trick or Treat Chest."); + agent.sendMessage(" "); + addBackButton(agent, playerName); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Votifier/plugin.yml b/Plugins/Mineplex.Votifier/plugin.yml deleted file mode 100644 index 75a40f893..000000000 --- a/Plugins/Mineplex.Votifier/plugin.yml +++ /dev/null @@ -1,3 +0,0 @@ -name: MineplexVotifier -main: mineplex.votifier.Votifier -version: 0.1 \ No newline at end of file diff --git a/Plugins/Mineplex.Votifier/pom.xml b/Plugins/Mineplex.Votifier/pom.xml deleted file mode 100644 index 0d3e1464c..000000000 --- a/Plugins/Mineplex.Votifier/pom.xml +++ /dev/null @@ -1,27 +0,0 @@ - -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>com.mineplex</groupId> - <artifactId>mineplex-plugin</artifactId> - <version>dev-SNAPSHOT</version> - <relativePath>../plugin.xml</relativePath> - </parent> - - <name>MineplexVotifier</name> - <artifactId>mineplex-votifier</artifactId> - - <dependencies> - <dependency> - <groupId>${project.groupId}</groupId> - <artifactId>mineplex-core</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>com.vexsoftware</groupId> - <artifactId>votifier</artifactId> - </dependency> - </dependencies> -</project> diff --git a/Plugins/Mineplex.Votifier/src/mineplex/votifier/Votifier.java b/Plugins/Mineplex.Votifier/src/mineplex/votifier/Votifier.java deleted file mode 100644 index c314bdf85..000000000 --- a/Plugins/Mineplex.Votifier/src/mineplex/votifier/Votifier.java +++ /dev/null @@ -1,33 +0,0 @@ -package mineplex.votifier; - -import mineplex.core.account.CoreClientManager; -import mineplex.core.bonuses.BonusManager; -import mineplex.core.command.CommandCenter; -import mineplex.core.donation.DonationManager; -import org.bukkit.plugin.java.JavaPlugin; - -/** - * Created by shaun on 15-08-05. - */ -public class Votifier extends JavaPlugin -{ - private String WEB_CONFIG = "webServer"; - - @Override - public void onEnable() - { - getConfig().addDefault(WEB_CONFIG, "http://accounts.mineplex.com/"); - getConfig().set(WEB_CONFIG, getConfig().getString(WEB_CONFIG)); - saveConfig(); - - String webServerAddress = getConfig().getString(WEB_CONFIG); - - CommandCenter.Initialize(this); - CoreClientManager clientManager = new CoreClientManager(this, webServerAddress); - DonationManager donationManager = new DonationManager(this, clientManager, webServerAddress); - BonusManager bonusManager = new BonusManager(this, clientManager, donationManager); - - - VotifierManager vote = new VotifierManager(this, clientManager, donationManager, bonusManager); - } -} diff --git a/Plugins/Mineplex.Votifier/src/mineplex/votifier/VotifierManager.java b/Plugins/Mineplex.Votifier/src/mineplex/votifier/VotifierManager.java deleted file mode 100644 index 5e9393d2a..000000000 --- a/Plugins/Mineplex.Votifier/src/mineplex/votifier/VotifierManager.java +++ /dev/null @@ -1,268 +0,0 @@ -package mineplex.votifier; - -import java.sql.Date; -import java.util.UUID; - -import mineplex.core.MiniPlugin; -import mineplex.core.account.CoreClientManager; -import mineplex.core.bonuses.BonusAmount; -import mineplex.core.bonuses.BonusManager; -import mineplex.core.bonuses.redis.VotifierCommand; -import mineplex.core.common.Pair; -import mineplex.core.common.util.Callback; -import mineplex.core.common.util.UUIDFetcher; -import mineplex.core.donation.DonationManager; -import mineplex.database.Tables; -import mineplex.database.tables.records.BonusRecord; -import mineplex.serverdata.Region; -import mineplex.serverdata.Utility; -import mineplex.serverdata.commands.ServerCommand; -import mineplex.serverdata.data.PlayerStatus; -import mineplex.serverdata.database.DBPool; -import mineplex.serverdata.redis.RedisConfig; -import mineplex.serverdata.redis.RedisDataRepository; -import mineplex.serverdata.servers.ServerManager; - -import org.bukkit.event.EventHandler; -import org.bukkit.plugin.java.JavaPlugin; -import org.jooq.DSLContext; -import org.jooq.Record1; -import org.jooq.SQLDialect; -import org.jooq.impl.DSL; - -import redis.clients.jedis.Jedis; -import redis.clients.jedis.JedisPool; - -import com.vexsoftware.votifier.model.Vote; -import com.vexsoftware.votifier.model.VotifierEvent; - -/** - * Created by shaun on 15-08-05. - */ -public class VotifierManager extends MiniPlugin -{ - private CoreClientManager _clientManager; - private DonationManager _donationManager; - private BonusManager _bonusManager; - - private RedisConfig _usConfig; - private RedisConfig _euConfig; - private RedisDataRepository<PlayerStatus> _usPlayerRepo; - private RedisDataRepository<PlayerStatus> _euPlayerRepo; - private JedisPool _usWritePool; - private JedisPool _euWritePool; - - public VotifierManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, BonusManager bonusManager) - { - super("Votifier", plugin); - - _clientManager = clientManager; - _donationManager = donationManager; - _bonusManager = bonusManager; - - _usConfig = ServerManager.loadConfig("us-redis.dat"); - _euConfig = ServerManager.loadConfig("eu-redis.dat"); - - _usPlayerRepo = new RedisDataRepository<PlayerStatus>(_usConfig.getConnection(true, "DefaultConnection"), - _usConfig.getConnection(false, "DefaultConnection"), Region.US, PlayerStatus.class, "playerStatus"); - _euPlayerRepo = new RedisDataRepository<PlayerStatus>(_euConfig.getConnection(true, "DefaultConnection"), - _euConfig.getConnection(false, "DefaultConnection"), Region.EU, PlayerStatus.class, "playerStatus"); - - _usWritePool = Utility.generatePool(_usConfig.getConnection(true, "DefaultConnection")); - _euWritePool = Utility.generatePool(_euConfig.getConnection(true, "DefaultConnection")); - } - - @EventHandler - public void handleVote(VotifierEvent event) - { - final Vote vote = event.getVote(); - final String playerName = vote.getUsername(); - - System.out.println("New Vote: " + playerName); - - runAsync(new Runnable() - { - @Override - public void run() - { - UUID uuid = UUIDFetcher.getUUIDOf(playerName); - if (uuid == null) - { - System.out.println("Failed to load UUID of " + playerName + " from UUIDFetcher. Trying with database"); - uuid = _clientManager.loadUUIDFromDB(playerName); - - if (uuid == null) - { - System.out.println("Failed to load UUID from database. Giving up on " + playerName); - } - } - - String lowerPlayerName = playerName.toLowerCase(); - final PlayerStatus usStatus = _usPlayerRepo.getElement(lowerPlayerName); - final PlayerStatus euStatus = _euPlayerRepo.getElement(lowerPlayerName); - - System.out.println("Loaded " + playerName + " with uuid " + uuid); - System.out.println("Attempting to award bonus"); - final UUID finalUuid = uuid; - awardBonus(playerName, finalUuid, new Callback<Integer>() - { - @Override - public void run(final Integer shards) - { - runSync(new Runnable() - { - @Override - public void run() - { - if (usStatus != null) - { - System.out.println("Found " + playerName + " on US " + usStatus.getServer()); - notifyServer(playerName, shards, Region.US, usStatus.getServer()); - } - - if (euStatus != null) - { - System.out.println("Found " + playerName + " on EU " + euStatus.getServer()); - notifyServer(playerName, shards, Region.EU, euStatus.getServer()); - } - } - }); - } - }); - } - }); - System.out.println(); - System.out.println(); - -// UUID uuid = _clientManager.loadUUIDFromDB(playerName); -// if (uuid != null) -// { -// System.out.println("Found UUID:" + uuid.toString()); -// if (playerName.equalsIgnoreCase("Phinary")) -// { -// System.out.println("award bonus"); -// awardBonus(uuid); -// } -// } -// else -// { -// System.out.println("Failed to load UUID for player: " + playerName); -// } - -// PlayerStatus usStatus = _usPlayerRepo.getElement(playerName); -// if (usStatus != null) -// { -// System.out.println("Found on US Server: " + usStatus.getServer()); -// writePool = _usWritePool; -// serverName = usStatus.getServer(); -// } -// -// PlayerStatus euStatus = _euPlayerRepo.getElement(playerName); -// if (euStatus != null) -// { -// System.out.println("Found on EU Server: " + euStatus.getServer()); -// writePool = _euWritePool; -// serverName = euStatus.getServer(); -// } - - // Currently we just notify all servers, and the server with the player on it can deal with it -// notifyServer(playerName, true); - } - - private void notifyServer(String playerName, int shards, Region region, String targetServer) - { - JedisPool writePool = region == Region.EU ? _euWritePool : _usWritePool; - - VotifierCommand command = new VotifierCommand(playerName, shards, targetServer); - publishCommand(command, writePool); - } - - private void awardBonus(final String playerName, final UUID uuid, final Callback<Integer> onComplete) - { - DSLContext create = DSL.using(DBPool.getAccount(), SQLDialect.MYSQL); - - Record1<Integer> idRecord = create.select(Tables.accounts.id).from(Tables.accounts).where(Tables.accounts.uuid.eq(uuid.toString())).fetchOne(); - if (idRecord != null) - { - final int accountId = idRecord.value1(); - final BonusRecord client = _bonusManager.getRepository().loadRecord(playerName, accountId); - - final BonusAmount amount = _bonusManager.getVoteBonusAmount(client.getVoteStreak()); - - _bonusManager.getRepository().attemptVoteBonus(accountId, new Callback<Pair<Boolean, Date>>() - { - @Override - public void run(Pair<Boolean, Date> pair) - { - if (pair.getLeft()) - { - // Reward Amount - if (amount.getTickets() > 0) - client.setTickets(client.getTickets() + amount.getTickets()); - - if (amount.getTotalGems() > 0) - { - _donationManager.RewardGems(new Callback<Boolean>() - { - @Override - public void run(Boolean data) - { - if (data) - System.out.println("Gave " + amount.getGems() + " gems to " + playerName); - else - System.out.println("Failed to give " + amount.getGems() + " gems to " + playerName); - } - }, "Votifier", playerName, uuid, amount.getTotalGems()); - } - - if (amount.getTotalCoins() > 0) - { - _donationManager.RewardCoins(new Callback<Boolean>() - { - @Override - public void run(Boolean data) - { - if (data) - System.out.println("Gave " + amount.getCoins() + " coins to " + playerName); - else - System.out.println("Failed to give " + amount.getCoins() + " coins to " + playerName); - } - }, "Votifier", playerName, accountId, amount.getTotalCoins()); - } - - // Check if we need to reset vote streak - _bonusManager.updateVoteStreak(client); - client.setVotetime(pair.getRight()); - - // Update Streak - _bonusManager.incrementVoteStreak(client); - - client.store(); - System.out.println("Awarded carl ticket to " + playerName); - onComplete.run(amount.getTotalCoins()); - } - else - { - System.out.println(playerName + " attempted to vote, vote bonus returned false!"); - } - } - }); - } - } - - private void publishCommand(final ServerCommand serverCommand, final JedisPool writePool) - { - new Thread(new Runnable() - { - public void run() - { - try (Jedis jedis = writePool.getResource()) - { - String commandType = serverCommand.getClass().getSimpleName(); - String serializedCommand = Utility.serialize(serverCommand); - jedis.publish("commands.server" + ":" + commandType, serializedCommand); - } - } - }).start(); - } -} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java index a47fc844e..2a9f9b518 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -71,6 +71,7 @@ import net.minecraft.server.v1_8_R3.MinecraftServer; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; +import org.spigotmc.SpigotConfig; import java.io.File; import java.util.HashMap; @@ -197,8 +198,9 @@ public class Arcade extends JavaPlugin //Updates getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1); - - MinecraftServer.getServer().getPropertyManager().setProperty("debug", true); + + MinecraftServer.getServer().getPropertyManager().setProperty("debug", false); + SpigotConfig.debug = false; // Remove nasty biomes from natural terrain generation, used for UHC BiomeBase.getBiomes()[BiomeBase.OCEAN.id] = BiomeBase.PLAINS; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index 58c49294b..bb9ca2417 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -255,6 +255,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation //Game commands public static final String GAME_CMD_MODE_FILE = "GAME_CMD_MODE.dat"; private boolean _gameCommandMode; + + public final boolean IsHolidayEnabled; public ArcadeManager(Arcade plugin, ServerStatusManager serverStatusManager, GameServerConfig serverConfig, CoreClientManager clientManager, DonationManager donationManager, DamageManager damageManager, @@ -344,7 +346,10 @@ public class ArcadeManager extends MiniPlugin implements IRelation _hologramManager = hologramManager; _idleManager = new IdleManager(this); TitanGiveawayManager titanGiveaway = new TitanGiveawayManager(getPlugin(), clientManager, serverStatusManager); + new HolidayManager(this, titanGiveaway); + IsHolidayEnabled = true; + new ValentinesGiftManager(plugin, clientManager, _bonusManager.getRewardManager(), inventoryManager, _cosmeticManager.getGadgetManager(), statsManager); new GameTestingManager(this); require(PlayerDisguiseManager.class); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java index f47271c0f..6473d5118 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java @@ -43,6 +43,7 @@ import nautilus.game.arcade.game.games.gladiators.modes.OverpoweredGladiators; import nautilus.game.arcade.game.games.gladiators.modes.SmashGladiators; import nautilus.game.arcade.game.games.gravity.Gravity; import nautilus.game.arcade.game.games.halloween.Halloween; +import nautilus.game.arcade.game.games.halloween2016.Halloween2016; import nautilus.game.arcade.game.games.hideseek.HideSeek; import nautilus.game.arcade.game.games.hideseek.modes.Countdown; import nautilus.game.arcade.game.games.holeinwall.HoleInTheWall; @@ -145,6 +146,7 @@ public enum GameType { Pair.create(MinecraftVersion.ALL, "http://file.mineplex.com/ResHalloween.zip") }, true), + Halloween2016(Halloween2016.class, GameDisplay.Halloween2016), HideSeek(HideSeek.class, GameDisplay.HideSeek), HoleInTheWall(HoleInTheWall.class, GameDisplay.HoleInTheWall), Horse(Horse.class, GameDisplay.Horse), diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/barbarians/kits/KitArcher.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/barbarians/kits/KitArcher.java index 7bfea9ddf..afeb88449 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/barbarians/kits/KitArcher.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/barbarians/kits/KitArcher.java @@ -1,5 +1,11 @@ package nautilus.game.arcade.game.games.barbarians.kits; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + import mineplex.core.itemstack.ItemStackFactory; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.kit.KitAvailability; @@ -7,11 +13,6 @@ import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.ProgressingKit; import nautilus.game.arcade.kit.perks.PerkFletcher; import nautilus.game.arcade.kit.perks.PerkRopedArrow; -import org.bukkit.Material; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; public class KitArcher extends ProgressingKit { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bouncyballs/kits/KitPlayer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bouncyballs/kits/KitPlayer.java index dc752c593..9c1db1e7b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bouncyballs/kits/KitPlayer.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bouncyballs/kits/KitPlayer.java @@ -6,13 +6,10 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import mineplex.core.itemstack.ItemStackFactory; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.perks.PerkFletcher; -import nautilus.game.arcade.kit.perks.PerkRopedArrow; public class KitPlayer extends Kit { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/kits/KitArcher.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/kits/KitArcher.java index 661415b70..a02a04427 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/kits/KitArcher.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/kits/KitArcher.java @@ -1,19 +1,19 @@ package nautilus.game.arcade.game.games.bridge.kits; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemStackFactory; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.games.bridge.Bridge; -import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.game.games.smash.perks.skeleton.PerkBarrage; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.ProgressingKit; -import nautilus.game.arcade.kit.perks.PerkBarrage; import nautilus.game.arcade.kit.perks.PerkFletcher; -import org.bukkit.Material; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; public class KitArcher extends ProgressingKit { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/Build.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/Build.java index bcdf30b4a..4ef07344b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/Build.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/Build.java @@ -127,8 +127,10 @@ public class Build extends Game private int _countdownTimerState = 0; protected String[] _words; - protected String[] _holidayWords; - protected boolean _useHolidayWords = false; + protected String[] _christmasWords; + protected String[] _halloweenWords; + protected boolean _useChristmasWords = false; + protected boolean _useHalloweenWords = true; protected String _word = "?"; @@ -231,7 +233,7 @@ public class Build extends Game "Water Gun", "Astronaut", "Wither", "Meteor" }; - _holidayWords = new String[] + _christmasWords = new String[] { "Santa", "Reindeer", "Ornament", "Elf", "North Pole", "Candy Cane", "Xmas Lights", "Christmas Tree", "Fireplace", "Hot Chocolate", "Snowflake", "Snowman", "Sleigh", "Toys", "Milk", "Eggnog", "Coal", @@ -241,6 +243,16 @@ public class Build extends Game "Boots", "Gingerbread Man", "Glacier", "Ice Hockey", "Scarf", "Snowboard" }; + _halloweenWords = new String[] + { + "Bat", "Cauldron", "Broomstick", "Witch", "Witch Hat", "Haunted House", "Ghost", "Spider", + "Werewolf", "Full Moon", "Vampire", "Dracula", "Zombie", "Grim Reaper", "Graveyard", + "Gravestone", "Pumpkin", "Pumpkin Patch", "Jack-O-Lantern", "Scarecrow", "Haunted", + "Monster", "Halloween", "Skeleton", "Skull", "Coffin", "Tomb", "Cobweb", "Spider Web", + "Costume", "Frankenstein", "Black Cat", "Bone", "Candy", "Trick or Treat", "Eyeball", "Fangs", + "Goblin", "Potion", "Treat", "Trick" + }; + _mobShop = new MobShop(getArcadeManager(), getArcadeManager().GetClients(), getArcadeManager().GetDonation()); _optionsShop = new OptionsShop(this, getArcadeManager(), getArcadeManager().GetClients(), getArcadeManager().GetDonation()); _shopItem = ItemStackFactory.Instance.CreateStack(Material.DIAMOND, (byte) 0, 1, C.cGreen + "Options"); @@ -289,10 +301,7 @@ public class Build extends Game player.setFlySpeed(0.1f); } - if (!_useHolidayWords || Math.random() >= 0.5) - _word = _words[UtilMath.r(_words.length)]; - else - _word = _holidayWords[UtilMath.r(_holidayWords.length)]; + _word = getNextWord(); UtilTextMiddle.display(null, C.cYellow + "Build " + C.cWhite + _word, 0, 80, 5); @@ -1664,7 +1673,24 @@ public class Build extends Game return Arrays.asList(player); } - + + protected String getNextWord() + { + // TODO: These should be even no matter what word packs are enabled + if (_useHalloweenWords && Math.random() <= 0.5) + { + return _halloweenWords[UtilMath.r(_halloweenWords.length)]; + } + else if (_useChristmasWords && Math.random() <= 0.5) + { + return _christmasWords[UtilMath.r(_christmasWords.length)]; + } + else + { + return _words[UtilMath.r(_words.length)]; + } + } + public Map<Player, BuildData> getData() { return _data; @@ -1680,16 +1706,6 @@ public class Build extends Game return _word; } - public boolean useHolidayWords() - { - return _useHolidayWords; - } - - public String[] getHolidayWords() - { - return _holidayWords; - } - public String[] getWords() { return _words; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/modes/TeamBuild.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/modes/TeamBuild.java index 3b2d98bb5..ef5e41c08 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/modes/TeamBuild.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/modes/TeamBuild.java @@ -69,10 +69,7 @@ public class TeamBuild extends Build } } - if (!useHolidayWords() || Math.random() >= 0.5) - setWord(getWords()[UtilMath.r(getWords().length)]); - else - setWord(getHolidayWords()[UtilMath.r(getHolidayWords().length)]); + setWord(getNextWord()); UtilTextMiddle.display(null, C.cYellow + "Build " + C.cWhite + getWord(), 0, 80, 5); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitHumanMarksman.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitHumanMarksman.java index 66e032aea..1b01d6622 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitHumanMarksman.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitHumanMarksman.java @@ -1,14 +1,5 @@ package nautilus.game.arcade.game.games.castlesiege.kits; -import mineplex.core.common.util.C; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.kit.KitAvailability; -import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.perks.PerkBarrage; -import nautilus.game.arcade.kit.perks.PerkFletcher; import org.bukkit.Material; import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; @@ -16,6 +7,16 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.inventory.ItemStack; +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.smash.perks.skeleton.PerkBarrage; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.PerkFletcher; + public class KitHumanMarksman extends KitHuman { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragons/kits/KitMarksman.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragons/kits/KitMarksman.java index 6e57a6cdf..9fffc8f5f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragons/kits/KitMarksman.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragons/kits/KitMarksman.java @@ -1,19 +1,20 @@ package nautilus.game.arcade.game.games.dragons.kits; -import mineplex.core.common.util.C; -import mineplex.core.itemstack.ItemStackFactory; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.kit.KitAvailability; -import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.ProgressingKit; -import nautilus.game.arcade.kit.perks.PerkBarrage; -import nautilus.game.arcade.kit.perks.PerkFletcher; import org.bukkit.Material; import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemStackFactory; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.smash.perks.skeleton.PerkBarrage; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.ProgressingKit; +import nautilus.game.arcade.kit.perks.PerkFletcher; + public class KitMarksman extends ProgressingKit { @@ -46,7 +47,7 @@ public class KitMarksman extends ProgressingKit { super(manager, "Marksman", "dragonsmarksman", KitAvailability.Gem, DESCRIPTION, PERKS, EntityType.ZOMBIE, IN_HAND); } - + @Override public void GiveItems(Player player) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java index b6bad607f..3171f1920 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java @@ -91,8 +91,10 @@ public class Draw extends SoloGame private HashSet<Tool> _tools; private String[] _words; - private String[] _holidayWords; - private boolean _useHolidayWords = false; + private String[] _christmasWords; + private String[] _halloweenWords; + private boolean _useChristmasWords = false; + private boolean _useHalloweenWords = true; private HashSet<String> _usedWords = new HashSet<String>(); public Draw(ArcadeManager manager) @@ -187,7 +189,7 @@ public class Draw extends SoloGame "Strawberry", "Jam", "Sandwich", "Owl", "Watermelon", "Australia", "Canada", "United States", "Diary" }; - _holidayWords = new String[] + _christmasWords = new String[] { "Santa", "Reindeer", "Ornament", "Elf", "North Pole", "Candy Cane", "Christmas Tree", "Fireplace", "Hot Chocolate", "Snowflake", "Snowman", "Sleigh", "Toys", "Milk", "Eggnog", "Coal", @@ -197,6 +199,16 @@ public class Draw extends SoloGame "Boots", "Gingerbread Man", "Glacier", "Ice Hockey", "Scarf", "Snowboard" }; + _halloweenWords = new String[] + { + "Bat", "Cauldron", "Broomstick", "Witch", "Witch Hat", "Haunted House", "Ghost", "Spider", + "Werewolf", "Full Moon", "Vampire", "Dracula", "Zombie", "Grim Reaper", "Graveyard", + "Gravestone", "Pumpkin", "Pumpkin Patch", "Jack-O-Lantern", "Scarecrow", "Haunted", + "Monster", "Halloween", "Skeleton", "Skull", "Coffin", "Tomb", "Cobweb", "Spider Web", + "Costume", "Frankenstein", "Black Cat", "Bone", "Candy", "Trick or Treat", "Eyeball", "Fangs", + "Goblin", "Potion", "Treat", "Trick" + }; + _tools = new HashSet<Tool>(); _tools.add(new ToolLine(this)); _tools.add(new ToolSquare(this)); @@ -416,12 +428,19 @@ public class Draw extends SoloGame private String getRandomWord() { - if (!_useHolidayWords || Math.random() >= 0.30) + // TODO: These should be even no matter what word packs are enabled + if (_useHalloweenWords && Math.random() <= 0.3) + { + return _halloweenWords[UtilMath.r(_halloweenWords.length)]; + } + else if (_useChristmasWords && Math.random() <= 0.3) + { + return _christmasWords[UtilMath.r(_christmasWords.length)]; + } + else { return _words[UtilMath.r(_words.length)]; } - - return _holidayWords[UtilMath.r(_holidayWords.length)]; } @EventHandler(priority = EventPriority.LOWEST) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkBlockTossEVO.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkBlockTossEVO.java index 1ed85835a..2d91ec76d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkBlockTossEVO.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkBlockTossEVO.java @@ -43,7 +43,6 @@ public class PerkBlockTossEVO extends Perk implements IThrown */ private HashMap<Player, BlockTossData> _hold = new HashMap<Player, BlockTossData>(); - private HashMap<Player, Long> _charge = new HashMap<Player, Long>(); private HashSet<Player> _charged = new HashSet<Player>(); private HashMap<FallingBlock, Player> _falling = new HashMap<FallingBlock, Player>(); @@ -107,10 +106,8 @@ public class PerkBlockTossEVO extends Perk implements IThrown //Manager.GetBlockRestore().Add(event.getClickedBlock(), 0, (byte)0, 10000); event.getClickedBlock().getWorld().playEffect(event.getClickedBlock().getLocation(), Effect.STEP_SOUND, event.getClickedBlock().getType()); - _hold.put(player, new BlockTossData(id, data)); + _hold.put(player, new BlockTossData(id, data, System.currentTimeMillis())); - _charge.put(player, System.currentTimeMillis()); - //Effect player.getWorld().playEffect(event.getClickedBlock().getLocation(), Effect.STEP_SOUND, id); } @@ -132,7 +129,7 @@ public class PerkBlockTossEVO extends Perk implements IThrown //Charged Tick if (!_charged.contains(cur)) - if (System.currentTimeMillis() - _charge.get(cur) > 1200) + if (System.currentTimeMillis() - _hold.get(cur).Time > 1200) { _charged.add(cur); cur.playEffect(cur.getLocation(), Effect.CLICK1, 0); @@ -149,7 +146,7 @@ public class PerkBlockTossEVO extends Perk implements IThrown _charged.remove(cur); - long charge = System.currentTimeMillis() - _charge.remove(cur); + long charge = System.currentTimeMillis() - data.Time; //Throw double mult = 1.4; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/Halloween.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/Halloween.java index 3f4c10226..a2160dda5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/Halloween.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/Halloween.java @@ -1,7 +1,37 @@ package nautilus.game.arcade.game.games.halloween; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; + +import org.bukkit.ChatColor; +import org.bukkit.Difficulty; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.entity.Fireball; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.entity.EntityTargetEvent; +import org.bukkit.event.entity.ItemSpawnEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; + import mineplex.core.common.currency.GlobalCurrency; -import mineplex.core.common.util.*; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; @@ -17,36 +47,38 @@ import nautilus.game.arcade.game.games.halloween.creatures.InterfaceMove; import nautilus.game.arcade.game.games.halloween.kits.KitFinn; import nautilus.game.arcade.game.games.halloween.kits.KitRobinHood; import nautilus.game.arcade.game.games.halloween.kits.KitThor; -import nautilus.game.arcade.game.games.halloween.waves.*; +import nautilus.game.arcade.game.games.halloween.waves.Wave1; +import nautilus.game.arcade.game.games.halloween.waves.Wave2; +import nautilus.game.arcade.game.games.halloween.waves.Wave3; +import nautilus.game.arcade.game.games.halloween.waves.Wave4; +import nautilus.game.arcade.game.games.halloween.waves.Wave5; +import nautilus.game.arcade.game.games.halloween.waves.WaveBase; +import nautilus.game.arcade.game.games.halloween.waves.WaveBoss; +import nautilus.game.arcade.game.games.halloween.waves.WaveVictory; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.managers.chat.ChatStatData; import net.minecraft.server.v1_8_R3.PacketPlayOutNamedSoundEffect; -import org.bukkit.*; -import org.bukkit.block.Block; -import org.bukkit.entity.Fireball; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.entity.*; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; - -import java.util.*; public class Halloween extends SoloGame { //Wave Data - private ArrayList<ArrayList<Location>> _spawns; + protected ArrayList<ArrayList<Location>> _spawns; - private ArrayList<WaveBase> _waves; - private int _wave = 0; + protected ArrayList<WaveBase> _waves; + protected int _wave = 0; - private int _maxMobs = 80; - private ArrayList<CreatureBase> _mobs = new ArrayList<CreatureBase>(); + protected int _maxMobs = 80; + protected ArrayList<CreatureBase<?>> _mobs = new ArrayList<>(); - private HashMap<Player, Long> _damageTime = new HashMap<Player, Long>(); + protected HashMap<Player, Long> _damageTime = new HashMap<Player, Long>(); - private HashSet<Player> _soundOff = new HashSet<Player>(); + protected HashSet<Player> _soundOff = new HashSet<Player>(); + + protected UpdateType _updateCreatureMoveRate = UpdateType.FASTEST; + + protected boolean doVoices = true; + + public String Objective = null; public long total = 0; public long move = 0; @@ -78,7 +110,7 @@ public class Halloween extends SoloGame public Halloween(ArcadeManager manager) { - super(manager, GameType.Halloween, + this(manager, GameType.Halloween, new Kit[] { @@ -94,6 +126,12 @@ public class Halloween extends SoloGame "Defeat the waves of monsters", "Kill the Pumpkin King" }); + } + + protected Halloween(ArcadeManager manager, GameType gameType, Kit[] kits, String[] gameDesc) + { + super(manager, gameType, kits, gameDesc); + this.DamagePvP = false; @@ -116,6 +154,19 @@ public class Halloween extends SoloGame BlankLine, new ChatStatData("kit", "Kit", true) ); + + _help = new String[] + { + C.cGreen + "Giants one hit kill you! Stay away!!!", + C.cAqua + "Work together with your team mates.", + C.cGreen + "Each kit gives a buff to nearby allies.", + C.cAqua + "Kill monsters to keep their numbers down.", + C.cGreen + "Kill giants quickly.", + C.cAqua + "Defend your team mates from monsters.", + C.cGreen + "Zombies, Giants and Spiders get faster over time.", + C.cAqua + "Stick together to survive.", + C.cGreen + "The Pumpkin King gets harder over time!", + }; } @Override @@ -134,7 +185,7 @@ public class Halloween extends SoloGame _waves.add(new Wave4(this)); _waves.add(new Wave5(this)); _waves.add(new WaveBoss(this)); - _waves.add(new WaveVictory(this)); + _waves.add(new WaveVictory(this, GetSpawnSet(3))); //Make zombies break doors WorldData.World.setDifficulty(Difficulty.HARD); @@ -146,13 +197,20 @@ public class Halloween extends SoloGame if (event.GetState() != GameState.End) return; - for (CreatureBase ent : _mobs) - ent.GetEntity().remove(); + for (CreatureBase<?> ent : _mobs) + { + ent.remove(); + } _mobs.clear(); _spawns.clear(); } + public ArrayList<CreatureBase<?>> getMobs() + { + return _mobs; + } + @EventHandler(priority = EventPriority.MONITOR) public void TeamGen(GameStateChangeEvent event) { @@ -168,6 +226,8 @@ public class Halloween extends SoloGame if (event.GetState() != GameState.Live) return; + if(!doVoices) return; + Announce(C.Bold + "Type " + C.cGreen + C.Bold + "/voice" + C.cWhite + C.Bold + " to disable voice audio."); } @@ -253,8 +313,12 @@ public class Halloween extends SoloGame if (!IsLive()) return; + + if(_waves.get(_wave) instanceof WaveVictory || + _waves.get(_wave) instanceof nautilus.game.arcade.game.games.halloween2016.wave.WaveVictory) + return; - if (Math.random() > 0.6) + if (Math.random() > 0.2) return; for (Player player : UtilServer.getPlayers()) @@ -297,12 +361,12 @@ public class Halloween extends SoloGame return locSet.get(UtilMath.r(locSet.size())); } - public void AddCreature(CreatureBase mob) + public void AddCreature(CreatureBase<?> mob) { _mobs.add(0, mob); } - public ArrayList<CreatureBase> GetCreatures() + public ArrayList<CreatureBase<?>> GetCreatures() { return _mobs; } @@ -310,7 +374,7 @@ public class Halloween extends SoloGame @EventHandler public void CreatureMoveUpdate(UpdateEvent event) { - if (event.getType() != UpdateType.FASTEST) + if (event.getType() != _updateCreatureMoveRate) return; if (_mobs.isEmpty()) @@ -318,7 +382,7 @@ public class Halloween extends SoloGame long start = System.currentTimeMillis(); - CreatureBase base = _mobs.remove(0); + CreatureBase<?> base = _mobs.remove(0); if (base instanceof InterfaceMove) { @@ -342,25 +406,33 @@ public class Halloween extends SoloGame return; //Clean - Iterator<CreatureBase> mobIterator = _mobs.iterator(); + Iterator<CreatureBase<?>> mobIterator = _mobs.iterator(); while (mobIterator.hasNext()) { - CreatureBase base = mobIterator.next(); + CreatureBase<?> base = mobIterator.next(); if (base.Updater(event)) + { + onRemove(base); + base.remove(); mobIterator.remove(); + } } total += System.currentTimeMillis() - start; update += System.currentTimeMillis() - start; } + + public void onRemove(CreatureBase<?> mob) + { + } @EventHandler public void CreatureDamage(CustomDamageEvent event) { long start = System.currentTimeMillis(); - for (CreatureBase base : _mobs) + for (CreatureBase<?> base : _mobs) base.Damage(event); total += System.currentTimeMillis() - start; @@ -372,7 +444,7 @@ public class Halloween extends SoloGame { long start = System.currentTimeMillis(); - for (CreatureBase base : _mobs) + for (CreatureBase<?> base : _mobs) base.Target(event); total += System.currentTimeMillis() - start; @@ -451,7 +523,7 @@ public class Halloween extends SoloGame { Block block = blockIterator.next(); - if (block.getY() < 4) + if (block.getY() < 4 || block.getY() <= WorldData.MinY) blockIterator.remove(); } @@ -494,40 +566,6 @@ public class Halloween extends SoloGame { return _maxMobs; } - - private long _helpTimer = 0; - private int _helpIndex = 0; - private String[] _help = new String[] - { - C.cGreen + "Giants one hit kill you! Stay away!!!", - C.cAqua + "Work together with your team mates.", - C.cGreen + "Each kit gives a buff to nearby allies.", - C.cAqua + "Kill monsters to keep their numbers down.", - C.cGreen + "Kill giants quickly.", - C.cAqua + "Defend your team mates from monsters.", - C.cGreen + "Zombies, Giants and Spiders get faster over time.", - C.cAqua + "Stick together to survive.", - C.cGreen + "The Pumpkin King gets harder over time!", - }; - - @EventHandler - public void StateUpdate(UpdateEvent event) - { - if (event.getType() != UpdateType.SEC) - return; - - if (this.GetState() != GameState.Recruit) - return; - - if (!UtilTime.elapsed(_helpTimer, 8000)) - return; - - _helpTimer = System.currentTimeMillis(); - - Announce(C.cWhite + C.Bold + "TIP " + ChatColor.RESET + _help[_helpIndex]); - - _helpIndex = (_helpIndex + 1)%_help.length; - } @Override @EventHandler @@ -552,7 +590,7 @@ public class Halloween extends SoloGame Scoreboard.writeNewLine(); Scoreboard.write(C.cYellow + C.Bold + "Players"); - if (GetPlayers(true).size() < 8) + if (GetPlayers(true).size() < 5) { for (Player player : GetPlayers(true)) { @@ -564,12 +602,21 @@ public class Halloween extends SoloGame Scoreboard.write(GetPlayers(true).size() + " Alive"); } + if(Objective != null) + { + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Objective"); + Scoreboard.write(Objective); + } + Scoreboard.draw(); } @EventHandler public void soundOff(PlayerCommandPreprocessEvent event) { + if(!doVoices) return; + if (event.getMessage().equalsIgnoreCase("/voice")) { if (_soundOff.remove(event.getPlayer())) @@ -587,12 +634,12 @@ public class Halloween extends SoloGame } } - public void playSound(HalloweenAudio audio) + public void playSound(NamedAudio audio) { for (Player player : UtilServer.getPlayers()) if (!_soundOff.contains(player)) { - PacketPlayOutNamedSoundEffect packet = new PacketPlayOutNamedSoundEffect(audio.getName(), + PacketPlayOutNamedSoundEffect packet = new PacketPlayOutNamedSoundEffect(audio.getAudioPath(), player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ(), 20f, 1F); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/HalloweenAudio.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/HalloweenAudio.java index c737a3a68..0b51ac003 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/HalloweenAudio.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/HalloweenAudio.java @@ -1,6 +1,6 @@ package nautilus.game.arcade.game.games.halloween; -public enum HalloweenAudio +public enum HalloweenAudio implements NamedAudio { WAVE_1("halloween.wave1"), WAVE_2("halloween.wave2"), @@ -25,7 +25,7 @@ public enum HalloweenAudio _name = name; } - public String getName() + public String getAudioPath() { return _name; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/NamedAudio.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/NamedAudio.java new file mode 100644 index 000000000..ab4b6f987 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/NamedAudio.java @@ -0,0 +1,8 @@ +package nautilus.game.arcade.game.games.halloween; + +public interface NamedAudio +{ + + public String getAudioPath(); + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/CreatureBase.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/CreatureBase.java index fb4b3232c..69dd85093 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/CreatureBase.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/CreatureBase.java @@ -1,18 +1,22 @@ package nautilus.game.arcade.game.games.halloween.creatures; +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Location; +import org.bukkit.entity.Creature; +import org.bukkit.entity.Damageable; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityTargetEvent; + import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.game.games.halloween.Halloween; -import org.bukkit.Location; -import org.bukkit.entity.Creature; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.entity.EntityTargetEvent; -import org.bukkit.util.Vector; - public abstract class CreatureBase<T extends LivingEntity> { public Halloween Host; @@ -22,6 +26,8 @@ public abstract class CreatureBase<T extends LivingEntity> private Location _target; private long _targetTime; + + private List<Entity> _parts = new ArrayList<>(); public CreatureBase(Halloween game, String name, Class<T> mobClass, Location loc) { @@ -37,11 +43,39 @@ public abstract class CreatureBase<T extends LivingEntity> _ent.setCustomName(name); _ent.setCustomNameVisible(true); } + + addEntityPart(_ent); SpawnCustom(_ent); game.CreatureAllowOverride = false; } + + protected void addEntityPart(Entity ent) + { + if(_parts.contains(ent)) return; + _parts.add(ent); + } + + public List<Entity> getEntityParts() + { + return new ArrayList<>(_parts); + } + + public List<Player> getInsideBoundingBox() + { + List<Player> players = Host.GetPlayers(true); + List<Player> list = UtilEnt.getPlayersInsideEntity(_ent, players); + for(Entity ent : _parts) + { + players.removeAll(list); + if(players.isEmpty()) break; + + list.addAll(UtilEnt.getPlayersInsideEntity(ent, players)); + } + + return list; + } public abstract void SpawnCustom(T ent); @@ -114,8 +148,13 @@ public abstract class CreatureBase<T extends LivingEntity> public abstract void Damage(CustomDamageEvent event); public abstract void Target(EntityTargetEvent event); - + public void CreatureMove(Creature creature) + { + CreatureMove(creature, 1); + } + + public void CreatureMove(Creature creature, float speed) { //New Target SetTarget(GetRoamTarget()); @@ -131,8 +170,23 @@ public abstract class CreatureBase<T extends LivingEntity> //Move else { - UtilEnt.CreatureMove(creature, GetTarget(), 1f); + UtilEnt.CreatureMove(creature, GetTarget(), speed); Host.moves++; } } + + public void remove() + { + for(Entity ent : _parts) + { + if(ent instanceof Damageable) + { + ((Damageable) ent).damage(((Damageable) ent).getHealth()); + } + else + { + ent.remove(); + } + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/kits/KitRobinHood.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/kits/KitRobinHood.java index cd31b70d3..395bd2bc4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/kits/KitRobinHood.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/kits/KitRobinHood.java @@ -1,5 +1,12 @@ package nautilus.game.arcade.game.games.halloween.kits; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.inventory.ItemStack; + import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilMath; @@ -8,18 +15,12 @@ import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.smash.perks.skeleton.PerkBarrage; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.ProgressingKit; -import nautilus.game.arcade.kit.perks.PerkBarrage; import nautilus.game.arcade.kit.perks.PerkFletcher; import nautilus.game.arcade.kit.perks.PerkQuickshotRobinHood; -import org.bukkit.Material; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.inventory.ItemStack; public class KitRobinHood extends ProgressingKit { @@ -31,8 +32,8 @@ public class KitRobinHood extends ProgressingKit }; private static final Perk[] PERKS = { - new PerkFletcher(1, 8, true), - new PerkBarrage(8, 125, true, true), + new PerkFletcher(3, 6, true), + new PerkBarrage(8, 125, true, false), new PerkQuickshotRobinHood() }; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/kits/KitThor.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/kits/KitThor.java index 58bba7619..84ffe7f24 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/kits/KitThor.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/kits/KitThor.java @@ -32,7 +32,7 @@ public class KitThor extends ProgressingKit private static final Perk[] PERKS = { new PerkKnockbackAttack(2), - new PerkFletcher(2, 2, true, 9), + new PerkFletcher(2, 2, true, 8), new PerkSeismicHammer(), new PerkHammerThrow(), }; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/WaveBase.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/WaveBase.java index 3a8a07c4a..9d5a06b62 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/WaveBase.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/WaveBase.java @@ -1,6 +1,6 @@ package nautilus.game.arcade.game.games.halloween.waves; -import java.util.ArrayList; +import java.util.List; import org.bukkit.Location; import org.bukkit.Material; @@ -9,29 +9,40 @@ import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; import org.bukkit.util.Vector; -import nautilus.game.arcade.game.games.halloween.Halloween; -import nautilus.game.arcade.game.games.halloween.HalloweenAudio; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; +import nautilus.game.arcade.game.games.halloween.Halloween; +import nautilus.game.arcade.game.games.halloween.NamedAudio; public abstract class WaveBase { protected Halloween Host; protected String _name; - protected HalloweenAudio _audio; + protected boolean _displayWaveNumber = true; + protected boolean _announceWaveChat = true; + protected boolean _announceWaveTitle = true; + protected NamedAudio _audio; protected long _start; protected long _duration; private int _tick = 0; - protected ArrayList<Location> _spawns; + protected List<Location> _spawns; - public WaveBase(Halloween host, String name, long duration, ArrayList<Location> spawns, HalloweenAudio audio) + private boolean _spawnBeacons = true; + private boolean _announceStart = true; + private boolean _displayProgress = true; + + protected String _titleColor = C.cYellow; + + protected String[] _desc = null; + + public WaveBase(Halloween host, String name, long duration, List<Location> spawns, NamedAudio audio) { Host = host; @@ -66,22 +77,57 @@ public abstract class WaveBase if (_tick == 0) { System.out.println("Wave " + wave + " has started."); - Host.Announce(C.cRed + C.Bold + "Wave " + wave + ": " + C.cYellow + _name); - - UtilTextMiddle.display(C.cYellow + "Wave " + wave, _name, 10, 100, 20); - - if (_audio != null) - { - Host.playSound(_audio); + if(_announceStart) + { + if(_announceWaveChat) + { + String number = C.cRed + C.Bold + "Wave " + wave; + String name = C.cYellow + _name; + if(name != null) + { + number += ": "; + } + if(_name == null) name = ""; + if(!_displayWaveNumber) number = ""; + + String waveName = number + name; + + Host.Announce(waveName); + } + if(_desc != null) + { + for(String l : _desc) + { + Host.Announce(C.cGray + " ● " + C.cYellow + l); + } + } + + if(_announceWaveTitle) + { + String waveTitle = _displayWaveNumber ? _titleColor + "Wave " + wave : _name; + String waveSub = _displayWaveNumber ? _name : ""; + UtilTextMiddle.display(waveTitle, waveSub, 10, 100, 20); + } + + + if (_audio != null) + { + Host.playSound(_audio); + } } } //Display - for (Player player : UtilServer.getPlayers()) - player.setExp(Math.min(0.999f, (float)(_duration - (System.currentTimeMillis() - _start)) / (float)_duration)); + if(_displayProgress) + { + for (Player player : UtilServer.getPlayers()) + { + player.setExp(Math.min(0.999f, (float)(_duration - (System.currentTimeMillis() - _start)) / (float)_duration)); + } + } //Spawn Beacons - if (_tick == 0) + if (_tick == 0 && _spawnBeacons) SpawnBeacons(_spawns); //Spawn @@ -92,7 +138,7 @@ public abstract class WaveBase return false; } - public void SpawnBeacons(ArrayList<Location> locs) + public void SpawnBeacons(List<Location> locs) { //Average Location Vector total = new Vector(0,0,0); @@ -121,6 +167,36 @@ public abstract class WaveBase { return true; } + + public void setAnnounceStart(boolean announceStart) + { + _announceStart = announceStart; + } + + public void setDisplayProgress(boolean displayProgress) + { + _displayProgress = displayProgress; + } + + public void setSpawnBeacons(boolean spawnBeacons) + { + _spawnBeacons = spawnBeacons; + } + + public boolean getAnnounceStart() + { + return _announceStart; + } + + public boolean getDisplayProgress() + { + return _displayProgress; + } + + public boolean getSpawnBeacons() + { + return _spawnBeacons; + } public abstract void Spawn(int tick); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/WaveVictory.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/WaveVictory.java index 618658947..dada174c5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/WaveVictory.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/WaveVictory.java @@ -1,6 +1,9 @@ package nautilus.game.arcade.game.games.halloween.waves; +import java.util.List; + import org.bukkit.Effect; +import org.bukkit.Location; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -11,9 +14,9 @@ import nautilus.game.arcade.game.games.halloween.creatures.CreatureBase; public class WaveVictory extends WaveBase { - public WaveVictory(Halloween host) + public WaveVictory(Halloween host, List<Location> beaconSpawn) { - super(host, "Celebration!", 15000, host.GetSpawnSet(3), null); + super(host, "Celebration!", 15000, beaconSpawn, null); } @Override @@ -28,7 +31,7 @@ public class WaveVictory extends WaveBase player.playEffect(Host.WorldData.GetDataLocs("BLACK").get(0), Effect.RECORD_PLAY, 2259); //Mobs - for (CreatureBase<LivingEntity> mob : Host.GetCreatures()) + for (CreatureBase<? extends LivingEntity> mob : Host.GetCreatures()) mob.GetEntity().damage(5); //Time diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/Crypt.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/Crypt.java new file mode 100644 index 000000000..562bd08cc --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/Crypt.java @@ -0,0 +1,139 @@ +package nautilus.game.arcade.game.games.halloween2016; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.bukkit.Effect; +import org.bukkit.Location; +import org.bukkit.entity.Entity; + +import mineplex.core.common.block.schematic.Schematic; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextTop; +import mineplex.core.common.util.UtilTime; + +public class Crypt +{ + + private int _maxHealth = 2000; + private int _health = _maxHealth; + + private List<Schematic> _states; + private int _stateIndex = 0; + private Location _schematicBase; + + private Map<Entity, Integer> _damageCooldown = new HashMap<>(); + + private Halloween2016 _host; + + public Crypt(Halloween2016 host, Location base, List<Schematic> states) + { + _host = host; + _states = new ArrayList<>(); + _states.addAll(states); + _schematicBase = base.clone(); + } + + public boolean tryDamage(Entity mob, int damage, int cooldown) + { + if(isDestroyed()) return false; + Integer lastTime = _damageCooldown.get(mob); + if(lastTime != null && lastTime > UtilTime.getServerTick()) return false; + + _health -= damage; + _damageCooldown.put(mob, UtilTime.getServerTick() + cooldown); + + updateState(damage); + + return true; + } + + public void setHealth(int health) + { + int diff = _health-health; + _health = health; + updateState(diff); + } + + public void updateHealthDisplay() + { + UtilTextTop.displayProgress(C.cRed + C.Bold + "Crypt", getHealthProgress(), UtilServer.getPlayers()); + } + + public float getHealthProgress() + { + return Math.max(0, _health/ (float) _maxHealth); + } + + public int getMaxHealth() + { + return _maxHealth; + } + + public int getHealth() + { + return _health; + } + + public int getStateIndex() + { + return _stateIndex; + } + + public Location getSchematicBase() + { + return _schematicBase.clone(); + } + + public void updateState(int damage) + { + float prevProg = (damage + _health) / (float) _maxHealth; + float progress = getHealthProgress(); + + int state = (int) (_states.size() * (1-progress)); + if(state != _stateIndex && state < _states.size()) + { + _stateIndex = state; + _states.get(state).paste(_schematicBase, false, true); + } + + int iprog = (int) Math.ceil(progress*100); + int iprevProg = (int) Math.ceil(prevProg*100); + + if((iprog%10 == 0 || iprog <= 5) && iprevProg > iprog) + { + String color = C.cGreen; + if(iprog <= 60) color = C.cYellow; + if(iprog <= 30) color = C.cGold; + if(iprog <= 10) color = C.cRed; + + if(iprog == 0) + { + _host.Announce(F.main("Crypt", "The crypt has been destroyed!"), true); + } + else + { + _host.Announce(F.main("Crypt", "The crypt only has " + color + C.Bold + iprog + "%" + C.mBody + " left!"), true); + } + + if(iprog == 0) + { + for(Location loc : _host.getInfrontOfDoorTargets()) + { + loc.getWorld().playEffect(loc, Effect.EXPLOSION_HUGE, 0); + loc.getWorld().strikeLightningEffect(loc); + } + } + } + } + + public boolean isDestroyed() + { + return _health <= 0; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/Halloween2016.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/Halloween2016.java new file mode 100644 index 000000000..4fef083cc --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/Halloween2016.java @@ -0,0 +1,715 @@ +package nautilus.game.arcade.game.games.halloween2016; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.block.Block; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.Action; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +import mineplex.core.common.animation.AnimationPoint; +import mineplex.core.common.animation.Animator; +import mineplex.core.common.animation.AnimatorFactory; +import mineplex.core.common.block.schematic.Schematic; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.reward.RewardRarity; +import mineplex.core.reward.rewards.PetReward; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +import javafx.util.Pair; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.halloween.Halloween; +import nautilus.game.arcade.game.games.halloween.creatures.CreatureBase; +import nautilus.game.arcade.game.games.halloween.kits.KitFinn; +import nautilus.game.arcade.game.games.halloween.kits.KitRobinHood; +import nautilus.game.arcade.game.games.halloween.kits.KitThor; +import nautilus.game.arcade.game.games.halloween2016.creatures.MobPumpling; +import nautilus.game.arcade.game.games.halloween2016.tutorial.TutorialHalloween2016; +import nautilus.game.arcade.game.games.halloween2016.wave.Wave1; +import nautilus.game.arcade.game.games.halloween2016.wave.Wave2; +import nautilus.game.arcade.game.games.halloween2016.wave.Wave3; +import nautilus.game.arcade.game.games.halloween2016.wave.Wave4; +import nautilus.game.arcade.game.games.halloween2016.wave.Wave5; +import nautilus.game.arcade.game.games.halloween2016.wave.WaveBoss; +import nautilus.game.arcade.game.games.halloween2016.wave.WaveVictory; +import nautilus.game.arcade.kit.Kit; + +public class Halloween2016 extends Halloween +{ + + private List<PumpkinPlant> _pumpkins = new ArrayList<>(); + private Crypt _crypt; + + private Animator _introAnimator; + + private int _maxPumplings = 30; + private int _maxNonPumplings = 65; + + private double _mobCapMultiplier = 1; + private int _defaultMaxPlayerCount = 16; + + private List<MobPumpling> _pumplings = new ArrayList<>(); + private List<CreatureBase<?>> _nonPumplings = new ArrayList<>(); + + private List<List<Location>> _lanes = new ArrayList<>(); + + private Location _cryptView; + + private Location _lockAllPlayers = null; + private Map<Player, Pair<Location, GameMode>> _playerPreLockData = new HashMap<>(); + + private static boolean DO_TUTORIALS = true; + + public Halloween2016(ArcadeManager manager) + { + super(manager, GameType.Halloween2016, + new Kit[] + { + new KitFinn(manager), + new KitRobinHood(manager), + new KitThor(manager) + }, + new String[] + { + "Do not die.", + "Work as a team!", + "Defeat the waves of monsters", + "Kill the Pumpkin Prince", + "Destroy pumpkins by hitting them 3 times", + "Protect the crypt!" + } + ); + + _help = new String[] + { + C.cGreen + "Giants one hit kill you! Stay away!!!", + C.cAqua + "Work together with your teammates.", + C.cGreen + "Each kit gives a buff to nearby allies.", + C.cAqua + "Kill monsters to keep their numbers down.", + C.cGreen + "Giants instantly destroy the crypt! Kill them quickly!", + C.cAqua + "Defend your teammates from monsters.", + C.cGreen + "Zombies, Giants and Spiders get faster over time.", + C.cAqua + "Stick together to survive.", + C.cGreen + "The Pumpkin Prince gets harder over time!", + C.cAqua + "Protect the crypt to not lose the game!", + C.cGreen + "Pumplings spawn from pumpkins. Hit the pumpkins 3 times to prevent it from spawning.", + }; + + _updateCreatureMoveRate = UpdateType.TICK; + EnableTutorials = DO_TUTORIALS; + + doVoices = false; + } + + public void setObjective(String objective) + { + Objective = objective; + Announce(F.main("Objective", C.cYellow + C.Bold + objective)); + } + + public void unlockAllPlayers() + { + if(_lockAllPlayers == null) return; + + _lockAllPlayers = null; + for(Entry<Player, Pair<Location, GameMode>> e : _playerPreLockData.entrySet()) + { + e.getKey().teleport(e.getValue().getKey()); + e.getKey().setGameMode(e.getValue().getValue()); + if(IsAlive(e.getKey())) + { + UtilPlayer.showForAll(e.getKey()); + } + } + _playerPreLockData.clear(); + + Manager.getCosmeticManager().setHideParticles(false); + } + + public void lockAllPlayers(Location loc) + { + unlockAllPlayers(); + + _lockAllPlayers = loc; + + Manager.getCosmeticManager().setHideParticles(true); + } + + @EventHandler + public void lockPlayerTask(UpdateEvent event) + { + if(event.getType() != UpdateType.TICK) return; + + if(_lockAllPlayers != null) + { + for(Player p : Bukkit.getOnlinePlayers()) + { + if(!_playerPreLockData.containsKey(p)) + { + _playerPreLockData.put(p, new Pair<Location, GameMode>(p.getLocation(), p.getGameMode())); + p.setGameMode(GameMode.SPECTATOR); + } + p.teleport(_lockAllPlayers); + if(IsAlive(p)) + { + UtilPlayer.hideFromAll(p); + } + } + } + } + + @EventHandler + @Override + public void onGameStart(GameStateChangeEvent event) + { + super.onGameStart(event); + + if(event.GetState() != GameState.Live) return; + + _mobCapMultiplier = (double) GetPlayers(true).size() / (double) _defaultMaxPlayerCount; + if(_mobCapMultiplier < 0.5) + { + _mobCapMultiplier = 0.5; + } + + _maxNonPumplings *= _mobCapMultiplier; + _maxPumplings *= _mobCapMultiplier; + _maxMobs *= _mobCapMultiplier; + } + + public int getMaxPumplings() + { + return _maxPumplings; + } + + public void setMaxPumplings(int maxPumplings) + { + _maxPumplings = maxPumplings; + } + + @Override + public void ParseData() + { + List<Schematic> schematics = new ArrayList<>(); + Location doorSchematicLocation = getDoorSchematicLocation(); + _crypt = new Crypt(this, getDoorSchematicLocation(), schematics); + + for(Location loc : getPumkinSpawns()) + { + _pumpkins.add(new PumpkinPlant(this, loc)); + } + + _lanes.add(getBackLane()); + _lanes.add(getLeftLane()); + _lanes.add(getRightLane()); + _lanes.add(getMainLane()); + _lanes.add(getGraveLane()); + + _waves = new ArrayList<>(); + _waves.add(new Wave1(this)); + _waves.add(new Wave2(this)); + _waves.add(new Wave3(this)); + _waves.add(new Wave4(this)); + _waves.add(new Wave5(this)); + _waves.add(new WaveBoss(this)); + _waves.add(new WaveVictory(this, getMobSpawns())); + + _spawns = new ArrayList<>(); + + + CreatureAllowOverride = true; + ArmorStand bat = doorSchematicLocation.getWorld().spawn(doorSchematicLocation, ArmorStand.class); + CreatureAllowOverride = false; + UtilEnt.Vegetate(bat, true); + UtilEnt.setAI(bat, false); + UtilEnt.setTickWhenFarAway(bat, true); + bat.setRemoveWhenFarAway(false); + bat.setVisible(false); + + _introAnimator = new Animator(Manager.getPlugin()) + { + private int _tick = 0; + @Override + protected void tick(Location loc) + { + if(loc == null) return; + + for(Player p : Halloween2016.this.GetPlayers(false)) + { + if(p.getGameMode() != GameMode.SPECTATOR) p.setGameMode(GameMode.SPECTATOR); + if(!p.getAllowFlight()) p.setAllowFlight(true); + if(!p.isFlying()) p.setFlying(true); + + if(_tick%3 == 0) p.teleport(loc); + } + + _tick++; + } + + @Override + protected void finish(Location loc) + {} + }; + + _cryptView = WorldData.GetCustomLocs("CryptView").get(0); + _cryptView.setDirection(getClosest(_cryptView, "PINK").subtract(_cryptView).toVector()); + + AnimatorFactory factory = new AnimatorFactory(); + + double lastEntry = 0; + double firstEntry = Double.MAX_VALUE; + Location first = null; + + for(Entry<String, ArrayList<Location>> point : WorldData.GetAllCustomLocs().entrySet()) + { + String[] args = point.getKey().split(" "); + if(args.length < 2) continue; + if(args[0].equals("Intro")) + { + try + { + double sec = Double.parseDouble(args[1]); + double delay = 0; + try + { + delay = Double.parseDouble(args[2]); + } + catch(Exception e1) {} + int tick = (int) (sec*20); + int tickdelay = (int) (delay*20); + + Location loc = point.getValue().get(0); + Location lookingAt = getClosest(loc, "PINK"); + + loc.setDirection(lookingAt.subtract(loc).toVector()); + + factory.addLocation(loc, tick); + if(tickdelay > 0) factory.addLocation(loc, tickdelay); + + if(sec > lastEntry) lastEntry = sec; + if(delay > lastEntry) lastEntry = delay; + + if(sec < firstEntry) + { + firstEntry = sec; + first = loc.clone(); + } + } + catch(Exception e2) {} + } + } + + System.out.print("Scanned " + WorldData.GetAllCustomLocs().entrySet().size() + " data points"); + + List<AnimationPoint> animation = factory.getBuildList(first); + _introAnimator.addPoints(animation); + + System.out.println("Loaded intro animation with " + _introAnimator.getSet().size() + " | " + animation.size() + " points and duration of " + lastEntry + "s"); + + GameTeam team = GetTeamList().get(0); + team.setTutorial(new TutorialHalloween2016(this, _introAnimator, team, first, (int) (lastEntry * 20))); + } + + public Location getInfrontOfCrypt() + { + return WorldData.GetCustomLocs("PumpkinKing Win").get(0).clone(); + } + + public Location getPrinceTargetInfrontOfCrypt() + { + return WorldData.GetCustomLocs("PrinceTarget").get(0).clone(); + } + + public Location getPrinceSpawn() + { + return WorldData.GetCustomLocs("PrinceSpawn").get(0).clone(); + } + + + public Location getClosest(Location loc, String dataSet) + { + Location c = null; + double dist = 0; + for(Location l : WorldData.GetDataLocs(dataSet)) + { + double ldist = loc.distanceSquared(l); + if(c == null || ldist <= dist) + { + c = l; + dist = ldist; + } + } + if(c == null) return null; + return c.clone(); + } + + public Crypt getCrypt() + { + return _crypt; + } + + public Location getGiantSpawn() + { + return getMainLane().get(UtilMath.r(getMainLane().size())); + } + + public List<Location> getMainLane() + { + return WorldData.GetDataLocs("RED"); + } + + public List<Location> getLeftLane() + { + return WorldData.GetDataLocs("MAGENTA"); + } + + public List<Location> getBackLane() + { + return WorldData.GetDataLocs("LIGHT_BLUE"); + } + + public List<Location> getRightLane() + { + return WorldData.GetDataLocs("YELLOW"); + } + + public List<Location> getGraveLane() + { + return WorldData.GetDataLocs("MAGENTA"); + } + + public List<Location> getRandomLane() + { + List<Location> lane = new ArrayList<>(); + lane.addAll(_lanes.get(UtilMath.r(_lanes.size()))); + return lane; + } + + public List<Location> getMobSpawns() + { + List<Location> list = new ArrayList<>(); + for(List<Location> lane : _lanes) + { + list.addAll(lane); + } + return list; + } + + public List<Location> getPumkinSpawns() + { + return new ArrayList<>(WorldData.GetDataLocs("ORANGE")); + } + + public List<Location> getInfrontOfDoorTargets() + { + return new ArrayList<>(WorldData.GetDataLocs("BLUE")); + } + + public Location getDoorSchematicLocation() + { + return WorldData.GetCustomLocs("Door Schematic Paste").get(0).clone(); + } + + @EventHandler + public void updatePumpkinPlants(UpdateEvent event) + { + if(!IsLive()) return; + + if(event.getType() != UpdateType.TICK) return; + + List<PumpkinPlant> notGrowing = new ArrayList<>(); + int growing = 0; + for(PumpkinPlant plant : _pumpkins) + { + if(plant.isGrowing()) + { + growing++; + } + else + { + notGrowing.add(plant); + } + plant.tick(); + } + + if(!notGrowing.isEmpty() && growing + getPumplings().size() < getMaxPumplings()) + { + notGrowing.get(UtilMath.r(notGrowing.size())).startGrow(); + } + } + + public Location getCryptView() + { + return _cryptView.clone(); + } + + + @Override + @EventHandler + public void WaveUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + if (!IsLive()) + return; + + if(_crypt.isDestroyed() && !(_waves.get(_wave) instanceof WaveBoss) && !(_waves.get(_wave) instanceof WaveVictory)) + { + for(CreatureBase<?> c : _mobs) + { + c.remove(); + } + + Announce(F.main("Objective", C.cRed + C.Bold + "Objective failed!")); + endGame(GetTeam(ChatColor.RED)); + + return; + } + + super.WaveUpdate(event); + } + + + @EventHandler + public void onUpdateCrypt(UpdateEvent event) + { + if(event.getType() != UpdateType.TICK) return; + if(!IsLive()) return; + if(_crypt.isDestroyed()) return; + _crypt.updateHealthDisplay(); + } + + @EventHandler + public void onInteract(PlayerInteractEvent event) + { + if(event.getAction() != Action.LEFT_CLICK_BLOCK) return; + if(event.getClickedBlock() == null) return; + + Block block = event.getClickedBlock(); + + for(PumpkinPlant plant : _pumpkins) + { + plant.hit(block); + } + } + + @Override + public void AddCreature(CreatureBase<?> mob) + { + AddCreature(mob, true); + } + + public void AddCreature(CreatureBase<?> mob, boolean cap) + { + super.AddCreature(mob); + if(!cap) return; + + if(mob instanceof MobPumpling) + { + _pumplings.add((MobPumpling) mob); + } + else + { + _nonPumplings.add(mob); + } + } + + public List<MobPumpling> getPumplings() + { + return _pumplings; + } + + public List<CreatureBase<?>> getNonPumplings() + { + return _nonPumplings; + } + + + public int getMaxNonPumplings() + { + return _maxNonPumplings; + } + + @Override + public void onRemove(CreatureBase<?> mob) + { + _pumplings.remove(mob); + _nonPumplings.remove(mob); + } + + + @EventHandler + public void onCommand(PlayerCommandPreprocessEvent event) + { + if(!UtilServer.isTestServer()) return; + + + String[] args = event.getMessage().split(" "); + boolean orig = event.isCancelled(); + event.setCancelled(true); + if(args[0].equalsIgnoreCase("/setwave")) + { + if(event.getMessage().matches("/setwave [0-9]+")) + { + Announce(event.getPlayer().getName() + " set wave to " + args[1], true); + _wave = Integer.parseInt(args[1]); + } + else + { + event.getPlayer().sendMessage("Use /setwave #Wave"); + } + } + else if(args[0].equalsIgnoreCase("/god")) + { + Announce(event.getPlayer().getName() + " made everyone 'gods'", true); + for(Player p : GetPlayers(false)) + { + p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 99999, 200, true, false), true); + p.addPotionEffect(new PotionEffect(PotionEffectType.SATURATION, 99999, 200, true, false), true); + p.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 99999, 200, true, false), true); + } + } + else if(args[0].equalsIgnoreCase("/degod")) + { + Announce(event.getPlayer().getName() + " made everyone no longer 'gods'", true); + for(Player p : GetPlayers(false)) + { + p.removePotionEffect(PotionEffectType.REGENERATION); + p.removePotionEffect(PotionEffectType.SATURATION); + p.removePotionEffect(PotionEffectType.NIGHT_VISION); + } + } + else if(args[0].equals("/tutorial")) + { + if(args.length != 2) + { + event.getPlayer().sendMessage("Use /tutorial <true/false> - true = tutorial enabled before game"); + return; + } + if(args[1].equalsIgnoreCase("true") || args[1].equalsIgnoreCase("on")) + { + DO_TUTORIALS = true; + Announce(event.getPlayer().getName() + " enabled tutorials before games starts"); + } + else if(args[1].equalsIgnoreCase("false") || args[1].equalsIgnoreCase("off")) + { + DO_TUTORIALS = false; + Announce(event.getPlayer().getName() + " disabled tutorials before games starts"); + } + else + { + event.getPlayer().sendMessage("Use /tutorial <true/false> - true = tutorial enabled before game"); + } + + EnableTutorials = DO_TUTORIALS; + } + else + { + event.setCancelled(orig); + } + } + + @EventHandler + public void onDeath(EntityDeathEvent event) + { + if(event.getEntity().getKiller() != null) + { + AddGems(event.getEntity().getKiller(), 0.2, "Mobs Killed", true, true); + } + } + + @EventHandler(priority = EventPriority.MONITOR) + public void Clean(GameStateChangeEvent event) + {} + + @Override + @EventHandler(priority = EventPriority.MONITOR) + public void TeamGen(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Live) + return; + + GetTeamList().add(new GameTeam(this, "Pumpkin Prince", ChatColor.RED, WorldData.GetDataLocs("RED"))); + } + + @Override + public void EndCheck() + { + if (!IsLive()) + return; + + if (_wave >= _waves.size()) + { + for (Player player : GetPlayers(false)) + { + Manager.GetGame().AddGems(player, 30, "Killing the Pumpkin Prince", false, false); + Manager.GetGame().AddGems(player, 10, "Participation", false, false); + } + + if (Manager.IsRewardItems()) + { + SetCustomWinLine("You earned the Grim Reaper Pet!"); + + for (Player player : GetPlayers(false)) + { + //Prevent game hopping + if (!player.isOnline()) + continue; + + PetReward pr = new PetReward(Manager.getCosmeticManager().getPetManager(), Manager.getInventoryManager(), Manager.GetDonation(), "Grim Reaper", "Grim Reaper", EntityType.BLAZE, RewardRarity.OTHER, 0, 0); + + if (pr.canGiveReward(player)) + { + pr.giveReward(null, player, data -> {}); + } + } + } + + AnnounceEnd(this.GetTeamList().get(0)); + + SetState(GameState.End); + } + + else if (GetPlayers(true).size() == 0) + { + for (Player player : GetPlayers(false)) + { + Manager.GetGame().AddGems(player, 10, "Participation", false, false); + } + + AnnounceEnd(this.GetTeamList().get(1)); + + SetState(GameState.End); + } + } + + + + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/PumpkinPlant.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/PumpkinPlant.java new file mode 100644 index 000000000..73e9e6165 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/PumpkinPlant.java @@ -0,0 +1,93 @@ +package nautilus.game.arcade.game.games.halloween2016; + +import org.bukkit.Effect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.material.MaterialData; + +import nautilus.game.arcade.game.games.halloween2016.creatures.MobPumpling; + +public class PumpkinPlant +{ + private static final int GROWING_TICKS = 30 * 20; // 30 seconds + private static final int GLOW_TRANSITION_TIME = (int)Math.floor(GROWING_TICKS * .75); + + private Halloween2016 _game; + private int _age; + private Block _growing = null; + private int _health; + + public PumpkinPlant(Halloween2016 game, Location loc) + { + _growing = loc.getBlock(); + _game = game; + } + + public void startGrow() + { + if(isGrowing()) return; + + _growing.setType(Material.PUMPKIN); + + _health = 3; + } + + public boolean isGrowing() + { + return _growing != null &&_growing.getType() != Material.AIR; + } + + public void tick() + { + if(!isGrowing()) return; + + _age++; + + if (_age == GLOW_TRANSITION_TIME) + { + _growing.setType(Material.JACK_O_LANTERN); + } + + if (_age == GROWING_TICKS) + { + spawn(); + } + } + + public void spawn() + { + _growing.setType(Material.AIR); + + Location loc = _growing.getLocation().add(0.5, 0, 0.5); + + _game.AddCreature(new MobPumpling(_game, loc)); + + loc.getWorld().playEffect(loc, Effect.LARGE_SMOKE, 4); + } + + public void hit(Block block) + { + if(block.equals(_growing)) + { + _health--; + + Location loc = _growing.getLocation().add(0.5, 0, 0.5); + + if(_health <= 0) + { + _growing.setType(Material.AIR); + + loc.getWorld().playEffect(loc, Effect.TILE_BREAK, new MaterialData(Material.PUMPKIN)); + + _growing = null; + } + else + { + loc.getWorld().playSound(loc, Sound.DIG_WOOL, 1, 1); + } + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/creatures/CryptBreaker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/creatures/CryptBreaker.java new file mode 100644 index 000000000..5dd31ea1c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/creatures/CryptBreaker.java @@ -0,0 +1,256 @@ +package nautilus.game.arcade.game.games.halloween2016.creatures; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.entity.Creature; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityTargetEvent; + +import mineplex.core.common.util.UtilEnt; +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.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.games.halloween.creatures.CreatureBase; +import nautilus.game.arcade.game.games.halloween.creatures.InterfaceMove; +import nautilus.game.arcade.game.games.halloween2016.Crypt; +import nautilus.game.arcade.game.games.halloween2016.Halloween2016; +import net.minecraft.server.v1_8_R3.PacketPlayOutAnimation; + +public abstract class CryptBreaker<T extends Creature> extends CreatureBase<T> implements InterfaceMove +{ + + protected final Crypt _crypt; + protected final List<Location> _doorLocations = new ArrayList<>(); + + protected final int _cryptDamage; + protected final int _cryptDamageRate; + + protected double _playerTargetForwardRange = 4; + protected double _playerTargetBackRange = 1; + protected double _playerFollowRange = 5; + + protected double _customCryptRange = -1; + + protected double _extraDamage; + + protected float _speed; + + protected boolean _targetPlayers = true; + + protected Halloween2016 Host16; + + public CryptBreaker(Halloween2016 game, String name, Class<T> mobClass, Location loc, int cryptDamage, int cryptDamageRate, float speed) + { + super(game, name, mobClass, loc); + _crypt = game.getCrypt(); + _doorLocations.addAll(game.getInfrontOfDoorTargets()); + _cryptDamage = cryptDamage; + _cryptDamageRate = cryptDamageRate; + _speed = speed; + Host16 = game; + + Creature ent = GetEntity(); + UtilEnt.setTickWhenFarAway(ent, true); + ent.setRemoveWhenFarAway(false); + } + + @Override + public void SpawnCustom(T ent) + {} + + @Override + public void Update(UpdateEvent event) + { + if(event.getType() != UpdateType.TICK) return; + + if(inCryptRange()) + { + attackCrypt(); + } + } + + public boolean inCryptRange() + { + double width = UtilEnt.getWidth(GetEntity()); + if(_customCryptRange != -1) + { + width = _customCryptRange; + } + + if(getClosestDoor().distanceSquared(GetEntity().getLocation()) <= width*width) + { + return true; + } + return false; + } + + public void attackCrypt() + { + if(!_crypt.tryDamage(GetEntity(), _cryptDamage, _cryptDamageRate)) return; + + GetEntity().getWorld().playSound(GetEntity().getLocation(), Sound.ZOMBIE_WOODBREAK, 1, 0.7f + UtilMath.random.nextFloat() * 0.5f); + swingArms(); + } + + public void swingArms() + { + PacketPlayOutAnimation packet = new PacketPlayOutAnimation(); + packet.a = GetEntity().getEntityId(); + packet.b = 0; + + for(Player p : Host.GetPlayers(false)) + { + UtilPlayer.sendPacket(p, packet); + } + } + + @Override + public void Damage(CustomDamageEvent event) + { + if(_extraDamage > 0) + { + if(GetEntity().equals(event.GetDamagerEntity(true))) + { + event.AddMod("Mod", _extraDamage); + } + } + } + + @Override + public void Target(EntityTargetEvent event) + { + if(_crypt.isDestroyed()) return; + + if(!event.getEntity().equals(GetEntity())) return; + if(event.getTarget() == null) return; + + if(!_targetPlayers) + { + event.setCancelled(true); + return; + } + + if(!(event.getTarget() instanceof Player)) + { + event.setCancelled(true); + return; + } + + if(inCryptRange()) + { + event.setCancelled(true); + return; + } + + Location door = getClosestDoor(); + Location target = event.getTarget().getLocation(); + if(target.distanceSquared(door) - _playerTargetBackRange*_playerTargetBackRange > door.distanceSquared(GetEntity().getLocation())) + { + event.setCancelled(true); + return; + } + if(target.distanceSquared(GetEntity().getLocation()) <= _playerTargetForwardRange*_playerTargetForwardRange) + { + event.setCancelled(true); + return; + } + } + + @Override + public Location GetRoamTarget() + { + if(_crypt.isDestroyed()) return GetPlayerTarget(); + + Location door = getClosestDoor(); + double distDoor = door.distanceSquared(GetEntity().getLocation()); + + if(!_targetPlayers) return door; + + Player player = null; + double distance = -1; + + for(Player p : Host.GetPlayers(true)) + { + if(p.getLocation().distanceSquared(door) - _playerTargetBackRange*_playerTargetBackRange > distDoor) continue; + + double dist = GetEntity().getLocation().distanceSquared(p.getLocation()); + if(player == null || dist < distance) + { + player = p; + distance = dist; + } + } + + if(player != null && distance <= _playerTargetForwardRange*_playerTargetForwardRange) + { + GetEntity().setTarget(player); + return player.getLocation(); + } + + return door; + } + + @Override + public void Move() + { + if(_crypt.isDestroyed()) + { + CreatureMove(GetEntity()); + return; + } + + Location door = getClosestDoor(); + double distDoor = door.distanceSquared(GetEntity().getLocation()); + if(GetEntity().getTarget() != null) + { + Location target = GetEntity().getTarget().getLocation(); + if(target.distanceSquared(door) - _playerFollowRange*_playerFollowRange > distDoor) + { + GetEntity().setTarget(null); + SetTarget(GetRoamTarget()); + } + } + + if(GetEntity().getTarget() == null) + { + SetTarget(GetRoamTarget()); + } + + if(_customCryptRange > 0) + { + if(distDoor <= _customCryptRange*_customCryptRange) + { + SetTarget(GetEntity().getLocation()); + } + } + + if(GetTarget() != null) + { + UtilEnt.CreatureMove(GetEntity(), GetTarget(), _speed); + Host.moves++; + } + } + + public Location getClosestDoor() + { + Location loc = GetEntity().getLocation(); + Location door = null; + double dist = -1; + for(Location d : _doorLocations) + { + double testDist = d.distanceSquared(loc); + if(door == null || testDist < dist) + { + door = d; + dist = testDist; + } + } + return door.clone(); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/creatures/MobBlaze.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/creatures/MobBlaze.java new file mode 100644 index 000000000..af79dd420 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/creatures/MobBlaze.java @@ -0,0 +1,23 @@ +package nautilus.game.arcade.game.games.halloween2016.creatures; + +import org.bukkit.Location; +import org.bukkit.entity.Blaze; + +import mineplex.core.common.util.C; + +import nautilus.game.arcade.game.games.halloween2016.Halloween2016; + +public class MobBlaze extends CryptBreaker<Blaze> +{ + + private static int CRYPT_DAMAGE = 10; + private static int CRYPT_RATE = 30; + + private static float SPEED = 1; + + public MobBlaze(Halloween2016 game, Location loc) + { + super(game, C.cYellow + "Blaze", Blaze.class, loc, CRYPT_DAMAGE, CRYPT_RATE, SPEED); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/creatures/MobCreeper.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/creatures/MobCreeper.java new file mode 100644 index 000000000..01af9bb08 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/creatures/MobCreeper.java @@ -0,0 +1,83 @@ +package nautilus.game.arcade.game.games.halloween2016.creatures; + +import java.lang.reflect.Method; + +import net.minecraft.server.v1_8_R3.EntityCreeper; + +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftCreeper; +import org.bukkit.entity.Creeper; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilReflection; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +import nautilus.game.arcade.game.games.halloween2016.Halloween2016; + +public class MobCreeper extends CryptBreaker<Creeper> +{ + + public static final int CRYPT_DAMAGE = 200; + public static float SPEED = 0.8f; + + private boolean exploded = false; + + public MobCreeper(Halloween2016 game, Location loc) + { + super(game, C.cYellow + "Creeper", Creeper.class, loc, 0, 0, SPEED); + + _extraDamage = 5; + + _targetPlayers = false; + } + + + @Override + public void Update(UpdateEvent event) + { + if(event.getType() != UpdateType.TICK) return; + + if(_crypt.isDestroyed()) return; + + double width = UtilEnt.getWidth(GetEntity()); + + EntityCreeper c = ((CraftCreeper)GetEntity()).getHandle(); + if(getClosestDoor().distanceSquared(GetEntity().getLocation()) <= width*width) + { + c.co(); + } + + int fuse = (int) UtilReflection.getValueOfField(c, "fuseTicks"); + int max = (int) UtilReflection.getValueOfField(c, "maxFuseTicks"); + + if(fuse >= max-1) + { + _crypt.tryDamage(GetEntity(), CRYPT_DAMAGE, 0); + exploded = true; + } + } + + @Override + public void remove() + { + if(!exploded && GetEntity().isDead()) + { + //Make creeper explode, even if dead using NMS code + try + { + EntityCreeper nms = ((CraftCreeper)GetEntity()).getHandle(); + Method explodeMethod = nms.getClass().getDeclaredMethod("cr"); + explodeMethod.setAccessible(true); + explodeMethod.invoke(nms); + } + catch(Exception e) + { + e.printStackTrace(); + } + } + super.remove(); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/creatures/MobGiant.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/creatures/MobGiant.java new file mode 100644 index 000000000..6f6a41af4 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/creatures/MobGiant.java @@ -0,0 +1,190 @@ +package nautilus.game.arcade.game.games.halloween2016.creatures; + +import java.util.List; + +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.entity.Giant; +import org.bukkit.entity.Player; +import org.bukkit.entity.Zombie; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilText; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.games.halloween2016.Halloween2016; + +public class MobGiant extends CryptBreaker<Giant> +{ + + //Instant destroy crypt + public static final int CRYPT_DAMAGE = 100000; + public static final int CRYPT_DAMAGE_COOLDOWN = 1; + public static final float SPEED = 0.5f; + + private static double DAMAGE = 9000; + private static double KNOCKBACK = 8; + private static double HEALTH = 200; + + private static float EXTRA_EXPLOSION_DAMAGE = 10; + + private boolean _cryptDestroyed = false; + + private Zombie _pathDummy; + + private Player _target; + + public MobGiant(Halloween2016 game, Location loc) + { + super(game, null, Giant.class, loc, CRYPT_DAMAGE, CRYPT_DAMAGE_COOLDOWN, SPEED); + + _customCryptRange = 3; + } + + @Override + public void SpawnCustom(Giant ent) + { + _pathDummy = ent.getWorld().spawn(ent.getLocation(), Zombie.class); + + super.Host.Manager.GetCondition().Factory().Invisible("Cloak", _pathDummy, _pathDummy, 999999, 0, false, false, false); + _pathDummy.setCustomNameVisible(true); + + ent.setMaxHealth(HEALTH); + ent.setHealth(ent.getMaxHealth()); + + UtilEnt.setBoundingBox(_pathDummy, 0, 0); + UtilEnt.Vegetate(_pathDummy, true); + UtilEnt.setStepHeight(_pathDummy, 1); + + //Prevent other mobs from pushing the giant + UtilEnt.ghost(_pathDummy, true, true); + + _pathDummy.setRemoveWhenFarAway(false); + UtilEnt.setTickWhenFarAway(_pathDummy, true); + + addEntityPart(_pathDummy); + } + + @Override + public void Update(UpdateEvent event) + { + if(event.getType() == UpdateType.TICK) + { + move(); + updateHealthBar(); + } + + if(!_cryptDestroyed && _crypt.isDestroyed()) + { + SetTarget(null); + _cryptDestroyed = true; + } + + } + + private Player getRandomPlayer() + { + List<Player> players = Host.GetPlayers(true); + return players.get(UtilMath.r(players.size())); + } + + private void move() + { + if(_target != null) + { + if(!_target.isOnline() || !_target.isValid() || !Host.GetPlayers(true).contains(_target)) + { + _target = null; + } + } + + Location target = GetTarget(); + if(target == null && _target == null) + { + if(_crypt.isDestroyed()) + { + _target = getRandomPlayer(); + } + else + { + target = getClosestDoor(); + + } + SetTarget(target); + } + if(_target != null) + { + target = _target.getLocation(); + } + UtilEnt.CreatureMove(_pathDummy, target, SPEED); + GetEntity().teleport(_pathDummy); + + if(!_crypt.isDestroyed()) + { + if(getClosestDoor().distanceSquared(GetEntity().getLocation()) <= _customCryptRange*_customCryptRange) + { + if(!_crypt.tryDamage(GetEntity(), _cryptDamage, _cryptDamageRate)) return; + + GetEntity().getWorld().playSound(GetEntity().getLocation(), Sound.ZOMBIE_WOODBREAK, 1, 0.7f + UtilMath.random.nextFloat() * 0.5f); + swingArms(); + } + } + + boolean hit = false; + + for(Player p : getInsideBoundingBox()) + { + Host.getArcadeManager().GetDamage().NewDamageEvent(p, GetEntity(), null, GetEntity().getLocation(), DamageCause.ENTITY_ATTACK, DAMAGE, true, false, false, "Giant", "Giant Damage", false); + hit = true; + } + if(hit) + { + swingArms(); + GetEntity().getWorld().playSound(GetEntity().getLocation(), Sound.ZOMBIE_IDLE, 2, 0.5f); + } + } + + @Override + public void Move() + {} + + @Override + public void Damage(CustomDamageEvent event) + { + if(_pathDummy.equals(event.GetDamageeEntity())) + { + event.SetCancelled("Invalid Entity"); + return; + } + if(event.GetDamageeEntity().equals(GetEntity())) + { + event.SetKnockback(false); + + if(event.GetCause() == DamageCause.SUFFOCATION) + { + event.SetCancelled("Invalid Giant Damage"); + return; + } + else if(event.GetCause() == DamageCause.ENTITY_EXPLOSION) + { + event.AddMod("Explosion", EXTRA_EXPLOSION_DAMAGE); + } + } + + if(!GetEntity().equals(event.GetDamagerEntity(false))) return; + + event.SetKnockback(true); + event.AddKnockback("Giant Knockback", KNOCKBACK); + } + + public void updateHealthBar() + { + _pathDummy.setCustomName(UtilText.getProgress(C.cGreen, GetEntity().getHealth()/GetEntity().getMaxHealth(), C.cGray, false)); + } + + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/creatures/MobMiniZombie.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/creatures/MobMiniZombie.java new file mode 100644 index 000000000..63a4bad70 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/creatures/MobMiniZombie.java @@ -0,0 +1,70 @@ +package nautilus.game.arcade.game.games.halloween2016.creatures; + +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.entity.Zombie; +import org.bukkit.event.entity.EntityTargetEvent; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import nautilus.game.arcade.game.games.halloween.Halloween; +import nautilus.game.arcade.game.games.halloween.creatures.CreatureBase; +import nautilus.game.arcade.game.games.halloween.creatures.InterfaceMove; + +public class MobMiniZombie extends CreatureBase<Zombie> implements InterfaceMove +{ + + private static final double HEALTH = 5; + + public MobMiniZombie(Halloween game, Location loc) + { + super(game, C.cYellow + "Baby Zombie", Zombie.class, loc); + } + + @Override + public void SpawnCustom(Zombie ent) + { + ent.setBaby(true); + + ent.setMaxHealth(HEALTH); + ent.setHealth(HEALTH); + } + + @Override + public void Update(UpdateEvent event) + { + + } + + @Override + public void Damage(CustomDamageEvent event) + { + + } + + @Override + public void Target(EntityTargetEvent event) + { + + } + + @Override + public void Move() + { + CreatureMove(GetEntity(), 1f); + } + + @Override + public void remove() + { + super.remove(); + UtilParticle.PlayParticleToAll(ParticleType.LARGE_SMOKE, GetEntity().getLocation(), null, 0.1f, 10, ViewDist.NORMAL); + GetEntity().getWorld().playSound(GetEntity().getLocation(), Sound.FIZZ, 0.8f, 0.3f); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/creatures/MobPigZombie.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/creatures/MobPigZombie.java new file mode 100644 index 000000000..369f7e102 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/creatures/MobPigZombie.java @@ -0,0 +1,72 @@ +package nautilus.game.arcade.game.games.halloween2016.creatures; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.entity.Zombie; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.disguise.disguises.DisguisePigZombie; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.games.halloween2016.Halloween2016; + +public class MobPigZombie extends CryptBreaker<Zombie> +{ + + private static float SPEED = 1; + private static int CRYPT_DAMAGE = 3; + private static int CRYPT_RATE = 20; + + private static int FIRE_TICKS = 60; + + public MobPigZombie(Halloween2016 game, Location loc) + { + super(game, C.cYellow + "Pigman Warrior", Zombie.class, loc, CRYPT_DAMAGE, CRYPT_RATE, SPEED); + + _extraDamage = 5; + } + + @Override + public void SpawnCustom(Zombie ent) + { + ent.getEquipment().setItemInHand(new ItemStack(Material.GOLD_SWORD)); + + DisguisePigZombie disg = new DisguisePigZombie(ent); + Host.getArcadeManager().GetDisguise().disguise(disg); + } + + @Override + public void Update(UpdateEvent event) + { + super.Update(event); + if(event.getType() == UpdateType.TICK) + { + GetEntity().setFireTicks(5); + } + } + + @Override + public void Damage(CustomDamageEvent event) + { + if(event.GetDamageeEntity() instanceof Player) + { + if(GetEntity().equals(event.GetDamagerEntity(false))) + { + event.GetDamageeEntity().setFireTicks(FIRE_TICKS); + } + } + + else if(GetEntity().equals(event.GetDamageeEntity())) + { + if(event.GetCause() == DamageCause.FIRE || event.GetCause() == DamageCause.FIRE_TICK) + { + event.SetCancelled("Cancel Fire"); + } + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/creatures/MobPrinceGuard.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/creatures/MobPrinceGuard.java new file mode 100644 index 000000000..36c04abfa --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/creatures/MobPrinceGuard.java @@ -0,0 +1,236 @@ +package nautilus.game.arcade.game.games.halloween2016.creatures; + +import java.util.List; + +import net.minecraft.server.v1_8_R3.PacketPlayOutAnimation; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Horse.Variant; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; +import org.bukkit.entity.Zombie; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityTargetEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; +import org.spigotmc.event.entity.EntityDismountEvent; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.disguise.disguises.DisguiseHorse; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import nautilus.game.arcade.game.games.halloween.Halloween; +import nautilus.game.arcade.game.games.halloween.creatures.CreatureBase; + +public class MobPrinceGuard extends CreatureBase<Skeleton> +{ + + private Zombie _horse; + private DisguiseHorse _horseDisguise; + + private MobPumpkinPrince _prince; + private Entity _target; + + private Location _strikeTarget; + private long _strikeStamp; + + private boolean _AI = true; + + private final static float HORSE_SPEED = 1.8f; + private final static float HORSE_SPEED_CHARGE = 2.3f; + private final static double STRIKE_RANGE = 10; + private final static long MAX_STRIKE_TIME = 10_000; + private final static long STRIKE_COOLDOWN = 15_000; + private final static double DAMAGE = 5; + private final static double KNOCKBACK = 3; + private final static double HEALTH = 50; + + public MobPrinceGuard(Halloween game, Location loc, MobPumpkinPrince prince) + { + super(game, C.cYellow + C.Bold + "Prince Guard", Skeleton.class, loc); + _prince = prince; + } + + public Zombie getHorse() + { + return _horse; + } + + @Override + public void SpawnCustom(Skeleton ent) + { + ent.getEquipment().setItemInHand(new ItemStack(Material.IRON_SWORD)); + ent.getEquipment().setHelmet(new ItemStack(Material.PUMPKIN)); + + _horse = ent.getWorld().spawn(ent.getLocation(), Zombie.class); + + _horseDisguise = new DisguiseHorse(_horse); + _horseDisguise.setType(Variant.SKELETON_HORSE); + Host.getArcadeManager().GetDisguise().disguise(_horseDisguise); + + _horse.setRemoveWhenFarAway(false); + UtilEnt.setTickWhenFarAway(_horse, true); + + UtilEnt.setStepHeight(_horse, 1); + UtilEnt.setBoundingBox(_horse, 0, 0); + + UtilEnt.setTickWhenFarAway(ent, true); + ent.setRemoveWhenFarAway(true); + + ent.setMaxHealth(HEALTH); + ent.setHealth(ent.getMaxHealth()); + + _horse.setPassenger(ent); + + _horse.setVegetated(true); + //UtilEnt#silence doesn't seem to work. Using native silence instead + ((CraftEntity)_horse).getHandle().b(true); + + addEntityPart(_horse); + } + + public void setAI(boolean aI) + { + _AI = aI; + } + + public boolean getAI() + { + return _AI; + } + + @Override + public void Update(UpdateEvent event) + { + if(event.getType() != UpdateType.TICK) return; + + if(!_AI) return; + + if(_strikeTarget != null) + { + if(_strikeStamp < System.currentTimeMillis()) + { + _strikeTarget = null; + } + else if(UtilEnt.canEntityWalkCloserToNavigationTarget(_horse)) + { + _strikeTarget = null; + return; + } + else + { + _horse.getWorld().playSound(_horse.getLocation(), Sound.FIZZ, 0.2f, 1f); + _horse.getWorld().playSound(_horse.getLocation(), Sound.SKELETON_WALK, 0.2f, 0.5f); + + UtilParticle.PlayParticleToAll(ParticleType.SMOKE, _horse.getLocation(), null, 0.1f, 5, ViewDist.NORMAL); + UtilParticle.PlayParticleToAll(ParticleType.FLAME, _horse.getLocation(), null, 0.1f, 5, ViewDist.NORMAL); + } + } + + List<Player> inGame = Host.GetPlayers(true); + if(_target == null || !inGame.contains(_target)) + { + double dist = 0; + for(Player p : inGame) + { + double d = p.getLocation().distanceSquared(_prince.getHorse().getLocation()); + if(_target == null || dist > d) + { + dist = d; + _target = p; + } + } + } + Location target = _target.getLocation(); + Vector diff = target.clone().subtract(_horse.getLocation()).toVector(); + if(_strikeStamp + STRIKE_COOLDOWN > System.currentTimeMillis() || diff.lengthSquared() >= STRIKE_RANGE*STRIKE_RANGE) + { + diff.normalize().multiply(STRIKE_RANGE*2); + target.add(diff); + SetTarget(target); + + UtilEnt.CreatureMove(_horse, GetTarget(), HORSE_SPEED); + } + else + { + _target = null; + + _strikeTarget = target; + _strikeStamp = System.currentTimeMillis() + MAX_STRIKE_TIME; + + UtilEnt.CreatureMove(_horse, GetTarget(), HORSE_SPEED_CHARGE); + } + + for(Player p : getInsideBoundingBox()) + { + Host.getArcadeManager().GetDamage().NewDamageEvent(p, _horse, null, _horse.getLocation(), DamageCause.ENTITY_ATTACK, DAMAGE, true, false, false, "Prince Guard", "Horse Kick", false); + } + } + + @Override + public void Damage(CustomDamageEvent event) + { + if(_horse.equals(event.GetDamageeEntity())) + { + event.setDamagee(GetEntity()); + } + + if(GetEntity().equals(event.GetDamageeEntity())) + { + if(_prince.equals(event.GetDamagerEntity(true))) + { + if(event.GetProjectile() != null) + { + event.GetProjectile().setFireTicks(0); + } + event.SetCancelled("Cancel"); + return; + } + + if(!_AI) + { + event.SetCancelled("No AI"); + return; + } + + if(!event.isCancelled() && _horse != null && _horse.isValid()) + { + PacketPlayOutAnimation hurt = new PacketPlayOutAnimation(); + hurt.a = _horseDisguise.getEntityId(); + hurt.b = 1; + _horseDisguise.sendPacket(hurt); + } + } + + else if(event.GetDamageeEntity() instanceof Player) + { + if(_horse.equals(event.GetDamagerEntity(false))) + { + event.AddKnockback("Horse Knockback", KNOCKBACK); + } + } + } + + @Override + public void Target(EntityTargetEvent event) + {} + + @EventHandler + public void onDismount(EntityDismountEvent event) + { + if(event.getDismounted().equals(GetEntity())) event.setCancelled(true); + } + + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/creatures/MobPumpkinPrince.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/creatures/MobPumpkinPrince.java new file mode 100644 index 000000000..a09970660 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/creatures/MobPumpkinPrince.java @@ -0,0 +1,478 @@ +package nautilus.game.arcade.game.games.halloween2016.creatures; + +import net.minecraft.server.v1_8_R3.PacketPlayOutAnimation; + +import org.bukkit.Effect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.BlockFace; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftZombie; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Fireball; +import org.bukkit.entity.Horse.Variant; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; +import org.bukkit.entity.Skeleton.SkeletonType; +import org.bukkit.entity.Snowball; +import org.bukkit.entity.Zombie; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.entity.EntityTargetEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.util.Vector; +import org.spigotmc.event.entity.EntityDismountEvent; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilItem; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextTop; +import mineplex.core.disguise.disguises.DisguiseHorse; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import nautilus.game.arcade.game.games.halloween.creatures.CreatureBase; +import nautilus.game.arcade.game.games.halloween2016.Halloween2016; + +public class MobPumpkinPrince extends CreatureBase<Skeleton> implements Listener +{ + + private Halloween2016 Host; + + private Zombie _horse; + private DisguiseHorse _horseDisguise; + + private boolean _AI = false; + private boolean _invulnerable = false; + + private long _horseKick = 0; + private static final long HORSE_KICK_DURATION = 1000; + + private static final double HORSE_KICK_DAMAGE = 5; + + private static final float HORSE_SPEED = 1.5f; + + private static final double STAGE_3_KNOCKBACK = 3; + private static final double HORSE_KNOCKBACK = 3; + + private static final double HEALTH = 1000; + + + public MobPumpkinPrince(Halloween2016 game, Location loc) + { + super(game, C.cRed + C.Bold + "Pumpkin Prince", Skeleton.class, loc); + Host = game; + } + + @Override + public void SpawnCustom(Skeleton ent) + { + ent.getEquipment().setHelmet(new ItemStack(Material.PUMPKIN)); + ent.getEquipment().setItemInHand(new ItemStack(Material.BOW)); + + ent.setMaxHealth(HEALTH); + ent.setHealth(ent.getMaxHealth()); + + ent.setSkeletonType(SkeletonType.WITHER); + + + super.Host.CreatureAllowOverride = true; + _horse = ent.getWorld().spawn(ent.getLocation(), Zombie.class); + super.Host.CreatureAllowOverride = false; + + _horseDisguise = new DisguiseHorse(_horse); + _horseDisguise.setType(Variant.SKELETON_HORSE); + + super.Host.getArcadeManager().GetDisguise().disguise(_horseDisguise); + + UtilEnt.setStepHeight(ent, 1); + UtilEnt.setStepHeight(_horse, 1); + + UtilEnt.setBoundingBox(_horse, 0, 0); + + //For some reason 'UtilEnt.silence' doesn't work, so using native silence instead + //UtilEnt.silence(_horse, true); + ((CraftZombie)_horse).getHandle().b(true); + + _horse.setPassenger(ent); + UtilEnt.Vegetate(_horse); + + UtilServer.RegisterEvents(this); + + UtilEnt.setTickWhenFarAway(ent, true); + ent.setRemoveWhenFarAway(false); + UtilEnt.setTickWhenFarAway(_horse, true); + _horse.setRemoveWhenFarAway(false); + + addEntityPart(_horse); + } + + public void setInvulnerable(boolean invulnerable) + { + _invulnerable = invulnerable; + } + + public boolean isInvulnerable() + { + return _invulnerable; + } + + public void setAI(boolean AI) + { + _AI = AI; + } + + public boolean getAI() + { + return _AI; + } + + @Override + public void Update(UpdateEvent event) + { + if(!_AI) return; + + if(event.getType() != UpdateType.TICK) return; + + UtilTextTop.displayProgress(C.cYellow + C.Bold + "Pumpkin Prince", getHealthProgress(), UtilServer.getPlayers()); + + int state = getState(); + + if(_horse.isValid() && state > 1) + { + _horse.getWorld().playSound(_horse.getLocation(), Sound.BLAZE_DEATH, 3, 1); + UtilParticle.PlayParticleToAll(ParticleType.LARGE_SMOKE, _horse.getLocation(), null, 0.5f, 20, ViewDist.NORMAL); + _horse.setHealth(0); + } + + if(state == 1) + { + Entity target = GetEntity().getTarget(); + if(target != null) + { + UtilEnt.CreatureMove(_horse, GetEntity().getTarget().getLocation(), HORSE_SPEED); + + boolean hit = false; + + for(Player p : getInsideBoundingBox()) + { + CustomDamageEvent dmgEvent = Host.getArcadeManager().GetDamage().NewDamageEvent(p, _horse, null, GetEntity().getLocation(), DamageCause.ENTITY_ATTACK, HORSE_KICK_DAMAGE, true, false, false, "Pumpkin Prince", "Horse Kick", false); + if(dmgEvent.isCancelled()) continue; + hit = true; + } + if(hit) + { + _horseKick = System.currentTimeMillis(); + + _horseDisguise.kick(); + Host.getArcadeManager().GetDisguise().updateDisguise(_horseDisguise); + + _horse.getWorld().playSound(_horse.getLocation(), Sound.SKELETON_HURT, 4f, 0.6f); + _horse.getWorld().playSound(_horse.getLocation(), Sound.SKELETON_HURT, 4f, 0.6f); + } + + if(_horseKick + HORSE_KICK_DURATION < System.currentTimeMillis()) + { + _horseDisguise.stopKick(); + Host.getArcadeManager().GetDisguise().updateDisguise(_horseDisguise); + } + + if(GetEntity().getTicksLived() % 15 == 0) + { + if(target.getLocation().distanceSquared(GetEntity().getLocation()) > 40*40) return; + + Arrow a = GetEntity().launchProjectile(Arrow.class); + + Vector force = UtilAlg.getTrajectory(GetEntity(), target).add(new Vector(0, 0.2, 0)); + a.setVelocity(force); + + a.setFireTicks(99999); + } + + } + else + { + GetEntity().setTarget(getRandomPlayer()); + } + } + else if(state == 2) + { + if(GetEntity().getTicksLived() % (20*5) == 0) + { + for(int i = 0; i < 64; i++) + { + if(tryRandomTeleport()) break; + } + } + if(GetEntity().getTicksLived() % 25 == 0) + { + Vector v = GetPlayerTarget().subtract(GetEntity().getLocation()).toVector().multiply(0.01); + + Location loc = GetEntity().getLocation(); + loc.setDirection(v); + GetEntity().teleport(loc); + GetEntity().launchProjectile(Fireball.class, v); + } + } + else if(state == 3) + { + if(GetEntity().getTicksLived() % 20*10 == 0) + { + GetEntity().setTarget(getRandomPlayer()); + } + } + } + + public Player getRandomPlayer() + { + return Host.GetPlayers(true).get(UtilMath.r(Host.GetPlayers(true).size())); + } + + private boolean tryRandomTeleport() + { + Location loc = GetPlayerTarget(); + loc.add((UtilMath.random.nextDouble() - 0.5) * 64, UtilMath.r(64)-32, (UtilMath.random.nextDouble() - 0.5) * 64); + + for(int y = loc.getBlockY(); y > 0; y--) + { + if(!loc.getBlock().getRelative(BlockFace.DOWN).getType().isSolid()) continue; + Material m1 = loc.getBlock().getType(); + Material m2 = loc.getBlock().getRelative(BlockFace.UP).getType(); + if(m1.isSolid()) continue; + if(m2.isSolid()) continue; + if(UtilItem.isLiquid(m1)) continue; + if(UtilItem.isLiquid(m2)) continue; + + loc.getWorld().playEffect(GetEntity().getLocation(), Effect.ENDER_SIGNAL, 0); + loc.getWorld().playSound(GetEntity().getLocation(), Sound.ENDERMAN_TELEPORT, 2, 0); + GetEntity().teleport(loc.getBlock().getLocation().add(0.5, 0, 0.5)); + loc.getWorld().playEffect(GetEntity().getLocation(), Effect.ENDER_SIGNAL, 0); + loc.getWorld().playSound(GetEntity().getLocation(), Sound.ENDERMAN_TELEPORT, 2, 0); + return true; + } + return false; + + } + + @EventHandler + public void onShoot(EntityShootBowEvent event) + { + if(!event.getEntity().equals(GetEntity())) return; + + event.setCancelled(true); + } + + @EventHandler + public void onDismount(EntityDismountEvent event) + { + if(event.getDismounted().equals(GetEntity())) event.setCancelled(true); + } + + public Zombie getHorse() + { + return _horse; + } + + @Override + public void Damage(CustomDamageEvent event) + { + if(event.GetDamageeEntity().equals(_horse)) + { + event.setDamagee(GetEntity()); + _horse.setFireTicks(0); + } + + if(event.GetDamageeEntity() instanceof Player) + { + if(GetEntity().equals(event.GetDamagerEntity(true))) + { + onPrinceDamagePlayer(event); + } + else + { + onOtherDamagePlayer(event); + } + } + + if(GetEntity().equals(event.GetDamageeEntity())) + { + onPrinceTakeDamage(event); + + if(!event.isCancelled() && _horse != null && _horse.isValid()) + { + PacketPlayOutAnimation hurt = new PacketPlayOutAnimation(); + hurt.a = _horseDisguise.getEntityId(); + hurt.b = 1; + _horseDisguise.sendPacket(hurt); + } + } + } + + public void onPrinceTakeDamage(CustomDamageEvent event) + { + if(event.GetCause() == DamageCause.SUFFOCATION || event.GetCause() == DamageCause.FALL) + { + event.SetCancelled("Boss Invalid Damage"); + return; + } + + if(GetEntity().equals(event.GetDamagerEntity(true))) + { + event.SetCancelled("Boss Invalid Damage"); + return; + } + + if(!_AI) + { + event.SetCancelled("AI Disabled"); + return; + } + + if(_invulnerable) + { + event.SetCancelled("Invulnerable"); + Player p = event.GetDamagerPlayer(true); + if(p != null) + { + if(Recharge.Instance.use(p, "Boss Inulnerable Info", 5000, false, false)) + { + p.sendMessage(F.main("Game", "Kill the " + F.item("Guards") + " before you can damage the " + F.color("Pumpkin Prince", C.cYellow + C.Bold))); + } + } + return; + } + + if(event.GetProjectile() instanceof Snowball) + { + event.SetKnockback(false); + } + + updateHealth(GetEntity().getHealth(), GetEntity().getHealth()-event.GetDamage()); + } + + public void onPrinceDamagePlayer(CustomDamageEvent event) + { + int state = getState(); + + if(state == 3) + { + event.AddKnockback("Boss Knockback", STAGE_3_KNOCKBACK); + } + } + + public void onOtherDamagePlayer(CustomDamageEvent event) + { + if(_horse.equals(event.GetDamagerEntity(false))) + { + event.AddKnockback("Horse Kick", HORSE_KNOCKBACK); + } + } + + public void updateHealth(double oldH, double newH) + { + int oldState = getState(getHealthProgress(oldH)); + int newState = getState(getHealthProgress(newH)); + if(oldState != newState) + { + updateState(newState); + } + } + + public void updateState(int state) + { + if(state == 1) + { + + } + if(state == 2) + { + GetEntity().getEquipment().setItemInHand(new ItemStack(Material.DIAMOND_SWORD)); + + GetEntity().addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 1)); + GetEntity().addPotionEffect(new PotionEffect(PotionEffectType.JUMP, Integer.MAX_VALUE, 1)); + } + if(state == 3) + { + Host.setMaxPumplings(0); + + GetEntity().addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 2), true); + GetEntity().addPotionEffect(new PotionEffect(PotionEffectType.JUMP, Integer.MAX_VALUE, 2), true); + } + } + + @Override + public void remove() + { + die(); + super.remove(); + } + + public void die() + { + UtilServer.Unregister(this); + } + + @Override + public void Target(EntityTargetEvent event) + { + if(!event.getEntity().equals(GetEntity())) return; + + if(!_AI) + { + event.setCancelled(true); + return; + } + + if(event.getTarget() == null) + { + event.setCancelled(true); + return; + } + + if(event.getTarget().getType() != EntityType.PLAYER) event.setCancelled(true); + } + + public int getState() + { + return getState(getHealthProgress()); + } + + public int getState(double healthProgress) + { + if(healthProgress > 0.6) return 1; + if(healthProgress > 0.4) return 2; + return 3; + } + + public double getHealthProgress(double health) + { + return health / GetEntity().getMaxHealth(); + } + + public double getHealthProgress() + { + return getHealthProgress(GetEntity().getHealth()); + } + + public boolean isDead() + { + return getHealthProgress() <= 0; + } + + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/creatures/MobPumpling.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/creatures/MobPumpling.java new file mode 100644 index 000000000..774cbbecd --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/creatures/MobPumpling.java @@ -0,0 +1,97 @@ +package nautilus.game.arcade.game.games.halloween2016.creatures; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; +import org.bukkit.event.entity.EntityTargetEvent; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.games.halloween.creatures.CreatureBase; +import nautilus.game.arcade.game.games.halloween.creatures.InterfaceMove; +import nautilus.game.arcade.game.games.halloween2016.Halloween2016; + +public class MobPumpling extends CreatureBase<Skeleton> implements InterfaceMove +{ + private static double EXTRA_DAMAGE = 5; + private static float SPEED = 1; + + public MobPumpling(Halloween2016 game, Location loc) + { + super(game, C.cYellow + "Pumpling", Skeleton.class, loc); + } + + @Override + public void SpawnCustom(Skeleton ent) + { + Host.Manager.GetCondition().Factory().Invisible("Cloak", ent, ent, 999999, 0, false, false, false); + + ent.getEquipment().setHelmet(new ItemStack(Material.PUMPKIN)); + + ent.setMaxHealth(15); + ent.setHealth(ent.getMaxHealth()); + + UtilEnt.setTickWhenFarAway(ent, true); + } + + @Override + public void Damage(CustomDamageEvent event) + { + if(GetEntity().equals(event.GetDamagerEntity(false))) + { + event.AddMod("Damage", EXTRA_DAMAGE); + } + } + + @Override + public void Target(EntityTargetEvent event) + { + + } + + @Override + public void Update(UpdateEvent event) + { + + } + + @Override + public void Move() + { + UtilEnt.CreatureMove(GetEntity(), getClosestPlayer(), SPEED); + } + + public Location getClosestPlayer() + { + Player p = null; + double d = 0; + for(Player pp : Host.GetPlayers(true)) + { + double dd = pp.getLocation().distanceSquared(GetEntity().getLocation()); + if(p == null || dd < d) + { + d = dd; + p = pp; + } + } + return p.getLocation(); + } + + @Override + public void remove() + { + UtilParticle.PlayParticleToAll(ParticleType.LARGE_SMOKE, GetEntity().getLocation(), null, 0.3f, 20, ViewDist.NORMAL); + GetEntity().getWorld().playSound(GetEntity().getLocation(), Sound.SKELETON_DEATH, 1, 1); + GetEntity().getWorld().playSound(GetEntity().getLocation(), Sound.FIZZ, 1, 1); + super.remove(); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/creatures/MobSkeletonArcher.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/creatures/MobSkeletonArcher.java new file mode 100644 index 000000000..fcc6f7235 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/creatures/MobSkeletonArcher.java @@ -0,0 +1,53 @@ +package nautilus.game.arcade.game.games.halloween2016.creatures; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftArrow; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.Skeleton; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.C; +import nautilus.game.arcade.game.games.halloween2016.Halloween2016; + +public class MobSkeletonArcher extends CryptBreaker<Skeleton> +{ + + private static final int CRYPT_DAMAGE = 3; + private static final int CRYPT_DAMAGE_RATE = 20; + private static final float SPEED = 1; + private static final double HEALTH = 15; + + public MobSkeletonArcher(Halloween2016 game, Location loc) + { + super(game, C.cYellow + "Skeleton Archer", Skeleton.class, loc, CRYPT_DAMAGE, CRYPT_DAMAGE_RATE, SPEED); + + _extraDamage = 1; + _customCryptRange = 3; + + _playerTargetBackRange = 2; + } + + @Override + public void SpawnCustom(Skeleton ent) + { + ent.getEquipment().setItemInHand(new ItemStack(Material.BOW)); + + ent.setMaxHealth(HEALTH); + ent.setHealth(HEALTH); + } + + @Override + public void attackCrypt() + { + if(!_crypt.tryDamage(GetEntity(), _cryptDamage, _cryptDamageRate)) return; + + Location door = getClosestDoor(); + Vector diff = door.toVector().subtract(GetEntity().getLocation().toVector()); + diff.setY(diff.getY() + 0.5); + Arrow a = GetEntity().launchProjectile(Arrow.class, diff); + ((CraftArrow)a).getHandle().noclip = true; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/creatures/MobWitch.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/creatures/MobWitch.java new file mode 100644 index 000000000..3342f1f96 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/creatures/MobWitch.java @@ -0,0 +1,295 @@ +package nautilus.game.arcade.game.games.halloween2016.creatures; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftCreature; +import org.bukkit.entity.Bat; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Zombie; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityTargetEvent; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilServer; +import mineplex.core.disguise.disguises.DisguiseWitch; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.games.halloween.creatures.CreatureBase; +import nautilus.game.arcade.game.games.halloween2016.Halloween2016; +import net.minecraft.server.v1_8_R3.RandomPositionGenerator; +import net.minecraft.server.v1_8_R3.Vec3D; + +public class MobWitch extends CreatureBase<Zombie> +{ + private static int HEALTH = 20; + private static int PANIC_TIME = 100; + + private float SPEED_IDLE = 1f; + private float SPEED_PANIC = 2f; + + private static int BATS_BURST = 10; + private static int BATS_TICKS = 80; + private static double BAT_KNOCKBACK = 1.75; + private static int BAT_FIRE_TICKS = 10; + private static double BAT_DAMAGE = 3; + + private static double HEAL_DISTANCE = 7; + private static double HEAL_AMOUNT = 10; + private static double HEAL_RAY_SPEED = 0.2; + + + + private CreatureBase<?> _healTarget = null; + public Location _healRay = null; + + private int _panicTicks = 0; + private List<Bat> _bats = new ArrayList<>(); + + private Location _panicTarget = null; + + private Halloween2016 _host; + + public MobWitch(Halloween2016 game, Location loc) + { + super(game, C.cYellow + "Witch", Zombie.class, loc); + _host = game; + } + + @Override + public void SpawnCustom(Zombie ent) + { + ent.setMaxHealth(HEALTH); + ent.setHealth(ent.getMaxHealth()); + + UtilEnt.setTickWhenFarAway(ent, true); + ent.setRemoveWhenFarAway(false); + + DisguiseWitch disg = new DisguiseWitch(ent); + Host.getArcadeManager().GetDisguise().disguise(disg); + } + + @Override + public void Update(UpdateEvent event) + { + if(event.getType() == UpdateType.TICK) + { + updateBats(); + move(); + } + } + + @Override + public void Damage(CustomDamageEvent event) + { + if(event.isCancelled()) return; + + if(_bats.contains(event.GetDamageeEntity())) + { + if(event.GetCause() == DamageCause.FIRE_TICK) + { + event.SetCancelled("Fire Imunity"); + return; + } + } + if(event.GetDamageeEntity() instanceof Player) + { + if (event.GetReason() != null && event.GetReason().contains(GetName())) + { + event.AddKnockback(GetName(), BAT_KNOCKBACK); + return; + } + } + if(!GetEntity().equals(event.GetDamageeEntity())) return; + + LivingEntity damager = event.GetDamagerEntity(false); + + if(damager != null && _panicTicks <= 0) + { + shootBats(damager.getEyeLocation().subtract(GetEntity().getEyeLocation()).toVector()); + } + + _panicTicks = PANIC_TIME; + } + + public void shootBats(Vector direction) + { + Location loc = GetEntity().getLocation(); + loc.setDirection(direction); + GetEntity().teleport(loc); + Host.CreatureAllowOverride = true; + for(int i = 0; i < BATS_BURST; i++) + { + Bat bat = GetEntity().getWorld().spawn(GetEntity().getEyeLocation(), Bat.class); + UtilEnt.Vegetate(bat); + _bats.add(bat); + addEntityPart(bat); + } + Host.CreatureAllowOverride = false; + } + + @Override + public void Target(EntityTargetEvent event) + {} + + public void move() + { + if(_panicTicks > 0) + { + movePanic(); + _panicTicks--; + } + else + { + _panicTarget = null; + moveIdle(); + } + } + + public void updateBats() + { + for (Iterator<Bat> it = _bats.iterator(); it.hasNext();) + { + Bat bat = it.next(); + if (!bat.isValid()) + { + it.remove(); + continue; + } + + if(bat.getTicksLived() > BATS_TICKS) + { + bat.remove(); + it.remove(); + UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, bat.getLocation(), 0, 0, 0, 0, 3, + ViewDist.LONG, UtilServer.getPlayers()); + continue; + } + + bat.setFireTicks(10); + + Vector rand = new Vector((Math.random() - 0.5)/2, (Math.random() - 0.5)/2, (Math.random() - 0.5)/2); + bat.setVelocity(bat.getLocation().getDirection().multiply(0.5).add(rand)); + + for(Player p : UtilEnt.getPlayersInsideEntity(bat, Host.GetPlayers(true))) + { + if (!Recharge.Instance.usable(p, "Hit by Bat")) + continue; + + //Damage Event + Host.getArcadeManager().GetDamage().NewDamageEvent(p, GetEntity(), null, + DamageCause.CUSTOM, BAT_DAMAGE, true, true, false, + GetEntity().getName(), GetName()); + p.setFireTicks(p.getFireTicks() + BAT_FIRE_TICKS); + + //Effect + bat.getWorld().playSound(bat.getLocation(), Sound.BAT_HURT, 1f, 1f); + UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, bat.getLocation(), 0, 0, 0, 0, 3, + ViewDist.LONG, UtilServer.getPlayers()); + + bat.remove(); + it.remove(); + + //Recharge on hit + Recharge.Instance.useForce(p, "Hit by Bat", 200); + } + } + } + + public void getNewHealTarget() + { + CreatureBase<?> close = null; + double dist = -1; + for(CreatureBase<?> c : _host.getNonPumplings()) + { + if(c.equals(this)) continue; + if(!c.GetEntity().isValid()) continue; + + if(c.GetEntity().getHealth() < c.GetEntity().getMaxHealth()) + { + double d = GetEntity().getLocation().distanceSquared(c.GetEntity().getLocation()); + if(close == null || d < dist) + { + close = c; + dist = d; + } + } + } + _healTarget = close; + } + + public void moveIdle() + { + if(_healTarget != null && !_healTarget.GetEntity().isValid()) + { + _healTarget = null; + } + if(_healTarget == null) + { + getNewHealTarget(); + } + + if(_healTarget == null) + { + UtilEnt.CreatureMove(GetEntity(), _host.getInfrontOfDoorTargets().get(0), SPEED_IDLE); + + return; + } + + if(_healRay != null) + { + Vector diff = _healTarget.GetEntity().getEyeLocation().subtract(_healRay).toVector(); + double length = diff.lengthSquared(); + if(length <= HEAL_RAY_SPEED * HEAL_RAY_SPEED) + { + LivingEntity ent = _healTarget.GetEntity(); + ent.setHealth(Math.min(ent.getMaxHealth(), ent.getHealth()+HEAL_AMOUNT)); + + UtilParticle.PlayParticleToAll(ParticleType.HEART, ent.getEyeLocation(), 1, 1, 1, 0, 20, ViewDist.NORMAL); + + _healTarget = null; + _healRay = null; + + return; + } + diff.normalize().multiply(HEAL_RAY_SPEED); + + _healRay.add(diff); + UtilParticle.PlayParticleToAll(ParticleType.HEART, _healRay, 0, 0, 0, 0, 1, ViewDist.NORMAL); + + return; + } + + double dist = _healTarget.GetEntity().getLocation().distanceSquared(GetEntity().getLocation()); + if(dist < HEAL_DISTANCE * HEAL_DISTANCE) + { + _healRay = GetEntity().getEyeLocation(); + return; + } + + UtilEnt.CreatureMove(GetEntity(), _healTarget.GetEntity().getLocation(), SPEED_IDLE); + } + + public void movePanic() + { + if(_panicTarget == null || UtilEnt.canEntityWalkCloserToNavigationTarget(GetEntity())) + { + Vec3D v = RandomPositionGenerator.a(((CraftCreature)GetEntity()).getHandle(), 5, 4); + _panicTarget = new Location(GetEntity().getWorld(), v.a, v.b, v.c); + } + + UtilEnt.CreatureMove(GetEntity(), _panicTarget, SPEED_PANIC); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/creatures/MobZombie.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/creatures/MobZombie.java new file mode 100644 index 000000000..5de0819e6 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/creatures/MobZombie.java @@ -0,0 +1,32 @@ +package nautilus.game.arcade.game.games.halloween2016.creatures; + +import org.bukkit.Location; +import org.bukkit.entity.Zombie; + +import mineplex.core.common.util.C; +import nautilus.game.arcade.game.games.halloween2016.Halloween2016; + +public class MobZombie extends CryptBreaker<Zombie> +{ + + private static float SPEED = 1; + private static int CRYPT_DAMAGE = 3; + private static int CRYPT_DAMAGE_COOLDOWN = 20; + + private static double HEALTH = 15; + + public MobZombie(Halloween2016 game, Location loc) + { + super(game, C.cYellow + "Zombie", Zombie.class, loc, CRYPT_DAMAGE, CRYPT_DAMAGE_COOLDOWN, SPEED); + + _extraDamage = 5; + } + + @Override + public void SpawnCustom(Zombie ent) + { + ent.setMaxHealth(HEALTH); + ent.setHealth(HEALTH); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/creatures/MobZombieSpawner.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/creatures/MobZombieSpawner.java new file mode 100644 index 000000000..6b5ae9fef --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/creatures/MobZombieSpawner.java @@ -0,0 +1,75 @@ +package nautilus.game.arcade.game.games.halloween2016.creatures; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Zombie; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +import nautilus.game.arcade.game.games.halloween2016.Halloween2016; + +public class MobZombieSpawner extends CryptBreaker<Zombie> +{ + + private static final int CRYPT_DAMAGE = 20; + private static final int CRYPT_RATE = 20; + private static final float SPEED = 0.5f; + private static final int MAX_MINI_ZOMBIES = 4; + + private List<MobMiniZombie> _miniZombies = new ArrayList<>(); + + public MobZombieSpawner(Halloween2016 game, Location loc) + { + super(game, C.cYellow + "Zombie Spawner", Zombie.class, loc, CRYPT_DAMAGE, CRYPT_RATE, SPEED); + } + + @Override + public void SpawnCustom(Zombie ent) + { + ent.setVillager(true); + + ent.getEquipment().setHelmet(new ItemStack(Material.MOB_SPAWNER)); + } + + @Override + public void Update(UpdateEvent event) + { + super.Update(event); + + if(event.getType() == UpdateType.SEC_05) + { + for(Iterator<MobMiniZombie> it = _miniZombies.iterator(); it.hasNext();) + { + if(!it.next().GetEntity().isValid()) it.remove(); + } + + if(_miniZombies.size() >= MAX_MINI_ZOMBIES) return; + + //Combat concurrency issues (can't add mobs while in the "tick" loop of mobs) + Host.Manager.runSync(() -> + { + if(GetEntity().isValid()) + { + Location loc = GetEntity().getLocation().add(GetEntity().getLocation().getDirection().normalize()); + UtilParticle.PlayParticleToAll(ParticleType.SMOKE, loc, null, 0.1f, 20, ViewDist.NORMAL); + loc.getWorld().playSound(loc, Sound.ZOMBIE_INFECT, 1, 0.6f); + MobMiniZombie mini = new MobMiniZombie(Host, loc); + _miniZombies.add(mini); + Host16.AddCreature(mini, false); + } + }); + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/tutorial/TutorialHalloween2016.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/tutorial/TutorialHalloween2016.java new file mode 100644 index 000000000..c38389e25 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/tutorial/TutorialHalloween2016.java @@ -0,0 +1,44 @@ +package nautilus.game.arcade.game.games.halloween2016.tutorial; + +import org.bukkit.Location; + +import mineplex.core.common.animation.Animator; + +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.halloween2016.Halloween2016; +import nautilus.game.arcade.gametutorial.GameTutorial; +import nautilus.game.arcade.gametutorial.TutorialPhase; + +public class TutorialHalloween2016 extends GameTutorial +{ + + private Halloween2016 _host; + + public TutorialHalloween2016(Halloween2016 host, Animator animator, GameTeam team, Location start, int duration) + { + super(host.Manager, new TutorialPhase[]{ + new TutorialPhaseHalloween(duration, animator, team, start) + }); + _host = host; + + SetTutorialPositions = false; + } + + @Override + public void onStart() + { + super.onStart(); + + _host.Manager.getCosmeticManager().setHideParticles(true); + } + + @Override + public void onEnd() + { + super.onEnd(); + _host.AllowParticles = true; + + _host.Manager.getCosmeticManager().setHideParticles(false); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/tutorial/TutorialPhaseHalloween.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/tutorial/TutorialPhaseHalloween.java new file mode 100644 index 000000000..5ad45f140 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/tutorial/TutorialPhaseHalloween.java @@ -0,0 +1,67 @@ +package nautilus.game.arcade.game.games.halloween2016.tutorial; + +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.entity.Player; + +import mineplex.core.common.animation.Animator; +import mineplex.core.common.util.C; + +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.gametutorial.TutorialPhase; +import nautilus.game.arcade.gametutorial.TutorialText; + +public class TutorialPhaseHalloween extends TutorialPhase +{ + + private Animator _animator; + private GameTeam _team; + private Location _start; + + public TutorialPhaseHalloween(int duration, Animator animator, GameTeam team, Location start) + { + super(new TutorialText[] + { + new TutorialText(C.cGold + "Legend says that many years ago", 5 * 20, 1), + new TutorialText(C.cGold + "A group of heroes defeated the Pumpkin King", 4 * 20, 2), + new TutorialText(C.cGold + "Since then the world has known peace.", 3 * 20, 3), + new TutorialText("", 2 * 20, 4), + new TutorialText(C.cGold + "My family has guarded this tomb for generations.", 4 * 20, 5), + new TutorialText(C.cGold + "All I know is we must not let it fall.", 4 * 20, 6), + new TutorialText("", 2 * 20, 7), + new TutorialText("", Math.max((duration-(24*20)), 8)) + }); + + _animator = animator; + _team = team; + _start = start; + } + + + @Override + public void onStart() + { + _animator.start(_start); + } + + + + @Override + public void onEnd() + { + for(Player p : _team.GetPlayers(false)) + { + p.setGameMode(GameMode.SURVIVAL); + } + _animator.stop(); + } + + @Override + public int ID() + { + return 1; + } + + + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/wave/Wave1.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/wave/Wave1.java new file mode 100644 index 000000000..b2ed6fd86 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/wave/Wave1.java @@ -0,0 +1,46 @@ +package nautilus.game.arcade.game.games.halloween2016.wave; + +import mineplex.core.common.util.UtilTime; + +import nautilus.game.arcade.game.games.halloween2016.Halloween2016; +import nautilus.game.arcade.game.games.halloween2016.creatures.MobSkeletonArcher; +import nautilus.game.arcade.game.games.halloween2016.creatures.MobZombie; + +public class Wave1 extends WaveBase +{ + + public Wave1(Halloween2016 host) + { + super(host, null, 80000, host.getMobSpawns(), null); + _desc = new String[] + { + "Zombies", + "Skeletons" + }; + } + + @Override + public void Spawn(int tick) + { + if(tick == 0) + { + Host.setObjective("Protect the Crypt"); + } + + if (UtilTime.elapsed(_start, 50000)) + return; + + if (Host.getNonPumplings().size() > Host.getMaxNonPumplings()) return; + + if(tick%10 == 0) + { + Host.AddCreature(new MobZombie(Host, GetSpawn())); + } + + if(tick%15 == 0) + { + Host.AddCreature(new MobSkeletonArcher(Host, GetSpawn())); + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/wave/Wave2.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/wave/Wave2.java new file mode 100644 index 000000000..b716a7095 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/wave/Wave2.java @@ -0,0 +1,56 @@ +package nautilus.game.arcade.game.games.halloween2016.wave; + +import mineplex.core.common.util.UtilTime; + +import nautilus.game.arcade.game.games.halloween.creatures.MobSpiderLeaper; +import nautilus.game.arcade.game.games.halloween.creatures.MobSpiderSmasher; +import nautilus.game.arcade.game.games.halloween2016.Halloween2016; +import nautilus.game.arcade.game.games.halloween2016.creatures.MobGiant; +import nautilus.game.arcade.game.games.halloween2016.creatures.MobZombie; + +public class Wave2 extends WaveBase +{ + + public Wave2(Halloween2016 host) + { + super(host, null, 90000, host.getMobSpawns(), null); + _desc = new String[] + { + "Giants", + "Creepers", + "Zombies", + "Spiders" + }; + } + + @Override + public void Spawn(int tick) + { + if(tick == 0) + { + Host.AddCreature(new MobGiant(Host, getSpawn(Host.getMainLane()))); + } + + if (UtilTime.elapsed(_start, 60000)) + return; + + if(tick%200 == 0) + { + spawnCreepers(); + } + + if (Host.getNonPumplings().size() > Host.getMaxNonPumplings()) return; + + if(tick%7 == 0) + { + Host.AddCreature(new MobZombie(Host, GetSpawn())); + } + + if(tick%20 == 0) + { + Host.AddCreature(new MobSpiderLeaper(Host, GetSpawn())); + Host.AddCreature(new MobSpiderSmasher(Host, GetSpawn())); + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/wave/Wave3.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/wave/Wave3.java new file mode 100644 index 000000000..fef51ae1a --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/wave/Wave3.java @@ -0,0 +1,68 @@ +package nautilus.game.arcade.game.games.halloween2016.wave; + +import mineplex.core.common.util.UtilTime; + +import nautilus.game.arcade.game.games.halloween2016.Halloween2016; +import nautilus.game.arcade.game.games.halloween2016.creatures.MobBlaze; +import nautilus.game.arcade.game.games.halloween2016.creatures.MobGiant; +import nautilus.game.arcade.game.games.halloween2016.creatures.MobWitch; +import nautilus.game.arcade.game.games.halloween2016.creatures.MobZombie; +import nautilus.game.arcade.game.games.halloween2016.creatures.MobZombieSpawner; + +public class Wave3 extends WaveBase +{ + + public Wave3(Halloween2016 host) + { + super(host, null, 90000, host.getMobSpawns(), null); + _desc = new String[] + { + "Giants", + "Creepers", + "Zombies", + "Zombie Spawners", + "Blazes" + }; + } + + @Override + public void Spawn(int tick) + { + if (UtilTime.elapsed(_start, 60000)) + return; + + if(tick%200 == 0) + { + spawnCreepers(); + } + + if(tick%(20*7) == 0) + { + Host.AddCreature(new MobWitch(Host, GetSpawn())); + } + + if(tick%(20 * 10) == 0) + { + Host.AddCreature(new MobGiant(Host, getSpawn(Host.getMainLane()))); + } + + if (Host.getNonPumplings().size() > Host.getMaxNonPumplings()) return; + + if(tick%15 == 0) + { + Host.AddCreature(new MobZombie(Host, GetSpawn())); + } + + if(tick%60 == 0) + { + Host.AddCreature(new MobZombieSpawner(Host, GetSpawn())); + } + + if(tick%30 == 0) + { + Host.AddCreature(new MobBlaze(Host, GetSpawn())); + } + + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/wave/Wave4.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/wave/Wave4.java new file mode 100644 index 000000000..7083c3e87 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/wave/Wave4.java @@ -0,0 +1,56 @@ +package nautilus.game.arcade.game.games.halloween2016.wave; + +import mineplex.core.common.util.UtilTime; +import nautilus.game.arcade.game.games.halloween2016.Halloween2016; +import nautilus.game.arcade.game.games.halloween2016.creatures.MobBlaze; +import nautilus.game.arcade.game.games.halloween2016.creatures.MobGiant; +import nautilus.game.arcade.game.games.halloween2016.creatures.MobPigZombie; +import nautilus.game.arcade.game.games.halloween2016.creatures.MobWitch; + +public class Wave4 extends WaveBase +{ + + public Wave4(Halloween2016 host) + { + super(host, null, 100000, host.getMobSpawns(), null); + _desc = new String[] + { + "Giants", + "Creepers", + "Zombie Pigmen", + "Blazes", + "Witches", + }; + } + + @Override + public void Spawn(int tick) + { + if(tick%(20 * 30) == 0) + { + Host.AddCreature(new MobGiant(Host, getSpawn(Host.getMainLane()))); + } + + if (Host.getNonPumplings().size() > Host.getMaxNonPumplings()) return; + + if (UtilTime.elapsed(_start, 70000)) + return; + + if(tick%15 == 0) + { + Host.AddCreature(new MobPigZombie(Host, GetSpawn())); + } + + if(tick%60 == 0) + { + Host.AddCreature(new MobBlaze(Host, GetSpawn())); + } + + if(tick%100 == 0) + { + Host.AddCreature(new MobWitch(Host, GetSpawn())); + } + + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/wave/Wave5.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/wave/Wave5.java new file mode 100644 index 000000000..176d375b7 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/wave/Wave5.java @@ -0,0 +1,84 @@ +package nautilus.game.arcade.game.games.halloween2016.wave; + +import mineplex.core.common.util.UtilTime; + +import nautilus.game.arcade.game.games.halloween.creatures.MobSpiderLeaper; +import nautilus.game.arcade.game.games.halloween.creatures.MobSpiderSmasher; +import nautilus.game.arcade.game.games.halloween2016.Halloween2016; +import nautilus.game.arcade.game.games.halloween2016.creatures.MobBlaze; +import nautilus.game.arcade.game.games.halloween2016.creatures.MobGiant; +import nautilus.game.arcade.game.games.halloween2016.creatures.MobSkeletonArcher; +import nautilus.game.arcade.game.games.halloween2016.creatures.MobWitch; +import nautilus.game.arcade.game.games.halloween2016.creatures.MobZombie; +import nautilus.game.arcade.game.games.halloween2016.creatures.MobZombieSpawner; + +public class Wave5 extends WaveBase +{ + + public Wave5(Halloween2016 host) + { + super(host, null, 120000, host.getMobSpawns(), null); + _desc = new String[] + { + "Giants", + "Creepers", + "Zombies", + "Zombie Spawners", + "Skeletons", + "Witches", + "Blazes", + "Spiders" + }; + } + + @Override + public void Spawn(int tick) + { + if(tick%(20*30) == 0) + { + Host.AddCreature(new MobGiant(Host, getSpawn(Host.getMainLane()))); + } + + if (UtilTime.elapsed(_start, 100000)) + return; + + if(tick%300 == 0) + { + spawnCreepers(); + } + + if (Host.getNonPumplings().size() > Host.getMaxNonPumplings()) return; + + if(tick%40 == 0) + { + Host.AddCreature(new MobZombie(Host, GetSpawn())); + } + + if(tick%40 == 0) + { + Host.AddCreature(new MobSkeletonArcher(Host, GetSpawn())); + } + + if(tick%50 == 0) + { + Host.AddCreature(new MobZombieSpawner(Host, GetSpawn())); + } + + if(tick%50 == 0) + { + Host.AddCreature(new MobWitch(Host, GetSpawn())); + } + + if(tick%50 == 0) + { + Host.AddCreature(new MobBlaze(Host, GetSpawn())); + } + + if(tick%40 == 0) + { + Host.AddCreature(new MobSpiderLeaper(Host, GetSpawn())); + Host.AddCreature(new MobSpiderSmasher(Host, GetSpawn())); + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/wave/WaveBase.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/wave/WaveBase.java new file mode 100644 index 000000000..95a211c18 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/wave/WaveBase.java @@ -0,0 +1,46 @@ +package nautilus.game.arcade.game.games.halloween2016.wave; + +import java.util.List; + +import org.bukkit.Location; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilMath; + +import nautilus.game.arcade.game.games.halloween.NamedAudio; +import nautilus.game.arcade.game.games.halloween2016.Halloween2016; +import nautilus.game.arcade.game.games.halloween2016.creatures.MobCreeper; + +public abstract class WaveBase extends nautilus.game.arcade.game.games.halloween.waves.WaveBase +{ + + protected Halloween2016 Host; + + protected static final int CREEPER_SPAWN_PACK_SIZE = 5; + + public WaveBase(Halloween2016 host, String name, long duration, List<Location> spawns, NamedAudio audio) + { + super(host, name, duration, spawns, audio); + Host = host; + + _titleColor = C.cRed; + } + + public Location getSpawn(List<Location> lane) + { + return lane.get(UtilMath.r(lane.size())); + } + + public void spawnCreepers() + { + Location loc = GetSpawn(); + for(int i = 0; i < CREEPER_SPAWN_PACK_SIZE; i++) + { + double x = UtilMath.random(-3, 3); + double z = UtilMath.random(-3, 3); + + Host.AddCreature(new MobCreeper(Host, loc.clone().add(x, 0, z)), false); + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/wave/WaveBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/wave/WaveBoss.java new file mode 100644 index 000000000..c390473bc --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/wave/WaveBoss.java @@ -0,0 +1,253 @@ +package nautilus.game.arcade.game.games.halloween2016.wave; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Fireball; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; +import org.bukkit.entity.Skeleton.SkeletonType; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import nautilus.game.arcade.game.games.halloween.creatures.CreatureBase; +import nautilus.game.arcade.game.games.halloween2016.Halloween2016; +import nautilus.game.arcade.game.games.halloween2016.creatures.MobPrinceGuard; +import nautilus.game.arcade.game.games.halloween2016.creatures.MobPumpkinPrince; + +public class WaveBoss extends WaveBase implements Listener +{ + private MobPumpkinPrince _prince; + private Halloween2016 Host; + + private Skeleton _pumpkinKing; + + private List<MobPrinceGuard> _guards = new ArrayList<>(); + private int _guardsCount = 4; + private int _guardsCountQueue = _guardsCount; + private double _nextPrinceHealthStageForNewGuards; + + private int _tick = 0; + + private Fireball _fireball; + + private final static float KING_SPEED = 1.7f; + private final static float PRINCE_SPEED = 1.3f; + + private Location _princeTarget; + + public WaveBoss(Halloween2016 host) + { + super(host, "Boss Fight", 0, host.getMobSpawns(), null); + Host = host; + } + + @Override + public void Spawn(int tick) + { + tick = _tick; + _tick++; + if(tick == 0) + { + UtilServer.RegisterEvents(this); + + for(Player p : Host.GetPlayers(true)) + { + p.teleport(Host.getCryptView()); + } + Host.lockAllPlayers(Host.getCryptView()); + + for(CreatureBase<?> c : Host.getMobs()) + { + c.remove(); + } + } + else if(tick == 4) + { + for(CreatureBase<?> c : Host.getMobs()) + { + c.remove(); + } + for(Entity e : Host.WorldData.World.getEntities()) + { + if((e instanceof LivingEntity) && !(e instanceof Player)) + { + e.remove(); + } + } + } + else if(tick == 5) + { + + _princeTarget = Host.getPrinceTargetInfrontOfCrypt(); + + _prince = new MobPumpkinPrince(Host, Host.getPrinceSpawn()); + _prince.setAI(false); + Host.AddCreature(_prince); + + _nextPrinceHealthStageForNewGuards = _prince.GetEntity().getHealth()-200; + } + else if(tick < 20 * 5) + { + UtilEnt.CreatureMove(_prince.getHorse(), _princeTarget, PRINCE_SPEED); + } + else if(tick == 20 * 6) + { + Vector diff = Host.getInfrontOfDoorTargets().get(1).clone().add(0, 1, 0).subtract(_prince.GetEntity().getEyeLocation()).toVector(); + UtilEnt.CreatureLook(_prince.GetEntity(), UtilAlg.GetPitch(diff), UtilAlg.GetYaw(diff)); + _fireball = _prince.GetEntity().launchProjectile(Fireball.class); + } + else if(tick == 20 * 11) + { + Host.Announce("", false); + Host.Announce("", false); + say("Pumpkin King", "I am free! Free at last!"); + } + if(tick == 20 * 12) + { + say("Pumpkin King", "Protect me my son!"); + } + if(tick > 20 * 13 && tick < 20 * 18) + { + UtilEnt.CreatureMove(_pumpkinKing, Host.getGiantSpawn(), KING_SPEED); + + } + else if(tick == 20 * 18) + { + _pumpkinKing.remove(); + + Host.unlockAllPlayers(); + _prince.setAI(true); + for(MobPrinceGuard guard : _guards) + { + guard.setAI(true); + } + + Host.Objective = "Eliminate the Guards"; + Host.Announce(C.cGreen + C.Bold + "Kill the Prince's Guards first!", false); + } + + + + + + + + + if(tick > 20 * 18){ + boolean empt = _guards.isEmpty(); + for(Iterator<MobPrinceGuard> it = _guards.iterator(); it.hasNext();) + { + MobPrinceGuard g = it.next(); + if(!g.GetEntity().isValid()) it.remove(); + } + if(empt != _guards.isEmpty() && !empt) + { + Host.Objective = "Defeat the Pumpkin Prince"; + Host.Announce(C.cGreen + C.Bold + "All the Pumpking Prince's guards are dead!", false); + Host.Announce(C.cGreen + C.Bold + "Kill him while he is unprotected!", true); + } + + _prince.setInvulnerable(!_guards.isEmpty()); + + if(_prince.GetEntity().getHealth() < _nextPrinceHealthStageForNewGuards) + { + Host.Objective = "Eliminate the Guards"; + Host.Announce(C.cGreen + C.Bold + "The Pumpkin Prince's guards are back to protect him", false); + Host.Announce(C.cGreen + C.Bold + "Kill them first before attacking the Prince!", true); + + + _prince.setInvulnerable(true); + _nextPrinceHealthStageForNewGuards -= 200; + _guardsCountQueue = _guardsCount; + } + + if(tick % 20 * 20 == 0) + { + if(_guardsCountQueue > 0) + { + MobPrinceGuard guard = new MobPrinceGuard(Host, Host.getGiantSpawn(), _prince); + _guards.add(guard); + Host.AddCreature(guard); + _guardsCountQueue--; + } + } + } + } + + public void say(String role, String msg) + { + Host.Announce("\n" + C.cGold + C.Bold + role + ": " + C.cGray + msg + "\n"); + UtilTextMiddle.display(C.cGold + msg, null, 0, 40, 0); + } + + @Override + public boolean CanEnd() + { + boolean r = _prince != null && _prince.isDead(); + if(r) + { + end(); + } + return r; + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onExplode(EntityExplodeEvent event) + { + if(event.getEntity().equals(_fireball)) + { + event.setCancelled(true); + event.blockList().clear(); + Host.getCrypt().setHealth(0); + + + Host.CreatureAllowOverride = true; + _pumpkinKing = GetSpawn().getWorld().spawn(Host.getInfrontOfCrypt(), Skeleton.class); + Host.CreatureAllowOverride = false; + + _pumpkinKing.setSkeletonType(SkeletonType.WITHER); + _pumpkinKing.getEquipment().setHelmet(new ItemStack(Material.PUMPKIN)); + + _pumpkinKing.setCustomName(C.cYellow + C.Bold + "Pumpking King"); + _pumpkinKing.setCustomNameVisible(true); + + UtilEnt.Vegetate(_pumpkinKing); + + _pumpkinKing.getWorld().strikeLightningEffect(_pumpkinKing.getLocation()); + } + } + + public void end() + { + UtilServer.Unregister(this); + + Host.Announce("\n" + C.cYellow + C.Bold + "The Pumpkin Prince has been defeated!\nThe World is safe... for tonight.\n"); + } + + @EventHandler + public void onDamage(CustomDamageEvent event) + { + if(event.GetDamageeEntity().equals(_pumpkinKing)) + { + event.SetCancelled("Invincible Statue"); + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/wave/WaveVictory.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/wave/WaveVictory.java new file mode 100644 index 000000000..fc775aae3 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/wave/WaveVictory.java @@ -0,0 +1,52 @@ +package nautilus.game.arcade.game.games.halloween2016.wave; + +import java.util.List; + +import org.bukkit.Effect; +import org.bukkit.Location; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; + +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import nautilus.game.arcade.game.games.halloween.creatures.CreatureBase; +import nautilus.game.arcade.game.games.halloween2016.Halloween2016; + +public class WaveVictory extends WaveBase +{ + public WaveVictory(Halloween2016 host, List<Location> beaconSpawn) + { + super(host, "Celebration!", 15000, beaconSpawn, null); + + _displayWaveNumber = false; + _announceWaveChat = false; + } + + @Override + public void Spawn(int tick) + { + if (UtilTime.elapsed(_start, 20000)) return; + + // Play + if (tick == 0) + { + for (Player player : UtilServer.getPlayers()) + { + player.playEffect(Host.getDoorSchematicLocation(), Effect.RECORD_PLAY, 2259); + } + } + + // Mobs + for (CreatureBase<? extends LivingEntity> mob : Host.GetCreatures()) + { + mob.GetEntity().damage(5); + } + + // Time + if (Host.WorldTimeSet != 6000) + { + Host.WorldTimeSet = (Host.WorldTimeSet + 50) % 24000; + Host.WorldData.World.setTime(Host.WorldTimeSet); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java index ec646d75c..b8161cbb7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java @@ -413,11 +413,11 @@ public class HideSeek extends TeamGame if (event.GetState() != GameState.Recruit) return; - _hiders = GetTeamList().get(0); + _hiders = GetTeamList().stream().filter(team -> team.GetName().toUpperCase().contains("BLUE")).toArray(size -> new GameTeam[size])[0]; _hiders.SetColor(ChatColor.AQUA); _hiders.SetName("Hiders"); - _seekers = GetTeamList().get(1); + _seekers = GetTeamList().stream().filter(team -> team.GetName().toUpperCase().contains("RED")).toArray(size -> new GameTeam[size])[0]; _seekers.SetColor(ChatColor.RED); _seekers.SetName("Hunters"); @@ -639,9 +639,9 @@ public class HideSeek extends TeamGame @EventHandler public void FallingBlockBreak(ItemSpawnEvent event) { - if (event.getEntity().getItemStack().getType() == Material.getMaterial(175)) + if (event.getEntity().getItemStack().getType() == Material.getMaterial(175) || (Manager.IsHolidayEnabled && (event.getEntity().getItemStack().getType() == Material.PRISMARINE_SHARD || event.getEntity().getItemStack().getType() == Material.EMERALD))) return; - + event.setCancelled(true); for (Form form : _forms.values()) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/GunModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/GunModule.java index e4dbe64ba..5cb098b4e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/GunModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/GunModule.java @@ -1546,7 +1546,7 @@ public class GunModule implements Listener if (_bombItem != null && _bombItem.equals(ent)) continue; - if (ent instanceof Item && ((Item)ent).getItemStack().getTypeId() == 175) + if (ent instanceof Item && (((Item)ent).getItemStack().getTypeId() == 175 || (Manager.IsHolidayEnabled && (((Item)ent).getItemStack().getType() == Material.PRISMARINE_SHARD || ((Item)ent).getItemStack().getType() == Material.EMERALD)))) continue; ent.remove(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monsterleague/perks/PerkBlinkMonsterLeague.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monsterleague/perks/PerkBlinkMonsterLeague.java index de32a72e1..2ee19c256 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monsterleague/perks/PerkBlinkMonsterLeague.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monsterleague/perks/PerkBlinkMonsterLeague.java @@ -20,7 +20,6 @@ import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilPlayer; import mineplex.core.recharge.Recharge; import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.SmashPerk; public class PerkBlinkMonsterLeague extends Perk { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sheep/kits/KitArcher.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sheep/kits/KitArcher.java index b78c3cf40..f562f9b72 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sheep/kits/KitArcher.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sheep/kits/KitArcher.java @@ -1,19 +1,20 @@ package nautilus.game.arcade.game.games.sheep.kits; -import mineplex.core.common.util.C; -import mineplex.core.itemstack.ItemStackFactory; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.kit.KitAvailability; -import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.ProgressingKit; -import nautilus.game.arcade.kit.perks.PerkBarrage; -import nautilus.game.arcade.kit.perks.PerkFletcher; import org.bukkit.Material; import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemStackFactory; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.smash.perks.skeleton.PerkBarrage; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.ProgressingKit; +import nautilus.game.arcade.kit.perks.PerkFletcher; + public class KitArcher extends ProgressingKit { private static final String[] DESCRIPTION = { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SoloSuperSmash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SoloSuperSmash.java index 478341edb..1cb424597 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SoloSuperSmash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SoloSuperSmash.java @@ -82,7 +82,7 @@ public class SoloSuperSmash extends SuperSmash _players = GetTeamList().get(0); _players.SetColor(ChatColor.YELLOW); _players.SetName("Players"); - _players.setDisplayName(C.cYellow + C.Bold + "Players"); + _players.setDisplayName(C.cYellowB + "Players"); } @Override @@ -95,34 +95,29 @@ public class SoloSuperSmash extends SuperSmash //Wipe Last Scoreboard.reset(); - if (GetPlayers(true).size() > 14) + boolean minimise = false; + + if (GetPlayers(false).size() > 14) { + minimise = true; + Scoreboard.writeNewLine(); - Scoreboard.write(C.cGreen + "Players Alive"); + Scoreboard.write(C.cGreenB + "Players Alive"); Scoreboard.write(GetPlayers(true).size() + " "); Scoreboard.writeNewLine(); - Scoreboard.write(C.cRed + "Players Dead"); + Scoreboard.write(C.cRedB + "Players Dead"); Scoreboard.write((GetPlayers(false).size() - GetPlayers(true).size()) + " "); } else { Scoreboard.writeNewLine(); - Scoreboard.writeGroup(GetPlayers(true), player -> + Scoreboard.writeGroup(GetPlayers(minimise), player -> { - int lives = GetLives(player); + int lives = getLives(player); - String out; - if (lives >= 4) out = C.cGreen + player.getName(); - else if (lives == 3) out = C.cYellow + player.getName(); - else if (lives == 2) out = C.cGold + player.getName(); - else if (lives == 1) out = C.cRed + player.getName(); - else if (lives == 0) out = C.cRed + player.getName(); - else - return null; - - return Pair.create(out, lives); + return Pair.create(getLiveColour(lives) + player.getName(), lives); }, true); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmash.java index 2ce62d81c..82dbb73c7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmash.java @@ -1,26 +1,19 @@ package nautilus.game.arcade.game.games.smash; -import mineplex.core.common.block.BlockData; -import mineplex.core.common.util.*; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.recharge.Recharge; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.ArcadeFormat; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.GameType; -import nautilus.game.arcade.events.GameStateChangeEvent; -import nautilus.game.arcade.game.Game; -import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.game.GameTeam.PlayerState; -import nautilus.game.arcade.game.games.smash.kits.*; -import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.kit.SmashKit; -import org.bukkit.*; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.TimeUnit; + +import org.bukkit.ChatColor; +import org.bukkit.Color; import org.bukkit.FireworkEffect.Type; -import org.bukkit.block.BlockFace; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; import org.bukkit.entity.EnderCrystal; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -30,192 +23,325 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityRegainHealthEvent; import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; +import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.scheduler.BukkitRunnable; -import java.util.HashMap; -import java.util.HashSet; +import com.google.common.collect.Sets; + +import mineplex.core.blockrestore.BlockRestore; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.hologram.Hologram; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import nautilus.game.arcade.ArcadeFormat; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.GameTeam.PlayerState; +import nautilus.game.arcade.game.games.smash.kits.KitBlaze; +import nautilus.game.arcade.game.games.smash.kits.KitChicken; +import nautilus.game.arcade.game.games.smash.kits.KitCow; +import nautilus.game.arcade.game.games.smash.kits.KitCreeper; +import nautilus.game.arcade.game.games.smash.kits.KitEnderman; +import nautilus.game.arcade.game.games.smash.kits.KitGolem; +import nautilus.game.arcade.game.games.smash.kits.KitGuardian; +import nautilus.game.arcade.game.games.smash.kits.KitMagmaCube; +import nautilus.game.arcade.game.games.smash.kits.KitPig; +import nautilus.game.arcade.game.games.smash.kits.KitSheep; +import nautilus.game.arcade.game.games.smash.kits.KitSkeletalHorse; +import nautilus.game.arcade.game.games.smash.kits.KitSkeleton; +import nautilus.game.arcade.game.games.smash.kits.KitSkySquid; +import nautilus.game.arcade.game.games.smash.kits.KitSlime; +import nautilus.game.arcade.game.games.smash.kits.KitSnowman; +import nautilus.game.arcade.game.games.smash.kits.KitSpider; +import nautilus.game.arcade.game.games.smash.kits.KitWitch; +import nautilus.game.arcade.game.games.smash.kits.KitWitherSkeleton; +import nautilus.game.arcade.game.games.smash.kits.KitWolf; +import nautilus.game.arcade.game.games.smash.kits.KitZombie; +import nautilus.game.arcade.game.games.smash.perks.SmashUltimate; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.Perk; public abstract class SuperSmash extends Game { - private HashMap<Player, Integer> _lives = new HashMap<Player, Integer>(); + + private static final int MAX_LIVES = 4; + private static final int POWERUP_SPAWN_Y_INCREASE = 120; + private static final int HUNGER_DELAY = 250; + + private static final String DATA_POINT_POWERUP = "RED"; + + private Map<Player, Integer> _lives = new HashMap<>(); private Location _powerupCurrent = null; private Location _powerupTarget = null; private EnderCrystal _powerup = null; + private Hologram _powerupHologram = null; + private boolean _powerupHologramColour; private long _nextPowerup = 0; - - private HashSet<BlockData> _restoreBlock = new HashSet<BlockData>(); - public SuperSmash(ArcadeManager manager, GameType type, String[] description) + private static final Set<Material> REMOVE_ON_ITEM_SPAWN = Sets.newHashSet(Material.CACTUS, Material.BROWN_MUSHROOM, Material.RED_MUSHROOM, Material.YELLOW_FLOWER, Material.RED_ROSE); + + public SuperSmash(ArcadeManager manager, GameType type, String[] description) { this(manager, - new Kit[] - { + new Kit[] { - new KitSkeleton(manager), - new KitGolem(manager), - new KitSpider(manager), - new KitSlime(manager), + new KitSkeleton(manager), new KitGolem(manager), new KitSpider(manager), new KitSlime(manager), new KitCreeper(manager), new KitEnderman(manager), new KitSnowman(manager), + new KitWolf(manager), new KitBlaze(manager), new KitWitch(manager), new KitChicken(manager), new KitSkeletalHorse(manager), new KitPig(manager), new KitSkySquid(manager), + new KitWitherSkeleton(manager), new KitMagmaCube(manager), new KitZombie(manager), new KitCow(manager), new KitSheep(manager), new KitGuardian(manager) - new KitCreeper(manager), - new KitEnderman(manager), - new KitSnowman(manager), - new KitWolf(manager), - - - new KitBlaze(manager), - new KitWitch(manager), - new KitChicken(manager), - new KitSkeletalHorse(manager), - new KitPig(manager), - new KitSkySquid(manager), - new KitWitherSkeleton(manager), - new KitMagmaCube(manager), - new KitZombie(manager), - new KitCow(manager), - - new KitSheep(manager) - - }, type, description); + }, type, description); } - - public SuperSmash(ArcadeManager manager, Kit[] kits, GameType type, String[] description) + + public SuperSmash(ArcadeManager manager, Kit[] kits, GameType type, String[] description) { super(manager, type, kits, description); - this.DeathOut = false; - - this.CompassEnabled = true; - - this.DeathSpectateSecs = 4; - - this.WorldWaterDamage = 1000; - - this.HideTeamSheep = true; - - this.ReplaceTeamsWithKits = true; - - // Add stat table here - // Example - // Manager.GetStatsManager().addTable("SuperSmashMobStats", "Kills", "Deaths", "Wins", "Losses"); + DeathOut = false; + CompassEnabled = true; + DeathSpectateSecs = 4; + WorldWaterDamage = 1000; + HideTeamSheep = true; + ReplaceTeamsWithKits = true; } @EventHandler(priority = EventPriority.HIGH) - public void GameStateChange(GameStateChangeEvent event) + public void gameStart(GameStateChangeEvent event) { if (event.GetState() != GameState.Prepare) + { return; + } for (Player player : GetPlayers(true)) - _lives.put(player, 4); - - _nextPowerup = (long) (System.currentTimeMillis() + 240000 + 360000 * Math.random()); + { + _lives.put(player, MAX_LIVES); + } + + _nextPowerup = getNewSmashTime(); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void playerDeath(PlayerDeathEvent event) + { + if (!loseLife(event.getEntity())) + { + SetPlayerState(event.getEntity(), PlayerState.OUT); + } + + // I think this causes players to sometimes be invisible + // DisguiseManager disguiseManager = Manager.GetDisguise(); + // DisguiseBase disguise = + // disguiseManager.getActiveDisguise(event.getEntity()); + // + // if (disguise == null) + // { + // return; + // } + // + // disguiseManager.undisguise(disguise); } @EventHandler - public void PlayerOut(PlayerDeathEvent event) + public void playerQuit(PlayerQuitEvent event) { - if (!LoseLife(event.getEntity())) - { - this.SetPlayerState(event.getEntity(), PlayerState.OUT); - } + _lives.remove(event.getPlayer()); } - public int GetLives(Player player) + public int getLives(Player player) { if (!_lives.containsKey(player)) + { return 0; + } if (!IsAlive(player)) + { return 0; + } return _lives.get(player); } - public boolean LoseLife(Player player) + public boolean loseLife(Player player) { - int lives = GetLives(player) - 1; + int lives = getLives(player) - 1; if (lives > 0) { - UtilPlayer.message(player, C.cRed + C.Bold + "You have died!"); - UtilPlayer.message(player, C.cRed + C.Bold + "You have " + lives + " " + (lives == 1 ? "life" : "lives") + " left!"); + String livesString = (lives == 1 ? "life" : "lives"); + + UtilPlayer.message(player, C.cRedB + "You have died!"); + UtilPlayer.message(player, C.cRedB + "You have " + lives + " " + livesString + " left!"); player.playSound(player.getLocation(), Sound.NOTE_BASS_GUITAR, 2f, 0.5f); _lives.put(player, lives); + new BukkitRunnable() + { + + @Override + public void run() + { + UtilTextMiddle.display(null, getLiveColour(lives) + lives + " " + livesString + " left!", 10, 30, 10, player); + } + }.runTaskLater(Manager.getPlugin(), (long) DeathSpectateSecs * 20 + 2); + return true; } - else - { - UtilPlayer.message(player, C.cRed + C.Bold + "You are out of the game!"); - player.playSound(player.getLocation(), Sound.EXPLODE, 2f, 1f); - return false; + String gameOver = "You ran out of lives!"; + + UtilTextMiddle.display(C.cRedB + "GAME OVER", gameOver, 10, 50, 10, player); + UtilPlayer.message(player, C.cRedB + gameOver); + player.playSound(player.getLocation(), Sound.EXPLODE, 2f, 1f); + + return false; + } + + @EventHandler + public void triggerSuper(PlayerInteractEvent event) + { + if (!IsLive()) + { + return; + } + + if (event.getMaterial() != Material.NETHER_STAR) + { + return; + } + + Player player = event.getPlayer(); + + for (Perk perk : GetKit(player).GetPerks()) + { + if (perk instanceof SmashUltimate) + { + SmashUltimate ultimate = (SmashUltimate) perk; + String name = ultimate.GetName(); + + if (ultimate.isUsingUltimate(player) || !ultimate.isUsable(player)) + { + continue; + } + + UtilInv.remove(player, Material.NETHER_STAR, (byte) 0, 1); + + player.setHealth(player.getMaxHealth()); + player.playSound(player.getLocation(), ultimate.getSound(), 10, 1); + + Announce(C.Bold + event.getPlayer().getName() + " activated " + C.cGreenB + name + ChatColor.RESET + C.Bold + "!"); + UtilTextMiddle.display("Smash Crystal", event.getPlayer().getName() + " used " + C.cGreen + name, 5, 50, 5, UtilServer.getPlayers()); + + ultimate.activate(player); + } } } + @SuppressWarnings("deprecation") @EventHandler public void powerupSpawn(UpdateEvent event) { if (event.getType() != UpdateType.FASTER) + { return; + } if (!IsLive()) + { return; + } + + if (_powerupHologram != null) + { + _powerupHologram.setText((_powerupHologramColour ? C.cGreenB : C.cWhiteB) + "SMASH CRYSTAL"); + _powerupHologramColour = !_powerupHologramColour; + } if (_powerup == null) { if (System.currentTimeMillis() < _nextPowerup) + { return; + } - if (WorldData.GetDataLocs("RED").isEmpty()) + if (WorldData.GetDataLocs(DATA_POINT_POWERUP).isEmpty()) + { return; + } if (_powerupTarget == null) { - Location newTarget = UtilAlg.Random(WorldData.GetDataLocs("RED")); - - _powerupTarget = newTarget; - _powerupCurrent = _powerupTarget.clone().add(0, 120, 0); - - //Blocks - for (int x=-1 ; x<=1 ; x++) - for (int z=-1 ; z<=1 ; z++) + BlockRestore blockRestore = Manager.GetBlockRestore(); + Location newTarget = UtilAlg.Random(WorldData.GetDataLocs(DATA_POINT_POWERUP)); + Block targetBlock = newTarget.getBlock(); + + // This relies on this method being called 4 times a second (5 + // ticks, UpdateType.FASTER). + long restoreTime = (POWERUP_SPAWN_Y_INCREASE / 4 / 2) * 1000 + 500; + + _powerupTarget = newTarget.clone(); + _powerupCurrent = newTarget.clone().add(0, POWERUP_SPAWN_Y_INCREASE, 0); + + // Blocks + for (int x = -1; x <= 1; x++) + { + for (int z = -1; z <= 1; z++) { - _restoreBlock.add(new BlockData(_powerupTarget.getBlock().getRelative(x, -2, z))); - _restoreBlock.add(new BlockData(_powerupTarget.getBlock().getRelative(x, -1, z))); - - _powerupTarget.getBlock().getRelative(x, -2, z).setType(Material.IRON_BLOCK); - _powerupTarget.getBlock().getRelative(x, -1, z).setType(Material.QUARTZ_BLOCK); + blockRestore.add(targetBlock.getRelative(x, -3, z), Material.IRON_BLOCK.getId(), (byte) 0, restoreTime); + + if (x == 0 && z == 0) + { + continue; + } + + blockRestore.add(targetBlock.getRelative(x, -1, z), Material.QUARTZ_BLOCK.getId(), (byte) 0, restoreTime); } - - _powerupTarget.getBlock().getRelative(BlockFace.DOWN).setType(Material.BEACON); + } + + blockRestore.add(targetBlock.getRelative(0, -2, 0), Material.BEACON.getId(), (byte) 0, restoreTime); + blockRestore.add(targetBlock.getRelative(0, -1, 0), Material.STAINED_GLASS.getId(), (byte) 5, restoreTime); } if (_powerupTarget.getY() < _powerupCurrent.getY()) { - _powerupCurrent.add(0, -2, 0); - UtilFirework.playFirework(_powerupCurrent, Type.BURST, Color.RED, false, true); + _powerupCurrent.subtract(0, 2, 0); + UtilFirework.playFirework(_powerupCurrent, Type.BURST, Color.LIME, false, true); } else { CreatureAllowOverride = true; _powerup = _powerupTarget.getWorld().spawn(_powerupTarget, EnderCrystal.class); + _powerupHologram = new Hologram(Manager.getHologramManager(), _powerupTarget.add(0, 2, 0), true, "SMASH CRYSTAL").start(); CreatureAllowOverride = false; - _powerupTarget.getBlock().getRelative(BlockFace.DOWN).setType(Material.GLASS); - + UtilFirework.playFirework(_powerupTarget, Type.BURST, Color.YELLOW, false, true); + _powerupTarget = null; _powerupCurrent = null; - - - //Restore Blocks - for (BlockData block : _restoreBlock) - block.restore(true); - _restoreBlock.clear(); } } } @@ -223,24 +349,37 @@ public abstract class SuperSmash extends Game @EventHandler public void powerupPickup(UpdateEvent event) { - if (event.getType() != UpdateType.TICK) + if (event.getType() != UpdateType.FASTEST) + { return; + } if (!IsLive()) + { return; + } if (_powerup == null) + { return; + } Player best = null; double bestDist = 0; for (Player player : GetPlayers(true)) { + if (UtilPlayer.isSpectator(player)) + { + continue; + } + double dist = UtilMath.offset(player, _powerup); if (dist > 2) + { continue; + } if (best == null || dist < bestDist) { @@ -251,68 +390,98 @@ public abstract class SuperSmash extends Game if (best != null) { + _powerupHologram.stop(); + _powerupHologram = null; + _powerup.remove(); _powerup = null; - best.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.NETHER_STAR, (byte)0, ((SmashKit)GetKit(best)).getSuperCharges(), - C.cYellow + C.Bold + "Click" + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + ((SmashKit)GetKit(best)).getSuperName())); - - _nextPowerup = (long) (System.currentTimeMillis() + 240000 + 360000 * Math.random()); - - Manager.GetGame().Announce(C.Bold + best.getName() + " collected " + C.cGreen + C.Bold + "Smash Crystal" + ChatColor.RESET + C.Bold + "!"); + giveSmashItem(best); + _nextPowerup = getNewSmashTime(); } } - + + private void giveSmashItem(Player player) + { + int amount = 1; + if(GetKit(player) instanceof KitSnowman) + { + amount = 3; + } + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.NETHER_STAR, (byte) 0, amount, C.cYellowB + "Click" + C.cWhiteB + " - " + C.cGreenB + "Smash")); + Manager.GetGame().Announce(C.Bold + player.getName() + " collected " + C.cGreen + C.Bold + "Smash Crystal" + ChatColor.RESET + C.Bold + "!"); + } + @EventHandler(priority = EventPriority.LOWEST) public void powerupDamage(EntityDamageEvent event) { if (_powerup != null && _powerup.equals(event.getEntity())) + { event.setCancelled(true); + } } @EventHandler(priority = EventPriority.LOWEST) - public void FallDamage(CustomDamageEvent event) + public void fallDamage(CustomDamageEvent event) { if (event.IsCancelled()) + { return; + } if (event.GetCause() == DamageCause.FALL) + { event.SetCancelled("No Fall Damage"); + } } @EventHandler(priority = EventPriority.HIGH) - public void Knockback(CustomDamageEvent event) + public void knockback(CustomDamageEvent event) { if (event.IsCancelled()) + { return; + } if (event.GetDamageePlayer() != null) - event.AddKnockback("Smash Knockback", 1 + 0.1 * (20 - event.GetDamageePlayer().getHealth())); + { + Player player = event.GetDamageePlayer(); + + event.AddKnockback("Smash Knockback", 1 + 0.1 * (player.getMaxHealth() - player.getHealth())); + } } @EventHandler(priority = EventPriority.HIGH) - public void ArenaWalls(CustomDamageEvent event) + public void arenaBoundry(CustomDamageEvent event) { if (event.IsCancelled()) + { return; + } if (event.GetCause() == DamageCause.VOID || event.GetCause() == DamageCause.LAVA) { - event.GetDamageeEntity().eject(); - event.GetDamageeEntity().leaveVehicle(); + LivingEntity entity = event.GetDamageeEntity(); + + entity.eject(); + entity.leaveVehicle(); if (event.GetDamageePlayer() != null) - event.GetDamageeEntity().getWorld().strikeLightningEffect(event.GetDamageeEntity().getLocation()); + { + entity.getWorld().strikeLightningEffect(entity.getLocation()); + } event.AddMod("Smash", "Super Smash Mobs", 5000, false); - } + } } @EventHandler - public void HealthChange(EntityRegainHealthEvent event) + public void healthRegen(EntityRegainHealthEvent event) { if (event.getRegainReason() == RegainReason.SATIATED) + { event.setCancelled(true); + } } @EventHandler(priority = EventPriority.MONITOR) @@ -322,7 +491,7 @@ public abstract class SuperSmash extends Game } @Override - public void SetKit(Player player, Kit kit, boolean announce) + public void SetKit(Player player, Kit kit, boolean announce) { GameTeam team = GetTeam(player); if (team != null) @@ -348,36 +517,53 @@ public abstract class SuperSmash extends Game } @EventHandler(priority = EventPriority.LOWEST) - public void AbilityDescription(PlayerInteractEvent event) + public void abilityDescription(PlayerInteractEvent event) { if (event.isCancelled()) + { return; + } Player player = event.getPlayer(); + ItemStack itemStack = player.getItemInHand(); - if (player.getItemInHand() == null) + if (itemStack == null) + { return; + } - if (player.getItemInHand().getItemMeta() == null) + if (itemStack.getItemMeta() == null) + { return; + } - if (player.getItemInHand().getItemMeta().getDisplayName() == null) + ItemMeta itemMeta = itemStack.getItemMeta(); + + if (itemMeta.getDisplayName() == null) + { return; + } - if (player.getItemInHand().getItemMeta().getLore() == null) + if (itemMeta.getLore() == null) + { return; + } - if (Manager.GetGame() == null || Manager.GetGame().GetState() != GameState.Recruit) + if (GetState() != GameState.Recruit) + { return; + } - for (int i=player.getItemInHand().getItemMeta().getLore().size() ; i<=7 ; i++) - UtilPlayer.message(player, " "); + for (int i = player.getItemInHand().getItemMeta().getLore().size(); i <= 7; i++) + { + UtilPlayer.message(player, ""); + } UtilPlayer.message(player, ArcadeFormat.Line); UtilPlayer.message(player, "§aAbility - §f§l" + player.getItemInHand().getItemMeta().getDisplayName()); - //Perk Descs + // Perk Descs for (String line : player.getItemInHand().getItemMeta().getLore()) { UtilPlayer.message(player, line); @@ -397,67 +583,191 @@ public abstract class SuperSmash extends Game } @EventHandler - public void BlockFade(BlockFadeEvent event) + public void blockFade(BlockFadeEvent event) { event.setCancelled(true); } private int hungerTick = 0; + @EventHandler - public void Hunger(UpdateEvent event) + public void hunger(UpdateEvent event) { if (event.getType() != UpdateType.SEC) + { return; + } if (!IsLive()) + { return; + } - hungerTick = (hungerTick + 1)%10; + hungerTick = (hungerTick + 1) % 10; for (Player player : GetPlayers(true)) { - player.setSaturation(3f); + player.setSaturation(3f); player.setExhaustion(0f); if (player.getFoodLevel() <= 0) { - Manager.GetDamage().NewDamageEvent(player, null, null, - DamageCause.STARVATION, 1, false, true, false, - "Starvation", GetName()); + Manager.GetDamage().NewDamageEvent(player, null, null, DamageCause.STARVATION, 1, false, true, false, "Starvation", GetName()); UtilPlayer.message(player, F.main("Game", "Attack other players to restore hunger!")); } if (hungerTick == 0) + { UtilPlayer.hunger(player, -1); + } } } @EventHandler(priority = EventPriority.MONITOR) - public void HungerRestore(CustomDamageEvent event) + public void hungerRestore(CustomDamageEvent event) { if (event.IsCancelled()) + { return; + } Player damager = event.GetDamagerPlayer(true); + if (damager == null) + { return; + } if (damager.equals(event.GetDamageeEntity())) + { return; - + } + if (!(event.GetDamageeEntity() instanceof Player)) - return; - - if (!Recharge.Instance.use(damager, "Hunger Restore", 250, false, false)) + { return; + } - int amount = Math.max(1, (int)(event.GetDamage()/2)); + if (!Recharge.Instance.use(damager, "Hunger Restore", HUNGER_DELAY, false, false)) + { + return; + } + + int amount = Math.max(1, (int) (event.GetDamage() / 2)); UtilPlayer.hunger(damager, amount); } - - public HashMap<Player, Integer> getLiveMap() + + @EventHandler + public void itemSpawn(ItemSpawnEvent event) + { + if (REMOVE_ON_ITEM_SPAWN.contains(event.getEntity().getItemStack().getType())) + { + event.setCancelled(true); + } + } + + public long getNewSmashTime() + { + return (long) (System.currentTimeMillis() + TimeUnit.MINUTES.toMillis(3) + TimeUnit.MINUTES.toMillis(5) * Math.random()); + } + + public String getLiveColour(int lives) + { + switch (lives) + { + case 3: + return C.cYellow; + case 2: + return C.cGold; + case 1: + return C.cRed; + case 0: + return C.cGray + C.Strike; + default: + return C.cGreen; + } + } + + public Map<Player, Integer> getLiveMap() { return _lives; } + + @EventHandler + public void debugCommands(PlayerCommandPreprocessEvent event) + { + if (!UtilServer.isTestServer()) + { + return; + } + + String message = event.getMessage(); + Player player = event.getPlayer(); + + if (message.startsWith("/cooldown")) + { + event.setCancelled(true); + + for (Player other : UtilServer.getPlayers()) + { + Recharge.Instance.Reset(other); + } + + Announce(C.cWhiteB + player.getName() + C.cAquaB + " reset cooldowns!"); + } + else if (message.startsWith("/nextsmash")) + { + event.setCancelled(true); + + _nextPowerup = System.currentTimeMillis() + 1000; + Announce(C.cWhiteB + player.getName() + C.cAquaB + " spawned a smash crystal!"); + } + else if (message.startsWith("/smash")) + { + event.setCancelled(true); + + giveSmashItem(player); + } + else if (message.startsWith("/kit")) + { + event.setCancelled(true); + + String[] args = message.split(" "); + String kit = ""; + + for (int i = 1; i < args.length; i++) + { + kit += args[i] + " "; + } + + kit = kit.trim(); + + for (Kit kits : GetKits()) + { + if (kit.equalsIgnoreCase(kits.GetName())) + { + SetKit(player, kits, true); + return; + } + } + + player.sendMessage(F.main("Kit", "Sorry that is not a kit!")); + } + else if (message.startsWith("/lives")) + { + event.setCancelled(true); + + Announce(C.cWhiteB + player.getName() + C.cAquaB + " reset their lives!"); + + if (!IsAlive(player)) + { + SetPlayerState(player, PlayerState.IN); + RespawnPlayer(player); + player.sendMessage(F.main("Revive", "You are back in the game!")); + } + + _lives.put(player, MAX_LIVES); + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/TeamSuperSmash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/TeamSuperSmash.java index 7d560c10a..c6414d5fd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/TeamSuperSmash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/TeamSuperSmash.java @@ -3,11 +3,21 @@ package nautilus.game.arcade.game.games.smash; import java.util.ArrayList; import java.util.List; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.scheduler.BukkitRunnable; + +import mineplex.core.common.Pair; import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.modules.TeamModule; import nautilus.game.arcade.managers.chat.ChatStatData; @@ -17,55 +27,31 @@ import nautilus.game.arcade.stats.OneVThreeStatTracker; import nautilus.game.arcade.stats.RecoveryMasterStatTracker; import nautilus.game.arcade.stats.WinWithoutDyingStatTracker; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; - public class TeamSuperSmash extends SuperSmash { - - public TeamSuperSmash(ArcadeManager manager) + + public TeamSuperSmash(ArcadeManager manager) { - super(manager, GameType.SmashTeams, - new String[] - { - "Each player has 3 respawns", - "Attack to restore hunger!", - "Last team alive wins!" - }); - + super(manager, GameType.SmashTeams, new String[] { "Each player has 3 respawns", "Attack to restore hunger!", "Last team alive wins!" }); + PlayersPerTeam = 2; FillTeamsInOrderToCount = 2; - + SpawnNearAllies = true; DamageTeamSelf = false; - + TeamArmorHotbar = true; - + DontAllowOverfill = true; - + TeamMode = true; registerModule(new TeamModule()); - registerStatTrackers( - new WinWithoutDyingStatTracker(this, "MLGPro"), - new FreeKitWinStatTracker(this), - new OneVThreeStatTracker(this), - new KillFastStatTracker(this, 3, 10, "TripleKill"), - new RecoveryMasterStatTracker(this) - ); + registerStatTrackers(new WinWithoutDyingStatTracker(this, "MLGPro"), new FreeKitWinStatTracker(this), new OneVThreeStatTracker(this), new KillFastStatTracker(this, 3, 10, "TripleKill"), + new RecoveryMasterStatTracker(this)); - registerChatStats( - Kills, - Deaths, - KDRatio, - BlankLine, - Assists, - DamageTaken, - DamageDealt, - BlankLine, - new ChatStatData("kit", "Kit", true) - ); + registerChatStats(Kills, Deaths, KDRatio, BlankLine, Assists, DamageTaken, DamageDealt, BlankLine, new ChatStatData("kit", "Kit", true)); } @Override @@ -75,53 +61,120 @@ public class TeamSuperSmash extends SuperSmash if (event.getType() != UpdateType.FAST) return; - ArrayList<GameTeam> alive = new ArrayList<GameTeam>(); - for (GameTeam team : GetTeamList()) - { - if (team.IsTeamAlive()) - alive.add(team); - } - //Wipe Last Scoreboard.reset(); - Scoreboard.writeNewLine(); + + List<GameTeam> aliveTeams = new ArrayList<>(); - if (GetPlayers(true).size() < 16) + for (GameTeam team : GetTeamList()) { - - for (GameTeam team : GetTeamList()) + if (team.GetPlayers(true).isEmpty()) { - for (Player player : team.GetPlayers(true)) - { - int lives = GetLives(player); - - Scoreboard.write(C.cWhite + lives + " " + team.GetColor() + player.getName()); - } + continue; } + + aliveTeams.add(team); } - else if (alive.size() < 16) + + if (aliveTeams.size() > 7) { - for (GameTeam team : alive) - { - int lives = 0; - - for (Player player : team.GetPlayers(true)) - { - lives += GetLives(player); - } - - Scoreboard.write(C.cWhite + lives + " " + team.GetColor() + team.GetName()); - } + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellowB + "Teams Alive"); + Scoreboard.write(aliveTeams.size() + " "); } else { - Scoreboard.write(C.cYellow + C.Bold + "Teams Alive"); - Scoreboard.write(C.cWhite + alive.size()); + Scoreboard.writeNewLine(); + + for (GameTeam team : GetTeamList()) + { + Scoreboard.writeGroup(team.GetPlayers(false), player -> + { + int lives = getLives(player); + + return Pair.create(team.GetColor() + (IsAlive(player) ? "" : C.Strike) + player.getName(), lives); + }, true); + } } - + Scoreboard.draw(); } + + @Override + @EventHandler + public void gameStart(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + { + return; + } + + super.gameStart(event); + + new BukkitRunnable() + { + + @Override + public void run() + { + for (Player player : GetPlayers(true)) + { + GameTeam team = GetTeam(player); + Player bestTeamMember = null; + + if (team == null) + { + continue; + } + + for (Player teamMember : team.GetPlayers(true)) + { + if (player.equals(teamMember)) + { + continue; + } + + bestTeamMember = teamMember; + } + + if (bestTeamMember == null) + { + UtilTextMiddle.display(C.cRedB + "No one", "You don\'t have a teammate :(", 10, 50, 10, player); + return; + } + + UtilTextMiddle.display(null, team.GetColor() + bestTeamMember.getName() + " is your teammate", 10, 50, 10, player); + } + } + }.runTaskLater(Manager.getPlugin(), 40); + } + @EventHandler + public void onCustomDamage(CustomDamageEvent event) + { + if (!(event.GetDamagerEntity(true) instanceof Player || event.GetDamageeEntity() instanceof Player)) + { + return; + } + + Player damager = event.GetDamagerPlayer(true); + Player damagee = event.GetDamageePlayer(); + + if (GetTeam(damager) == null || GetTeam(damagee) == null) + { + return; + } + + if (GetTeam(damager).equals(GetTeam(damagee))) + { + if (event.GetCause() == DamageCause.FIRE) + { + damagee.setFireTicks(0); + } + + event.SetCancelled("Team Damage"); + } + } @Override public void EndCheck() { @@ -136,7 +189,7 @@ public class TeamSuperSmash extends SuperSmash if (teamsAlive.size() <= 1) { - //Announce + // Announce if (teamsAlive.size() > 0) AnnounceEnd(teamsAlive.get(0)); @@ -153,7 +206,7 @@ public class TeamSuperSmash extends SuperSmash AddGems(player, 10, "Participation", false, false); } - //End + // End SetState(GameState.End); } } @@ -183,10 +236,41 @@ public class TeamSuperSmash extends SuperSmash return players; } - + @Override public String GetMode() { return "Team Mode"; } + + /** + * @param manager The arcade manager + * @param player The player to check + * @param includeSelf If true, then the list will contain the given player in addition to team mates. If false then it will + * not include the player. If the given player is a spectator then this will always return empty. + * @return Returns a list of players who the given player should not be able to damage as they are + * the player's team mates. If the given player is a spectator the list will return empty. If the game is Solo Super Smash Mobs + * or any other game than Team Super Smash Mob then the list will return only the player or empty depending on <code>includeSelf</code> + */ + public static List<Player> getTeam(ArcadeManager manager, Player player, boolean includeSelf) + { + List<Player> list = new ArrayList<>(); + if(!manager.IsAlive(player)) + { + return list; + } + else if(manager.GetGame() instanceof TeamSuperSmash) + { + list.addAll(manager.GetGame().GetTeam(player).GetPlayers(true)); + if(!includeSelf) list.remove(player); + } + else + { + if(includeSelf) + { + list.add(player); + } + } + return list; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitBlaze.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitBlaze.java index 2214dfa2a..37399886a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitBlaze.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitBlaze.java @@ -1,5 +1,12 @@ package nautilus.game.arcade.game.games.smash.kits; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.inventory.ItemStack; + import mineplex.core.common.util.C; import mineplex.core.common.util.UtilInv; import mineplex.core.disguise.disguises.DisguiseBlaze; @@ -8,31 +15,27 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.smash.perks.PerkSmashStats; +import nautilus.game.arcade.game.games.smash.perks.SmashKit; +import nautilus.game.arcade.game.games.smash.perks.blaze.PerkFirefly; +import nautilus.game.arcade.game.games.smash.perks.blaze.PerkInferno; +import nautilus.game.arcade.game.games.smash.perks.blaze.SmashBlaze; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.SmashKit; -import nautilus.game.arcade.kit.perks.*; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.inventory.ItemStack; +import nautilus.game.arcade.kit.perks.PerkDoubleJump; +import nautilus.game.arcade.kit.perks.PerkKnockbackFire; +import nautilus.game.arcade.kit.perks.PerkSpeed; public class KitBlaze extends SmashKit { - private static final String[] DESCRIPTION = { - DOUBLE_JUMP, - }; - private static final Perk[] PERKS = { - new PerkSmashStats(6, 1.5, 0.15, 5), + new PerkSmashStats(6, 1.5, 0.25, 5), new PerkDoubleJump("Double Jump", 1, 1, false), new PerkKnockbackFire(1.50), new PerkSpeed(0), new PerkInferno(), - new PerkFirefly() + new PerkFirefly(), + new SmashBlaze() }; private static final ItemStack IN_HAND = new ItemStack(Material.BLAZE_ROD); @@ -64,20 +67,22 @@ public class KitBlaze extends SmashKit }; private static final ItemStack[] PLAYER_ARMOR = { - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_BOOTS), - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_LEGGINGS), - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_CHESTPLATE), + new ItemStack(Material.CHAINMAIL_BOOTS), + new ItemStack(Material.CHAINMAIL_LEGGINGS), + new ItemStack(Material.CHAINMAIL_CHESTPLATE), }; public KitBlaze(ArcadeManager manager) { - super(manager, "Blaze", KitAvailability.Gem, 8000, DESCRIPTION, PERKS, EntityType.BLAZE, IN_HAND, "Phoenix", 18000, Sound.BLAZE_DEATH); + super(manager, "Blaze", KitAvailability.Gem, 8000, PERKS, EntityType.BLAZE, IN_HAND, DisguiseBlaze.class); } - + @Override - public void giveCoreItems(Player player) - { + public void GiveItems(Player player) + { + disguise(player); + UtilInv.Clear(player); player.getInventory().addItem(PLAYER_ITEMS[0], PLAYER_ITEMS[1]); @@ -86,51 +91,30 @@ public class KitBlaze extends SmashKit player.getInventory().addItem(PLAYER_ITEMS[2]); } - player.getInventory().setArmorContents(PLAYER_ARMOR); } - @Override - public void giveSuperItems(Player player) - { - player.getInventory().remove(Material.IRON_SWORD); - player.getInventory().remove(Material.IRON_AXE); - - UtilInv.Update(player); - } - - @Override - public void GiveItems(Player player) - { - giveCoreItems(player); - - //Disguise - DisguiseBlaze disguise = new DisguiseBlaze(player); - - if (Manager.GetGame().GetTeam(player) != null) - disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); - else - disguise.setName(player.getName()); - - disguise.setCustomNameVisible(true); - Manager.GetDisguise().disguise(disguise); - } - @EventHandler public void FireItemResist(UpdateEvent event) { if (event.getType() != UpdateType.FAST) + { return; - + } + if (Manager.GetGame() == null) + { return; - + } + for (Player player : Manager.GetGame().GetPlayers(true)) { if (!HasKit(player)) + { continue; - + } + Manager.GetCondition().Factory().FireItemImmunity(GetName(), player, player, 1.9, false); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitChicken.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitChicken.java index 3cf01c3f6..6e4f0b442 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitChicken.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitChicken.java @@ -1,35 +1,35 @@ package nautilus.game.arcade.game.games.smash.kits; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + import mineplex.core.common.util.C; import mineplex.core.common.util.UtilInv; import mineplex.core.disguise.disguises.DisguiseChicken; import mineplex.core.itemstack.ItemStackFactory; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.smash.perks.PerkSmashStats; +import nautilus.game.arcade.game.games.smash.perks.SmashKit; +import nautilus.game.arcade.game.games.smash.perks.chicken.PerkChickenRocket; +import nautilus.game.arcade.game.games.smash.perks.chicken.PerkEggGun; +import nautilus.game.arcade.game.games.smash.perks.chicken.PerkFlap; +import nautilus.game.arcade.game.games.smash.perks.chicken.SmashChicken; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.SmashKit; -import nautilus.game.arcade.kit.perks.PerkChickenRocket; -import nautilus.game.arcade.kit.perks.PerkEggGun; -import nautilus.game.arcade.kit.perks.PerkFlap; -import nautilus.game.arcade.kit.perks.PerkSmashStats; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; public class KitChicken extends SmashKit { - private static final String[] DESCRIPTION = { - }; - + private static final Perk[] PERKS = { - new PerkSmashStats(4, 2.0, 0.15, 2), + new PerkSmashStats(4.5, 2.0, 0.2, 2), new PerkFlap(0.8, 0.8, false), new PerkEggGun(), - new PerkChickenRocket() + new PerkChickenRocket(), + new SmashChicken() }; private static final ItemStack IN_HAND = new ItemStack(Material.EGG); @@ -71,19 +71,21 @@ public class KitChicken extends SmashKit private static final ItemStack[] PLAYER_ARMOR = { null, null, - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_CHESTPLATE), + new ItemStack(Material.CHAINMAIL_CHESTPLATE), null }; public KitChicken(ArcadeManager manager) { - super(manager, "Chicken", KitAvailability.Gem, 8000, DESCRIPTION, PERKS, EntityType.CHICKEN, IN_HAND, "Aerial Gunner", 20000, Sound.CHICKEN_HURT); + super(manager, "Chicken", KitAvailability.Gem, 8000, PERKS, EntityType.CHICKEN, IN_HAND, DisguiseChicken.class); } @Override - public void giveCoreItems(Player player) + public void GiveItems(Player player) { + disguise(player); + UtilInv.Clear(player); player.getInventory().addItem(PLAYER_ITEMS[0], PLAYER_ITEMS[1]); @@ -93,39 +95,6 @@ public class KitChicken extends SmashKit player.getInventory().addItem(PLAYER_ITEMS[2], PLAYER_ITEMS[3]); } - player.getInventory().setArmorContents(PLAYER_ARMOR); } - - @Override - public void giveSuperItems(Player player) - { - player.getInventory().remove(Material.IRON_SWORD); - player.getInventory().remove(Material.IRON_AXE); - - UtilInv.Update(player); - } - - @Override - public void GiveItems(Player player) - { - giveCoreItems(player); - - //Disguise - DisguiseChicken disguise = new DisguiseChicken(player); - - if (Manager.GetGame().GetTeam(player) != null) - disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); - else - disguise.setName(player.getName()); - - disguise.setCustomNameVisible(true); - Manager.GetDisguise().disguise(disguise); - } - - @Override - public void activateSuperCustom(Player player) - { - player.setExp(0.99f); - } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitCow.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitCow.java index 532d38060..33b49741d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitCow.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitCow.java @@ -1,38 +1,37 @@ package nautilus.game.arcade.game.games.smash.kits; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + import mineplex.core.common.util.C; import mineplex.core.common.util.UtilInv; import mineplex.core.disguise.disguises.DisguiseCow; import mineplex.core.itemstack.ItemStackFactory; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.Game.GameState; -import nautilus.game.arcade.game.games.smash.perks.PerkCowAngryHerd; -import nautilus.game.arcade.game.games.smash.perks.PerkCowMilkSpiral; -import nautilus.game.arcade.game.games.smash.perks.PerkCowMooshroomMadness; -import nautilus.game.arcade.game.games.smash.perks.PerkCowStampede; +import nautilus.game.arcade.game.games.smash.perks.PerkSmashStats; +import nautilus.game.arcade.game.games.smash.perks.SmashKit; +import nautilus.game.arcade.game.games.smash.perks.cow.PerkCowAngryHerd; +import nautilus.game.arcade.game.games.smash.perks.cow.PerkCowMilkSpiral; +import nautilus.game.arcade.game.games.smash.perks.cow.SmashCow; +import nautilus.game.arcade.game.games.smash.perks.cow.PerkCowStampede; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.SmashKit; import nautilus.game.arcade.kit.perks.PerkDoubleJump; -import nautilus.game.arcade.kit.perks.PerkSmashStats; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; public class KitCow extends SmashKit { - private static final String[] DESCRIPTION = { - }; private static final Perk[] PERKS = { - new PerkSmashStats(6, 0.9, 0.25, 7.5), + new PerkSmashStats(6, 1.1, 0.25, 6.5), new PerkDoubleJump("Double Jump", 0.9, 0.9, false), - new PerkCowStampede(), + new PerkCowStampede(), new PerkCowAngryHerd(), new PerkCowMilkSpiral(), - new PerkCowMooshroomMadness() + new SmashCow() }; private static final ItemStack IN_HAND = new ItemStack(Material.MILK_BUCKET); @@ -70,57 +69,34 @@ public class KitCow extends SmashKit ChatColor.RESET + "and abilities, halves ability cooldowns,", ChatColor.RESET + "and increases your health to 15 hearts.", ChatColor.RESET + "", - ChatColor.RESET + "You remain a Mooshroom until you die.", + ChatColor.RESET + "You remain a Mooshroom for 30 seconds.", }) }; private static final ItemStack[] PLAYER_ARMOR = { - ItemStackFactory.Instance.CreateStack(Material.IRON_BOOTS), - ItemStackFactory.Instance.CreateStack(Material.IRON_LEGGINGS), - ItemStackFactory.Instance.CreateStack(Material.IRON_CHESTPLATE), - ItemStackFactory.Instance.CreateStack(Material.IRON_HELMET), - + new ItemStack(Material.IRON_BOOTS), + new ItemStack(Material.IRON_LEGGINGS), + new ItemStack(Material.CHAINMAIL_CHESTPLATE), + new ItemStack(Material.IRON_HELMET), }; public KitCow(ArcadeManager manager) { - super(manager, "Cow", KitAvailability.Gem, 6000, DESCRIPTION, PERKS, EntityType.COW, IN_HAND, "Mooshroom Madness", 0, null); + super(manager, "Cow", KitAvailability.Gem, 6000, PERKS, EntityType.COW, IN_HAND, DisguiseCow.class); } @Override - public void giveCoreItems(Player player) + public void GiveItems(Player player) { + disguise(player); + UtilInv.Clear(player); player.getInventory().addItem(PLAYER_ITEMS[0], PLAYER_ITEMS[1]); if (Manager.GetGame().GetState() == GameState.Recruit) player.getInventory().addItem(PLAYER_ITEMS[2], PLAYER_ITEMS[3]); - player.getInventory().setArmorContents(PLAYER_ARMOR); } - - @Override - public void giveSuperItems(Player player) - { - - } - - @Override - public void GiveItems(Player player) - { - giveCoreItems(player); - - //Disguise - DisguiseCow disguise = new DisguiseCow(player); - - if (Manager.GetGame().GetTeam(player) != null) - disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); - else - disguise.setName(player.getName()); - - disguise.setCustomNameVisible(true); - Manager.GetDisguise().disguise(disguise); - } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitCreeper.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitCreeper.java index 46d839e2b..9503a5c9f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitCreeper.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitCreeper.java @@ -1,33 +1,36 @@ package nautilus.game.arcade.game.games.smash.kits; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + import mineplex.core.common.util.C; import mineplex.core.common.util.UtilInv; import mineplex.core.disguise.disguises.DisguiseCreeper; import mineplex.core.itemstack.ItemStackFactory; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.smash.perks.PerkSmashStats; +import nautilus.game.arcade.game.games.smash.perks.SmashKit; +import nautilus.game.arcade.game.games.smash.perks.creeper.PerkCreeperElectricity; +import nautilus.game.arcade.game.games.smash.perks.creeper.PerkCreeperExplode; +import nautilus.game.arcade.game.games.smash.perks.creeper.PerkCreeperSulphurBomb; +import nautilus.game.arcade.game.games.smash.perks.creeper.SmashCreeper; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.SmashKit; -import nautilus.game.arcade.kit.perks.*; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; +import nautilus.game.arcade.kit.perks.PerkDoubleJump; public class KitCreeper extends SmashKit { - private static final String[] DESCRIPTION = { - }; - private static final Perk[] PERKS = { new PerkSmashStats(6, 1.65, 0.4, 3.5), new PerkDoubleJump("Double Jump", 0.9, 0.9, false), new PerkCreeperElectricity(), new PerkCreeperSulphurBomb(), new PerkCreeperExplode(), + new SmashCreeper() }; private static final ItemStack IN_HAND = new ItemStack(Material.TNT); @@ -72,21 +75,22 @@ public class KitCreeper extends SmashKit }; private static final ItemStack[] PLAYER_ARMOR = { - ItemStackFactory.Instance.CreateStack(Material.LEATHER_BOOTS), - ItemStackFactory.Instance.CreateStack(Material.LEATHER_LEGGINGS), - ItemStackFactory.Instance.CreateStack(Material.LEATHER_CHESTPLATE), - ItemStackFactory.Instance.CreateStack(Material.LEATHER_HELMET), - + new ItemStack(Material.LEATHER_BOOTS), + new ItemStack(Material.LEATHER_LEGGINGS), + new ItemStack(Material.LEATHER_CHESTPLATE), + new ItemStack(Material.LEATHER_HELMET), }; public KitCreeper(ArcadeManager manager) { - super(manager, "Creeper", KitAvailability.Gem, 4000, DESCRIPTION, PERKS, EntityType.CREEPER, IN_HAND, "Atomic Blast", 0, Sound.CREEPER_DEATH); + super(manager, "Creeper", KitAvailability.Gem, 4000, PERKS, EntityType.CREEPER, IN_HAND, DisguiseCreeper.class); } @Override - public void giveCoreItems(Player player) + public void GiveItems(Player player) { + disguise(player); + UtilInv.Clear(player); player.getInventory().addItem(PLAYER_ITEMS[0], PLAYER_ITEMS[1]); @@ -95,27 +99,4 @@ public class KitCreeper extends SmashKit player.getInventory().setArmorContents(PLAYER_ARMOR); } - - @Override - public void giveSuperItems(Player player) - { - - } - - @Override - public void GiveItems(Player player) - { - giveCoreItems(player); - - //Disguise - DisguiseCreeper disguise = new DisguiseCreeper(player); - - if (Manager.GetGame().GetTeam(player) != null) - disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); - else - disguise.setName(player.getName()); - - disguise.setCustomNameVisible(true); - Manager.GetDisguise().disguise(disguise); - } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitEnderman.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitEnderman.java index d064ad2ba..0b2307689 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitEnderman.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitEnderman.java @@ -1,5 +1,17 @@ package nautilus.game.arcade.game.games.smash.kits; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map.Entry; + +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.inventory.ItemStack; + import mineplex.core.common.util.C; import mineplex.core.common.util.UtilInv; import mineplex.core.disguise.disguises.DisguiseEnderman; @@ -8,30 +20,20 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.Game.GameState; -import nautilus.game.arcade.game.games.smash.perks.PerkEndermanTeleport; +import nautilus.game.arcade.game.games.smash.perks.PerkSmashStats; +import nautilus.game.arcade.game.games.smash.perks.SmashKit; +import nautilus.game.arcade.game.games.smash.perks.enderman.PerkBlink; +import nautilus.game.arcade.game.games.smash.perks.enderman.PerkBlockToss; +import nautilus.game.arcade.game.games.smash.perks.enderman.PerkEndermanTeleport; +import nautilus.game.arcade.game.games.smash.perks.enderman.SmashEnderman; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.SmashKit; -import nautilus.game.arcade.kit.perks.*; +import nautilus.game.arcade.kit.perks.PerkDoubleJump; import nautilus.game.arcade.kit.perks.event.PerkBlockGrabEvent; import nautilus.game.arcade.kit.perks.event.PerkBlockThrowEvent; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.inventory.ItemStack; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map.Entry; public class KitEnderman extends SmashKit { - private static final String[] DESCRIPTION = { - }; private static final Perk[] PERKS = { new PerkSmashStats(7, 1.3, 0.25, 6), @@ -39,7 +41,7 @@ public class KitEnderman extends SmashKit new PerkBlink("Blink", 16, 6000), new PerkBlockToss(), new PerkEndermanTeleport(), - new PerkEndermanDragon() + new SmashEnderman() }; private static final ItemStack IN_HAND = new ItemStack(Material.ENDER_PEARL); @@ -73,10 +75,10 @@ public class KitEnderman extends SmashKit }; private static final ItemStack[] PLAYER_ARMOR = { - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_BOOTS), - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_LEGGINGS), - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_CHESTPLATE), - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_HELMET), + new ItemStack(Material.CHAINMAIL_BOOTS), + new ItemStack(Material.CHAINMAIL_LEGGINGS), + new ItemStack(Material.CHAINMAIL_CHESTPLATE), + new ItemStack(Material.CHAINMAIL_HELMET), }; @@ -84,49 +86,26 @@ public class KitEnderman extends SmashKit public KitEnderman(ArcadeManager manager) { - super(manager, "Enderman", KitAvailability.Gem, 3000, DESCRIPTION, PERKS, EntityType.ENDERMAN, IN_HAND, "Dragon Rider", 30000, Sound.ENDERDRAGON_GROWL); - } - - @Override - public void giveCoreItems(Player player) - { - UtilInv.Clear(player); - - player.getInventory().addItem(PLAYER_ITEMS[0], PLAYER_ITEMS[1]); - - if (Manager.GetGame().GetState() == GameState.Recruit) - player.getInventory().addItem(PLAYER_ITEMS[2]); - - player.getInventory().setArmorContents(PLAYER_ARMOR); - } - - @Override - public void giveSuperItems(Player player) - { - player.getInventory().remove(Material.IRON_SWORD); - player.getInventory().remove(Material.IRON_AXE); - - UtilInv.Update(player); + super(manager, "Enderman", KitAvailability.Gem, 3000, PERKS, EntityType.ENDERMAN, IN_HAND, DisguiseEnderman.class); } @Override public void GiveItems(Player player) { - giveCoreItems(player); + disguise(player); + + _disguises.put(player, (DisguiseEnderman) Manager.GetDisguise().getActiveDisguise(player)); + + UtilInv.Clear(player); - //Disguise - DisguiseEnderman disguise = new DisguiseEnderman(player); + player.getInventory().addItem(PLAYER_ITEMS[0], PLAYER_ITEMS[1]); - if (Manager.GetGame().GetTeam(player) != null) - disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); - else - disguise.setName(player.getName()); - - disguise.setCustomNameVisible(true); - disguise.a(false); - Manager.GetDisguise().disguise(disguise); - - _disguises.put(player, disguise); + if (Manager.GetGame().GetState() == GameState.Recruit) + { + player.getInventory().addItem(PLAYER_ITEMS[2]); + } + + player.getInventory().setArmorContents(PLAYER_ARMOR); } @EventHandler @@ -150,8 +129,10 @@ public class KitEnderman extends SmashKit public void SetBlock(DisguiseEnderman disguise, int id, byte data) { if (disguise == null) + { return; - + } + disguise.SetCarriedId(id); disguise.SetCarriedData(data); @@ -162,16 +143,19 @@ public class KitEnderman extends SmashKit public void cleanDisguises(UpdateEvent event) { if (event.getType() != UpdateType.FAST) + { return; - - for (Iterator<Entry<Player, DisguiseEnderman>> iterator = _disguises.entrySet().iterator(); iterator.hasNext(); ) + } + + for (Iterator<Entry<Player, DisguiseEnderman>> iterator = _disguises.entrySet().iterator(); iterator.hasNext();) { Entry<Player, DisguiseEnderman> current = iterator.next(); if (!Manager.GetDisguise().isDisguised(current.getKey())) { iterator.remove(); - } else if (Manager.GetDisguise().getDisguise(current.getKey()) != current.getValue()) + } + else if (Manager.GetDisguise().getActiveDisguise(current.getKey()) != current.getValue()) { iterator.remove(); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitGolem.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitGolem.java index 14d1f20d9..00c38f95f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitGolem.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitGolem.java @@ -1,26 +1,30 @@ package nautilus.game.arcade.game.games.smash.kits; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + import mineplex.core.common.util.C; import mineplex.core.common.util.UtilInv; import mineplex.core.disguise.disguises.DisguiseIronGolem; import mineplex.core.itemstack.ItemStackFactory; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.smash.perks.PerkSmashStats; +import nautilus.game.arcade.game.games.smash.perks.SmashKit; +import nautilus.game.arcade.game.games.smash.perks.golem.PerkFissure; +import nautilus.game.arcade.game.games.smash.perks.golem.SmashGolem; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.SmashKit; -import nautilus.game.arcade.kit.perks.*; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; +import nautilus.game.arcade.kit.perks.PerkDoubleJump; +import nautilus.game.arcade.kit.perks.PerkIronHook; +import nautilus.game.arcade.kit.perks.PerkSeismicSlam; +import nautilus.game.arcade.kit.perks.PerkSlow; public class KitGolem extends SmashKit { - private static final String[] DESCRIPTION = { - }; private static final Perk[] PERKS = { new PerkSmashStats(7, 1.0, 0.2, 8), @@ -29,7 +33,7 @@ public class KitGolem extends SmashKit new PerkFissure(), new PerkIronHook(), new PerkSeismicSlam(), - new PerkEarthquake() + new SmashGolem() }; private static final ItemStack IN_HAND = new ItemStack(Material.IRON_BLOCK); @@ -66,20 +70,22 @@ public class KitGolem extends SmashKit }; private static final ItemStack[] PLAYER_ARMOR = { - ItemStackFactory.Instance.CreateStack(Material.DIAMOND_BOOTS), - ItemStackFactory.Instance.CreateStack(Material.IRON_LEGGINGS), - ItemStackFactory.Instance.CreateStack(Material.IRON_CHESTPLATE), - ItemStackFactory.Instance.CreateStack(Material.IRON_HELMET), + new ItemStack(Material.DIAMOND_BOOTS), + new ItemStack(Material.IRON_LEGGINGS), + new ItemStack(Material.IRON_CHESTPLATE), + new ItemStack(Material.IRON_HELMET), }; public KitGolem(ArcadeManager manager) { - super(manager, "Iron Golem", KitAvailability.Free, DESCRIPTION, PERKS, EntityType.IRON_GOLEM, IN_HAND, "Earthquake", 0, Sound.IRONGOLEM_DEATH); + super(manager, "Iron Golem", KitAvailability.Free, PERKS, EntityType.IRON_GOLEM, IN_HAND, DisguiseIronGolem.class); } @Override - public void giveCoreItems(Player player) + public void GiveItems(Player player) { + disguise(player); + UtilInv.Clear(player); player.getInventory().addItem(PLAYER_ITEMS[0], PLAYER_ITEMS[1], PLAYER_ITEMS[2]); @@ -89,27 +95,4 @@ public class KitGolem extends SmashKit player.getInventory().setArmorContents(PLAYER_ARMOR); } - - @Override - public void giveSuperItems(Player player) - { - - } - - @Override - public void GiveItems(Player player) - { - giveCoreItems(player); - - //Disguise - DisguiseIronGolem disguise = new DisguiseIronGolem(player); - - if (Manager.GetGame().GetTeam(player) != null) - disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); - else - disguise.setName(player.getName()); - - disguise.setCustomNameVisible(true); - Manager.GetDisguise().disguise(disguise); - } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitGuardian.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitGuardian.java new file mode 100644 index 000000000..45129c462 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitGuardian.java @@ -0,0 +1,108 @@ +package nautilus.game.arcade.game.games.smash.kits; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilInv; +import mineplex.core.disguise.disguises.DisguiseGuardian; +import mineplex.core.itemstack.ItemStackFactory; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.smash.perks.PerkSmashStats; +import nautilus.game.arcade.game.games.smash.perks.SmashKit; +import nautilus.game.arcade.game.games.smash.perks.guardian.PerkTargetLazer; +import nautilus.game.arcade.game.games.smash.perks.guardian.PerkThorns; +import nautilus.game.arcade.game.games.smash.perks.guardian.PerkWaterSplash; +import nautilus.game.arcade.game.games.smash.perks.guardian.PerkWhirlpoolBlade; +import nautilus.game.arcade.game.games.smash.perks.guardian.SmashGuardian; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.PerkDoubleJump; + +public class KitGuardian extends SmashKit +{ + + private static final Perk[] PERKS = { + new PerkSmashStats(4, 1.25, 0.25, 4.5), + new PerkDoubleJump("Double Jump", 0.9, 0.9, false), + new PerkWhirlpoolBlade(), + new PerkWaterSplash(), + new PerkTargetLazer(), + new PerkThorns(), + new SmashGuardian() + }; + + private static final ItemStack IN_HAND = new ItemStack(Material.PRISMARINE_SHARD); + + private static final ItemStack[] PLAYER_ITEMS = { + ItemStackFactory.Instance.CreateStack(Material.IRON_AXE, (byte) 0, 1, + C.cYellowB + "Right-Click" + C.cWhiteB + " - " + C.cGreenB + "Whirlpool Axe", + new String[] { + C.Reset + "Fires a Prismarine Shard that deals damage to", + C.Reset + "the first player it collides with.", + C.Reset + "The player is then drawn towards you." + }), + ItemStackFactory.Instance.CreateStack(Material.IRON_SWORD, (byte) 0, 1, + C.cYellowB + "Right-Click" + C.cWhiteB + " - " + C.cGreenB + "Water Splash", + new String[] { + C.Reset + "You bounce into the air and pull all nearby players", + C.Reset + "towards you.", + C.Reset + "Blocking with the sword while bouncing increases the height.", + C.Reset + "Landing causes a water splash dealing damage and knockback", + C.Reset + "to nearby players." + }), + ItemStackFactory.Instance.CreateStack(Material.IRON_PICKAXE, (byte) 0, 1, + C.cYellowB + "Right-Click" + C.cWhiteB + " - " + C.cGreenB + "Target Laser", + new String[] { + C.Reset + "You target the nearest player with your laser.", + C.Reset + "That player takes increased damage and knockback from you.", + C.Reset + "Your laser breaks if you get too far away or after some time." + }), + ItemStackFactory.Instance.CreateStack(Material.PRISMARINE_SHARD, (byte) 0, 1, + C.cYellowB + "Passive" + C.cWhiteB + " - " + C.cGreenB + "Thorns", + new String[] { + C.Reset + "Takes 66% less damage and knockback from projectiles", + C.Reset + "when under 10 health.", + }), + ItemStackFactory.Instance.CreateStack(Material.NETHER_STAR, (byte) 0, 1, + C.cYellowB + "Smash Crystal" + C.cWhiteB + " - " + C.cGreenB + "Rise of the Guardian", + new String[] { + C.Reset + "You call upon Gwen who begins to charge her laser.", + C.Reset + "Any player near the laser is drawn to it and cannot", + C.Reset + "escape from it.", + C.Reset + "Once the laser has charged all players nearby get hit", + C.Reset + "with HUGE damage and knockback!" + }), + }; + + private static final ItemStack[] PLAYER_ARMOR = { + new ItemStack(Material.DIAMOND_BOOTS), + new ItemStack(Material.DIAMOND_LEGGINGS), + null, + null, + }; + + public KitGuardian(ArcadeManager manager) + { + super(manager, "Guardian", KitAvailability.Gem, 8000, PERKS, EntityType.GUARDIAN, IN_HAND, DisguiseGuardian.class); + } + + @Override + public void GiveItems(Player player) + { + disguise(player); + + UtilInv.Clear(player); + + player.getInventory().addItem(PLAYER_ITEMS[0], PLAYER_ITEMS[1], PLAYER_ITEMS[2]); + + if (Manager.GetGame().GetState() == GameState.Recruit) + player.getInventory().addItem(PLAYER_ITEMS[3], PLAYER_ITEMS[4]); + + player.getInventory().setArmorContents(PLAYER_ARMOR); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitKnight.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitKnight.java deleted file mode 100644 index 5981b1303..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitKnight.java +++ /dev/null @@ -1,291 +0,0 @@ -package nautilus.game.arcade.game.games.smash.kits; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; - -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Horse; -import org.bukkit.entity.Horse.Color; -import org.bukkit.entity.Horse.Style; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Horse.Variant; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.player.PlayerInteractEntityEvent; -import org.bukkit.inventory.ItemStack; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilInv; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.disguise.disguises.DisguiseSkeleton; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.kit.KitAvailability; -import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.SmashKit; -import nautilus.game.arcade.kit.perks.PerkNotFinished; -import nautilus.game.arcade.kit.perks.PerkDoubleJumpHorse; -import nautilus.game.arcade.kit.perks.PerkFletcher; -import nautilus.game.arcade.kit.perks.PerkHorseKick; -import nautilus.game.arcade.kit.perks.PerkKnockbackArrow; -import nautilus.game.arcade.kit.perks.PerkSmashStats; - -public class KitKnight extends SmashKit -{ - private HashMap<Player, Horse> _mounts = new HashMap<Player, Horse>(); - private HashSet<Horse> _horses = new HashSet<Horse>(); - - private HashSet<CustomDamageEvent> _calledEvents = new HashSet<CustomDamageEvent>(); - - public KitKnight(ArcadeManager manager) - { - super(manager, "Undead Knight", KitAvailability.Gem, 5000, - - new String[] - { - }, - - new Perk[] - { - new PerkSmashStats(6, 1.2, 0.25, 7.5), - new PerkFletcher(1, 2, false), - new PerkKnockbackArrow(2), - new PerkDoubleJumpHorse(), - new PerkHorseKick(), - new PerkNotFinished() - }, - EntityType.HORSE, - new ItemStack(Material.IRON_BARDING), - "", 0, null); - } - - @Override - public void giveCoreItems(Player player) - { - UtilInv.Clear(player); - - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_AXE, (byte)0, 1, - C.cYellow + C.Bold + "Right-Click" + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + "Horse Kick", - new String[] - { - - })); - - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.BOW, (byte)0, 1, - C.cYellow + C.Bold + "Right-Click" + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + "Coming Soon...", - new String[] - { - - })); - - player.getInventory().setHelmet(ItemStackFactory.Instance.CreateStack(Material.IRON_HELMET)); - player.getInventory().setChestplate(ItemStackFactory.Instance.CreateStack(Material.IRON_CHESTPLATE)); - player.getInventory().setLeggings(ItemStackFactory.Instance.CreateStack(Material.IRON_LEGGINGS)); - player.getInventory().setBoots(ItemStackFactory.Instance.CreateStack(Material.IRON_BOOTS)); - } - - @Override - public void giveSuperItems(Player player) - { - - } - - @Override - public void GiveItems(Player player) - { - //Disguise - DisguiseSkeleton disguise = new DisguiseSkeleton(player); - - if (Manager.GetGame().GetTeam(player) != null) - disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); - else - disguise.setName(player.getName()); - - disguise.setCustomNameVisible(true); - Manager.GetDisguise().disguise(disguise); - - //Horse - Manager.GetGame().CreatureAllowOverride = true; - final Horse horse = player.getWorld().spawn(player.getLocation(), Horse.class); - Manager.GetGame().CreatureAllowOverride = false; - - //Owner - horse.setTamed(true); - horse.setOwner(player); - horse.setMaxDomestication(1); - - //Visual - horse.setColor(Color.DARK_BROWN); - horse.setStyle(Style.WHITE_DOTS); - horse.setVariant(Variant.UNDEAD_HORSE); - horse.getInventory().setSaddle(new ItemStack(Material.SADDLE)); - horse.getInventory().setArmor(new ItemStack(Material.IRON_BARDING)); - - //Stats - horse.setAdult(); - horse.setJumpStrength(1); - horse.setMaxHealth(100); - horse.setHealth(horse.getMaxHealth()); - - _horses.add(horse); - _mounts.put(player, horse); - - /* - final Player fPlayer = player; - - Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() - { - public void run() - { - horse.setPassenger(fPlayer); - } - }, 1); - */ - } - - @EventHandler - public void HorseUpdate(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; - - Iterator<Horse> horseIterator = _horses.iterator(); - - while (horseIterator.hasNext()) - { - Horse horse = horseIterator.next(); - - if (horse.isValid() && _mounts.containsValue(horse)) - continue; - - horseIterator.remove(); - horse.remove(); - } - } - - @EventHandler - public void HorseUpdate(PlayerInteractEntityEvent event) - { - if (!(event.getRightClicked() instanceof Horse)) - return; - - Player player = event.getPlayer(); - Horse horse = (Horse)event.getRightClicked(); - - if (_mounts.containsKey(player) && _mounts.get(player).equals(horse)) - return; - - UtilPlayer.message(player, F.main("Game", "This is not your " + F.elem("Skeletal Horse") + "!")); - event.setCancelled(true); - } - - @EventHandler(priority = EventPriority.LOWEST) - public void PlayerDamage(CustomDamageEvent event) - { - if (_calledEvents.contains(event)) - return; - - Player damagee = event.GetDamageePlayer(); - if (damagee == null) return; - - if (damagee.getVehicle() == null) - return; - - if (!(damagee.getVehicle() instanceof Horse)) - return; - - if (event.GetCause() == DamageCause.SUFFOCATION) - { - event.SetCancelled("Horse Suffocation"); - return; - } - - Horse horse = (Horse)damagee.getVehicle(); - - //Damage Event - CustomDamageEvent newEvent = new CustomDamageEvent(horse, event.GetDamagerEntity(true), event.GetProjectile(), null, - event.GetCause(), event.GetDamageInitial(), true, false, false, - UtilEnt.getName(event.GetDamagerPlayer(true)), event.GetReason(), false); - -// _calledEvents.add(newEvent); -// Manager.getPlugin().getServer().getPluginManager().callEvent(newEvent); -// _calledEvents.remove(newEvent); - } - - @EventHandler(priority = EventPriority.LOWEST) - public void HorseDamage(CustomDamageEvent event) - { - if (_calledEvents.contains(event)) - return; - - if (event.GetCause() == DamageCause.THORNS) - return; - - if (!(event.GetDamageeEntity() instanceof Horse)) - return; - - Horse horse = (Horse)event.GetDamageeEntity(); - - if (horse.getPassenger() == null) - return; - - if (!(horse.getPassenger() instanceof Player)) - return; - - Player player = (Player)horse.getPassenger(); - - //Damage Event - final CustomDamageEvent newEvent = new CustomDamageEvent(player, event.GetDamagerEntity(true), event.GetProjectile(), null, - event.GetCause(), event.GetDamageInitial(), true, false, false, - UtilEnt.getName(event.GetDamagerPlayer(true)), event.GetReason(), false); - - _calledEvents.add(newEvent); - Manager.getPlugin().getServer().getPluginManager().callEvent(newEvent); - _calledEvents.remove(newEvent); - //Add Knockback - event.AddKnockback("Knockback Multiplier", 1.2); - } - - @Override - public Entity SpawnEntity(Location loc) - { - EntityType type = _entityType; - if (type == EntityType.PLAYER) - type = EntityType.ZOMBIE; - - LivingEntity entity = (LivingEntity) Manager.GetCreature().SpawnEntity(loc, type); - - entity.setRemoveWhenFarAway(false); - entity.setCustomName(GetAvailability().GetColor() + GetName() + " Kit"); - entity.setCustomNameVisible(true); - entity.getEquipment().setItemInHand(_itemInHand); - - if (type == EntityType.HORSE) - { - Horse horse = (Horse)entity; - horse.setAdult(); - horse.setColor(Color.DARK_BROWN); - horse.setStyle(Style.WHITE_DOTS); - horse.setVariant(Variant.UNDEAD_HORSE); - horse.getInventory().setSaddle(new ItemStack(Material.SADDLE)); - horse.getInventory().setArmor(new ItemStack(Material.IRON_BARDING)); - } - - UtilEnt.Vegetate(entity); - - SpawnCustom(entity); - - return entity; - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitMagmaCube.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitMagmaCube.java index f90b5c729..e252a2e64 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitMagmaCube.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitMagmaCube.java @@ -1,26 +1,33 @@ package nautilus.game.arcade.game.games.smash.kits; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.inventory.ItemStack; + import mineplex.core.common.util.C; import mineplex.core.common.util.UtilInv; import mineplex.core.disguise.disguises.DisguiseMagmaCube; import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.smash.perks.PerkSmashStats; +import nautilus.game.arcade.game.games.smash.perks.SmashKit; +import nautilus.game.arcade.game.games.smash.perks.magmacube.PerkFlameDash; +import nautilus.game.arcade.game.games.smash.perks.magmacube.PerkMagmaBlast; +import nautilus.game.arcade.game.games.smash.perks.magmacube.PerkMagmaBoost; +import nautilus.game.arcade.game.games.smash.perks.magmacube.SmashMagmacube; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.SmashKit; -import nautilus.game.arcade.kit.perks.*; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; +import nautilus.game.arcade.kit.perks.PerkDoubleJump; public class KitMagmaCube extends SmashKit { - private static final String[] DESCRIPTION = { - }; private static final Perk[] PERKS = { new PerkSmashStats(5, 1.75, 0.35, 5), @@ -28,7 +35,7 @@ public class KitMagmaCube extends SmashKit new PerkMagmaBoost(), new PerkMagmaBlast(), new PerkFlameDash(), - new PerkMeteorShower() + new SmashMagmacube() }; private static final ItemStack IN_HAND = new ItemStack(Material.MAGMA_CREAM); @@ -67,20 +74,26 @@ public class KitMagmaCube extends SmashKit }; private static final ItemStack[] PLAYER_ARMOR = { - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_BOOTS), + new ItemStack(Material.CHAINMAIL_BOOTS), null, - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_CHESTPLATE), - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_HELMET), + new ItemStack(Material.CHAINMAIL_CHESTPLATE), + new ItemStack(Material.CHAINMAIL_HELMET), }; public KitMagmaCube(ArcadeManager manager) { - super(manager, "Magma Cube", KitAvailability.Gem, 5000, DESCRIPTION, PERKS, EntityType.MAGMA_CUBE, IN_HAND, "Meteor Shower", 0, Sound.AMBIENCE_THUNDER); + super(manager, "Magma Cube", KitAvailability.Gem, 5000, PERKS, EntityType.MAGMA_CUBE, IN_HAND, DisguiseMagmaCube.class); } @Override - public void giveCoreItems(Player player) + public void GiveItems(Player player) { + disguise(player); + + DisguiseMagmaCube disguise = (DisguiseMagmaCube) Manager.GetDisguise().getActiveDisguise(player); + + disguise.SetSize(1); + UtilInv.Clear(player); player.getInventory().addItem(PLAYER_ITEMS[0], PLAYER_ITEMS[1]); @@ -88,31 +101,30 @@ public class KitMagmaCube extends SmashKit if (Manager.GetGame().GetState() == GameState.Recruit) player.getInventory().addItem(PLAYER_ITEMS[2]); - player.getInventory().setArmorContents(PLAYER_ARMOR); + player.getInventory().setArmorContents(PLAYER_ARMOR);; } - - @Override - public void giveSuperItems(Player player) + + @EventHandler + public void fireResistance(UpdateEvent event) { - - } - - @Override - public void GiveItems(Player player) - { - giveCoreItems(player); - - //Disguise - DisguiseMagmaCube disguise = new DisguiseMagmaCube(player); - - if (Manager.GetGame().GetTeam(player) != null) - disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); - else - disguise.setName(player.getName()); - - disguise.setCustomNameVisible(true); - Manager.GetDisguise().disguise(disguise); - - disguise.SetSize(1); + if (event.getType() != UpdateType.FAST) + { + return; + } + + if (Manager.GetGame() == null) + { + return; + } + + for (Player player : Manager.GetGame().GetPlayers(true)) + { + if (!HasKit(player)) + { + continue; + } + + player.setFireTicks(0); + } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitPig.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitPig.java index 228622660..c97306a50 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitPig.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitPig.java @@ -1,5 +1,12 @@ package nautilus.game.arcade.game.games.smash.kits; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.inventory.ItemStack; + import mineplex.core.common.util.C; import mineplex.core.common.util.UtilInv; import mineplex.core.disguise.disguises.DisguisePig; @@ -8,29 +15,30 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.smash.perks.PerkSmashStats; +import nautilus.game.arcade.game.games.smash.perks.SmashKit; +import nautilus.game.arcade.game.games.smash.perks.pig.PerkPigBaconBomb; +import nautilus.game.arcade.game.games.smash.perks.pig.PerkPigBaconBounce; +import nautilus.game.arcade.game.games.smash.perks.pig.PerkPigZombie; +import nautilus.game.arcade.game.games.smash.perks.pig.SmashPig; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.SmashKit; -import nautilus.game.arcade.kit.perks.*; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.inventory.ItemStack; +import nautilus.game.arcade.kit.perks.PerkDoubleJump; public class KitPig extends SmashKit { - private static final String[] DESCRIPTION = { - }; + private static final float MAX_ENERGY = 0.99F; + private static final float ENERGY_PER_TICK_NORMAL = 0.005F; + private static final float ENERGY_PER_TICK_SMASH = 0.02F; + private static final Perk[] PERKS = { new PerkSmashStats(5, 1.5, 0.25, 5), new PerkDoubleJump("Double Jump", 0.9, 0.9, false), new PerkPigBaconBounce(), new PerkPigBaconBomb(), new PerkPigZombie(), + new SmashPig() }; private static final ItemStack IN_HAND = new ItemStack(Material.PORK); @@ -75,21 +83,23 @@ public class KitPig extends SmashKit }; private static final ItemStack[] PLAYER_ARMOR = { - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_BOOTS), - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_LEGGINGS), - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_CHESTPLATE), + new ItemStack(Material.CHAINMAIL_BOOTS), + new ItemStack(Material.CHAINMAIL_LEGGINGS), + new ItemStack(Material.CHAINMAIL_CHESTPLATE), null, }; public KitPig(ArcadeManager manager) { - super(manager, "Pig", KitAvailability.Gem, 7000, DESCRIPTION, PERKS, EntityType.PIG, IN_HAND, "Pig Stink", 40000, Sound.PIG_DEATH); + super(manager, "Pig", KitAvailability.Gem, 7000, PERKS, EntityType.PIG, IN_HAND, DisguisePig.class); } @Override - public void giveCoreItems(Player player) + public void GiveItems(Player player) { + disguise(player); + UtilInv.Clear(player); player.getInventory().addItem(PLAYER_ITEMS[0], PLAYER_ITEMS[1]); @@ -97,59 +107,30 @@ public class KitPig extends SmashKit if (Manager.GetGame().GetState() == GameState.Recruit) player.getInventory().addItem(PLAYER_ITEMS[2], PLAYER_ITEMS[3]); - player.getInventory().setArmorContents(PLAYER_ARMOR); } - @Override - public void giveSuperItems(Player player) - { - - } - - @Override - public void GiveItems(Player player) - { - giveCoreItems(player); - - //Disguise - DisguisePig disguise = new DisguisePig(player); - - if (Manager.GetGame().GetTeam(player) != null) - disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); - else - disguise.setName(player.getName()); - - disguise.setCustomNameVisible(true); - Manager.GetDisguise().disguise(disguise); - } - @EventHandler public void EnergyUpdate(UpdateEvent event) { if (event.getType() != UpdateType.TICK) + { return; - + } + + if(Manager.GetGame() == null) + { + return; + } + for (Player player : Manager.GetGame().GetPlayers(true)) { if (!HasKit(player)) + { continue; - - player.setExp((float) Math.min(0.999, player.getExp() + (isSuperActive(player) ? 0.02 : 0.005))); + } + + player.setExp((float) Math.min(MAX_ENERGY, player.getExp() + (isSmashActive(player) ? ENERGY_PER_TICK_SMASH : ENERGY_PER_TICK_NORMAL))); } } - - @Override - public void activateSuperCustom(Player player) - { - for (Player other : Manager.GetGame().GetPlayers(true)) - if (!player.equals(other)) - Manager.GetCondition().Factory().Confuse("Pig Stink " + player.getName(), other, player, 40, 0, false, false, false); - } - - @Override - public void deactivateSuperCustom(Player player) - { - - } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSheep.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSheep.java index f3a600a09..00dd730ee 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSheep.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSheep.java @@ -1,5 +1,11 @@ package nautilus.game.arcade.game.games.smash.kits; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + import mineplex.core.achievement.Achievement; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilInv; @@ -7,37 +13,33 @@ import mineplex.core.disguise.disguises.DisguiseSheep; import mineplex.core.itemstack.ItemStackFactory; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.smash.perks.PerkSmashStats; +import nautilus.game.arcade.game.games.smash.perks.SmashKit; +import nautilus.game.arcade.game.games.smash.perks.sheep.SmashSheep; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.SmashKit; -import nautilus.game.arcade.kit.perks.*; -import org.bukkit.ChatColor; -import org.bukkit.DyeColor; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; +import nautilus.game.arcade.kit.perks.PerkDoubleJump; +import nautilus.game.arcade.kit.perks.PerkLazer; +import nautilus.game.arcade.kit.perks.PerkWoolBomb; +import nautilus.game.arcade.kit.perks.PerkWoolCloud; public class KitSheep extends SmashKit { - private static final String[] DESCRIPTION = { - }; private static final Perk[] PERKS = { new PerkSmashStats(5, 1.7, 0.25, 5), new PerkDoubleJump("Double Jump", 1, 1, false), - new PerkLazer(40, 6000), + new PerkLazer(40, 7000), new PerkWoolBomb(), new PerkWoolCloud(), - new PerkSheepHoming() + new SmashSheep() }; private static final ItemStack IN_HAND = new ItemStack(Material.WOOL); private static final ItemStack[] PLAYER_ITEMS = { ItemStackFactory.Instance.CreateStack(Material.IRON_SWORD, (byte) 0, 1, - C.cYellow + C.Bold + "Right-Click" + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + "Static Lazer", + C.cYellow + C.Bold + "Right-Click" + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + "Static Laser", new String[]{ ChatColor.RESET + "Charge up static electricity in your", ChatColor.RESET + "wooly coat, and then unleash it upon", @@ -89,14 +91,16 @@ public class KitSheep extends SmashKit public KitSheep(ArcadeManager manager) { - super(manager, "Sir. Sheep", KitAvailability.Achievement, 99999, DESCRIPTION, PERKS, EntityType.SHEEP, IN_HAND, "Homing Sheeples", 0, Sound.SHEEP_IDLE); + super(manager, "Sir. Sheep", KitAvailability.Achievement, 99999, PERKS, EntityType.SHEEP, IN_HAND, DisguiseSheep.class); this.setAchievementRequirements(ACHIEVEMENTS); } - + @Override - public void giveCoreItems(Player player) + public void GiveItems(Player player) { + disguise(player); + UtilInv.Clear(player); player.getInventory().addItem(PLAYER_ITEMS[0], PLAYER_ITEMS[1], PLAYER_ITEMS[2]); @@ -106,29 +110,4 @@ public class KitSheep extends SmashKit player.getInventory().setArmorContents(PLAYER_ARMOR); } - - @Override - public void giveSuperItems(Player player) - { - - } - - @Override - public void GiveItems(Player player) - { - giveCoreItems(player); - - //Disguise - DisguiseSheep disguise = new DisguiseSheep(player); - - if (Manager.GetGame().GetTeam(player) != null) - disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); - else - disguise.setName(player.getName()); - - disguise.setColor(DyeColor.WHITE); - - disguise.setCustomNameVisible(true); - Manager.GetDisguise().disguise(disguise); - } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSkeletalHorse.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSkeletalHorse.java index 119b90b7c..6bcd59057 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSkeletalHorse.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSkeletalHorse.java @@ -1,35 +1,41 @@ package nautilus.game.arcade.game.games.smash.kits; +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Horse; +import org.bukkit.entity.Horse.Variant; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilInv; import mineplex.core.disguise.disguises.DisguiseHorse; import mineplex.core.itemstack.ItemStackFactory; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.smash.perks.PerkSmashStats; +import nautilus.game.arcade.game.games.smash.perks.SmashKit; +import nautilus.game.arcade.game.games.smash.perks.skeletalhorse.PerkBoneRush; +import nautilus.game.arcade.game.games.smash.perks.skeletalhorse.PerkDeadlyBones; +import nautilus.game.arcade.game.games.smash.perks.skeletalhorse.PerkHorseKick; +import nautilus.game.arcade.game.games.smash.perks.skeletalhorse.SmashSkeletalHorse; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.SmashKit; -import nautilus.game.arcade.kit.perks.*; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.*; -import org.bukkit.entity.Horse.Variant; -import org.bukkit.inventory.ItemStack; +import nautilus.game.arcade.kit.perks.PerkDoubleJump; public class KitSkeletalHorse extends SmashKit { - private static final String[] DESCRIPTION = { - }; private static final Perk[] PERKS = { - new PerkSmashStats(6, 1.4, 0.3, 6), + new PerkSmashStats(6, 1.4, 0.3, 6.5), new PerkDoubleJump("Double Jump", 1, 1, false), new PerkHorseKick(), new PerkBoneRush(), - new PerkDeadlyBones() + new PerkDeadlyBones(), + new SmashSkeletalHorse() }; private static final ItemStack IN_HAND = new ItemStack(Material.BONE); @@ -71,20 +77,26 @@ public class KitSkeletalHorse extends SmashKit }; private static final ItemStack[] PLAYER_ARMOR = { - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_BOOTS), - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_LEGGINGS), - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_CHESTPLATE), - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_HELMET), + new ItemStack(Material.IRON_BOOTS), + new ItemStack(Material.CHAINMAIL_LEGGINGS), + new ItemStack(Material.CHAINMAIL_CHESTPLATE), + new ItemStack(Material.CHAINMAIL_HELMET), }; public KitSkeletalHorse(ArcadeManager manager) { - super(manager, "Skeletal Horse", KitAvailability.Gem, 7000, DESCRIPTION, PERKS, EntityType.HORSE, IN_HAND, "Bone Storm", 20000, Sound.HORSE_SKELETON_DEATH); + super(manager, "Skeletal Horse", KitAvailability.Gem, 7000, PERKS, EntityType.HORSE, IN_HAND, DisguiseHorse.class); } - + @Override - public void giveCoreItems(Player player) + public void GiveItems(Player player) { + disguise(player); + + DisguiseHorse disguise = (DisguiseHorse) Manager.GetDisguise().getActiveDisguise(player); + + disguise.setType(Variant.SKELETON_HORSE); + UtilInv.Clear(player); player.getInventory().addItem(PLAYER_ITEMS[0], PLAYER_ITEMS[1]); @@ -92,62 +104,16 @@ public class KitSkeletalHorse extends SmashKit if (Manager.GetGame().GetState() == GameState.Recruit) player.getInventory().addItem(PLAYER_ITEMS[2], PLAYER_ITEMS[3]); - player.getInventory().setArmorContents(PLAYER_ARMOR); } - @Override - public void giveSuperItems(Player player) - { - player.getInventory().remove(Material.IRON_SPADE); - player.getInventory().remove(Material.IRON_AXE); - - UtilInv.Update(player); - } - - @Override - public void GiveItems(Player player) - { - giveCoreItems(player); - - //Disguise - DisguiseHorse disguise = new DisguiseHorse(player); - disguise.setType(Variant.SKELETON_HORSE); - - if (Manager.GetGame().GetTeam(player) != null) - disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); - else - disguise.setName(player.getName()); - - disguise.setCustomNameVisible(true); - Manager.GetDisguise().disguise(disguise); - } - @Override public Entity SpawnEntity(Location loc) { - EntityType type = _entityType; - if (type == EntityType.PLAYER) - type = EntityType.ZOMBIE; - - LivingEntity entity = (LivingEntity) Manager.GetCreature().SpawnEntity(loc, type); - - entity.setRemoveWhenFarAway(false); - entity.setCustomName(GetAvailability().GetColor() + GetName() + " Kit"); - entity.setCustomNameVisible(true); - entity.getEquipment().setItemInHand(_itemInHand); - - if (type == EntityType.HORSE) - { - Horse horse = (Horse) entity; - horse.setAdult(); - horse.setVariant(Variant.SKELETON_HORSE); - } - - UtilEnt.Vegetate(entity); - - SpawnCustom(entity); - - return entity; + Horse horse = (Horse) super.SpawnEntity(loc); + + horse.setVariant(Variant.SKELETON_HORSE); + + return horse; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSkeleton.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSkeleton.java index cb9adbe24..07f123e5b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSkeleton.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSkeleton.java @@ -1,36 +1,48 @@ package nautilus.game.arcade.game.games.smash.kits; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.inventory.ItemStack; + import mineplex.core.common.util.C; import mineplex.core.common.util.UtilInv; import mineplex.core.disguise.disguises.DisguiseSkeleton; import mineplex.core.itemstack.ItemStackFactory; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.smash.perks.PerkSmashStats; +import nautilus.game.arcade.game.games.smash.perks.SmashKit; +import nautilus.game.arcade.game.games.smash.perks.skeleton.PerkBarrage; +import nautilus.game.arcade.game.games.smash.perks.skeleton.PerkBoneExplosion; +import nautilus.game.arcade.game.games.smash.perks.skeleton.SmashSkeleton; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.SmashKit; -import nautilus.game.arcade.kit.perks.*; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; +import nautilus.game.arcade.kit.perks.PerkDoubleJump; +import nautilus.game.arcade.kit.perks.PerkFletcher; +import nautilus.game.arcade.kit.perks.PerkKnockbackArrow; +import nautilus.game.arcade.kit.perks.PerkRopedArrow; public class KitSkeleton extends SmashKit { - private static final String[] DESCRIPTION = { - }; + + private static double ARROW_DAMAGE = 6; private static final Perk[] PERKS = { - new PerkSmashStats(5, 1.25, 0.15, 6), + new PerkSmashStats(5, 1.25, 0.2, 6), new PerkDoubleJump("Double Jump", 0.9, 0.9, false), new PerkFletcher(3, 3, false), new PerkKnockbackArrow(1.5), new PerkBoneExplosion(), new PerkRopedArrow("Roped Arrow", 1, 5000), new PerkBarrage(5, 300, true, false, true), - new PerkSkeletonArrowStorm() + new SmashSkeleton() }; private static final ItemStack IN_HAND = new ItemStack(Material.BOW); @@ -69,21 +81,23 @@ public class KitSkeleton extends SmashKit }; private static final ItemStack[] PLAYER_ARMOR = { - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_BOOTS), - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_LEGGINGS), - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_CHESTPLATE), - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_HELMET), + new ItemStack(Material.CHAINMAIL_BOOTS), + new ItemStack(Material.CHAINMAIL_LEGGINGS), + new ItemStack(Material.CHAINMAIL_CHESTPLATE), + new ItemStack(Material.CHAINMAIL_HELMET), }; public KitSkeleton(ArcadeManager manager) { - super(manager, "Skeleton", KitAvailability.Free, DESCRIPTION, PERKS, EntityType.SKELETON, IN_HAND, "Arrow Storm", 8000, Sound.SKELETON_HURT); + super(manager, "Skeleton", KitAvailability.Free, PERKS, EntityType.SKELETON, IN_HAND, DisguiseSkeleton.class); } @Override - public void giveCoreItems(Player player) + public void GiveItems(Player player) { + disguise(player); + UtilInv.Clear(player); player.getInventory().addItem(PLAYER_ITEMS[0], PLAYER_ITEMS[1]); @@ -95,31 +109,31 @@ public class KitSkeleton extends SmashKit player.getInventory().setArmorContents(PLAYER_ARMOR); } - - @Override - public void giveSuperItems(Player player) + + @EventHandler(priority = EventPriority.HIGHEST) + public void arrowDamage(CustomDamageEvent event) { - - } - - @Override - public void GiveItems(Player player) - { - giveCoreItems(player); - - //Disguise - DisguiseSkeleton disguise = new DisguiseSkeleton(player); - - if (Manager.GetGame().GetTeam(player) != null) + Player player = event.GetDamagerPlayer(true); + Projectile proj = event.GetProjectile(); + + if (player == null || proj == null) { - disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); - } else - { - disguise.setName(player.getName()); + return; } - - disguise.setCustomNameVisible(true); - disguise.hideArmor(); - Manager.GetDisguise().disguise(disguise); + + if (!(proj instanceof Arrow)) + { + return; + } + + if (!HasKit(player)) + { + return; + } + + //Try making arrows deal static damage + double diff = ARROW_DAMAGE - event.GetDamage(); + + event.AddMod("Arrow Nerf", diff); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSkySquid.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSkySquid.java index 4f133927e..7e0c0bf36 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSkySquid.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSkySquid.java @@ -1,35 +1,37 @@ package nautilus.game.arcade.game.games.smash.kits; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + import mineplex.core.common.util.C; import mineplex.core.common.util.UtilInv; import mineplex.core.disguise.disguises.DisguiseSquid; import mineplex.core.itemstack.ItemStackFactory; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.Game.GameState; -import nautilus.game.arcade.game.games.smash.perks.PerkFishFlurry; +import nautilus.game.arcade.game.games.smash.perks.PerkSmashStats; +import nautilus.game.arcade.game.games.smash.perks.SmashKit; +import nautilus.game.arcade.game.games.smash.perks.squid.PerkFishFlurry; +import nautilus.game.arcade.game.games.smash.perks.squid.PerkInkBlast; +import nautilus.game.arcade.game.games.smash.perks.squid.SmashSquid; +import nautilus.game.arcade.game.games.smash.perks.squid.PerkSuperSquid; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.SmashKit; -import nautilus.game.arcade.kit.perks.*; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; +import nautilus.game.arcade.kit.perks.PerkDoubleJump; public class KitSkySquid extends SmashKit { - private static final String[] DESCRIPTION = { - }; - + private static final Perk[] PERKS = { new PerkSmashStats(6, 1.5, 0.25, 5), new PerkDoubleJump("Double Jump", 0.9, 0.9, false), new PerkSuperSquid(), new PerkInkBlast(7, 2), new PerkFishFlurry(), - new PerkStormSquid() + new SmashSquid() }; private static final ItemStack IN_HAND = new ItemStack(Material.INK_SACK); @@ -73,36 +75,23 @@ public class KitSkySquid extends SmashKit }; private static final ItemStack[] PLAYER_ARMOR = { - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_BOOTS), - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_LEGGINGS), - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_CHESTPLATE), + new ItemStack(Material.CHAINMAIL_BOOTS), + new ItemStack(Material.CHAINMAIL_LEGGINGS), + new ItemStack(Material.CHAINMAIL_CHESTPLATE), null }; public KitSkySquid(ArcadeManager manager) { - super(manager, "Sky Squid", KitAvailability.Gem, 3000, DESCRIPTION, PERKS, EntityType.SQUID, IN_HAND, "Storm Squid", 24000, Sound.SPLASH2); + super(manager, "Sky Squid", KitAvailability.Gem, 3000, PERKS, EntityType.SQUID, IN_HAND, DisguiseSquid.class); } - @Override - public void giveCoreItems(Player player) - { - UtilInv.Clear(player); - - player.getInventory().addItem(PLAYER_ITEMS[0], PLAYER_ITEMS[1], PLAYER_ITEMS[2]); - - if (Manager.GetGame().GetState() == GameState.Recruit) - player.getInventory().addItem(PLAYER_ITEMS[3]); - - player.getInventory().setArmorContents(PLAYER_ARMOR); - } - - @Override - public void giveSuperItems(Player player) + public void giveSmashItems(Player player) { player.getInventory().remove(Material.IRON_SWORD); player.getInventory().remove(Material.IRON_AXE); + player.getInventory().remove(Material.IRON_SPADE); player.getInventory().addItem(PLAYER_ITEMS[4]); @@ -112,32 +101,15 @@ public class KitSkySquid extends SmashKit @Override public void GiveItems(Player player) { - giveCoreItems(player); + disguise(player); + + UtilInv.Clear(player); - //Disguise - DisguiseSquid disguise = new DisguiseSquid(player); + player.getInventory().addItem(PLAYER_ITEMS[0], PLAYER_ITEMS[1], PLAYER_ITEMS[2]); - if (Manager.GetGame().GetTeam(player) != null) - disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); - else - disguise.setName(player.getName()); + if (Manager.GetGame().GetState() == GameState.Recruit) + player.getInventory().addItem(PLAYER_ITEMS[3]); - disguise.setCustomNameVisible(true); - Manager.GetDisguise().disguise(disguise); - } - - @Override - public void activateSuperCustom(Player player) - { - Manager.GetGame().WorldWeatherEnabled = true; - Manager.GetGame().WorldData.World.setStorm(true); - Manager.GetGame().WorldData.World.setThundering(true); - Manager.GetGame().WorldData.World.setThunderDuration(9999); - } - - @Override - public void deactivateSuperCustom(Player player) - { - Manager.GetGame().WorldWeatherEnabled = false; + player.getInventory().setArmorContents(PLAYER_ARMOR); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSlime.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSlime.java index c8a1915d1..f439afb7c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSlime.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSlime.java @@ -1,43 +1,35 @@ package nautilus.game.arcade.game.games.smash.kits; -import mineplex.core.common.util.*; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.disguise.disguises.DisguiseBase; -import mineplex.core.disguise.disguises.DisguiseSlime; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.condition.Condition.ConditionType; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.game.Game.GameState; -import nautilus.game.arcade.kit.KitAvailability; -import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.SmashKit; -import nautilus.game.arcade.kit.perks.PerkDoubleJump; -import nautilus.game.arcade.kit.perks.PerkSlimeRocket; -import nautilus.game.arcade.kit.perks.PerkSlimeSlam; -import nautilus.game.arcade.kit.perks.PerkSmashStats; import org.bukkit.ChatColor; import org.bukkit.Material; -import org.bukkit.Sound; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.inventory.ItemStack; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilInv; +import mineplex.core.disguise.disguises.DisguiseSlime; +import mineplex.core.itemstack.ItemStackFactory; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.smash.perks.PerkSmashStats; +import nautilus.game.arcade.game.games.smash.perks.SmashKit; +import nautilus.game.arcade.game.games.smash.perks.slime.PerkSlimeRocket; +import nautilus.game.arcade.game.games.smash.perks.slime.PerkSlimeSlam; +import nautilus.game.arcade.game.games.smash.perks.slime.SmashSlime; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.PerkDoubleJump; + public class KitSlime extends SmashKit { - private static final String[] DESCRIPTION = { - }; private static final Perk[] PERKS = { - new PerkSmashStats(6, 1.75, 0.5, 3), + new PerkSmashStats(6, 1.75, 0.35, 3), new PerkDoubleJump("Double Jump", 1.2, 1, false), new PerkSlimeSlam(), - new PerkSlimeRocket() + new PerkSlimeRocket(), + new SmashSlime() }; private static final ItemStack IN_HAND = new ItemStack(Material.SLIME_BALL); @@ -76,18 +68,24 @@ public class KitSlime extends SmashKit private static final ItemStack[] PLAYER_ARMOR = { null, null, - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_CHESTPLATE), - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_HELMET), + new ItemStack(Material.CHAINMAIL_CHESTPLATE), + new ItemStack(Material.CHAINMAIL_HELMET), }; public KitSlime(ArcadeManager manager) { - super(manager, "Slime", KitAvailability.Free, DESCRIPTION, PERKS, EntityType.SLIME, IN_HAND, "Giga Slime", 24000, Sound.SLIME_ATTACK); + super(manager, "Slime", KitAvailability.Free, PERKS, EntityType.SLIME, IN_HAND, DisguiseSlime.class); } - + @Override - public void giveCoreItems(Player player) + public void GiveItems(Player player) { + disguise(player); + + DisguiseSlime disguise = (DisguiseSlime) Manager.GetDisguise().getActiveDisguise(player); + + disguise.SetSize(3); + UtilInv.Clear(player); player.getInventory().addItem(PLAYER_ITEMS[0], PLAYER_ITEMS[1]); @@ -98,103 +96,4 @@ public class KitSlime extends SmashKit player.getInventory().setArmorContents(PLAYER_ARMOR); } - @Override - public void giveSuperItems(Player player) - { - player.getInventory().remove(Material.IRON_SWORD); - player.getInventory().remove(Material.IRON_AXE); - - UtilInv.Update(player); - } - - @Override - public void GiveItems(Player player) - { - giveCoreItems(player); - - //Disguise - DisguiseSlime disguise = new DisguiseSlime(player); - - if (Manager.GetGame().GetTeam(player) != null) - disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); - else - disguise.setName(player.getName()); - - disguise.setCustomNameVisible(true); - Manager.GetDisguise().disguise(disguise); - - disguise.SetSize(3); - } - - @Override - public void activateSuperCustom(Player player) - { - DisguiseBase disguise = Manager.GetDisguise().getDisguise(player); - if (disguise != null && disguise instanceof DisguiseSlime) - { - DisguiseSlime slime = (DisguiseSlime) disguise; - - slime.SetSize(14); - Manager.GetDisguise().updateDisguise(slime); - } - - player.setExp(0.99f); - - Manager.GetCondition().Factory().Speed("Giga Slime", player, player, 20, 2, false, false, false); - } - - @Override - public void deactivateSuperCustom(Player player) - { - Manager.GetCondition().EndCondition(player, ConditionType.SPEED, "Giga Slime"); - } - - @EventHandler(priority = EventPriority.LOW) - public void immunityDamagee(CustomDamageEvent event) - { - if (event.GetDamageePlayer() == null || event.GetDamagerEntity(true) == null) - return; - - if (this.isSuperActive(event.GetDamageePlayer())) - event.SetCancelled(getSuperName()); - } - - @EventHandler(priority = EventPriority.LOW) - public void immunityDamager(CustomDamageEvent event) - { - if (event.GetCause() != DamageCause.ENTITY_ATTACK) - return; - - if (event.GetDamagerPlayer(true) == null) - return; - - if (isSuperActive(event.GetDamagerPlayer(true))) - event.SetCancelled(getSuperName()); - } - - @EventHandler - public void collide(UpdateEvent event) - { - for (Player player : getSuperActive()) - for (Player other : Manager.GetGame().GetPlayers(true)) - { - if (player.equals(other)) - continue; - - if (Manager.isSpectator(other)) - continue; - - if (UtilMath.offset(player.getLocation().add(0, 3, 0), other.getLocation()) < 5) - { - Manager.GetDamage().NewDamageEvent(other, player, null, - DamageCause.CUSTOM, 8, true, false, false, - player.getName(), GetName()); - - UtilParticle.PlayParticle(ParticleType.SLIME, other.getLocation().add(0, 0.6, 0), 1f, 1f, 1f, 0, 20, - ViewDist.LONG, UtilServer.getPlayers()); - - player.getWorld().playSound(other.getLocation(), Sound.SLIME_ATTACK, 3f, 1f); - } - } - } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSnowman.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSnowman.java index 3b877ec1f..c8af47cc9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSnowman.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSnowman.java @@ -1,35 +1,39 @@ package nautilus.game.arcade.game.games.smash.kits; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + import mineplex.core.common.util.C; import mineplex.core.common.util.UtilInv; import mineplex.core.disguise.disguises.DisguiseSnowman; import mineplex.core.itemstack.ItemStackFactory; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.smash.perks.PerkSmashStats; +import nautilus.game.arcade.game.games.smash.perks.SmashKit; +import nautilus.game.arcade.game.games.smash.perks.snowman.PerkArcticAura; +import nautilus.game.arcade.game.games.smash.perks.snowman.PerkIcePath; +import nautilus.game.arcade.game.games.smash.perks.snowman.SmashSnowman; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.SmashKit; -import nautilus.game.arcade.kit.perks.*; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; +import nautilus.game.arcade.kit.perks.PerkBlizzard; +import nautilus.game.arcade.kit.perks.PerkDamageSnow; +import nautilus.game.arcade.kit.perks.PerkDoubleJump; public class KitSnowman extends SmashKit { - private static final String[] DESCRIPTION = { - }; private static final Perk[] PERKS = { - new PerkSmashStats(5.5, 1.4, 0.3, 6), + new PerkSmashStats(6, 1.4, 0.3, 6), new PerkDoubleJump("Double Jump", 0.9, 0.9, false), new PerkDamageSnow(1, 0.4), new PerkArcticAura(), new PerkBlizzard(), new PerkIcePath(), - new PerkSnowTurret() + new SmashSnowman() }; private static final ItemStack IN_HAND = new ItemStack(Material.SNOW_BALL); @@ -68,33 +72,22 @@ public class KitSnowman extends SmashKit }; private static final ItemStack[] PLAYER_ARMOR = { - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_BOOTS), - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_LEGGINGS), - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_CHESTPLATE), - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_HELMET), + new ItemStack(Material.CHAINMAIL_BOOTS), + new ItemStack(Material.CHAINMAIL_LEGGINGS), + new ItemStack(Material.CHAINMAIL_CHESTPLATE), + new ItemStack(Material.CHAINMAIL_HELMET), }; public KitSnowman(ArcadeManager manager) { - super(manager, "Snowman", KitAvailability.Gem, 5000, DESCRIPTION, PERKS, EntityType.SNOWMAN, IN_HAND, "Snow Turret", 0, Sound.STEP_SNOW); - setSuperCharges(3); - } - - @Override - public void giveCoreItems(Player player) - { - - } - - @Override - public void giveSuperItems(Player player) - { - + super(manager, "Snowman", KitAvailability.Gem, 5000, PERKS, EntityType.SNOWMAN, IN_HAND, DisguiseSnowman.class); } @Override public void GiveItems(Player player) { + disguise(player); + UtilInv.Clear(player); player.getInventory().addItem(PLAYER_ITEMS[0], PLAYER_ITEMS[1]); @@ -102,16 +95,5 @@ public class KitSnowman extends SmashKit player.getInventory().addItem(PLAYER_ITEMS[2], PLAYER_ITEMS[3]); player.getInventory().setArmorContents(PLAYER_ARMOR); - - //Disguise - DisguiseSnowman disguise = new DisguiseSnowman(player); - - if (Manager.GetGame().GetTeam(player) != null) - disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); - else - disguise.setName(player.getName()); - - disguise.setCustomNameVisible(true); - Manager.GetDisguise().disguise(disguise); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSpider.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSpider.java index 87ae8f0b0..67cac165b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSpider.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSpider.java @@ -1,33 +1,36 @@ package nautilus.game.arcade.game.games.smash.kits; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + import mineplex.core.common.util.C; import mineplex.core.common.util.UtilInv; import mineplex.core.disguise.disguises.DisguiseSpider; import mineplex.core.itemstack.ItemStackFactory; + import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.smash.perks.PerkSmashStats; +import nautilus.game.arcade.game.games.smash.perks.SmashKit; +import nautilus.game.arcade.game.games.smash.perks.spider.PerkNeedler; +import nautilus.game.arcade.game.games.smash.perks.spider.PerkSpiderLeap; +import nautilus.game.arcade.game.games.smash.perks.spider.PerkWebShot; +import nautilus.game.arcade.game.games.smash.perks.spider.SmashSpider; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.SmashKit; -import nautilus.game.arcade.kit.perks.*; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; public class KitSpider extends SmashKit { - private static final String[] DESCRIPTION = { - }; private static final Perk[] PERKS = { new PerkSmashStats(6, 1.5, 0.25, 6), new PerkSpiderLeap(), new PerkNeedler(), new PerkWebShot(), - new PerkSpidersNest() + new SmashSpider() }; private static final ItemStack IN_HAND = new ItemStack(Material.WEB); @@ -77,50 +80,32 @@ public class KitSpider extends SmashKit }; private static final ItemStack[] PLAYER_ARMOR = { - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_BOOTS), - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_LEGGINGS), - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_CHESTPLATE), - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_HELMET), + new ItemStack(Material.CHAINMAIL_BOOTS), + new ItemStack(Material.CHAINMAIL_LEGGINGS), + new ItemStack(Material.CHAINMAIL_CHESTPLATE), + new ItemStack(Material.CHAINMAIL_HELMET), }; public KitSpider(ArcadeManager manager) { - super(manager, "Spider", KitAvailability.Free, DESCRIPTION, PERKS, EntityType.SPIDER, IN_HAND, "Spider Nest", 30000, Sound.SPIDER_DEATH); - } - - @Override - public void giveCoreItems(Player player) - { - UtilInv.Clear(player); - - player.getInventory().addItem(PLAYER_ITEMS[0], PLAYER_ITEMS[1]); - - if (Manager.GetGame().GetState() == GameState.Recruit) - player.getInventory().addItem(PLAYER_ITEMS[2], PLAYER_ITEMS[3], PLAYER_ITEMS[4]); - - player.getInventory().setArmorContents(PLAYER_ARMOR); - } - - @Override - public void giveSuperItems(Player player) - { - + super(manager, "Spider", KitAvailability.Free, PERKS, EntityType.SPIDER, IN_HAND, DisguiseSpider.class); } @Override public void GiveItems(Player player) { - giveCoreItems(player); + disguise(player); + + UtilInv.Clear(player); - //Disguise - DisguiseSpider disguise = new DisguiseSpider(player); + player.getInventory().addItem(PLAYER_ITEMS[0], PLAYER_ITEMS[1]); - if (Manager.GetGame().GetTeam(player) != null) - disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); - else - disguise.setName(player.getName()); - - disguise.setCustomNameVisible(true); - Manager.GetDisguise().disguise(disguise); + if (Manager.GetGame().GetState() == GameState.Recruit) + { + player.getInventory().addItem(PLAYER_ITEMS[2], PLAYER_ITEMS[3], PLAYER_ITEMS[4]); + } + + player.getInventory().setArmorContents(PLAYER_ARMOR); + player.setExp(0.99F); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitWitch.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitWitch.java index 6a7bfc74f..34657771c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitWitch.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitWitch.java @@ -1,33 +1,35 @@ package nautilus.game.arcade.game.games.smash.kits; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + import mineplex.core.common.util.C; import mineplex.core.common.util.UtilInv; import mineplex.core.disguise.disguises.DisguiseWitch; import mineplex.core.itemstack.ItemStackFactory; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.smash.perks.PerkSmashStats; +import nautilus.game.arcade.game.games.smash.perks.SmashKit; +import nautilus.game.arcade.game.games.smash.perks.witch.PerkBatWave; +import nautilus.game.arcade.game.games.smash.perks.witch.PerkWitchPotion; +import nautilus.game.arcade.game.games.smash.perks.witch.SmashWitch; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.SmashKit; -import nautilus.game.arcade.kit.perks.*; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; +import nautilus.game.arcade.kit.perks.PerkDoubleJump; public class KitWitch extends SmashKit { - private static final String[] DESCRIPTION = { - }; private static final Perk[] PERKS = { new PerkSmashStats(6, 1.5, 0.3, 5), new PerkDoubleJump("Double Jump", 0.9, 0.9, false), new PerkWitchPotion(), new PerkBatWave(), - new PerkBatForm() + new SmashWitch() }; private static final ItemStack IN_HAND = new ItemStack(Material.POTION); @@ -73,35 +75,21 @@ public class KitWitch extends SmashKit }; private static final ItemStack[] PLAYER_ARMOR = { - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_BOOTS), - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_LEGGINGS), - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_CHESTPLATE), + new ItemStack(Material.CHAINMAIL_BOOTS), + new ItemStack(Material.CHAINMAIL_LEGGINGS), + new ItemStack(Material.CHAINMAIL_CHESTPLATE), null }; public KitWitch(ArcadeManager manager) { - super(manager, "Witch", KitAvailability.Gem, 6000, DESCRIPTION, PERKS, EntityType.WITCH, IN_HAND, "Bat Form", 20000, Sound.BAT_HURT); + super(manager, "Witch", KitAvailability.Gem, 6000, PERKS, EntityType.WITCH, IN_HAND, DisguiseWitch.class); } - - @Override - public void giveCoreItems(Player player) + + public void giveSmashItems(Player player) { - UtilInv.Clear(player); - - player.getInventory().addItem(PLAYER_ITEMS[0], PLAYER_ITEMS[1]); - - if (Manager.GetGame().GetState() == GameState.Recruit) - player.getInventory().addItem(PLAYER_ITEMS[2], PLAYER_ITEMS[3]); - - player.getInventory().setArmorContents(PLAYER_ARMOR); - } - - @Override - public void giveSuperItems(Player player) - { - player.getInventory().remove(Material.IRON_SPADE); player.getInventory().remove(Material.IRON_AXE); + player.getInventory().remove(Material.IRON_SPADE); player.getInventory().addItem(PLAYER_ITEMS[4]); @@ -111,33 +99,15 @@ public class KitWitch extends SmashKit @Override public void GiveItems(Player player) { - giveCoreItems(player); + disguise(player); + + UtilInv.Clear(player); - //Disguise - DisguiseWitch disguise = new DisguiseWitch(player); + player.getInventory().addItem(PLAYER_ITEMS[0], PLAYER_ITEMS[1]); - if (Manager.GetGame().GetTeam(player) != null) - disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); - else - disguise.setName(player.getName()); + if (Manager.GetGame().GetState() == GameState.Recruit) + player.getInventory().addItem(PLAYER_ITEMS[2], PLAYER_ITEMS[3]); - disguise.setCustomNameVisible(true); - Manager.GetDisguise().disguise(disguise); - } - - @Override - public void activateSuperCustom(Player player) - { - for (Perk perk : GetPerks()) - if (perk instanceof PerkDoubleJump) - ((PerkDoubleJump) perk).disableForPlayer(player); - } - - @Override - public void deactivateSuperCustom(Player player) - { - for (Perk perk : GetPerks()) - if (perk instanceof PerkDoubleJump) - ((PerkDoubleJump) perk).enableForPlayer(player); + player.getInventory().setArmorContents(PLAYER_ARMOR); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitWither.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitWither.java deleted file mode 100644 index 9aa80de7c..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitWither.java +++ /dev/null @@ -1,143 +0,0 @@ -package nautilus.game.arcade.game.games.smash.kits; - -import org.bukkit.Color; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.LeatherArmorMeta; - -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilInv; -import mineplex.core.common.util.UtilServer; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.kit.KitAvailability; -import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.SmashKit; -import nautilus.game.arcade.kit.perks.PerkDoubleJump; -import nautilus.game.arcade.kit.perks.PerkSmashStats; -import nautilus.game.arcade.kit.perks.PerkSkullShot; - -public class KitWither extends SmashKit -{ - public KitWither(ArcadeManager manager) - { - super(manager, "Wither", KitAvailability.Gem, 5000, - - new String[] - { - }, - - new Perk[] - { - new PerkSmashStats(6, 1.2, 0.3, 6), - new PerkDoubleJump("Double Jump", 0.9, 0.9, false), - new PerkSkullShot(), - }, - EntityType.ZOMBIE, - new ItemStack(Material.BOW), - "", 0, null); - } - - @Override - public void giveCoreItems(Player player) - { - UtilInv.Clear(player); - - player.getInventory().addItem(new ItemStack(Material.ARROW)); - - ItemStack head = ItemStackFactory.Instance.CreateStack(Material.SKULL_ITEM, (byte)1, 1); - player.getInventory().setHelmet(head); - - ItemStack armor = new ItemStack(Material.LEATHER_CHESTPLATE); - LeatherArmorMeta meta = (LeatherArmorMeta)armor.getItemMeta(); - meta.setColor(Color.BLACK); - armor.setItemMeta(meta); - player.getInventory().setChestplate(armor); - - ItemStack legs = new ItemStack(Material.LEATHER_LEGGINGS); - LeatherArmorMeta metaLegs = (LeatherArmorMeta)armor.getItemMeta(); - metaLegs.setColor(Color.BLACK); - armor.setItemMeta(metaLegs); - player.getInventory().setLeggings(legs); - - ItemStack boots = new ItemStack(Material.LEATHER_BOOTS); - LeatherArmorMeta metaBoots = (LeatherArmorMeta)armor.getItemMeta(); - metaBoots.setColor(Color.BLACK); - boots.setItemMeta(metaBoots); - player.getInventory().setBoots(boots); - } - - @Override - public void giveSuperItems(Player player) - { - - } - - @Override - public void GiveItems(Player player) - { - giveCoreItems(player); - } - - @EventHandler - public void InvisibilityUpdate(UpdateEvent event) - { - if (event.getType() != UpdateType.FAST) - return; - - for (Player player : UtilServer.getPlayers()) - { - if (!HasKit(player)) - continue; - - if (player.getInventory().getChestplate() == null) - continue; - - Manager.GetCondition().Factory().Invisible("Wither Invis", player, player, 1.9, 0, false, false, false); - } - } - - @Override - public Entity SpawnEntity(Location loc) - { - EntityType type = _entityType; - if (type == EntityType.PLAYER) - type = EntityType.ZOMBIE; - - LivingEntity entity = (LivingEntity) Manager.GetCreature().SpawnEntity(loc, type); - - entity.setRemoveWhenFarAway(false); - entity.setCustomName(GetAvailability().GetColor() + GetName() + " Kit"); - entity.setCustomNameVisible(true); - entity.getEquipment().setItemInHand(_itemInHand); - - Manager.GetCondition().Factory().Invisible("Kit Invis", entity, entity, 7777, 0, false, false, false); - - UtilEnt.Vegetate(entity); - - SpawnCustom(entity); - - return entity; - } - - @Override - public void SpawnCustom(LivingEntity ent) - { - ItemStack head = ItemStackFactory.Instance.CreateStack(Material.SKULL_ITEM, (byte)1, 1); - ent.getEquipment().setHelmet(head); - - ItemStack armor = new ItemStack(Material.LEATHER_CHESTPLATE); - LeatherArmorMeta meta = (LeatherArmorMeta)armor.getItemMeta(); - meta.setColor(Color.BLACK); - armor.setItemMeta(meta); - ent.getEquipment().setChestplate(armor); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitWitherSkeleton.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitWitherSkeleton.java index 75739762e..8efef7fe6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitWitherSkeleton.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitWitherSkeleton.java @@ -1,34 +1,37 @@ package nautilus.game.arcade.game.games.smash.kits; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton.SkeletonType; +import org.bukkit.inventory.ItemStack; + import mineplex.core.common.util.C; import mineplex.core.common.util.UtilInv; import mineplex.core.disguise.disguises.DisguiseSkeleton; import mineplex.core.itemstack.ItemStackFactory; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.smash.perks.PerkSmashStats; +import nautilus.game.arcade.game.games.smash.perks.SmashKit; +import nautilus.game.arcade.game.games.smash.perks.witherskeleton.PerkWitherImage; +import nautilus.game.arcade.game.games.smash.perks.witherskeleton.PerkWitherSkull; +import nautilus.game.arcade.game.games.smash.perks.witherskeleton.SmashWitherSkeleton; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.SmashKit; -import nautilus.game.arcade.kit.perks.*; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.entity.Skeleton.SkeletonType; -import org.bukkit.inventory.ItemStack; +import nautilus.game.arcade.kit.perks.PerkDoubleJump; public class KitWitherSkeleton extends SmashKit { - private static final String[] DESCRIPTION = { - }; private static final Perk[] PERKS = { new PerkSmashStats(6, 1.2, 0.3, 6), new PerkDoubleJump("Double Jump", 0.9, 0.9, false), new PerkWitherSkull(), new PerkWitherImage(), - new PerkWitherForm() + new SmashWitherSkeleton() }; private static final ItemStack IN_HAND = new ItemStack(Material.IRON_SWORD); @@ -67,21 +70,32 @@ public class KitWitherSkeleton extends SmashKit private static final ItemStack[] PLAYER_ARMOR = { - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_BOOTS), - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_LEGGINGS), - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_CHESTPLATE), - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_HELMET) + new ItemStack(Material.CHAINMAIL_BOOTS), + new ItemStack(Material.CHAINMAIL_LEGGINGS), + new ItemStack(Material.CHAINMAIL_CHESTPLATE), + new ItemStack(Material.CHAINMAIL_HELMET) }; - public KitWitherSkeleton(ArcadeManager manager) { - super(manager, "Wither Skeleton", KitAvailability.Gem, 6000, DESCRIPTION, PERKS, EntityType.SKELETON, IN_HAND, "Wither Form", 18000, Sound.WITHER_SPAWN); + super(manager, "Wither Skeleton", KitAvailability.Gem, 6000, PERKS, EntityType.SKELETON, IN_HAND, DisguiseSkeleton.class); + } + + public void giveSmashItems(Player player) + { + player.getInventory().remove(Material.IRON_SWORD); + player.getInventory().remove(Material.IRON_AXE); + + player.getInventory().addItem(PLAYER_ITEMS[3]); + + UtilInv.Update(player); } @Override - public void giveCoreItems(Player player) + public void GiveItems(Player player) { + disguise(player); + UtilInv.Clear(player); player.getInventory().addItem(PLAYER_ITEMS[0], PLAYER_ITEMS[1]); @@ -91,31 +105,23 @@ public class KitWitherSkeleton extends SmashKit player.getInventory().setArmorContents(PLAYER_ARMOR); } - + @Override - public void giveSuperItems(Player player) - { - player.getInventory().remove(Material.IRON_SWORD); - player.getInventory().remove(Material.IRON_AXE); - - player.getInventory().addItem(PLAYER_ARMOR[3]); - - UtilInv.Update(player); - } - - @Override - public void GiveItems(Player player) - { - giveCoreItems(player); - + public void disguise(Player player) + { //Disguise DisguiseSkeleton disguise = new DisguiseSkeleton(player); - - if (Manager.GetGame().GetTeam(player) != null) - disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); + GameTeam gameTeam = Manager.GetGame().GetTeam(player); + + if (gameTeam != null) + { + disguise.setName(gameTeam.GetColor() + player.getName()); + } else + { disguise.setName(player.getName()); - + } + disguise.setCustomNameVisible(true); disguise.SetSkeletonType(SkeletonType.WITHER); disguise.hideArmor(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitWolf.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitWolf.java index d6bcf19a5..0de6382fa 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitWolf.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitWolf.java @@ -1,34 +1,33 @@ package nautilus.game.arcade.game.games.smash.kits; -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilInv; -import mineplex.core.disguise.disguises.DisguiseBase; -import mineplex.core.disguise.disguises.DisguiseWolf; -import mineplex.core.itemstack.ItemStackFactory; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.game.Game.GameState; -import nautilus.game.arcade.kit.KitAvailability; -import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.SmashKit; -import nautilus.game.arcade.kit.perks.PerkDoubleJump; -import nautilus.game.arcade.kit.perks.PerkSmashStats; -import nautilus.game.arcade.kit.perks.PerkWolf; import org.bukkit.ChatColor; import org.bukkit.Material; -import org.bukkit.Sound; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilInv; +import mineplex.core.disguise.disguises.DisguiseWolf; +import mineplex.core.itemstack.ItemStackFactory; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.smash.perks.PerkSmashStats; +import nautilus.game.arcade.game.games.smash.perks.SmashKit; +import nautilus.game.arcade.game.games.smash.perks.wolf.PerkWolf; +import nautilus.game.arcade.game.games.smash.perks.wolf.SmashWolf; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.PerkDoubleJump; + public class KitWolf extends SmashKit { - private static final String[] DESCRIPTION = { - }; private static final Perk[] PERKS = { - new PerkSmashStats(5, 1.6, 0.25, 4.5), + new PerkSmashStats(5, 1.6, 0.25, 5), new PerkDoubleJump("Wolf Jump", 1.0, 1.0, true), - new PerkWolf() + new PerkWolf(), + new SmashWolf() }; private static final ItemStack IN_HAND = new ItemStack(Material.BONE); @@ -66,23 +65,24 @@ public class KitWolf extends SmashKit }) }; - private static final ItemStack[] PLAYER_ARMOR = { null, - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_LEGGINGS), - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_CHESTPLATE), + new ItemStack(Material.CHAINMAIL_LEGGINGS), + new ItemStack(Material.IRON_CHESTPLATE), null }; public KitWolf(ArcadeManager manager) { - super(manager, "Wolf", KitAvailability.Gem, 4000, DESCRIPTION, PERKS, EntityType.WOLF, IN_HAND, "Frenzy", 30000, Sound.WOLF_HOWL); + super(manager, "Wolf", KitAvailability.Gem, 4000, PERKS, EntityType.WOLF, IN_HAND, DisguiseWolf.class); } @Override - public void giveCoreItems(Player player) + public void GiveItems(Player player) { + disguise(player); + UtilInv.Clear(player); player.getInventory().addItem(PLAYER_ITEMS[0], PLAYER_ITEMS[1]); @@ -92,53 +92,4 @@ public class KitWolf extends SmashKit player.getInventory().setArmorContents(PLAYER_ARMOR); } - - @Override - public void giveSuperItems(Player player) - { - - } - - @Override - public void GiveItems(Player player) - { - giveCoreItems(player); - - //Disguise - DisguiseWolf disguise = new DisguiseWolf(player); - - if (Manager.GetGame().GetTeam(player) != null) - disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); - else - disguise.setName(player.getName()); - - disguise.setCustomNameVisible(true); - Manager.GetDisguise().disguise(disguise); - } - - @Override - public void activateSuperCustom(Player player) - { - Manager.GetCondition().Factory().Strength(GetName(), player, player, 30, 1, false, false, false); - Manager.GetCondition().Factory().Speed(GetName(), player, player, 30, 2, false, false, false); - Manager.GetCondition().Factory().Regen(GetName(), player, player, 30, 2, false, false, false); - - DisguiseBase disguise = Manager.GetDisguise().getDisguise(player); - if (disguise instanceof DisguiseWolf) - { - ((DisguiseWolf) disguise).setAngry(true); - Manager.GetDisguise().updateDisguise(disguise); - } - } - - @Override - public void deactivateSuperCustom(Player player) - { - DisguiseBase disguise = Manager.GetDisguise().getDisguise(player); - if (disguise instanceof DisguiseWolf) - { - ((DisguiseWolf) disguise).setAngry(false); - Manager.GetDisguise().updateDisguise(disguise); - } - } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitZombie.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitZombie.java index 6f2d17e76..62ea7dc0a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitZombie.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitZombie.java @@ -1,26 +1,35 @@ package nautilus.game.arcade.game.games.smash.kits; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.event.EventHandler; +import org.bukkit.inventory.ItemStack; + import mineplex.core.common.util.C; import mineplex.core.common.util.UtilInv; import mineplex.core.disguise.disguises.DisguiseZombie; import mineplex.core.itemstack.ItemStackFactory; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.smash.perks.PerkSmashStats; +import nautilus.game.arcade.game.games.smash.perks.SmashKit; +import nautilus.game.arcade.game.games.smash.perks.zombie.SmashZombie; +import nautilus.game.arcade.game.games.smash.perks.zombie.PerkOvercharge; +import nautilus.game.arcade.game.games.smash.perks.zombie.PerkZombieBile; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.SmashKit; -import nautilus.game.arcade.kit.perks.*; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; +import nautilus.game.arcade.kit.perks.PerkDeathsGrasp; +import nautilus.game.arcade.kit.perks.PerkDoubleJump; +import nautilus.game.arcade.kit.perks.PerkFletcher; +import nautilus.game.arcade.kit.perks.PerkKnockbackArrow; public class KitZombie extends SmashKit { - private static final String[] DESCRIPTION = { - }; private static final Perk[] PERKS = { new PerkSmashStats(6, 1.25, 0.25, 5), @@ -30,7 +39,7 @@ public class KitZombie extends SmashKit new PerkOvercharge(6, 250, true), new PerkZombieBile(), new PerkDeathsGrasp(), - new PerkNightLivingDead() + new SmashZombie() }; private static final ItemStack IN_HAND = new ItemStack(Material.IRON_AXE); @@ -68,21 +77,23 @@ public class KitZombie extends SmashKit }; private static final ItemStack[] PLAYER_ARMOR = { - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_BOOTS), - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_LEGGINGS), - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_CHESTPLATE), + new ItemStack(Material.CHAINMAIL_BOOTS), + new ItemStack(Material.CHAINMAIL_LEGGINGS), + new ItemStack(Material.CHAINMAIL_CHESTPLATE), null, }; public KitZombie(ArcadeManager manager) { - super(manager, "Zombie", KitAvailability.Gem, 6000, DESCRIPTION, PERKS, EntityType.ZOMBIE, IN_HAND, "Night of the Living Dead", 0, Sound.AMBIENCE_CAVE); + super(manager, "Zombie", KitAvailability.Gem, 6000, PERKS, EntityType.ZOMBIE, IN_HAND, DisguiseZombie.class); } @Override - public void giveCoreItems(Player player) + public void GiveItems(Player player) { + disguise(player); + UtilInv.Clear(player); player.getInventory().addItem(PLAYER_ITEMS[0], PLAYER_ITEMS[1]); @@ -90,30 +101,30 @@ public class KitZombie extends SmashKit if (Manager.GetGame().GetState() == GameState.Recruit) player.getInventory().addItem(PLAYER_ITEMS[2], PLAYER_ITEMS[3]); - player.getInventory().setArmorContents(PLAYER_ARMOR); } - - @Override - public void giveSuperItems(Player player) + + @EventHandler + public void arrowDamage(CustomDamageEvent event) { - - } - - @Override - public void GiveItems(Player player) - { - giveCoreItems(player); - - //Disguise - DisguiseZombie disguise = new DisguiseZombie(player); - - if (Manager.GetGame().GetTeam(player) != null) - disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); - else - disguise.setName(player.getName()); - - disguise.setCustomNameVisible(true); - Manager.GetDisguise().disguise(disguise); + Player player = event.GetDamagerPlayer(true); + Projectile proj = event.GetProjectile(); + + if (player == null || proj == null) + { + return; + } + + if (!(proj instanceof Arrow)) + { + return; + } + + if (!HasKit(player)) + { + return; + } + + event.AddMod("Arrow Nerf", -1); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/modes/RandomKitSSM.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/modes/RandomKitSSM.java index 1f90c3a95..c47040297 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/modes/RandomKitSSM.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/modes/RandomKitSSM.java @@ -18,6 +18,7 @@ import nautilus.game.arcade.game.games.smash.kits.KitCow; import nautilus.game.arcade.game.games.smash.kits.KitCreeper; import nautilus.game.arcade.game.games.smash.kits.KitEnderman; import nautilus.game.arcade.game.games.smash.kits.KitGolem; +import nautilus.game.arcade.game.games.smash.kits.KitGuardian; import nautilus.game.arcade.game.games.smash.kits.KitMagmaCube; import nautilus.game.arcade.game.games.smash.kits.KitPig; import nautilus.game.arcade.game.games.smash.kits.KitSheep; @@ -60,13 +61,10 @@ public class RandomKitSSM extends SoloSuperSmash new KitGolem(manager), new KitSpider(manager), new KitSlime(manager), - new KitCreeper(manager), new KitEnderman(manager), new KitSnowman(manager), new KitWolf(manager), - - new KitBlaze(manager), new KitWitch(manager), new KitChicken(manager), @@ -77,17 +75,17 @@ public class RandomKitSSM extends SoloSuperSmash new KitMagmaCube(manager), new KitZombie(manager), new KitCow(manager), - - new KitSheep(manager) + new KitSheep(manager), + new KitGuardian(manager) }; } @Override @EventHandler(priority = EventPriority.HIGH) - public void GameStateChange(GameStateChangeEvent event) + public void gameStart(GameStateChangeEvent event) { - super.GameStateChange(event); + super.gameStart(event); if (event.GetState() != GameState.Prepare) return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/modes/kits/KitHipster.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/modes/kits/KitHipster.java index f32ea4f82..73a4bdb57 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/modes/kits/KitHipster.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/modes/kits/KitHipster.java @@ -1,15 +1,14 @@ package nautilus.game.arcade.game.games.smash.modes.kits; import org.bukkit.Material; -import org.bukkit.Sound; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.smash.perks.SmashKit; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.SmashKit; /** * KitPlayer @@ -21,27 +20,13 @@ public class KitHipster extends SmashKit public KitHipster(ArcadeManager manager) { - super(manager, "Hipster", KitAvailability.Free, 0, - new String[]{"Always get another kit!"}, new Perk[]{}, EntityType.ZOMBIE, new ItemStack(Material.RECORD_10), "Super", - 1, Sound.BURP); - } - - @Override - public void giveCoreItems(Player player) - { - - } - - @Override - public void giveSuperItems(Player player) - { - + super(manager, "Hipster", KitAvailability.Free, 0, new Perk[] {}, EntityType.ZOMBIE, new ItemStack(Material.RECORD_10), null); } @Override public void GiveItems(Player player) { - + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/PerkCowMooshroomMadness.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/PerkCowMooshroomMadness.java deleted file mode 100644 index 4ec1a0909..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/PerkCowMooshroomMadness.java +++ /dev/null @@ -1,77 +0,0 @@ -package nautilus.game.arcade.game.games.smash.perks; - -import java.util.HashSet; - -import org.bukkit.Sound; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.entity.PlayerDeathEvent; - -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.disguise.disguises.DisguiseBase; -import mineplex.core.disguise.disguises.DisguiseMooshroom; -import mineplex.core.recharge.Recharge; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.kit.SmashPerk; - -public class PerkCowMooshroomMadness extends SmashPerk -{ - private HashSet<String> _cowSuperActive = new HashSet<String>(); - - public PerkCowMooshroomMadness() - { - super("Mooshroom Madness", new String[] - { - }, false); - } - - @Override - public void addSuperCustom(Player player) - { - _cowSuperActive.add(player.getName()); - - //Disguise - DisguiseMooshroom disguise = new DisguiseMooshroom(player); - - if (Manager.GetGame().GetTeam(player) != null) - disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); - else - disguise.setName(player.getName()); - - disguise.setCustomNameVisible(true); - Manager.GetDisguise().disguise(disguise); - - //Armor - player.setMaxHealth(30); - player.setHealth(30); - - //Sound - player.getWorld().playSound(player.getLocation(), Sound.COW_HURT, 5f, 0.25f); - - //Recharges - Recharge.Instance.recharge(player, "Angry Herd"); - Recharge.Instance.recharge(player, "Milk Spiral"); - } - - @EventHandler - public void damageBuff(CustomDamageEvent event) - { - Player player = event.GetDamagerPlayer(true); - if (player == null) - return; - - if (_cowSuperActive.contains(player.getName())) - { - event.AddMod(player.getName(), GetName(), 1, false); - } - } - - @Override - public boolean isSuperActive(Player player) - { - DisguiseBase disguise = Manager.GetDisguise().getDisguise(player); - - return disguise != null && disguise instanceof DisguiseMooshroom; - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSmashStats.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/PerkSmashStats.java similarity index 97% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSmashStats.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/PerkSmashStats.java index bf9bc5c47..2b5d00808 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSmashStats.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/PerkSmashStats.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.kit.perks; +package nautilus.game.arcade.game.games.smash.perks; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilPlayer; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/SmashKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/SmashKit.java new file mode 100644 index 000000000..c79cd2660 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/SmashKit.java @@ -0,0 +1,133 @@ +package nautilus.game.arcade.game.games.smash.perks; + +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.disguise.DisguiseManager; +import mineplex.core.disguise.disguises.DisguiseInsentient; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.ProgressingKit; + +public abstract class SmashKit extends ProgressingKit +{ + + protected static final String DOUBLE_JUMP = C.cYellow + "Double tap " + C.cWhite + "your jump key to " + C.cGreen + "Double Jump"; + + private Class<? extends DisguiseInsentient> _clazz; + private String[] _description; + + public SmashKit(ArcadeManager manager, String name, KitAvailability kitAvailability, Perk[] kitPerks, EntityType entityType, ItemStack itemInHand, Class<? extends DisguiseInsentient> clazz) + { + this(manager, name, kitAvailability, 0, kitPerks, entityType, itemInHand, clazz); + } + + public SmashKit(ArcadeManager manager, String name, KitAvailability kitAvailability, int cost, Perk[] kitPerks, EntityType entityType, ItemStack itemInHand, + Class<? extends DisguiseInsentient> clazz) + { + super(manager, name, "smash" + name.toLowerCase().replace(" ", ""), kitAvailability, cost, null, kitPerks, entityType, itemInHand); + + _clazz = clazz; + } + + public boolean isSmashActive(Player player) + { + for (Perk perk : GetPerks()) + { + if (!(perk instanceof SmashUltimate)) + { + continue; + } + + SmashUltimate ultimate = (SmashUltimate) perk; + + if (ultimate.isUsingUltimate(player)) + { + return true; + } + } + + return false; + } + + public void disguise(Player player) + { + disguise(player, _clazz); + } + + public void disguise(Player player, Class<? extends DisguiseInsentient> clazz) + { + if (_clazz == null) + { + return; + } + + DisguiseManager disguiseManager = Manager.GetDisguise(); + + try + { + DisguiseInsentient disguise = clazz.getConstructor(Entity.class).newInstance(player); + GameTeam gameTeam = Manager.GetGame().GetTeam(player); + + if (gameTeam != null) + { + disguise.setName(gameTeam.GetColor() + player.getName()); + } + else + { + disguise.setName(player.getName()); + } + + disguise.setCustomNameVisible(true); + disguiseManager.disguise(disguise); + } + catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) + { + e.printStackTrace(); + } + } + + @Override + public String[] getDescription() + { + return GetDesc(); + } + + @Override + public String[] GetDesc() + { + if (_description == null) + { + List<String> description = new ArrayList<>(); + + description.add(C.cGreen + "Kit - " + C.cWhiteB + GetName()); + + for (Perk perk : GetPerks()) + { + if (!perk.IsVisible()) + { + continue; + } + + for (String line : perk.GetDesc()) + { + description.add(C.cGray + " " + line); + } + } + + _description = description.toArray(new String[description.size()]); + } + + return _description; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/SmashPerk.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/SmashPerk.java new file mode 100644 index 000000000..0c7d669be --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/SmashPerk.java @@ -0,0 +1,65 @@ +package nautilus.game.arcade.game.games.smash.perks; + +import org.bukkit.entity.Player; + +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.smash.TeamSuperSmash; +import nautilus.game.arcade.kit.Perk; + +public class SmashPerk extends Perk +{ + + public SmashPerk(String name, String[] perkDesc) + { + super(name, perkDesc); + } + + /** + * @param player + * The player that you need to check. + * + * @return true when the player is currently using a SmashUltimate. + */ + public boolean isSuperActive(Player player) + { + if (Kit instanceof SmashKit) + { + SmashKit kit = (SmashKit) Kit; + + if (kit.isSmashActive(player)) + { + return true; + } + } + + return false; + } + + /** + * Checks to see if an attack would count as team damage. + * Always returns false if the game is not {@link TeamSuperSmash}. + * + * @param player1 + * @param player2 + * @return true when the team of player1 equals the team of player2. + * @see GameTeam + */ + public boolean isTeamDamage(Player player1, Player player2) + { + Game game = Manager.GetGame(); + + if (!(game instanceof TeamSuperSmash)) + { + return false; + } + + if (game.GetTeam(player1).equals(game.GetTeam(player2))) + { + return true; + } + + return false; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/SmashUltimate.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/SmashUltimate.java new file mode 100644 index 000000000..8bddb995c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/SmashUltimate.java @@ -0,0 +1,158 @@ +package nautilus.game.arcade.game.games.smash.perks; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; + +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.kit.Perk; + +public class SmashUltimate extends Perk +{ + + private static final int MIN_ULTIAMTE_DISPLAY_TIME = 1000; + + private Map<UUID, Long> _lastUltimate = new HashMap<>(); + + private Sound _sound; + private int _length; + + public SmashUltimate(String name, String[] perkDesc, Sound sound, int length) + { + super(name, perkDesc); + + _sound = sound; + _length = length; + } + + public void activate(Player player) + { + _lastUltimate.put(player.getUniqueId(), System.currentTimeMillis()); + + if (_length > MIN_ULTIAMTE_DISPLAY_TIME) + { + Recharge recharge = Recharge.Instance; + + recharge.recharge(player, GetName()); + recharge.use(player, GetName(), _length, false, false); + recharge.setDisplayForce(player, GetName(), true); + recharge.setCountdown(player, GetName(), true); + } + } + + public void cancel(Player player) + { + _lastUltimate.remove(player.getUniqueId()); + + if (_length > MIN_ULTIAMTE_DISPLAY_TIME) + { + player.sendMessage(F.main("Game", "Deactivated " + F.skill(GetName()) + ".")); + player.playSound(player.getLocation(), Sound.BLAZE_DEATH, 1, 0); + } + + player.getInventory().clear(); + Kit.GiveItems(player); + } + + public boolean isUsable(Player player) + { + return true; + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST || _length == 0) + { + return; + } + + List<UUID> list = new ArrayList<>(); + list.addAll(_lastUltimate.keySet()); + + for (UUID uuid : list) + { + Player player = UtilPlayer.searchExact(uuid); + + if (player == null) + { + continue; + } + + if (UtilTime.elapsed(_lastUltimate.get(uuid), _length)) + { + cancel(player); + } + } + } + + @EventHandler + public void onCombatDeath(CombatDeathEvent event) + { + if (!(event.GetEvent().getEntity() instanceof Player)) + { + return; + } + + Player player = (Player) event.GetEvent().getEntity(); + + if (!isUsingUltimate(player)) + { + return; + } + + cancel(player); + } + + @EventHandler + public void onGameStateChange(GameStateChangeEvent event) + { + if (event.GetState() != GameState.End) + { + for (UUID uuid : _lastUltimate.keySet()) + { + cancel(UtilPlayer.searchExact(uuid)); + } + } + } + + public boolean isUsingUltimate(Player player) + { + return isUsingUltimate(player.getUniqueId()); + } + + public boolean isUsingUltimate(UUID uuid) + { + return _lastUltimate.containsKey(uuid); + } + + public Map<UUID, Long> getLastUltimate() + { + return _lastUltimate; + } + + public Sound getSound() + { + return _sound; + } + + public int getLength() + { + return _length; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/blaze/PerkFirefly.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/blaze/PerkFirefly.java new file mode 100644 index 000000000..29cd6d704 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/blaze/PerkFirefly.java @@ -0,0 +1,262 @@ +package nautilus.game.arcade.game.games.smash.perks.blaze; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + +import org.bukkit.EntityEffect; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilItem; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.games.smash.perks.SmashPerk; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.data.FireflyData; + +public class PerkFirefly extends SmashPerk +{ + + private static final int COOLDOWN = 12000; + private static final int DURATION = 2750; + private static final int DAMAGE = 7; + + private static final int RADIUS_NORMAL = 4; + private static final float VELOCITY_NORMAL = 0.7F; + + private static final int RADIUS_SMASH = 7; + private static final float VELOCITY_SMASH = 0.79F; + + private static final int HIT_FREQUENCY = 2000; + private static final int WARMUP_TIME = 1500; + private static final int MIN_CANCEL_DAMAGE = 4; + private static final int KNOCKBACK_MAGNITUDE = 2; + + private Set<FireflyData> _data = new HashSet<FireflyData>(); + + private int _tick = 0; + + public PerkFirefly() + { + super("Firefly", new String[] { C.cYellow + "Right-Click" + C.cGray + " with Axe to use " + C.cGreen + "Firefly" }); + } + + @EventHandler + public void Skill(PlayerInteractEvent event) + { + if (event.isCancelled()) + { + return; + } + + if (!UtilEvent.isAction(event, ActionType.R)) + { + return; + } + + if (UtilBlock.usable(event.getClickedBlock())) + { + return; + } + + Player player = event.getPlayer(); + + if (!UtilItem.isAxe(player.getItemInHand().getType())) + { + return; + } + + if (!hasPerk(player)) + { + return; + } + + if (isSuperActive(player)) + { + return; + } + + if (!Recharge.Instance.use(player, GetName(), COOLDOWN, true, true)) + { + return; + } + + activate(player, this); + } + + /* + * It is split like this so Blaze's Smash can be called without the need to + * copy code. + */ + public void activate(Player player, Perk caller) + { + _data.add(new FireflyData(player)); + + UtilPlayer.message(player, F.main("Skill", "You used " + F.skill(caller.GetName()) + ".")); + } + + @EventHandler + public void Update(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + _tick++; + + Iterator<FireflyData> dataIterator = _data.iterator(); + + //There are a lot of magic numbers here, they are all arbitrary sound and particle values. + + while (dataIterator.hasNext()) + { + FireflyData data = dataIterator.next(); + + Player player = data.Player; + boolean superActive = isSuperActive(data.Player); + String skillName = superActive ? "Phoenix" : GetName(); + + if (UtilPlayer.isSpectator(player)) + { + dataIterator.remove(); + continue; + } + + // Warmup + if (!UtilTime.elapsed(data.Time, WARMUP_TIME) && !superActive) + { + UtilAction.zeroVelocity(player); + player.getWorld().playSound(player.getLocation(), Sound.EXPLODE, 0.2f, 0.6f); + data.Location = player.getLocation(); + + // Sound and Effect + UtilParticle.PlayParticleToAll(ParticleType.FIREWORKS_SPARK, player.getLocation().add(0, 1, 0), 0.6f, 0.6f, 0.6f, 0, 10, ViewDist.LONG); + + float progress = (float) (System.currentTimeMillis() - data.Time) / WARMUP_TIME; + + player.getWorld().playSound(player.getLocation(), Sound.BLAZE_BREATH, 0.5f, 1f + progress); + } + // Velocity + else if (!UtilTime.elapsed(data.Time, DURATION) || superActive) + { + UtilAction.velocity(player, player.getLocation().getDirection().multiply(superActive ? VELOCITY_SMASH : VELOCITY_NORMAL).add(new Vector(0, 0.15, 0))); + player.getWorld().playSound(player.getLocation(), Sound.EXPLODE, 0.6f, 1.2f); + + // Sound and Effect + if (!superActive) + { + UtilParticle.PlayParticleToAll(ParticleType.FLAME, player.getLocation().add(0, 1, 0), 0.6f, 0.6f, 0.6f, 0, 40, ViewDist.LONG); + + player.getWorld().playSound(player.getLocation(), Sound.EXPLODE, 0.5f, 1.25f); + } + else + { + UtilParticle.PlayParticleToAll(ParticleType.FLAME, player.getLocation().add(0, 1, 0), 1f, 1f, 1f, 0, 60, ViewDist.LONG); + UtilParticle.PlayParticleToAll(ParticleType.LAVA, player.getLocation().add(0, 1, 0), 1f, 1f, 1f, 0, 40, ViewDist.LONG); + + player.getWorld().playSound(player.getLocation(), Sound.EXPLODE, 0.75f, 0.75f); + } + + for (Player other : UtilPlayer.getNearby(player.getLocation(), superActive ? RADIUS_SMASH : RADIUS_NORMAL)) + { + if (other.equals(player)) + { + continue; + } + + if (UtilPlayer.isSpectator(other)) + { + continue; + } + + other.playEffect(EntityEffect.HURT); + + if (_tick % 12 == 0) + { + if (Recharge.Instance.use(other, GetName() + " hit by " + player.getName(), HIT_FREQUENCY, false, false)) + { + // Damage Event + Manager.GetDamage().NewDamageEvent(other, player, null, DamageCause.CUSTOM, DAMAGE, true, true, false, player.getName(), skillName); + + UtilPlayer.message(other, F.main("Game", F.elem(Manager.GetColor(player) + player.getName()) + " hit you with " + F.elem(skillName) + ".")); + } + } + } + } + else + { + dataIterator.remove(); + } + } + } + + @EventHandler + public void FireflyDamage(CustomDamageEvent event) + { + if (event.GetDamage() < MIN_CANCEL_DAMAGE) + { + return; + } + + if (!(event.GetDamagerEntity(true) instanceof Player)) + { + return; + } + + Iterator<FireflyData> dataIterator = _data.iterator(); + + while (dataIterator.hasNext()) + { + FireflyData data = dataIterator.next(); + + if (!data.Player.equals(event.GetDamageeEntity())) + { + continue; + } + + if (!UtilTime.elapsed(data.Time, 1250) && !isSuperActive(data.Player)) + { + if (isTeamDamage(data.Player, event.GetDamagerPlayer(true))) + { + continue; + } + + dataIterator.remove(); + } + else + { + event.SetCancelled("Firefly Immunity"); + } + } + } + + @EventHandler + public void Knockback(CustomDamageEvent event) + { + if (event.GetReason() == null || !event.GetReason().contains(GetName())) + { + return; + } + + event.AddKnockback(GetName(), KNOCKBACK_MAGNITUDE); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/blaze/PerkInferno.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/blaze/PerkInferno.java new file mode 100644 index 000000000..7eb44eca3 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/blaze/PerkInferno.java @@ -0,0 +1,161 @@ +package nautilus.game.arcade.game.games.smash.perks.blaze; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Item; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilItem; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.games.smash.perks.SmashPerk; + +public class PerkInferno extends SmashPerk +{ + + private static final float MAX_ENERGY = 0.999F; + private static final float ENERGY_PER_TICK = 0.025F; + private static final float ENERGY_PER_ITEM = 0.035F; + + private static final double ITEM_EXPIRE_TIME = 0.7; + private static final double ITEM_BURN_TIME = 0.5; + private static final double ITEM_DAMAGE = 0.25; + private static final float ITEM_VELOCITY_MAGNITUDE = 1.6F; + + private Map<UUID, Long> _active = new HashMap<>(); + + public PerkInferno() + { + super("Inferno", new String[] { C.cYellow + "Hold Block" + C.cGray + " to use " + C.cGreen + "Inferno" }); + } + + @EventHandler + public void EnergyUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + for (Player player : Manager.GetGame().GetPlayers(true)) + { + if (!hasPerk(player)) + { + continue; + } + + if (!player.isBlocking()) + { + player.setExp(Math.min(MAX_ENERGY, player.getExp() + ENERGY_PER_TICK)); + } + } + } + + @EventHandler + public void Activate(PlayerInteractEvent event) + { + if (event.isCancelled()) + { + return; + } + + if (!UtilEvent.isAction(event, ActionType.R)) + { + return; + } + + if (UtilBlock.usable(event.getClickedBlock())) + { + return; + } + + Player player = event.getPlayer(); + + if (!UtilItem.isSword(player.getItemInHand())) + { + return; + } + + if (!hasPerk(player)) + { + return; + } + + if (isSuperActive(player)) + { + return; + } + + _active.put(player.getUniqueId(), System.currentTimeMillis()); + + UtilPlayer.message(player, F.main("Skill", "You used " + F.skill(GetName()) + ".")); + } + + @EventHandler + public void Update(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + for (Player cur : UtilServer.getPlayers()) + { + UUID key = cur.getUniqueId(); + + if (!_active.containsKey(key)) + { + continue; + } + + if (!cur.isBlocking()) + { + _active.remove(key); + continue; + } + + cur.setExp(cur.getExp() - ENERGY_PER_ITEM); + + if (cur.getExp() <= 0) + { + _active.remove(key); + continue; + } + + // Fire + Item fire = cur.getWorld().dropItem(cur.getEyeLocation(), new ItemStack(Material.BLAZE_POWDER)); + Manager.GetFire().Add(fire, cur, ITEM_EXPIRE_TIME, 0, ITEM_BURN_TIME, ITEM_DAMAGE, GetName(), false); + + fire.teleport(cur.getEyeLocation()); + fire.setVelocity(cur.getLocation().getDirection().add(getRandomVector()).multiply(ITEM_VELOCITY_MAGNITUDE)); + + // Effect + cur.getWorld().playSound(cur.getLocation(), Sound.GHAST_FIREBALL, 0.1f, 1f); + } + } + + private Vector getRandomVector() + { + double x = 0.07 - (UtilMath.r(14) / 100); + double y = 0.07 - (UtilMath.r(14) / 100); + double z = 0.07 - (UtilMath.r(14) / 100); + + return new Vector(x, y, z); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/blaze/SmashBlaze.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/blaze/SmashBlaze.java new file mode 100644 index 000000000..6fba264a3 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/blaze/SmashBlaze.java @@ -0,0 +1,40 @@ +package nautilus.game.arcade.game.games.smash.perks.blaze; + +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; + +import nautilus.game.arcade.game.games.smash.perks.SmashUltimate; +import nautilus.game.arcade.kit.Perk; + +public class SmashBlaze extends SmashUltimate +{ + + private static final int DURATION = 18000; + + public SmashBlaze() + { + super("Phoenix", new String[] {}, Sound.BLAZE_DEATH, DURATION); + } + + @Override + public void activate(Player player) + { + super.activate(player); + + player.getInventory().remove(Material.IRON_SWORD); + player.getInventory().remove(Material.IRON_AXE); + + for (Perk perk : Kit.GetPerks()) + { + if (!(perk instanceof PerkFirefly)) + { + continue; + } + + PerkFirefly firefly = (PerkFirefly) perk; + + firefly.activate(player, this); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkChickenRocket.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/chicken/PerkChickenRocket.java similarity index 57% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkChickenRocket.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/chicken/PerkChickenRocket.java index 5b34be0b8..2c04bff35 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkChickenRocket.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/chicken/PerkChickenRocket.java @@ -1,10 +1,11 @@ -package nautilus.game.arcade.kit.perks; +package nautilus.game.arcade.game.games.smash.perks.chicken; import java.util.HashSet; import java.util.Iterator; +import java.util.List; +import java.util.Set; import org.bukkit.Color; -import org.bukkit.FireworkEffect; import org.bukkit.FireworkEffect.Type; import org.bukkit.Sound; import org.bukkit.entity.Arrow; @@ -13,7 +14,6 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.block.Action; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.player.PlayerInteractEvent; @@ -23,62 +23,81 @@ import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilFirework; -import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.SmashPerk; + +import nautilus.game.arcade.game.games.smash.TeamSuperSmash; +import nautilus.game.arcade.game.games.smash.perks.SmashPerk; import nautilus.game.arcade.kit.perks.data.ChickenMissileData; public class PerkChickenRocket extends SmashPerk { - private HashSet<ChickenMissileData> _data = new HashSet<ChickenMissileData>(); - public PerkChickenRocket() + private static final int COOLDOWN = 7000; + private static final int MIN_TIME = 200; + private static final int MAX_TIME = 4000; + private static final int HIT_BOX_RADIUS = 2; + private static final int DAMAGE_RADIUS = 3; + private static final int DAMAGE = 8; + + private Set<ChickenMissileData> _data = new HashSet<>(); + + public PerkChickenRocket() { - super("Chicken Missile", new String[] - { - C.cYellow + "Right-Click" + C.cGray + " with Axe to " + C.cGreen + "Chicken Missile", - C.cGreen + "Chicken Missile" + C.cGray + " instantly recharges if you hit a player." - }); + super("Chicken Missile", new String[] { C.cYellow + "Right-Click" + C.cGray + " with Axe to " + C.cGreen + "Chicken Missile", C.cGreen + "Chicken Missile" + C.cGray + + " instantly recharges if you hit a player." }); } @EventHandler public void Missile(PlayerInteractEvent event) { if (event.isCancelled()) + { return; + } - if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) + if (!UtilEvent.isAction(event, ActionType.R)) + { return; + } if (UtilBlock.usable(event.getClickedBlock())) + { return; - - if (event.getPlayer().getItemInHand() == null) - return; - - if (!event.getPlayer().getItemInHand().getType().toString().contains("_AXE")) - return; + } Player player = event.getPlayer(); - + + if (!UtilItem.isAxe(player.getItemInHand())) + { + return; + } + if (isSuperActive(player)) + { return; + } - if (!Kit.HasKit(player)) + if (!hasPerk(player)) + { return; + } - if (!Recharge.Instance.use(player, GetName(), 7000, true, true)) + if (!Recharge.Instance.use(player, GetName(), COOLDOWN, true, true)) + { return; + } Manager.GetGame().CreatureAllowOverride = true; Chicken ent = player.getWorld().spawn(player.getEyeLocation().add(player.getLocation().getDirection()), Chicken.class); @@ -88,10 +107,10 @@ public class PerkChickenRocket extends SmashPerk ent.setAgeLock(true); UtilEnt.Vegetate(ent); Manager.GetGame().CreatureAllowOverride = false; - + _data.add(new ChickenMissileData(player, ent)); - - //Inform + + // Inform UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + ".")); } @@ -99,7 +118,9 @@ public class PerkChickenRocket extends SmashPerk public void Update(UpdateEvent event) { if (event.getType() != UpdateType.TICK) + { return; + } Iterator<ChickenMissileData> dataIterator = _data.iterator(); @@ -109,90 +130,99 @@ public class PerkChickenRocket extends SmashPerk data.Chicken.setVelocity(data.Direction); data.Chicken.getWorld().playSound(data.Chicken.getLocation(), Sound.CHICKEN_HURT, 0.3f, 1.5f); - - if (!UtilTime.elapsed(data.Time, 200)) + + if (!UtilTime.elapsed(data.Time, MIN_TIME)) { continue; } - + boolean detonate = false; - - if (UtilTime.elapsed(data.Time, 4000)) + + if (UtilTime.elapsed(data.Time, MAX_TIME)) { detonate = true; } else { - //Hit Entity - for (Entity ent : data.Player.getWorld().getEntities()) + List<Player> team = TeamSuperSmash.getTeam(Manager, data.Player, true); + // Hit Entity + for (Entity ent : UtilEnt.getInRadius(data.Chicken.getLocation(), HIT_BOX_RADIUS).keySet()) { if (ent instanceof Arrow) - if (((Arrow)ent).isOnGround()) - continue; - - if (ent.equals(data.Player)) - continue; - - if (ent.equals(data.Chicken)) - continue; - - if (UtilMath.offset(data.Chicken.getLocation(), ent.getLocation().add(0, 0.5, 0)) > 2) - continue; - - if (ent instanceof Player) - if (!Manager.GetGame().IsAlive((Player)ent)) + { + if (((Arrow) ent).isOnGround()) + { continue; - - //Recharge + } + } + + if (ent.equals(data.Player) || ent.equals(data.Chicken)) + { + continue; + } + + if (ent instanceof Player) + { + if (UtilPlayer.isSpectator(ent)) + { + continue; + } + + if(team.contains(ent)) + { + continue; + } + } + + // Recharge Recharge.Instance.useForce(data.Player, GetName(), -1); - + detonate = true; break; } - //Hit Block + // Hit Block if (!detonate && data.HasHitBlock()) { detonate = true; } } - + if (detonate) { - //Damage - for (Entity ent : data.Player.getWorld().getEntities()) + List<Player> team = TeamSuperSmash.getTeam(Manager, data.Player, true); + // Damage + for (LivingEntity ent : UtilEnt.getInRadius(data.Chicken.getLocation(), DAMAGE_RADIUS).keySet()) { - if (!(ent instanceof LivingEntity)) - continue; - if (ent.equals(data.Player)) + { continue; - - if (UtilMath.offset(data.Chicken.getLocation(), ent.getLocation().add(0, 0.5, 0)) > 3) - continue; + } if (ent instanceof Player) - if (!Manager.GetGame().IsAlive((Player)ent)) + { + if (UtilPlayer.isSpectator(ent)) + { continue; - - LivingEntity livingEnt = (LivingEntity)ent; - - //Damage Event - Manager.GetDamage().NewDamageEvent(livingEnt, data.Player, null, - DamageCause.PROJECTILE, 8, false, true, false, - data.Player.getName(), GetName()); - - UtilAction.velocity(livingEnt, UtilAlg.getTrajectory2d(data.Chicken, livingEnt), 1.6, true, 0.8, 0, 10, true); + } + if (team.contains(ent)) + { + continue; + } + } + + // Damage Event + Manager.GetDamage().NewDamageEvent(ent, data.Player, null, DamageCause.PROJECTILE, DAMAGE, false, true, false, data.Player.getName(), GetName()); + + UtilAction.velocity(ent, UtilAlg.getTrajectory2d(data.Chicken, ent), 1.6, true, 0.8, 0, 10, true); } - - //Effect - UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, data.Chicken.getLocation(), 0, 0, 0, 0, 1, - ViewDist.MAX, UtilServer.getPlayers()); + + // Effect + UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, data.Chicken.getLocation(), 0, 0, 0, 0, 1, ViewDist.MAX, UtilServer.getPlayers()); data.Chicken.getWorld().playSound(data.Chicken.getLocation(), Sound.EXPLODE, 2f, 1.2f); - - //Firework + + // Firework UtilFirework.playFirework(data.Chicken.getLocation().add(0, 0.6, 0), Type.BALL, Color.WHITE, false, false); - data.Chicken.remove(); dataIterator.remove(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkEggGun.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/chicken/PerkEggGun.java similarity index 60% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkEggGun.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/chicken/PerkEggGun.java index 727a2bfc2..df35fda05 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkEggGun.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/chicken/PerkEggGun.java @@ -1,13 +1,14 @@ -package nautilus.game.arcade.kit.perks; +package nautilus.game.arcade.game.games.smash.perks.chicken; import java.util.HashMap; +import java.util.Map; +import java.util.UUID; import org.bukkit.Sound; import org.bukkit.entity.Egg; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.block.Action; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.util.Vector; @@ -17,6 +18,9 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilItem; +import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; @@ -24,113 +28,141 @@ import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.SmashPerk; +import nautilus.game.arcade.game.games.smash.perks.SmashPerk; public class PerkEggGun extends SmashPerk { - private HashMap<Player, Long> _active = new HashMap<Player, Long>(); - - public PerkEggGun() + + private static final int COOLDOWN = 2500; + private static final int DURATION = 750; + private static final int DAMAGE = 1; + + private Map<UUID, Long> _active = new HashMap<>(); + + public PerkEggGun() { - super("Egg Blaster", new String[] - { - C.cYellow + "Hold Block" + C.cGray + " to use " + C.cGreen + "Egg Blaster" - }); + super("Egg Blaster", new String[] { C.cYellow + "Hold Block" + C.cGray + " to use " + C.cGreen + "Egg Blaster" }); } - - + @EventHandler public void Activate(PlayerInteractEvent event) { if (event.isCancelled()) + { return; - - if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) + } + + if (!UtilEvent.isAction(event, ActionType.R)) + { return; - + } + if (UtilBlock.usable(event.getClickedBlock())) + { return; - - if (!event.getPlayer().getItemInHand().getType().toString().contains("_SWORD")) - return; - + } + Player player = event.getPlayer(); + + if (!UtilItem.isSword(player.getItemInHand())) + { + return; + } if (isSuperActive(event.getPlayer())) + { return; - - if (!Kit.HasKit(player)) + } + + if (!hasPerk(player)) + { return; - - if (!Recharge.Instance.use(player, GetName(), 2500, true, true)) + } + + if (!Recharge.Instance.use(player, GetName(), COOLDOWN, true, true)) + { return; - - _active.put(player, System.currentTimeMillis()); + } + + _active.put(player.getUniqueId(), System.currentTimeMillis()); UtilPlayer.message(player, F.main("Skill", "You used " + F.skill(GetName()) + ".")); } - + @EventHandler - public void Update(UpdateEvent event) + public void Update(UpdateEvent event) { if (event.getType() != UpdateType.TICK) + { return; + } for (Player cur : UtilServer.getPlayers()) { + UUID key = cur.getUniqueId(); + if (!isSuperActive(cur)) { - if (!_active.containsKey(cur)) - continue; - - if (!cur.isBlocking()) + if (!_active.containsKey(key)) { - _active.remove(cur); continue; } - - if (UtilTime.elapsed(_active.get(cur), 750)) + + if (!cur.isBlocking()) { - _active.remove(cur); + _active.remove(key); + continue; + } + + if (UtilTime.elapsed(_active.get(key), DURATION)) + { + _active.remove(key); continue; } } - + Vector offset = cur.getLocation().getDirection(); + if (offset.getY() < 0) + { offset.setY(0); + } Egg egg = cur.getWorld().spawn(cur.getLocation().add(0, 0.5, 0).add(offset), Egg.class); - egg.setVelocity(cur.getLocation().getDirection().add(new Vector(0,0.2,0))); + egg.setVelocity(cur.getLocation().getDirection().add(new Vector(0, 0.2, 0))); egg.setShooter(cur); - - //Effect + + // Effect cur.getWorld().playSound(cur.getLocation(), Sound.CHICKEN_EGG_POP, 0.5f, 1f); } } - + @EventHandler public void EggHit(CustomDamageEvent event) { if (event.GetProjectile() == null) + { return; + } if (!(event.GetProjectile() instanceof Egg)) + { return; + } - if (event.GetDamage() >= 1) + if (event.GetDamage() >= DAMAGE) + { return; + } event.SetCancelled("Egg Blaster"); - - Egg egg = (Egg)event.GetProjectile(); - - //Damage Event - Manager.GetDamage().NewDamageEvent(event.GetDamageeEntity(), (LivingEntity)egg.getShooter(), egg, - DamageCause.PROJECTILE, 1, true, true, false, - UtilEnt.getName((LivingEntity)egg.getShooter()), GetName()); - + + Egg egg = (Egg) event.GetProjectile(); + + // Damage Event + Manager.GetDamage().NewDamageEvent(event.GetDamageeEntity(), (LivingEntity) egg.getShooter(), egg, DamageCause.PROJECTILE, DAMAGE, true, true, false, UtilEnt.getName((LivingEntity) egg + .getShooter()), GetName()); + UtilAction.zeroVelocity(event.GetDamageeEntity()); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFlap.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/chicken/PerkFlap.java similarity index 64% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFlap.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/chicken/PerkFlap.java index 490e1e79a..6464c22d1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFlap.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/chicken/PerkFlap.java @@ -1,8 +1,7 @@ -package nautilus.game.arcade.kit.perks; +package nautilus.game.arcade.game.games.smash.perks.chicken; import org.bukkit.GameMode; import org.bukkit.Sound; -import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerToggleFlightEvent; @@ -11,25 +10,28 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.SmashPerk; +import nautilus.game.arcade.game.games.smash.perks.SmashPerk; public class PerkFlap extends SmashPerk { + + private static final float MAX_ENERGY = 0.999F; + private static final float ENERGY_PER_TICK = 0.03F; + private static final float ENERGY_PER_FLAP = 0.17F; + private static final int COOLDOWN = 80; + private double _power; private boolean _control; - - public PerkFlap(double power, double heightLimit, boolean control) + + public PerkFlap(double power, double heightLimit, boolean control) { - super("Flap", new String[] - { - C.cYellow + "Tap Jump Twice" + C.cGray + " to " + C.cGreen + "Flap" - }); - + super("Flap", new String[] { C.cYellow + "Tap Jump Twice" + C.cGray + " to " + C.cGreen + "Flap" }); + _power = power; _control = control; } @@ -38,25 +40,31 @@ public class PerkFlap extends SmashPerk public void FlightHop(PlayerToggleFlightEvent event) { Player player = event.getPlayer(); - - if (Manager.isSpectator(player)) + + if (UtilPlayer.isSpectator(player)) + { return; + } - if (!Kit.HasKit(player)) + if (!hasPerk(player)) + { return; + } if (player.getGameMode() == GameMode.CREATIVE) + { return; + } event.setCancelled(true); player.setFlying(false); - - //Disable Flight + + // Disable Flight player.setAllowFlight(false); - + double power = 0.4 + 0.6 * (_power * player.getExp()); - - //Velocity + + // Velocity if (_control) { UtilAction.velocity(player, power, 0.2, 10, true); @@ -65,35 +73,43 @@ public class PerkFlap extends SmashPerk { UtilAction.velocity(player, player.getLocation().getDirection(), power, true, power, 0, 10, true); } - - //Sound - player.getWorld().playSound(player.getLocation(), Sound.BAT_TAKEOFF, (float)(0.3 + player.getExp()), (float)(Math.random()/2+1)); - - //Set Recharge - Recharge.Instance.use(player, GetName(), 80, false, false); - - //Energy + + // Sound + player.getWorld().playSound(player.getLocation(), Sound.BAT_TAKEOFF, (float) (0.3 + player.getExp()), (float) (Math.random() / 2 + 1)); + + // Set Recharge + Recharge.Instance.use(player, GetName(), COOLDOWN, false, false); + + // Energy if (!isSuperActive(player)) - player.setExp(Math.max(0f, player.getExp() - (1f/6f))); + { + player.setExp(Math.max(0f, player.getExp() - ENERGY_PER_FLAP)); + } } - + @EventHandler public void FlightUpdate(UpdateEvent event) { if (event.getType() != UpdateType.TICK) + { return; - + } + for (Player player : UtilServer.getPlayers()) { if (player.getGameMode() == GameMode.CREATIVE) - continue; - - if (!Kit.HasKit(player)) - continue; - - if (UtilEnt.isGrounded(player) || UtilBlock.solid(player.getLocation().getBlock().getRelative(BlockFace.DOWN))) { - player.setExp(Math.min(0.9999f, player.getExp() + 0.03f)); + continue; + } + + if (!hasPerk(player)) + { + continue; + } + + if (UtilEnt.isGrounded(player) || UtilBlock.solid(player.getLocation().subtract(0, 2, 0).getBlock())) + { + player.setExp(Math.min(MAX_ENERGY, player.getExp() + ENERGY_PER_TICK)); player.setAllowFlight(true); } else if (Recharge.Instance.usable(player, GetName()) && player.getExp() > 0) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/chicken/SmashChicken.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/chicken/SmashChicken.java new file mode 100644 index 000000000..605499efc --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/chicken/SmashChicken.java @@ -0,0 +1,30 @@ +package nautilus.game.arcade.game.games.smash.perks.chicken; + +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; + +import nautilus.game.arcade.game.games.smash.perks.SmashUltimate; + +public class SmashChicken extends SmashUltimate +{ + + private static final int DURATION = 20000; + + public SmashChicken() + { + super("Aerial Gunner", new String[] {}, Sound.CHICKEN_IDLE, DURATION); + } + + /** + * See {@link PerkEggGun} for smash code. + */ + @Override + public void activate(Player player) + { + super.activate(player); + + player.getInventory().remove(Material.IRON_SWORD); + player.getInventory().remove(Material.IRON_AXE); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/DataCowCharge.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/cow/DataCowCharge.java similarity index 92% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/DataCowCharge.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/cow/DataCowCharge.java index a03be6065..b57c15d2d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/DataCowCharge.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/cow/DataCowCharge.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.smash.perks; +package nautilus.game.arcade.game.games.smash.perks.cow; import org.bukkit.Location; import org.bukkit.entity.Cow; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/DataCowMilkSpiral.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/cow/DataCowMilkSpiral.java similarity index 97% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/DataCowMilkSpiral.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/cow/DataCowMilkSpiral.java index f4bb60f93..6026c0f8d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/DataCowMilkSpiral.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/cow/DataCowMilkSpiral.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.smash.perks; +package nautilus.game.arcade.game.games.smash.perks.cow; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; @@ -12,7 +12,6 @@ import mineplex.core.common.util.UtilParticle.ViewDist; import org.bukkit.Location; import org.bukkit.Sound; -import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.util.Vector; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/PerkCowAngryHerd.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/cow/PerkCowAngryHerd.java similarity index 63% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/PerkCowAngryHerd.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/cow/PerkCowAngryHerd.java index d398bba74..18ea1df4e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/PerkCowAngryHerd.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/cow/PerkCowAngryHerd.java @@ -1,7 +1,8 @@ -package nautilus.game.arcade.game.games.smash.perks; +package nautilus.game.arcade.game.games.smash.perks.cow; import java.util.ArrayList; import java.util.Iterator; +import java.util.List; import org.bukkit.Location; import org.bukkit.Sound; @@ -9,7 +10,6 @@ import org.bukkit.entity.Cow; import org.bukkit.entity.MushroomCow; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.block.Action; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.util.Vector; @@ -19,135 +19,149 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.disguise.disguises.DisguiseBase; -import mineplex.core.disguise.disguises.DisguiseMooshroom; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.kit.SmashPerk; +import nautilus.game.arcade.game.games.smash.perks.SmashPerk; -public class PerkCowAngryHerd extends SmashPerk +public class PerkCowAngryHerd extends SmashPerk { - private ArrayList<DataCowCharge> _active = new ArrayList<DataCowCharge>(); - public PerkCowAngryHerd() + private static final int COOLDOWN_NORMAL = 13000; + private static final int COOLDOWN_SMASH = 6000; + private static final int MAX_TIME = 2500; + private static final int STUCK_TIME = 300; + private static final int FORCE_MOVE = 350; + private static final float HIT_BOX_RADIUS = 2.2F; + private static final int HIT_FREQUENCY = 600; + private static final int DAMAGE = 5; + + private List<DataCowCharge> _active = new ArrayList<>(); + + public PerkCowAngryHerd() { - super("Angry Herd", new String[] - { - C.cYellow + "Right-Click" + C.cGray + " with Axe to use " + C.cGreen + "Angry Herd" - }); + super("Angry Herd", new String[] { C.cYellow + "Right-Click" + C.cGray + " with Axe to use " + C.cGreen + "Angry Herd" }); } - @EventHandler public void shoot(PlayerInteractEvent event) { if (event.isCancelled()) + { return; + } - if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) + if (!UtilEvent.isAction(event, ActionType.R)) + { return; + } if (UtilBlock.usable(event.getClickedBlock())) + { return; - - if (event.getPlayer().getItemInHand() == null) - return; - - if (!event.getPlayer().getItemInHand().getType().toString().contains("_AXE")) - return; + } Player player = event.getPlayer(); - - if (!Kit.HasKit(player)) - return; - if (!Recharge.Instance.use(player, GetName(), isSuperActive(player) ? 6000 : 12000, true, true)) + if (!UtilItem.isAxe(player.getItemInHand())) + { return; + } + + if (!hasPerk(player)) + { + return; + } + + if (!Recharge.Instance.use(player, GetName(), isSuperActive(player) ? COOLDOWN_SMASH : COOLDOWN_NORMAL, true, true)) + { + return; + } event.setCancelled(true); - - for (double i=-2 ; i<3 ; i++) + + for (double i = -2; i < 3; i++) { Vector dir = player.getLocation().getDirection(); dir.setY(0); dir.normalize(); - + Location loc = player.getLocation(); - + loc.add(dir); - loc.add(UtilAlg.getLeft(dir).multiply(i*1.5)); - + loc.add(UtilAlg.getLeft(dir).multiply(i * 1.5)); + Manager.GetGame().CreatureAllowOverride = true; Class<? extends Cow> clazz = isSuperActive(player) ? MushroomCow.class : Cow.class; Cow cow = player.getWorld().spawn(loc, clazz); Manager.GetGame().CreatureAllowOverride = false; - + _active.add(new DataCowCharge(player, cow)); } - //Sound + // Sound player.getWorld().playSound(player.getLocation(), Sound.COW_IDLE, 2f, 0.6f); - - //Inform + + // Inform UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + ".")); } - + @EventHandler public void update(UpdateEvent event) { if (event.getType() != UpdateType.TICK) return; - + Iterator<DataCowCharge> activeIter = _active.iterator(); - + while (activeIter.hasNext()) { DataCowCharge data = activeIter.next(); - - //Expire - if (UtilTime.elapsed(data.Time, 3000)) + + // Expire + if (UtilTime.elapsed(data.Time, MAX_TIME)) { if (data.Cow.isValid()) { data.Cow.remove(); - UtilParticle.PlayParticle(ParticleType.EXPLODE, data.Cow.getLocation().add(0, 1, 0), 0, 0, 0, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers()); + UtilParticle.PlayParticleToAll(ParticleType.EXPLODE, data.Cow.getLocation().add(0, 1, 0), 0, 0, 0, 0, 1, ViewDist.NORMAL); } activeIter.remove(); continue; } - - //Set Moved + + // Set Moved if (UtilMath.offset(data.Cow.getLocation(), data.LastLoc) > 1) { - data.LastLoc = data.Cow.getLocation(); data.LastMoveTime = System.currentTimeMillis(); } - - //Stuck Remove - if (UtilTime.elapsed(data.LastMoveTime, 1000)) + + // Stuck Remove + if (UtilTime.elapsed(data.LastMoveTime, STUCK_TIME)) { if (data.Cow.isValid()) { data.Cow.remove(); - UtilParticle.PlayParticle(ParticleType.EXPLODE, data.Cow.getLocation().add(0, 1, 0), 0, 0, 0, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers()); + UtilParticle.PlayParticleToAll(ParticleType.EXPLODE, data.Cow.getLocation().add(0, 1, 0), 0, 0, 0, 0, 1, ViewDist.NORMAL); } - + activeIter.remove(); continue; } - //Gravity + // Gravity if (UtilEnt.isGrounded(data.Cow)) { data.Direction.setY(-0.1); @@ -156,35 +170,44 @@ public class PerkCowAngryHerd extends SmashPerk { data.Direction.setY(Math.max(-1, data.Direction.getY() - 0.03)); } - - //Move - if (UtilTime.elapsed(data.LastMoveTime, 350) && UtilEnt.isGrounded(data.Cow)) - data.Cow.setVelocity(data.Direction.clone().add(new Vector(0,0.75,0))); + + // Move + if (UtilTime.elapsed(data.LastMoveTime, FORCE_MOVE) && UtilEnt.isGrounded(data.Cow)) + { + data.Cow.setVelocity(data.Direction.clone().add(new Vector(0, 0.75, 0))); + } else + { data.Cow.setVelocity(data.Direction); - + } + if (Math.random() > 0.99) + { data.Cow.getWorld().playSound(data.Cow.getLocation(), Sound.COW_IDLE, 1f, 1f); - + } + if (Math.random() > 0.97) + { data.Cow.getWorld().playSound(data.Cow.getLocation(), Sound.COW_WALK, 1f, 1.2f); + } - //Hit + // Hit for (Player player : Manager.GetGame().GetPlayers(true)) { if (player.equals(data.Player)) - continue; - - if (UtilMath.offset(player, data.Cow) < 2.2) { - if (Recharge.Instance.use(player, "Hit by " + data.Player.getName(), 600, false, false)) + continue; + } + + if (UtilMath.offset(player, data.Cow) < HIT_BOX_RADIUS) + { + if (Recharge.Instance.use(player, "Hit by " + data.Player.getName(), HIT_FREQUENCY, false, false)) { // Damage Event - Manager.GetDamage().NewDamageEvent(player, data.Player, null, data.Cow.getLocation(), DamageCause.CUSTOM, - 5, true, true, false, UtilEnt.getName(data.Player), GetName()); - - UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, data.Cow.getLocation().add(0, 1, 0), 1f, 1f, 1f, 0, 12, ViewDist.LONG, UtilServer.getPlayers()); - + Manager.GetDamage().NewDamageEvent(player, data.Player, null, data.Cow.getLocation(), DamageCause.CUSTOM, DAMAGE, true, true, false, UtilEnt.getName(data.Player), GetName()); + + UtilParticle.PlayParticleToAll(ParticleType.LARGE_EXPLODE, data.Cow.getLocation().add(0, 1, 0), 1f, 1f, 1f, 0, 12, ViewDist.LONG); + data.Cow.getWorld().playSound(data.Cow.getLocation(), Sound.ZOMBIE_WOOD, 0.75f, 0.8f); data.Cow.getWorld().playSound(data.Cow.getLocation(), Sound.COW_HURT, 1.5f, 0.75f); } @@ -192,21 +215,15 @@ public class PerkCowAngryHerd extends SmashPerk } } } - + @EventHandler public void Knockback(CustomDamageEvent event) { if (event.GetReason() == null || !event.GetReason().contains(GetName())) + { return; + } event.AddKnockback(GetName(), 1.25); } - - @Override - public boolean isSuperActive(Player player) - { - DisguiseBase disguise = Manager.GetDisguise().getDisguise(player); - - return disguise != null && disguise instanceof DisguiseMooshroom; - } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/PerkCowMilkSpiral.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/cow/PerkCowMilkSpiral.java similarity index 56% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/PerkCowMilkSpiral.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/cow/PerkCowMilkSpiral.java index 0bea3c61a..e909decf2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/PerkCowMilkSpiral.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/cow/PerkCowMilkSpiral.java @@ -1,111 +1,123 @@ -package nautilus.game.arcade.game.games.smash.perks; +package nautilus.game.arcade.game.games.smash.perks.cow; -import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; +import java.util.Set; import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.block.Action; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.player.PlayerInteractEvent; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.disguise.disguises.DisguiseBase; -import mineplex.core.disguise.disguises.DisguiseMooshroom; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import nautilus.game.arcade.kit.SmashPerk; +import nautilus.game.arcade.game.games.smash.perks.SmashPerk; public class PerkCowMilkSpiral extends SmashPerk { - private HashMap<Player, DataCowMilkSpiral> _active = new HashMap<Player, DataCowMilkSpiral>(); - - public PerkCowMilkSpiral() + + private static final int COOLDOWN_NORMAL = 11000; + private static final int COOLDOWN_SMASH = 6000; + private static final int HIT_BOX_RADIUS = 2; + private static final int DAMAGE = 6; + + private Set<DataCowMilkSpiral> _active = new HashSet<>(); + + public PerkCowMilkSpiral() { - super("Milk Spiral", new String[] - { - C.cYellow + "Right Click" + C.cGray + " with Spade to " + C.cGreen + "Milk Spiral", - C.cGray + "Crouch to cancel movement for Milk Spiral" - }); + super("Milk Spiral", new String[] { C.cYellow + "Right Click" + C.cGray + " with Spade to " + C.cGreen + "Milk Spiral", C.cGray + "Crouch to cancel movement for Milk Spiral" }); } - + @EventHandler public void activate(PlayerInteractEvent event) { if (event.isCancelled()) + { return; - - if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) + } + + if (!UtilEvent.isAction(event, ActionType.R)) + { return; - + } + if (UtilBlock.usable(event.getClickedBlock())) + { return; - - if (!event.getPlayer().getItemInHand().getType().toString().contains("_SPADE")) - return; - + } + Player player = event.getPlayer(); - - if (!Kit.HasKit(player)) + + if (!UtilItem.isSpade(player.getItemInHand())) + { return; - - if (!Recharge.Instance.use(player, GetName(), isSuperActive(player) ? 6000 : 12000, true, true)) + } + + if (!hasPerk(player)) + { return; - - _active.put(player, new DataCowMilkSpiral(player, isSuperActive(player))); - - //Inform + } + + if (!Recharge.Instance.use(player, GetName(), isSuperActive(player) ? COOLDOWN_SMASH : COOLDOWN_NORMAL, true, true)) + { + return; + } + + _active.add(new DataCowMilkSpiral(player, isSuperActive(player))); + + // Inform UtilPlayer.message(player, F.main("Skill", "You used " + F.skill(GetName()) + ".")); } - + @EventHandler - public void update(UpdateEvent event) + public void update(UpdateEvent event) { if (event.getType() != UpdateType.TICK) + { return; + } + + Iterator<DataCowMilkSpiral> activeIter = _active.iterator(); - Iterator<DataCowMilkSpiral> activeIter = _active.values().iterator(); - while (activeIter.hasNext()) { DataCowMilkSpiral data = activeIter.next(); - + if (data.update()) + { activeIter.remove(); - + } + for (Player player : Manager.GetGame().GetPlayers(true)) { if (player.equals(data.Player)) - continue; - - if (UtilMath.offset(player.getLocation().add(0, 1, 0), data.Spiral) < 2) { - Manager.GetDamage().NewDamageEvent(player, data.Player, null, - DamageCause.CUSTOM, 6, true, false, false, - player.getName(), GetName()); - - UtilParticle.PlayParticle(isSuperActive(player) ? ParticleType.RED_DUST : ParticleType.FIREWORKS_SPARK, player.getLocation().add(0, 1, 0), 0.2f, 0.2f, 0.2f, 0.3f, 30, ViewDist.LONG, UtilServer.getPlayers()); + continue; + } + + if (UtilMath.offset(player.getLocation().add(0, 1, 0), data.Spiral) < HIT_BOX_RADIUS) + { + Manager.GetDamage().NewDamageEvent(player, data.Player, null, DamageCause.CUSTOM, DAMAGE, true, false, false, player.getName(), GetName()); + + UtilParticle.PlayParticle(isSuperActive(player) ? ParticleType.RED_DUST : ParticleType.FIREWORKS_SPARK, player.getLocation().add(0, 1, 0), 0.2f, 0.2f, 0.2f, 0.3f, 30, + ViewDist.LONG, UtilServer.getPlayers()); player.getWorld().playSound(player.getLocation(), Sound.SPLASH, 0.25f, 2f); } } } } - - @Override - public boolean isSuperActive(Player player) - { - DisguiseBase disguise = Manager.GetDisguise().getDisguise(player); - - return disguise != null && disguise instanceof DisguiseMooshroom; - } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/PerkCowStampede.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/cow/PerkCowStampede.java similarity index 57% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/PerkCowStampede.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/cow/PerkCowStampede.java index 287ba285e..5b7a16647 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/PerkCowStampede.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/cow/PerkCowStampede.java @@ -1,28 +1,10 @@ -package nautilus.game.arcade.game.games.smash.perks; +package nautilus.game.arcade.game.games.smash.perks.cow; -import java.util.WeakHashMap; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.disguise.disguises.DisguiseBase; -import mineplex.core.disguise.disguises.DisguiseMooshroom; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; -import mineplex.minecraft.game.classcombat.Skill.SkillFactory; -import mineplex.minecraft.game.classcombat.Skill.ISkill.SkillType; -import mineplex.minecraft.game.classcombat.Skill.event.SkillEvent; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.kit.SmashPerk; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; import org.bukkit.Sound; -import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -31,74 +13,95 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.potion.PotionEffectType; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; +import mineplex.minecraft.game.classcombat.Skill.event.SkillEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.games.smash.perks.SmashPerk; + public class PerkCowStampede extends SmashPerk { - private WeakHashMap<Player, Long> _sprintTime = new WeakHashMap<Player, Long>(); - private WeakHashMap<Player, Integer> _sprintStr = new WeakHashMap<Player, Integer>(); - - public PerkCowStampede() + private Map<UUID, Long> _sprintTime = new HashMap<>(); + private Map<UUID, Integer> _sprintStr = new HashMap<>(); + + public PerkCowStampede() { - super("Stampede", new String[] - { - C.cGray + "Build up Speed Levels as you sprint.", - C.cGray + "+1 damage for each Speed Level.", - }); - } + super("Stampede", new String[] { C.cGray + "Build up Speed Levels as you sprint.", C.cGray + "+1 damage for each Speed Level.", }); + } @EventHandler public void update(UpdateEvent event) { if (event.getType() != UpdateType.FASTER) + { return; + } for (Player cur : UtilServer.getPlayers()) { - if (!Kit.HasKit(cur)) - continue; - - //Active - Check for Disable - if (_sprintTime.containsKey(cur)) + if (!hasPerk(cur)) { - //Stopped + continue; + } + + UUID key = cur.getUniqueId(); + + // Active - Check for Disable + if (_sprintTime.containsKey(key)) + { + // Stopped if (!cur.isSprinting() || cur.getLocation().getBlock().isLiquid()) { - _sprintTime.remove(cur); - _sprintStr.remove(cur); + _sprintTime.remove(key); + _sprintStr.remove(key); cur.removePotionEffect(PotionEffectType.SPEED); continue; } - long time = _sprintTime.get(cur); - int str = _sprintStr.get(cur); + long time = _sprintTime.get(key); + int str = _sprintStr.get(key); - //Apply Speed + // Apply Speed if (str > 0) - Manager.GetCondition().Factory().Speed(GetName(), cur, cur, 1.9, !isSuperActive(cur) ? str-1 : str, false, true, true); + { + Manager.GetCondition().Factory().Speed(GetName(), cur, cur, 1.9, !isSuperActive(cur) ? str - 1 : str, false, true, true); + } - //Upgrade Speed + // Upgrade Speed if (!UtilTime.elapsed(time, 3000)) + { continue; + } - _sprintTime.put(cur, System.currentTimeMillis()); + _sprintTime.put(key, System.currentTimeMillis()); if (str < 3) - { - _sprintStr.put(cur, str+1); + { + _sprintStr.put(key, str + 1); - //Effect + // Effect cur.getWorld().playSound(cur.getLocation(), Sound.COW_HURT, 2f, 0.75f + 0.25f * str); } - - //Event + + // Event UtilServer.getServer().getPluginManager().callEvent(new SkillEvent(cur, GetName(), ClassType.Brute)); } else if (cur.isSprinting() || !cur.getLocation().getBlock().isLiquid()) { - //Start Timer - if (!_sprintTime.containsKey(cur)) + // Start Timer + if (!_sprintTime.containsKey(key)) { - _sprintTime.put(cur, System.currentTimeMillis()); - _sprintStr.put(cur, 0); + _sprintTime.put(key, System.currentTimeMillis()); + _sprintStr.put(key, 0); } } } @@ -108,16 +111,26 @@ public class PerkCowStampede extends SmashPerk public void particle(UpdateEvent event) { if (event.getType() != UpdateType.TICK) - return; - - for (Player ent : _sprintStr.keySet()) { - if (_sprintStr.get(ent) <= 0) + return; + } + + for (UUID key : _sprintStr.keySet()) + { + if (_sprintStr.get(key) <= 0) + { continue; - - UtilParticle.PlayParticle(isSuperActive(ent) ? ParticleType.RED_DUST : ParticleType.CRIT, ent.getLocation(), - (float)(Math.random() - 0.5), 0.2f + (float)Math.random(), (float)(Math.random() - 0.5), 0, _sprintStr.get(ent) * 2, - ViewDist.NORMAL, UtilServer.getPlayers()); + } + + Player player = UtilPlayer.searchExact(key); + + if (player == null) + { + continue; + } + + UtilParticle.PlayParticle(isSuperActive(player) ? ParticleType.RED_DUST : ParticleType.CRIT, player.getLocation(), (float) (Math.random() - 0.5), 0.2f + (float) Math.random(), + (float) (Math.random() - 0.5), 0, _sprintStr.get(key) * 2, ViewDist.NORMAL, UtilServer.getPlayers()); } } @@ -125,73 +138,89 @@ public class PerkCowStampede extends SmashPerk public void damage(CustomDamageEvent event) { if (event.IsCancelled()) + { return; - + } + if (event.GetCause() != DamageCause.ENTITY_ATTACK) + { return; + } Player damager = event.GetDamagerPlayer(false); - if (damager == null) return; - - if (!_sprintStr.containsKey(damager)) + + if (damager == null) + { return; + } + + UUID key = damager.getUniqueId(); - if (_sprintStr.get(damager) == 0) + if (!_sprintStr.containsKey(key)) + { return; + } + + if (_sprintStr.get(key) == 0) + { + return; + } LivingEntity damagee = event.GetDamageeEntity(); - if (damagee == null) return; - //Remove - _sprintTime.remove(damager); - int str = _sprintStr.remove(damager); + if (damagee == null) + { + return; + } + + // Remove + _sprintTime.remove(key); + int str = _sprintStr.remove(key); damager.removePotionEffect(PotionEffectType.SPEED); - //Damage + // Damage event.AddMod(damager.getName(), GetName(), str, true); event.AddKnockback(GetName(), 1 + (0.1 * str)); - //Inform + // Inform UtilPlayer.message(damagee, F.main("Game", F.name(damager.getName()) + " hit you with " + F.skill(GetName()) + ".")); - //Effect - damager.getWorld().playSound(damager.getLocation(), Sound.ZOMBIE_WOOD, 1f, 2f); - damager.getWorld().playSound(damager.getLocation(), Sound.COW_HURT, 2f, 2f); - - //Event + // Effect + damager.getWorld().playSound(damager.getLocation(), Sound.ZOMBIE_WOOD, 1f, 2f); + damager.getWorld().playSound(damager.getLocation(), Sound.COW_HURT, 2f, 2f); + + // Event UtilServer.getServer().getPluginManager().callEvent(new SkillEvent(damager, GetName(), ClassType.Brute, damagee)); } - + @EventHandler(priority = EventPriority.HIGH) public void damageCancel(CustomDamageEvent event) { if (event.IsCancelled()) + { return; + } Player damagee = event.GetDamageePlayer(); - if (damagee == null) return; + + if (damagee == null) + { + return; + } clean(damagee); Manager.GetCondition().EndCondition(damagee, null, GetName()); } @EventHandler - public void quit(PlayerQuitEvent event) + public void quit(PlayerQuitEvent event) { clean(event.getPlayer()); } - - public void clean(Player player) + + public void clean(Player player) { - _sprintTime.remove(player); - _sprintStr.remove(player); - } - - @Override - public boolean isSuperActive(Player player) - { - DisguiseBase disguise = Manager.GetDisguise().getDisguise(player); - - return disguise != null && disguise instanceof DisguiseMooshroom; + _sprintTime.remove(player.getUniqueId()); + _sprintStr.remove(player.getUniqueId()); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/cow/SmashCow.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/cow/SmashCow.java new file mode 100644 index 000000000..d3aaa527d --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/cow/SmashCow.java @@ -0,0 +1,73 @@ +package nautilus.game.arcade.game.games.smash.perks.cow; + +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +import mineplex.core.disguise.disguises.DisguiseCow; +import mineplex.core.disguise.disguises.DisguiseMooshroom; +import mineplex.core.recharge.Recharge; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.games.smash.perks.SmashKit; +import nautilus.game.arcade.game.games.smash.perks.SmashUltimate; + +public class SmashCow extends SmashUltimate +{ + + private static final int DURATION = 30000; + private static final int DAMAGE_BUFF = 1; + private static final int HEALTH = 30; + + public SmashCow() + { + super("Mooshroom Madness", new String[] {}, Sound.COW_IDLE, DURATION); + } + + @Override + public void activate(Player player) + { + super.activate(player); + + SmashKit kit = (SmashKit) Kit; + + kit.disguise(player, DisguiseMooshroom.class); + + // Health + player.setMaxHealth(HEALTH); + player.setHealth(HEALTH); + + // Sound + player.getWorld().playSound(player.getLocation(), Sound.COW_HURT, 5f, 0.25f); + + // Recharges + Recharge.Instance.recharge(player, "Angry Herd"); + Recharge.Instance.recharge(player, "Milk Spiral"); + } + + @Override + public void cancel(Player player) + { + super.cancel(player); + + SmashKit kit = (SmashKit) Kit; + kit.disguise(player, DisguiseCow.class); + + player.setMaxHealth(20); + } + + @EventHandler + public void damageBuff(CustomDamageEvent event) + { + Player player = event.GetDamagerPlayer(true); + + if (player == null) + { + return; + } + + if (isUsingUltimate(player)) + { + event.AddMod(player.getName(), GetName(), DAMAGE_BUFF, false); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkCreeperElectricity.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/creeper/PerkCreeperElectricity.java similarity index 65% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkCreeperElectricity.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/creeper/PerkCreeperElectricity.java index 0b6ae7d62..a92cb53b5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkCreeperElectricity.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/creeper/PerkCreeperElectricity.java @@ -1,7 +1,9 @@ -package nautilus.game.arcade.kit.perks; +package nautilus.game.arcade.game.games.smash.perks.creeper; import java.util.HashMap; import java.util.Iterator; +import java.util.Map; +import java.util.UUID; import org.bukkit.Sound; import org.bukkit.entity.Player; @@ -22,57 +24,77 @@ import nautilus.game.arcade.kit.Perk; public class PerkCreeperElectricity extends Perk { - private HashMap<Player, Long> _active = new HashMap<Player, Long>(); - public PerkCreeperElectricity() - { - super("Lightning Shield", new String[] - { - "When hit by a non-melee attack, you gain " + C.cGreen + "Lightning Shield" - }); - } + private static final int DURATION = 2000; + private static final int SHOCK = 1; + private static final int DAMAGE = 4; + private static final float KNOCKBACK_MAGNITUDE = 2.5F; + + private Map<UUID, Long> _active = new HashMap<>(); + public PerkCreeperElectricity() + { + super("Lightning Shield", new String[] { "When hit by a non-melee attack, you gain " + C.cGreen + "Lightning Shield" }); + } @EventHandler public void Shield(CustomDamageEvent event) { if (event.IsCancelled()) + { return; - - if (event.GetCause() == DamageCause.ENTITY_ATTACK || event.GetCause() == DamageCause.FIRE_TICK || event.GetCause() == DamageCause.STARVATION) + } + + if (event.GetCause() == DamageCause.ENTITY_ATTACK || event.GetCause() == DamageCause.FIRE_TICK || event.GetCause() == DamageCause.STARVATION || event.GetCause() == DamageCause.POISON) + { return; - + } + Player damagee = event.GetDamageePlayer(); - if (damagee == null) return; - - if (!Kit.HasKit(damagee)) + + if (damagee == null) + { return; + } - _active.put(damagee, System.currentTimeMillis()); + if (!hasPerk(damagee)) + { + return; + } + _active.put(damagee.getUniqueId(), System.currentTimeMillis()); + SetPowered(damagee, true); - + Manager.GetCondition().Factory().Speed(GetName(), damagee, damagee, 4, 1, false, false, false); - - //Sound + + // Sound damagee.getWorld().playSound(damagee.getLocation(), Sound.CREEPER_HISS, 3f, 1.25f); - - //Inform + + // Inform UtilPlayer.message(damagee, F.main("Skill", "You gained " + F.skill(GetName()) + ".")); } - @EventHandler - public void Update(UpdateEvent event) + public void Update(UpdateEvent event) { if (event.getType() != UpdateType.TICK) + { return; - - Iterator<Player> shieldIterator = _active.keySet().iterator(); + } + + Iterator<UUID> shieldIterator = _active.keySet().iterator(); while (shieldIterator.hasNext()) { - Player player = shieldIterator.next(); + UUID key = shieldIterator.next(); + Player player = UtilPlayer.searchExact(key); + + if (player == null) + { + shieldIterator.remove(); + continue; + } if (!IsPowered(player)) { @@ -80,14 +102,14 @@ public class PerkCreeperElectricity extends Perk SetPowered(player, false); continue; } - - if (UtilTime.elapsed(_active.get(player), 2000)) + + if (UtilTime.elapsed(_active.get(key), DURATION)) { shieldIterator.remove(); SetPowered(player, false); - - //Sound + + // Sound player.getWorld().playSound(player.getLocation(), Sound.CREEPER_HISS, 3f, 0.75f); } } @@ -97,64 +119,87 @@ public class PerkCreeperElectricity extends Perk public void Damage(CustomDamageEvent event) { if (event.IsCancelled()) + { return; + } if (event.GetCause() != DamageCause.ENTITY_ATTACK) + { return; + } Player damagee = event.GetDamageePlayer(); - if (damagee == null) return; - if (!Kit.HasKit(damagee)) + if (damagee == null) + { return; + } + + if (!hasPerk(damagee)) + { + return; + } if (!IsPowered(damagee)) + { return; + } event.SetCancelled("Lightning Shield"); - - //Inform + + // Inform UtilPlayer.message(damagee, F.main("Skill", "You hit " + F.elem(UtilEnt.getName(event.GetDamagerPlayer(false))) + " with " + F.skill(GetName()) + ".")); - - //Elec + + // Elec damagee.getWorld().strikeLightningEffect(damagee.getLocation()); - Manager.GetCondition().Factory().Shock(GetName(), event.GetDamagerEntity(false), event.GetDamageeEntity(), 1, false, false); - + Manager.GetCondition().Factory().Shock(GetName(), event.GetDamagerEntity(false), event.GetDamageeEntity(), SHOCK, false, false); + SetPowered(damagee, false); - - //Damage Event - Manager.GetDamage().NewDamageEvent(event.GetDamagerEntity(false), damagee, null, - DamageCause.LIGHTNING, 4, true, true, false, - damagee.getName(), GetName()); + + // Damage Event + Manager.GetDamage().NewDamageEvent(event.GetDamagerEntity(false), damagee, null, DamageCause.LIGHTNING, DAMAGE, true, true, false, damagee.getName(), GetName()); } - + public DisguiseCreeper GetDisguise(Player player) { - DisguiseBase disguise = Manager.GetDisguise().getDisguise(player); + DisguiseBase disguise = Manager.GetDisguise().getActiveDisguise(player); + if (disguise == null) + { return null; + } if (!(disguise instanceof DisguiseCreeper)) + { return null; + } - return (DisguiseCreeper)disguise; + return (DisguiseCreeper) disguise; } - + public void SetPowered(Player player, boolean powered) { DisguiseCreeper creeper = GetDisguise(player); - if (creeper == null) return; + + if (creeper == null) + { + return; + } creeper.SetPowered(powered); - + Manager.GetDisguise().updateDisguise(creeper); } - + public boolean IsPowered(Player player) { DisguiseCreeper creeper = GetDisguise(player); - if (creeper == null) return false; - + + if (creeper == null) + { + return false; + } + return creeper.IsPowered(); } @@ -162,8 +207,10 @@ public class PerkCreeperElectricity extends Perk public void Knockback(CustomDamageEvent event) { if (event.GetReason() == null || !event.GetReason().contains(GetName())) + { return; - - event.AddKnockback(GetName(), 2.5); + } + + event.AddKnockback(GetName(), KNOCKBACK_MAGNITUDE); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkCreeperExplode.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/creeper/PerkCreeperExplode.java similarity index 50% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkCreeperExplode.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/creeper/PerkCreeperExplode.java index fee25dd52..e07b996fa 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkCreeperExplode.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/creeper/PerkCreeperExplode.java @@ -1,174 +1,205 @@ -package nautilus.game.arcade.kit.perks; +package nautilus.game.arcade.game.games.smash.perks.creeper; import java.util.Collection; import java.util.HashMap; -import java.util.HashSet; import java.util.Iterator; +import java.util.Map; +import java.util.UUID; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.player.PlayerInteractEvent; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguiseCreeper; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.kit.SmashPerk; - -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.block.Block; -import org.bukkit.entity.Entity; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.block.Action; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.util.Vector; +import nautilus.game.arcade.game.games.smash.perks.SmashPerk; public class PerkCreeperExplode extends SmashPerk { - private HashMap<Player, Long> _active = new HashMap<Player, Long>(); - private HashSet<Player> _super = new HashSet<Player>(); - - public PerkCreeperExplode() + + private static final int COOLDOWN = 8000; + private static final int WARMUP = 1500; + private static final int RADIUS_NORMAL = 8; + private static final int RADIUS_SMASH = 24; + private static final int DAMAGE_NORMAL = 20; + private static final int DAMAGE_SMASH = 30; + private static final int SPAWN_REMOVAL_RADIUS = 14; + private static final float KNOCKBACK_MAGNITUDE = 2.5F; + + private Map<UUID, Long> _active = new HashMap<>(); + + public PerkCreeperExplode() { - super("Explode", new String[] - { - C.cYellow + "Right-Click" + C.cGray + " with Shovel use " + C.cGreen + "Explosive Leap" - }); + super("Explode", new String[] { C.cYellow + "Right-Click" + C.cGray + " with Shovel use " + C.cGreen + "Explosive Leap" }); } @EventHandler public void Activate(PlayerInteractEvent event) { if (event.isCancelled()) + { return; + } - if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) + if (!UtilEvent.isAction(event, ActionType.R)) + { return; + } if (UtilBlock.usable(event.getClickedBlock())) + { return; - - if (!event.getPlayer().getItemInHand().getType().toString().contains("_SPADE")) - return; + } Player player = event.getPlayer(); - + + if (!UtilItem.isSpade(player.getItemInHand())) + { + return; + } + + if (!hasPerk(player)) + { + return; + } + if (isSuperActive(player)) + { return; + } - if (!Kit.HasKit(player)) + if (!Recharge.Instance.use(player, GetName(), COOLDOWN, true, true)) + { return; + } - if (!Recharge.Instance.use(player, GetName(), 8000, true, true)) - return; - - _active.put(player, System.currentTimeMillis()); + _active.put(player.getUniqueId(), System.currentTimeMillis()); IncreaseSize(player); UtilPlayer.message(player, F.main("Skill", "You are charging " + F.skill(GetName()) + ".")); } - @Override - public void addSuperCustom(Player player) - { - _active.put(player, System.currentTimeMillis()); - _super.add(player); - - IncreaseSize(player); - } - @EventHandler - public void Update(UpdateEvent event) + public void Update(UpdateEvent event) { if (event.getType() != UpdateType.TICK) + { return; + } - Iterator<Player> chargeIterator = _active.keySet().iterator(); + Iterator<UUID> chargeIterator = _active.keySet().iterator(); while (chargeIterator.hasNext()) { - Player player = chargeIterator.next(); + UUID key = chargeIterator.next(); + Player player = UtilPlayer.searchExact(key); - double elapsed = (System.currentTimeMillis() - _active.get(player))/1000d; + if (player == null) + { + chargeIterator.remove(); + continue; + } - //Idle in Air + long elapsed = (System.currentTimeMillis() - _active.get(key)); + + // Idle in Air UtilAction.zeroVelocity(player); - - //Sound - player.getWorld().playSound(player.getLocation(), Sound.CREEPER_HISS, (float)(0.5 + elapsed), (float)(0.5 + elapsed)); + + // Sound + player.getWorld().playSound(player.getLocation(), Sound.CREEPER_HISS, (float) (0.5 + elapsed), (float) (0.5 + elapsed)); IncreaseSize(player); - - player.setExp(Math.min(0.99f, (float)(elapsed/1.5))); - //Not Detonated - if (elapsed < 1.5) + player.setExp(Math.min(0.999f, elapsed / (float) WARMUP)); + + // Not Detonated + if (!UtilTime.elapsed(_active.get(key), WARMUP)) + { continue; + } + + player.setExp(0); chargeIterator.remove(); - //Unpower + // Unpower DecreaseSize(player); - boolean isSuper = _super.remove(player); - - //Explode - if (!isSuper) + // Explode + if (!isSuperActive(player)) { - //Effect - UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, player.getLocation(), 0, 0, 0, 0, 1, - ViewDist.MAX, UtilServer.getPlayers()); + // Effect + UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, player.getLocation(), 0, 0, 0, 0, 1, ViewDist.MAX, UtilServer.getPlayers()); player.getWorld().playSound(player.getLocation(), Sound.EXPLODE, 2f, 1f); } else { - //Particles - UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, player.getLocation(), 5f, 5f, 5f, 0, 20, - ViewDist.MAX, UtilServer.getPlayers()); - - //Sound - for (int i=0 ; i<4 ; i++) - player.getWorld().playSound(player.getLocation(), Sound.EXPLODE, (float)(2 + Math.random()*4), (float)(Math.random() + 0.2)); - - //Blocks + // Particles + UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, player.getLocation(), 5f, 5f, 5f, 0, 20, ViewDist.MAX, UtilServer.getPlayers()); + + // Sound + for (int i = 0; i < 4; i++) + { + player.getWorld().playSound(player.getLocation(), Sound.EXPLODE, (float) (2 + Math.random() * 4), (float) (Math.random() + 0.2)); + } + + // Blocks Collection<Block> blocks = UtilBlock.getInRadius(player.getLocation(), 12).keySet(); Iterator<Block> iter = blocks.iterator(); - while (iter.hasNext()) { - Block b = iter.next(); + while (iter.hasNext()) + { + Block b = iter.next(); - if(b.getType() == Material.STATIONARY_LAVA || b.getType() == Material.LAVA || b.getType() == Material.BEDROCK) iter.remove();; + if (b.getType() == Material.STATIONARY_LAVA || b.getType() == Material.LAVA || b.getType() == Material.BEDROCK) + { + iter.remove(); + } } Manager.GetExplosion().BlockExplosion(blocks, player.getLocation(), false); - - //Remove Spawns + + // Remove Spawns Iterator<Location> spawnIterator = Manager.GetGame().GetTeam(player).GetSpawns().iterator(); while (spawnIterator.hasNext()) { Location spawn = spawnIterator.next(); - - if (UtilMath.offset(player.getLocation(), spawn) < 14) + + if (UtilMath.offset(player.getLocation(), spawn) < SPAWN_REMOVAL_RADIUS) + { spawnIterator.remove(); + } } - - //If all spawns have been destroyed revert to using the spectator spawn + + // If all spawns have been destroyed revert to using the + // spectator spawn for (GameTeam team : Manager.GetGame().GetTeamList()) { if (team.GetSpawns().isEmpty()) @@ -177,110 +208,134 @@ public class PerkCreeperExplode extends SmashPerk } } } - - //Damage - for (Entity ent : player.getWorld().getEntities()) + + double maxRange = isSuperActive(player) ? RADIUS_SMASH : RADIUS_NORMAL; + double damage = isSuperActive(player) ? DAMAGE_SMASH : DAMAGE_NORMAL; + + // Damage + for (LivingEntity ent : UtilEnt.getInRadius(player.getLocation(), maxRange).keySet()) { - if (!(ent instanceof LivingEntity)) - continue; - if (ent.equals(player)) + { continue; + } double dist = UtilMath.offset(player.getLocation(), ent.getLocation()); - - double maxRange = 8; - if (isSuper) - maxRange = 24; - - double damage = 20; - if (isSuper) - damage = 30; - - if (dist > maxRange) + + if (UtilPlayer.isSpectator(player)) + { continue; + } - if (ent instanceof Player) - if (!Manager.GetGame().IsAlive((Player)ent)) - continue; + LivingEntity livingEnt = (LivingEntity) ent; - LivingEntity livingEnt = (LivingEntity)ent; - - double scale = 0.1 + 0.9 * ((maxRange-dist)/maxRange); - - //Damage Event - Manager.GetDamage().NewDamageEvent(livingEnt, player, null, - DamageCause.CUSTOM, damage * scale, true, true, false, - player.getName(), isSuper ? "Atomic Blast" : GetName()); + double scale = 0.1 + 0.9 * ((maxRange - dist) / maxRange); + + // Damage Event + Manager.GetDamage().NewDamageEvent(livingEnt, player, null, DamageCause.CUSTOM, damage * scale, true, true, false, player.getName(), isSuperActive(player) ? "Atomic Blast" : GetName()); } - - //Velocity + + // Velocity UtilAction.velocity(player, 1.8, 0.2, 1.4, true); - - //Inform - if (!isSuper) + + // Inform + if (!isSuperActive(player)) + { UtilPlayer.message(player, F.main("Skill", "You used " + F.skill(GetName()) + ".")); + } } } + + public void activate(Player player) + { + _active.put(player.getUniqueId(), System.currentTimeMillis()); + } public DisguiseCreeper GetDisguise(Player player) { - DisguiseBase disguise = Manager.GetDisguise().getDisguise(player); + DisguiseBase disguise = Manager.GetDisguise().getActiveDisguise(player); + if (disguise == null) + { return null; + } if (!(disguise instanceof DisguiseCreeper)) + { return null; + } - return (DisguiseCreeper)disguise; + return (DisguiseCreeper) disguise; } - + public int GetSize(Player player) { DisguiseCreeper creeper = GetDisguise(player); - if (creeper == null) return 0; - + + if (creeper == null) + { + return 0; + } + return creeper.bV(); } - + public void DecreaseSize(Player player) { DisguiseCreeper creeper = GetDisguise(player); - if (creeper == null) return; - + + if (creeper == null) + { + return; + } + creeper.a(-1); - + Manager.GetDisguise().updateDisguise(creeper); } - + public void IncreaseSize(Player player) { DisguiseCreeper creeper = GetDisguise(player); - if (creeper == null) return; - + + if (creeper == null) + { + return; + } + creeper.a(1); - + Manager.GetDisguise().updateDisguise(creeper); } - + @EventHandler public void Knockback(CustomDamageEvent event) { if (event.GetReason() == null || !event.GetReason().contains(GetName())) + { return; - - event.AddKnockback(GetName(), 2.5); + } + + event.AddKnockback(GetName(), KNOCKBACK_MAGNITUDE); } - + @EventHandler - public void Death(PlayerDeathEvent event) + public void Death(CombatDeathEvent event) { - if (!Kit.HasKit(event.getEntity())) + if (!(event.GetEvent().getEntity() instanceof Player)) + { return; - - _active.remove(event.getEntity()); - _super.remove(event.getEntity()); - - DecreaseSize(event.getEntity()); + } + + Player player = (Player) event.GetEvent().getEntity(); + + if (!hasPerk(player)) + { + return; + } + + _active.remove(player.getUniqueId()); + + DecreaseSize(player); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkCreeperSulphurBomb.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/creeper/PerkCreeperSulphurBomb.java similarity index 62% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkCreeperSulphurBomb.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/creeper/PerkCreeperSulphurBomb.java index c1d93f7b7..111271be2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkCreeperSulphurBomb.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/creeper/PerkCreeperSulphurBomb.java @@ -1,12 +1,12 @@ -package nautilus.game.arcade.kit.perks; +package nautilus.game.arcade.game.games.smash.perks.creeper; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.block.Block; +import org.bukkit.entity.Item; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.block.Action; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.player.PlayerInteractEvent; @@ -15,110 +15,121 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.projectile.IThrown; import mineplex.core.projectile.ProjectileUser; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.kit.SmashPerk; +import nautilus.game.arcade.game.games.smash.perks.SmashPerk; public class PerkCreeperSulphurBomb extends SmashPerk implements IThrown { - public PerkCreeperSulphurBomb() - { - super("Sulphur Bomb", new String[] - { - C.cYellow + "Right-Click" + C.cGray + " with Axe to use " + C.cGreen + "Sulphur Bomb" - }); - } + + private static final int COOLDOWN = 3000; + private static final float DAMAGE = 6.5F; + private static final float KNOCKBACK_MAGNITUDE = 2.5F; + public PerkCreeperSulphurBomb() + { + super("Sulphur Bomb", new String[] { C.cYellow + "Right-Click" + C.cGray + " with Axe to use " + C.cGreen + "Sulphur Bomb" }); + } @EventHandler public void ShootWeb(PlayerInteractEvent event) { if (event.isCancelled()) + { return; + } - if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) + if (!UtilEvent.isAction(event, ActionType.R)) + { return; + } if (UtilBlock.usable(event.getClickedBlock())) + { return; - - if (event.getPlayer().getItemInHand() == null) - return; - - if (!event.getPlayer().getItemInHand().getType().toString().contains("_AXE")) - return; + } Player player = event.getPlayer(); - if (isSuperActive(player)) + if (!UtilItem.isAxe(player.getItemInHand())) + { return; + } + + if (!hasPerk(player)) + { + return; + } - if (!Kit.HasKit(player)) + if (isSuperActive(player)) + { return; + } - if (!Recharge.Instance.use(player, GetName(), 3000, true, true)) + if (!Recharge.Instance.use(player, GetName(), COOLDOWN, true, true)) + { return; - + } + event.setCancelled(true); UtilInv.Update(player); - org.bukkit.entity.Item ent = player.getWorld().dropItem(player.getEyeLocation(), ItemStackFactory.Instance.CreateStack(Material.COAL, (byte)0)); + Item ent = player.getWorld().dropItem(player.getEyeLocation(), ItemStackFactory.Instance.CreateStack(Material.COAL, (byte) 0)); - UtilAction.velocity(ent, player.getLocation().getDirection(), 1.2, false, 0, 0.2, 10, false); + UtilAction.velocity(ent, player.getLocation().getDirection(), 1.2, false, 0, 0.2, 10, false); - Manager.GetProjectile().AddThrow(ent, player, this, -1, true, true, true, true, - null, 1f, 1f, - null, 1, UpdateType.SLOW, - 0.65f); + Manager.GetProjectile().AddThrow(ent, player, this, -1, true, true, true, true, null, 1f, 1f, null, 1, UpdateType.SLOW, 0.6f); - //Inform + // Inform UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + ".")); - //Effect + // Effect player.getWorld().playSound(player.getLocation(), Sound.CREEPER_DEATH, 2f, 1.5f); } @Override - public void Collide(LivingEntity target, Block block, ProjectileUser data) + public void Collide(LivingEntity target, Block block, ProjectileUser data) { Explode(data); if (target == null) + { return; - - //Damage Event - Manager.GetDamage().NewDamageEvent(target, data.getThrower(), null, - DamageCause.PROJECTILE, 7, true, true, false, - UtilEnt.getName(data.getThrower()), GetName()); + } + + // Damage Event + Manager.GetDamage().NewDamageEvent(target, data.getThrower(), null, DamageCause.PROJECTILE, DAMAGE, true, true, false, UtilEnt.getName(data.getThrower()), GetName()); } @Override - public void Idle(ProjectileUser data) + public void Idle(ProjectileUser data) { Explode(data); } @Override - public void Expire(ProjectileUser data) + public void Expire(ProjectileUser data) { Explode(data); } public void Explode(ProjectileUser data) { - UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, data.getThrown().getLocation(), 0, 0, 0, 0, 1, - ViewDist.MAX, UtilServer.getPlayers()); + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, data.getThrown().getLocation(), 0, 0, 0, 0, 1, ViewDist.MAX, UtilServer.getPlayers()); data.getThrown().getWorld().playSound(data.getThrown().getLocation(), Sound.EXPLODE, 1f, 1.5f); data.getThrown().remove(); } @@ -127,8 +138,10 @@ public class PerkCreeperSulphurBomb extends SmashPerk implements IThrown public void Knockback(CustomDamageEvent event) { if (event.GetReason() == null || !event.GetReason().contains(GetName())) + { return; - - event.AddKnockback(GetName(), 2); + } + + event.AddKnockback(GetName(), KNOCKBACK_MAGNITUDE); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/creeper/SmashCreeper.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/creeper/SmashCreeper.java new file mode 100644 index 000000000..b20752818 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/creeper/SmashCreeper.java @@ -0,0 +1,36 @@ +package nautilus.game.arcade.game.games.smash.perks.creeper; + +import org.bukkit.Sound; +import org.bukkit.entity.Player; + +import nautilus.game.arcade.game.games.smash.perks.SmashUltimate; +import nautilus.game.arcade.kit.Perk; + +public class SmashCreeper extends SmashUltimate +{ + + public SmashCreeper() + { + super("Atomic Blast", new String[] {}, Sound.CREEPER_HISS, 1600); + } + + @Override + public void activate(Player player) + { + super.activate(player); + + for (Perk perk : Kit.GetPerks()) + { + if (!(perk instanceof PerkCreeperExplode)) + { + continue; + } + + PerkCreeperExplode explode = (PerkCreeperExplode) perk; + + explode.IncreaseSize(player); + explode.activate(player); + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/enderman/PerkBlink.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/enderman/PerkBlink.java new file mode 100644 index 000000000..c7f8c30ff --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/enderman/PerkBlink.java @@ -0,0 +1,102 @@ +package nautilus.game.arcade.game.games.smash.perks.enderman; + +import org.bukkit.Color; +import org.bukkit.FireworkEffect.Type; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilItem; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.particles.effects.LineParticle; +import mineplex.core.recharge.Recharge; +import nautilus.game.arcade.game.games.smash.perks.SmashPerk; + +public class PerkBlink extends SmashPerk +{ + + private static final float INCREMENTAITON = 0.2F; + + private String _name; + private double _range; + private int _recharge; + + public PerkBlink(String name, double range, int recharge) + { + super(name, new String[] { C.cYellow + "Right-Click" + C.cGray + " with Axe to " + C.cGreen + name }); + + _name = name; + _range = range; + _recharge = recharge; + } + + @EventHandler + public void Blink(PlayerInteractEvent event) + { + if (event.isCancelled()) + { + return; + } + + if (!UtilEvent.isAction(event, ActionType.R)) + { + return; + } + + if (UtilBlock.usable(event.getClickedBlock())) + { + return; + } + + Player player = event.getPlayer(); + + if (!UtilItem.isAxe(player.getItemInHand())) + { + return; + } + + if (!hasPerk(player)) + { + return; + } + + if (isSuperActive(player)) + { + return; + } + + if (!Recharge.Instance.use(player, _name, _recharge, true, true)) + { + return; + } + + LineParticle lineParticle = new LineParticle(player.getEyeLocation(), player.getLocation().getDirection(), INCREMENTAITON, _range, null, ParticleType.SMOKE, UtilServer.getPlayers()); + + while (!lineParticle.update()) + { + } + + // Firework + UtilFirework.playFirework(player.getEyeLocation(), Type.BALL, Color.BLACK, false, false); + + player.playSound(player.getLocation(), Sound.ENDERMAN_TELEPORT, 1f, 1f); + player.teleport(lineParticle.getDestination()); + player.setFallDistance(0); + player.playSound(player.getLocation(), Sound.ENDERMAN_TELEPORT, 1f, 1f); + + // Firework + UtilFirework.playFirework(player.getEyeLocation(), Type.BALL, Color.BLACK, false, false); + + // Inform + UtilPlayer.message(player, F.main("Game", "You used " + F.skill(_name) + ".")); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBlockToss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/enderman/PerkBlockToss.java similarity index 56% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBlockToss.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/enderman/PerkBlockToss.java index 83870c9d9..afa59acd8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBlockToss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/enderman/PerkBlockToss.java @@ -1,28 +1,10 @@ -package nautilus.game.arcade.kit.perks; +package nautilus.game.arcade.game.games.smash.perks.enderman; import java.util.HashMap; import java.util.HashSet; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilEvent; -import mineplex.core.common.util.UtilGear; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilEvent.ActionType; -import mineplex.core.projectile.IThrown; -import mineplex.core.projectile.ProjectileUser; -import mineplex.core.recharge.Recharge; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.kit.SmashPerk; -import nautilus.game.arcade.kit.perks.data.BlockTossData; -import nautilus.game.arcade.kit.perks.event.PerkBlockGrabEvent; -import nautilus.game.arcade.kit.perks.event.PerkBlockThrowEvent; +import java.util.Map; +import java.util.Set; +import java.util.UUID; import org.bukkit.Effect; import org.bukkit.block.Block; @@ -35,49 +17,91 @@ import org.bukkit.event.entity.EntityChangeBlockEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.player.PlayerInteractEvent; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilItem; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.projectile.IThrown; +import mineplex.core.projectile.ProjectileUser; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import nautilus.game.arcade.game.games.smash.perks.SmashPerk; +import nautilus.game.arcade.kit.perks.data.BlockTossData; +import nautilus.game.arcade.kit.perks.event.PerkBlockGrabEvent; +import nautilus.game.arcade.kit.perks.event.PerkBlockThrowEvent; + public class PerkBlockToss extends SmashPerk implements IThrown { - private HashMap<Player, BlockTossData> _hold = new HashMap<Player, BlockTossData>(); - private HashMap<Player, Long> _charge = new HashMap<Player, Long>(); - private HashSet<Player> _charged = new HashSet<Player>(); - private HashMap<FallingBlock, Player> _falling = new HashMap<FallingBlock, Player>(); - public PerkBlockToss() + private static final int COOLDOWN = 2000; + private static final int CHARGE_TIME = 1200; + private static final int DAMAGE = 9; + private static final float KNOCKBACK_MAGNITUDE = 2.5F; + + private Map<UUID, BlockTossData> _hold = new HashMap<>(); + private Set<UUID> _charged = new HashSet<>(); + private Map<FallingBlock, UUID> _falling = new HashMap<>(); + + public PerkBlockToss() { - super("Block Toss", new String[] - { - C.cYellow + "Hold Block" + C.cGray + " to " + C.cGreen + "Grab Block", - C.cYellow + "Release Block" + C.cGray + " to " + C.cGreen + "Throw Block" - }); + super("Block Toss", new String[] { C.cYellow + "Hold Block" + C.cGray + " to " + C.cGreen + "Grab Block", C.cYellow + "Release Block" + C.cGray + " to " + C.cGreen + "Throw Block" }); } @EventHandler public void Grab(PlayerInteractEvent event) - { - Player player = event.getPlayer(); + { + if (event.isCancelled()) + { + return; + } if (!UtilEvent.isAction(event, ActionType.R_BLOCK)) + { return; - + } + + if (UtilBlock.usable(event.getClickedBlock())) + { + return; + } + + Player player = event.getPlayer(); + + if (!UtilItem.isSword(player.getItemInHand())) + { + return; + } + + if (!hasPerk(player)) + { + return; + } + if (isSuperActive(player)) + { return; + } - if (!Kit.HasKit(player)) - return; - - if (!UtilGear.isSword(player.getItemInHand())) - return; - - if (_hold.containsKey(player)) + if (_hold.containsKey(player.getUniqueId())) + { return; + } Block grab = event.getClickedBlock(); - if (UtilBlock.usable(grab)) - return; - if (!Recharge.Instance.usable(player, GetName())) + { return; + } if (!UtilBlock.airFoliage(grab.getRelative(BlockFace.UP)) || Manager.GetBlockRestore().contains(grab.getRelative(BlockFace.UP))) { @@ -85,23 +109,20 @@ public class PerkBlockToss extends SmashPerk implements IThrown return; } - //Event + // Event PerkBlockGrabEvent blockEvent = new PerkBlockGrabEvent(player, grab.getTypeId(), grab.getData()); UtilServer.getServer().getPluginManager().callEvent(blockEvent); - //Block to Data + // Block to Data int id = grab.getTypeId(); byte data = grab.getData(); - - //Remove Block - //Manager.GetBlockRestore().Add(event.getClickedBlock(), 0, (byte)0, 10000); - event.getClickedBlock().getWorld().playEffect(event.getClickedBlock().getLocation(), Effect.STEP_SOUND, event.getClickedBlock().getType()); - - _hold.put(player, new BlockTossData(id, data)); - - _charge.put(player, System.currentTimeMillis()); - //Effect + // Remove Block + event.getClickedBlock().getWorld().playEffect(event.getClickedBlock().getLocation(), Effect.STEP_SOUND, event.getClickedBlock().getType()); + + _hold.put(player.getUniqueId(), new BlockTossData(id, data, System.currentTimeMillis())); + + // Effect player.getWorld().playEffect(event.getClickedBlock().getLocation(), Effect.STEP_SOUND, id); } @@ -109,104 +130,119 @@ public class PerkBlockToss extends SmashPerk implements IThrown public void Throw(UpdateEvent event) { if (event.getType() != UpdateType.TICK) - return; - - HashSet<Player> throwSet = new HashSet<Player>(); - - for (Player cur : _hold.keySet()) { - //Throw - if (!cur.isBlocking()) - throwSet.add(cur); + return; + } - //Charged Tick - if (!_charged.contains(cur)) - if (System.currentTimeMillis() - _charge.get(cur) > 1200) + Set<Player> throwSet = new HashSet<>(); + + for (UUID key : _hold.keySet()) + { + Player player = UtilPlayer.searchExact(key); + + if (player == null) + { + continue; + } + + // Throw + if (!player.isBlocking()) + { + throwSet.add(player); + } + + // Charged Tick + if (!_charged.contains(key)) + { + if (System.currentTimeMillis() - _hold.get(key).Time > CHARGE_TIME) { - _charged.add(cur); - cur.playEffect(cur.getLocation(), Effect.CLICK1, 0); + _charged.add(key); + player.getWorld().playEffect(player.getLocation(), Effect.CLICK1, 0); } + } } for (Player cur : throwSet) { + UUID key = cur.getUniqueId(); + Recharge.Instance.recharge(cur, GetName()); - Recharge.Instance.use(cur, GetName(), 2000, false, true); - - BlockTossData data = _hold.remove(cur); - - FallingBlock block = cur.getWorld().spawnFallingBlock(cur.getEyeLocation().add(cur.getLocation().getDirection()), data.Type, data.Data); - - _falling.put(block, cur); - - _charged.remove(cur); - - long charge = System.currentTimeMillis() - _charge.remove(cur); + Recharge.Instance.use(cur, GetName(), COOLDOWN, false, true); - //Throw - double mult = 1.4; - if (charge < 1200) - mult = mult * ((double)charge/1200d); - - //Action + BlockTossData data = _hold.remove(key); + + FallingBlock block = cur.getWorld().spawnFallingBlock(cur.getEyeLocation().add(cur.getLocation().getDirection()), data.Type, data.Data); + + _falling.put(block, key); + + _charged.remove(key); + + long charge = System.currentTimeMillis() - data.Time; + + // Throw + double mult = Math.min(1.4, 1.4 * ((double) charge / CHARGE_TIME)); + + // Action UtilAction.velocity(block, cur.getLocation().getDirection(), mult, false, 0.2, 0, 1, true); - Manager.GetProjectile().AddThrow(block, cur, this, -1, true, true, true, true, - null, 0, 0, null, 0, UpdateType.FASTEST, 1f); + Manager.GetProjectile().AddThrow(block, cur, this, -1, true, true, true, true, null, 0, 0, null, 0, UpdateType.FASTEST, 1f); - //Event + // Event PerkBlockThrowEvent blockEvent = new PerkBlockThrowEvent(cur); UtilServer.getServer().getPluginManager().callEvent(blockEvent); } } @Override - public void Collide(LivingEntity target, Block block, ProjectileUser data) + public void Collide(LivingEntity target, Block block, ProjectileUser data) { if (target == null) + { return; + } - //Damage Event - Manager.GetDamage().NewDamageEvent(target, data.getThrower(), null, - DamageCause.PROJECTILE, data.getThrown().getVelocity().length() * 10, true, true, false, - UtilEnt.getName(data.getThrower()), GetName()); + // Damage Event + Manager.GetDamage().NewDamageEvent(target, data.getThrower(), null, DamageCause.PROJECTILE, data.getThrown().getVelocity().length() * DAMAGE, true, true, false, UtilEnt.getName(data + .getThrower()), GetName()); - //Block to Item + // Block to Item if (data.getThrown() instanceof FallingBlock) { FallingBlock thrown = (FallingBlock) data.getThrown(); - FallingBlock newThrown = data.getThrown().getWorld().spawnFallingBlock(data.getThrown().getLocation(), thrown.getMaterial(), (byte)0); + FallingBlock newThrown = data.getThrown().getWorld().spawnFallingBlock(data.getThrown().getLocation(), thrown.getMaterial(), (byte) 0); - //Remove Old + // Remove Old _falling.remove(thrown); thrown.remove(); - //Add New + // Add New if (data.getThrower() instanceof Player) - _falling.put(newThrown, (Player)data.getThrower()); + { + _falling.put(newThrown, data.getThrower().getUniqueId()); + } } - } - - @Override - public void Idle(ProjectileUser data) - { } @Override - public void Expire(ProjectileUser data) + public void Idle(ProjectileUser data) { + } - } - + @Override + public void Expire(ProjectileUser data) + { + } @EventHandler public void BlockForm(EntityChangeBlockEvent event) { if (!(event.getEntity() instanceof FallingBlock)) + { return; + } - FallingBlock falling = (FallingBlock)event.getEntity(); + FallingBlock falling = (FallingBlock) event.getEntity(); falling.getWorld().playEffect(event.getBlock().getLocation(), Effect.STEP_SOUND, falling.getBlockId()); @@ -220,8 +256,10 @@ public class PerkBlockToss extends SmashPerk implements IThrown public void Knockback(CustomDamageEvent event) { if (event.GetReason() == null || !event.GetReason().contains(GetName())) + { return; + } - event.AddKnockback(GetName(), 2.5); + event.AddKnockback(GetName(), KNOCKBACK_MAGNITUDE); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/PerkEndermanTeleport.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/enderman/PerkEndermanTeleport.java similarity index 52% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/PerkEndermanTeleport.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/enderman/PerkEndermanTeleport.java index 7a0bf6059..5fcc81787 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/PerkEndermanTeleport.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/enderman/PerkEndermanTeleport.java @@ -1,7 +1,8 @@ -package nautilus.game.arcade.game.games.smash.perks; +package nautilus.game.arcade.game.games.smash.perks.enderman; import java.util.HashMap; -import java.util.HashSet; +import java.util.Map; +import java.util.UUID; import org.bukkit.Material; import org.bukkit.Sound; @@ -12,111 +13,120 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerQuitEvent; import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import nautilus.game.arcade.kit.SmashPerk; +import nautilus.game.arcade.game.games.smash.perks.SmashPerk; public class PerkEndermanTeleport extends SmashPerk { - private HashMap<Player, Block> _target = new HashMap<Player, Block>(); - private HashMap<Player, Float> _charge = new HashMap<Player, Float>(); - public PerkEndermanTeleport() + private static final int COOLDOWN = 5000; + private static final float CHARGE_PER_TICK = 0.015F; + + private Map<UUID, Block> _target = new HashMap<>(); + private Map<UUID, Float> _charge = new HashMap<>(); + + public PerkEndermanTeleport() { - super("Teleport", new String[] - { - C.cYellow + "Hold Sneak" + C.cGray + " to " + C.cGreen + "Teleport" - }); + super("Teleport", new String[] { C.cYellow + "Hold Sneak" + C.cGray + " to " + C.cGreen + "Teleport" }); } @EventHandler public void update(UpdateEvent event) - { + { if (event.getType() != UpdateType.TICK) + { return; - - if(!Manager.GetGame().IsLive()) - return; + } for (Player player : UtilServer.getPlayers()) { - if (!Kit.HasKit(player)) + if (!hasPerk(player) || UtilPlayer.isSpectator(player)) + { continue; + } + + UUID key = player.getUniqueId(); if (!player.isSneaking() || !Recharge.Instance.usable(player, GetName())) { - _target.remove(player); - _charge.remove(player); + _target.remove(key); + _charge.remove(key); continue; } - Block block = player.getTargetBlock((HashSet<Byte>) null, 200); - - if (!_target.containsKey(player) || !_charge.containsKey(player)) + Block block = UtilPlayer.getTarget(player, UtilBlock.blockPassSet, 100); + + if (!_target.containsKey(key) || !_charge.containsKey(key)) { if (block == null || block.getType() == Material.AIR) + { continue; - - _target.put(player, block); - _charge.put(player, 0f); + } + + _target.put(key, block); + _charge.put(key, 0f); } - //Invalid Block - End + // Invalid Block - End if (block == null || block.getType() == Material.AIR) { - _target.remove(player); - _charge.remove(player); + _target.remove(key); + _charge.remove(key); } - //Same Block - Increase Charge - else if (block.equals(_target.get(player))) + + // Same Block - Increase Charge + else if (block.equals(_target.get(key))) { - _charge.put(player, _charge.get(player) + 0.015f); - - UtilTextMiddle.display(null, UtilTextMiddle.progress(_charge.get(player)), 0, 10, 10, player); - - if (_charge.get(player) >= 1f) + _charge.put(key, _charge.get(key) + CHARGE_PER_TICK); + + UtilTextMiddle.display(null, UtilTextMiddle.progress(_charge.get(key)), 0, 10, 10, player); + + if (_charge.get(key) >= 1) { UtilTextMiddle.display(null, C.cGreen + "Teleported", 0, 10, 10, player); - Recharge.Instance.useForce(player, GetName(), 5000); - + Recharge.Instance.useForce(player, GetName(), COOLDOWN); + while (block.getRelative(BlockFace.UP).getType() != Material.AIR) { block = block.getRelative(BlockFace.UP); } - + player.playSound(player.getLocation(), Sound.ENDERMAN_TELEPORT, 1f, 0.5f); player.teleport(block.getLocation().add(0.5, 1, 0.5).setDirection(player.getLocation().getDirection())); player.playSound(player.getLocation(), Sound.ENDERMAN_TELEPORT, 1f, 0.5f); - - UtilParticle.PlayParticle(ParticleType.WITCH_MAGIC, player.getLocation().add(0, 1, 0), 1f, 1f, 1f, 0.1f, 100, ViewDist.LONG, UtilServer.getPlayers()); + + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, player.getLocation().add(0, 1, 0), 1f, 1f, 1f, 0.1f, 100, ViewDist.LONG); } else { - player.playSound(player.getLocation(), Sound.ENDERMAN_TELEPORT, 1f, 1f + _charge.get(player)); - UtilParticle.PlayParticle(ParticleType.WITCH_MAGIC, player.getLocation().add(0, 1, 0), 1f, 1f, 1f, 0.05f, 10, ViewDist.LONG, UtilServer.getPlayers()); + player.playSound(player.getLocation(), Sound.ENDERMAN_TELEPORT, 1f, 1f + _charge.get(key)); + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, player.getLocation().add(0, 1, 0), 1f, 1f, 1f, 0.05f, 10, ViewDist.LONG); } } - //New Block - Reset + // New Block - Reset else { - _target.put(player, block); - _charge.put(player, 0f); + _target.put(key, block); + _charge.put(key, 0f); } } } - + @EventHandler public void clean(PlayerQuitEvent event) { - _target.remove(event.getPlayer()); - _charge.remove(event.getPlayer()); + UUID key = event.getPlayer().getUniqueId(); + + _target.remove(key); + _charge.remove(key); } } - - diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkEndermanDragon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/enderman/SmashEnderman.java similarity index 59% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkEndermanDragon.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/enderman/SmashEnderman.java index 4d430ad0b..254343602 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkEndermanDragon.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/enderman/SmashEnderman.java @@ -1,184 +1,224 @@ -package nautilus.game.arcade.kit.perks; +package nautilus.game.arcade.game.games.smash.perks.enderman; import java.util.HashMap; +import java.util.Map; +import java.util.UUID; import org.bukkit.Color; -import org.bukkit.Location; import org.bukkit.FireworkEffect.Type; +import org.bukkit.Location; +import org.bukkit.Sound; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEnderDragon; import org.bukkit.entity.EnderDragon; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; -import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityExplodeEvent; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.kit.SmashPerk; +import nautilus.game.arcade.game.games.smash.perks.SmashUltimate; -public class PerkEndermanDragon extends SmashPerk +public class SmashEnderman extends SmashUltimate { - private HashMap<Player, EnderDragon> _dragons = new HashMap<Player, EnderDragon>(); - - public PerkEndermanDragon() - { - super("Ender Dragon", new String[] - { - }, false); - } - @Override - public void addSuperCustom(Player player) + private static final int DURATION = 30000; + private static final int DRAGON_VELOCITY_MAGNITUDE = 40; + private static final int HIT_COOLDOWN = 1000; + private static final int DAMAGE_RADIUS = 6; + private static final int DAMAGE = 20; + private static final int KNOCKBACK_MAGNITUDE = 4; + + private Map<UUID, EnderDragon> _dragons = new HashMap<>(); + + public SmashEnderman() { + super("Ender Dragon", new String[] {}, Sound.ENDERDRAGON_GROWL, DURATION); + } + + @Override + public void activate(Player player) + { + super.activate(player); + Manager.GetGame().CreatureAllowOverride = true; EnderDragon dragon = player.getWorld().spawn(player.getLocation().add(0, 5, 0), EnderDragon.class); UtilEnt.Vegetate(dragon); Manager.GetGame().CreatureAllowOverride = false; - + dragon.setCustomName(C.cYellow + player.getName() + "'s Dragon"); - + UtilFirework.playFirework(dragon.getLocation(), Type.BALL_LARGE, Color.BLACK, true, true); - - _dragons.put(player, dragon); + + _dragons.put(player.getUniqueId(), dragon); } - + @Override - public void removeSuperCustom(Player player) + public void cancel(Player player) { - EnderDragon dragon = _dragons.remove(player); + super.cancel(player); + + EnderDragon dragon = _dragons.remove(player.getUniqueId()); + if (dragon == null) + { return; + } player.leaveVehicle(); dragon.remove(); } - + @EventHandler public void update(UpdateEvent event) { if (event.getType() != UpdateType.TICK) return; - - for (Player player : _dragons.keySet()) + + for (UUID key : _dragons.keySet()) { - EnderDragon dragon = _dragons.get(player); + Player player = UtilPlayer.searchExact(key); - //Mount + if (player == null) + { + continue; + } + + EnderDragon dragon = _dragons.get(key); + + // Mount if (dragon.getPassenger() == null || !dragon.getPassenger().equals(player)) { player.leaveVehicle(); dragon.setPassenger(player); } - - //Move - Location target = player.getLocation().add(player.getLocation().getDirection().multiply(40)); - ((CraftEnderDragon)dragon).getHandle().setTargetBlock(target.getBlockX(), target.getBlockY(), target.getBlockZ()); + + // Move + Location target = player.getLocation().add(player.getLocation().getDirection().multiply(DRAGON_VELOCITY_MAGNITUDE)); + ((CraftEnderDragon) dragon).getHandle().setTargetBlock(target.getBlockX(), target.getBlockY(), target.getBlockZ()); } } - + @EventHandler(priority = EventPriority.LOWEST) public void explosionBlocks(EntityExplodeEvent event) { event.blockList().clear(); } - + @EventHandler(priority = EventPriority.LOW) public void suffocationCancel(CustomDamageEvent event) { if (event.GetCause() != DamageCause.SUFFOCATION) + { return; + } if (event.GetDamageePlayer() == null) + { return; - - if (isSuperActive(event.GetDamageePlayer())) + } + + if (isUsingUltimate(event.GetDamageePlayer())) + { event.SetCancelled("Enderman Dragon Suffocate"); + } } - - @EventHandler(priority = EventPriority.LOW) - public void dragonDamageeCancel(CustomDamageEvent event) - { - if (event.GetDamagerEntity(false) == null) - return; - - if (_dragons.values().contains(event.GetDamagerEntity(false))) - event.SetCancelled("Enderman Dragon Damagee"); - } - + @EventHandler(priority = EventPriority.LOW) public void dragonDamagerCancel(CustomDamageEvent event) { if (event.GetDamagerEntity(false) == null) + { return; + } if (!_dragons.values().contains(event.GetDamagerEntity(false))) + { return; + } event.SetCancelled("Dragon Damage Cancel"); } - + @EventHandler public void updateDamageAoe(UpdateEvent event) { if (event.getType() != UpdateType.TICK) - return; - - for (Player player : _dragons.keySet()) { - EnderDragon dragon = _dragons.get(player); + return; + } + + for (UUID key : _dragons.keySet()) + { + Player player = UtilPlayer.searchExact(key); - UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, dragon.getLocation(), 0, 0, 0, 0, 1, - ViewDist.LONGER, UtilServer.getPlayers()); + if (player == null) + { + continue; + } + EnderDragon dragon = _dragons.get(key); + + UtilParticle.PlayParticleToAll(ParticleType.FIREWORKS_SPARK, dragon.getLocation(), 0, 0, 0, 0, 1, ViewDist.LONGER); + for (Player other : Manager.GetGame().GetPlayers(true)) { if (other.equals(player)) - continue; - - if (UtilMath.offset(dragon.getLocation().add(0, 4, 0), other.getLocation()) < 6 && Recharge.Instance.use(other, "Hit By Dragon", 1000, false, false)) { - //Damage Event - Manager.GetDamage().NewDamageEvent(other, player, null, - DamageCause.CUSTOM, 20, true, true, false, - player.getName(), GetName()); + continue; + } + + if (UtilMath.offset(dragon.getLocation().add(0, 4, 0), other.getLocation()) < DAMAGE_RADIUS && Recharge.Instance.use(other, "Hit By Dragon", HIT_COOLDOWN, false, false)) + { + // Damage Event + Manager.GetDamage().NewDamageEvent(other, player, null, DamageCause.CUSTOM, DAMAGE, true, true, false, player.getName(), GetName()); } } } } - + @EventHandler public void knockback(CustomDamageEvent event) { if (event.GetReason() == null || !event.GetReason().contains(GetName())) + { return; + } - event.AddKnockback(GetName(), 4); + event.AddKnockback(GetName(), KNOCKBACK_MAGNITUDE); } - + @EventHandler(priority = EventPriority.LOW) public void voidCancel(CustomDamageEvent event) { if (event.GetCause() != DamageCause.VOID) + { return; + } Player player = event.GetDamageePlayer(); + if (player == null) + { return; + } - if (!isSuperActive(player)) + if (!isUsingUltimate(player)) + { return; + } - event.SetCancelled("Dragon Void Immunity"); + event.SetCancelled("Dragon Void Immunity"); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFissure.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/golem/PerkFissure.java similarity index 66% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFissure.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/golem/PerkFissure.java index 24819a826..ad8cd2688 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFissure.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/golem/PerkFissure.java @@ -1,16 +1,19 @@ -package nautilus.game.arcade.kit.perks; +package nautilus.game.arcade.game.games.smash.perks.golem; import java.util.HashSet; +import java.util.Set; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerInteractEvent; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilPlayer; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; @@ -19,72 +22,87 @@ import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.perks.data.FissureData; public class PerkFissure extends Perk -{ - private HashSet<FissureData> _active = new HashSet<FissureData>(); +{ - public PerkFissure() + private static final int COOLDOWN = 8000; + + private Set<FissureData> _active = new HashSet<>(); + + public PerkFissure() { - super("Fissure", new String[] - { - C.cYellow + "Right-Click" + C.cGray + " with Axe to " + C.cGreen + "Fissure" - }); + super("Fissure", new String[] { C.cYellow + "Right-Click" + C.cGray + " with Axe to " + C.cGreen + "Fissure" }); } @EventHandler public void Leap(PlayerInteractEvent event) { if (event.isCancelled()) + { return; + } - if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) + if (!UtilEvent.isAction(event, ActionType.R)) + { return; + } if (UtilBlock.usable(event.getClickedBlock())) + { return; - - if (event.getPlayer().getItemInHand() == null) - return; - - if (!event.getPlayer().getItemInHand().getType().toString().contains("_AXE")) - return; + } Player player = event.getPlayer(); - if (!Kit.HasKit(player)) + if (!UtilItem.isAxe(player.getItemInHand())) + { return; - + } + + if (!hasPerk(player)) + { + return; + } + if (!UtilEnt.isGrounded(player)) { UtilPlayer.message(player, F.main("Game", "You cannot use " + F.skill(GetName()) + " while airborne.")); return; } - if (!Recharge.Instance.use(player, GetName(), 8000, true, true)) + if (!Recharge.Instance.use(player, GetName(), COOLDOWN, true, true)) + { return; + } FissureData data = new FissureData(this, player, player.getLocation().getDirection(), player.getLocation().add(0, -0.4, 0)); _active.add(data); - - //Inform + + // Inform UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + ".")); } - + @EventHandler public void Update(UpdateEvent event) { if (event.getType() != UpdateType.TICK) + { return; + } - HashSet<FissureData> remove = new HashSet<FissureData>(); - + Set<FissureData> remove = new HashSet<>(); + for (FissureData data : _active) + { if (data.Update()) + { remove.add(data); - + } + } + for (FissureData data : remove) { _active.remove(data); data.Clear(); - } + } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/golem/PerkIronHook.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/golem/PerkIronHook.java new file mode 100644 index 000000000..93ca69da5 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/golem/PerkIronHook.java @@ -0,0 +1,132 @@ +package nautilus.game.arcade.game.games.smash.perks.golem; + +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.entity.Item; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.player.PlayerInteractEvent; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilItem; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.projectile.IThrown; +import mineplex.core.projectile.ProjectileUser; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import nautilus.game.arcade.kit.Perk; + +public class PerkIronHook extends Perk implements IThrown +{ + + private static final int COOLDOWN = 8000; + private static final int DAMAGE = 4; + + public PerkIronHook() + { + super("Iron Hook", new String[] { C.cYellow + "Right-Click" + C.cGray + " with Pickaxe to " + C.cGreen + "Iron Hook" }); + } + + @EventHandler + public void Activate(PlayerInteractEvent event) + { + if (event.isCancelled()) + { + return; + } + + if (!UtilEvent.isAction(event, ActionType.R)) + { + return; + } + + if (UtilBlock.usable(event.getClickedBlock())) + { + return; + } + + Player player = event.getPlayer(); + + if (!UtilItem.isPickaxe(player.getItemInHand())) + { + return; + } + + if (!hasPerk(player)) + { + return; + } + + if (!Recharge.Instance.use(player, GetName(), COOLDOWN, true, true)) + { + return; + } + + // Action + Item item = player.getWorld().dropItem(player.getEyeLocation().add(player.getLocation().getDirection()), ItemStackFactory.Instance.CreateStack(131)); + UtilAction.velocity(item, player.getLocation().getDirection(), 1.8, false, 0, 0.2, 10, false); + + Manager.GetProjectile().AddThrow(item, player, this, -1, true, true, true, true, Sound.FIRE_IGNITE, 1.4f, 0.8f, ParticleType.CRIT, null, 0, UpdateType.TICK, 0.6f); + + // Inform + UtilPlayer.message(player, F.main("Skill", "You used " + F.skill(GetName()) + ".")); + + // Effect + item.getWorld().playSound(item.getLocation(), Sound.IRONGOLEM_THROW, 2f, 0.8f); + } + + @Override + public void Collide(LivingEntity target, Block block, ProjectileUser data) + { + // Remove + double velocity = data.getThrown().getVelocity().length(); + data.getThrown().remove(); + + if (!(data.getThrower() instanceof Player)) + { + return; + } + + Player player = (Player) data.getThrower(); + + if (target == null) + { + return; + } + + // Pull + UtilAction.velocity(target, UtilAlg.getTrajectory(target.getLocation(), player.getLocation()), 2, false, 0, 0.8, 1.5, true); + + // Condition + Manager.GetCondition().Factory().Falling(GetName(), target, player, 10, false, true); + + // Damage Event + Manager.GetDamage().NewDamageEvent(target, player, null, DamageCause.CUSTOM, velocity * DAMAGE, false, true, false, player.getName(), GetName()); + + // Inform + UtilPlayer.message(target, F.main("Skill", F.name(player.getName()) + " hit you with " + F.skill(GetName()) + ".")); + } + + @Override + public void Idle(ProjectileUser data) + { + data.getThrown().remove(); + } + + @Override + public void Expire(ProjectileUser data) + { + data.getThrown().remove(); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/golem/PerkSeismicSlam.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/golem/PerkSeismicSlam.java new file mode 100644 index 000000000..88b960cd1 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/golem/PerkSeismicSlam.java @@ -0,0 +1,192 @@ +package nautilus.game.arcade.game.games.smash.perks.golem; + +import java.util.HashMap; +import java.util.Map; + +import org.bukkit.Effect; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilItem; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.kit.Perk; + +public class PerkSeismicSlam extends Perk +{ + + private static final int COOLDOWN = 7000; + private static final int TIME = 1000; + private static final int DAMAGE = 10; + private static final int RADIUS = 8; + private static final float KNOCKBACK_MAGNITUDE = 2.4F; + + private Map<LivingEntity, Long> _live = new HashMap<>(); + + public PerkSeismicSlam() + { + super("Seismic Slam", new String[] { C.cYellow + "Right-Click" + C.cGray + " with Spade to " + C.cGreen + "Seismic Slam" }); + } + + @EventHandler + public void deactivateDeath(PlayerDeathEvent event) + { + Player player = event.getEntity(); + + if (!hasPerk(player)) + { + return; + } + + if (_live.containsKey(player)) + { + _live.remove(player); + } + } + + @EventHandler + public void Leap(PlayerInteractEvent event) + { + if (event.isCancelled()) + { + return; + } + + if (!UtilEvent.isAction(event, ActionType.R)) + { + return; + } + + if (UtilBlock.usable(event.getClickedBlock())) + { + return; + } + + Player player = event.getPlayer(); + + if (!UtilItem.isSpade(player.getItemInHand())) + { + return; + } + + if (!hasPerk(player)) + { + return; + } + + if (!Recharge.Instance.use(player, GetName(), COOLDOWN, true, true)) + return; + + // Action + Vector vec = player.getLocation().getDirection(); + if (vec.getY() < 0) + { + vec.setY(vec.getY() * -1); + } + + UtilAction.velocity(player, vec, 1, true, 1, 0, 1, true); + + // Record + _live.put(player, System.currentTimeMillis()); + + // Inform + UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + ".")); + } + + @EventHandler + public void Slam(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + for (Player player : Manager.GetGame().GetPlayers(true)) + { + if (!UtilEnt.isGrounded(player)) + { + continue; + } + + if (!_live.containsKey(player)) + { + continue; + } + + if (!UtilTime.elapsed(_live.get(player), TIME)) + { + continue; + } + + _live.remove(player); + + // Action + + Map<LivingEntity, Double> targets = UtilEnt.getInRadius(player.getLocation(), RADIUS); + + for (LivingEntity cur : targets.keySet()) + { + if (cur.equals(player)) + { + continue; + } + + if (cur instanceof Player && !UtilPlayer.isSpectator(cur)) + { + continue; + } + + // Damage Event + Manager.GetDamage().NewDamageEvent(cur, player, null, DamageCause.CUSTOM, DAMAGE * targets.get(cur) + 0.5, true, true, false, player.getName(), GetName()); + + // Condition + Manager.GetCondition().Factory().Falling(GetName(), cur, player, 10, false, true); + + // Inform + if (cur instanceof Player) + UtilPlayer.message((Player) cur, F.main("Game", F.name(player.getName()) + " hit you with " + F.skill(GetName()) + ".")); + } + + // Effect + player.getWorld().playSound(player.getLocation(), Sound.ZOMBIE_WOOD, 2f, 0.2f); + + for (Block cur : UtilBlock.getInRadius(player.getLocation(), 4).keySet()) + { + if (UtilBlock.airFoliage(cur.getRelative(BlockFace.UP)) && !UtilBlock.airFoliage(cur)) + { + cur.getWorld().playEffect(cur.getLocation(), Effect.STEP_SOUND, cur.getType()); + } + } + } + } + + @EventHandler + public void Knockback(CustomDamageEvent event) + { + if (event.GetReason() == null || !event.GetReason().contains(GetName())) + { + return; + } + + event.AddKnockback(GetName(), KNOCKBACK_MAGNITUDE); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/golem/SmashGolem.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/golem/SmashGolem.java new file mode 100644 index 000000000..a92739364 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/golem/SmashGolem.java @@ -0,0 +1,120 @@ +package nautilus.game.arcade.game.games.smash.perks.golem; + +import java.util.List; + +import org.bukkit.Effect; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +import nautilus.game.arcade.game.games.smash.TeamSuperSmash; +import nautilus.game.arcade.game.games.smash.perks.SmashUltimate; + +public class SmashGolem extends SmashUltimate +{ + + private static final int DURATION = 16000; + private static final int HIT_FREQUENCY = 400; + private static final int DAMAGE_RADIUS = 2; + private static final int EFFECT_RADIUS = 5; + + public SmashGolem() + { + super("Earthquake", new String[] {}, Sound.IRONGOLEM_HIT, DURATION); + } + + @Override + public void activate(Player player) + { + super.activate(player); + } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTEST) + { + return; + } + + List<Player> alivePlayers = Manager.GetGame().GetPlayers(true); + + for (Player player : alivePlayers) + { + if (!isUsingUltimate(player)) + { + continue; + } + + List<Player> team = TeamSuperSmash.getTeam(Manager, player, true); + + for (Player other : alivePlayers) + { + if (player.equals(other) || UtilPlayer.isSpectator(other) || team.contains(other)) + { + continue; + } + + other.playSound(other.getLocation(), Sound.MINECART_BASE, 0.2f, 0.2f); + + boolean grounded = false; + + for (Block block : UtilBlock.getInRadius(other.getLocation(), DAMAGE_RADIUS).keySet()) + { + if (block.getType() != Material.AIR) + { + grounded = true; + break; + } + } + + if (!grounded) + { + continue; + } + + // Damage Event + Manager.GetDamage().NewDamageEvent(other, player, null, DamageCause.CUSTOM, 1 + 2 * Math.random(), false, false, false, other.getName(), GetName()); + + // Velocity + if (Recharge.Instance.use(other, GetName() + " Hit", HIT_FREQUENCY, false, false)) + { + UtilAction.velocity(other, new Vector(Math.random() - 0.5, Math.random() * 0.2, Math.random() - 0.5), Math.random() * 1 + 1, false, 0, 0.1 + Math.random() * 0.2, 2, true); + } + + // Effect + for (Block block : UtilBlock.getInRadius(other.getLocation(), EFFECT_RADIUS).keySet()) + { + if (Math.random() < 0.98) + { + continue; + } + + if (!UtilBlock.solid(block)) + { + continue; + } + + if (!UtilBlock.airFoliage(block.getRelative(BlockFace.UP))) + { + continue; + } + + other.playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType()); + } + } + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/guardian/PerkTargetLazer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/guardian/PerkTargetLazer.java new file mode 100644 index 000000000..b90cdfd24 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/guardian/PerkTargetLazer.java @@ -0,0 +1,269 @@ +package nautilus.game.arcade.game.games.smash.perks.guardian; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + +import org.bukkit.Effect; +import org.bukkit.Material; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerInteractEvent; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilItem; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.disguise.DisguiseManager; +import mineplex.core.disguise.disguises.DisguiseGuardian; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.games.smash.perks.SmashPerk; + +public class PerkTargetLazer extends SmashPerk +{ + + private static final int COOLDOWN = 15000; + private static final int MAX_RANGE = 11; + private static final int MAX_TIME = 8000; + private static final int DAMAGE_INCREASE = 3; + private static final int KNOCKBACK_INCREASE = 1; + + private Set<TargetLazerData> _data = new HashSet<>(); + + public PerkTargetLazer() + { + super("Target Laser", new String[] { C.cYellow + "Right-Click" + C.cGray + " with Pickaxe to use " + C.cGreen + "Target Laser" }); + } + + @EventHandler + public void activate(PlayerInteractEvent event) + { + if (event.isCancelled()) + { + return; + } + + if (!UtilEvent.isAction(event, ActionType.R)) + { + return; + } + + if (UtilBlock.usable(event.getClickedBlock())) + { + return; + } + + Player player = event.getPlayer(); + + if (!UtilItem.isPickaxe(player.getItemInHand())) + { + return; + } + + if (!hasPerk(player)) + { + return; + } + + if (!UtilEnt.isGrounded(player)) + { + player.sendMessage(F.main("Game", "You must be on the ground to use " + F.skill(GetName())) + "."); + return; + } + + if (!Recharge.Instance.usable(player, GetName())) + { + return; + } + + Player best = null; + double bestD = Double.MAX_VALUE; + + for (Player other : UtilServer.getPlayers()) + { + if (player.equals(other) || UtilPlayer.isSpectator(other) || isTeamDamage(player, other)) + { + continue; + } + + double d = UtilMath.offset(player, other); + + if (d > MAX_RANGE) + { + continue; + } + + if (best == null || d < bestD) + { + best = other; + bestD = d; + } + } + + boolean contained = false; + + for (TargetLazerData data : _data) + { + if (data.getAttacker().equals(player)) + { + if (data.getTimeElapsed() < MAX_TIME) + { + return; + } + + contained = true; + data.setTarget(best); + } + } + + if (best == null) + { + player.sendMessage(F.main("Game", "There are no targets within range.")); + return; + } + + player.sendMessage(F.main("Game", "You targeted " + F.name(best.getName())) + " with " + F.skill(GetName()) + "."); + best.sendMessage(F.main("Game", F.name(player.getName()) + " targeted you with their " + F.skill(GetName()) + ".")); + + if (!contained) + { + TargetLazerData data = new TargetLazerData(player); + + _data.add(data); + data.setTarget(best); + } + + setLazerTarget(player, best); + } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() == UpdateType.TICK) + { + for (TargetLazerData data : _data) + { + data.update(Manager); + } + } + + if (event.getType() != UpdateType.FASTER) + { + return; + } + + Iterator<TargetLazerData> iterator = _data.iterator(); + + while (iterator.hasNext()) + { + TargetLazerData data = iterator.next(); + + if (data.getTarget() == null) + { + continue; + } + + UtilParticle.PlayParticle(ParticleType.MAGIC_CRIT, data.getTarget().getLocation().add(0, 0.5, 0.5), 1F, 0.5F, 1F, 0.1F, 10, ViewDist.LONG, data.getAttacker()); + + if (UtilMath.offset(data.getTarget(), data.getAttacker()) > MAX_RANGE || data.getTimeElapsed() > MAX_TIME) + { + long time = data.getTimeElapsed() / 1000; + double damage = 0.5 * time; + ArmorStand targetPlaceholder = data.update(Manager); + + targetPlaceholder.remove(); + setLazerTarget(data.getAttacker(), null); + + data.getAttacker().sendMessage(F.main("Game", "Your laser broke, dealing damage to " + F.name(data.getTarget().getName())) + "."); + Manager.GetDamage().NewDamageEvent(data.getTarget(), data.getAttacker(), null, DamageCause.CUSTOM, damage, false, true, false, data.getAttacker().getName(), GetName()); + + Recharge.Instance.use(data.getAttacker(), GetName(), COOLDOWN, true, true); + + iterator.remove(); + } + } + } + + @EventHandler + public void damage(CustomDamageEvent event) + { + if (event.GetDamagerPlayer(true) == null || event.GetDamageePlayer() == null) + { + return; + } + + Player damager = event.GetDamagerPlayer(true); + Player damagee = event.GetDamageePlayer(); + + for (TargetLazerData data : _data) + { + if (data.getTarget() == null) + { + continue; + } + + if (data.getAttacker().equals(damager) && data.getTarget().equals(damagee)) + { + event.AddMod(GetName(), DAMAGE_INCREASE); + event.AddKnockback(GetName(), KNOCKBACK_INCREASE); + data.getAttacker().playEffect(damagee.getLocation().add(0, 0.5, 0), Effect.STEP_SOUND, Material.REDSTONE_BLOCK); + } + } + } + + @EventHandler + public void death(PlayerDeathEvent event) + { + Player player = event.getEntity(); + + Iterator<TargetLazerData> iterator = _data.iterator(); + + while (iterator.hasNext()) + { + TargetLazerData data = iterator.next(); + + if (data.getTarget().equals(player) || data.getAttacker().equals(player)) + { + iterator.remove(); + } + } + } + + private void setLazerTarget(Player disguised, Player target) + { + DisguiseManager disguiseManager = Manager.GetDisguise(); + DisguiseGuardian disguise = (DisguiseGuardian) disguiseManager.getActiveDisguise(disguised); + + for (TargetLazerData data : _data) + { + if (data.getAttacker().equals(disguised)) + { + if (target == null) + { + disguise.setTarget(0); + } + else + { + disguise.setTarget(data.update(Manager).getEntityId()); + } + + disguiseManager.updateDisguise(disguise); + } + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/guardian/PerkThorns.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/guardian/PerkThorns.java new file mode 100644 index 000000000..4e1e99010 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/guardian/PerkThorns.java @@ -0,0 +1,47 @@ +package nautilus.game.arcade.game.games.smash.perks.guardian; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +import mineplex.core.common.util.C; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import nautilus.game.arcade.kit.Perk; + +public class PerkThorns extends Perk +{ + + private static final int MAX_HEALTH = 10; + private static final float DAMAGE_DECREASE = 0.66F; + private static final float KNOCKBACK_DECREASE = 0.66F; + + public PerkThorns() + { + super("Thorns", new String[] { C.cGray + "Takes 66% less damage and knockback from projectiles", C.cGray + "when under 10 health."}); + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void damage(CustomDamageEvent event) + { + if (event.GetDamagerPlayer(true) == null || event.GetCause() == DamageCause.ENTITY_ATTACK) + { + return; + } + + Player player = event.GetDamageePlayer(); + + + if (!hasPerk(player)) + { + return; + } + + if (player.getHealth() < MAX_HEALTH) + { + event.AddMult(GetName(), null, DAMAGE_DECREASE, false); + event.AddKnockback(GetName(), KNOCKBACK_DECREASE); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/guardian/PerkWaterSplash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/guardian/PerkWaterSplash.java new file mode 100644 index 000000000..653344a77 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/guardian/PerkWaterSplash.java @@ -0,0 +1,193 @@ +package nautilus.game.arcade.game.games.smash.perks.guardian; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; + +import org.bukkit.Effect; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilItem; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import nautilus.game.arcade.game.games.smash.TeamSuperSmash; +import nautilus.game.arcade.kit.Perk; + +public class PerkWaterSplash extends Perk +{ + + private static final int COOLDOWN = 12000; + private static final int VELOCITY_Y = 1; + private static final int RADIUS = 5; + private static final int MIN_AIR_TIME = 750; + private static final int SECOND_BOOST_TIME = 800; + private static final int DAMAGE = 12; + + private Map<UUID, Long> _active = new HashMap<>(); + private Set<UUID> _usedSecondBoost = new HashSet<>(); + + public PerkWaterSplash() + { + super("Water Splash", new String[] { C.cYellow + "Right-Click" + C.cGray + " with Sword to use " + C.cGreen + "Water Splash", C.cYellow + "Hold Block" + C.cGray + " to " + C.cGreen + "Bounce higher with Water Splash" }); + } + + @EventHandler + public void activate(PlayerInteractEvent event) + { + if (event.isCancelled()) + { + return; + } + + if (!UtilEvent.isAction(event, ActionType.R)) + { + return; + } + + if (UtilBlock.usable(event.getClickedBlock())) + { + return; + } + + Player player = event.getPlayer(); + + if (!UtilItem.isSword(player.getItemInHand())) + { + return; + } + + if (!hasPerk(player)) + { + return; + } + + if (!Recharge.Instance.use(player, GetName(), COOLDOWN, true, true)) + { + return; + } + + UtilAction.velocity(player, new Vector(0, VELOCITY_Y, 0)); + _active.put(player.getUniqueId(), System.currentTimeMillis()); + + List<Player> team = TeamSuperSmash.getTeam(Manager, player, true); + for (Player other : UtilPlayer.getNearby(player.getLocation(), RADIUS)) + { + if (team.contains(other)) + { + continue; + } + + UtilAction.velocity(other, UtilAlg.getTrajectory(other, player).setY(0.5)); + } + } + + @EventHandler + public void damage(CustomDamageEvent event) + { + if (_active.containsKey(event.GetDamageeEntity().getUniqueId())) + { + event.SetKnockback(false); + } + } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + Iterator<UUID> iterator = _active.keySet().iterator(); + + while (iterator.hasNext()) + { + UUID uuid = iterator.next(); + Player player = UtilPlayer.searchExact(uuid); + + if (player == null) + { + continue; + } + + if (UtilPlayer.isSpectator(player)) + { + iterator.remove(); + _usedSecondBoost.remove(uuid); + continue; + } + + UtilParticle.PlayParticleToAll(ParticleType.DRIP_WATER, player.getLocation(), 0.5F, 0.5F, 0.5F, 0.01F, 10, ViewDist.LONG); + + if (UtilEnt.isGrounded(player) && UtilTime.elapsed(_active.get(uuid), MIN_AIR_TIME)) + { + iterator.remove(); + _usedSecondBoost.remove(uuid); + + UtilParticle.PlayParticleToAll(ParticleType.FIREWORKS_SPARK, player.getEyeLocation(), 0, 0, 0, 0.5F, 50, ViewDist.LONG); + + for (Block block : UtilBlock.getInRadius(player.getLocation(), RADIUS).keySet()) + { + if (Math.random() > 0.5) + { + continue; + } + + block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType()); + } + + player.getWorld().playSound(player.getLocation(), Sound.SPLASH2, 2, 0); + + Map<Player, Double> nearby = UtilPlayer.getInRadius(player.getLocation(), RADIUS); + + List<Player> team = TeamSuperSmash.getTeam(Manager, player, true); + for (Player other : nearby.keySet()) + { + if (team.contains(other)) + { + continue; + } + + double power = nearby.get(other); + + Manager.GetDamage().NewDamageEvent(other, player, null, DamageCause.CUSTOM, DAMAGE * power, true, true, false, player.getName(), GetName()); + Manager.GetCondition().Factory().Falling(GetName(), other, player, DAMAGE, false, true); + } + } + else if (UtilTime.elapsed(_active.get(uuid), SECOND_BOOST_TIME) && !_usedSecondBoost.contains(uuid) && player.isBlocking()) + { + _usedSecondBoost.add(uuid); + + Vector direction = player.getLocation().getDirection().setY(0.2); + + UtilAction.velocity(player, direction); + } + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/guardian/PerkWhirlpoolBlade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/guardian/PerkWhirlpoolBlade.java new file mode 100644 index 000000000..e738a721a --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/guardian/PerkWhirlpoolBlade.java @@ -0,0 +1,153 @@ +package nautilus.game.arcade.game.games.smash.perks.guardian; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.entity.Item; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilItem; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.projectile.IThrown; +import mineplex.core.projectile.ProjectileUser; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import nautilus.game.arcade.kit.Perk; + +public class PerkWhirlpoolBlade extends Perk implements IThrown +{ + + private static final int COOLDOWN = 5000; + private static final int EXPIRE_TIME = 3000; + private static final float VELOCITY = 1.6F; + private static final float HIT_BOX = 0.5F; + private static final int DAMAGE = 5; + + private Set<Item> _items = new HashSet<>(); + + public PerkWhirlpoolBlade() + { + super("Whirlpool Axe", new String[] { C.cYellow + "Right-Click" + C.cGray + " with Axe to use " + C.cGreen + "Whirlpool Axe" }); + } + + @EventHandler + public void activate(PlayerInteractEvent event) + { + if (event.isCancelled()) + { + return; + } + + if (!UtilEvent.isAction(event, ActionType.R)) + { + return; + } + + if (UtilBlock.usable(event.getClickedBlock())) + { + return; + } + + Player player = event.getPlayer(); + + if (!UtilItem.isAxe(player.getItemInHand())) + { + return; + } + + if (!hasPerk(player)) + { + return; + } + + if (!Recharge.Instance.use(player, GetName(), COOLDOWN, true, true)) + { + return; + } + + player.playSound(player.getLocation(), Sound.DIG_SNOW, 1, 1); + + Item item = player.getWorld().dropItem(player.getEyeLocation(), new ItemStack(Material.PRISMARINE_SHARD)); + + item.setVelocity(player.getLocation().getDirection().multiply(VELOCITY)); + Manager.GetProjectile().AddThrow(item, player, this, EXPIRE_TIME, true, true, true, false, false, HIT_BOX); + _items.add(item); + } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + Iterator<Item> iterator = _items.iterator(); + + while (iterator.hasNext()) + { + Item item = iterator.next(); + + if (!item.isValid()) + { + iterator.remove(); + continue; + } + + UtilParticle.PlayParticleToAll(ParticleType.DRIP_WATER, item.getLocation(), 0, 0, 0, 0.01F, 1, ViewDist.LONG); + } + } + + @Override + public void Collide(LivingEntity target, Block block, ProjectileUser data) + { + if (!UtilBlock.airFoliage(block)) + { + data.getThrown().remove(); + } + + if (target == null) + { + return; + } + + CustomDamageEvent event = Manager.GetDamage().NewDamageEvent(target, data.getThrower(), null, DamageCause.CUSTOM, DAMAGE, false, true, true, data.getThrower().getName(), GetName()); + if(event.IsCancelled()) + { + return; + } + UtilAction.velocity(target, UtilAlg.getTrajectory(target, data.getThrower()).setY(0.5)); + } + + @Override + public void Idle(ProjectileUser data) + { + data.getThrown().remove(); + } + + @Override + public void Expire(ProjectileUser data) + { + data.getThrown().remove(); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/guardian/SmashAnimationData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/guardian/SmashAnimationData.java new file mode 100644 index 000000000..e891ca5cf --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/guardian/SmashAnimationData.java @@ -0,0 +1,194 @@ +package nautilus.game.arcade.game.games.smash.perks.guardian; + +import java.util.List; +import java.util.Map; +import java.util.Random; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.util.Vector; + +import mineplex.core.blockrestore.BlockRestore; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.particles.effects.LineParticle; +import mineplex.core.disguise.DisguiseManager; +import mineplex.core.disguise.disguises.DisguiseGuardian; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.smash.TeamSuperSmash; + +public class SmashAnimationData +{ + + private static final double THETA_INCREMENTATION = Math.PI / 20; + private static final int RADIUS = 3; + private static final int DAMAGE_RADIUS = 11; + private static final int VELOCITY_DAMAGE = 2; + private static final int Y_INCREASE = 7; + + private ArcadeManager _manager; + private Player _player; + private ArmorStand _elder; + private ArmorStand[] _guardians; + private ArmorStand _target; + + private double _lastTheta; + private double _thetaSpacing; + + private int _blockRadius; + private int _duration; + private int _ticks; + + public SmashAnimationData(ArcadeManager manager, Player player, int guardians, int duration) + { + _manager = manager; + _player = player; + _thetaSpacing = 2 * Math.PI / guardians; + _duration = duration; + + DisguiseManager disguiseManager = manager.GetDisguise(); + Location location = player.getLocation().add(0, Y_INCREASE, 0); + ArmorStand target = player.getWorld().spawn(player.getLocation(), ArmorStand.class); + + target.setArms(false); + target.setSmall(true); + target.setBasePlate(false); + target.setGravity(false); + target.setVisible(false); + + _target = target; + + _elder = player.getWorld().spawn(location, ArmorStand.class); + _elder.setGravity(false); + + DisguiseGuardian disguiseElder = new DisguiseGuardian(_elder); + disguiseElder.setElder(true); + disguiseElder.setTarget(target.getEntityId()); + disguiseManager.disguise(disguiseElder); + + _guardians = new ArmorStand[guardians]; + + for (int i = 0; i < guardians; i++) + { + ArmorStand guardian = player.getWorld().spawn(location, ArmorStand.class); + + guardian.setGravity(false); + + DisguiseGuardian disguise = new DisguiseGuardian(guardian); + disguise.setTarget(target.getEntityId()); + disguiseManager.disguise(disguise); + + _guardians[i] = guardian; + + } + } + + @SuppressWarnings("deprecation") + public void update() + { + _ticks++; + + if (_ticks % 10 == 0) + { + _blockRadius++; + + BlockRestore blockRestore = _manager.GetBlockRestore(); + Map<Block, Double> inRadius = UtilBlock.getInRadius(_target.getLocation().getBlock(), _blockRadius, true); + Random random = new Random(); + + for (Block block : inRadius.keySet()) + { + if (blockRestore.contains(block) || UtilBlock.airFoliage(block) || UtilBlock.liquid(block)) + { + continue; + } + + blockRestore.add(block, Material.PRISMARINE.getId(), (byte) random.nextInt(3), (long) (_duration + 5000 * Math.random())); + } + + List<Player> team = TeamSuperSmash.getTeam(_manager, _player, true); + for (Player player : UtilPlayer.getNearby(_target.getLocation(), DAMAGE_RADIUS)) + { + if (team.contains(player)) + { + continue; + } + + double offset = UtilMath.offset(_target, player); + Vector vector = UtilAlg.getTrajectory(player, _target); + + if (offset < DAMAGE_RADIUS / 3) + { + continue; + } + + LineParticle lineParticle = new LineParticle(player.getEyeLocation(), _target.getEyeLocation(), vector, 0.2, offset, null, ParticleType.WITCH_MAGIC, UtilServer.getPlayers()); + + while (!lineParticle.update()) + { + } + + player.getWorld().playSound(player.getLocation(), Sound.ZOMBIE_REMEDY, 1, 0.75F); + UtilAction.velocity(player, vector.setY(player.getLocation().getY() - 3 > _target.getLocation().getY() ? 0 : 0.5).multiply(0.5)); + _manager.GetDamage().NewDamageEvent(player, _player, null, DamageCause.CUSTOM, VELOCITY_DAMAGE, false, true, false, _player.getName(), "Mini Guardian"); + } + } + + Location center = _target.getLocation().add(0, Y_INCREASE, 0); + int i = 0; + + //Teleport the elder guardian around in a circle + { + double x = Math.cos(_lastTheta); + double z = Math.sin(_lastTheta); + + center.add(x, 0, z); + _elder.teleport(center); + center.subtract(x, 0, z); + } + + //Teleport all guardians around in a circle + for (ArmorStand guardian : _guardians) + { + double theta = _lastTheta + _thetaSpacing * i++; + double x = RADIUS * Math.cos(theta); + double z = RADIUS * Math.sin(theta); + + center.add(x, 0, z); + guardian.teleport(center); + center.subtract(x, 0, z); + } + + _lastTheta += THETA_INCREMENTATION; + } + + public Player getPlayer() + { + return _player; + } + + public ArmorStand getElder() + { + return _elder; + } + + public ArmorStand[] getGuardians() + { + return _guardians; + } + + public ArmorStand getTarget() + { + return _target; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/guardian/SmashGuardian.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/guardian/SmashGuardian.java new file mode 100644 index 000000000..78e133ba2 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/guardian/SmashGuardian.java @@ -0,0 +1,123 @@ +package nautilus.game.arcade.game.games.smash.perks.guardian; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.bukkit.Sound; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +import nautilus.game.arcade.game.games.smash.TeamSuperSmash; +import nautilus.game.arcade.game.games.smash.perks.SmashUltimate; + +public class SmashGuardian extends SmashUltimate +{ + + private static final int DURATION = 10000; + private static final int GUARDIANS = 4; + private static final int RADIUS = 15; + private static final int DAMAGE = 40; + + private Set<SmashAnimationData> _data = new HashSet<>(); + + public SmashGuardian() + { + super("Rise of the Guardian", new String[] {}, Sound.AMBIENCE_THUNDER, DURATION); + } + + @Override + public void activate(Player player) + { + super.activate(player); + + Manager.GetGame().CreatureAllowOverride = true; + + _data.add(new SmashAnimationData(Manager, player, GUARDIANS, DURATION)); + + Manager.GetGame().CreatureAllowOverride = false; + } + + @Override + public void cancel(Player player) + { + super.cancel(player); + + Iterator<SmashAnimationData> iterator = _data.iterator(); + + while (iterator.hasNext()) + { + SmashAnimationData data = iterator.next(); + + if (data.getPlayer().equals(player)) + { + Map<Player, Double> inRadius = UtilPlayer.getInRadius(data.getTarget().getLocation(), RADIUS); + List<Player> team = TeamSuperSmash.getTeam(Manager, player, true); + for (Player other : inRadius.keySet()) + { + if (team.contains(other)) + { + continue; + } + + Manager.GetDamage().NewDamageEvent(other, player, null, DamageCause.CUSTOM, DAMAGE * inRadius.get(other), true, true, false, player.getName(), GetName()); + } + + data.getTarget().getWorld().strikeLightningEffect(data.getTarget().getLocation()); + UtilParticle.PlayParticleToAll(ParticleType.HUGE_EXPLOSION, data.getTarget().getLocation().add(0, 2, 0), RADIUS, 1, RADIUS, 1F, 30, ViewDist.MAX); + player.getWorld().playSound(data.getTarget().getLocation(), Sound.EXPLODE, 5, 0.5F); + + data.getElder().remove(); + data.getTarget().remove(); + + for (ArmorStand guardian : data.getGuardians()) + { + guardian.remove(); + } + + iterator.remove(); + } + } + } + + @Override + public boolean isUsable(Player player) + { + boolean grounded = UtilEnt.isGrounded(player); + + if (!grounded) + { + player.sendMessage(F.main("Game", "You need to be on the ground to use " + F.skill(GetName()) + ".")); + } + + return grounded; + } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + for (SmashAnimationData data : _data) + { + data.update(); + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/guardian/TargetLazerData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/guardian/TargetLazerData.java new file mode 100644 index 000000000..f81316ce8 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/guardian/TargetLazerData.java @@ -0,0 +1,65 @@ +package nautilus.game.arcade.game.games.smash.perks.guardian; + +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.Player; + +import mineplex.core.common.util.UtilEnt; + +import nautilus.game.arcade.ArcadeManager; + +public class TargetLazerData +{ + + private Player _attacker; + private Player _target; + private long _startTime; + private ArmorStand _targetPlaceholder; + + public TargetLazerData(Player attacker) + { + _attacker = attacker; + } + + public void setTarget(Player target) + { + _target = target; + _startTime = System.currentTimeMillis(); + } + + public ArmorStand update(ArcadeManager manager) + { + if (_targetPlaceholder == null || !_targetPlaceholder.isValid()) + { + manager.GetGame().CreatureAllowOverride = true; + _targetPlaceholder = _target.getWorld().spawn(_target.getLocation(), ArmorStand.class); + _targetPlaceholder.setArms(false); + _targetPlaceholder.setSmall(true); + _targetPlaceholder.setBasePlate(false); + _targetPlaceholder.setGravity(false); + _targetPlaceholder.setVisible(false); + + UtilEnt.ghost(_targetPlaceholder, true, true); + + manager.GetGame().CreatureAllowOverride = false; + } + + _targetPlaceholder.teleport(_target.getLocation().add(0, 0.25, 0)); + return _targetPlaceholder; + } + + public Player getAttacker() + { + return _attacker; + } + + public Player getTarget() + { + return _target; + } + + public long getTimeElapsed() + { + return System.currentTimeMillis() - _startTime; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFlameDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/magmacube/PerkFlameDash.java similarity index 67% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFlameDash.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/magmacube/PerkFlameDash.java index 969e5120b..f8030aaeb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFlameDash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/magmacube/PerkFlameDash.java @@ -1,12 +1,12 @@ -package nautilus.game.arcade.kit.perks; +package nautilus.game.arcade.game.games.smash.perks.magmacube; import java.util.HashSet; import java.util.Iterator; +import java.util.Set; import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.block.Action; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.util.Vector; @@ -15,13 +15,16 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -31,38 +34,48 @@ import nautilus.game.arcade.kit.perks.data.FireflyData; public class PerkFlameDash extends Perk { - private HashSet<FireflyData> _data = new HashSet<FireflyData>(); + + private static final int COOLDOWN = 8000; + private static final int TIME = 800; + private static final int DAMAGE_RADIUS = 3; + private static final int KNOCKBACK_MAGNITUDE = 2; + + private Set<FireflyData> _data = new HashSet<FireflyData>(); - public PerkFlameDash() + public PerkFlameDash() { - super("Flame Dash", new String[] - { - C.cYellow + "Right-Click" + C.cGray + " with Spade to use " + C.cGreen + "Flame Dash" - }); + super("Flame Dash", new String[] { C.cYellow + "Right-Click" + C.cGray + " with Spade to use " + C.cGreen + "Flame Dash" }); } @EventHandler public void Skill(PlayerInteractEvent event) { if (event.isCancelled()) + { return; + } - if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) + if (!UtilEvent.isAction(event, ActionType.R)) + { return; + } if (UtilBlock.usable(event.getClickedBlock())) + { return; - - if (event.getPlayer().getItemInHand() == null) - return; - - if (!event.getPlayer().getItemInHand().getType().toString().contains("_SPADE")) - return; + } Player player = event.getPlayer(); - if (!Kit.HasKit(player)) + if (!UtilItem.isSpade(player.getItemInHand())) + { return; + } + + if (!hasPerk(player)) + { + return; + } if (!Recharge.Instance.usable(player, GetName())) { @@ -75,7 +88,7 @@ public class PerkFlameDash extends Perk done = true; } } - + if (done) { UtilPlayer.message(player, F.main("Skill", "You ended " + F.skill(GetName()) + ".")); @@ -83,18 +96,18 @@ public class PerkFlameDash extends Perk } else { - Recharge.Instance.use(player, GetName(), 8000, true, true); + Recharge.Instance.use(player, GetName(), COOLDOWN, true, true); } - + return; } - Recharge.Instance.useForce(player, GetName(), 8000); + Recharge.Instance.recharge(player, GetName()); + Recharge.Instance.use(player, GetName(), COOLDOWN, true, true); _data.add(new FireflyData(player)); Manager.GetCondition().Factory().Cloak(GetName(), player, player, 2.5, false, false); - //Manager.GetCondition().Factory().Invisible(getName(), player, player, 2.5, 0, false, false, true); UtilPlayer.message(player, F.main("Skill", "You used " + F.skill(GetName()) + ".")); } @@ -116,9 +129,8 @@ public class PerkFlameDash extends Perk { FireflyData data = dataIterator.next(); - - //Move - if (!UtilTime.elapsed(data.Time, 800)) + // Move + if (!UtilTime.elapsed(data.Time, TIME)) { Vector vel = data.Location.getDirection(); vel.setY(0); @@ -126,58 +138,59 @@ public class PerkFlameDash extends Perk vel.setY(0.05); UtilAction.velocity(data.Player, vel); - - //Sound + + // Sound data.Player.getWorld().playSound(data.Player.getLocation(), Sound.FIZZ, 0.6f, 1.2f); - - //Particles - UtilParticle.PlayParticle(ParticleType.FLAME, data.Player.getLocation().add(0, 0.4, 0), 0.2f, 0.2f, 0.2f, 0f, 3, - ViewDist.LONGER, UtilServer.getPlayers()); + + // Particles + UtilParticle.PlayParticle(ParticleType.FLAME, data.Player.getLocation().add(0, 0.4, 0), 0.2f, 0.2f, 0.2f, 0f, 3, ViewDist.LONGER, UtilServer.getPlayers()); } - //End + // End else { - for (Player other : UtilPlayer.getNearby(data.Player.getLocation(), 3)) + for (Player other : UtilPlayer.getNearby(data.Player.getLocation(), DAMAGE_RADIUS)) { if (other.equals(data.Player)) + { continue; - - if (!Manager.GetGame().IsAlive(other)) - continue; + } - double dist = UtilMath.offset(data.Player.getLocation(), data.Location)/2d; + if (UtilPlayer.isSpectator(other)) + { + continue; + } + + double dist = UtilMath.offset(data.Player.getLocation(), data.Location) / 2; - //Damage Event - Manager.GetDamage().NewDamageEvent(other, data.Player, null, - DamageCause.CUSTOM, 2 + dist, true, true, false, - data.Player.getName(), GetName()); + // Damage Event + Manager.GetDamage().NewDamageEvent(other, data.Player, null, DamageCause.CUSTOM, 2 + dist, true, true, false, data.Player.getName(), GetName()); UtilPlayer.message(other, F.main("Game", F.elem(Manager.GetColor(data.Player) + data.Player.getName()) + " hit you with " + F.elem(GetName()) + ".")); } - //End Invisible + // End Invisible Manager.GetCondition().EndCondition(data.Player, null, GetName()); - //Sound + // Sound data.Player.getWorld().playSound(data.Player.getLocation(), Sound.EXPLODE, 1f, 1.2f); - - //Particles - UtilParticle.PlayParticle(ParticleType.FLAME, data.Player.getLocation(), 0.1f, 0.1f, 0.1f, 0.3f, 100, - ViewDist.MAX, UtilServer.getPlayers()); - UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, data.Player.getLocation().add(0, 0.4, 0), 0.2f, 0.2f, 0.2f, 0f, 1, - ViewDist.MAX, UtilServer.getPlayers()); + + // Particles + UtilParticle.PlayParticle(ParticleType.FLAME, data.Player.getLocation(), 0.1f, 0.1f, 0.1f, 0.3f, 100, ViewDist.MAX, UtilServer.getPlayers()); + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, data.Player.getLocation().add(0, 0.4, 0), 0.2f, 0.2f, 0.2f, 0f, 1, ViewDist.MAX, UtilServer.getPlayers()); dataIterator.remove(); } - } + } } @EventHandler public void Knockback(CustomDamageEvent event) { if (event.GetReason() == null || !event.GetReason().contains(GetName())) + { return; - - event.AddKnockback(GetName(), 2); + } + + event.AddKnockback(GetName(), KNOCKBACK_MAGNITUDE); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkMagmaBlast.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/magmacube/PerkMagmaBlast.java similarity index 51% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkMagmaBlast.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/magmacube/PerkMagmaBlast.java index 339dd0a7c..036734ecd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkMagmaBlast.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/magmacube/PerkMagmaBlast.java @@ -1,7 +1,11 @@ -package nautilus.game.arcade.kit.perks; +package nautilus.game.arcade.game.games.smash.perks.magmacube; import java.util.HashMap; import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import net.minecraft.server.v1_8_R3.EntityLargeFireball; import org.bukkit.Location; import org.bukkit.Sound; @@ -10,7 +14,7 @@ import org.bukkit.entity.LargeFireball; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; import org.bukkit.event.EventHandler; -import org.bukkit.event.block.Action; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.util.Vector; @@ -20,109 +24,125 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilItem; +import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import nautilus.game.arcade.game.games.smash.TeamSuperSmash; import nautilus.game.arcade.kit.Perk; -import net.minecraft.server.v1_8_R3.EntityLargeFireball; public class PerkMagmaBlast extends Perk { - public HashMap<LargeFireball, Location> _proj = new HashMap<LargeFireball, Location>(); - public PerkMagmaBlast() - { - super("Magma Blast", new String[] - { - C.cYellow + "Right-Click" + C.cGray + " with Axe to use " + C.cGreen + "Magma Blast" - }); - } + private static final int COOLDOWN = 6000; + private static final float FIREBALL_VELOCITY = 0.2F; + private static final int FIRE_TICKS = 40; + private static final int VELOCITY_RADIUS = 8; + private static final int FIRE_RADIUS = 2; + private static final int DAMAGE = 8; + + + private Map<LargeFireball, Location> _proj = new HashMap<>(); + public PerkMagmaBlast() + { + super("Magma Blast", new String[] { C.cYellow + "Right-Click" + C.cGray + " with Axe to use " + C.cGreen + "Magma Blast" }); + } @EventHandler public void Shoot(PlayerInteractEvent event) { if (event.isCancelled()) + { return; + } - if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) + if (!UtilEvent.isAction(event, ActionType.R)) + { return; + } if (UtilBlock.usable(event.getClickedBlock())) + { return; - - if (event.getPlayer().getItemInHand() == null) - return; - - if (!event.getPlayer().getItemInHand().getType().toString().contains("_AXE")) - return; + } Player player = event.getPlayer(); - if (!Kit.HasKit(player)) + if (!UtilItem.isAxe(player.getItemInHand())) + { return; + } - if (!Recharge.Instance.use(player, GetName(), 6000, true, true)) + if (!hasPerk(player)) + { return; + } + if (!Recharge.Instance.use(player, GetName(), COOLDOWN, true, true)) + { + return; + } + event.setCancelled(true); - //Action + // Action LargeFireball ball = player.launchProjectile(LargeFireball.class); ball.setShooter(player); - ball.setIsIncendiary(false); + ball.setIsIncendiary(false); ball.setYield(0); ball.setBounce(false); ball.teleport(player.getEyeLocation().add(player.getLocation().getDirection().multiply(1))); - - //ball.setVelocity(new Vector(0,0,0)); - - Vector dir = player.getLocation().getDirection().multiply(0.2); - + + Vector dir = player.getLocation().getDirection().multiply(FIREBALL_VELOCITY); + EntityLargeFireball eFireball = ((CraftLargeFireball) ball).getHandle(); eFireball.dirX = dir.getX(); eFireball.dirY = dir.getY(); eFireball.dirZ = dir.getZ(); - - //Knockback + + // Knockback UtilAction.velocity(player, player.getLocation().getDirection().multiply(-1), 1.2, false, 0, 0.2, 1.2, true); - - //Add + + // Add _proj.put(ball, player.getLocation()); - //Inform + // Inform UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + ".")); - //Effect + // Effect player.getWorld().playSound(player.getLocation(), Sound.CREEPER_DEATH, 2f, 1.5f); } - + @EventHandler - public void Update(UpdateEvent event) + public void Update(UpdateEvent event) { if (event.getType() != UpdateType.TICK) + { return; - - Iterator<LargeFireball> projIterator = _proj.keySet().iterator(); + } + Iterator<LargeFireball> projIterator = _proj.keySet().iterator(); + while (projIterator.hasNext()) { LargeFireball proj = projIterator.next(); - + if (!proj.isValid()) { projIterator.remove(); proj.remove(); continue; } - -// proj.setDirection(_proj.get(proj).clone().getDirection()); -// proj.setVelocity(_proj.get(proj).clone().getDirection().multiply(0.6)); } } @@ -130,29 +150,81 @@ public class PerkMagmaBlast extends Perk public void Collide(ProjectileHitEvent event) { Projectile proj = event.getEntity(); - + if (!_proj.containsKey(proj)) + { return; - - if (proj.getShooter() == null) - return; - - if (!(proj.getShooter() instanceof Player)) - return; - - //Velocity Players - HashMap<Player,Double> hitMap = UtilPlayer.getInRadius(proj.getLocation(), 8); - for (Player cur : hitMap.keySet()) - { - double range = hitMap.get(cur); - - //Velocity - UtilAction.velocity(cur, UtilAlg.getTrajectory(proj.getLocation().add(0, -0.5, 0), cur.getEyeLocation()), - 1 + 2 * range, false, 0, 0.2 + 0.4 * range, 1.2, true); } - //Particles - UtilParticle.PlayParticle(ParticleType.LAVA, proj.getLocation(), 0.1f, 0.1f, 0.1f, 0.1f, 50, - ViewDist.LONG, UtilServer.getPlayers()); + if (proj.getShooter() == null) + { + return; + } + + if (!(proj.getShooter() instanceof Player)) + { + return; + } + + Player shooter = (Player) proj.getShooter(); + // Velocity Players + Map<Player, Double> hitMap = UtilPlayer.getInRadius(proj.getLocation(), VELOCITY_RADIUS); + + List<Player> team = TeamSuperSmash.getTeam(Manager, shooter, false); + for (Player cur : hitMap.keySet()) + { + if(team.contains(cur)) + { + { + continue; + } + } + + double range = hitMap.get(cur); + + Manager.GetDamage().NewDamageEvent(cur, shooter, proj, DamageCause.PROJECTILE, range * DAMAGE, false, true, false, shooter.getName(), GetName()); + + // Velocity + UtilAction.velocity(cur, UtilAlg.getTrajectory(proj.getLocation().add(0, -0.5, 0), cur.getEyeLocation()), 1 + 2 * range, false, 0, 0.2 + 0.4 * range, 1.2, true); + } + + // Particles + UtilParticle.PlayParticleToAll(ParticleType.LAVA, proj.getLocation(), 0.1f, 0.1f, 0.1f, 0.1f, 50, ViewDist.LONG); + } + + @EventHandler + public void damage(CustomDamageEvent event) + { + if (event.GetProjectile() == null || event.GetDamageeEntity() == null) + { + return; + } + + Projectile proj = event.GetProjectile(); + + if (!(proj instanceof LargeFireball)) + { + return; + } + + if (!_proj.containsKey(proj)) + { + return; + } + + Player player = event.GetDamageePlayer(); + if(proj.getShooter() instanceof Player) + { + Player shooter = (Player) proj.getShooter(); + if(TeamSuperSmash.getTeam(Manager, shooter, true).contains(player)) + { + return; + } + } + + if (UtilMath.offset(player, proj) < FIRE_RADIUS) + { + player.setFireTicks(FIRE_TICKS); + } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/magmacube/PerkMagmaBoost.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/magmacube/PerkMagmaBoost.java new file mode 100644 index 000000000..3e817de76 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/magmacube/PerkMagmaBoost.java @@ -0,0 +1,181 @@ +package nautilus.game.arcade.game.games.smash.perks.magmacube; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.disguise.disguises.DisguiseMagmaCube; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import nautilus.game.arcade.kit.Perk; + +public class PerkMagmaBoost extends Perk +{ + + private static final int MAX_STACKS = 3; + + private Map<UUID, Integer> _kills = new HashMap<>(); + + public PerkMagmaBoost() + { + super("Fuel the Fire", new String[] { C.cGray + "Kills give +1 Damage, -15% Knockback Taken and +1 Size.", C.cGray + "Kill bonuses can stack " + MAX_STACKS + " times, and reset on death.", }); + } + + @EventHandler + public void kill(CombatDeathEvent event) + { + Player killed = (Player) event.GetEvent().getEntity(); + + _kills.remove(killed.getUniqueId()); + + if (event.GetLog().GetKiller() == null) + { + return; + } + + Player killer = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName()); + + if (killer == null || killer.equals(killed) || !hasPerk(killer)) + { + return; + } + + DisguiseMagmaCube slime = (DisguiseMagmaCube) Manager.GetDisguise().getActiveDisguise(killer); + UUID key = killer.getUniqueId(); + + if (slime == null) + { + return; + } + + int size = 1; + + if (_kills.containsKey(key)) + { + size += _kills.get(key); + } + + size = Math.min(MAX_STACKS, size); + + _kills.put(key, size); + + slime.SetSize(size + 1); + Manager.GetDisguise().updateDisguise(slime); + + killer.setExp(0.99F * (size / (float) MAX_STACKS)); + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void sizeDamage(CustomDamageEvent event) + { + if (event.IsCancelled()) + { + return; + } + + if (event.GetCause() != DamageCause.ENTITY_ATTACK) + { + return; + } + + Player damager = event.GetDamagerPlayer(false); + + if (damager == null) + { + return; + } + + if (!hasPerk(damager)) + { + return; + } + + UUID key = damager.getUniqueId(); + + if (!_kills.containsKey(key)) + { + return; + } + + event.AddMod(damager.getName(), GetName(), _kills.get(key), false); + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void sizeKnockback(CustomDamageEvent event) + { + if (event.IsCancelled()) + { + return; + } + + if (event.GetCause() != DamageCause.ENTITY_ATTACK) + { + return; + } + + Player damagee = event.GetDamageePlayer(); + + if (damagee == null) + { + return; + } + if (!hasPerk(damagee)) + { + return; + } + + if (!_kills.containsKey(damagee.getUniqueId())) + { + return; + } + + int bonus = _kills.get(damagee.getUniqueId()); + + event.AddKnockback(GetName(), bonus * 0.15d); + } + + @EventHandler + public void energyUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTER) + { + return; + } + + for (Player player : UtilServer.getPlayers()) + { + if (!hasPerk(player)) + { + continue; + } + + float size = 0; + + if (_kills.containsKey(player.getUniqueId())) + { + size += _kills.get(player.getUniqueId()); + } + + playParticles(player, size); + } + } + + private void playParticles(Player player, float size) + { + UtilParticle.PlayParticleToAll(ParticleType.LAVA, player.getLocation().add(0, 0.4, 0), 0.15f + 0.15f * size, 0.15f + 0.15f * size, 0.15f + 0.15f * size, 0, 1, ViewDist.LONG); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/magmacube/SmashMagmacube.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/magmacube/SmashMagmacube.java new file mode 100644 index 000000000..5f2a61ba2 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/magmacube/SmashMagmacube.java @@ -0,0 +1,56 @@ +package nautilus.game.arcade.game.games.smash.perks.magmacube; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.games.smash.perks.SmashUltimate; +import nautilus.game.arcade.kit.perks.data.MeteorShowerData; + +public class SmashMagmacube extends SmashUltimate +{ + + private static final int DURATION = 12000; + + private List<MeteorShowerData> _meteors = new ArrayList<>(); + + public SmashMagmacube() + { + super("Meteor Shower", new String[] {}, Sound.AMBIENCE_THUNDER, 0); + } + + @Override + public void activate(Player player) + { + _meteors.add(new MeteorShowerData(player, UtilPlayer.getTarget(player, UtilBlock.blockPassSet, 128).getLocation(), DURATION)); + } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + Iterator<MeteorShowerData> meteorIter = _meteors.iterator(); + + while (meteorIter.hasNext()) + { + MeteorShowerData data = meteorIter.next(); + + if (data.update()) + { + meteorIter.remove(); + } + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPigBaconBomb.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/pig/PerkPigBaconBomb.java similarity index 55% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPigBaconBomb.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/pig/PerkPigBaconBomb.java index ba3a225c8..9e863f0a0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPigBaconBomb.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/pig/PerkPigBaconBomb.java @@ -1,16 +1,17 @@ -package nautilus.game.arcade.kit.perks; +package nautilus.game.arcade.game.games.smash.perks.pig; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; -import java.util.WeakHashMap; +import java.util.Map; +import java.util.Set; +import java.util.UUID; import org.bukkit.Sound; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Pig; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.block.Action; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.util.Vector; @@ -20,158 +21,195 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguisePigZombie; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import nautilus.game.arcade.kit.SmashPerk; +import nautilus.game.arcade.game.games.smash.perks.SmashPerk; public class PerkPigBaconBomb extends SmashPerk { - private WeakHashMap<Player, HashSet<Pig>> _pigs = new WeakHashMap<Player, HashSet<Pig>>(); - public PerkPigBaconBomb() + private static final float ENERGY_PER_PIG = 0.35F; + private static final float ENERGY_PER_PIG_DISGUISED_FACTOR = 0.7F; + private static final int COOLDOWN = 100; + private static final int PIG_MAX_TICKS = 80; + private static final float PIG_SPEED = 1.2F; + private static final int PIG_EXPLODE_RADIUS = 2; + private static final int PIG_EXPLODE_DAMAGE = 4; + private static final int PIG_EXPLODE_DAMAGE_RADIUS = 4; + + private Map<UUID, Set<Pig>> _pigs = new HashMap<UUID, Set<Pig>>(); + + public PerkPigBaconBomb() { - super("Baby Bacon Bomb", new String[] - { - C.cYellow + "Right-Click" + C.cGray + " with Spade to " + C.cGreen + "Baby Bacon Bomb" - }); + super("Baby Bacon Bomb", new String[] { C.cYellow + "Right-Click" + C.cGray + " with Spade to " + C.cGreen + "Baby Bacon Bomb" }); } - - + @EventHandler public void Skill(PlayerInteractEvent event) { if (event.isCancelled()) + { return; + } - if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) + if (!UtilEvent.isAction(event, ActionType.R)) + { return; + } if (UtilBlock.usable(event.getClickedBlock())) + { return; - - if (event.getPlayer().getItemInHand() == null) - return; - - if (!event.getPlayer().getItemInHand().getType().toString().contains("_SPADE")) - return; + } Player player = event.getPlayer(); - if (!Kit.HasKit(player)) + if (!UtilItem.isSpade(player.getItemInHand())) + { return; - - float energy = 0.30f; - - DisguiseBase disguise = Manager.GetDisguise().getDisguise(player); - if (disguise != null && disguise instanceof DisguisePigZombie) - energy = energy * 0.7f; + } - //Energy + if (!hasPerk(player)) + { + return; + } + + float energy = ENERGY_PER_PIG; + + DisguiseBase disguise = Manager.GetDisguise().getActiveDisguise(player); + + if (disguise != null && disguise instanceof DisguisePigZombie) + { + energy = energy * ENERGY_PER_PIG_DISGUISED_FACTOR; + } + + // Energy if (player.getExp() < energy) { UtilPlayer.message(player, F.main("Energy", "Not enough Energy to use " + F.skill(GetName()) + ".")); return; } - - //Recharge - if (!Recharge.Instance.use(player, GetName(), 100, false, false)) + + // Recharge + if (!Recharge.Instance.use(player, GetName(), COOLDOWN, false, false)) + { return; - - //Use Energy + } + + // Use Energy player.setExp(Math.max(0f, player.getExp() - energy)); - - //Velocity - UtilAction.velocity(player, player.getLocation().getDirection(), 0.8, true, 0.9, 0, 1, true); - - //Sound + + // Velocity + UtilAction.velocity(player, player.getLocation().getDirection(), 0.8, true, 0.9, 0, 1, true); + + // Sound player.getWorld().playSound(player.getLocation(), Sound.PIG_IDLE, 2f, 0.75f); - - //Pig + + // Pig Manager.GetGame().CreatureAllowOverride = true; Pig pig = player.getWorld().spawn(player.getLocation(), Pig.class); pig.setHealth(5); pig.setVelocity(new Vector(0, -0.4, 0)); Manager.GetGame().CreatureAllowOverride = false; - + pig.setBaby(); UtilEnt.Vegetate(pig); UtilEnt.ghost(pig, true, false); + + UUID key = player.getUniqueId(); - //Store - if (!_pigs.containsKey(player)) - _pigs.put(player, new HashSet<Pig>()); + // Store + if (!_pigs.containsKey(key)) + { + _pigs.put(key, new HashSet<Pig>()); + } - _pigs.get(player).add(pig); - - //Inform + _pigs.get(key).add(pig); + + // Inform UtilPlayer.message(player, F.main("Skill", "You used " + F.skill(GetName()) + ".")); } - + @EventHandler public void Check(UpdateEvent event) { if (event.getType() != UpdateType.TICK) return; - - for (Player player : _pigs.keySet()) + + for (UUID key : _pigs.keySet()) { - Iterator<Pig> pigIterator = _pigs.get(player).iterator(); + Player player = UtilPlayer.searchExact(key); + if (player == null) + { + continue; + } + + Iterator<Pig> pigIterator = _pigs.get(key).iterator(); + while (pigIterator.hasNext()) { Pig pig = pigIterator.next(); - - if (!pig.isValid() || pig.getTicksLived() > 80) + + if (!pig.isValid() || pig.getTicksLived() > PIG_MAX_TICKS) { PigExplode(pigIterator, pig, player); continue; } + + Player target = UtilPlayer.getClosest(pig.getLocation(), player); - Player target = UtilPlayer.getClosest(pig.getLocation(), player); if (target == null) + { continue; + } - UtilEnt.CreatureMoveFast(pig, target.getLocation(), 1.2f); - - if (UtilMath.offset(target, pig) < 2) + UtilEnt.CreatureMoveFast(pig, target.getLocation(), PIG_SPEED); + + if (UtilMath.offset(target, pig) < PIG_EXPLODE_RADIUS) + { PigExplode(pigIterator, pig, player); + } } } - } - + } + public void PigExplode(Iterator<Pig> pigIterator, Pig pig, Player owner) { - //Effect - UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, pig.getLocation().add(0, 0.5, 0), 0, 0, 0, 0, 1, - ViewDist.MAX, UtilServer.getPlayers()); - - //Sound + // Effect + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, pig.getLocation().add(0, 0.5, 0), 0, 0, 0, 0, 1, ViewDist.MAX, UtilServer.getPlayers()); + + // Sound pig.getWorld().playSound(pig.getLocation(), Sound.EXPLODE, 0.6f, 2f); pig.getWorld().playSound(pig.getLocation(), Sound.PIG_DEATH, 1f, 2f); + + // Damage + Map<LivingEntity, Double> targets = UtilEnt.getInRadius(pig.getLocation(), PIG_EXPLODE_DAMAGE_RADIUS); - //Damage - HashMap<LivingEntity, Double> targets = UtilEnt.getInRadius(pig.getLocation(), 4); for (LivingEntity cur : targets.keySet()) { if (cur.equals(owner)) + { continue; - - //Damage Event - Manager.GetDamage().NewDamageEvent(cur, owner, null, - DamageCause.CUSTOM, 4 * targets.get(cur) + 2, false, true, false, - owner.getName(), GetName()); + } + + // Damage Event + Manager.GetDamage().NewDamageEvent(cur, owner, null, DamageCause.CUSTOM, PIG_EXPLODE_DAMAGE, false, true, false, owner.getName(), GetName()); } - - //Remove + + // Remove pigIterator.remove(); pig.remove(); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPigBaconBounce.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/pig/PerkPigBaconBounce.java similarity index 64% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPigBaconBounce.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/pig/PerkPigBaconBounce.java index 195717459..87e993d45 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPigBaconBounce.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/pig/PerkPigBaconBounce.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.kit.perks; +package nautilus.game.arcade.game.games.smash.perks.pig; import org.bukkit.Material; import org.bukkit.Sound; @@ -9,7 +9,6 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; -import org.bukkit.event.block.Action; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerPickupItemEvent; @@ -21,11 +20,14 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilServer; import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguisePigZombie; @@ -33,154 +35,162 @@ import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.projectile.IThrown; import mineplex.core.projectile.ProjectileUser; import mineplex.core.recharge.Recharge; -import nautilus.game.arcade.game.games.smash.TeamSuperSmash; -import nautilus.game.arcade.kit.SmashPerk; +import nautilus.game.arcade.game.games.smash.perks.SmashPerk; public class PerkPigBaconBounce extends SmashPerk implements IThrown { - public PerkPigBaconBounce() + + private static final float ENERGY_PER_BACON = 0.2F; + private static final float ENERGY_PER_BACON_DISGUISED_FACTOR = 0.7F; + private static final int COOLDOWN = 100; + private static final int HEALTH_PER_BACON = 1; + private static final int BACON_DAMAGE = 4; + + public PerkPigBaconBounce() { - super("Bouncy Bacon", new String[] - { - C.cYellow + "Right-Click" + C.cGray + " with Axe to " + C.cGreen + "Bouncy Bacon", - }); + super("Bouncy Bacon", new String[] { C.cYellow + "Right-Click" + C.cGray + " with Axe to " + C.cGreen + "Bouncy Bacon", }); } - + @EventHandler public void Skill(PlayerInteractEvent event) { if (event.isCancelled()) + { return; + } - if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) + if (!UtilEvent.isAction(event, ActionType.R)) + { return; + } if (UtilBlock.usable(event.getClickedBlock())) + { return; - - if (event.getPlayer().getItemInHand() == null) - return; - - if (!event.getPlayer().getItemInHand().getType().toString().contains("_AXE")) - return; + } Player player = event.getPlayer(); - if (!Kit.HasKit(player)) + if (!UtilItem.isAxe(player.getItemInHand())) + { return; - - float energy = 0.2f; - - DisguiseBase disguise = Manager.GetDisguise().getDisguise(player); - if (disguise != null && disguise instanceof DisguisePigZombie) - energy = energy * 0.7f; + } - //Energy + if (!hasPerk(player)) + { + return; + } + + float energy = ENERGY_PER_BACON; + + DisguiseBase disguise = Manager.GetDisguise().getActiveDisguise(player); + + if (disguise != null && disguise instanceof DisguisePigZombie) + { + energy = energy * ENERGY_PER_BACON_DISGUISED_FACTOR; + } + + // Energy if (player.getExp() < energy) { UtilPlayer.message(player, F.main("Energy", "Not enough Energy to use " + F.skill(GetName()) + ".")); return; } - - //Recharge - if (!Recharge.Instance.use(player, GetName(), 100, false, false)) + + // Recharge + if (!Recharge.Instance.use(player, GetName(), COOLDOWN, false, false)) + { return; - - //Use Energy - player.setExp(Math.max(0f, player.getExp() - energy)); + } - //Launch - Item ent = player.getWorld().dropItem(player.getEyeLocation(), ItemStackFactory.Instance.CreateStack(Material.PORK, (byte) 0, 1, "Bacon"+System.currentTimeMillis())); + // Use Energy + player.setExp(Math.max(0f, player.getExp() - energy)); + + // Launch + Item ent = player.getWorld().dropItem(player.getEyeLocation(), ItemStackFactory.Instance.CreateStack(Material.PORK, (byte) 0, 1, "Bacon" + System.currentTimeMillis())); UtilAction.velocity(ent, player.getLocation().getDirection(), 1.2, false, 0, 0.2, 10, false); Manager.GetProjectile().AddThrow(ent, player, this, -1, true, true, true, false, 0.4f); ent.setPickupDelay(9999); - - //Sound + + // Sound player.getWorld().playSound(player.getLocation(), Sound.PIG_IDLE, 2f, 1.5f); - - //Inform + + // Inform UtilPlayer.message(player, F.main("Skill", "You used " + F.skill(GetName()) + ".")); } - + @Override - public void Collide(LivingEntity target, Block block, ProjectileUser data) + public void Collide(LivingEntity target, Block block, ProjectileUser data) { Rebound(data.getThrower(), data.getThrown()); - + if (target == null) - return; - - if (Manager.GetGame() instanceof TeamSuperSmash && target instanceof Player && data.getThrower() instanceof Player) { - TeamSuperSmash smash = (TeamSuperSmash) Manager.GetGame(); - Player targetPlayer = (Player) target; - Player throwerPlayer = (Player) data.getThrower(); - - if(smash.GetTeam(targetPlayer).equals(smash.GetTeam(throwerPlayer))) - { - return; - } + return; } - //Damage Event - Manager.GetDamage().NewDamageEvent(target, data.getThrower(), null, - DamageCause.CUSTOM, 4, true, true, false, - UtilEnt.getName(data.getThrower()), GetName()); - - Item item = (Item)data.getThrown(); + // Damage Event + Manager.GetDamage().NewDamageEvent(target, data.getThrower(), null, DamageCause.CUSTOM, BACON_DAMAGE, true, true, false, UtilEnt.getName(data.getThrower()), GetName()); + + Item item = (Item) data.getThrown(); item.setItemStack(new ItemStack(Material.GRILLED_PORK)); } @Override - public void Idle(ProjectileUser data) + public void Idle(ProjectileUser data) { Rebound(data.getThrower(), data.getThrown()); } @Override - public void Expire(ProjectileUser data) + public void Expire(ProjectileUser data) { Rebound(data.getThrower(), data.getThrown()); } - + public void Rebound(LivingEntity player, Entity ent) { ent.getWorld().playSound(ent.getLocation(), Sound.ITEM_PICKUP, 1f, 0.5f); - + double mult = 0.5 + (0.035 * UtilMath.offset(player.getLocation(), ent.getLocation())); - - //Velocity + + // Velocity ent.setVelocity(player.getLocation().toVector().subtract(ent.getLocation().toVector()).normalize().add(new Vector(0, 0.4, 0)).multiply(mult)); - - //Ticks + + // Ticks if (ent instanceof Item) - ((Item)ent).setPickupDelay(5); + { + ((Item) ent).setPickupDelay(5); + } } - + @EventHandler(priority = EventPriority.LOWEST) public void Pickup(PlayerPickupItemEvent event) { - if (!Kit.HasKit(event.getPlayer())) + if (!hasPerk(event.getPlayer())) + { return; + } - if (event.getItem().getItemStack().getType() != Material.PORK && event.getItem().getItemStack().getType() != Material.GRILLED_PORK) + Material type = event.getItem().getItemStack().getType(); + + if (type != Material.PORK && type != Material.GRILLED_PORK) return; - - //Remove + + // Remove event.getItem().remove(); - - //Restore Energy + + // Restore Energy event.getPlayer().setExp(Math.min(0.999f, event.getPlayer().getExp() + 0.05f)); - - //Sound + + // Sound event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.EAT, 2f, 1f); - - //Heal + + // Heal if (event.getItem().getItemStack().getType() == Material.GRILLED_PORK) { - UtilPlayer.health(event.getPlayer(), 1); - UtilParticle.PlayParticle(ParticleType.HEART, event.getPlayer().getLocation().add(0, 0.5, 0), 0.2f, 0.2f, 0.2f, 0, 4, - ViewDist.LONG, UtilServer.getPlayers()); + UtilPlayer.health(event.getPlayer(), HEALTH_PER_BACON); + UtilParticle.PlayParticle(ParticleType.HEART, event.getPlayer().getLocation().add(0, 0.5, 0), 0.2f, 0.2f, 0.2f, 0, 4, ViewDist.LONG, UtilServer.getPlayers()); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPigZombie.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/pig/PerkPigZombie.java similarity index 57% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPigZombie.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/pig/PerkPigZombie.java index f12182cf1..306f0ed3b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPigZombie.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/pig/PerkPigZombie.java @@ -1,6 +1,8 @@ -package nautilus.game.arcade.kit.perks; +package nautilus.game.arcade.game.games.smash.perks.pig; import java.util.HashSet; +import java.util.Set; +import java.util.UUID; import org.bukkit.Material; import org.bukkit.Sound; @@ -14,113 +16,106 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.disguise.disguises.DisguisePig; import mineplex.core.disguise.disguises.DisguisePigZombie; -import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import nautilus.game.arcade.kit.SmashPerk; +import nautilus.game.arcade.game.games.smash.perks.SmashKit; +import nautilus.game.arcade.game.games.smash.perks.SmashPerk; public class PerkPigZombie extends SmashPerk { - public HashSet<Player> _active = new HashSet<Player>(); - public PerkPigZombie() + private static final int MIN_HEALTH = 6; + + public Set<UUID> _active = new HashSet<>(); + + public PerkPigZombie() { - super("Nether Pig", new String[] - { - C.cGray + "Become Nether Pig when HP is below 6.", - C.cGray + "Return to Pig when HP is 10 or higher." - }); + super("Nether Pig", new String[] { C.cGray + "Become Nether Pig when HP is below 6.", C.cGray + "Return to Pig when HP is 10 or higher." }); } - + @EventHandler public void Check(UpdateEvent event) { if (event.getType() != UpdateType.FASTER) + { return; + } for (Player player : Manager.GetGame().GetPlayers(true)) { - if (!Kit.HasKit(player)) + if (!hasPerk(player)) + { continue; + } - //Active - if (_active.contains(player)) + // Active + if (_active.contains(player.getUniqueId())) { Manager.GetCondition().Factory().Speed("Pig Zombie", player, player, 0.9, 0, false, false, false); - + if (player.getHealth() < 10 || isSuperActive(player)) + { continue; + } - //Deactivate - _active.remove(player); - - //Armor + // Deactivate + _active.remove(player.getUniqueId()); + + // Armor player.getInventory().setHelmet(null); - player.getInventory().setChestplate(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_CHESTPLATE)); - player.getInventory().setLeggings(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_LEGGINGS)); - player.getInventory().setBoots(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_BOOTS)); - + player.getInventory().setChestplate(new ItemStack(Material.CHAINMAIL_CHESTPLATE)); + player.getInventory().setLeggings(new ItemStack(Material.CHAINMAIL_LEGGINGS)); + player.getInventory().setBoots(new ItemStack(Material.CHAINMAIL_BOOTS)); + player.getInventory().remove(Material.IRON_HELMET); player.getInventory().remove(Material.IRON_CHESTPLATE); player.getInventory().remove(Material.IRON_LEGGINGS); player.getInventory().remove(Material.IRON_BOOTS); + + SmashKit kit = (SmashKit) Kit; - //Disguise - DisguisePig disguise = new DisguisePig(player); + kit.disguise(player, DisguisePig.class); - if (Manager.GetGame().GetTeam(player) != null) - disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); - else - disguise.setName(player.getName()); - - disguise.setCustomNameVisible(true); - Manager.GetDisguise().disguise(disguise); - - //Sound + // Sound player.getWorld().playSound(player.getLocation(), Sound.PIG_IDLE, 2f, 1f); player.getWorld().playSound(player.getLocation(), Sound.PIG_IDLE, 2f, 1f); - - //Inform + + // Inform UtilPlayer.message(player, F.main("Skill", "You returned to " + F.skill("Pig Form") + ".")); } - //Not Active + // Not Active else { - if (player.getHealth() <= 0 || (!isSuperActive(player) && player.getHealth() > 6)) + if (player.getHealth() <= 0 || (!isSuperActive(player) && player.getHealth() > MIN_HEALTH)) + { continue; + } - //Activate - _active.add(player); - - //Armor + // Activate + _active.add(player.getUniqueId()); + + // Armor player.getInventory().setHelmet(new ItemStack(Material.IRON_HELMET)); player.getInventory().setChestplate(new ItemStack(Material.IRON_CHESTPLATE)); player.getInventory().setLeggings(new ItemStack(Material.IRON_LEGGINGS)); player.getInventory().setBoots(new ItemStack(Material.IRON_BOOTS)); - - //Disguise - DisguisePigZombie disguise = new DisguisePigZombie(player); - if (Manager.GetGame().GetTeam(player) != null) - disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); - else - disguise.setName(player.getName()); + SmashKit kit = (SmashKit) Kit; - disguise.setCustomNameVisible(true); - Manager.GetDisguise().disguise(disguise); - - //Sound + kit.disguise(player, DisguisePigZombie.class); + + // Sound player.getWorld().playSound(player.getLocation(), Sound.ZOMBIE_PIG_ANGRY, 2f, 1f); player.getWorld().playSound(player.getLocation(), Sound.ZOMBIE_PIG_ANGRY, 2f, 1f); - - //Inform + + // Inform UtilPlayer.message(player, F.main("Skill", "You transformed into " + F.skill("Nether Pig Form") + ".")); - + player.setExp(0.99f); } } } - + @EventHandler public void Clean(PlayerDeathEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/pig/SmashPig.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/pig/SmashPig.java new file mode 100644 index 000000000..e8300adde --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/pig/SmashPig.java @@ -0,0 +1,32 @@ +package nautilus.game.arcade.game.games.smash.perks.pig; + +import org.bukkit.Sound; +import org.bukkit.entity.Player; + +import nautilus.game.arcade.game.games.smash.perks.SmashUltimate; + +public class SmashPig extends SmashUltimate +{ + + private static final int DURATION = 40000; + + public SmashPig() + { + super("Pig Stink", new String[] {}, Sound.PIG_IDLE, DURATION); + } + + @Override + public void activate(Player player) + { + super.activate(player); + + for (Player other : Manager.GetGame().GetPlayers(true)) + { + if (!player.equals(other)) + { + Manager.GetCondition().Factory().Confuse(GetName() + " " + player.getName(), other, player, DURATION / 1000, 0, false, false, false); + } + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSheepHoming.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/sheep/SmashSheep.java similarity index 53% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSheepHoming.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/sheep/SmashSheep.java index eea416543..61e49baba 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSheepHoming.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/sheep/SmashSheep.java @@ -1,8 +1,9 @@ -package nautilus.game.arcade.kit.perks; +package nautilus.game.arcade.game.games.smash.perks.sheep; import java.util.ArrayList; -import java.util.HashMap; import java.util.Iterator; +import java.util.List; +import java.util.Map; import org.bukkit.Sound; import org.bukkit.entity.Player; @@ -10,98 +11,113 @@ import org.bukkit.entity.Sheep; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.kit.SmashPerk; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.games.smash.perks.SmashUltimate; import nautilus.game.arcade.kit.perks.data.HomingSheepData; -public class PerkSheepHoming extends SmashPerk +public class SmashSheep extends SmashUltimate { - private ArrayList<HomingSheepData> _sheep = new ArrayList<HomingSheepData>(); - public PerkSheepHoming() + private static final int DAMAGE_RADIUS = 10; + private static final int DAMAGE = 20; + private static final int KNOCKBACK_MAGNITUDE = 3; + + private List<HomingSheepData> _sheep = new ArrayList<>(); + + public SmashSheep() { - super("Homing Sheeples", new String[] - { - }, false); + super("Homing Sheeples", new String[] {}, Sound.SHEEP_IDLE, 0); } @Override - public void addSuperCustom(Player player) - { - //Fire Sheep + public void activate(Player player) + { + super.activate(player); + + Game game = Manager.GetGame(); + + game.CreatureAllowOverride = true; + + // Fire Sheep for (Player target : Manager.GetGame().GetPlayers(true)) { if (target.equals(player)) + { continue; + } - Manager.GetGame().CreatureAllowOverride = true; Sheep sheep = player.getWorld().spawn(player.getEyeLocation(), Sheep.class); - Manager.GetGame().CreatureAllowOverride = false; - + sheep.setBaby(); - + _sheep.add(new HomingSheepData(player, target, sheep)); } + + game.CreatureAllowOverride = false; } - + @EventHandler public void sheepUpdate(UpdateEvent event) { - if (event.getType() != UpdateType.TICK) - return; - - Iterator<HomingSheepData> sheepIter = _sheep.iterator(); - - while (sheepIter.hasNext()) - { - HomingSheepData data = sheepIter.next(); - - if (data.update()) - { - sheepIter.remove(); - explode(data); - } - } + if (event.getType() != UpdateType.TICK) + { + return; + } + + Iterator<HomingSheepData> sheepIter = _sheep.iterator(); + + while (sheepIter.hasNext()) + { + HomingSheepData data = sheepIter.next(); + + if (data.update()) + { + sheepIter.remove(); + explode(data); + } + } } private void explode(HomingSheepData data) { - double scale = 0.4 + 0.6 * Math.min(1, data.Sheep.getTicksLived()/60d); + double scale = 0.4 + 0.6 * Math.min(1, data.Sheep.getTicksLived() / 60d); + + // Players + Map<Player, Double> players = UtilPlayer.getInRadius(data.Sheep.getLocation(), DAMAGE_RADIUS); - //Players - HashMap<Player, Double> players = UtilPlayer.getInRadius(data.Sheep.getLocation(), 10); for (Player player : players.keySet()) { - if (!Manager.GetGame().IsAlive(player)) + if (UtilPlayer.isSpectator(player)) + { continue; - - //Damage Event - Manager.GetDamage().NewDamageEvent(player, data.Shooter, null, - DamageCause.CUSTOM, 20 * scale, true, true, false, - data.Shooter.getName(), GetName()); + } + + // Damage Event + Manager.GetDamage().NewDamageEvent(player, data.Shooter, null, DamageCause.CUSTOM, DAMAGE * scale, true, true, false, data.Shooter.getName(), GetName()); } - - UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, data.Sheep.getLocation(), 0, 0, 0, 0, 1, - ViewDist.MAX, UtilServer.getPlayers()); + + UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, data.Sheep.getLocation(), 0, 0, 0, 0, 1, ViewDist.MAX, UtilServer.getPlayers()); data.Sheep.getWorld().playSound(data.Sheep.getLocation(), Sound.EXPLODE, 2f, 1f); - + data.Sheep.remove(); } - + @EventHandler public void knockback(CustomDamageEvent event) { if (event.GetReason() == null || !event.GetReason().contains(GetName())) + { return; + } - event.AddKnockback(GetName(), 3); + event.AddKnockback(GetName(), KNOCKBACK_MAGNITUDE); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/skeletalhorse/PerkBoneRush.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/skeletalhorse/PerkBoneRush.java new file mode 100644 index 000000000..4fc78ea1b --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/skeletalhorse/PerkBoneRush.java @@ -0,0 +1,241 @@ +package nautilus.game.arcade.game.games.smash.perks.skeletalhorse; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.UUID; + +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.entity.Item; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilItem; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.projectile.IThrown; +import mineplex.core.projectile.ProjectileUser; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.games.smash.perks.SmashPerk; + +public class PerkBoneRush extends SmashPerk implements IThrown +{ + + private static final int COOLDOWN = 10000; + private static final float DAMAGE_NORMAL = 0.7F; + private static final int DAMAGE_SMASH = 3; + private static final int KNOCKBACK_NORMAL = 10; + private static final int KNOCKBACK_SMASH = 6; + private static final int EXPIRE_TIME = 2000; + private static final float Y_LIMIT = 0.25F; + + private Map<UUID, Long> _active = new HashMap<>(); + + public PerkBoneRush() + { + super("Bone Rush", new String[] { C.cYellow + "Right-Click" + C.cGray + " with Spade to use " + C.cGreen + "Bone Rush", C.cGray + "Crouch to avoid movement with " + C.cGreen + "Bone Rush" }); + } + + @EventHandler + public void Skill(PlayerInteractEvent event) + { + if (event.isCancelled()) + { + return; + } + + if (!UtilEvent.isAction(event, ActionType.R)) + { + return; + } + + if (UtilBlock.usable(event.getClickedBlock())) + { + return; + } + + Player player = event.getPlayer(); + + if (!UtilItem.isSpade(player.getItemInHand())) + { + return; + } + + if (!hasPerk(player)) + { + return; + } + + if (isSuperActive(player)) + { + return; + } + + if (!Recharge.Instance.use(player, GetName(), COOLDOWN, true, true)) + { + return; + } + + activate(player); + + UtilPlayer.message(player, F.main("Skill", "You used " + F.skill(GetName()) + ".")); + } + + public void activate(Player player) + { + _active.put(player.getUniqueId(), System.currentTimeMillis()); + } + + public void deactivate(Player player) + { + _active.remove(player.getUniqueId()); + } + + @EventHandler + public void Update(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + Iterator<UUID> playerIterator = _active.keySet().iterator(); + + while (playerIterator.hasNext()) + { + UUID key = playerIterator.next(); + Player player = UtilPlayer.searchExact(key); + + if (player == null) + { + playerIterator.remove(); + continue; + } + + if (!player.isValid() || (UtilTime.elapsed(_active.get(key), 1500) && !isSuperActive(player))) + { + playerIterator.remove(); + continue; + } + + // Sound + player.getWorld().playSound(player.getLocation(), Sound.SKELETON_HURT, 0.4f, (float) (Math.random() + 1)); + + // Velocity + Vector dir = player.getLocation().getDirection(); + double limit = isSuperActive(player) ? Y_LIMIT + 0.1 : Y_LIMIT; + + if (dir.getY() > limit) + { + dir.setY(limit); + } + + // Player + if (!player.isSneaking()) + { + UtilAction.velocity(player, dir, 0.6, false, 0, 0.1, 0.3, false); + } + + // Bones + for (int i = 0; i < 6; i++) + { + Item bone = player.getWorld().dropItem(player.getLocation().add(Math.random() * 5 - 2.5, Math.random() * 3, Math.random() * 5 - 2.5), new ItemStack(Material.BONE)); + UtilAction.velocity(bone, dir, 0.6 + 0.3 * Math.random(), false, 0, 0.1 + Math.random() * 0.05, 0.3, false); + Manager.GetProjectile().AddThrow(bone, player, this, EXPIRE_TIME, true, true, true, true, 0.5f); + } + } + } + + @EventHandler + public void Knockback(CustomDamageEvent event) + { + if (event.GetReason() == null) + { + return; + } + + if (event.GetReason().contains(GetName())) + { + event.AddKnockback(GetName(), KNOCKBACK_NORMAL); + } + + if (event.GetReason().contains("Bone Storm")) + { + event.AddKnockback(GetName(), KNOCKBACK_SMASH); + } + } + + @Override + public void Collide(LivingEntity target, Block block, ProjectileUser data) + { + data.getThrown().remove(); + + if (target == null) + { + return; + } + + if (!(target instanceof Player || data.getThrower() instanceof Player)) + { + return; + } + + target = (Player) target; + Player damager = (Player) data.getThrower(); + String reason = GetName(); + + if (target instanceof Player && damager instanceof Player) + { + if (isTeamDamage((Player) target, damager)) + { + return; + } + } + + if (isSuperActive(damager)) + { + reason = "Bone Storm"; + } + + // Damage Event + Manager.GetDamage().NewDamageEvent(target, data.getThrower(), null, DamageCause.CUSTOM, isSuperActive(damager) ? DAMAGE_SMASH : DAMAGE_NORMAL, false, true, false, UtilEnt.getName(data.getThrower()), reason); + + UtilAction.velocity(target, data.getThrown().getVelocity()); + } + + @Override + public void Idle(ProjectileUser data) + { + data.getThrown().remove(); + } + + @Override + public void Expire(ProjectileUser data) + { + data.getThrown().remove(); + } + + @EventHandler + public void Clean(PlayerDeathEvent event) + { + _active.remove(event.getEntity().getUniqueId()); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDeadlyBones.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/skeletalhorse/PerkDeadlyBones.java similarity index 51% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDeadlyBones.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/skeletalhorse/PerkDeadlyBones.java index a7db37726..ca13e82ac 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDeadlyBones.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/skeletalhorse/PerkDeadlyBones.java @@ -1,9 +1,10 @@ -package nautilus.game.arcade.kit.perks; +package nautilus.game.arcade.game.games.smash.perks.skeletalhorse; import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; import java.util.List; +import java.util.Map; +import java.util.UUID; import org.bukkit.Material; import org.bukkit.Sound; @@ -18,83 +19,109 @@ import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.kit.SmashPerk; +import nautilus.game.arcade.game.games.smash.perks.SmashPerk; public class PerkDeadlyBones extends SmashPerk { - private HashMap<Item, Player> _active = new HashMap<Item, Player>(); - public PerkDeadlyBones() + private static final int RATE = 400; + private static final int TICKS = 50; + private static final int DAMAGE_RADIUS = 4; + private static final int DAMAGE = 4; + private static final float KNOCKBACK_MAGNITUDE = 2.5F; + + private Map<Item, UUID> _active = new HashMap<>(); + + public PerkDeadlyBones() { - super("Deadly Bones", new String[] - { - C.cGray + "Drop explosive bones when you take damage." - }); + super("Deadly Bones", new String[] { C.cGray + "Drop explosive bones when you take damage." }); } @EventHandler public void damageActivate(CustomDamageEvent event) { if (event.IsCancelled()) + { return; + } Player player = event.GetDamageePlayer(); - if (player == null) - return; - if (!Kit.HasKit(player)) + if (player == null) + { return; - - if (!Recharge.Instance.use(player, GetName(), 400, false, false)) + } + + if (!hasPerk(player)) + { return; - - _active.put(player.getWorld().dropItemNaturally(player.getLocation().add(0, 0.5, 0), - ItemStackFactory.Instance.CreateStack(Material.BONE, (byte)0, 1, "Explosive Bone " + System.currentTimeMillis())), player); + } + + if (!Recharge.Instance.use(player, GetName(), RATE, false, false)) + { + return; + } + + _active.put(player.getWorld().dropItemNaturally(player.getLocation().add(0, 0.5, 0), ItemStackFactory.Instance.CreateStack(Material.BONE, (byte) 0, 1, "Explosive Bone " + System + .currentTimeMillis())), player.getUniqueId()); } - + @EventHandler public void update(UpdateEvent event) { if (event.getType() != UpdateType.TICK) - return; - -// Using copy to prevent concurrency issues for when an explosion damages -// another player with this perk active adding a new item to the list while -// we are still in the loop - List<Item> itemListCopy = new ArrayList<>(_active.keySet()); - - for(Item item : itemListCopy) { - //Not Ready - if (item.isValid() && item.getTicksLived() < 50) - continue; + return; + } - //Effect - UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, item.getLocation(), 0, 0, 0, 0, 1, - ViewDist.MAX, UtilServer.getPlayers()); - item.getWorld().playSound(item.getLocation(), Sound.EXPLODE, 0.8f, 1.4f); + // Using copy to prevent concurrency issues for when an explosion + // damages + // another player with this perk active adding a new item to the list + // while + // we are still in the loop + List<Item> itemListCopy = new ArrayList<>(_active.keySet()); + + for (Item item : itemListCopy) + { + // Not Ready + if (item.isValid() && item.getTicksLived() < TICKS) + { + continue; + } + + // Effect + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, item.getLocation(), 0, 0, 0, 0, 1, ViewDist.MAX, UtilServer.getPlayers()); + item.getWorld().playSound(item.getLocation(), Sound.EXPLODE, 0.8f, 1.4f); + + UUID key = _active.get(item); + Player player = UtilPlayer.searchExact(key); + + if (player == null) + { + continue; + } + + // Damage + Map<LivingEntity, Double> targets = UtilEnt.getInRadius(item.getLocation(), DAMAGE_RADIUS); - Player player = _active.get(item); - - //Damage - HashMap<LivingEntity, Double> targets = UtilEnt.getInRadius(item.getLocation(), 4); for (LivingEntity cur : targets.keySet()) { if (cur.equals(player)) + { continue; - - Manager.GetDamage().NewDamageEvent(cur, player, null, - DamageCause.CUSTOM, 4 * targets.get(cur) + 1, true, true, false, - player.getName(), GetName()); + } + + Manager.GetDamage().NewDamageEvent(cur, player, null, DamageCause.CUSTOM, DAMAGE * targets.get(cur) + 1, true, true, false, player.getName(), GetName()); } - - //Remove + + // Remove item.remove(); _active.remove(item); } @@ -104,8 +131,10 @@ public class PerkDeadlyBones extends SmashPerk public void knockback(CustomDamageEvent event) { if (event.GetReason() == null || !event.GetReason().contains(GetName())) + { return; - - event.AddKnockback(GetName(), 2.5); + } + + event.AddKnockback(GetName(), KNOCKBACK_MAGNITUDE); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkHorseKick.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/skeletalhorse/PerkHorseKick.java similarity index 56% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkHorseKick.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/skeletalhorse/PerkHorseKick.java index 8339b3b3c..a343c4a12 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkHorseKick.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/skeletalhorse/PerkHorseKick.java @@ -1,27 +1,30 @@ -package nautilus.game.arcade.kit.perks; +package nautilus.game.arcade.game.games.smash.perks.skeletalhorse; import java.util.HashMap; import java.util.Iterator; +import java.util.Map; +import java.util.UUID; import org.bukkit.Location; import org.bukkit.Sound; -import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.block.Action; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.player.PlayerInteractEvent; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguiseHorse; @@ -29,123 +32,145 @@ import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.kit.SmashPerk; +import nautilus.game.arcade.game.games.smash.perks.SmashPerk; public class PerkHorseKick extends SmashPerk { - private HashMap<Player, Long> _active = new HashMap<Player, Long>(); - - public PerkHorseKick() - { - super("Bone Kick", new String[] - { - C.cYellow + "Right-Click" + C.cGray + " with Axe to use " + C.cGreen + "Bone Kick" - }); - } + private static final int COOLDOWN = 6000; + private static final float DAMAGE = 6.5F; + private static final int KICK_TIME = 1000; + private static final int KNOCKBACK_MAGNITUDE = 4; + + private Map<UUID, Long> _active = new HashMap<>(); + + public PerkHorseKick() + { + super("Bone Kick", new String[] { C.cYellow + "Right-Click" + C.cGray + " with Axe to use " + C.cGreen + "Bone Kick" }); + } + @EventHandler public void Activate(PlayerInteractEvent event) { if (event.isCancelled()) + { return; + } - if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) + if (!UtilEvent.isAction(event, ActionType.R)) + { return; + } if (UtilBlock.usable(event.getClickedBlock())) + { return; - - if (!event.getPlayer().getItemInHand().getType().toString().contains("_AXE")) - return; + } Player player = event.getPlayer(); - + + if (!UtilItem.isAxe(player.getItemInHand())) + { + return; + } + + if (!hasPerk(player)) + { + return; + } + if (isSuperActive(player)) + { return; + } - if (!Kit.HasKit(player)) + if (!Recharge.Instance.use(player, GetName(), COOLDOWN, true, true)) + { return; + } - if (!Recharge.Instance.use(player, GetName(), 6000, true, true)) - return; + // Horse Animation + DisguiseBase horse = Manager.GetDisguise().getActiveDisguise(player); - //Horse Animation - DisguiseBase horse = Manager.GetDisguise().getDisguise(player); if (horse != null && horse instanceof DisguiseHorse) { - ((DisguiseHorse)horse).kick(); + ((DisguiseHorse) horse).kick(); Manager.GetDisguise().updateDisguise(horse); } - //Animation - _active.put(player, System.currentTimeMillis()); + // Animation + _active.put(player.getUniqueId(), System.currentTimeMillis()); - - //AoE Area + // AoE Area Location loc = player.getLocation(); loc.add(player.getLocation().getDirection().setY(0).normalize().multiply(1.5)); loc.add(0, 0.8, 0); - for (Entity other : player.getWorld().getEntities()) + for (LivingEntity other : UtilEnt.getInRadius(loc, 2.5).keySet()) { - if (!(other instanceof LivingEntity)) + if (UtilPlayer.isSpectator(other)) + { continue; - - if (other instanceof Player) - if (!Manager.GetGame().IsAlive((Player)other)) - continue; + } if (other.equals(player)) + { continue; + } - if (UtilMath.offset(loc, other.getLocation()) > 2.5) - continue; + // Damage Event + Manager.GetDamage().NewDamageEvent(other, player, null, DamageCause.CUSTOM, DAMAGE, true, true, false, player.getName(), GetName()); - //Damage Event - Manager.GetDamage().NewDamageEvent((LivingEntity)other, player, null, - DamageCause.CUSTOM, 7, true, true, false, - player.getName(), GetName()); - - //Sound + // Sound player.getWorld().playSound(player.getLocation(), Sound.SKELETON_HURT, 4f, 0.6f); player.getWorld().playSound(player.getLocation(), Sound.SKELETON_HURT, 4f, 0.6f); - //Inform - UtilPlayer.message(other, F.main("Skill", F.name(player.getName()) + " hit you with " + F.skill(GetName()) + ".")); + // Inform + UtilPlayer.message(other, F.main("Skill", F.name(player.getName()) + " hit you with " + F.skill(GetName()) + ".")); } - //Inform + // Inform UtilPlayer.message(player, F.main("Skill", "You used " + F.skill(GetName()) + ".")); - - //Slow + + // Slow Manager.GetCondition().Factory().Slow(GetName(), player, player, 0.8, 3, false, false, true, false); } @EventHandler - public void Update(UpdateEvent event) + public void Update(UpdateEvent event) { if (event.getType() != UpdateType.TICK) + { return; - - //Player - Iterator<Player> playerIterator = _active.keySet().iterator(); + } + // Player + Iterator<UUID> playerIterator = _active.keySet().iterator(); + while (playerIterator.hasNext()) { - Player player = playerIterator.next(); + UUID key = playerIterator.next(); + Player player = UtilPlayer.searchExact(key); - if (!player.isValid() || player.getHealth() <= 0 || UtilTime.elapsed(_active.get(player), 1000)) + if (player == null) { playerIterator.remove(); + continue; + } + + if (!player.isValid() || player.getHealth() <= 0 || UtilTime.elapsed(_active.get(key), KICK_TIME)) + { + playerIterator.remove(); + + // Horse Animation + DisguiseBase horse = Manager.GetDisguise().getActiveDisguise(player); - //Horse Animation - DisguiseBase horse = Manager.GetDisguise().getDisguise(player); if (horse != null && horse instanceof DisguiseHorse) { - ((DisguiseHorse)horse).stopKick(); + ((DisguiseHorse) horse).stopKick(); Manager.GetDisguise().updateDisguise(horse); } - + Manager.GetCondition().EndCondition(player, null, GetName()); } else @@ -153,9 +178,8 @@ public class PerkHorseKick extends SmashPerk Location loc = player.getLocation(); loc.add(player.getLocation().getDirection().setY(0).normalize().multiply(1.5)); loc.add(0, 0.8, 0); - - UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, loc, 0.3f, 0.3f, 0.3f, 0, 2, - ViewDist.LONG, UtilServer.getPlayers()); + + UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, loc, 0.3f, 0.3f, 0.3f, 0, 2, ViewDist.LONG, UtilServer.getPlayers()); } } } @@ -163,9 +187,11 @@ public class PerkHorseKick extends SmashPerk @EventHandler public void Knockback(CustomDamageEvent event) { - if (event.GetReason() == null || (!event.GetReason().contains(GetName()) && !event.GetReason().contains("Flame Kick"))) + if (event.GetReason() == null || !event.GetReason().contains(GetName())) + { return; - - event.AddKnockback(GetName(), 4); + } + + event.AddKnockback(GetName(), KNOCKBACK_MAGNITUDE); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/skeletalhorse/SmashSkeletalHorse.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/skeletalhorse/SmashSkeletalHorse.java new file mode 100644 index 000000000..058c4c3d8 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/skeletalhorse/SmashSkeletalHorse.java @@ -0,0 +1,55 @@ +package nautilus.game.arcade.game.games.smash.perks.skeletalhorse; + +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; + +import nautilus.game.arcade.game.games.smash.perks.SmashUltimate; +import nautilus.game.arcade.kit.Perk; + +public class SmashSkeletalHorse extends SmashUltimate +{ + + private static final int DURATION = 20000; + + public SmashSkeletalHorse() + { + super("Bone Storm", new String[] {}, Sound.HORSE_SKELETON_DEATH, DURATION); + } + + @Override + public void activate(Player player) + { + super.activate(player); + + player.getInventory().remove(Material.IRON_SPADE); + player.getInventory().remove(Material.IRON_AXE); + + for (Perk perk : Kit.GetPerks()) + { + if (perk instanceof PerkBoneRush) + { + PerkBoneRush boneRush = (PerkBoneRush) perk; + + boneRush.activate(player); + } + } + } + + @Override + public void cancel(Player player) + { + super.cancel(player); + + for (Perk perk : Kit.GetPerks()) + { + if (perk instanceof PerkBoneRush) + { + PerkBoneRush boneRush = (PerkBoneRush) perk; + + boneRush.deactivate(player); + } + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/skeleton/PerkBarrage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/skeleton/PerkBarrage.java new file mode 100644 index 000000000..4c980e69b --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/skeleton/PerkBarrage.java @@ -0,0 +1,373 @@ +package nautilus.game.arcade.game.games.smash.perks.skeleton; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; +import java.util.UUID; + +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilGear; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.games.smash.perks.SmashPerk; + +public class PerkBarrage extends SmashPerk +{ + private Map<UUID, Integer> _charge = new HashMap<>(); + private Map<UUID, Long> _chargeLast = new HashMap<>(); + + private Set<UUID> _firing = new HashSet<>(); + private Set<Projectile> _arrows = new HashSet<Projectile>(); + + private int _max; + private int _tick; + private boolean _remove; + private boolean _noDelay; + private boolean _useExp; + + public PerkBarrage(int max, int tick, boolean remove, boolean noDelay) + { + this(max, tick, remove, noDelay, false); + } + + public PerkBarrage(int max, int tick, boolean remove, boolean noDelay, boolean useExpAndBar) + { + super("Barrage", new String[] { C.cYellow + "Charge" + C.cGray + " your Bow to use " + C.cGreen + "Barrage" }); + _useExp = useExpAndBar; + _max = max; + _tick = tick; + _remove = remove; + _noDelay = noDelay; + } + + @EventHandler + public void BarrageDrawBow(PlayerInteractEvent event) + { + if (event.isCancelled()) + { + return; + } + + if (!UtilEvent.isAction(event, ActionType.R)) + { + return; + } + + if (UtilBlock.usable(event.getClickedBlock())) + { + return; + } + + Player player = event.getPlayer(); + + if (!UtilGear.isBow(player.getItemInHand())) + { + return; + } + + if (!hasPerk(player)) + { + return; + } + + if (isSuperActive(player)) + { + return; + } + + if (!player.getInventory().contains(Material.ARROW)) + { + return; + } + + if (event.getClickedBlock() != null) + { + if (UtilBlock.usable(event.getClickedBlock())) + { + return; + } + } + + // Start Charge + _charge.put(player.getUniqueId(), 0); + _chargeLast.put(player.getUniqueId(), System.currentTimeMillis()); + _firing.remove(player.getUniqueId()); + } + + @EventHandler + public void BarrageCharge(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + for (Player cur : UtilServer.getPlayers()) + { + UUID key = cur.getUniqueId(); + + // Not Charging + if (!_charge.containsKey(key)) + { + continue; + } + + if (_firing.contains(key)) + { + continue; + } + + // Max Charge + if (_charge.get(key) >= _max) + { + continue; + } + + // Charge Interval + if (_charge.get(key) == 0) + { + if (!UtilTime.elapsed(_chargeLast.get(key), 1000)) + { + continue; + } + } + else + { + if (!UtilTime.elapsed(_chargeLast.get(key), _tick)) + { + continue; + } + } + + // No Longer Holding Bow + if (cur.getItemInHand() == null || cur.getItemInHand().getType() != Material.BOW) + { + if (_useExp) + { + cur.setExp(0f); + } + _charge.remove(key); + _chargeLast.remove(key); + continue; + } + + // Increase Charge + _charge.put(key, _charge.get(key) + 1); + + if (_useExp) + { + cur.setExp(Math.min(0.9999f, (float) _charge.get(key) / (float) _max)); + } + _chargeLast.put(key, System.currentTimeMillis()); + + // Effect + cur.playSound(cur.getLocation(), Sound.CLICK, 1f, 1f + (0.1f * _charge.get(key))); + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void BarrageFireBow(EntityShootBowEvent event) + { + if (event.isCancelled()) + { + return; + + } + if (!Manager.GetGame().IsLive()) + { + return; + } + + if (!(event.getEntity() instanceof Player)) + { + return; + } + + if (!(event.getProjectile() instanceof Arrow)) + { + return; + } + + Player player = (Player) event.getEntity(); + + if (!_charge.containsKey(player.getUniqueId())) + { + return; + } + + // Start Barrage + _firing.add(player.getUniqueId()); + _chargeLast.put(player.getUniqueId(), System.currentTimeMillis()); + } + + @EventHandler + public void BarrageArrows(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + Set<Player> remove = new HashSet<Player>(); + + for (UUID key : _firing) + { + Player cur = UtilPlayer.searchExact(key); + + if (cur == null) + { + continue; + } + + if (!_charge.containsKey(key) || !_chargeLast.containsKey(key)) + { + remove.add(cur); + continue; + } + + if (cur.getItemInHand() == null || cur.getItemInHand().getType() != Material.BOW) + { + remove.add(cur); + continue; + } + + int arrows = _charge.get(key); + if (arrows <= 0) + { + remove.add(cur); + continue; + } + + _charge.put(key, arrows - 1); + if (_useExp) + { + cur.setExp(Math.min(0.9999f, _charge.get(key) / _max)); + } + + // Fire Arrow + Vector random = new Vector((Math.random() - 0.5) / 10, (Math.random() - 0.5) / 10, (Math.random() - 0.5) / 10); + Projectile arrow = cur.launchProjectile(Arrow.class); + arrow.setVelocity(cur.getLocation().getDirection().add(random).multiply(3)); + _arrows.add(arrow); + cur.getWorld().playSound(cur.getLocation(), Sound.SHOOT_ARROW, 1f, 1f); + } + + for (Player cur : remove) + { + if (_useExp) + { + cur.setExp(0f); + } + _charge.remove(cur.getUniqueId()); + _chargeLast.remove(cur.getUniqueId()); + _firing.remove(cur.getUniqueId()); + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void BarrageDamageTime(CustomDamageEvent event) + { + if (!_noDelay) + { + return; + } + + if (event.GetProjectile() == null) + { + return; + } + + if (event.GetDamagerPlayer(true) == null) + { + return; + } + + if (!(event.GetProjectile() instanceof Arrow)) + { + return; + } + + Player damager = event.GetDamagerPlayer(true); + + if (!hasPerk(damager)) + { + return; + } + + event.SetCancelled("Barrage Cancel"); + + event.GetProjectile().remove(); + + // Damage Event + Manager.GetDamage().NewDamageEvent(event.GetDamageeEntity(), damager, null, DamageCause.THORNS, event.GetDamage(), true, true, false, damager.getName(), GetName()); + } + + @EventHandler + public void BarrageProjectileHit(ProjectileHitEvent event) + { + if (_remove) + { + if (_arrows.remove(event.getEntity().getUniqueId())) + { + event.getEntity().remove(); + } + } + } + + @EventHandler + public void BarrageClean(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + { + return; + } + + for (Iterator<Projectile> arrowIterator = _arrows.iterator(); arrowIterator.hasNext();) + { + Projectile arrow = arrowIterator.next(); + + if (arrow.isDead() || !arrow.isValid()) + { + arrowIterator.remove(); + } + } + } + + @EventHandler + public void Quit(PlayerQuitEvent event) + { + Player player = event.getPlayer(); + + clean(player); + } + + public void clean(Player player) + { + _charge.remove(player.getUniqueId()); + _chargeLast.remove(player.getUniqueId()); + _firing.remove(player.getUniqueId()); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBoneExplosion.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/skeleton/PerkBoneExplosion.java similarity index 53% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBoneExplosion.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/skeleton/PerkBoneExplosion.java index 5a388d7ae..5fe9a20db 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBoneExplosion.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/skeleton/PerkBoneExplosion.java @@ -1,90 +1,109 @@ -package nautilus.game.arcade.kit.perks; +package nautilus.game.arcade.game.games.smash.perks.skeleton; -import java.util.HashMap; +import java.util.Map; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.block.Action; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.player.PlayerInteractEvent; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilPlayer; import mineplex.core.recharge.Recharge; import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.kit.SmashPerk; +import nautilus.game.arcade.game.games.smash.perks.SmashPerk; public class PerkBoneExplosion extends SmashPerk -{ - public PerkBoneExplosion() +{ + + private static final int COOLDOWN = 10000; + private static final int DAMAGE_RADIUS = 7; + private static final int DAMAGE = 6; + private static final float KNOCKBACK_MAGNITUDE = 2.5F; + + public PerkBoneExplosion() { - super("Bone Explosion", new String[] - { - C.cYellow + "Right-Click" + C.cGray + " with Axe to " + C.cGreen + "Bone Explosion" - }); + super("Bone Explosion", new String[] { C.cYellow + "Right-Click" + C.cGray + " with Axe to " + C.cGreen + "Bone Explosion" }); } @EventHandler public void Skill(PlayerInteractEvent event) { if (event.isCancelled()) + { return; - - if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) + } + + if (!UtilEvent.isAction(event, ActionType.R)) + { return; - + } + if (UtilBlock.usable(event.getClickedBlock())) + { return; - - if (event.getPlayer().getItemInHand() == null) - return; - - if (!event.getPlayer().getItemInHand().getType().toString().contains("_AXE")) - return; - + } + Player player = event.getPlayer(); - + + if (!UtilItem.isAxe(player.getItemInHand())) + { + return; + } + + if (!hasPerk(player)) + { + return; + } + if (isSuperActive(player)) - return; - - if (!Kit.HasKit(player)) + { return; - - if (!Recharge.Instance.use(player, GetName(), 10000, true, true)) + } + + if (!Recharge.Instance.use(player, GetName(), COOLDOWN, true, true)) + { return; + } + + Map<Player, Double> nearby = UtilPlayer.getInRadius(player.getLocation(), DAMAGE_RADIUS); - HashMap<Player, Double> nearby = UtilPlayer.getInRadius(player.getLocation(), 7); for (Player other : nearby.keySet()) { if (player.equals(other)) + { continue; + } - //Inform + // Inform UtilPlayer.message(other, F.main("Game", F.elem(Manager.GetColor(player) + player.getName()) + " used " + F.skill(GetName()) + ".")); - - //Damage Event - Manager.GetDamage().NewDamageEvent(other, player, null, - DamageCause.CUSTOM, 6 * nearby.get(other), true, true, false, - player.getName(), GetName()); + + // Damage Event + Manager.GetDamage().NewDamageEvent(other, player, null, DamageCause.CUSTOM, DAMAGE * nearby.get(other), true, true, false, player.getName(), GetName()); } - - //Inform + + // Inform UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + ".")); - - //Effect - Manager.GetBlood().Effects(null, player.getLocation().add(0, 0.5, 0), 48, 0.8, Sound.SKELETON_HURT, 2f, 1.2f, Material.BONE, (byte)0, 40, false); + + // Effect + Manager.GetBlood().Effects(null, player.getLocation().add(0, 0.5, 0), 48, 0.8, Sound.SKELETON_HURT, 2f, 1.2f, Material.BONE, (byte) 0, 40, false); } - + @EventHandler public void Knockback(CustomDamageEvent event) { if (event.GetReason() == null || !event.GetReason().contains(GetName())) + { return; + } - event.AddKnockback(GetName(), 2.5); + event.AddKnockback(GetName(), KNOCKBACK_MAGNITUDE); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/skeleton/SmashSkeleton.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/skeleton/SmashSkeleton.java new file mode 100644 index 000000000..bb86fdbcf --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/skeleton/SmashSkeleton.java @@ -0,0 +1,85 @@ +package nautilus.game.arcade.game.games.smash.perks.skeleton; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; +import java.util.UUID; + +import org.bukkit.Sound; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.games.smash.perks.SmashUltimate; + +public class SmashSkeleton extends SmashUltimate +{ + + private static final int DURATION = 10000; + + private Set<Projectile> _arrows = new HashSet<Projectile>(); + + public SmashSkeleton() + { + super("Arrow Storm", new String[] {}, Sound.SKELETON_HURT, DURATION); + } + + @EventHandler + public void fireArrows(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + for (UUID uuid : getLastUltimate().keySet()) + { + Player cur = UtilPlayer.searchExact(uuid); + + if (cur == null) + { + continue; + } + + Vector random = new Vector((Math.random() - 0.5) / 5, (Math.random() - 0.5) / 5, (Math.random() - 0.5) / 5); + Projectile arrow = cur.launchProjectile(Arrow.class); + arrow.setVelocity(cur.getLocation().getDirection().add(random).multiply(3)); + _arrows.add(arrow); + cur.getWorld().playSound(cur.getLocation(), Sound.SHOOT_ARROW, 1f, 1f); + } + } + + @EventHandler + public void projectileHit(ProjectileHitEvent event) + { + if (_arrows.remove(event.getEntity())) + { + event.getEntity().remove(); + } + } + + @EventHandler + public void clean(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + { + return; + } + + for (Iterator<Projectile> arrowIterator = _arrows.iterator(); arrowIterator.hasNext();) + { + Projectile arrow = arrowIterator.next(); + + if (arrow.isDead() || !arrow.isValid()) + { + arrowIterator.remove(); + } + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSlimeRocket.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/slime/PerkSlimeRocket.java similarity index 59% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSlimeRocket.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/slime/PerkSlimeRocket.java index 0bf4780f1..a9994d4a1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSlimeRocket.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/slime/PerkSlimeRocket.java @@ -1,7 +1,9 @@ -package nautilus.game.arcade.kit.perks; +package nautilus.game.arcade.game.games.smash.perks.slime; import java.util.HashMap; import java.util.Iterator; +import java.util.Map; +import java.util.UUID; import org.bukkit.Material; import org.bukkit.Sound; @@ -10,9 +12,8 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Slime; import org.bukkit.event.EventHandler; -import org.bukkit.event.block.Action; -import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.player.PlayerInteractEvent; import mineplex.core.common.util.C; @@ -20,12 +21,15 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.disguise.disguises.DisguiseSlime; import mineplex.core.projectile.IThrown; import mineplex.core.projectile.ProjectileUser; @@ -33,53 +37,71 @@ import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.game.games.smash.TeamSuperSmash; -import nautilus.game.arcade.kit.SmashPerk; + +import nautilus.game.arcade.game.games.smash.perks.SmashPerk; public class PerkSlimeRocket extends SmashPerk implements IThrown { - private HashMap<Player, Long> _charge = new HashMap<Player, Long>(); - private HashMap<Slime, Player> _owner = new HashMap<Slime, Player>(); - private HashMap<Slime, Long> _lastAttack = new HashMap<Slime, Long>(); - - public PerkSlimeRocket() + + private static final int COOLDOWN = 6000; + private static final float ENERGY_PER_TICK = 0.004F; + private static final int KNOCKBACK_MAGNITUDE = 3; + private static final int MAX_ENERGY_TIME = 3000; + private static final int MAX_HOLD_TIME = 5000; + + private Map<UUID, Long> _charge = new HashMap<>(); + private Map<Slime, UUID> _owner = new HashMap<>(); + private Map<Slime, Long> _lastAttack = new HashMap<>(); + + public PerkSlimeRocket() { - super("Slime Rocket", new String[] - { - C.cYellow + "Hold/Release Block" + C.cGray + " to use " + C.cGreen + "Slime Rocket" - }); + super("Slime Rocket", new String[] { C.cYellow + "Hold/Release Block" + C.cGray + " to use " + C.cGreen + "Slime Rocket" }); } @EventHandler public void EnergyUpdate(UpdateEvent event) { if (event.getType() != UpdateType.TICK) + { return; + } for (Player player : Manager.GetGame().GetPlayers(true)) { - if (!Kit.HasKit(player)) + if (!hasPerk(player)) + { continue; - + } + if (isSuperActive(player)) + { continue; - + } + int size = 1; - if (player.getExp() > 0.8) size = 3; - else if (player.getExp() > 0.55) size = 2; - - - DisguiseSlime slime = (DisguiseSlime)Manager.GetDisguise().getDisguise(player); + if (player.getExp() > 0.8) + { + size = 3; + } + else if (player.getExp() > 0.55) + { + size = 2; + } + + DisguiseSlime slime = (DisguiseSlime) Manager.GetDisguise().getActiveDisguise(player); + if (slime != null && slime.GetSize() != size) { slime.SetSize(size); Manager.GetDisguise().updateDisguise(slime); } - if (player.isBlocking()) + if (player.isBlocking() && !Recharge.Instance.usable(player, GetName())) + { continue; + } - player.setExp((float) Math.min(0.999, player.getExp()+0.004)); + player.setExp((float) Math.min(0.999, player.getExp() + ENERGY_PER_TICK)); } } @@ -87,51 +109,74 @@ public class PerkSlimeRocket extends SmashPerk implements IThrown public void Activate(PlayerInteractEvent event) { if (event.isCancelled()) + { return; + } - if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) + if (!UtilEvent.isAction(event, ActionType.R)) + { return; + } if (UtilBlock.usable(event.getClickedBlock())) + { return; - - if (!event.getPlayer().getItemInHand().getType().toString().contains("_SWORD")) - return; + } Player player = event.getPlayer(); - if (isSuperActive(player)) - return; - - if (!Kit.HasKit(player)) + if (!UtilItem.isSword(player.getItemInHand())) + { return; + } - if (!Recharge.Instance.use(player, GetName(), 6000, true, true)) + if (!hasPerk(player)) + { return; + } + + if (isSuperActive(player)) + { + return; + } + + if (!Recharge.Instance.use(player, GetName(), COOLDOWN, true, true)) + { + return; + } UtilPlayer.message(player, F.main("Skill", "You are charging " + F.skill(GetName()) + ".")); - - _charge.put(player, System.currentTimeMillis()); + + _charge.put(player.getUniqueId(), System.currentTimeMillis()); } @EventHandler - public void ChargeRelease(UpdateEvent event) + public void ChargeRelease(UpdateEvent event) { if (event.getType() != UpdateType.TICK) + { return; + } - Iterator<Player> chargeIterator = _charge.keySet().iterator(); + Iterator<UUID> chargeIterator = _charge.keySet().iterator(); while (chargeIterator.hasNext()) { - Player player = chargeIterator.next(); + UUID key = chargeIterator.next(); + Player player = UtilPlayer.searchExact(key); - long time = _charge.get(player); - - //Charge + if (player == null) + { + chargeIterator.remove(); + continue; + } + + long time = _charge.get(key); + + // Charge if (player.isBlocking()) { - //Energy Depleted + // Energy Depleted if (player.getExp() < 0.1) { FireRocket(player); @@ -139,29 +184,29 @@ public class PerkSlimeRocket extends SmashPerk implements IThrown } else { - double elapsed = Math.min(3, (double)(System.currentTimeMillis() - time)/1000d); - - //Use Energy - if (!UtilTime.elapsed(time, 3000)) + double elapsed = Math.min(3, (double) (System.currentTimeMillis() - time) / 1000d); + + // Use Energy + if (!UtilTime.elapsed(time, MAX_ENERGY_TIME)) { - player.setExp((float) Math.max(0, player.getExp()-0.01f)); + player.setExp((float) Math.max(0, player.getExp() - 0.01f)); } - - //AutoFire - if (UtilTime.elapsed(time, 5000)) + + // AutoFire + if (UtilTime.elapsed(time, MAX_HOLD_TIME)) { FireRocket(player); chargeIterator.remove(); } - - //Effect - player.getWorld().playSound(player.getLocation(), Sound.SLIME_WALK, 0.5f, (float)(0.5 + 1.5*(elapsed/3d))); - UtilParticle.PlayParticle(ParticleType.SLIME, player.getLocation().add(0, 1, 0), - (float)(elapsed/6d), (float)(elapsed/6d), (float)(elapsed/6d), 0, (int)(elapsed * 5), - ViewDist.LONGER, UtilServer.getPlayers()); + + float offset = (float) (elapsed / 6d); + + // Effect + player.getWorld().playSound(player.getLocation(), Sound.SLIME_WALK, 0.5f, (float) (0.5 + 1.5 * (elapsed / 3d))); + UtilParticle.PlayParticle(ParticleType.SLIME, player.getLocation().add(0, 1, 0), offset, offset, offset, 0, (int) (elapsed * 5), ViewDist.LONGER, UtilServer.getPlayers()); } } - //Release + // Release else { FireRocket(player); @@ -172,54 +217,55 @@ public class PerkSlimeRocket extends SmashPerk implements IThrown public void FireRocket(Player player) { - double charge = Math.min(3, (double)(System.currentTimeMillis() - _charge.get(player))/1000d); + double charge = Math.min(3, (double) (System.currentTimeMillis() - _charge.get(player.getUniqueId())) / 1000d); - //Spawn Slime + // Spawn Slime Manager.GetGame().CreatureAllowOverride = true; Slime slime = player.getWorld().spawn(player.getEyeLocation(), Slime.class); slime.setSize(1); Manager.GetGame().CreatureAllowOverride = false; - //Size - slime.setSize(Math.max(1, (int)charge)); - + // Size + slime.setSize(Math.max(1, (int) charge)); + slime.setMaxHealth(5 + charge * 7); slime.setHealth(slime.getMaxHealth()); - - _owner.put(slime, player); - - //Inform + + _owner.put(slime, player.getUniqueId()); + + // Inform UtilPlayer.message(player, F.main("Skill", "You released " + F.skill(GetName()) + ".")); slime.leaveVehicle(); player.eject(); - UtilAction.velocity(slime, player.getLocation().getDirection(), 1 + charge/2d, false, 0, 0.2, 10, true); - - Manager.GetProjectile().AddThrow(slime, player, this, -1, true, true, true, true, - null, 0, 0, null, 0, UpdateType.FASTEST, 1f); + UtilAction.velocity(slime, player.getLocation().getDirection(), 1 + charge / 2d, false, 0, 0.2, 10, true); + + Manager.GetProjectile().AddThrow(slime, player, this, -1, true, true, true, true, null, 0, 0, null, 0, UpdateType.FASTEST, 1f); } @EventHandler public void SlimeTarget(EntityTargetEvent event) { if (event.isCancelled()) + { return; + } if (!_owner.containsKey(event.getEntity())) - return; - - if (Manager.GetGame() instanceof TeamSuperSmash && event.getTarget() instanceof Player) { - TeamSuperSmash smash = (TeamSuperSmash) Manager.GetGame(); - Player targetPlayer = (Player) event.getTarget(); - - if (smash.GetTeam(_owner.get(event.getEntity())).equals(smash.GetTeam(targetPlayer))) + return; + } + + if (event.getTarget() instanceof Player) + { + if (isTeamDamage((Player) event.getTarget(), UtilPlayer.searchExact(_owner.get(event.getEntity())))) { event.setCancelled(true); + return; } } - + if (_owner.get(event.getEntity()).equals(event.getTarget())) { event.setCancelled(true); @@ -230,86 +276,89 @@ public class PerkSlimeRocket extends SmashPerk implements IThrown public void Collide(LivingEntity target, Block block, ProjectileUser data) { if (target == null) - return; - - if (!(data.getThrown() instanceof Slime)) - return; - - Slime slime = (Slime)data.getThrown(); - - if (Manager.GetGame() instanceof TeamSuperSmash && target instanceof Player && data.getThrower() instanceof Player) { - TeamSuperSmash smash = (TeamSuperSmash) Manager.GetGame(); + return; + } + + if (!(data.getThrown() instanceof Slime)) + { + return; + } + + Slime slime = (Slime) data.getThrown(); + + if (target instanceof Player && data.getThrower() instanceof Player) + { Player targetPlayer = (Player) target; Player throwerPlayer = (Player) data.getThrower(); - - if(smash.GetTeam(targetPlayer).equals(smash.GetTeam(throwerPlayer))) + + if (isTeamDamage(targetPlayer, throwerPlayer)) { return; } } - - //Damage Event - Manager.GetDamage().NewDamageEvent(target, data.getThrower(), null, - DamageCause.PROJECTILE, 3 + slime.getSize() * 3, true, true, false, - UtilEnt.getName(data.getThrower()), GetName()); + + // Damage Event + Manager.GetDamage().NewDamageEvent(target, data.getThrower(), null, DamageCause.PROJECTILE, 3 + slime.getSize() * 3, true, true, false, UtilEnt.getName(data.getThrower()), GetName()); } - + @EventHandler public void Knockback(CustomDamageEvent event) { if (event.GetReason() == null || !event.GetReason().contains(GetName())) + { return; - - event.AddKnockback(GetName(), 3.0); + } + + event.AddKnockback(GetName(), KNOCKBACK_MAGNITUDE); } @Override public void Idle(ProjectileUser data) { - + } @Override public void Expire(ProjectileUser data) { - + } - + @EventHandler public void SlimeDamage(CustomDamageEvent event) { if (!(event.GetDamagerEntity(false) instanceof Slime)) + { return; - - Slime slime = (Slime)event.GetDamagerEntity(false); - - - //Attack Rate + } + + Slime slime = (Slime) event.GetDamagerEntity(false); + + // Attack Rate if (_lastAttack.containsKey(slime) && !UtilTime.elapsed(_lastAttack.get(slime), 500)) { event.SetCancelled("Slime Attack Rate"); return; } - + _lastAttack.put(slime, System.currentTimeMillis()); - - //Get Owner - Player owner = _owner.get(slime); - //if (owner != null) - // event.SetDamager(owner); This gives knockback from wrong direction :( - - if (Manager.GetGame() instanceof TeamSuperSmash) + + // Get Owner + UUID key = _owner.get(slime); + Player owner = UtilPlayer.searchExact(key); + + if (owner == null) { - TeamSuperSmash smash = (TeamSuperSmash) Manager.GetGame(); - - if (smash.GetTeam(owner).equals(smash.GetTeam(event.GetDamageePlayer()))) - { - event.SetCancelled("Team Damage"); - return; - } + return; } - + + if (isTeamDamage(owner, event.GetDamageePlayer())) + { + event.SetCancelled("Team Damage"); + return; + } + if (owner != null && owner.equals(event.GetDamageeEntity())) { event.SetCancelled("Owner Damage"); @@ -319,41 +368,49 @@ public class PerkSlimeRocket extends SmashPerk implements IThrown event.AddMod("Slime Damage", "Negate", -event.GetDamageInitial(), false); event.AddMod("Slime Damage", "Attack", 2 * slime.getSize(), true); event.AddKnockback("Slime Knockback", 2); - } + } } - + @EventHandler - public void SlimeClean(UpdateEvent event) + public void SlimeClean(UpdateEvent event) { if (event.getType() != UpdateType.SEC) + { return; + } Iterator<Slime> slimeIterator = _owner.keySet().iterator(); while (slimeIterator.hasNext()) { Slime slime = slimeIterator.next(); - - //Shrink + + // Shrink if (slime.getVehicle() == null) { if (slime.getTicksLived() > 120) { slime.setTicksLived(1); - - Manager.GetBlood().Effects(null, slime.getLocation(), 6 + 6 * slime.getSize(), 0.2 + 0.1 * slime.getSize(), null, 1f, 1f, Material.SLIME_BALL, (byte)0, 15, false); - + + Manager.GetBlood().Effects(null, slime.getLocation(), 6 + 6 * slime.getSize(), 0.2 + 0.1 * slime.getSize(), null, 1f, 1f, Material.SLIME_BALL, (byte) 0, 15, false); + if (slime.getSize() <= 1) + { slime.remove(); + } else - slime.setSize(slime.getSize()-1); + { + slime.setSize(slime.getSize() - 1); + } } } - + if (!slime.isValid()) + { slimeIterator.remove(); + } } - + slimeIterator = _lastAttack.keySet().iterator(); while (slimeIterator.hasNext()) @@ -361,7 +418,9 @@ public class PerkSlimeRocket extends SmashPerk implements IThrown Slime slime = slimeIterator.next(); if (!slime.isValid()) + { slimeIterator.remove(); + } } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/slime/PerkSlimeSlam.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/slime/PerkSlimeSlam.java new file mode 100644 index 000000000..6d27af729 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/slime/PerkSlimeSlam.java @@ -0,0 +1,184 @@ +package nautilus.game.arcade.game.games.smash.perks.slime; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.player.PlayerInteractEvent; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilItem; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.games.smash.perks.SmashPerk; + +public class PerkSlimeSlam extends SmashPerk +{ + + private static final int COOLDOWN = 6000; + private static final int HIT_BOX = 2; + private static final int START_TIME = 1000; + private static final int DAMAGE_RATE_LIMIT = 500; + private static final int DAMAGE = 7; + private static final int KNOCKBACK_MAGNITUDE = 2; + + private Map<UUID, Long> _live = new HashMap<>(); + + public PerkSlimeSlam() + { + super("Slime Slam", new String[] { C.cYellow + "Right-Click" + C.cGray + " with Axe to " + C.cGreen + "Slime Slam" }); + } + + @EventHandler + public void Leap(PlayerInteractEvent event) + { + if (event.isCancelled()) + { + return; + } + + if (!UtilEvent.isAction(event, ActionType.R)) + { + return; + } + + if (UtilBlock.usable(event.getClickedBlock())) + { + return; + } + + Player player = event.getPlayer(); + + if (!UtilItem.isAxe(player.getItemInHand())) + { + return; + } + + if (!hasPerk(player)) + { + return; + } + + if (!Recharge.Instance.use(player, GetName(), COOLDOWN, true, true)) + { + return; + } + + UtilAction.velocity(player, player.getLocation().getDirection(), 1.2, false, 0, 0.2, 1.2, true); + + // Record + _live.put(player.getUniqueId(), System.currentTimeMillis()); + + // Inform + UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + ".")); + } + + @EventHandler + public void End(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + List<Player> alivePlayers = Manager.GetGame().GetPlayers(true); + + // Collide + for (Player player : alivePlayers) + { + if (!_live.containsKey(player.getUniqueId())) + { + continue; + } + + for (Player other : alivePlayers) + { + if (player.equals(other) || UtilPlayer.isSpectator(other) || isTeamDamage(player, other)) + { + continue; + } + + if (UtilMath.offset(player, other) < HIT_BOX) + { + doSlam(player, other); + _live.remove(player.getUniqueId()); + return; + } + } + } + + // End + for (Player player : alivePlayers) + { + UUID key = player.getUniqueId(); + + if (!UtilEnt.isGrounded(player)) + { + continue; + } + + if (!_live.containsKey(key)) + { + continue; + } + + if (!UtilTime.elapsed(_live.get(key), START_TIME)) + { + continue; + } + + _live.remove(key); + } + } + + public void doSlam(Player damager, LivingEntity damagee) + { + if (damagee instanceof Player) + { + if (!Recharge.Instance.use((Player) damagee, GetName() + " Hit", DAMAGE_RATE_LIMIT, false, false)) + { + return; + } + } + + // Recoil Event + if (!isSuperActive(damager)) + { + Manager.GetDamage().NewDamageEvent(damager, damagee, null, DamageCause.CUSTOM, DAMAGE / 4, true, true, false, damager.getName(), GetName() + " Recoil"); + + // Damage Event + Manager.GetDamage().NewDamageEvent(damagee, damager, null, DamageCause.CUSTOM, DAMAGE, true, true, false, damager.getName(), GetName()); + } + + // Inform + UtilPlayer.message(damager, F.main("Game", "You hit " + F.name(UtilEnt.getName(damagee)) + " with " + F.skill(GetName()) + ".")); + UtilPlayer.message(damagee, F.main("Game", F.name(damager.getName()) + " hit you with " + F.skill(GetName()) + ".")); + } + + @EventHandler + public void Knockback(CustomDamageEvent event) + { + if (event.GetReason() == null || !event.GetReason().contains(GetName())) + { + return; + } + + event.AddKnockback(GetName(), KNOCKBACK_MAGNITUDE); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/slime/SmashSlime.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/slime/SmashSlime.java new file mode 100644 index 000000000..16bfccd4e --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/slime/SmashSlime.java @@ -0,0 +1,143 @@ +package nautilus.game.arcade.game.games.smash.perks.slime; + +import java.util.List; + +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.disguise.disguises.DisguiseBase; +import mineplex.core.disguise.disguises.DisguiseSlime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.condition.Condition.ConditionType; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.games.smash.perks.SmashUltimate; + +public class SmashSlime extends SmashUltimate +{ + + private static final int DURATION = 19000; + private static final int HIT_BOX = 5; + private static final int DAMAGE = 8; + + public SmashSlime() + { + super("Giga Slime", new String[] {}, Sound.SLIME_ATTACK, DURATION); + } + + @Override + public void activate(Player player) + { + super.activate(player); + + player.getInventory().remove(Material.IRON_SWORD); + + DisguiseBase disguise = Manager.GetDisguise().getActiveDisguise(player); + if (disguise != null && disguise instanceof DisguiseSlime) + { + DisguiseSlime slime = (DisguiseSlime) disguise; + + slime.SetSize(14); + Manager.GetDisguise().updateDisguise(slime); + } + + player.setExp(0.99f); + + Manager.GetCondition().Factory().Speed(GetName(), player, player, DURATION / 1000, 2, false, false, false); + + } + + @Override + public void cancel(Player player) + { + super.cancel(player); + + Manager.GetCondition().EndCondition(player, ConditionType.SPEED, GetName()); + } + + @EventHandler(priority = EventPriority.LOW) + public void immunityDamagee(CustomDamageEvent event) + { + if (event.GetDamageePlayer() == null || event.GetDamagerEntity(true) == null) + { + return; + } + + if (isUsingUltimate(event.GetDamageePlayer())) + { + event.SetCancelled(GetName()); + } + } + + @EventHandler(priority = EventPriority.LOW) + public void immunityDamager(CustomDamageEvent event) + { + if (event.GetCause() != DamageCause.ENTITY_ATTACK) + { + return; + } + + if (event.GetDamagerPlayer(true) == null) + { + return; + } + + if (isUsingUltimate(event.GetDamagerPlayer(true))) + { + event.SetCancelled(GetName()); + } + } + + @EventHandler + public void collide(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + List<Player> alivePlayers = Manager.GetGame().GetPlayers(true); + + for (Player player : alivePlayers) + { + + if (!isUsingUltimate(player)) + { + continue; + } + + for (Player other : alivePlayers) + { + if (player.equals(other)) + { + continue; + } + + if (UtilPlayer.isSpectator(other)) + { + continue; + } + + if (UtilMath.offset(player.getLocation().add(0, 3, 0), other.getLocation()) < HIT_BOX) + { + Manager.GetDamage().NewDamageEvent(other, player, null, DamageCause.CUSTOM, DAMAGE, true, false, false, player.getName(), GetName()); + + UtilParticle.PlayParticle(ParticleType.SLIME, other.getLocation().add(0, 0.6, 0), 1f, 1f, 1f, 0, 20, ViewDist.LONG, UtilServer.getPlayers()); + + player.getWorld().playSound(other.getLocation(), Sound.SLIME_ATTACK, 3f, 1f); + } + } + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/snowman/PerkArcticAura.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/snowman/PerkArcticAura.java new file mode 100644 index 000000000..aa0ed0242 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/snowman/PerkArcticAura.java @@ -0,0 +1,56 @@ +package nautilus.game.arcade.game.games.smash.perks.snowman; + +import java.util.Map; + +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.kit.Perk; + +public class PerkArcticAura extends Perk +{ + + private static final int DURATION = 2000; + private static final int RANGE = 5; + + public PerkArcticAura() + { + super("Arctic Aura", new String[] { "You freeze things around you, slowing enemies." }); + } + + @EventHandler + public void SnowAura(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + for (Player player : Manager.GetGame().GetPlayers(true)) + { + if (!hasPerk(player)) + { + continue; + } + + if (UtilPlayer.isSpectator(player)) + { + continue; + } + + double range = RANGE * player.getExp(); + + Map<Block, Double> blocks = UtilBlock.getInRadius(player.getLocation(), range); + + for (Block block : blocks.keySet()) + { + Manager.GetBlockRestore().snow(block, (byte) 1, (byte) 1, (int) (DURATION * (1 + blocks.get(block))), 250, 0); + } + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/snowman/PerkBlizzard.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/snowman/PerkBlizzard.java new file mode 100644 index 000000000..7a2690bcf --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/snowman/PerkBlizzard.java @@ -0,0 +1,173 @@ +package nautilus.game.arcade.game.games.smash.perks.snowman; + +import java.util.HashMap; +import java.util.Map; + +import org.bukkit.Sound; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.entity.Snowball; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.kit.Perk; + +public class PerkBlizzard extends Perk +{ + + private static final float MAX_ENERGY = 0.99F; + private static final float ENERGY_PER_TICK = 1 / 60; + private static final float ENERGY_PER_USE = 1 / 9; + private static final int SNOWBALL_PER_USE = 4; + + private Map<Projectile, Player> _snowball = new HashMap<>(); + + public PerkBlizzard() + { + super("Blizzard", new String[] { C.cYellow + "Hold Block" + C.cGray + " to use " + C.cGreen + "Blizzard" }); + } + + @EventHandler + public void EnergyUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + for (Player player : Manager.GetGame().GetPlayers(true)) + { + if (!hasPerk(player)) + { + continue; + } + + if (player.isBlocking()) + { + continue; + } + + player.setExp(Math.min(MAX_ENERGY, player.getExp() + ENERGY_PER_TICK)); + } + } + + @EventHandler + public void Snow(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTEST) + { + return; + } + + for (Player player : Manager.GetGame().GetPlayers(true)) + { + if (!player.isBlocking()) + { + continue; + } + + if (!hasPerk(player)) + { + continue; + } + + // Energy + if (player.getExp() < 0.1) + { + continue; + } + + player.setExp(Math.max(0, player.getExp() - ENERGY_PER_USE)); + + for (int i = 0; i < SNOWBALL_PER_USE; i++) + { + Snowball snow = player.getWorld().spawn(player.getEyeLocation().add(player.getLocation().getDirection()), Snowball.class); + double x = 0.1 - (UtilMath.r(20) / 100d); + double y = UtilMath.r(20) / 100d; + double z = 0.1 - (UtilMath.r(20) / 100d); + snow.setShooter(player); + snow.setVelocity(player.getLocation().getDirection().add(new Vector(x, y, z)).multiply(2)); + _snowball.put(snow, player); + } + + // Effect + player.getWorld().playSound(player.getLocation(), Sound.STEP_SNOW, 0.1f, 0.5f); + } + } + + @EventHandler(priority = EventPriority.LOW) + public void Snowball(CustomDamageEvent event) + { + if (event.GetCause() != DamageCause.PROJECTILE) + { + return; + } + + Projectile proj = event.GetProjectile(); + + if (proj == null) + { + return; + } + + if (!(proj instanceof Snowball)) + { + return; + } + + if (!_snowball.containsKey(proj)) + { + return; + } + + LivingEntity damagee = event.GetDamageeEntity(); + + if (damagee == null) + { + return; + } + + event.SetCancelled("Blizzard"); + + UtilAction.velocity(damagee, proj.getVelocity().multiply(0.15).add(new Vector(0, 0.15, 0))); + + // Damage Event + if (damagee instanceof Player) + { + if (Recharge.Instance.use((Player) damagee, GetName(), 200, false, false)) + { + Manager.GetDamage().NewDamageEvent(damagee, event.GetDamagerEntity(true), null, DamageCause.CUSTOM, 1, false, true, false, UtilEnt.getName(event.GetDamagerEntity(true)), GetName()); + } + } + } + + @EventHandler + public void SnowballForm(ProjectileHitEvent event) + { + Projectile proj = event.getEntity(); + + if (!(proj instanceof Snowball)) + { + return; + } + + if (_snowball.remove(proj) == null) + { + return; + } + + Manager.GetBlockRestore().snow(proj.getLocation().getBlock(), (byte) 1, (byte) 7, 2000, 250, 0); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/snowman/PerkDamageSnow.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/snowman/PerkDamageSnow.java new file mode 100644 index 000000000..3fd58b90e --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/snowman/PerkDamageSnow.java @@ -0,0 +1,49 @@ +package nautilus.game.arcade.game.games.smash.perks.snowman; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilPlayer; +import nautilus.game.arcade.kit.Perk; + +public class PerkDamageSnow extends Perk +{ + private int _damage; + private double _knockback; + + public PerkDamageSnow(int damage, double knockback) + { + super("Snow Attack", new String[] { C.cGray + "+" + damage + " Damage and " + (int) ((knockback - 1) * 100) + "% Knockback to enemies on snow.", }); + + _damage = damage; + _knockback = knockback; + } + + @EventHandler(priority = EventPriority.HIGH) + public void Knockback(CustomDamageEvent event) + { + if (event.GetDamageeEntity().getLocation().getBlock().getType() != Material.SNOW) + { + return; + } + + Player damager = event.GetDamagerPlayer(true); + + if (damager == null) + { + return; + } + + if (!hasPerk(damager) || UtilPlayer.isSpectator(damager)) + { + return; + } + + event.AddMod(damager.getName(), GetName(), _damage, false); + event.AddKnockback("Knockback Snow", _knockback); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkIcePath.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/snowman/PerkIcePath.java similarity index 62% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkIcePath.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/snowman/PerkIcePath.java index 0e87f9d3e..3916424a9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkIcePath.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/snowman/PerkIcePath.java @@ -1,13 +1,13 @@ -package nautilus.game.arcade.kit.perks; +package nautilus.game.arcade.game.games.smash.perks.snowman; import java.util.HashSet; import java.util.Iterator; +import java.util.Set; import org.bukkit.Effect; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.util.Vector; @@ -15,6 +15,9 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilPlayer; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; @@ -24,65 +27,77 @@ import nautilus.game.arcade.kit.perks.data.IcePathData; public class PerkIcePath extends Perk { - private HashSet<IcePathData> _data = new HashSet<IcePathData>(); - public PerkIcePath() + private static final int COOLDOWN = 12000; + private static final int MELT_TIME = 6000; + + private Set<IcePathData> _data = new HashSet<>(); + + public PerkIcePath() { - super("Ice Path", new String[] - { - C.cYellow + "Right-Click" + C.cGray + " with Axe to " + C.cGreen + "Ice Path" - }); + super("Ice Path", new String[] { C.cYellow + "Right-Click" + C.cGray + " with Axe to " + C.cGreen + "Ice Path" }); } @EventHandler public void Skill(PlayerInteractEvent event) { if (event.isCancelled()) + { return; - - if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) + } + + if (!UtilEvent.isAction(event, ActionType.R)) + { return; - + } + if (UtilBlock.usable(event.getClickedBlock())) + { return; - - if (event.getPlayer().getItemInHand() == null) - return; - - if (!event.getPlayer().getItemInHand().getType().toString().contains("_AXE")) - return; - + } + Player player = event.getPlayer(); - - if (!Kit.HasKit(player)) + + if (!UtilItem.isAxe(player.getItemInHand())) + { return; - - if (!Recharge.Instance.use(player, GetName(), 12000, true, true)) + } + + if (!hasPerk(player)) + { return; + } + + if (!Recharge.Instance.use(player, GetName(), COOLDOWN, true, true)) + { + return; + } player.teleport(player.getLocation().add(0, 1, 0)); - UtilAction.velocity(player, new Vector(0,0.5,0)); - + UtilAction.velocity(player, new Vector(0, 0.5, 0)); + _data.add(new IcePathData(player)); - - //Inform + + // Inform UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + ".")); } - + @EventHandler public void Freeze(UpdateEvent event) { if (event.getType() != UpdateType.TICK) + { return; + } Iterator<IcePathData> dataIterator = _data.iterator(); - + while (dataIterator.hasNext()) { - IcePathData data = dataIterator.next(); - + IcePathData data = dataIterator.next(); + Block block = data.GetNextBlock(); - + if (block == null) { dataIterator.remove(); @@ -90,7 +105,7 @@ public class PerkIcePath extends Perk else { block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, 79); - Manager.GetBlockRestore().add(block, 79, (byte) 0, 6000); + Manager.GetBlockRestore().add(block, 79, (byte) 0, MELT_TIME); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/snowman/SmashSnowman.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/snowman/SmashSnowman.java new file mode 100644 index 000000000..83823308a --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/snowman/SmashSnowman.java @@ -0,0 +1,254 @@ +package nautilus.game.arcade.game.games.smash.perks.snowman; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +import org.bukkit.Sound; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.entity.Snowball; +import org.bukkit.entity.Snowman; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilText; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.games.smash.TeamSuperSmash; +import nautilus.game.arcade.game.games.smash.perks.SmashUltimate; + +public class SmashSnowman extends SmashUltimate +{ + + private static final int DURATION = 20000; + private static final int TURRET_HEALTH = 40; + private static final int RATE = 250; + private static final float KNOCKBACK_MAGNITUDE = 2.5F; + private static final int COOLDOWN = 1000; + + private Map<Projectile, Player> _snowball = new HashMap<>(); + + private Map<Snowman, Player> _turret = new HashMap<>(); + + public SmashSnowman() + { + super("Snow Turret", new String[] {}, Sound.STEP_SNOW, DURATION); + } + + @Override + public void activate(Player player) + { +// super.activate(player); + + player.sendMessage(F.main("Game", "Activated " + F.skill(GetName()) + ".")); + + + Game game = Manager.GetGame(); + + game.CreatureAllowOverride = true; + Snowman ent = player.getWorld().spawn(player.getEyeLocation(), Snowman.class); + game.CreatureAllowOverride = false; + + UtilEnt.Vegetate(ent); + UtilEnt.ghost(ent, true, false); + + ent.setMaxHealth(TURRET_HEALTH); + ent.setHealth(TURRET_HEALTH); + + UtilAction.velocity(ent, player.getLocation().getDirection(), 1, false, 0, 0.2, 1, false); + + Recharge.Instance.useForce(player, "Smash Cooldown - " + GetName(), COOLDOWN); + + _turret.put(ent, player); + } + + @Override + public void cancel(Player player) + { +// super.cancel(player); + + player.sendMessage(F.main("Game", "Deactivated " + F.skill(GetName()) + ".")); + + + /* + Iterator<Snowman> iterator = _turret.keySet().iterator(); + + while (iterator.hasNext()) + { + Snowman snowman = iterator.next(); + + if (_turret.get(snowman).equals(player)) + { + UtilParticle.PlayParticle(ParticleType.SNOWBALL_POOF, snowman.getLocation().add(0, 1, 0), 0.4f, 0.4f, 0.4f, 0, 12, ViewDist.LONG, UtilServer.getPlayers()); + snowman.remove(); + iterator.remove(); + return; + } + } + */ + } + + @EventHandler + public void updateSnowman(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTER) + { + return; + } + + Iterator<Snowman> turretIter = _turret.keySet().iterator(); + + while (turretIter.hasNext()) + { + Snowman snowman = turretIter.next(); + + if(snowman.getTicksLived() >= (DURATION/50.0)) + { + UtilParticle.PlayParticle(ParticleType.SNOWBALL_POOF, snowman.getLocation().add(0, 1, 0), 0.4f, 0.4f, 0.4f, 0, 12, ViewDist.LONG, UtilServer.getPlayers()); + snowman.remove(); + turretIter.remove(); + continue; + } + else + { + double amount = 1 - snowman.getTicksLived() / (DURATION/50.0); + snowman.setCustomName(UtilText.getProgress(C.cGreen, amount, C.cRed, false)); + snowman.setCustomNameVisible(true); + } + + Player player = _turret.get(snowman); + Player target = UtilPlayer.getClosest(snowman.getLocation(), TeamSuperSmash.getTeam(Manager, player, true)); + + if (target == null) + { + continue; + } + + snowman.setTarget(target); + + // Snowball + double mult = 1 + Math.min(3, UtilMath.offset(snowman, target) / 16); + double heightBonus = UtilMath.offset(snowman, target) / 140; + Vector rand = new Vector((Math.random() - 0.5) * 0.2, (Math.random() - 0.5) * 0.2, (Math.random() - 0.5) * 0.2); + + _snowball.put(snowman.launchProjectile(Snowball.class, UtilAlg.getTrajectory(snowman.getLocation(), target.getLocation()).multiply(mult).add(rand).add(new Vector(0, heightBonus, 0))), + player); + + // Look dir + UtilEnt.CreatureMoveFast(snowman, target.getLocation(), 0.1f); + + // Sound + snowman.getWorld().playSound(snowman.getLocation(), Sound.STEP_SNOW, 0.6f, 1f); + } + } + + @EventHandler(priority = EventPriority.LOW) + public void snowballHit(CustomDamageEvent event) + { + if (event.GetCause() != DamageCause.PROJECTILE) + { + return; + } + + Projectile proj = event.GetProjectile(); + + if (proj == null) + { + return; + } + + if (!(proj instanceof Snowball)) + { + return; + } + + Player damager = _snowball.get(proj); + + if (damager == null) + { + return; + } + + LivingEntity damagee = event.GetDamageeEntity(); + + if (damagee == null) + { + return; + } + + event.SetCancelled("Turret"); + + if(TeamSuperSmash.getTeam(Manager, damager, true).contains(damagee)) + { + return; + } + + UtilAction.velocity(damagee, proj.getVelocity().multiply(0.3).add(new Vector(0, 0.3, 0))); + + // Damage Event + if (!(damagee instanceof LivingEntity)) + { + return; + } + + if (!Recharge.Instance.use((Player) damagee, GetName() + " Hit", RATE, false, false)) + { + return; + } + + Manager.GetDamage().NewDamageEvent(damagee, damager, null, DamageCause.PROJECTILE, 2, false, true, false, UtilEnt.getName(_snowball.get(proj)), GetName()); + } + + @EventHandler + public void damageCancel(CustomDamageEvent event) + { + if (_turret.containsKey(event.GetDamageeEntity())) + { + event.SetCancelled("Turret Immunity"); + } + } + + @EventHandler + public void clean(ProjectileHitEvent event) + { + _snowball.remove(event.getEntity()); + } + + @EventHandler + public void knockback(CustomDamageEvent event) + { + if (event.GetReason() == null || !event.GetReason().contains(GetName())) + { + return; + } + + event.AddKnockback(GetName(), KNOCKBACK_MAGNITUDE); + } + + @Override + public boolean isUsable(Player player) + { + return Recharge.Instance.usable(player, "Smash Cooldown - " + GetName()); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkNeedler.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/spider/PerkNeedler.java similarity index 60% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkNeedler.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/spider/PerkNeedler.java index 4c39ea23d..d65af9d03 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkNeedler.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/spider/PerkNeedler.java @@ -1,106 +1,127 @@ -package nautilus.game.arcade.kit.perks; +package nautilus.game.arcade.game.games.smash.perks.spider; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.Map; +import java.util.Set; +import java.util.UUID; import org.bukkit.Sound; import org.bukkit.entity.Arrow; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.block.Action; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.player.PlayerInteractEvent; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.SmashPerk; +import nautilus.game.arcade.game.games.smash.perks.SmashPerk; public class PerkNeedler extends SmashPerk { - private HashMap<Player, Integer> _active = new HashMap<Player, Integer>(); - private HashSet<Arrow> _arrows = new HashSet<Arrow>(); - public PerkNeedler() + private static final int COOLDOWN_NORMAL = 2000; + private static final int COOLDOWN_SMASH = 600; + private static final float DAMAGE = 1.1F; + private static final int MAX_TICKS = 300; + + private Map<UUID, Integer> _active = new HashMap<>(); + private Set<Arrow> _arrows = new HashSet<>(); + + public PerkNeedler() { - super("Needler", new String[] - { - C.cYellow + "Hold Block" + C.cGray + " to use " + C.cGreen + "Needler" - }); + super("Needler", new String[] { C.cYellow + "Hold Block" + C.cGray + " to use " + C.cGreen + "Needler" }); } @EventHandler public void Activate(PlayerInteractEvent event) { if (event.isCancelled()) + { return; + } - if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) + if (!UtilEvent.isAction(event, ActionType.R)) + { return; + } if (UtilBlock.usable(event.getClickedBlock())) + { return; - - if (!event.getPlayer().getItemInHand().getType().toString().contains("_SWORD")) - return; + } Player player = event.getPlayer(); - if (!Kit.HasKit(player)) + if (!UtilItem.isSword(player.getItemInHand())) + { return; + } - if (!Recharge.Instance.use(player, GetName(), isSuperActive(player) ? 600 : 2000, !isSuperActive(player), !isSuperActive(player))) + if (!hasPerk(player)) + { return; + } - _active.put(player, 8); + if (!Recharge.Instance.use(player, GetName(), isSuperActive(player) ? COOLDOWN_SMASH : COOLDOWN_NORMAL, !isSuperActive(player), !isSuperActive(player))) + { + return; + } + + _active.put(player.getUniqueId(), 8); UtilPlayer.message(player, F.main("Skill", "You used " + F.skill(GetName()) + ".")); } @EventHandler - public void Update(UpdateEvent event) + public void Update(UpdateEvent event) { if (event.getType() != UpdateType.TICK) return; for (Player cur : UtilServer.getPlayers()) { - if (!_active.containsKey(cur)) + UUID key = cur.getUniqueId(); + + if (!_active.containsKey(key)) + { continue; - + } + if (!cur.isBlocking()) { - _active.remove(cur); + _active.remove(key); continue; } - int count = _active.get(cur) - 1; - - + int count = _active.get(key) - 1; + if (count <= 0) { - _active.remove(cur); + _active.remove(key); continue; } else { - _active.put(cur, count); + _active.put(key, count); } - Arrow arrow = cur.getWorld().spawnArrow(cur.getEyeLocation().add(cur.getLocation().getDirection()), - cur.getLocation().getDirection(), 1.2f, 6); + Arrow arrow = cur.getWorld().spawnArrow(cur.getEyeLocation().add(cur.getLocation().getDirection()), cur.getLocation().getDirection(), 1.2f, 6); arrow.setShooter(cur); _arrows.add(arrow); - //Sound + // Sound cur.getWorld().playSound(cur.getLocation(), Sound.SPIDER_IDLE, 0.8f, 2f); } } @@ -109,45 +130,53 @@ public class PerkNeedler extends SmashPerk public void ArrowDamamge(CustomDamageEvent event) { if (event.GetProjectile() == null) + { return; - + } + if (event.GetDamagerPlayer(true) == null) + { return; - + } + if (!(event.GetProjectile() instanceof Arrow)) + { return; - + } + Player damager = event.GetDamagerPlayer(true); - if (!Kit.HasKit(damager)) + if (!hasPerk(damager)) + { return; - + } + event.SetCancelled("Needler Cancel"); - - event.GetProjectile().remove(); - - //Damage Event - Manager.GetDamage().NewDamageEvent(event.GetDamageeEntity(), damager, null, - DamageCause.THORNS, 1.1, true, true, false, - damager.getName(), GetName()); - if(!Manager.GetGame().GetTeam(event.GetDamageePlayer()).equals(Manager.GetGame().GetTeam(damager))) + event.GetProjectile().remove(); + + // Damage Event + Manager.GetDamage().NewDamageEvent(event.GetDamageeEntity(), damager, null, DamageCause.THORNS, DAMAGE, true, true, false, damager.getName(), GetName()); + + if (!isTeamDamage(damager, event.GetDamageePlayer())) { Manager.GetCondition().Factory().Poison(GetName(), event.GetDamageeEntity(), damager, 2, 0, false, false, false); } } - + @EventHandler public void Clean(UpdateEvent event) { if (event.getType() != UpdateType.SEC) + { return; + } - for (Iterator<Arrow> arrowIterator = _arrows.iterator(); arrowIterator.hasNext();) + for (Iterator<Arrow> arrowIterator = _arrows.iterator(); arrowIterator.hasNext();) { Arrow arrow = arrowIterator.next(); - - if (arrow.isOnGround() || !arrow.isValid() || arrow.getTicksLived() > 300) + + if (arrow.isOnGround() || !arrow.isValid() || arrow.getTicksLived() > MAX_TICKS) { arrowIterator.remove(); arrow.remove(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSpiderLeap.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/spider/PerkSpiderLeap.java similarity index 52% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSpiderLeap.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/spider/PerkSpiderLeap.java index 37d07564d..dc62b516e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSpiderLeap.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/spider/PerkSpiderLeap.java @@ -1,11 +1,11 @@ -package nautilus.game.arcade.kit.perks; +package nautilus.game.arcade.game.games.smash.perks.spider; import java.util.HashSet; +import java.util.Set; +import java.util.UUID; -import org.bukkit.GameMode; import org.bukkit.Sound; import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerToggleFlightEvent; @@ -15,75 +15,88 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; + import nautilus.game.arcade.kit.Perk; public class PerkSpiderLeap extends Perk { - private HashSet<Player> _secondJump = new HashSet<Player>(); - - public PerkSpiderLeap() + + private static final float ENERGY_PER_TICK = 0.005F; + private static final float ENERGY_PER_LEAP = 0.17F; + + private Set<UUID> _secondJump = new HashSet<>(); + private Set<UUID> _finalJump = new HashSet<>(); + + public PerkSpiderLeap() { - super("Spider Leap", new String[] - { - C.cYellow + "Tap Jump Twice" + C.cGray + " to " + C.cGreen + "Spider Leap", - C.cYellow + "Hold Crouch" + C.cGray + " to " + C.cGreen + "Wall Climb", - C.cWhite + "Wall Climb requires Energy (Experience Bar)." - - }); + super("Spider Leap", new String[] { C.cYellow + "Tap Jump Twice" + C.cGray + " to " + C.cGreen + "Spider Leap", C.cYellow + "Hold Crouch" + C.cGray + " to " + C.cGreen + "Wall Climb", C.cWhite + + "Wall Climb requires Energy (Experience Bar)." }); } - + @EventHandler public void WallClimb(UpdateEvent event) { if (event.getType() != UpdateType.TICK) + { return; + } for (Player player : UtilServer.getPlayers()) { - if (Manager.isSpectator(player)) - continue; - - if (!Kit.HasKit(player)) - continue; - - if (!player.isSneaking()) + if (UtilPlayer.isSpectator(player) || !hasPerk(player)) { - if (UtilEnt.isGrounded(player) || UtilBlock.solid(player.getLocation().getBlock().getRelative(BlockFace.DOWN))) - { - player.setExp((float) Math.min(0.999, player.getExp()+(1f/80f))); - _secondJump.remove(player); - } - continue; } - - player.setExp((float) Math.max(0, player.getExp()-(1f/80f))); - + + if (!player.isSneaking()) + { + boolean grounded = UtilEnt.isGrounded(player); + + if (grounded) + { + _secondJump.remove(player.getUniqueId()); + } + + player.setExp(Math.min(0.999F, player.getExp() + (grounded ? ENERGY_PER_TICK * 2 : ENERGY_PER_TICK))); + + continue; + } + + player.setExp(Math.max(0, player.getExp() - ENERGY_PER_TICK)); + if (player.getExp() <= 0) + { continue; - + } + + if (player.getExp() >= ENERGY_PER_LEAP) + { + _finalJump.remove(player.getUniqueId()); + } + if (!Recharge.Instance.usable(player, GetName())) + { continue; - + } + for (Block block : UtilBlock.getSurrounding(player.getLocation().getBlock(), true)) { if (!UtilBlock.airFoliage(block) && !block.isLiquid()) { UtilAction.velocity(player, new Vector(0, 0.2, 0)); - - if (!_secondJump.contains(player)) + + if (!_secondJump.contains(player.getUniqueId())) { player.setAllowFlight(true); - _secondJump.add(player); + _secondJump.add(player.getUniqueId()); } - - continue; } - } + } } } @@ -91,53 +104,61 @@ public class PerkSpiderLeap extends Perk public void FlightHop(PlayerToggleFlightEvent event) { Player player = event.getPlayer(); - - if (!Kit.HasKit(player)) + + if (UtilPlayer.isSpectator(player) || !hasPerk(player)) + { return; - - if (Manager.isSpectator(player)) - return; - - if (player.getGameMode() == GameMode.CREATIVE) - return; - + } + event.setCancelled(true); player.setFlying(false); - - //Disable Flight + + // Disable Flight player.setAllowFlight(false); - - if (player.getExp() < (1f/6f)) - return; - - //Velocity + + if (player.getExp() < ENERGY_PER_LEAP) + { + if (!_finalJump.contains(player.getUniqueId())) + { + _finalJump.add(player.getUniqueId()); + } + else + { + return; + } + } + + // Velocity UtilAction.velocity(player, 1.0, 0.2, 1.0, true); - - //Energy - player.setExp((float) Math.max(0, player.getExp()-(1f/6f))); - - //Sound + + // Energy + player.setExp(Math.max(0, player.getExp() - ENERGY_PER_LEAP)); + + // Sound player.getWorld().playSound(player.getLocation(), Sound.SPIDER_IDLE, 1f, 1.5f); - + Recharge.Instance.use(player, GetName(), 500, false, false); } - + @EventHandler public void FlightUpdate(UpdateEvent event) { if (event.getType() != UpdateType.TICK) + { return; + } for (Player player : UtilServer.getPlayers()) { - if (Manager.isSpectator(player)) + if (UtilPlayer.isSpectator(player) || !hasPerk(player)) + { continue; - - if (!Kit.HasKit(player)) - continue; - - if (UtilEnt.isGrounded(player) || UtilBlock.solid(player.getLocation().getBlock().getRelative(BlockFace.DOWN))) + } + + if (UtilEnt.isGrounded(player)) + { player.setAllowFlight(true); + } } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWebShot.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/spider/PerkWebShot.java similarity index 65% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWebShot.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/spider/PerkWebShot.java index 7103f5ca7..1fdd08267 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWebShot.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/spider/PerkWebShot.java @@ -1,13 +1,13 @@ -package nautilus.game.arcade.kit.perks; +package nautilus.game.arcade.game.games.smash.perks.spider; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.block.Block; +import org.bukkit.entity.Item; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.block.Action; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.util.Vector; @@ -17,91 +17,101 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilPlayer; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.projectile.IThrown; import mineplex.core.projectile.ProjectileUser; import mineplex.core.recharge.Recharge; -import nautilus.game.arcade.kit.SmashPerk; +import nautilus.game.arcade.game.games.smash.perks.SmashPerk; public class PerkWebShot extends SmashPerk implements IThrown { - public PerkWebShot() - { - super("Spin Web", new String[] - { - C.cYellow + "Right-Click" + C.cGray + " with Axe to use " + C.cGreen + "Spin Web" - }); - } + private static final int COOLDOWN_NORMAL = 10000; + private static final int COOLDOWN_SMASH = 1000; + private static final int WEBS = 20; + + public PerkWebShot() + { + super("Spin Web", new String[] { C.cYellow + "Right-Click" + C.cGray + " with Axe to use " + C.cGreen + "Spin Web" }); + } @EventHandler public void ShootWeb(PlayerInteractEvent event) { if (event.isCancelled()) + { return; + } - if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) + if (!UtilEvent.isAction(event, ActionType.R)) + { return; + } if (UtilBlock.usable(event.getClickedBlock())) + { return; - - if (event.getPlayer().getItemInHand() == null) - return; - - if (!event.getPlayer().getItemInHand().getType().toString().contains("_AXE")) - return; + } Player player = event.getPlayer(); - if (!Kit.HasKit(player)) + if (!UtilItem.isAxe(player.getItemInHand())) + { return; + } - if (!Recharge.Instance.use(player, GetName(), isSuperActive(player) ? 1000 : 10000, !isSuperActive(player), !isSuperActive(player))) + if (!hasPerk(player)) + { return; + } + + if (!Recharge.Instance.use(player, GetName(), isSuperActive(player) ? COOLDOWN_SMASH : COOLDOWN_NORMAL, !isSuperActive(player), !isSuperActive(player))) + { + return; + } event.setCancelled(true); - //Boost + // Boost UtilAction.velocity(player, 1.2, 0.2, 1.2, true); - - for (int i=0 ; i<20 ; i++) + + for (int i = 0; i < WEBS; i++) { - org.bukkit.entity.Item ent = player.getWorld().dropItem(player.getLocation().add(0, 0.5, 0), - ItemStackFactory.Instance.CreateStack(Material.WEB, (byte)0, 1, "Web " + player.getName() + " " + i)); - + Item ent = player.getWorld().dropItem(player.getLocation().add(0, 0.5, 0), ItemStackFactory.Instance.CreateStack(Material.WEB, (byte) 0, 1, "Web " + player.getName() + " " + i)); + Vector random = new Vector(Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5); random.normalize(); random.multiply(0.2); - - UtilAction.velocity(ent, player.getLocation().getDirection().multiply(-1).add(random), 1 + Math.random() * 0.4, false, 0, 0.2, 10, false); + + UtilAction.velocity(ent, player.getLocation().getDirection().multiply(-1).add(random), 1 + Math.random() * 0.4, false, 0, 0.2, 10, false); Manager.GetProjectile().AddThrow(ent, player, this, -1, true, true, true, true, 0.5f); } - //Inform + // Inform UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + ".")); - //Effect + // Effect player.getWorld().playSound(player.getLocation(), Sound.SPIDER_IDLE, 2f, 0.6f); } @Override - public void Collide(LivingEntity target, Block block, ProjectileUser data) + public void Collide(LivingEntity target, Block block, ProjectileUser data) { if (target != null) { data.getThrown().remove(); Manager.GetBlockRestore().add(target.getLocation().getBlock(), 30, (byte) 0, 3000); - - //Damage Event - Manager.GetDamage().NewDamageEvent(target, data.getThrower(), null, - DamageCause.PROJECTILE, 6, false, false, false, - UtilEnt.getName(data.getThrower()), GetName()); - + + // Damage Event + Manager.GetDamage().NewDamageEvent(target, data.getThrower(), null, DamageCause.PROJECTILE, 6, false, false, false, UtilEnt.getName(data.getThrower()), GetName()); + UtilAction.zeroVelocity(target); - + return; } @@ -109,13 +119,13 @@ public class PerkWebShot extends SmashPerk implements IThrown } @Override - public void Idle(ProjectileUser data) + public void Idle(ProjectileUser data) { Web(data); } @Override - public void Expire(ProjectileUser data) + public void Expire(ProjectileUser data) { Web(data); } @@ -126,6 +136,8 @@ public class PerkWebShot extends SmashPerk implements IThrown data.getThrown().remove(); if (data.getThrown().getTicksLived() > 3) + { Manager.GetBlockRestore().add(loc.getBlock(), 30, (byte) 0, 2000); + } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSpidersNest.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/spider/SmashSpider.java similarity index 61% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSpidersNest.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/spider/SmashSpider.java index 0bd72c5a9..3ffcf8635 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSpidersNest.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/spider/SmashSpider.java @@ -1,7 +1,7 @@ -package nautilus.game.arcade.kit.perks; +package nautilus.game.arcade.game.games.smash.perks.spider; import java.util.HashMap; -import java.util.WeakHashMap; +import java.util.Map; import org.bukkit.Sound; import org.bukkit.block.Block; @@ -13,108 +13,143 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilServer; import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.kit.SmashPerk; -public class PerkSpidersNest extends SmashPerk +import nautilus.game.arcade.game.games.smash.perks.SmashUltimate; + +public class SmashSpider extends SmashUltimate { - private WeakHashMap<LivingEntity, Double> _preHealth = new WeakHashMap<LivingEntity, Double>(); - - public PerkSpidersNest() + private static final int DURATION = 30000; + + private Map<LivingEntity, Double> _preHealth = new HashMap<>(); + + public SmashSpider() { - super("Spider Nest", new String[] {}); + super("Spider Nest", new String[] {}, Sound.SPIDER_DEATH, DURATION); } - + @Override - public void addSuperCustom(Player player) + public void activate(Player player) { - //Nest - HashMap<Block, Double> blocks = UtilBlock.getInRadius(player.getLocation().getBlock(), 16); - + super.activate(player); + + // Nest + Map<Block, Double> blocks = UtilBlock.getInRadius(player.getLocation().getBlock(), 16); + for (Block block : blocks.keySet()) { if (blocks.get(block) > 0.07) + { continue; - + } + if (!UtilBlock.airFoliage(block)) + { continue; - + } + if (block.getY() > player.getLocation().getY() + 10) + { continue; - + } + if (block.getY() < player.getLocation().getY() - 10) + { continue; - - Manager.GetBlockRestore().add(block, 30, (byte) 0, (long) (30000 + 5000 * Math.random())); + } + + Manager.GetBlockRestore().add(block, 30, (byte) 0, (int) (DURATION + 5000 * Math.random())); } - - //Regen - Manager.GetCondition().Factory().Regen(GetName(), player, player, 30, 0, false, false, false); + + // Regen + Manager.GetCondition().Factory().Regen(GetName(), player, player, DURATION / 1000, 2, false, false, false); } - + @EventHandler(priority = EventPriority.HIGH) public void damagePre(CustomDamageEvent event) { if (event.IsCancelled()) + { return; - - if (event.GetCause() != DamageCause.ENTITY_ATTACK && - event.GetCause() != DamageCause.PROJECTILE && - event.GetCause() != DamageCause.CUSTOM) + } + + if (event.GetCause() != DamageCause.ENTITY_ATTACK && event.GetCause() != DamageCause.PROJECTILE && event.GetCause() != DamageCause.CUSTOM) + { return; + } Player damager = event.GetDamagerPlayer(true); + if (damager == null) + { return; - + } + LivingEntity damagee = event.GetDamageeEntity(); + if (damagee == null) + { return; - - if (!isSuperActive(damager)) + } + + if (!isUsingUltimate(damager)) + { return; - + } + _preHealth.put(damagee, damagee.getHealth()); } - + @EventHandler(priority = EventPriority.MONITOR) public void damagePost(CustomDamageEvent event) { if (event.IsCancelled()) return; - + Player damager = event.GetDamagerPlayer(true); + if (damager == null) + { return; - + } + LivingEntity damagee = event.GetDamageeEntity(); + if (damagee == null) + { return; - - if (!isSuperActive(damager)) - return; - - if (!_preHealth.containsKey(damagee)) + } + + if (!isUsingUltimate(damager)) + { return; - double diff = (_preHealth.remove(damagee) - damagee.getHealth())/2d; - - if (diff <= 0) + } + if (!_preHealth.containsKey(damagee)) + { return; + } - damager.setMaxHealth(Math.min(60, damager.getMaxHealth() + diff)); - damager.setHealth(damager.getHealth() + diff); - - UtilParticle.PlayParticle(ParticleType.HEART, damager.getLocation().add(0, 1, 0), 0, 0, 0, 0, 1, - ViewDist.LONG, UtilServer.getPlayers()); - - UtilParticle.PlayParticle(ParticleType.RED_DUST, damagee.getLocation().add(0, 1, 0), 0.4f, 0.4f, 0.4f, 0, 12, - ViewDist.LONG, UtilServer.getPlayers()); + double diff = (_preHealth.remove(damagee) - damagee.getHealth()) / 2; + + if (diff <= 0) + { + return; + } + damager.setMaxHealth(Math.min(30, damager.getMaxHealth() + diff)); + + UtilParticle.PlayParticle(ParticleType.HEART, damager.getLocation().add(0, 1, 0), 0, 0, 0, 0, 1, ViewDist.LONG, UtilServer.getPlayers()); + + UtilParticle.PlayParticle(ParticleType.RED_DUST, damagee.getLocation().add(0, 1, 0), 0.4f, 0.4f, 0.4f, 0, 12, ViewDist.LONG, UtilServer.getPlayers()); + if (event.GetCause() == DamageCause.ENTITY_ATTACK) - damager.getWorld().playSound(damager.getLocation(), Sound.SPIDER_IDLE, 1.5f, 1f); + { + damager.getWorld().playSound(damager.getLocation(), Sound.SPIDER_IDLE, 1.5f, 1f); + } } + } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/DataSquidGeyser.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/squid/DataSquidGeyser.java similarity index 57% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/DataSquidGeyser.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/squid/DataSquidGeyser.java index 298a40fe3..c0446fc03 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/DataSquidGeyser.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/squid/DataSquidGeyser.java @@ -1,6 +1,6 @@ -package nautilus.game.arcade.game.games.smash.perks; +package nautilus.game.arcade.game.games.smash.perks.squid; -import java.util.HashSet; +import java.util.Set; import org.bukkit.block.Block; import org.bukkit.entity.Player; @@ -8,10 +8,10 @@ import org.bukkit.entity.Player; public class DataSquidGeyser { public Player Player; - public HashSet<Block> Blocks; + public Set<Block> Blocks; public long StartTime; - public DataSquidGeyser(Player player, HashSet<Block> blocks) + public DataSquidGeyser(Player player, Set<Block> blocks) { StartTime = System.currentTimeMillis(); Player = player; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/PerkFishFlurry.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/squid/PerkFishFlurry.java similarity index 62% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/PerkFishFlurry.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/squid/PerkFishFlurry.java index 6ca0a54e1..539e98cf9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/PerkFishFlurry.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/squid/PerkFishFlurry.java @@ -1,8 +1,10 @@ -package nautilus.game.arcade.game.games.smash.perks; +package nautilus.game.arcade.game.games.smash.perks.squid; import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; +import java.util.List; +import java.util.Set; import org.bukkit.Material; import org.bukkit.Sound; @@ -12,7 +14,6 @@ import org.bukkit.entity.Item; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.block.Action; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.util.Vector; @@ -23,13 +24,16 @@ import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.projectile.IThrown; import mineplex.core.projectile.ProjectileUser; @@ -37,130 +41,145 @@ import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.kit.SmashPerk; +import nautilus.game.arcade.game.games.smash.perks.SmashPerk; public class PerkFishFlurry extends SmashPerk implements IThrown { - private ArrayList<DataSquidGeyser> _active = new ArrayList<DataSquidGeyser>(); - public PerkFishFlurry() + private static final int COOLDOWN = 24000; + private static final float DAMAGE = 2.6F; + private static final int START_TIME = 2000; + private static final int END_TIME = 6000; + private static final float KNOCKBACK_MAGNITUDE = 1.5F; + + private List<DataSquidGeyser> _active = new ArrayList<>(); + + public PerkFishFlurry() { - super("Fish Flurry", new String[] - { - C.cYellow + "Right-Click" + C.cGray + " with Spade to use " + C.cGreen + "Fish Flurry" - }); + super("Fish Flurry", new String[] { C.cYellow + "Right-Click" + C.cGray + " with Spade to use " + C.cGreen + "Fish Flurry" }); } - @EventHandler public void shoot(PlayerInteractEvent event) { if (event.isCancelled()) + { return; + } - if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) + if (!UtilEvent.isAction(event, ActionType.R)) + { return; + } if (UtilBlock.usable(event.getClickedBlock())) + { return; - - if (event.getPlayer().getItemInHand() == null) - return; - - if (!event.getPlayer().getItemInHand().getType().toString().contains("_SPADE")) - return; + } Player player = event.getPlayer(); - - if (isSuperActive(player)) - return; - if (!Kit.HasKit(player)) + if (!UtilItem.isSpade(player.getItemInHand())) + { return; - - Block block = player.getTargetBlock((HashSet<Byte>) null, 64); - + } + + if (!hasPerk(player)) + { + return; + } + + if (isSuperActive(player)) + { + return; + } + + Block block = UtilPlayer.getTarget(player, UtilBlock.blockAirFoliageSet, 64); + if (block == null || block.getType() == Material.AIR) { UtilPlayer.message(player, F.main("Game", "You must target a block.")); return; } - if (!Recharge.Instance.use(player, GetName(), 24000, true, true)) + if (!Recharge.Instance.use(player, GetName(), COOLDOWN, true, true)) + { return; + } event.setCancelled(true); - HashSet<Block> blocks = new HashSet<Block>(); - + Set<Block> blocks = new HashSet<>(); + for (Block cur : UtilBlock.getInRadius(block, 3.5d).keySet()) { - if(cur == null) + if (cur == null) + { continue; - + } + if (UtilBlock.airFoliage(cur)) + { continue; - + } + if (!UtilBlock.airFoliage(cur.getRelative(BlockFace.UP))) + { continue; - + } + blocks.add(cur); } - + _active.add(new DataSquidGeyser(player, blocks)); - //Inform + // Inform UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + ".")); } - + @EventHandler public void update(UpdateEvent event) { if (event.getType() != UpdateType.TICK) + { return; - + } + Iterator<DataSquidGeyser> activeIter = _active.iterator(); - + while (activeIter.hasNext()) { DataSquidGeyser data = activeIter.next(); - - //particles + + // particles for (Block block : data.Blocks) + { UtilParticle.PlayParticle(ParticleType.SPLASH, block.getLocation().add(0.5, 1, 0.5), 0.25f, 0, 0.25f, 0, 3, ViewDist.LONG, UtilServer.getPlayers()); - - //sound + } + + // sound Block block = UtilAlg.Random(data.Blocks); if (Math.random() > 0.5) + { block.getWorld().playSound(block.getLocation(), Math.random() > 0.5 ? Sound.SPLASH : Sound.SPLASH2, 0.5f, 1f); + } + + if (!UtilTime.elapsed(data.StartTime, START_TIME)) + { + continue; + } - //Fish - if (!UtilTime.elapsed(data.StartTime, 2000)) + if (!UtilTime.elapsed(data.StartTime, END_TIME)) { - + Item fish = block.getWorld().dropItem(block.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.RAW_FISH, (byte) UtilMath.r(4), 1, "Fish" + Math.random())); + + Vector random = new Vector(Math.random() - 0.5, 1 + Math.random() * 1, Math.random() - 0.5); + + UtilAction.velocity(fish, random, 0.25 + 0.4 * Math.random(), false, 0, 0.2, 10, false); + + Manager.GetProjectile().AddThrow(fish, data.Player, this, -1, true, false, true, true, null, 1f, 1f, null, UpdateType.TICK, 1f); } - else if (!UtilTime.elapsed(data.StartTime, 6000)) - { - for (int i=0 ; i<1 ; i++) - { - Item fish = block.getWorld().dropItem(block.getLocation().add(0.5, 1.5, 0.5), - ItemStackFactory.Instance.CreateStack(Material.RAW_FISH, (byte)UtilMath.r(4), 1, "Fish" + System.currentTimeMillis())); - - Vector random = new Vector( - Math.random() - 0.5, - 1 + Math.random() * 1, - Math.random() - 0.5); - - - UtilAction.velocity(fish, random, 0.25 + 0.4 * Math.random(), false, 0, 0.2, 10, false); - - Manager.GetProjectile().AddThrow(fish, data.Player, this, - -1, true, false, true, true, - null, 1f, 1f, - null, UpdateType.TICK, 1f); - } - } - else + else { activeIter.remove(); } @@ -168,15 +187,13 @@ public class PerkFishFlurry extends SmashPerk implements IThrown } @Override - public void Collide(LivingEntity target, Block block, ProjectileUser data) + public void Collide(LivingEntity target, Block block, ProjectileUser data) { if (target != null) { - //Damage Event - Manager.GetDamage().NewDamageEvent(target, data.getThrower(), null, - DamageCause.PROJECTILE, 3, true, true, false, - UtilEnt.getName(data.getThrower()), GetName()); - + // Damage Event + Manager.GetDamage().NewDamageEvent(target, data.getThrower(), null, DamageCause.PROJECTILE, DAMAGE, false, true, false, UtilEnt.getName(data.getThrower()), GetName()); + UtilParticle.PlayParticle(ParticleType.EXPLODE, target.getLocation().add(0, 1, 0), 1f, 1f, 1f, 0, 12, ViewDist.LONG, UtilServer.getPlayers()); } @@ -184,26 +201,26 @@ public class PerkFishFlurry extends SmashPerk implements IThrown } @Override - public void Idle(ProjectileUser data) + public void Idle(ProjectileUser data) { data.getThrown().remove(); } @Override - public void Expire(ProjectileUser data) + public void Expire(ProjectileUser data) { data.getThrown().remove(); } - @EventHandler public void Knockback(CustomDamageEvent event) { if (event.GetReason() == null || !event.GetReason().contains(GetName())) + { return; + } - event.AddKnockback(GetName(), 1.5); - - event.setKnockbackOrigin(event.GetDamageeEntity().getLocation().add(Math.random()-0.5, -0.1, Math.random()-0.5)); + event.AddKnockback(GetName(), KNOCKBACK_MAGNITUDE); + event.setKnockbackOrigin(event.GetDamageeEntity().getLocation().add(Math.random() - 0.5, -0.1, Math.random() - 0.5)); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkInkBlast.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/squid/PerkInkBlast.java similarity index 66% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkInkBlast.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/squid/PerkInkBlast.java index bc40a81ae..80f6d91a5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkInkBlast.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/squid/PerkInkBlast.java @@ -1,12 +1,12 @@ -package nautilus.game.arcade.kit.perks; +package nautilus.game.arcade.game.games.smash.perks.squid; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.block.Block; +import org.bukkit.entity.Item; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.block.Action; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.util.Vector; @@ -16,122 +16,136 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.projectile.IThrown; import mineplex.core.projectile.ProjectileUser; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.kit.SmashPerk; +import nautilus.game.arcade.game.games.smash.perks.SmashPerk; public class PerkInkBlast extends SmashPerk implements IThrown { + + private static final int COOLDOWN = 6000; + private static final float PROJECTILE_VELOCITY = 0.15F; + private static final int KNOCKBACK_MAGNITUDE = 3; + private int _bullets; private double _damagePerBullet; public PerkInkBlast(int bullets, double damagePerBullet) { - super("Ink Shotgun", new String[] - { - C.cYellow + "Right-Click" + C.cGray + " with Axe to use " + C.cGreen + "Ink Shotgun" - }); + super("Ink Shotgun", new String[] { C.cYellow + "Right-Click" + C.cGray + " with Axe to use " + C.cGreen + "Ink Shotgun" }); _bullets = bullets; _damagePerBullet = damagePerBullet; } - @EventHandler public void shoot(PlayerInteractEvent event) { if (event.isCancelled()) + { return; + } - if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) + if (!UtilEvent.isAction(event, ActionType.R)) + { return; + } if (UtilBlock.usable(event.getClickedBlock())) + { return; - - if (event.getPlayer().getItemInHand() == null) - return; - - if (!event.getPlayer().getItemInHand().getType().toString().contains("_AXE")) - return; + } Player player = event.getPlayer(); - + + if (!UtilItem.isAxe(player.getItemInHand())) + { + return; + } + + if (!hasPerk(player)) + { + return; + } + if (isSuperActive(player)) + { return; + } - if (!Kit.HasKit(player)) - return; - - if (!Recharge.Instance.use(player, GetName(), 5000, true, true)) + if (!Recharge.Instance.use(player, GetName(), COOLDOWN, true, true)) + { return; + } event.setCancelled(true); UtilInv.Update(player); - for (int i=0 ; i < _bullets ; i++) + for (int i = 0; i < _bullets; i++) { - org.bukkit.entity.Item ent = player.getWorld().dropItem(player.getEyeLocation().add(player.getLocation().getDirection()), - ItemStackFactory.Instance.CreateStack(Material.INK_SACK, (byte)0, 1, "Ink" + Math.random())); - + Item ent = player.getWorld().dropItem(player.getEyeLocation().add(player.getLocation().getDirection()), ItemStackFactory.Instance.CreateStack(Material.INK_SACK, (byte) 0, 1, "Ink" + Math + .random())); + Vector random = new Vector(Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5); random.normalize(); - random.multiply(0.15); - - if (i==0) + random.multiply(PROJECTILE_VELOCITY); + + if (i == 0) + { random.multiply(0); - - UtilAction.velocity(ent, player.getLocation().getDirection().add(random), 1 + 0.4 * Math.random(), false, 0, 0.2, 10, false); - - Manager.GetProjectile().AddThrow(ent, player, this, -1, true, true, true, true, - null, 1f, 1f, - ParticleType.EXPLODE, UpdateType.TICK, - 0.5f); + } + + UtilAction.velocity(ent, player.getLocation().getDirection().add(random), 1 + 0.4 * Math.random(), false, 0, 0.2, 10, false); + + Manager.GetProjectile().AddThrow(ent, player, this, -1, true, true, true, true, null, 1f, 1f, ParticleType.EXPLODE, UpdateType.FASTEST, 0.5f); } - //Inform + // Inform UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + ".")); - //Effect + // Effect player.getWorld().playSound(player.getLocation(), Sound.EXPLODE, 1.5f, 0.75f); player.getWorld().playSound(player.getLocation(), Sound.SPLASH, 0.75f, 1f); } @Override - public void Collide(LivingEntity target, Block block, ProjectileUser data) + public void Collide(LivingEntity target, Block block, ProjectileUser data) { Explode(data); - - if (target == null) - return; - //Damage Event - Manager.GetDamage().NewDamageEvent(target, data.getThrower(), null, - DamageCause.PROJECTILE, _damagePerBullet, true, true, false, - UtilEnt.getName(data.getThrower()), GetName()); - + if (target == null) + { + return; + } + + // Damage Event + Manager.GetDamage().NewDamageEvent(target, data.getThrower(), null, DamageCause.PROJECTILE, _damagePerBullet, true, true, false, UtilEnt.getName(data.getThrower()), GetName()); + UtilParticle.PlayParticle(ParticleType.EXPLODE, target.getLocation().add(0, 1, 0), 1f, 1f, 1f, 0, 12, ViewDist.LONG, UtilServer.getPlayers()); } @Override - public void Idle(ProjectileUser data) + public void Idle(ProjectileUser data) { Explode(data); } @Override - public void Expire(ProjectileUser data) + public void Expire(ProjectileUser data) { Explode(data); } @@ -141,13 +155,15 @@ public class PerkInkBlast extends SmashPerk implements IThrown data.getThrown().getWorld().playSound(data.getThrown().getLocation(), Sound.EXPLODE, 0.75f, 1.25f); data.getThrown().remove(); } - + @EventHandler public void Knockback(CustomDamageEvent event) { if (event.GetReason() == null || !event.GetReason().contains(GetName())) + { return; - - event.AddKnockback(GetName(), 3); + } + + event.AddKnockback(GetName(), KNOCKBACK_MAGNITUDE); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSuperSquid.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/squid/PerkSuperSquid.java similarity index 58% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSuperSquid.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/squid/PerkSuperSquid.java index 385cb0d51..dc203d554 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSuperSquid.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/squid/PerkSuperSquid.java @@ -1,101 +1,125 @@ -package nautilus.game.arcade.kit.perks; +package nautilus.game.arcade.game.games.smash.perks.squid; import java.util.HashMap; +import java.util.Map; +import java.util.UUID; -import org.bukkit.Effect; import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerInteractEvent; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.kit.SmashPerk; +import nautilus.game.arcade.game.games.smash.perks.SmashPerk; public class PerkSuperSquid extends SmashPerk { - private HashMap<Player, Long> _active = new HashMap<Player, Long>(); - public PerkSuperSquid() + private static final int COOLDOWN = 8000; + private static final int VELOCITY_TIME = 1100; + + private Map<UUID, Long> _active = new HashMap<>(); + + public PerkSuperSquid() { - super("Super Squid", new String[] - { - C.cYellow + "Hold Block" + C.cGray + " to use " + C.cGreen + "Super Squid", - }); + super("Super Squid", new String[] { C.cYellow + "Hold Block" + C.cGray + " to use " + C.cGreen + "Super Squid", }); } - + @EventHandler public void Activate(PlayerInteractEvent event) { if (event.isCancelled()) + { return; - - if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) + } + + if (!UtilEvent.isAction(event, ActionType.R)) + { return; - + } + if (UtilBlock.usable(event.getClickedBlock())) + { return; - - if (!event.getPlayer().getItemInHand().getType().toString().contains("_SWORD")) - return; - + } + Player player = event.getPlayer(); + + if (!UtilItem.isSword(player.getItemInHand())) + { + return; + } + + if (!hasPerk(player)) + { + return; + } if (isSuperActive(player)) + { return; - - if (!Kit.HasKit(player)) + } + + if (!Recharge.Instance.use(player, GetName(), COOLDOWN, true, true)) + { return; + } - if (!Recharge.Instance.use(player, GetName(), 8000, true, true)) - return; - - _active.put(player, System.currentTimeMillis()); + _active.put(player.getUniqueId(), System.currentTimeMillis()); UtilPlayer.message(player, F.main("Skill", "You used " + F.skill(GetName()) + ".")); } - + @EventHandler - public void Update(UpdateEvent event) + public void Update(UpdateEvent event) { if (event.getType() != UpdateType.TICK) + { return; - + } + for (Player cur : UtilServer.getPlayers()) { - if (!_active.containsKey(cur)) - continue; - - if (isSuperActive(cur)) - return; - - if (!cur.isBlocking()) + if (!_active.containsKey(cur.getUniqueId())) { - _active.remove(cur); continue; } - if (UtilTime.elapsed(_active.get(cur), 1100)) + if (isSuperActive(cur)) { - _active.remove(cur); + continue; + } + + if (!cur.isBlocking()) + { + _active.remove(cur.getUniqueId()); + continue; + } + + if (UtilTime.elapsed(_active.get(cur.getUniqueId()), VELOCITY_TIME)) + { + _active.remove(cur.getUniqueId()); continue; } UtilAction.velocity(cur, 0.6, 0.1, 1, true); - + cur.getWorld().playSound(cur.getLocation(), Sound.SPLASH2, 0.5f, 1f); UtilParticle.PlayParticle(ParticleType.SPLASH, cur.getLocation().add(0, 0.5, 0), 0.3f, 0.3f, 0.3f, 0, 60, ViewDist.LONG, UtilServer.getPlayers()); } @@ -104,7 +128,9 @@ public class PerkSuperSquid extends SmashPerk @EventHandler public void DamageCancel(CustomDamageEvent event) { - if (_active.containsKey(event.GetDamageeEntity())) - event.SetCancelled("Super Squid"); + if (_active.containsKey(event.GetDamageeEntity().getUniqueId())) + { + event.SetCancelled(GetName()); + } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkStormSquid.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/squid/SmashSquid.java similarity index 54% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkStormSquid.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/squid/SmashSquid.java index a355bb013..118449e13 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkStormSquid.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/squid/SmashSquid.java @@ -1,11 +1,13 @@ -package nautilus.game.arcade.kit.perks; +package nautilus.game.arcade.game.games.smash.perks.squid; import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.Location; +import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -21,85 +23,121 @@ import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.kit.SmashKit; -import nautilus.game.arcade.kit.SmashPerk; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.games.smash.kits.KitSkySquid; +import nautilus.game.arcade.game.games.smash.perks.SmashUltimate; -public class PerkStormSquid extends SmashPerk +public class SmashSquid extends SmashUltimate { - public PerkStormSquid() - { - super("Storm Squid", new String[] - { - }, false); - } - @Override - public void addSuperCustom(Player player) - { - - } + private static final int DURATION = 24000; + private static final int RATE = 1600; + private static final int MAX_RANGE = 100; + private static final int DAMAGE = 16; + private static final int DAMAGE_RADIUS = 8; + private static final int KNOCKBACK_MAGNITUDE = 3; - @Override - public void removeSuperCustom(Player player) + public SmashSquid() { - player.setFlying(false); + super("Storm Squid", new String[] {}, Sound.SPLASH2, DURATION); } - @EventHandler(priority = EventPriority.LOW) //Happen before activation of Super + @Override + public void activate(Player player) + { + super.activate(player); + + Game game = Manager.GetGame(); + + game.WorldWeatherEnabled = true; + game.WorldData.World.setStorm(true); + game.WorldData.World.setThundering(true); + game.WorldData.World.setThunderDuration(9999); + + if (Kit instanceof KitSkySquid) + { + KitSkySquid squid = (KitSkySquid) Kit; + + squid.giveSmashItems(player); + } + } + + @Override + public void cancel(Player player) + { + super.cancel(player); + + Game game = Manager.GetGame(); + + game.WorldWeatherEnabled = false; + + player.setFlying(false); + } + + @EventHandler(priority = EventPriority.LOW) // Happen before activation of + // Super public void lightningStrike(PlayerInteractEvent event) { final Player player = event.getPlayer(); - if (!isSuperActive(player)) + if (!isUsingUltimate(player)) + { return; + } if (event.getAction() == Action.PHYSICAL) + { return; + } + + Block block = UtilPlayer.getTarget(player, UtilBlock.blockAirFoliageSet, MAX_RANGE); - Block block = player.getTargetBlock((HashSet<Byte>) null, 100); if (block == null) + { return; - + } + final Location loc = block.getLocation().add(0.5, 0.5, 0.5); - - if (!Recharge.Instance.use(player, GetName() + " Strike", 1600, false, false)) + + if (!Recharge.Instance.use(player, GetName() + " Strike", RATE, false, false)) + { return; - - //Warning - UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, loc.clone().add(0, 0.5, 0), 1f, 1f, 1f, 0.1f, 40, - ViewDist.MAX, UtilServer.getPlayers()); - UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, loc.clone().add(0, 0.5, 0), 0, 0, 0, 0, 1, - ViewDist.MAX, UtilServer.getPlayers()); - + } + + // Warning + UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, loc.clone().add(0, 0.5, 0), 1f, 1f, 1f, 0.1f, 40, ViewDist.MAX, UtilServer.getPlayers()); + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, loc.clone().add(0, 0.5, 0), 0, 0, 0, 0, 1, ViewDist.MAX, UtilServer.getPlayers()); + Bukkit.getScheduler().runTaskLater(Manager.getPlugin(), new Runnable() { @Override public void run() { - //Warning + // Warning player.getWorld().spigot().strikeLightningEffect(loc, false); - - HashMap<LivingEntity, Double> targets = UtilEnt.getInRadius(loc, 8); + + Map<LivingEntity, Double> targets = UtilEnt.getInRadius(loc, DAMAGE_RADIUS); + for (LivingEntity cur : targets.keySet()) { if (cur.equals(player)) + { continue; + } - //Damage Event - Manager.GetDamage().NewDamageEvent(cur, player, null, - DamageCause.CUSTOM, 16 * targets.get(cur), false, true, false, - player.getName(), GetName()); - - //Velocity - UtilAction.velocity(cur, UtilAlg.getTrajectory(loc, cur.getLocation()), - 3 * targets.get(cur), false, 0, 1 * targets.get(cur), 2, true); + // Damage Event + Manager.GetDamage().NewDamageEvent(cur, player, null, DamageCause.CUSTOM, DAMAGE * targets.get(cur), false, true, false, player.getName(), GetName()); + + // Velocity + UtilAction.velocity(cur, UtilAlg.getTrajectory(loc, cur.getLocation()), 3 * targets.get(cur), false, 0, 1 * targets.get(cur), 2, true); } } }, 10); @@ -109,17 +147,26 @@ public class PerkStormSquid extends SmashPerk public void attackCancel(CustomDamageEvent event) { if (event.IsCancelled()) + { return; + } Player player = event.GetDamagerPlayer(true); - if (player == null) - return; - if (!isSuperActive(player)) + if (player == null) + { return; + } + + if (!isUsingUltimate(player)) + { + return; + } if (event.GetCause() != DamageCause.ENTITY_ATTACK) + { return; + } event.SetCancelled("Wither Form Melee Cancel"); } @@ -128,29 +175,49 @@ public class PerkStormSquid extends SmashPerk public void flight(UpdateEvent event) { if (event.getType() != UpdateType.TICK) - return; - - for (Player player : ((SmashKit)Kit).getSuperActive()) { - if (player.isFlying()) + return; + } + + for (UUID uuid : getLastUltimate().keySet()) + { + Player player = UtilPlayer.searchExact(uuid); + + if (player == null) + { continue; + } + + if (player.isFlying()) + { + continue; + } player.setAllowFlight(true); player.setFlying(true); } } - + @EventHandler public void flightBump(UpdateEvent event) { if (event.getType() != UpdateType.FASTER) - return; - - for (Player player : ((SmashKit)Kit).getSuperActive()) { - ArrayList<Location> collisions = new ArrayList<Location>(); + return; + } - //Bump + for (UUID uuid : getLastUltimate().keySet()) + { + Player player = UtilPlayer.searchExact(uuid); + + if (player == null) + { + continue; + } + + List<Location> collisions = new ArrayList<>(); + + // Bump for (Block block : UtilBlock.getInRadius(player.getLocation().add(0, 0.5, 0), 1.5d).keySet()) { if (!UtilBlock.airFoliage(block)) @@ -162,18 +229,22 @@ public class PerkStormSquid extends SmashPerk Vector vec = UtilAlg.getAverageBump(player.getLocation(), collisions); if (vec == null) + { continue; + } UtilAction.velocity(player, vec, 0.6, false, 0, 0.4, 10, true); } } - + @EventHandler public void knockback(CustomDamageEvent event) { if (event.GetReason() == null || !event.GetReason().contains(GetName())) + { return; - - event.AddKnockback(GetName(), 3); + } + + event.AddKnockback(GetName(), KNOCKBACK_MAGNITUDE); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/witch/PerkBatWave.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/witch/PerkBatWave.java new file mode 100644 index 000000000..6433024c5 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/witch/PerkBatWave.java @@ -0,0 +1,316 @@ +package nautilus.game.arcade.game.games.smash.perks.witch; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; + +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.entity.Bat; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilItem; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import nautilus.game.arcade.game.games.smash.perks.SmashPerk; + +public class PerkBatWave extends SmashPerk +{ + + private static final int COOLDOWN = 8000; + private static final int LEASH_COOLDOWN = 500; + private static final int HIT_COOLDOWN = 200; + private static final int HIT_BOX = 2; + private static final int DAMAGE = 3; + private static final int DISABLE_DAMAGE = 20; + private static final float KNOCKBACK_MAGNITUDE = 1.75F; + + private static final String LEASH = "Leash Bats"; + private static final String HIT = "Hit By Bat"; + + private Map<UUID, Long> _active = new HashMap<>(); + private Map<UUID, Location> _direction = new HashMap<>(); + private Map<UUID, List<Bat>> _bats = new HashMap<>(); + private Map<UUID, Double> _damageTaken = new HashMap<>(); + private Set<UUID> _pulling = new HashSet<>(); + private Set<UUID> _allowLeash = new HashSet<>(); + + public PerkBatWave() + { + super("Bat Wave", new String[] { C.cYellow + "Right-Click" + C.cGray + " with Spade to use " + C.cGreen + "Bat Wave", C.cYellow + "Double Right-Click" + C.cGray + " with Spade to use " + + C.cGreen + "Bat Leash" }); + } + + @EventHandler + public void Activate(PlayerInteractEvent event) + { + if (event.isCancelled()) + { + return; + } + + if (!UtilEvent.isAction(event, ActionType.R)) + { + return; + } + + if (UtilBlock.usable(event.getClickedBlock())) + { + return; + } + + Player player = event.getPlayer(); + + if (!UtilItem.isSpade(player.getItemInHand())) + { + return; + } + + if (!hasPerk(player)) + { + return; + } + + if (isSuperActive(player)) + { + return; + } + + UUID key = player.getUniqueId(); + + if (!Recharge.Instance.use(player, GetName(), COOLDOWN, false, true)) + { + if (_active.containsKey(key)) + { + if (!Recharge.Instance.use(player, LEASH, LEASH_COOLDOWN, false, false)) + { + return; + } + + if (!_pulling.remove(key)) + { + if (_allowLeash.remove(key)) + { + _pulling.add(key); + + for (Bat bat : _bats.get(key)) + { + bat.setLeashHolder(player); + } + } + } + else + { + for (Bat bat : _bats.get(key)) + { + bat.setLeashHolder(null); + } + } + } + else + { + // Inform + Recharge.Instance.use(player, GetName(), COOLDOWN, true, true); + } + } + else + { + // Start + _direction.put(key, player.getEyeLocation()); + _active.put(key, System.currentTimeMillis()); + _allowLeash.add(key); + + _bats.put(key, new ArrayList<Bat>()); + + Manager.GetGame().CreatureAllowOverride = true; + + for (int i = 0; i < 32; i++) + { + Bat bat = player.getWorld().spawn(player.getEyeLocation(), Bat.class); + _bats.get(key).add(bat); + } + + Manager.GetGame().CreatureAllowOverride = false; + + // Inform + UtilPlayer.message(player, F.main("Skill", "You used " + F.skill(GetName()) + ".")); + } + } + + @EventHandler + public void Update(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + for (Player cur : UtilServer.getPlayers()) + { + UUID key = cur.getUniqueId(); + + if (!_active.containsKey(key)) + { + continue; + } + + if (UtilTime.elapsed(_active.get(key), 2500)) + { + Clear(cur); + continue; + } + + Location loc = _direction.get(key); + + Vector batVec = new Vector(0, 0, 0); + double batCount = 0; + + // Bat Movement + for (Bat bat : _bats.get(key)) + { + if (!bat.isValid()) + { + continue; + } + + batVec.add(bat.getLocation().toVector()); + batCount++; + + Vector rand = new Vector((Math.random() - 0.5) / 2, (Math.random() - 0.5) / 2, (Math.random() - 0.5) / 2); + bat.setVelocity(loc.getDirection().clone().multiply(0.5).add(rand)); + + for (Player other : Manager.GetGame().GetPlayers(true)) + { + if (other.equals(cur)) + { + continue; + } + + if (!Recharge.Instance.usable(other, HIT)) + { + continue; + } + + if (UtilEnt.hitBox(bat.getLocation(), other, HIT_BOX, null)) + { + // Damage Event + Manager.GetDamage().NewDamageEvent(other, cur, null, DamageCause.CUSTOM, DAMAGE, true, true, false, cur.getName(), GetName()); + + // Effect + bat.getWorld().playSound(bat.getLocation(), Sound.BAT_HURT, 1f, 1f); + UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, bat.getLocation(), 0, 0, 0, 0, 3, ViewDist.LONG, UtilServer.getPlayers()); + + bat.remove(); + + // Recharge on hit + Recharge.Instance.useForce(other, HIT, HIT_COOLDOWN); + } + } + } + + // Player Pull + if (_pulling.contains(key)) + { + batVec.multiply(1 / batCount); + + Location batLoc = batVec.toLocation(cur.getWorld()); + + UtilAction.velocity(cur, UtilAlg.getTrajectory(cur.getLocation(), batLoc), 0.35, false, 0, 0, 10, false); + } + } + } + + @EventHandler + public void PlayerQuit(PlayerQuitEvent event) + { + Clear(event.getPlayer()); + } + + @EventHandler + public void PlayerDeath(PlayerDeathEvent event) + { + Clear(event.getEntity()); + } + + public void Clear(Player player) + { + UUID key = player.getUniqueId(); + + _active.remove(key); + _direction.remove(key); + _pulling.remove(key); + _damageTaken.remove(key); + + if (_bats.containsKey(key)) + { + for (Bat bat : _bats.get(key)) + { + if (bat.isValid()) + { + UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, bat.getLocation(), 0, 0, 0, 0, 3, ViewDist.LONG, UtilServer.getPlayers()); + } + + bat.remove(); + } + + _bats.remove(player); + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void damage(CustomDamageEvent event) + { + if (event.GetDamageePlayer() != null) + { + Player player = event.GetDamageePlayer(); + UUID key = player.getUniqueId(); + + _damageTaken.putIfAbsent(key, 0D); + + if (hasPerk(player) && _damageTaken.containsKey(key) && _pulling.contains(key)) + { + _damageTaken.put(key, (_damageTaken.get(key) + event.GetDamage())); + + if (_damageTaken.get(key) >= DISABLE_DAMAGE) + { + Clear(player); + } + } + } + + if (event.GetReason() == null || !event.GetReason().contains(GetName())) + { + return; + } + + event.AddKnockback(GetName(), KNOCKBACK_MAGNITUDE); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/witch/PerkWitchPotion.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/witch/PerkWitchPotion.java new file mode 100644 index 000000000..02dd04394 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/witch/PerkWitchPotion.java @@ -0,0 +1,182 @@ +package nautilus.game.arcade.game.games.smash.perks.witch; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.bukkit.block.Block; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.entity.ThrownPotion; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilItem; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.projectile.IThrown; +import mineplex.core.projectile.ProjectileUser; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import nautilus.game.arcade.game.games.smash.TeamSuperSmash; +import nautilus.game.arcade.game.games.smash.perks.SmashPerk; + +public class PerkWitchPotion extends SmashPerk implements IThrown +{ + + private static final int COOLDOWN = 2000; + private static final int RANGE_NOMRAL = 3; + private static final int DAMAGE_DIRECT = 7; + private static final int DAMAGE_DISTANCE = 6; + private static final int KNOCKBACK_MAGNITUDE = 2; + + private List<Projectile> _proj = new ArrayList<>(); + + public PerkWitchPotion() + { + super("Daze Potion", new String[] { C.cYellow + "Right-Click" + C.cGray + " with Axe to use " + C.cGreen + "Daze Potion" }); + } + + @EventHandler + public void Activate(PlayerInteractEvent event) + { + if (event.isCancelled()) + { + return; + } + + if (!UtilEvent.isAction(event, ActionType.R)) + { + return; + } + + if (UtilBlock.usable(event.getClickedBlock())) + { + return; + } + + Player player = event.getPlayer(); + + if (!UtilItem.isAxe(player.getItemInHand())) + { + return; + } + + if (!hasPerk(player)) + { + return; + } + + if (isSuperActive(player)) + { + return; + } + + if (!Recharge.Instance.use(player, GetName(), COOLDOWN, true, true)) + { + return; + } + + // Start + ThrownPotion potion = player.launchProjectile(ThrownPotion.class); + UtilAction.velocity(potion, player.getLocation().getDirection(), 1, false, 0, 0.2, 10, false); + + _proj.add(potion); + + Manager.GetProjectile().AddThrow(potion, player, this, 10000, true, true, true, false, false, 0); + + // Inform + UtilPlayer.message(player, F.main("Skill", "You used " + F.skill(GetName()) + ".")); + } + + @EventHandler + public void Update(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + Iterator<Projectile> potionIterator = _proj.iterator(); + + while (potionIterator.hasNext()) + { + Projectile proj = potionIterator.next(); + + if (!proj.isValid()) + { + potionIterator.remove(); + continue; + } + + UtilParticle.PlayParticle(ParticleType.MOB_SPELL, proj.getLocation(), 0, 0, 0, 0, 1, ViewDist.LONGER, UtilServer.getPlayers()); + } + } + + @EventHandler + public void Knockback(CustomDamageEvent event) + { + if (event.GetReason() == null || !event.GetReason().contains(GetName())) + { + return; + } + + event.AddKnockback(GetName(), KNOCKBACK_MAGNITUDE); + } + + @Override + public void Collide(LivingEntity target, Block block, ProjectileUser data) + { + Player thrower = (Player) data.getThrower(); + + List<Player> players = new ArrayList<>(); + players.addAll(Manager.GetGame().GetPlayers(true)); + players.removeAll(TeamSuperSmash.getTeam(Manager, thrower, true)); + + List<Player> directHit = UtilEnt.getPlayersInsideEntity(data.getThrown(), players); + + for (Player player : directHit) + { + Manager.GetDamage().NewDamageEvent(player, thrower, null, DamageCause.CUSTOM, DAMAGE_DIRECT, true, true, false, thrower.getName(), GetName()); + } + + players.removeAll(directHit); + + Vector a = data.getThrown().getLocation().subtract(RANGE_NOMRAL, RANGE_NOMRAL, RANGE_NOMRAL).toVector(); + Vector b = data.getThrown().getLocation().add(RANGE_NOMRAL, RANGE_NOMRAL, RANGE_NOMRAL).toVector(); + for (Player player : players) + { + if(!UtilEnt.isInsideBoundingBox(player, a, b)) continue; + + Manager.GetDamage().NewDamageEvent(player, thrower, null, DamageCause.CUSTOM, DAMAGE_DISTANCE, true, true, false, thrower.getName(), GetName()); + } + } + + @Override + public void Idle(ProjectileUser data) + { + Collide(null, null, data); + } + + @Override + public void Expire(ProjectileUser data) + { + Collide(null, null, data); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBatForm.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/witch/SmashWitch.java similarity index 55% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBatForm.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/witch/SmashWitch.java index cdbe1d699..c8c048c3b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBatForm.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/witch/SmashWitch.java @@ -1,11 +1,12 @@ -package nautilus.game.arcade.kit.perks; +package nautilus.game.arcade.game.games.smash.perks.witch; import java.util.ArrayList; -import java.util.HashMap; import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.UUID; import org.bukkit.GameMode; -import org.bukkit.Location; import org.bukkit.Sound; import org.bukkit.block.BlockFace; import org.bukkit.entity.LivingEntity; @@ -22,176 +23,219 @@ import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; import mineplex.core.disguise.disguises.DisguiseBat; -import mineplex.core.disguise.disguises.DisguiseWitch; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.kit.SmashKit; -import nautilus.game.arcade.kit.SmashPerk; +import nautilus.game.arcade.game.games.smash.kits.KitWitch; +import nautilus.game.arcade.game.games.smash.perks.SmashKit; +import nautilus.game.arcade.game.games.smash.perks.SmashUltimate; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.PerkDoubleJump; import nautilus.game.arcade.kit.perks.data.SonicBoomData; -public class PerkBatForm extends SmashPerk +public class SmashWitch extends SmashUltimate { - private ArrayList<SonicBoomData> _sonic = new ArrayList<SonicBoomData>(); - public PerkBatForm() + private static final int DURATION = 20000; + private static final int COOLDOWN = 1200; + private static final int MAX_TIME = 12000; + private static final int HIT_BOX = 4; + private static final int DAMAGE_RADIUS = 10; + private static final int DAMAGE = 12; + private static final int FLAP_COOLDOWN = 40; + private static final int KNOCKBACK_MAGNITUDE = 2; + + private List<SonicBoomData> _sonic = new ArrayList<>(); + + public SmashWitch() { - super("Bat Form", new String[] - { - }, false); + super("Bat Form", new String[] {}, Sound.BAT_HURT, DURATION); } @Override - public void addSuperCustom(Player player) + public void activate(Player player) { - Manager.GetDisguise().undisguise(player); + super.activate(player); + + if (Kit instanceof KitWitch) + { + KitWitch kit = (KitWitch) Kit; + + kit.giveSmashItems(player); + } + + for (Perk perk : Kit.GetPerks()) + { + if (perk instanceof PerkDoubleJump) + { + ((PerkDoubleJump) perk).disableForPlayer(player); + } + } + + Manager.GetDisguise().undisguise(Manager.GetDisguise().getActiveDisguise(player)); - //Disguise - DisguiseBat disguise = new DisguiseBat(player); - - if (Manager.GetGame().GetTeam(player) != null) - disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); - else - disguise.setName(player.getName()); - - disguise.setCustomNameVisible(true); - Manager.GetDisguise().disguise(disguise); + SmashKit kit = (SmashKit) Kit; + kit.disguise(player, DisguiseBat.class); } @Override - public void removeSuperCustom(Player player) + public void cancel(Player player) { - Manager.GetDisguise().undisguise(player); + super.cancel(player); + + for (Perk perk : Kit.GetPerks()) + { + if (perk instanceof PerkDoubleJump) + { + ((PerkDoubleJump) perk).enableForPlayer(player); + } + } + + Manager.GetDisguise().undisguise(Manager.GetDisguise().getActiveDisguise(player)); - //Disguise - DisguiseWitch disguise = new DisguiseWitch(player); - - if (Manager.GetGame().GetTeam(player) != null) - disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); - else - disguise.setName(player.getName()); - - disguise.setCustomNameVisible(true); - Manager.GetDisguise().disguise(disguise); + SmashKit kit = (SmashKit) Kit; + kit.disguise(player); } @EventHandler(priority = EventPriority.LOWEST) public void attackCancel(CustomDamageEvent event) { if (event.IsCancelled()) + { return; - + } + Player player = event.GetDamagerPlayer(true); + if (player == null) + { return; - - if (!isSuperActive(player)) + } + + if (!isUsingUltimate(player)) + { return; - + } + if (event.GetCause() != DamageCause.ENTITY_ATTACK) + { return; - + } + event.SetCancelled("Bat Form Melee Cancel"); } - - @EventHandler(priority = EventPriority.LOW) //Happen before activation of Super + + @EventHandler(priority = EventPriority.LOW) // Happen before activation of + // Super public void sonicBoom(PlayerInteractEvent event) { Player player = event.getPlayer(); - if (!isSuperActive(player)) + if (!isUsingUltimate(player)) + { return; - + } + if (event.getAction() == Action.PHYSICAL) + { return; + } - if (!Recharge.Instance.use(player, GetName() + " Screech", 1200, false, false)) + if (!Recharge.Instance.use(player, GetName() + " Screech", COOLDOWN, false, false)) + { return; - - //Effect + } + + // Effect player.getWorld().playSound(player.getLocation(), Sound.BAT_HURT, 1f, 0.75f); - + _sonic.add(new SonicBoomData(player)); } - + @EventHandler public void sonicBoomUpdate(UpdateEvent event) { if (event.getType() != UpdateType.TICK) + { return; + } Iterator<SonicBoomData> sonicIter = _sonic.iterator(); - + while (sonicIter.hasNext()) { SonicBoomData data = sonicIter.next(); - - //Time Boom - if (UtilTime.elapsed(data.Time, 12000)) + + // Time Boom + if (UtilTime.elapsed(data.Time, MAX_TIME)) { sonicIter.remove(); explode(data); continue; } - - //Block Boom + + // Block Boom if (!UtilBlock.airFoliage(data.Location.getBlock())) { sonicIter.remove(); explode(data); continue; } - - //Proxy Boom + + // Proxy Boom for (Player player : Manager.GetGame().GetPlayers(true)) { if (Manager.isSpectator(player)) + { continue; + } if (player.equals(data.Shooter)) + { continue; + } - if (UtilMath.offset(player.getLocation().add(0, 1, 0), data.Location) < 4) + if (UtilMath.offset(player.getLocation().add(0, 1, 0), data.Location) < HIT_BOX) { sonicIter.remove(); explode(data); continue; } } - - //Move + + // Move data.Location.add(data.Direction.clone().multiply(1)); - - //Effect - UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, data.Location, 0, 0, 0, 0, 1, - ViewDist.MAX, UtilServer.getPlayers()); + + // Effect + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, data.Location, 0, 0, 0, 0, 1, ViewDist.MAX, UtilServer.getPlayers()); data.Location.getWorld().playSound(data.Location, Sound.FIZZ, 1f, 2f); } } private void explode(SonicBoomData data) { - //Effect - UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, data.Location, 0, 0, 0, 0, 1, - ViewDist.MAX, UtilServer.getPlayers()); + // Effect + UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, data.Location, 0, 0, 0, 0, 1, ViewDist.MAX, UtilServer.getPlayers()); data.Location.getWorld().playSound(data.Location, Sound.EXPLODE, 1f, 1.5f); + + // Damage + Map<LivingEntity, Double> targets = UtilEnt.getInRadius(data.Location, DAMAGE_RADIUS); - //Damage - HashMap<LivingEntity, Double> targets = UtilEnt.getInRadius(data.Location, 10); for (LivingEntity cur : targets.keySet()) { if (cur.equals(data.Shooter)) + { continue; + } - Manager.GetDamage().NewDamageEvent(cur, data.Shooter, null, - DamageCause.CUSTOM, 12 * targets.get(cur) + 0.5, true, false, false, - data.Shooter.getName(), GetName()); + Manager.GetDamage().NewDamageEvent(cur, data.Shooter, null, DamageCause.CUSTOM, DAMAGE * targets.get(cur) + 0.5, true, false, false, data.Shooter.getName(), GetName()); } } @@ -201,42 +245,59 @@ public class PerkBatForm extends SmashPerk Player player = event.getPlayer(); if (Manager.isSpectator(player)) + { return; - - if (!isSuperActive(player)) + } + + if (!isUsingUltimate(player)) + { return; + } if (player.getGameMode() == GameMode.CREATIVE) + { return; - + } + event.setCancelled(true); player.setFlying(false); - //Disable Flight + // Disable Flight player.setAllowFlight(false); - //Velocity + // Velocity UtilAction.velocity(player, player.getLocation().getDirection(), 0.8, false, 0, 0.8, 1, true); - //Sound - player.getWorld().playSound(player.getLocation(), Sound.BAT_TAKEOFF, (float)(0.3 + player.getExp()), (float)(Math.random()/2+0.5)); + // Sound + player.getWorld().playSound(player.getLocation(), Sound.BAT_TAKEOFF, (float) (0.3 + player.getExp()), (float) (Math.random() / 2 + 0.5)); - //Set Recharge - Recharge.Instance.use(player, GetName() + " Flap", 40, false, false); + // Set Recharge + Recharge.Instance.use(player, GetName() + " Flap", FLAP_COOLDOWN, false, false); } - + @EventHandler public void flapRecharge(UpdateEvent event) { if (event.getType() != UpdateType.TICK) - return; - - for (Player player : ((SmashKit)Kit).getSuperActive()) { - if (Manager.isSpectator(player)) + return; + } + + for (UUID uuid : getLastUltimate().keySet()) + { + Player player = UtilPlayer.searchExact(uuid); + + if (player == null) + { continue; - - if (UtilEnt.isGrounded(player) || UtilBlock.solid(player.getLocation().getBlock().getRelative(BlockFace.DOWN))) + } + + if (Manager.isSpectator(player)) + { + continue; + } + + if (UtilEnt.isGrounded(player) || UtilBlock.solid(player.getLocation().getBlock().getRelative(BlockFace.DOWN))) { player.setAllowFlight(true); } @@ -246,13 +307,15 @@ public class PerkBatForm extends SmashPerk } } } - + @EventHandler - public void knockback(CustomDamageEvent event) + public void knockback(CustomDamageEvent event) { if (event.GetReason() == null || !event.GetReason().contains(GetName())) + { return; + } - event.AddKnockback(GetName(), 2); + event.AddKnockback(GetName(), KNOCKBACK_MAGNITUDE); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitherImage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/witherskeleton/PerkWitherImage.java similarity index 55% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitherImage.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/witherskeleton/PerkWitherImage.java index 28011f7ff..bdc668038 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitherImage.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/witherskeleton/PerkWitherImage.java @@ -1,18 +1,9 @@ -package nautilus.game.arcade.kit.perks; +package nautilus.game.arcade.game.games.smash.perks.witherskeleton; import java.util.HashMap; import java.util.Iterator; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.recharge.Recharge; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.game.games.smash.TeamSuperSmash; -import nautilus.game.arcade.kit.SmashPerk; +import java.util.Map; +import java.util.UUID; import org.bukkit.Location; import org.bukkit.Material; @@ -23,158 +14,218 @@ import org.bukkit.entity.Skeleton; import org.bukkit.entity.Skeleton.SkeletonType; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; -import org.bukkit.event.block.Action; import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.player.PlayerInteractEvent; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilItem; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.games.smash.perks.SmashPerk; + public class PerkWitherImage extends SmashPerk -{ - private HashMap<Player, Skeleton> _ownerToSkeleton = new HashMap<Player, Skeleton>(); - private HashMap<Skeleton, Player> _skeletonToOwner = new HashMap<Skeleton, Player>(); +{ + + private static final int COOLDOWN = 12000; + private static final int SWAP_COOLDOWN = 2000; + private static final int TARGET_RADIUS = 15; - public PerkWitherImage() + private Map<UUID, Skeleton> _skeletons = new HashMap<>(); + + public PerkWitherImage() { - super("Wither Image", new String[] - { - C.cYellow + "Right-Click" + C.cGray + " with Axe to " + C.cGreen + "Wither Image", - C.cYellow + "Double Right-Click" + C.cGray + " with Axe to " + C.cGreen + "Wither Swap" - }); + super("Wither Image", new String[] { C.cYellow + "Right-Click" + C.cGray + " with Axe to " + C.cGreen + "Wither Image", C.cYellow + "Double Right-Click" + C.cGray + " with Axe to " + C.cGreen + + "Wither Swap" }); } @EventHandler public void activate(PlayerInteractEvent event) { if (event.isCancelled()) + { return; + } - if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) + if (!UtilEvent.isAction(event, ActionType.R)) + { return; + } if (UtilBlock.usable(event.getClickedBlock())) + { return; - - if (event.getPlayer().getItemInHand() == null) - return; - - if (!event.getPlayer().getItemInHand().getType().toString().contains("_AXE")) - return; + } Player player = event.getPlayer(); - if (isSuperActive(player)) - return; - - if (!Kit.HasKit(player)) - return; - - if (!_ownerToSkeleton.containsKey(player)) + if (!UtilItem.isAxe(player.getItemInHand())) { - if (!Recharge.Instance.use(player, GetName(), 12000, true, true)) + return; + } + + if (!hasPerk(player)) + { + return; + } + + if (isSuperActive(player)) + { + return; + } + + if (!_skeletons.containsKey(player.getUniqueId())) + { + if (!Recharge.Instance.use(player, GetName(), COOLDOWN, true, true)) + { return; - - //Spawn + } + + // Spawn Manager.GetGame().CreatureAllowOverride = true; Skeleton skel = player.getWorld().spawn(player.getEyeLocation().add(player.getLocation().getDirection()), Skeleton.class); Manager.GetGame().CreatureAllowOverride = false; - + skel.setSkeletonType(SkeletonType.WITHER); - + skel.getEquipment().setItemInHand(player.getItemInHand()); skel.setMaxHealth(20); skel.setHealth(skel.getMaxHealth()); - if (Manager.GetGame().GetTeamList().size() > 1) - skel.setCustomName(Manager.GetColor(player) + player.getName()); - else - skel.setCustomName(C.cYellow + player.getName()); - - skel.setCustomNameVisible(true); + for (Player other : UtilPlayer.getNearby(skel.getLocation(), TARGET_RADIUS)) + { + if (player.equals(other) || UtilPlayer.isSpectator(other) || isTeamDamage(player, other)) + { + continue; + } - //skel.setLeashHolder(player); - - UtilAction.velocity(skel, player.getLocation().getDirection(), 1.6, false, 0, 0.2, 10, true); - - _ownerToSkeleton.put(player, skel); - _skeletonToOwner.put(skel, player); - - Recharge.Instance.use(player, "Wither Swap", 500, false, false); + skel.setTarget(other); + break; + } - //Sound + if (Manager.GetGame().GetTeamList().size() > 1) + { + skel.setCustomName(Manager.GetColor(player) + player.getName()); + } + else + { + skel.setCustomName(C.cYellow + player.getName()); + } + + skel.setCustomNameVisible(true); + + UtilAction.velocity(skel, player.getLocation().getDirection(), 1.6, false, 0, 0.2, 10, true); + + _skeletons.put(player.getUniqueId(), skel); + + Recharge.Instance.use(player, "Wither Swap", SWAP_COOLDOWN / 4, false, false); + + // Sound player.getWorld().playSound(player.getLocation(), Sound.WITHER_SPAWN, 1f, 1f); - - //Inform + + // Inform UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + ".")); } else { - if (!Recharge.Instance.use(player, "Wither Swap", 2000, true, false)) + if (!Recharge.Instance.use(player, "Wither Swap", SWAP_COOLDOWN, true, false)) + { return; - - Skeleton skel = _ownerToSkeleton.get(player); - + } + + Skeleton skel = _skeletons.get(player.getUniqueId()); + Location loc = skel.getLocation(); skel.teleport(player.getLocation()); player.teleport(loc); - - //Sound + + // Sound player.getWorld().playSound(player.getLocation(), Sound.WITHER_SPAWN, 1f, 2f); - - //Inform + + // Inform UtilPlayer.message(player, F.main("Game", "You used " + F.skill("Wither Swap") + ".")); } } - + @EventHandler public void entityTarget(EntityTargetEvent event) { - if (_skeletonToOwner.containsKey(event.getEntity())) + if (_skeletons.containsValue(event.getEntity())) { - if (Manager.GetGame() instanceof TeamSuperSmash && event.getTarget() instanceof Player) + if (event.getTarget() instanceof Player) { - TeamSuperSmash smash = (TeamSuperSmash) Manager.GetGame(); - Player targetPlayer = (Player) event.getTarget(); - - if(smash.GetTeam(_skeletonToOwner.get(event.getEntity())).equals(smash.GetTeam(targetPlayer))) + if (isTeamDamage((Player) event.getTarget(), getOwner((Skeleton) event.getEntity()))) { event.setCancelled(true); } } - if (_ownerToSkeleton.get(event.getTarget()).equals(event.getEntity())) + + if (event.getTarget() != null && _skeletons.get(event.getTarget().getUniqueId()).equals(event.getEntity())) { event.setCancelled(true); } } } - + @EventHandler public void damage(CustomDamageEvent event) { Player damagee = event.GetDamageePlayer(); - if (damagee == null) return; - - if (!_ownerToSkeleton.containsKey(damagee.getUniqueId())) + + if (damagee == null) + { return; - + } + + if (!_skeletons.containsKey(damagee.getUniqueId())) + { + return; + } + LivingEntity damager = event.GetDamagerEntity(false); - if (damager == null) return; - - if (_ownerToSkeleton.get(damagee.getUniqueId()).equals(damager)) + + if (damager == null) + { + return; + } + + if (_skeletons.get(damagee.getUniqueId()).equals(damager)) + { event.SetCancelled("Wither Image"); + } } - + @EventHandler(priority = EventPriority.HIGHEST) public void minionDamageTransfer(CustomDamageEvent event) { LivingEntity damager = event.GetDamagerEntity(true); - if (damager == null) return; - - if (!_ownerToSkeleton.containsValue(damager)) + + if (damager == null) return; - - for (Player player : _ownerToSkeleton.keySet()) + + if (!_skeletons.containsValue(damager)) { - if (_ownerToSkeleton.get(player).equals(damager)) + return; + } + + for (UUID uuid : _skeletons.keySet()) + { + Player player = UtilPlayer.searchExact(uuid); + + if (player == null) + { + return; + } + + if (_skeletons.get(uuid).equals(damager)) { event.SetDamager(player); event.setKnockbackOrigin(damager.getLocation()); @@ -182,45 +233,69 @@ public class PerkWitherImage extends SmashPerk } } } - + @EventHandler public void update(UpdateEvent event) { if (event.getType() != UpdateType.FAST) + { return; - - Iterator<Player> playerIterator = _ownerToSkeleton.keySet().iterator(); - + + } + Iterator<UUID> playerIterator = _skeletons.keySet().iterator(); + while (playerIterator.hasNext()) { - Player player = playerIterator.next(); - Skeleton skel = _ownerToSkeleton.get(player); - - if (!player.isValid() || !skel.isValid() || skel.getTicksLived() > 160) + UUID uuid = playerIterator.next(); + Player player = UtilPlayer.searchExact(uuid); + + if (player == null) { - //Effect - Manager.GetBlood().Effects(null, skel.getLocation().add(0, 0.5, 0), 12, 0.3, Sound.WITHER_HURT, 1f, 0.75f, Material.BONE, (byte)0, 40, false); - + playerIterator.remove(); + continue; + } + + Skeleton skel = _skeletons.get(uuid); + + if (!player.isValid() || !skel.isValid() || skel.getTicksLived() > 160 || UtilBlock.liquid(skel.getLocation().getBlock())) + { + // Effect + Manager.GetBlood().Effects(null, skel.getLocation().add(0, 0.5, 0), 12, 0.3, Sound.WITHER_HURT, 1f, 0.75f, Material.BONE, (byte) 0, 40, false); + playerIterator.remove(); skel.remove(); continue; } } } - + @EventHandler(priority = EventPriority.LOWEST) public void clean(PlayerDeathEvent event) { - Skeleton skel = _ownerToSkeleton.remove(event.getEntity()); - _skeletonToOwner.remove(skel); - + Skeleton skel = _skeletons.remove(event.getEntity().getUniqueId()); + if (skel != null) { - //Effect - Manager.GetBlood().Effects(null, skel.getLocation().add(0, 0.5, 0), 12, 0.3, Sound.WITHER_HURT, 1f, 0.75f, Material.BONE, (byte)0, 40, false); - + // Effect + Manager.GetBlood().Effects(null, skel.getLocation().add(0, 0.5, 0), 12, 0.3, Sound.WITHER_HURT, 1f, 0.75f, Material.BONE, (byte) 0, 40, false); + skel.remove(); } } - + + private Player getOwner(Skeleton skel) + { + for (UUID uuid : _skeletons.keySet()) + { + Skeleton other = _skeletons.get(uuid); + + if (other.equals(skel)) + { + return UtilPlayer.searchExact(uuid); + } + } + + return null; + } + } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitherSkull.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/witherskeleton/PerkWitherSkull.java similarity index 54% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitherSkull.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/witherskeleton/PerkWitherSkull.java index de3505cc3..8f6845044 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitherSkull.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/witherskeleton/PerkWitherSkull.java @@ -1,18 +1,19 @@ -package nautilus.game.arcade.kit.perks; +package nautilus.game.arcade.game.games.smash.perks.witherskeleton; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.Map; +import java.util.Set; +import java.util.UUID; import org.bukkit.Location; import org.bukkit.Sound; -import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.WitherSkull; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; -import org.bukkit.event.block.Action; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.player.PlayerInteractEvent; @@ -20,107 +21,136 @@ import org.bukkit.util.Vector; import mineplex.core.common.util.C; import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.kit.SmashPerk; +import nautilus.game.arcade.game.games.smash.perks.SmashPerk; public class PerkWitherSkull extends SmashPerk { - private HashMap<WitherSkull, Vector> _active = new HashMap<WitherSkull, Vector>(); - private HashSet<Player> _ignoreControl = new HashSet<Player>(); - - public PerkWitherSkull() + + private static final int COOLDOWN_NORMAL = 6000; + private static final int COOLDOWN_SMASH = 1000; + private static final int DAMAGE = 12; + private static final float KNOCKBACK_MAGNITUDE = 1.5F; + + private Map<WitherSkull, Vector> _active = new HashMap<>(); + private Set<UUID> _ignoreControl = new HashSet<>(); + + public PerkWitherSkull() { - super("Wither Skull", new String[] - { - C.cYellow + "Hold Block" + C.cGray + " to use " + C.cGreen + "Wither Skull" - }); + super("Wither Skull", new String[] { C.cYellow + "Hold Block" + C.cGray + " to use " + C.cGreen + "Wither Skull" }); } - - - @EventHandler(priority = EventPriority.LOW) // Happen BEFORE super is triggered + + @EventHandler(priority = EventPriority.LOW) // Happen BEFORE super is + // triggered public void activate(PlayerInteractEvent event) { if (event.isCancelled()) + { return; - - Player player = event.getPlayer(); - - if (!isSuperActive(player)) - if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) - return; - - if (UtilBlock.usable(event.getClickedBlock())) - return; - - if (!isSuperActive(player)) - if (!event.getPlayer().getItemInHand().getType().toString().contains("_SWORD")) - return; + } - if (!Kit.HasKit(player)) + if (UtilBlock.usable(event.getClickedBlock())) + { return; - - if (!Recharge.Instance.use(player, GetName(), isSuperActive(player) ? 1000 : 6000, !isSuperActive(player), !isSuperActive(player))) + } + + Player player = event.getPlayer(); + boolean smash = isSuperActive(player); + + if (!smash) + { + if (!UtilItem.isSword(player.getItemInHand())) + { + return; + } + + if (!UtilEvent.isAction(event, ActionType.R)) + { + return; + } + } + + if (!hasPerk(player)) + { return; - - //Fire + } + + if (!Recharge.Instance.use(player, GetName(), smash ? COOLDOWN_SMASH : COOLDOWN_NORMAL, !smash, !smash)) + { + return; + } + + // Fire WitherSkull skull = player.launchProjectile(WitherSkull.class); - - if (!isSuperActive(player)) + + if (!smash) + { skull.setDirection(player.getLocation().getDirection()); - + } + _active.put(skull, player.getLocation().getDirection().multiply(0.6)); - - //Sound + + // Sound player.getWorld().playSound(player.getLocation(), Sound.WITHER_SHOOT, 1f, 1f); - //Inform - if (!isSuperActive(player)) + // Inform + if (!smash) + { UtilPlayer.message(player, F.main("Skill", "You launched " + F.skill(GetName()) + ".")); - - //Control - if (!isSuperActive(player)) - _ignoreControl.remove(player); + } + + // Control + if (!smash) + { + _ignoreControl.remove(player.getUniqueId()); + } else - _ignoreControl.add(player); + { + _ignoreControl.add(player.getUniqueId()); + } } - + @EventHandler - public void cleanAndControl(UpdateEvent event) + public void cleanAndControl(UpdateEvent event) { if (event.getType() != UpdateType.TICK) + { return; - - Iterator<WitherSkull> skullIterator = _active.keySet().iterator(); + } + Iterator<WitherSkull> skullIterator = _active.keySet().iterator(); + while (skullIterator.hasNext()) { WitherSkull skull = skullIterator.next(); - Player player = (Player)skull.getShooter(); - + Player player = (Player) skull.getShooter(); + if (!skull.isValid()) { skullIterator.remove(); skull.remove(); continue; } - - if (_ignoreControl.contains(player)) + + if (_ignoreControl.contains(player.getUniqueId())) + { continue; - - if (player.isBlocking() && !_ignoreControl.contains(player)) + } + + if (player.isBlocking() && !_ignoreControl.contains(player.getUniqueId())) { skull.setDirection(player.getLocation().getDirection()); skull.setVelocity(player.getLocation().getDirection().multiply(0.6)); @@ -128,88 +158,72 @@ public class PerkWitherSkull extends SmashPerk } else { - _ignoreControl.add(player); + _ignoreControl.add(player.getUniqueId()); skull.setDirection(_active.get(skull)); skull.setVelocity(_active.get(skull)); } } } - + @EventHandler public void explode(EntityExplodeEvent event) { if (!_active.containsKey(event.getEntity())) + { return; - + } + event.setCancelled(true); - - WitherSkull skull = (WitherSkull)event.getEntity(); - - UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, skull.getLocation(), 0, 0, 0, 0, 1, - ViewDist.MAX, UtilServer.getPlayers()); - - explode(skull, event.getLocation(), (LivingEntity)skull.getShooter()); + + WitherSkull skull = (WitherSkull) event.getEntity(); + + UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, skull.getLocation(), 0, 0, 0, 0, 1, ViewDist.MAX, UtilServer.getPlayers()); + + explode(skull, event.getLocation(), (LivingEntity) skull.getShooter()); } - + @EventHandler(priority = EventPriority.LOWEST) public void explodeDamage(CustomDamageEvent event) { if (event.IsCancelled()) + { return; + } if (event.GetProjectile() != null && event.GetProjectile() instanceof WitherSkull) - event.SetCancelled("Wither Skull Cancel"); - } - - //Sometimes wither skulls do entity attack damage (non-explosion)... cancel it! - @EventHandler(priority = EventPriority.LOWEST) - public void directHitDamageCancel(CustomDamageEvent event) - { - if (event.IsCancelled()) - return; - - if (event.GetCause() != DamageCause.ENTITY_ATTACK) - return; - - if (event.GetDamageInitial() != 7) - return; - - Player damager = event.GetDamagerPlayer(false); - if (damager == null) return; - - if (!Kit.HasKit(damager)) - return; - - if (!Manager.IsAlive(damager)) - return; - - event.SetCancelled("Wither Skull Direct Hit"); - } - - private void explode(WitherSkull skull, Location loc, LivingEntity shooter) - { - double scale = 0.4 + 0.6 * Math.min(1, skull.getTicksLived()/20d); - - //Players - HashMap<Player, Double> players = UtilPlayer.getInRadius(skull.getLocation(), 6); - for (Player player : players.keySet()) { - if (!Manager.GetGame().IsAlive(player)) - continue; - - //Damage Event - Manager.GetDamage().NewDamageEvent(player, (LivingEntity)skull.getShooter(), null, - DamageCause.CUSTOM, 12 * players.get(player) * scale, true, true, false, - UtilEnt.getName((LivingEntity)skull.getShooter()), GetName()); + event.SetCancelled("Wither Skull Cancel"); } } - + + private void explode(WitherSkull skull, Location loc, LivingEntity shooter) + { + double scale = 0.4 + 0.6 * Math.min(1, skull.getTicksLived() / 20d); + + // Players + Map<Player, Double> players = UtilPlayer.getInRadius(skull.getLocation(), 6); + + for (Player player : players.keySet()) + { + if (Manager.isSpectator(player)) + { + continue; + } + + // Damage Event + Manager.GetDamage().NewDamageEvent(player, (LivingEntity) skull.getShooter(), null, DamageCause.CUSTOM, DAMAGE * players.get(player) * scale, true, true, false, UtilEnt.getName( + (LivingEntity) skull.getShooter()), GetName()); + } + } + @EventHandler public void knockback(CustomDamageEvent event) { if (event.GetReason() == null || !event.GetReason().contains(GetName())) + { return; + } - event.AddKnockback(GetName(), 1.5); + event.AddKnockback(GetName(), KNOCKBACK_MAGNITUDE); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitherForm.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/witherskeleton/SmashWitherSkeleton.java similarity index 54% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitherForm.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/witherskeleton/SmashWitherSkeleton.java index fee83f056..717328a64 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitherForm.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/witherskeleton/SmashWitherSkeleton.java @@ -1,11 +1,13 @@ -package nautilus.game.arcade.kit.perks; +package nautilus.game.arcade.game.games.smash.perks.witherskeleton; import java.util.ArrayList; +import java.util.List; +import java.util.UUID; import org.bukkit.Location; +import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.entity.Player; -import org.bukkit.entity.Skeleton.SkeletonType; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; @@ -14,58 +16,46 @@ import org.bukkit.util.Vector; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; -import mineplex.core.disguise.disguises.DisguiseSkeleton; +import mineplex.core.common.util.UtilPlayer; import mineplex.core.disguise.disguises.DisguiseWither; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.kit.SmashKit; -import nautilus.game.arcade.kit.SmashPerk; +import nautilus.game.arcade.game.games.smash.kits.KitWitherSkeleton; +import nautilus.game.arcade.game.games.smash.perks.SmashKit; +import nautilus.game.arcade.game.games.smash.perks.SmashUltimate; -public class PerkWitherForm extends SmashPerk +public class SmashWitherSkeleton extends SmashUltimate { - public PerkWitherForm() + + private static final int DURAITON = 18000; + + public SmashWitherSkeleton() { - super("Wither Form", new String[] - { - }, false); + super("Wither Form", new String[] {}, Sound.WITHER_SPAWN, DURAITON); } @Override - public void addSuperCustom(Player player) + public void activate(Player player) { - Manager.GetDisguise().undisguise(player); + super.activate(player); - //Disguise - DisguiseWither disguise = new DisguiseWither(player); - - if (Manager.GetGame().GetTeam(player) != null) - disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); - else - disguise.setName(player.getName()); - - disguise.setCustomNameVisible(true); - Manager.GetDisguise().disguise(disguise); + if (Kit instanceof KitWitherSkeleton) + { + KitWitherSkeleton kit = (KitWitherSkeleton) Kit; + kit.disguise(player, DisguiseWither.class); + kit.giveSmashItems(player); + } } @Override - public void removeSuperCustom(Player player) + public void cancel(Player player) { - Manager.GetDisguise().undisguise(player); - - //Disguise - DisguiseSkeleton disguise = new DisguiseSkeleton(player); + super.cancel(player); - if (Manager.GetGame().GetTeam(player) != null) - disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); - else - disguise.setName(player.getName()); + SmashKit kit = (SmashKit) Kit; + kit.disguise(player); - disguise.setCustomNameVisible(true); - disguise.SetSkeletonType(SkeletonType.WITHER); - disguise.hideArmor(); - Manager.GetDisguise().disguise(disguise); - player.setFlying(false); } @@ -73,13 +63,22 @@ public class PerkWitherForm extends SmashPerk public void witherBump(UpdateEvent event) { if (event.getType() != UpdateType.FASTER) - return; - - for (Player player : ((SmashKit)Kit).getSuperActive()) { - ArrayList<Location> collisions = new ArrayList<Location>(); + return; + } - //Bump + for (UUID uuid : getLastUltimate().keySet()) + { + Player player = UtilPlayer.searchExact(uuid); + + if (player == null) + { + continue; + } + + List<Location> collisions = new ArrayList<>(); + + // Bump for (Block block : UtilBlock.getInRadius(player.getLocation().add(0, 0.5, 0), 1.5d).keySet()) { if (!UtilBlock.airFoliage(block)) @@ -91,8 +90,10 @@ public class PerkWitherForm extends SmashPerk Vector vec = UtilAlg.getAverageBump(player.getLocation(), collisions); if (vec == null) + { continue; - + } + UtilAction.velocity(player, vec, 0.6, false, 0, 0.4, 10, true); } } @@ -101,17 +102,26 @@ public class PerkWitherForm extends SmashPerk public void witherMeleeCancel(CustomDamageEvent event) { if (event.IsCancelled()) + { return; + } Player player = event.GetDamagerPlayer(true); - if (player == null) - return; - if (!isSuperActive(player)) + if (player == null) + { return; + } + + if (!isUsingUltimate(player)) + { + return; + } if (event.GetCause() != DamageCause.ENTITY_ATTACK) + { return; + } event.SetCancelled("Wither Form Melee Cancel"); } @@ -120,12 +130,23 @@ public class PerkWitherForm extends SmashPerk public void witherFlight(UpdateEvent event) { if (event.getType() != UpdateType.TICK) - return; - - for (Player player : ((SmashKit)Kit).getSuperActive()) { - if (player.isFlying()) + return; + } + + for (UUID uuid : getLastUltimate().keySet()) + { + Player player = UtilPlayer.searchExact(uuid); + + if (player == null) + { continue; + } + + if (player.isFlying()) + { + continue; + } player.setAllowFlight(true); player.setFlying(true); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/wolf/PerkWolf.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/wolf/PerkWolf.java new file mode 100644 index 000000000..74501dd68 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/wolf/PerkWolf.java @@ -0,0 +1,528 @@ +package nautilus.game.arcade.game.games.smash.perks.wolf; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.UUID; + +import org.bukkit.Effect; +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Wolf; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityTargetEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilItem; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import nautilus.game.arcade.game.games.smash.perks.SmashPerk; + +public class PerkWolf extends SmashPerk +{ + + private static final int TACKLE_COOLDOWN_NORMAL = 8000; + private static final int TACKLE_COOLDOWN_SMASH = 1600; + private static final int WOLF_HEALTH = 30; + private static final float WOLF_HIT_BOX = 2.5F; + private static final int WOLF_MAX_TICKS = 70; + private static final int TACKLE_DAMAGE = 5; + private static final int STRIKE_DAMAGE = 7; + + private static final String CUB_TACKLE = "Cub Tackle"; + private static final String WOLF_STRIKE = "Wolf Strike"; + + private Map<Wolf, UUID> _owner = new HashMap<>(); + private Map<Wolf, LivingEntity> _tackle = new HashMap<>(); + + private Map<UUID, Long> _strike = new HashMap<>(); + + private Map<UUID, ArrayList<Long>> _repeat = new HashMap<>(); + + private Map<LivingEntity, Long> _tacklestrike = new HashMap<>(); + + public PerkWolf() + { + super("Wolf", new String[] { C.cGray + "Attacks give +1 Damage for 3 seconds. Stacks.", C.cYellow + "Right-Click" + C.cGray + " with Axe to use " + C.cGreen + CUB_TACKLE, C.cYellow + + "Right-Click" + C.cGray + " with Spade to use " + C.cGreen + WOLF_STRIKE, C.cGray + "Wolf Strike deals 300% Knockback to tackled opponents.", }); + } + + @EventHandler + public void tackleTrigger(PlayerInteractEvent event) + { + if (event.isCancelled()) + { + return; + } + + if (!UtilEvent.isAction(event, ActionType.R)) + { + return; + } + + if (UtilBlock.usable(event.getClickedBlock())) + { + return; + } + + Player player = event.getPlayer(); + + if (!UtilItem.isAxe(player.getItemInHand())) + { + return; + } + + if (!hasPerk(player)) + { + return; + } + + boolean smash = isSuperActive(player); + + if (!Recharge.Instance.use(player, CUB_TACKLE, smash ? TACKLE_COOLDOWN_SMASH : TACKLE_COOLDOWN_NORMAL, !smash, !smash)) + { + return; + } + + // Get Nearest Wolf + Manager.GetGame().CreatureAllowOverride = true; + Wolf wolf = player.getWorld().spawn(player.getEyeLocation().add(player.getLocation().getDirection()), Wolf.class); + Manager.GetGame().CreatureAllowOverride = false; + + wolf.setBaby(); + + wolf.setAngry(true); + + UtilEnt.Vegetate(wolf); + + wolf.setMaxHealth(WOLF_HEALTH); + wolf.setHealth(wolf.getMaxHealth()); + + UtilAction.velocity(wolf, player.getLocation().getDirection(), 1.8, false, 0, 0.2, 1.2, true); + + player.getWorld().playSound(wolf.getLocation(), Sound.WOLF_BARK, 1f, 1.8f); + + // Record + _owner.put(wolf, player.getUniqueId()); + + // Inform + UtilPlayer.message(player, F.main("Game", "You used " + F.skill(CUB_TACKLE) + ".")); + } + + @EventHandler + public void tackleCollide(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + // Collide + Iterator<Wolf> wolfIterator = _owner.keySet().iterator(); + + while (wolfIterator.hasNext()) + { + Wolf wolf = wolfIterator.next(); + + // Hit Player + for (Player other : Manager.GetGame().GetPlayers(true)) + { + if (Manager.isSpectator(other)) + { + continue; + } + + if (UtilEnt.hitBox(wolf.getLocation(), other, WOLF_HIT_BOX, null)) + { + if (other.equals(tackleGetOwner(wolf))) + { + continue; + + } + + tackleCollideAction(tackleGetOwner(wolf), other, wolf); + wolfIterator.remove(); + return; + } + } + + if (!wolf.isValid() || (UtilEnt.isGrounded(wolf) && wolf.getTicksLived() > WOLF_MAX_TICKS)) + { + wolf.remove(); + wolfIterator.remove(); + } + } + } + + public void tackleCollideAction(Player damager, LivingEntity damagee, Wolf wolf) + { + if (damager == null) + { + return; + } + + if (damagee instanceof Player) + { + if (isTeamDamage(damager, (Player) damagee)) + { + return; + } + } + + _tackle.put(wolf, damagee); + + wolf.setVelocity(new Vector(0, -0.6, 0)); + UtilAction.zeroVelocity(damagee); + + // Damage + Manager.GetDamage().NewDamageEvent(damagee, damager, null, DamageCause.CUSTOM, TACKLE_DAMAGE, false, true, false, damager.getName(), CUB_TACKLE); + + // Sound + damagee.getWorld().playSound(damagee.getLocation(), Sound.WOLF_GROWL, 1.5f, 1.5f); + + // Inform + UtilPlayer.message(damager, F.main("Game", "You hit " + F.name(UtilEnt.getName(damagee)) + " with " + F.skill(CUB_TACKLE) + ".")); + UtilPlayer.message(damagee, F.main("Game", F.name(damager.getName()) + " hit you with " + F.skill(CUB_TACKLE) + ".")); + } + + @EventHandler + public void tackleUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + Iterator<Wolf> wolfIterator = _tackle.keySet().iterator(); + + while (wolfIterator.hasNext()) + { + Wolf wolf = wolfIterator.next(); + LivingEntity ent = _tackle.get(wolf); + + if (!wolf.isValid() || !ent.isValid() || wolf.getTicksLived() > WOLF_MAX_TICKS) + { + wolf.remove(); + wolfIterator.remove(); + continue; + } + + if (UtilMath.offset(wolf, ent) < WOLF_HIT_BOX) + { + Manager.GetCondition().Factory().Slow(CUB_TACKLE, ent, wolf, 0.9, 1, false, false, false, false); + UtilAction.velocity(ent, new Vector(0, -0.3, 0)); + } + + // Move + Location loc = ent.getLocation(); + loc.add(UtilAlg.getTrajectory2d(ent, wolf).multiply(1)); + + UtilEnt.CreatureMove(wolf, loc, 1); + } + } + + public Player tackleGetOwner(Wolf wolf) + { + if (_owner.containsKey(wolf)) + { + return UtilPlayer.searchExact(_owner.get(wolf)); + } + + return null; + } + + @EventHandler + public void tackleTargetCancel(EntityTargetEvent event) + { + if (_owner.containsKey(event.getEntity())) + { + if (_owner.get(event.getEntity()).equals(event.getTarget())) + { + event.setCancelled(true); + } + } + } + + @EventHandler + public void tackleDamage(CustomDamageEvent event) + { + if (event.GetCause() != DamageCause.ENTITY_ATTACK) + { + return; + } + + LivingEntity damager = event.GetDamagerEntity(false); + + if (damager == null) + { + return; + } + + if (damager instanceof Wolf) + { + event.SetCancelled("Wolf Cub"); + } + } + + @EventHandler + public void strikeTrigger(PlayerInteractEvent event) + { + if (event.isCancelled()) + { + return; + } + + if (!UtilEvent.isAction(event, ActionType.R)) + { + return; + } + + if (UtilBlock.usable(event.getClickedBlock())) + { + return; + } + + Player player = event.getPlayer(); + + if (!UtilItem.isSpade(player.getItemInHand())) + { + return; + } + + if (!hasPerk(player)) + { + return; + } + + boolean smash = isSuperActive(player); + + if (!Recharge.Instance.use(player, WOLF_STRIKE, smash ? 1600 : 8000, !smash, !smash)) + { + return; + } + + // Velocity + UtilAction.velocity(player, player.getLocation().getDirection(), 1.6, false, 1, 0.2, 1.2, true); + + // Record + _strike.put(player.getUniqueId(), System.currentTimeMillis()); + + player.getWorld().playSound(player.getLocation(), Sound.WOLF_BARK, 1f, 1.2f); + + // Inform + UtilPlayer.message(player, F.main("Game", "You used " + F.skill(WOLF_STRIKE) + ".")); + } + + @EventHandler + public void strikeEnd(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + // Collide + Iterator<UUID> playerIterator = _strike.keySet().iterator(); + + while (playerIterator.hasNext()) + { + UUID uuid = playerIterator.next(); + Player player = UtilPlayer.searchExact(uuid); + + if (player == null) + { + playerIterator.remove(); + continue; + } + + for (Player other : Manager.GetGame().GetPlayers(true)) + { + if (player.equals(other) || UtilPlayer.isSpectator(other) || isTeamDamage(player, other)) + { + continue; + } + + if (UtilEnt.hitBox(player.getLocation().add(0, 1, 0), other, WOLF_HIT_BOX, null)) + { + strikeHit(player, other); + playerIterator.remove(); + return; + } + } + + if (!UtilEnt.isGrounded(player)) + { + continue; + } + + if (!UtilTime.elapsed(_strike.get(uuid), 1500)) + { + continue; + } + + playerIterator.remove(); + } + } + + public void strikeHit(Player damager, LivingEntity damagee) + { + UtilAction.zeroVelocity(damager); + + // Remove tackle + Iterator<Wolf> wolfIterator = _tackle.keySet().iterator(); + + while (wolfIterator.hasNext()) + { + Wolf wolf = wolfIterator.next(); + + if (_tackle.get(wolf).equals(damagee)) + { + wolf.remove(); + wolfIterator.remove(); + + _tacklestrike.put(damagee, System.currentTimeMillis()); + } + } + + Manager.GetDamage().NewDamageEvent(damagee, damager, null, DamageCause.CUSTOM, STRIKE_DAMAGE, true, true, false, damager.getName(), WOLF_STRIKE); + + // Sound + damagee.getWorld().playSound(damagee.getLocation(), Sound.WOLF_BARK, 1.5f, 1f); + + // Inform + UtilPlayer.message(damager, F.main("Game", "You hit " + F.name(UtilEnt.getName(damagee)) + " with " + F.skill(WOLF_STRIKE) + ".")); + UtilPlayer.message(damagee, F.main("Game", F.name(damager.getName()) + " hit you with " + F.skill(WOLF_STRIKE) + ".")); + } + + @EventHandler + public void strikeKnockback(CustomDamageEvent event) + { + if (event.GetReason() != null && event.GetReason().contains(WOLF_STRIKE)) + { + if (_tacklestrike.containsKey(event.GetDamageeEntity()) && !UtilTime.elapsed(_tacklestrike.get(event.GetDamageeEntity()), 100)) + { + event.AddKnockback(GetName(), 3.0); + + // Blood + event.GetDamageeEntity().getWorld().playEffect(event.GetDamageeEntity().getLocation(), Effect.STEP_SOUND, 55); + + // Double Sound + event.GetDamageeEntity().getWorld().playSound(event.GetDamageeEntity().getLocation(), Sound.WOLF_BARK, 2f, 1.5f); + } + else + { + event.AddKnockback(GetName(), 1.5); + } + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void RepeatDamage(CustomDamageEvent event) + { + if (event.IsCancelled()) + { + return; + } + + if (event.GetCause() != DamageCause.ENTITY_ATTACK) + { + return; + } + + Player damager = event.GetDamagerPlayer(false); + + if (damager == null) + { + return; + } + + if (!hasPerk(damager)) + { + return; + } + + if (!_repeat.containsKey(damager.getUniqueId())) + { + _repeat.put(damager.getUniqueId(), new ArrayList<Long>()); + _repeat.get(damager.getUniqueId()).add(System.currentTimeMillis()); + + // Exp + damager.setExp(Math.min(0.99F, _repeat.get(damager.getUniqueId()).size() / 9f)); + + return; + } + + int count = _repeat.get(damager.getUniqueId()).size(); + + if (count > 0) + { + event.AddMod(damager.getName(), "Ravage", Math.min(2, count), false); + + // Sound + damager.getWorld().playSound(damager.getLocation(), Sound.WOLF_BARK, (float) (0.5 + count * 0.25), (float) (1 + count * 0.25)); + } + + _repeat.get(damager.getUniqueId()).add(System.currentTimeMillis()); + + // Exp + damager.setExp(Math.min(0.999f, _repeat.get(damager.getUniqueId()).size() / 9f)); + } + + @EventHandler + public void RepeatExpire(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + Iterator<UUID> playerIterator = _repeat.keySet().iterator(); + + while (playerIterator.hasNext()) + { + UUID uuid = playerIterator.next(); + Player player = UtilPlayer.searchExact(uuid); + + Iterator<Long> timeIterator = _repeat.get(uuid).iterator(); + + while (timeIterator.hasNext()) + { + long time = timeIterator.next(); + + if (UtilTime.elapsed(time, 3000)) + { + timeIterator.remove(); + } + } + + // Exp + player.setExp(Math.min(0.999f, _repeat.get(uuid).size() / 9f)); + + if(_repeat.get(uuid).isEmpty()) + { + playerIterator.remove(); + continue; + } + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/wolf/SmashWolf.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/wolf/SmashWolf.java new file mode 100644 index 000000000..eee6b9ca7 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/wolf/SmashWolf.java @@ -0,0 +1,59 @@ +package nautilus.game.arcade.game.games.smash.perks.wolf; + +import org.bukkit.Sound; +import org.bukkit.entity.Player; + +import mineplex.core.disguise.disguises.DisguiseBase; +import mineplex.core.disguise.disguises.DisguiseWolf; +import mineplex.core.recharge.Recharge; +import mineplex.minecraft.game.core.condition.ConditionFactory; + +import nautilus.game.arcade.game.games.smash.perks.SmashUltimate; + +public class SmashWolf extends SmashUltimate +{ + + private static final int DURATION = 30000; + + public SmashWolf() + { + super("Frenzy", new String[] {}, Sound.WOLF_HOWL, DURATION); + } + + @Override + public void activate(Player player) + { + super.activate(player); + + ConditionFactory factory = Manager.GetCondition().Factory(); + + factory.Strength(GetName(), player, player, 30, 1, false, false, false); + factory.Speed(GetName(), player, player, 30, 2, false, false, false); + factory.Regen(GetName(), player, player, 30, 2, false, false, false); + + DisguiseBase disguise = Manager.GetDisguise().getActiveDisguise(player); + + if (disguise instanceof DisguiseWolf) + { + ((DisguiseWolf) disguise).setAngry(true); + Manager.GetDisguise().updateDisguise(disguise); + } + + Recharge.Instance.recharge(player, "Wolf Strike"); + Recharge.Instance.recharge(player, "Cub Tackle"); + } + + @Override + public void cancel(Player player) + { + super.cancel(player); + + DisguiseBase disguise = Manager.GetDisguise().getActiveDisguise(player); + + if (disguise instanceof DisguiseWolf) + { + ((DisguiseWolf) disguise).setAngry(false); + Manager.GetDisguise().updateDisguise(disguise); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/zombie/PerkDeathsGrasp.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/zombie/PerkDeathsGrasp.java new file mode 100644 index 000000000..c31472a2f --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/zombie/PerkDeathsGrasp.java @@ -0,0 +1,242 @@ +package nautilus.game.arcade.game.games.smash.perks.zombie; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.player.PlayerInteractEvent; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.kit.Perk; + +public class PerkDeathsGrasp extends Perk +{ + + private static final int COOLDOWN = 12000; + + private Map<LivingEntity, Long> _live = new HashMap<>(); + private Map<LivingEntity, Long> _weakness = new HashMap<>(); + + public PerkDeathsGrasp() + { + super("Deaths Grasp", new String[] { C.cYellow + "Left-Click" + C.cGray + " with Bow to use " + C.cGreen + "Deaths Grasp", C.cGray + "+100% Arrow Damage to enemies thrown by Deaths Grasp" }); + } + + @EventHandler + public void leap(PlayerInteractEvent event) + { + if (event.isCancelled()) + { + return; + } + + if (!UtilEvent.isAction(event, ActionType.L)) + { + return; + } + + if (UtilBlock.usable(event.getClickedBlock())) + { + return; + } + + Player player = event.getPlayer(); + + if (player.getItemInHand() == null || player.getItemInHand().getType() != Material.BOW) + { + return; + } + + if (!hasPerk(player)) + { + return; + } + + if (!Recharge.Instance.use(player, GetName(), COOLDOWN, true, true)) + { + return; + } + + UtilAction.velocity(player, player.getLocation().getDirection(), 1.4, false, 0, 0.2, 1.2, true); + + // Record + _live.put(player, System.currentTimeMillis()); + + // Inform + UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + ".")); + + // Effect + player.getWorld().playSound(player.getLocation(), Sound.ZOMBIE_HURT, 1f, 1.4f); + } + + @EventHandler + public void end(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + List<Player> alivePlayers = Manager.GetGame().GetPlayers(true); + + // Collide + for (Player player : alivePlayers) + { + if (!_live.containsKey(player)) + { + continue; + } + + for (Player other : alivePlayers) + { + if (Manager.isSpectator(other)) + { + continue; + } + + if (other.equals(player)) + { + continue; + } + + if (UtilMath.offset(player, other) < 2) + { + collide(player, other); + _live.remove(player); + return; + } + } + } + + // Leap End + Iterator<LivingEntity> leapIter = _live.keySet().iterator(); + + while (leapIter.hasNext()) + { + LivingEntity ent = leapIter.next(); + + if (!UtilEnt.isGrounded(ent)) + { + continue; + } + + if (!UtilTime.elapsed(_live.get(ent), 1000)) + { + continue; + } + + leapIter.remove(); + } + + // Weakness End + Iterator<LivingEntity> weaknessIter = _weakness.keySet().iterator(); + + while (weaknessIter.hasNext()) + { + LivingEntity ent = weaknessIter.next(); + + if (!UtilEnt.isGrounded(ent)) + { + continue; + } + + if (!UtilTime.elapsed(_weakness.get(ent), 1000)) + { + continue; + } + + weaknessIter.remove(); + } + } + + public void collide(Player damager, LivingEntity damagee) + { + // Damage Event + Manager.GetDamage().NewDamageEvent(damagee, damager, null, DamageCause.CUSTOM, 6, false, true, false, damager.getName(), GetName()); + + UtilAction.velocity(damagee, UtilAlg.getTrajectory2d(damagee, damager), 1.6, false, 0, 1.2, 1.8, true); + + UtilAction.zeroVelocity(damager); + + damager.getWorld().playSound(damager.getLocation(), Sound.ZOMBIE_HURT, 1f, 0.7f); + + _weakness.put(damagee, System.currentTimeMillis()); + + // Inform + UtilPlayer.message(damager, F.main("Game", "You hit " + F.name(UtilEnt.getName(damagee)) + " with " + F.skill(GetName()) + ".")); + UtilPlayer.message(damagee, F.main("Game", F.name(damager.getName()) + " hit you with " + F.skill(GetName()) + ".")); + + Recharge.Instance.recharge(damager, GetName()); + Recharge.Instance.use(damager, GetName(), 2000, true, true); + } + + @EventHandler(priority = EventPriority.HIGH) + public void arrowDamage(CustomDamageEvent event) + { + if (event.GetProjectile() == null) + { + return; + } + + if (!(event.GetProjectile() instanceof Arrow)) + { + return; + } + + if (!_weakness.containsKey(event.GetDamageeEntity())) + { + return; + } + + Player damager = event.GetDamagerPlayer(true); + + if (damager == null) + { + return; + } + + if (!hasPerk(damager)) + { + return; + } + + if (Manager.isSpectator(damager)) + { + return; + } + + event.AddMult(GetName(), GetName() + " Combo", 2, true); + + UtilParticle.PlayParticle(ParticleType.RED_DUST, event.GetDamageeEntity().getLocation(), 0.5f, 0.5f, 0.5f, 0, 20, ViewDist.MAX, UtilServer.getPlayers()); + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, event.GetDamageeEntity().getLocation(), 0, 0, 0, 0, 1, ViewDist.MAX, UtilServer.getPlayers()); + + damager.getWorld().playSound(damager.getLocation(), Sound.ZOMBIE_HURT, 1f, 2f); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/zombie/PerkOvercharge.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/zombie/PerkOvercharge.java new file mode 100644 index 000000000..92edcd250 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/zombie/PerkOvercharge.java @@ -0,0 +1,252 @@ +package nautilus.game.arcade.game.games.smash.perks.zombie; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.UUID; + +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerQuitEvent; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.games.smash.perks.SmashPerk; + +public class PerkOvercharge extends SmashPerk +{ + private Map<UUID, Integer> _charge = new HashMap<>(); + private Map<UUID, Long> _chargeLast = new HashMap<>(); + + private Map<Arrow, Integer> _arrows = new HashMap<>(); + + private int _max; + private int _tick; + private boolean _useExp; + + public PerkOvercharge(int max, int tick, boolean useExpBar) + { + super("Corrupted Arrow", new String[] { C.cYellow + "Charge" + C.cGray + " your Bow to use " + C.cGreen + "Corrupted Arrow" }); + + _useExp = useExpBar; + _max = max; + _tick = tick; + } + + @EventHandler + public void drawBow(PlayerInteractEvent event) + { + if (event.isCancelled()) + { + return; + } + + if (!UtilEvent.isAction(event, ActionType.R)) + { + return; + } + + if (UtilBlock.usable(event.getClickedBlock())) + { + return; + } + + Player player = event.getPlayer(); + + if (player.getItemInHand() == null || player.getItemInHand().getType() != Material.BOW) + { + return; + } + + if (!player.getInventory().contains(Material.ARROW)) + { + return; + } + + if (!hasPerk(player)) + { + return; + } + + // Start Charge + _charge.put(player.getUniqueId(), 0); + _chargeLast.put(player.getUniqueId(), System.currentTimeMillis()); + } + + @EventHandler + public void charge(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + for (Player cur : UtilServer.getPlayers()) + { + UUID uuid = cur.getUniqueId(); + + // Not Charging + if (!_charge.containsKey(uuid)) + { + continue; + } + + // Max Charge + if (_charge.get(uuid) >= _max) + { + continue; + } + + // Charge Interval + if (_charge.get(uuid) == 0) + { + if (!UtilTime.elapsed(_chargeLast.get(uuid), 1000)) + { + continue; + } + } + else + { + if (!UtilTime.elapsed(_chargeLast.get(uuid), _tick)) + { + continue; + } + } + + // No Longer Holding Bow + if (cur.getItemInHand() == null || cur.getItemInHand().getType() != Material.BOW) + { + if (_useExp) + { + cur.setExp(0f); + } + + _charge.remove(uuid); + _chargeLast.remove(uuid); + continue; + } + + // Increase Charge + _charge.put(uuid, _charge.get(uuid) + 1); + + if (_useExp) + { + cur.setExp(Math.min(0.99f, _charge.get(uuid) / _max)); + } + + _chargeLast.put(uuid, System.currentTimeMillis()); + + // Effect + cur.playSound(cur.getLocation(), Sound.CLICK, 1f, 1f + (0.1f * _charge.get(uuid))); + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void fireBow(EntityShootBowEvent event) + { + if (event.isCancelled()) + { + return; + } + + if (!Manager.GetGame().IsLive()) + { + return; + } + + if (!(event.getEntity() instanceof Player)) + { + return; + } + + if (!(event.getProjectile() instanceof Arrow)) + { + return; + } + + Player player = (Player) event.getEntity(); + + if (!_charge.containsKey(player.getUniqueId())) + { + return; + } + + int charge = _charge.remove(player.getUniqueId()); + + if (charge <= 0) + { + return; + } + + // Start Barrage + _arrows.put((Arrow) event.getProjectile(), charge); + + player.setExp(0f); + } + + @EventHandler(priority = EventPriority.HIGH) + public void damageBonus(CustomDamageEvent event) + { + if (event.GetProjectile() == null) + { + return; + } + + if (!_arrows.containsKey(event.GetProjectile())) + { + return; + } + + int charge = _arrows.remove(event.GetProjectile()); + + event.AddMod(GetName(), GetName(), charge * 0.9, true); + } + + @EventHandler + public void clean(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + for (Iterator<Arrow> arrowIterator = _arrows.keySet().iterator(); arrowIterator.hasNext();) + { + Arrow arrow = arrowIterator.next(); + + if (arrow.isDead() || !arrow.isValid() || arrow.isOnGround() || arrow.getTicksLived() > 120) + { + arrowIterator.remove(); + } + else + { + UtilParticle.PlayParticle(ParticleType.RED_DUST, arrow.getLocation(), 0, 0, 0, 0, 1, ViewDist.MAX, UtilServer.getPlayers()); + } + } + } + + @EventHandler + public void quit(PlayerQuitEvent event) + { + Player player = event.getPlayer(); + + _charge.remove(player.getUniqueId()); + _chargeLast.remove(player.getUniqueId()); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkZombieBile.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/zombie/PerkZombieBile.java similarity index 51% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkZombieBile.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/zombie/PerkZombieBile.java index adb0f1455..cea58d3c1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkZombieBile.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/zombie/PerkZombieBile.java @@ -1,173 +1,194 @@ -package nautilus.game.arcade.kit.perks; +package nautilus.game.arcade.game.games.smash.perks.zombie; import java.util.HashMap; import java.util.Iterator; +import java.util.Map; +import java.util.UUID; + +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.entity.Item; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; -import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.projectile.IThrown; import mineplex.core.projectile.ProjectileUser; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.kit.SmashPerk; - -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.block.Block; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.block.Action; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.util.Vector; +import nautilus.game.arcade.game.games.smash.perks.SmashPerk; public class PerkZombieBile extends SmashPerk implements IThrown { - private HashMap<Player, Long> _active = new HashMap<Player, Long>(); + + private static final int COOLDOWN = 10000; + private static final int ITEMS = 3; + private static final int DAMAGE = 3; + private static final int KNOCKBACK_MAGNITUDE = 1; - public PerkZombieBile() + private Map<UUID, Long> _active = new HashMap<>(); + + public PerkZombieBile() { - super("Spew Bile", new String[] - { - C.cYellow + "Hold Block" + C.cGray + " to use " + C.cGreen + "Spew Bile" - }); + super("Spew Bile", new String[] { C.cYellow + "Hold Block" + C.cGray + " to use " + C.cGreen + "Spew Bile" }); } - + @EventHandler public void activate(PlayerInteractEvent event) { if (event.isCancelled()) + { return; - - if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) + } + + if (!UtilEvent.isAction(event, ActionType.R)) + { return; - + } + if (UtilBlock.usable(event.getClickedBlock())) + { return; - - if (!event.getPlayer().getItemInHand().getType().toString().contains("_AXE")) - return; - + } + Player player = event.getPlayer(); - - if (!Kit.HasKit(player)) + + if (!UtilItem.isAxe(player.getItemInHand())) + { return; - - if (!Recharge.Instance.use(player, GetName(), 10000, true, true)) + } + + if (!hasPerk(player)) + { return; - - _active.put(player, System.currentTimeMillis()); + } + + if (!Recharge.Instance.use(player, GetName(), COOLDOWN, true, true)) + { + return; + } + + _active.put(player.getUniqueId(), System.currentTimeMillis()); UtilPlayer.message(player, F.main("Skill", "You used " + F.skill(GetName()) + ".")); } - + @EventHandler public void deactivateDeath(PlayerDeathEvent event) { - if (!Manager.GetGame().IsLive()) - return; - - if (!Kit.HasKit(event.getEntity())) - return; - - if (_active.containsKey(event.getEntity())) + if (!hasPerk(event.getEntity())) { - _active.remove(event.getEntity()); + return; } + + _active.remove(event.getEntity().getUniqueId()); } - + @EventHandler - public void update(UpdateEvent event) + public void update(UpdateEvent event) { if (event.getType() != UpdateType.TICK) + { return; + } + + Iterator<UUID> activeIter = _active.keySet().iterator(); - Iterator<Player> activeIter = _active.keySet().iterator(); - while (activeIter.hasNext()) { - Player player = activeIter.next(); - - //Expire - if (UtilTime.elapsed(_active.get(player), 2000)) + UUID uuid = activeIter.next(); + Player player = UtilPlayer.searchExact(uuid); + + // Expire + if (UtilTime.elapsed(_active.get(player.getUniqueId()), 2000)) { activeIter.remove(); - continue; + continue; } - - //Sound + + // Sound if (Math.random() > 0.85) - player.getWorld().playSound(player.getLocation(), Sound.BURP, 1f, (float)(Math.random() + 0.5)); - - //Projectiles - for (int i=0 ; i<3 ; i++) { - Vector rand = new Vector((Math.random()-0.5)*0.6,(Math.random()-0.5)*0.6,(Math.random()-0.5)*0.6); - - org.bukkit.entity.Item ent = player.getWorld().dropItem(player.getEyeLocation().add(player.getLocation().getDirection()).subtract(0, 0.5, 0), ItemStackFactory.Instance.CreateStack(Material.ROTTEN_FLESH)); + player.getWorld().playSound(player.getLocation(), Sound.BURP, 1f, (float) (Math.random() + 0.5)); + } + + // Projectiles + for (int i = 0; i < ITEMS; i++) + { + Vector rand = new Vector((Math.random() - 0.5) * 0.525, (Math.random() - 0.5) * 0.525, (Math.random() - 0.5) * 0.525); + + Item ent = player.getWorld().dropItem(player.getEyeLocation().add(player.getLocation().getDirection()).subtract(0, 0.5, 0), new ItemStack(Material.ROTTEN_FLESH)); UtilAction.velocity(ent, player.getLocation().getDirection().add(rand), 0.8, false, 0, 0.2, 10, false); - Manager.GetProjectile().AddThrow(ent, player, this, System.currentTimeMillis() + 2000, true, true, true, false, 0.5f); + Manager.GetProjectile().AddThrow(ent, player, this, 2000, true, true, true, false, 0.5f); } } } - + @EventHandler public void death(PlayerDeathEvent event) { - if (_active.containsKey(event.getEntity())) - { - _active.remove(event.getEntity()); - } + _active.remove(event.getEntity().getUniqueId()); } - + @Override public void Collide(LivingEntity target, Block block, ProjectileUser data) { data.getThrown().remove(); - + if (target == null) + { return; + } - if (target instanceof Player) - if (!Manager.GetGame().IsAlive((Player)target)) - return; - - //Damage Event - Manager.GetDamage().NewDamageEvent(target, data.getThrower(), null, - DamageCause.CUSTOM, 3, true, false, false, - UtilEnt.getName(data.getThrower()), GetName()); + if (UtilPlayer.isSpectator(target)) + { + return; + } + + // Damage Event + Manager.GetDamage().NewDamageEvent(target, data.getThrower(), null, DamageCause.CUSTOM, DAMAGE, true, false, false, UtilEnt.getName(data.getThrower()), GetName()); data.getThrown().remove(); } @Override - public void Idle(ProjectileUser data) + public void Idle(ProjectileUser data) { data.getThrown().remove(); } @Override - public void Expire(ProjectileUser data) + public void Expire(ProjectileUser data) { data.getThrown().remove(); } - + @EventHandler public void Knockback(CustomDamageEvent event) { if (event.GetReason() == null || !event.GetReason().contains(GetName())) + { return; + } - event.AddKnockback(GetName(), 1); + event.AddKnockback(GetName(), KNOCKBACK_MAGNITUDE); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkNightLivingDead.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/zombie/SmashZombie.java similarity index 66% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkNightLivingDead.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/zombie/SmashZombie.java index 9f0bcc8c7..3973da393 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkNightLivingDead.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/zombie/SmashZombie.java @@ -1,8 +1,9 @@ -package nautilus.game.arcade.kit.perks; +package nautilus.game.arcade.game.games.smash.perks.zombie; import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; +import java.util.List; import org.bukkit.Effect; import org.bukkit.Location; @@ -21,105 +22,146 @@ import mineplex.core.common.util.UtilTime; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.game.games.smash.TeamSuperSmash; -import nautilus.game.arcade.kit.SmashPerk; +import nautilus.game.arcade.game.games.smash.perks.SmashUltimate; import nautilus.game.arcade.kit.perks.data.NightLivingDeadData; -public class PerkNightLivingDead extends SmashPerk +public class SmashZombie extends SmashUltimate { - private ArrayList<NightLivingDeadData> _night = new ArrayList<NightLivingDeadData>(); + private static final int DURATION = 30000; - private HashSet<Material> _ignoreList = new HashSet<Material>();; - - public PerkNightLivingDead() + private List<NightLivingDeadData> _night = new ArrayList<>(); + + private HashSet<Material> _ignoreList = new HashSet<>();; + + public SmashZombie() { - super("Night of the Living Dead", new String[] - { - }, false); + super("Night of the Living Dead", new String[] {}, Sound.AMBIENCE_CAVE, DURATION); } @Override - public void addSuperCustom(Player player) + public void activate(Player player) { + super.activate(player); + _night.add(new NightLivingDeadData(player)); } + @Override + public void cancel(Player player) + { + super.cancel(player); + + Iterator<NightLivingDeadData> nightIter = _night.iterator(); + + while (nightIter.hasNext()) + { + NightLivingDeadData data = nightIter.next(); + + // Expire + if (data.Player.equals(player)) + { + nightIter.remove(); + + for (Zombie zombie : data.Zombies) + { + zombie.damage(1000); + } + + return; + } + } + + } + @EventHandler public void timeUpdate(UpdateEvent event) { if (event.getType() != UpdateType.TICK) + { return; + } if (_night.isEmpty() && Manager.GetGame().WorldTimeSet != 12000) { - Manager.GetGame().WorldTimeSet = (Manager.GetGame().WorldTimeSet + 50)%24000; + Manager.GetGame().WorldTimeSet = (Manager.GetGame().WorldTimeSet + 50) % 24000; } else if (!_night.isEmpty() && Manager.GetGame().WorldTimeSet != 18000) { - Manager.GetGame().WorldTimeSet = (Manager.GetGame().WorldTimeSet + 50)%24000; + Manager.GetGame().WorldTimeSet = (Manager.GetGame().WorldTimeSet + 50) % 24000; } } - + @EventHandler public void update(UpdateEvent event) { if (event.getType() != UpdateType.TICK) + { return; + } Iterator<NightLivingDeadData> nightIter = _night.iterator(); - + while (nightIter.hasNext()) { NightLivingDeadData data = nightIter.next(); - - //Expire - if (UtilTime.elapsed(data.Time, 30000)) + + // Expire + if (UtilTime.elapsed(data.Time, DURATION)) { nightIter.remove(); - + for (Zombie zombie : data.Zombies) + { zombie.damage(1000); + } + continue; } - - //Spawn + + // Spawn if (UtilTime.elapsed(data.LastSpawn, 1000)) { Location origin = UtilAlg.Random(Manager.GetGame().GetPlayers(true)).getLocation(); Location loc = findSpawn(origin); - + if (Math.abs(loc.getY() - origin.getY()) > 6) + { continue; + } if (!UtilBlock.airFoliage(loc.getBlock()) || !UtilBlock.airFoliage(loc.getBlock().getRelative(BlockFace.UP))) + { continue; + } - //Set Spawned + // Set Spawned data.LastSpawn = System.currentTimeMillis(); - - //Move Down + + // Move Down loc.subtract(0, 1, 0); - - //Spawn + + // Spawn Manager.GetGame().CreatureAllowOverride = true; Zombie zombie = loc.getWorld().spawn(loc, Zombie.class); Manager.GetGame().CreatureAllowOverride = false; - + data.Zombies.add(zombie); - - //Pop up - zombie.setVelocity(new Vector(0,0.4,0)); - //zombie.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 9999, 1, true)); - - //Effect + + // Pop up + zombie.setVelocity(new Vector(0, 0.4, 0)); + // zombie.addPotionEffect(new + // PotionEffect(PotionEffectType.SPEED, 9999, 1, true)); + + // Effect zombie.getWorld().playSound(zombie.getLocation(), Sound.ZOMBIE_IDLE, 1f, 0.75f); - + loc.getWorld().playEffect(loc, Effect.STEP_SOUND, loc.getBlock().getType()); } } } - + @EventHandler - public void update(EntityTargetEvent event) + public void target(EntityTargetEvent event) { for (NightLivingDeadData data : _night) { @@ -129,7 +171,7 @@ public class PerkNightLivingDead extends SmashPerk { TeamSuperSmash smash = (TeamSuperSmash) Manager.GetGame(); Player targetPlayer = (Player) event.getTarget(); - + if (smash.GetTeam(data.Player).equals(smash.GetTeam(targetPlayer))) { event.setCancelled(true); @@ -142,9 +184,9 @@ public class PerkNightLivingDead extends SmashPerk } } } - + public Location findSpawn(Location area) { - return UtilBlock.getHighest(area.getWorld(), (int)(area.getX() + Math.random() * 24 - 12), (int)(area.getZ() + Math.random() * 24 - 12), _ignoreList).getLocation().add(0.5, 0.5, 0.5); + return UtilBlock.getHighest(area.getWorld(), (int) (area.getX() + Math.random() * 24 - 12), (int) (area.getZ() + Math.random() * 24 - 12), _ignoreList).getLocation().add(0.5, 0.5, 0.5); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/kit/KitArcher.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/kit/KitArcher.java index 8c9c49bd5..f520f6e26 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/kit/KitArcher.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/kit/KitArcher.java @@ -1,13 +1,14 @@ package nautilus.game.arcade.game.games.survivalgames.kit; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + import mineplex.core.common.util.C; import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.smash.perks.skeleton.PerkBarrage; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.perks.PerkBarrage; import nautilus.game.arcade.kit.perks.PerkFletcher; -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; public class KitArcher extends SurvivalGamesKit { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/tug/kits/KitArcher.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/tug/kits/KitArcher.java index 61d50a516..de82c4e11 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/tug/kits/KitArcher.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/tug/kits/KitArcher.java @@ -1,17 +1,18 @@ package nautilus.game.arcade.game.games.tug.kits; -import mineplex.core.itemstack.ItemStackFactory; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.kit.KitAvailability; -import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.ProgressingKit; -import nautilus.game.arcade.kit.perks.PerkBarrage; -import nautilus.game.arcade.kit.perks.PerkFletcher; import org.bukkit.Material; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import mineplex.core.itemstack.ItemStackFactory; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.smash.perks.skeleton.PerkBarrage; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.ProgressingKit; +import nautilus.game.arcade.kit.perks.PerkFletcher; + public class KitArcher extends ProgressingKit { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/kits/KitShredder.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/kits/KitShredder.java index b23f051ee..21b33aed8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/kits/KitShredder.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/kits/KitShredder.java @@ -1,20 +1,21 @@ package nautilus.game.arcade.game.games.turfforts.kits; -import mineplex.core.common.util.C; -import mineplex.core.itemstack.ItemStackFactory; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.kit.KitAvailability; -import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.ProgressingKit; -import nautilus.game.arcade.kit.perks.PerkBarrage; -import nautilus.game.arcade.kit.perks.PerkConstructor; -import nautilus.game.arcade.kit.perks.PerkFletcher; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemStackFactory; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.smash.perks.skeleton.PerkBarrage; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.ProgressingKit; +import nautilus.game.arcade.kit.perks.PerkConstructor; +import nautilus.game.arcade.kit.perks.PerkFletcher; + public class KitShredder extends ProgressingKit { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/zombiesurvival/kits/KitSurvivorArcher.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/zombiesurvival/kits/KitSurvivorArcher.java index 071588287..d807865d9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/zombiesurvival/kits/KitSurvivorArcher.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/zombiesurvival/kits/KitSurvivorArcher.java @@ -2,10 +2,10 @@ package nautilus.game.arcade.game.games.zombiesurvival.kits; import mineplex.core.itemstack.ItemStackFactory; import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.smash.perks.skeleton.PerkBarrage; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.ProgressingKit; -import nautilus.game.arcade.kit.perks.PerkBarrage; import nautilus.game.arcade.kit.perks.PerkFletcher; import org.bukkit.Material; import org.bukkit.entity.EntityType; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/combatlog/CombatLogModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/combatlog/CombatLogModule.java index 6e23a2ad6..9fd3f2f81 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/combatlog/CombatLogModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/combatlog/CombatLogModule.java @@ -228,6 +228,8 @@ public class CombatLogModule extends Module teamGame.RejoinTeam.remove(logoutNpc.getPlayerInfo().getName()); teamGame.RejoinHealth.remove(logoutNpc.getPlayerInfo().getName()); } + + _logoutNpcs.remove(logoutNpc.getPlayerInfo().getUniqueId()); } @EventHandler(ignoreCancelled = true) @@ -274,10 +276,7 @@ public class CombatLogModule extends Module { if (event.getType() == UpdateType.FASTER) { - for (CombatLogNPC npc : _logoutNpcs.values()) - { - npc.update(); - } + _logoutNpcs.values().forEach(CombatLogNPC::update); } if (event.getType() == UpdateType.SEC) @@ -297,7 +296,7 @@ public class CombatLogModule extends Module else if (!npc.isAlive()) { System.out.println("Removing NPC " + npc.getPlayerInfo().getName() + " for 2"); - npc.remove(); + npc.despawn(); iterator.remove(); } else if (npc.getAliveDuation() > this._spawnTime) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/combatlog/CombatLogNPC.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/combatlog/CombatLogNPC.java index 66c7eac4c..65e59f64b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/combatlog/CombatLogNPC.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/combatlog/CombatLogNPC.java @@ -3,6 +3,7 @@ package nautilus.game.arcade.game.modules.combatlog; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilTime; import mineplex.core.disguise.DisguiseManager; +import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.hologram.Hologram; import nautilus.game.arcade.ArcadeManager; @@ -33,6 +34,7 @@ public class CombatLogNPC private double _maxHealth; private LivingEntity _npc; + private DisguiseBase _disguise; private EntityDamageEvent.DamageCause _lastDamageCause; private Entity _lastDamager; @@ -59,7 +61,7 @@ public class CombatLogNPC */ public void onDeath() { - _disguiseManager.undisguise(_npc); + despawn(); } public void update() @@ -99,21 +101,30 @@ public class CombatLogNPC public void despawn() { + if (_disguise != null) + { + try + { + _disguiseManager.undisguise(_disguise); + _disguise = null; + } + catch (Exception e) + { + e.printStackTrace(); + } + } if (_npc != null) { _npc.remove(); _npc = null; + } + if (_hologram != null) + { _hologram.stop(); _hologram = null; } } - public void remove() - { - _hologram.stop(); - _hologram = null; - } - public PlayerInfo getPlayerInfo() { return _playerInfo; @@ -149,6 +160,8 @@ public class CombatLogNPC DisguisePlayer disguise = new DisguisePlayer(skel, ((CraftPlayer) player).getHandle().getProfile()); _disguiseManager.disguise(disguise); + _disguise = disguise; + return skel; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Perk.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Perk.java index 51c9f2959..18a51d276 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Perk.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Perk.java @@ -1,6 +1,8 @@ package nautilus.game.arcade.kit; import nautilus.game.arcade.ArcadeManager; + +import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.Listener; @@ -30,6 +32,11 @@ public abstract class Perk implements Listener public boolean hasPerk(Player player) { + if (Manager.GetGame() == null) + { + return false; + } + if (!Manager.GetGame().IsLive()) { return false; @@ -41,7 +48,7 @@ public abstract class Perk implements Listener } ProgressingKit progressingKit = (ProgressingKit) Kit; - + return Kit.HasKit(player) && progressingKit.getUpgradeLevel(player.getUniqueId()) == _upgradeLevel; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/SmashKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/SmashKit.java deleted file mode 100644 index a277c147e..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/SmashKit.java +++ /dev/null @@ -1,241 +0,0 @@ -package nautilus.game.arcade.kit; - -import mineplex.core.common.util.*; -import mineplex.core.recharge.Recharge; -import mineplex.core.updater.event.UpdateEvent; -import nautilus.game.arcade.ArcadeFormat; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.events.GameStateChangeEvent; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.inventory.ItemStack; - -import java.util.Collection; -import java.util.Iterator; - -public abstract class SmashKit extends ProgressingKit -{ - - protected static final String DOUBLE_JUMP = C.cYellow + "Double tap " + C.cWhite + "your jump key to " + C.cGreen + "Double Jump"; - - private NautHashMap<Player, Long> _superActive = new NautHashMap<Player, Long>(); - - private int _superCharges = 1; - private String _superName; - private long _superDuration; - private Sound _superSound; - - public SmashKit(ArcadeManager manager, String name, - KitAvailability kitAvailability, String[] kitDesc, Perk[] kitPerks, - EntityType entityType, ItemStack itemInHand, - String superName, long superDuration, Sound superSound) - { - super(manager, name, "smash" + name.toLowerCase().replace(" ", ""), kitAvailability, 3000, kitDesc, kitPerks, entityType, itemInHand); - - _superName = superName; - _superDuration = superDuration; - _superSound = superSound; - } - - public SmashKit(ArcadeManager manager, String name, - KitAvailability kitAvailability, int cost, String[] kitDesc, Perk[] kitPerks, - EntityType entityType, ItemStack itemInHand, - String superName, long superDuration, Sound superSound) - { - super(manager, name, "smash" + name.toLowerCase().replace(" ", ""), kitAvailability, cost, kitDesc, kitPerks, entityType, itemInHand); - - _superName = superName; - _superDuration = superDuration; - _superSound = superSound; - } - - @Override - public void DisplayDesc(Player player) - { - for (int i=0 ; i<3 ; i++) - UtilPlayer.message(player, ""); - - UtilPlayer.message(player, ArcadeFormat.Line); - - UtilPlayer.message(player, "§aKit - §f§l" + GetName()); - - //Desc - for (String line : GetDesc()) - { - UtilPlayer.message(player, C.cGray + " " + line); - } - - //Perk Descs - for (Perk perk : GetPerks()) - { - if (!perk.IsVisible()) - continue; - - for (String line : perk.GetDesc()) - { - UtilPlayer.message(player, C.cGray + " " + line); - } - } - - UtilPlayer.message(player, ArcadeFormat.Line); - - } - - @EventHandler - public void triggerSuper(PlayerInteractEvent event) - { - if (!Manager.GetGame().IsLive()) - return; - - if (!HasKit(event.getPlayer())) - return; - - if (!UtilGear.isMat(event.getItem(), Material.NETHER_STAR)) - return; - - if (!Recharge.Instance.use(event.getPlayer(), _superName, 500, true, false)) - return; - - UtilInv.remove(event.getPlayer(), Material.NETHER_STAR, (byte)0, 1); - - activateSuper(event.getPlayer()); - - //Heal - event.getPlayer().setHealth(event.getPlayer().getMaxHealth()); - - //Inform + Effect - event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), _superSound, 20f, 1f); - - if (Recharge.Instance.use(event.getPlayer(), _superName + " Announce", 20000, false, false)) - { - Manager.GetGame().Announce(C.Bold + event.getPlayer().getName() + " activated " + C.cGreen + C.Bold + _superName + ChatColor.RESET + C.Bold + "!"); - UtilTextMiddle.display("Smash Crystal", event.getPlayer().getName() + " used " + C.cGreen + _superName, 5, 50, 5, UtilServer.getPlayers()); - } - } - - @EventHandler - public void onEnd(GameStateChangeEvent event) - { - Iterator<Player> superIter = _superActive.keySet().iterator(); - - while (superIter.hasNext()) - { - Player player = superIter.next(); - superIter.remove(); - deactivateSuper(player); - } - } - - @EventHandler - public void expireSuper(UpdateEvent event) - { - Iterator<Player> superIter = _superActive.keySet().iterator(); - - while (superIter.hasNext()) - { - Player player = superIter.next(); - - if (System.currentTimeMillis() > _superActive.get(player)) - { - superIter.remove(); - deactivateSuper(player); - } - } - } - - @EventHandler - public void deathSuper(PlayerDeathEvent event) - { - if (_superActive.remove(event.getEntity()) != null) - deactivateSuper(event.getEntity()); - } - - public void activateSuper(Player player) - { - //Duration Super - if (_superDuration > 0) - { - _superActive.put(player, System.currentTimeMillis() + _superDuration); - - Recharge.Instance.recharge(player, _superName); - Recharge.Instance.use(player, _superName, _superDuration, false, false); - Recharge.Instance.setDisplayForce(player, _superName, true); - Recharge.Instance.setCountdown(player, _superName, true); - } - - //Disable Perks for Duration - for (Perk perk : GetPerks()) - if (perk instanceof SmashPerk) - ((SmashPerk)perk).addSuperActive(player); - - //Items - giveSuperItems(player); - - //Custom - activateSuperCustom(player); - - //Deactivate if instant - if (_superDuration <= 0) - { - deactivateSuper(player); - } - } - - public void activateSuperCustom(Player player) - { - //Null Default - } - - public void deactivateSuper(Player player) - { - //Perks - for (Perk perk : GetPerks()) - if (perk instanceof SmashPerk) - ((SmashPerk)perk).removeSuperActive(player); - - //Items - giveCoreItems(player); - - //Custom - deactivateSuperCustom(player); - } - - public void deactivateSuperCustom(Player player) - { - //Null Default - } - - public Collection<Player> getSuperActive() - { - return _superActive.keySet(); - } - - public boolean isSuperActive(Player player) - { - return _superActive.containsKey(player); - } - - public String getSuperName() - { - return _superName; - } - - public int getSuperCharges() - { - return _superCharges; - } - - public void setSuperCharges(int charges) - { - _superCharges = charges; - } - - public abstract void giveCoreItems(Player player); - public abstract void giveSuperItems(Player player); -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/SmashPerk.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/SmashPerk.java deleted file mode 100644 index 2c7dfa0ee..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/SmashPerk.java +++ /dev/null @@ -1,48 +0,0 @@ -package nautilus.game.arcade.kit; - -import java.util.HashSet; - -import org.bukkit.entity.Player; - -public abstract class SmashPerk extends Perk -{ - private HashSet<Player> _superActive = new HashSet<Player>(); - - public SmashPerk(String name, String[] perkDesc) - { - super(name, perkDesc); - } - - public SmashPerk(String name, String[] perkDesc, boolean display) - { - super(name, perkDesc, display); - } - - public void addSuperActive(Player player) - { - _superActive.add(player); - - addSuperCustom(player); - } - - public void addSuperCustom(Player player) - { - - } - - public void removeSuperActive(Player player) - { - if (_superActive.remove(player)) - removeSuperCustom(player); - } - - public void removeSuperCustom(Player player) - { - - } - - public boolean isSuperActive(Player player) - { - return _superActive.contains(player); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkArcticAura.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkArcticAura.java deleted file mode 100644 index 6af4ed018..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkArcticAura.java +++ /dev/null @@ -1,52 +0,0 @@ -package nautilus.game.arcade.kit.perks; - -import java.util.HashMap; - -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilMath; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import nautilus.game.arcade.kit.Perk; - -import org.bukkit.block.Block; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; - -public class PerkArcticAura extends Perk -{ - public PerkArcticAura() - { - super("Arctic Aura", new String[] - { - "You freeze things around you, slowing enemies." - }); - } - - @EventHandler - public void SnowAura(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; - - for (Player player : Manager.GetGame().GetPlayers(true)) - { - if (!Kit.HasKit(player)) - continue; - - if (((CraftPlayer) player).getHandle().spectating) - continue; - - double range = 5*player.getExp(); - - //Blocks - double duration = 2000; - HashMap<Block, Double> blocks = UtilBlock.getInRadius(player.getLocation(), range); - for (Block block : blocks.keySet()) - { - //Snow - Manager.GetBlockRestore().snow(block, (byte) 1, (byte) 1, (long) (duration * (1 + blocks.get(block))), 250, 0); - } - } - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBarrage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBarrage.java deleted file mode 100644 index 2542e5b3b..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBarrage.java +++ /dev/null @@ -1,302 +0,0 @@ -package nautilus.game.arcade.kit.perks; - -import java.util.HashSet; -import java.util.Iterator; -import java.util.WeakHashMap; - -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.Player; -import org.bukkit.entity.Projectile; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.block.Action; -import org.bukkit.event.entity.EntityShootBowEvent; -import org.bukkit.event.entity.ProjectileHitEvent; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.util.Vector; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTime; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.core.updater.UpdateType; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.kit.SmashPerk; - -public class PerkBarrage extends SmashPerk -{ - private WeakHashMap<Player, Integer> _charge = new WeakHashMap<Player, Integer>(); - private WeakHashMap<Player, Long> _chargeLast = new WeakHashMap<Player, Long>(); - - private HashSet<Player> _firing = new HashSet<Player>(); - private HashSet<Projectile> _arrows = new HashSet<Projectile>(); - - private int _max; - private long _tick; - private boolean _remove; - private boolean _noDelay; - private boolean _useExp; - - public PerkBarrage(int max, long tick, boolean remove, boolean noDelay) - { - this(max, tick, remove, noDelay, false); - } - - public PerkBarrage(int max, long tick, boolean remove, boolean noDelay, boolean useExpAndBar) - { - super("Barrage", new String[] - { - C.cYellow + "Charge" + C.cGray + " your Bow to use " + C.cGreen + "Barrage" - }); - _useExp = useExpAndBar; - _max = max; - _tick = tick; - _remove = remove; - _noDelay = noDelay; - } - - @EventHandler - public void BarrageDrawBow(PlayerInteractEvent event) - { - Player player = event.getPlayer(); - - if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) - return; - - if (player.getItemInHand() == null || player.getItemInHand().getType() != Material.BOW) - return; - - if (isSuperActive(player)) - return; - - if (!Kit.HasKit(player)) - return; - - if (!player.getInventory().contains(Material.ARROW)) - return; - - if (event.getClickedBlock() != null) - if (UtilBlock.usable(event.getClickedBlock())) - return; - - // Start Charge - _charge.put(player, 0); - _chargeLast.put(player, System.currentTimeMillis()); - _firing.remove(player); - } - - @EventHandler - public void BarrageCharge(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; - - for (Player cur : UtilServer.getPlayers()) - { - // Not Charging - if (!_charge.containsKey(cur)) - continue; - - if (_firing.contains(cur)) - continue; - - // Max Charge - if (_charge.get(cur) >= _max) - continue; - - // Charge Interval - if (_charge.get(cur) == 0) - { - if (!UtilTime.elapsed(_chargeLast.get(cur), 1000)) - continue; - } - else - { - if (!UtilTime.elapsed(_chargeLast.get(cur), _tick)) - continue; - } - - // No Longer Holding Bow - if (cur.getItemInHand() == null || cur.getItemInHand().getType() != Material.BOW) - { - if (_useExp) - { - cur.setExp(0f); - } - _charge.remove(cur); - _chargeLast.remove(cur); - continue; - } - - // Increase Charge - _charge.put(cur, _charge.get(cur) + 1); - - if (_useExp) - { - cur.setExp(Math.min(0.9999f, (float)_charge.get(cur) / (float)_max)); - } - _chargeLast.put(cur, System.currentTimeMillis()); - - // Effect - cur.playSound(cur.getLocation(), Sound.CLICK, 1f, 1f + (0.1f * _charge.get(cur))); - } - } - - @EventHandler(priority = EventPriority.HIGH) - public void BarrageFireBow(EntityShootBowEvent event) - { - if (event.isCancelled()) - return; - - if (!Manager.GetGame().IsLive()) - return; - - if (!(event.getEntity() instanceof Player)) - return; - - if (!(event.getProjectile() instanceof Arrow)) - return; - - Player player = (Player) event.getEntity(); - - if (!_charge.containsKey(player)) - return; - - // Start Barrage - _firing.add(player); - _chargeLast.put(player, System.currentTimeMillis()); - } - - @EventHandler - public void BarrageArrows(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; - - HashSet<Player> remove = new HashSet<Player>(); - - for (Player cur : _firing) - { - if (!_charge.containsKey(cur) || !_chargeLast.containsKey(cur)) - { - remove.add(cur); - continue; - } - - if (cur.getItemInHand() == null || cur.getItemInHand().getType() != Material.BOW) - { - remove.add(cur); - continue; - } - - int arrows = _charge.get(cur); - if (arrows <= 0) - { - remove.add(cur); - continue; - } - - _charge.put(cur, arrows - 1); - if (_useExp) - { - cur.setExp(Math.min(0.9999f, (float)_charge.get(cur) / (float)_max)); - } - - // Fire Arrow - Vector random = new Vector((Math.random() - 0.5) / 10, (Math.random() - 0.5) / 10, (Math.random() - 0.5) / 10); - Projectile arrow = cur.launchProjectile(Arrow.class); - arrow.setVelocity(cur.getLocation().getDirection().add(random).multiply(3)); - _arrows.add(arrow); - cur.getWorld().playSound(cur.getLocation(), Sound.SHOOT_ARROW, 1f, 1f); - } - - for (Player cur : remove) - { - if (_useExp) - { - cur.setExp(0f); - } - _charge.remove(cur); - _chargeLast.remove(cur); - _firing.remove(cur); - } - } - - @EventHandler(priority = EventPriority.HIGH) - public void BarrageDamageTime(CustomDamageEvent event) - { - if (!_noDelay) - return; - - if (event.GetProjectile() == null) - return; - - if (event.GetDamagerPlayer(true) == null) - return; - - if (!(event.GetProjectile() instanceof Arrow)) - return; - - Player damager = event.GetDamagerPlayer(true); - - if (!Kit.HasKit(damager)) - return; - - event.SetCancelled("Barrage Cancel"); - - event.GetProjectile().remove(); - - // Damage Event - Manager.GetDamage().NewDamageEvent(event.GetDamageeEntity(), damager, null, DamageCause.THORNS, event.GetDamage(), true, - true, false, damager.getName(), GetName()); - } - - @EventHandler - public void BarrageProjectileHit(ProjectileHitEvent event) - { - if (_remove) - if (_arrows.remove(event.getEntity())) - event.getEntity().remove(); - } - - @EventHandler - public void BarrageClean(UpdateEvent event) - { - if (event.getType() != UpdateType.SEC) - return; - - for (Iterator<Projectile> arrowIterator = _arrows.iterator(); arrowIterator.hasNext();) - { - Projectile arrow = arrowIterator.next(); - - if (arrow.isDead() || !arrow.isValid()) - arrowIterator.remove(); - } - } - - @EventHandler - public void Quit(PlayerQuitEvent event) - { - Player player = event.getPlayer(); - - clean(player); - } - - @Override - public void addSuperCustom(Player player) - { - clean(player); - } - - public void clean(Player player) - { - _charge.remove(player); - _chargeLast.remove(player); - _firing.remove(player); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBatWave.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBatWave.java deleted file mode 100644 index b0366e539..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBatWave.java +++ /dev/null @@ -1,256 +0,0 @@ -package nautilus.game.arcade.kit.perks; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; - -import org.bukkit.Location; -import org.bukkit.Sound; -import org.bukkit.entity.Bat; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.block.Action; -import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.util.Vector; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTime; -import mineplex.core.recharge.Recharge; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.kit.SmashPerk; - -public class PerkBatWave extends SmashPerk -{ - private HashMap<Player, Long> _active = new HashMap<Player, Long>(); - private HashMap<Player, Location> _direction = new HashMap<Player, Location>(); - private HashMap<Player, ArrayList<Bat>> _bats = new HashMap<Player, ArrayList<Bat>>(); - private HashSet<Player> _pulling = new HashSet<Player>(); - private HashSet<Player> _allowLeash = new HashSet<Player>(); - - public PerkBatWave() - { - super("Bat Wave", new String[] - { - C.cYellow + "Right-Click" + C.cGray + " with Spade to use " + C.cGreen + "Bat Wave", - C.cYellow + "Double Right-Click" + C.cGray + " with Spade to use " + C.cGreen + "Bat Leash" - }); - } - - @EventHandler - public void Deactivate(CustomDamageEvent event) - { - Player player = event.GetDamageePlayer(); - if (player == null) return; - - if (_pulling.remove(player)) - { - for (Bat bat : _bats.get(player)) - bat.setLeashHolder(null); - } - } - - @EventHandler - public void Activate(PlayerInteractEvent event) - { - if (event.isCancelled()) - return; - - if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) - return; - - if (UtilBlock.usable(event.getClickedBlock())) - return; - - if (!event.getPlayer().getItemInHand().getType().toString().contains("_SPADE")) - return; - - Player player = event.getPlayer(); - - if (isSuperActive(player)) - return; - - if (!Kit.HasKit(player)) - return; - - if (!Recharge.Instance.use(player, GetName(), 8000, false, true)) - { - if (_active.containsKey(player)) - { - if (!Recharge.Instance.use(player, "Leash Bats", 500, false, false)) - return; - - if (!_pulling.remove(player)) - { - if (_allowLeash.remove(player)) - { - _pulling.add(player); - - for (Bat bat : _bats.get(player)) - bat.setLeashHolder(player); - } - } - else - { - for (Bat bat : _bats.get(player)) - bat.setLeashHolder(null); - } - } - else - { - //Inform - Recharge.Instance.use(player, GetName(), 8000, true, true); - } - } - else - { - //Start - _direction.put(player, player.getEyeLocation()); - _active.put(player, System.currentTimeMillis()); - _allowLeash.add(player); - - _bats.put(player, new ArrayList<Bat>()); - - for (int i=0 ; i<32 ; i++) - { - Manager.GetGame().CreatureAllowOverride = true; - Bat bat = player.getWorld().spawn(player.getEyeLocation(), Bat.class); - _bats.get(player).add(bat); - Manager.GetGame().CreatureAllowOverride = false; - } - - //Inform - UtilPlayer.message(player, F.main("Skill", "You used " + F.skill(GetName()) + ".")); - } - } - - @EventHandler - public void Update(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; - - for (Player cur : UtilServer.getPlayers()) - { - if (!_active.containsKey(cur)) - continue; - - if (UtilTime.elapsed(_active.get(cur), 2500)) - { - Clear(cur); - continue; - } - - Location loc = _direction.get(cur); - - Vector batVec = new Vector(0,0,0); - double batCount = 0; - - //Bat Movement - for (Bat bat : _bats.get(cur)) - { - if (!bat.isValid()) - continue; - - batVec.add(bat.getLocation().toVector()); - batCount++; - - Vector rand = new Vector((Math.random() - 0.5)/2, (Math.random() - 0.5)/2, (Math.random() - 0.5)/2); - bat.setVelocity(loc.getDirection().clone().multiply(0.5).add(rand)); - - for (Player other : Manager.GetGame().GetPlayers(true)) - { - if (other.equals(cur)) - continue; - - if (!Recharge.Instance.usable(other, "Hit by Bat")) - continue; - - if (UtilEnt.hitBox(bat.getLocation(), other, 2, null)) - { - //Damage Event - Manager.GetDamage().NewDamageEvent(other, cur, null, - DamageCause.CUSTOM, 2.5, true, true, false, - cur.getName(), GetName()); - - //Effect - bat.getWorld().playSound(bat.getLocation(), Sound.BAT_HURT, 1f, 1f); - UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, bat.getLocation(), 0, 0, 0, 0, 3, - ViewDist.LONG, UtilServer.getPlayers()); - - bat.remove(); - - //Recharge on hit - Recharge.Instance.useForce(other, "Hit by Bat", 200); - } - } - } - - //Player Pull - if (_pulling.contains(cur)) - { - batVec.multiply(1/batCount); - - Location batLoc = batVec.toLocation(cur.getWorld()); - - UtilAction.velocity(cur, UtilAlg.getTrajectory(cur.getLocation(), batLoc), 0.35, false, 0, 0, 10, false); - } - } - } - - @EventHandler - public void PlayerQuit(PlayerQuitEvent event) - { - Clear(event.getPlayer()); - } - - @EventHandler - public void PlayerDeath(PlayerDeathEvent event) - { - Clear(event.getEntity()); - } - - public void Clear(Player player) - { - _active.remove(player); - _direction.remove(player); - _pulling.remove(player); - if (_bats.containsKey(player)) - { - for (Bat bat : _bats.get(player)) - { - if (bat.isValid()) - UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, bat.getLocation(), 0, 0, 0, 0, 3, - ViewDist.LONG, UtilServer.getPlayers()); - - bat.remove(); - } - - - _bats.remove(player); - } - } - - @EventHandler - public void Knockback(CustomDamageEvent event) - { - if (event.GetReason() == null || !event.GetReason().contains(GetName())) - return; - - event.AddKnockback(GetName(), 1.75); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBlink.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBlink.java deleted file mode 100644 index dfbc490a4..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBlink.java +++ /dev/null @@ -1,122 +0,0 @@ -package nautilus.game.arcade.kit.perks; - -import org.bukkit.Color; -import org.bukkit.Effect; -import org.bukkit.Location; -import org.bukkit.Sound; -import org.bukkit.FireworkEffect.Type; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.block.Action; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.util.Vector; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilFirework; -import mineplex.core.common.util.UtilGear; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.recharge.Recharge; -import nautilus.game.arcade.kit.SmashPerk; - -public class PerkBlink extends SmashPerk -{ - private String _name = ""; - private double _range; - private long _recharge; - - public PerkBlink(String name, double range, long recharge) - { - super("name", new String[] - { - C.cYellow + "Right-Click" + C.cGray + " with Axe to " + C.cGreen + name - }); - - _name = name; - _range = range; - _recharge = recharge; - } - - @EventHandler - public void Blink(PlayerInteractEvent event) - { - if (event.isCancelled()) - return; - - if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) - return; - - if (UtilBlock.usable(event.getClickedBlock())) - return; - - if (!UtilGear.isAxe(event.getPlayer().getItemInHand())) - return; - - Player player = event.getPlayer(); - - if (!Kit.HasKit(player)) - return; - - if (isSuperActive(player)) - return; - - if (!Recharge.Instance.use(player, _name, _recharge, true, true)) - return; - - //Smoke Trail - Block lastSmoke = player.getLocation().getBlock(); - - double curRange = 0; - while (curRange <= _range) - { - Location newTarget = player.getLocation().add(new Vector(0,0.2,0)).add(player.getLocation().getDirection().multiply(curRange)); - - if (!UtilBlock.airFoliage(newTarget.getBlock()) || - !UtilBlock.airFoliage(newTarget.getBlock().getRelative(BlockFace.UP))) - break; - - //Progress Forwards - curRange += 0.2; - - //Smoke Trail - if (!lastSmoke.equals(newTarget.getBlock())) - { - lastSmoke.getWorld().playEffect(lastSmoke.getLocation(), Effect.SMOKE, 4); - } - - lastSmoke = newTarget.getBlock(); - } - - //Modify Range - curRange -= 0.4; - if (curRange < 0) - curRange = 0; - - //Destination - Location loc = player.getLocation().add(player.getLocation().getDirection().multiply(curRange).add(new Vector(0, 0.4, 0))); - - if (curRange > 0) - { - //Firework - UtilFirework.playFirework(player.getEyeLocation(), Type.BALL, Color.BLACK, false, false); - - player.playSound(player.getLocation(), Sound.ENDERMAN_TELEPORT, 1f, 1f); - player.teleport(loc); - player.playSound(player.getLocation(), Sound.ENDERMAN_TELEPORT, 1f, 1f); - - //Firework - UtilFirework.playFirework(player.getEyeLocation(), Type.BALL, Color.BLACK, false, false); - } - - - player.setFallDistance(0); - - //Inform - UtilPlayer.message(player, F.main("Game", "You used " + F.skill(_name) + ".")); - } -} - - diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBlizzard.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBlizzard.java index fb8b77d58..68a30fba8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBlizzard.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBlizzard.java @@ -9,18 +9,19 @@ import org.bukkit.entity.Projectile; import org.bukkit.entity.Snowball; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; -import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.util.Vector; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import nautilus.game.arcade.game.games.smash.TeamSuperSmash; import nautilus.game.arcade.kit.Perk; public class PerkBlizzard extends Perk @@ -93,32 +94,50 @@ public class PerkBlizzard extends Perk public void Snowball(CustomDamageEvent event) { if (event.GetCause() != DamageCause.PROJECTILE) + { return; + } Projectile proj = event.GetProjectile(); - if (proj == null) return; + if (proj == null) + { + return; + } if (!(proj instanceof Snowball)) + { return; + } - if (!_snowball.containsKey(proj)) + Player shooter = _snowball.get(proj); + if (shooter == null) + { return; + } LivingEntity damagee = event.GetDamageeEntity(); - if (damagee == null) return; + if (damagee == null) + { + return; + } event.SetCancelled("Blizzard"); + + if(TeamSuperSmash.getTeam(Manager, shooter, true).contains(damagee)) + { + return; + } UtilAction.velocity(damagee, proj.getVelocity().multiply(0.15).add(new Vector(0, 0.15, 0))); //Damage Event if (damagee instanceof Player) + { if (Recharge.Instance.use((Player)damagee, GetName(), 200, false, false)) { - Manager.GetDamage().NewDamageEvent(damagee, event.GetDamagerEntity(true), null, - DamageCause.CUSTOM, 1, false, true, false, - UtilEnt.getName(event.GetDamagerEntity(true)), GetName()); + Manager.GetDamage().NewDamageEvent(damagee, shooter, null, DamageCause.CUSTOM, 1, false, true, false, shooter.getName(), GetName()); } + } } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBoneRush.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBoneRush.java deleted file mode 100644 index bdef9e25b..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBoneRush.java +++ /dev/null @@ -1,198 +0,0 @@ -package nautilus.game.arcade.kit.perks; - -import java.util.Iterator; -import java.util.WeakHashMap; - -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.block.Block; -import org.bukkit.entity.Item; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.block.Action; -import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.util.Vector; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilTime; -import mineplex.core.projectile.IThrown; -import mineplex.core.projectile.ProjectileUser; -import mineplex.core.recharge.Recharge; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.game.games.smash.TeamSuperSmash; -import nautilus.game.arcade.kit.SmashPerk; - -public class PerkBoneRush extends SmashPerk implements IThrown -{ - private WeakHashMap<Player, Long> _active = new WeakHashMap<Player, Long>(); - - private double yLimit = 0.25; - - public PerkBoneRush() - { - super("Bone Rush", new String[] - { - C.cYellow + "Right-Click" + C.cGray + " with Spade to use " + C.cGreen + "Bone Rush", - C.cGray + "Crouch to avoid movement with " + C.cGreen + "Bone Rush" - }); - } - - @EventHandler - public void Skill(PlayerInteractEvent event) - { - if (event.isCancelled()) - return; - - if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) - return; - - if (UtilBlock.usable(event.getClickedBlock())) - return; - - if (event.getPlayer().getItemInHand() == null) - return; - - if (!event.getPlayer().getItemInHand().getType().toString().contains("_SPADE")) - return; - - Player player = event.getPlayer(); - - if (isSuperActive(player)) - return; - - if (!Kit.HasKit(player)) - return; - - if (!Recharge.Instance.use(player, GetName(), 10000, true, true)) - return; - - _active.put(player, System.currentTimeMillis()); - - UtilPlayer.message(player, F.main("Skill", "You used " + F.skill(GetName()) + ".")); - } - - @Override - public void addSuperCustom(Player player) - { - _active.put(player, System.currentTimeMillis()); - } - - @EventHandler - public void Update(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; - - Iterator<Player> playerIterator = _active.keySet().iterator(); - - while (playerIterator.hasNext()) - { - Player player = playerIterator.next(); - - if (!player.isValid() || (UtilTime.elapsed(_active.get(player), 1500) && !isSuperActive(player))) - { - playerIterator.remove(); - continue; - } - - //Sound - player.getWorld().playSound(player.getLocation(), Sound.SKELETON_HURT, 0.4f, (float)(Math.random() + 1)); - - //Velocity - Vector dir = player.getLocation().getDirection(); - double limit = isSuperActive(player) ? yLimit + 0.1 : yLimit; - if (dir.getY() > limit) - dir.setY(limit); - - //Player - if (!player.isSneaking()) - UtilAction.velocity(player, dir, 0.6, false, 0, 0.1, 0.3, false); - - //Bones - for (int i=0 ; i<6 ; i++) - { - Item bone = player.getWorld().dropItem(player.getLocation().add(Math.random()*5 - 2.5, Math.random()*3, Math.random()*5 - 2.5), new ItemStack(Material.BONE)); - UtilAction.velocity(bone, dir, 0.6 + 0.3 * Math.random(), false, 0, 0.1 + Math.random() * 0.05, 0.3, false); - Manager.GetProjectile().AddThrow(bone, player, this, 2000, true, true, true, true, 0.5f); - } - } - } - - @EventHandler - public void Knockback(CustomDamageEvent event) - { - if (event.GetReason() != null && event.GetReason().contains(GetName())) - event.AddKnockback(GetName(), 10); - - if (event.GetReason() != null && event.GetReason().contains("Bone Storm")) - event.AddKnockback(GetName(), 6); - } - - @Override - public void Collide(LivingEntity target, Block block, ProjectileUser data) - { - data.getThrown().remove(); - - if (target == null) - return; - - Player damager = (Player)data.getThrower(); - - double damage = 0.7; - String reason = GetName(); - - if (Manager.GetGame() instanceof TeamSuperSmash && target instanceof Player && data.getThrower() instanceof Player) - { - TeamSuperSmash smash = (TeamSuperSmash) Manager.GetGame(); - Player targetPlayer = (Player) target; - Player throwerPlayer = (Player) data.getThrower(); - - if(smash.GetTeam(targetPlayer).equals(smash.GetTeam(throwerPlayer))) - { - return; - } - } - - if (isSuperActive(damager)) - { - damage = 3; - reason = "Bone Storm"; - } - - //Damage Event - Manager.GetDamage().NewDamageEvent(target, data.getThrower(), null, - DamageCause.CUSTOM, damage, false, true, false, - UtilEnt.getName(data.getThrower()), reason); - - UtilAction.velocity(target, data.getThrown().getVelocity()); - } - - @Override - public void Idle(ProjectileUser data) - { - data.getThrown().remove(); - } - - @Override - public void Expire(ProjectileUser data) - { - data.getThrown().remove(); - } - - @EventHandler - public void Clean(PlayerDeathEvent event) - { - _active.remove(event.getEntity()); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDeathsGrasp.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDeathsGrasp.java index d2996ce62..3bcbf1db5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDeathsGrasp.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDeathsGrasp.java @@ -1,10 +1,12 @@ package nautilus.game.arcade.kit.perks; -import java.time.temporal.WeekFields; import java.util.HashMap; import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.UUID; -import org.bukkit.GameMode; import org.bukkit.Sound; import org.bukkit.entity.Arrow; import org.bukkit.entity.LivingEntity; @@ -14,7 +16,6 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.block.Action; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.util.Vector; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -25,21 +26,25 @@ import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import nautilus.game.arcade.game.games.smash.TeamSuperSmash; import nautilus.game.arcade.kit.Perk; public class PerkDeathsGrasp extends Perk { - private HashMap<LivingEntity, Long> _live = new HashMap<LivingEntity, Long>(); + private Map<UUID, Long> _live = new HashMap<>(); private HashMap<LivingEntity, Long> _weakness = new HashMap<LivingEntity, Long>(); + + private static final long LEAP_DURATION = 1000; + private static final long WEAKNESS_DURATION = 1000; public PerkDeathsGrasp() { @@ -76,7 +81,7 @@ public class PerkDeathsGrasp extends Perk UtilAction.velocity(player, player.getLocation().getDirection(), 1.4, false, 0, 0.2, 1.2, true); //Record - _live.put(player, System.currentTimeMillis()); + _live.put(player.getUniqueId(), System.currentTimeMillis()); //Inform UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + ".")); @@ -89,51 +94,60 @@ public class PerkDeathsGrasp extends Perk public void end(UpdateEvent event) { if (event.getType() != UpdateType.TICK) - return; - - //Collide - for (Player player : Manager.GetGame().GetPlayers(true)) - if (_live.containsKey(player)) - for (Player other : Manager.GetGame().GetPlayers(true)) - if (!Manager.isSpectator(other)) - if (!other.equals(player)) - if (UtilMath.offset(player, other) < 2) - { - collide(player, other); - _live.remove(player); - return; - } - - //Leap End - Iterator<LivingEntity> leapIter = _live.keySet().iterator(); - - while (leapIter.hasNext()) { - LivingEntity ent = leapIter.next(); + return; + } + + + //Leap End & Collide + for(Iterator<Entry<UUID, Long>> it = _live.entrySet().iterator(); it.hasNext();) + { + Entry<UUID, Long> e = it.next(); + Player player = UtilPlayer.searchExact(e.getKey()); + if(player == null) + { + it.remove(); + return; + } + + if (UtilEnt.isGrounded(player) && UtilTime.elapsed(e.getValue(), LEAP_DURATION)) + { + it.remove(); + return; + } - if (!UtilEnt.isGrounded(ent)) - continue; - - if (!UtilTime.elapsed(_live.get(ent), 1000)) - continue; - - leapIter.remove(); + List<Player> team = TeamSuperSmash.getTeam(Manager, player, true); + for (Player other : Manager.GetGame().GetPlayers(true)) + { + if(team.contains(other)) + { + continue; + } + if (UtilMath.offset(player, other) < 2) + { + collide(player, other); + it.remove(); + return; + } + } } //Weakness End - Iterator<LivingEntity> weaknessIter = _weakness.keySet().iterator(); - - while (weaknessIter.hasNext()) + for (Iterator<LivingEntity> it = _weakness.keySet().iterator(); it.hasNext();) { - LivingEntity ent = weaknessIter.next(); + LivingEntity ent = it.next(); if (!UtilEnt.isGrounded(ent)) + { continue; + } - if (!UtilTime.elapsed(_weakness.get(ent), 1000)) + if (!UtilTime.elapsed(_weakness.get(ent), WEAKNESS_DURATION)) + { continue; + } - weaknessIter.remove(); + it.remove(); } } @@ -183,10 +197,8 @@ public class PerkDeathsGrasp extends Perk event.AddMult(GetName(), GetName() + " Combo", 2, true); - UtilParticle.PlayParticle(ParticleType.RED_DUST, event.GetDamageeEntity().getLocation(), 0.5f, 0.5f, 0.5f, 0, 20, - ViewDist.MAX, UtilServer.getPlayers()); - UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, event.GetDamageeEntity().getLocation(), 0, 0, 0, 0, 1, - ViewDist.MAX, UtilServer.getPlayers()); + UtilParticle.PlayParticleToAll(ParticleType.RED_DUST, event.GetDamageeEntity().getLocation(), 0.5f, 0.5f, 0.5f, 0, 20, ViewDist.MAX); + UtilParticle.PlayParticleToAll(ParticleType.LARGE_EXPLODE, event.GetDamageeEntity().getLocation(), 0, 0, 0, 0, 1, ViewDist.MAX); damager.getWorld().playSound(damager.getLocation(), Sound.ZOMBIE_HURT, 1f, 2f); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkEarthquake.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkEarthquake.java deleted file mode 100644 index 36fc5f6ed..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkEarthquake.java +++ /dev/null @@ -1,107 +0,0 @@ -package nautilus.game.arcade.kit.perks; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; - -import org.bukkit.Effect; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.entity.Player; -import org.bukkit.entity.Zombie; -import org.bukkit.event.EventHandler; -import org.bukkit.event.entity.EntityTargetEvent; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; -import org.bukkit.util.Vector; - -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilTime; -import mineplex.core.recharge.Recharge; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import nautilus.game.arcade.kit.SmashPerk; -import nautilus.game.arcade.kit.perks.data.EarthquakeData; -import nautilus.game.arcade.kit.perks.data.NightLivingDeadData; - -public class PerkEarthquake extends SmashPerk -{ - private ArrayList<EarthquakeData> _night = new ArrayList<EarthquakeData>(); - - public PerkEarthquake() - { - super("Earthquake", new String[] - { - }, false); - } - - @Override - public void addSuperCustom(Player player) - { - _night.add(new EarthquakeData(player)); - } - - @EventHandler - public void update(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; - - Iterator<EarthquakeData> quakeIter = _night.iterator(); - - while (quakeIter.hasNext()) - { - EarthquakeData data = quakeIter.next(); - - //Expire - if (UtilTime.elapsed(data.Time, 16000)) - { - quakeIter.remove(); - continue; - } - - for (Player player : Manager.GetGame().GetPlayers(true)) - { - player.playSound(player.getLocation(), Sound.MINECART_BASE, 0.2f, 0.2f); - - if (player.equals(data.Player)) - continue; - - if (UtilEnt.isGrounded(player)) - { - //Damage Event - Manager.GetDamage().NewDamageEvent(player, data.Player, null, - DamageCause.CUSTOM, 1 + 2 * Math.random(), false, false, false, - player.getName(), GetName()); - - //Velocity - if (Recharge.Instance.use(player, GetName() + " Hit", 400, false, false)) - UtilAction.velocity(player, new Vector(Math.random() - 0.5, Math.random() * 0.2, Math.random() - 0.5), - Math.random() * 1 + 1, false, 0, 0.1 + Math.random() * 0.2, 2, true); - } - - //Effect - for (Block block : UtilBlock.getInRadius(player.getLocation(), 5).keySet()) - { - if (Math.random() < 0.98) - continue; - - if (!UtilBlock.solid(block)) - continue; - - if (!UtilBlock.airFoliage(block.getRelative(BlockFace.UP))) - continue; - - player.playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType()); - } - } - } - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFirefly.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFirefly.java deleted file mode 100644 index f16ef797c..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFirefly.java +++ /dev/null @@ -1,219 +0,0 @@ -package nautilus.game.arcade.kit.perks; - -import java.util.HashSet; -import java.util.Iterator; - -import org.bukkit.EntityEffect; -import org.bukkit.Sound; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.block.Action; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.util.Vector; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTime; -import mineplex.core.recharge.Recharge; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.game.Game; -import nautilus.game.arcade.game.games.smash.TeamSuperSmash; -import nautilus.game.arcade.kit.SmashPerk; -import nautilus.game.arcade.kit.perks.data.FireflyData; - -public class PerkFirefly extends SmashPerk -{ - private HashSet<FireflyData> _data = new HashSet<FireflyData>(); - private int _tick = 0; - - public PerkFirefly() - { - super("Firefly", new String[] - { - C.cYellow + "Right-Click" + C.cGray + " with Axe to use " + C.cGreen + "Firefly" - }); - } - - @EventHandler - public void Skill(PlayerInteractEvent event) - { - if (event.isCancelled()) - return; - - if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) - return; - - if (UtilBlock.usable(event.getClickedBlock())) - return; - - if (event.getPlayer().getItemInHand() == null) - return; - - if (!event.getPlayer().getItemInHand().getType().toString().contains("_AXE")) - return; - - Player player = event.getPlayer(); - - if (isSuperActive(event.getPlayer())) - return; - - if (!Kit.HasKit(player)) - return; - - if (!Recharge.Instance.use(player, GetName(), 12000, true, true)) - return; - - _data.add(new FireflyData(player)); - - UtilPlayer.message(player, F.main("Skill", "You used " + F.skill(GetName()) + ".")); - } - - @Override - public void addSuperCustom(Player player) - { - _data.add(new FireflyData(player)); - } - - @EventHandler - public void Update(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; - - _tick++; - - Iterator<FireflyData> dataIterator = _data.iterator(); - - while (dataIterator.hasNext()) - { - FireflyData data = dataIterator.next(); - - boolean superActive = isSuperActive(data.Player); - - //Teleport - if (!UtilTime.elapsed(data.Time, 1500) && !superActive) - { - UtilAction.zeroVelocity(data.Player); - data.Player.getWorld().playSound(data.Player.getLocation(), Sound.EXPLODE, 0.2f, 0.6f); - data.Location = data.Player.getLocation(); - - //Sound and Effect - UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, data.Player.getLocation().add(0, 1, 0), 0.6f, 0.6f, 0.6f, 0, 10, ViewDist.LONG, UtilServer.getPlayers()); - - float progress = (float)(System.currentTimeMillis()-data.Time)/1500f; - - data.Player.getWorld().playSound(data.Player.getLocation(), Sound.BLAZE_BREATH, 0.5f, 1f + progress); - } - //Velocity - else if (!UtilTime.elapsed(data.Time, 2750) || superActive) - { - UtilAction.velocity(data.Player, data.Player.getLocation().getDirection().multiply(superActive ? 0.9 : 0.7).add(new Vector(0,0.15,0))); - data.Player.getWorld().playSound(data.Player.getLocation(), Sound.EXPLODE, 0.6f, 1.2f); - - //Sound and Effect - if (!isSuperActive(data.Player)) - { - UtilParticle.PlayParticle(ParticleType.FLAME, data.Player.getLocation().add(0, 1, 0), 0.6f, 0.6f, 0.6f, 0, 40, ViewDist.LONG, UtilServer.getPlayers()); - - data.Player.getWorld().playSound(data.Player.getLocation(), Sound.EXPLODE, 0.5f, 1.25f); - } - else - { - UtilParticle.PlayParticle(ParticleType.FLAME, data.Player.getLocation().add(0, 1, 0), 1f, 1f, 1f, 0, 60, ViewDist.LONG, UtilServer.getPlayers()); - UtilParticle.PlayParticle(ParticleType.LAVA, data.Player.getLocation().add(0, 1, 0), 1f, 1f, 1f, 0, 40, ViewDist.LONG, UtilServer.getPlayers()); - - data.Player.getWorld().playSound(data.Player.getLocation(), Sound.EXPLODE, 0.75f, 0.75f); - } - - for (Player other : UtilPlayer.getNearby(data.Player.getLocation(), isSuperActive(data.Player) ? 7 : 4)) - { - if (other.equals(data.Player)) - continue; - - if (!Manager.GetGame().IsAlive(other)) - continue; - - other.playEffect(EntityEffect.HURT); - - if (_tick % 12 == 0) - { - if (Recharge.Instance.use(other, GetName() + " hit by " + data.Player.getName(), 2000, false, false)) - { - //Damage Event - Manager.GetDamage().NewDamageEvent(other, data.Player, null, - DamageCause.CUSTOM, 10, true, true, false, - data.Player.getName(), isSuperActive(data.Player) ? "Phoenix" : GetName()); - - UtilPlayer.message(other, F.main("Game", F.elem(Manager.GetColor(data.Player) + data.Player.getName()) + " hit you with " + F.elem(GetName()) + ".")); - } - } - } - } - else - { - dataIterator.remove(); - } - } - } - - @EventHandler - public void FireflyDamage(CustomDamageEvent event) - { - if (event.GetDamage() <= 4) - return; - - if (!(event.GetDamagerEntity(true) instanceof Player)) - { - return; - } - - Iterator<FireflyData> dataIterator = _data.iterator(); - - while (dataIterator.hasNext()) - { - FireflyData data = dataIterator.next(); - - if (!data.Player.equals(event.GetDamageeEntity())) - continue; - - if (!UtilTime.elapsed(data.Time, 1250) && !isSuperActive(data.Player))// && event.GetCause() == DamageCause.PROJECTILE) - { - Game game = Manager.GetGame(); - - if (game instanceof TeamSuperSmash) - { - if (game.GetTeam(data.Player).equals(game.GetTeam(event.GetDamagerPlayer(true)))) - { - event.SetCancelled("Team Damage"); - return; - } - } - - dataIterator.remove(); - } - else - { - event.SetCancelled("Firefly Immunity"); - } - } - } - - @EventHandler - public void Knockback(CustomDamageEvent event) - { - if (event.GetReason() == null || !event.GetReason().contains(GetName())) - return; - - event.AddKnockback(GetName(), 2); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFleshArrow.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFleshArrow.java deleted file mode 100644 index e0eb24ebd..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFleshArrow.java +++ /dev/null @@ -1,112 +0,0 @@ -package nautilus.game.arcade.kit.perks; - -import java.util.HashSet; -import java.util.Iterator; - -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.Entity; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.entity.Projectile; -import org.bukkit.event.EventHandler; -import org.bukkit.event.block.Action; -import org.bukkit.event.entity.ProjectileHitEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.util.Vector; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.recharge.Recharge; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.kit.SmashPerk; - -public class PerkFleshArrow extends SmashPerk -{ - private HashSet<Entity> _arrows = new HashSet<Entity>(); - - public PerkFleshArrow() - { - super("Flesh Arrow", new String[] - { - C.cYellow + "Left-Click" + C.cGray + " with Bow to " + C.cGreen + "Flesh Arrow" - }); - } - - @EventHandler - public void fire(PlayerInteractEvent event) - { - if (event.getAction() != Action.LEFT_CLICK_AIR && event.getAction() != Action.LEFT_CLICK_BLOCK) - return; - - if (event.getPlayer().getItemInHand() == null) - return; - - if (event.getPlayer().getItemInHand().getType() != Material.BOW) - return; - - Player player = event.getPlayer(); - - if (!Kit.HasKit(player)) - return; - - if (!Recharge.Instance.use(player, GetName(), 8000, true, true)) - return; - - //Arrow - Arrow arrow = player.launchProjectile(Arrow.class); - arrow.setVelocity(player.getLocation().getDirection().multiply(3)); - _arrows.add(arrow); - - //Inform - UtilPlayer.message(player, F.main("Game", "You fired " + F.skill(GetName()) + ".")); - } - - @EventHandler - public void hit(ProjectileHitEvent event) - { - if (!_arrows.remove(event.getEntity())) - return; - - System.out.println("Flesh Arrow A"); - - event.getEntity().remove(); - } - - @EventHandler - public void damage(CustomDamageEvent event) - { - if (event.GetProjectile() == null) - return; - - if (!_arrows.contains(event.GetProjectile())) - return; - - LivingEntity ent = event.GetDamageeEntity(); - - Manager.GetCondition().Factory().Slow(GetName(), ent, event.GetDamagerEntity(true), 4, 3, false, false, false, false); - - UtilAction.velocity(ent, new Vector(0,-0.5,0)); - } - - @EventHandler - public void clean(UpdateEvent event) - { - if (event.getType() != UpdateType.SEC) - return; - - for (Iterator<Entity> arrowIterator = _arrows.iterator(); arrowIterator.hasNext();) - { - Entity arrow = arrowIterator.next(); - - if (!arrow.isValid()) - arrowIterator.remove(); - } - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFletcher.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFletcher.java index e0bd889de..3867996c0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFletcher.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFletcher.java @@ -57,7 +57,7 @@ public class PerkFletcher extends Perk public PerkFletcher(int time, int max, boolean remove, int slot, boolean instant) { - this(time, max, remove, slot, instant, "Fletcted Arrow"); + this(time, max, remove, slot, instant, "Fletched Arrow"); } public PerkFletcher(int time, int max, boolean remove, int slot, boolean instant, String name) @@ -162,7 +162,13 @@ public class PerkFletcher extends Perk } else { - cur.getInventory().setItem(_slot, ItemStackFactory.Instance.CreateStack(262, (byte)0, 1, F.item(_name))); + int amount = 1; + ItemStack old = cur.getInventory().getItem(_slot); + if(old != null && old.getType() == Material.ARROW) + { + amount += old.getAmount(); + } + cur.getInventory().setItem(_slot, ItemStackFactory.Instance.CreateStack(262, (byte)0, amount, F.item(_name))); } cur.playSound(cur.getLocation(), Sound.ITEM_PICKUP, 2f, 1f); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkHammerThrow.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkHammerThrow.java index 10c87bc33..f8ebc7caa 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkHammerThrow.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkHammerThrow.java @@ -87,7 +87,7 @@ public class PerkHammerThrow extends Perk implements IThrown @EventHandler public void Pickup(PlayerPickupItemEvent event) { - if (!_thrown.containsKey(event.getItem())) + if (!event.getPlayer().equals(_thrown.get(event.getItem()))) return; event.setCancelled(true); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkInfernalHorror.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkInfernalHorror.java deleted file mode 100644 index 5e67dbcec..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkInfernalHorror.java +++ /dev/null @@ -1,189 +0,0 @@ -package nautilus.game.arcade.kit.perks; - -import java.util.HashSet; - -import org.bukkit.Sound; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.events.PlayerGameRespawnEvent; -import nautilus.game.arcade.kit.SmashPerk; - -public class PerkInfernalHorror extends SmashPerk -{ - public HashSet<Player> _active = new HashSet<Player>(); - - public PerkInfernalHorror() - { - super("Infernal Horror", new String[] - { - C.cGray + "Tranform into " + F.skill("Infernal Horror") + " at 100% Rage.", - C.cGray + "Charge your Rage by dealing/taking damage." - }); - } - - @Override - public void addSuperCustom(Player player) - { - _active.add(player); - player.setExp(0.9999f); - } - - @EventHandler - public void energyUpdate(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; - - for (Player player : Manager.GetGame().GetPlayers(true)) - { - if (!Kit.HasKit(player)) - continue; - - player.setExp((float) Math.max(0, player.getExp()-0.001)); - } - } - - @EventHandler(priority = EventPriority.HIGHEST) - public void damagerEnergy(CustomDamageEvent event) - { - if (event.IsCancelled()) - return; - - if (event.GetCause() == DamageCause.FIRE_TICK) - return; - - Player damager = event.GetDamagerPlayer(true); - if (damager == null) return; - - if (!Kit.HasKit(damager)) - return; - - damager.setExp(Math.min(0.999f, damager.getExp() + (float)(event.GetDamage()/60d))); - - activeCheck(damager); - } - - @EventHandler(priority = EventPriority.MONITOR) - public void damageeEnergy(CustomDamageEvent event) - { - if (event.IsCancelled()) - return; - - if (event.GetCause() == DamageCause.FIRE_TICK) - return; - - if (event.GetCause() == DamageCause.VOID) - return; - - - Player damagee = event.GetDamageePlayer(); - if (damagee == null) return; - - if (!Kit.HasKit(damagee)) - return; - - damagee.setExp(Math.min(0.999f, damagee.getExp() + (float)(event.GetDamage()/60d))); - - activeCheck(damagee); - } - - @EventHandler(priority = EventPriority.HIGH) - public void damageBoost(CustomDamageEvent event) - { - if (event.IsCancelled()) - return; - - if (event.GetCause() != DamageCause.ENTITY_ATTACK) - return; - - Player damager = event.GetDamagerPlayer(false); - if (damager == null) return; - - if (!Kit.HasKit(damager)) - return; - - if (!_active.contains(damager)) - return; - - event.AddMod(damager.getName(), GetName(), 1, false); - } - - @EventHandler - public void check(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; - - for (Player player : Manager.GetGame().GetPlayers(true)) - if (Kit.HasKit(player)) - activeCheck(player); - } - - public void activeCheck(Player player) - { - //Active - if (_active.contains(player)) - { - if (!isSuperActive(player)) - player.setExp((float) Math.max(0, player.getExp()-0.005)); - - if (player.getExp() > 0) - { - //Condition - Manager.GetCondition().Factory().Speed(GetName(), player, player, 0.9, 1, false, false, false); - - //Particles - UtilParticle.PlayParticle(ParticleType.FLAME, player.getLocation().add(0, 1, 0), 0.25f, 0.25f, 0.25f, 0, 1, - ViewDist.LONG, UtilServer.getPlayers()); - - if (Math.random() > 0.9) - UtilParticle.PlayParticle(ParticleType.LAVA, player.getLocation().add(0, 1, 0), 0.25f, 0.25f, 0.25f, 0, 1, - ViewDist.LONG, UtilServer.getPlayers()); - } - else - { - _active.remove(player); - - //Inform - UtilPlayer.message(player, F.main("Skill", "You are no longer " + F.skill("Infernal Horror") + ".")); - } - } - //Not Active - else if (player.getExp() > 0.99) - { - _active.add(player); - - //Sound - player.getWorld().playSound(player.getLocation(), Sound.FIRE, 2f, 1f); - player.getWorld().playSound(player.getLocation(), Sound.FIRE, 2f, 1f); - - //Inform - UtilPlayer.message(player, F.main("Skill", "You transformed into " + F.skill("Infernal Horror") + ".")); - } - } - - @EventHandler - public void clean(PlayerGameRespawnEvent event) - { - event.GetPlayer().setExp(0f); - _active.remove(event.GetPlayer()); - } - - public boolean isActive(Player player) - { - return _active.contains(player); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkInferno.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkInferno.java deleted file mode 100644 index afba15ebd..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkInferno.java +++ /dev/null @@ -1,142 +0,0 @@ -package nautilus.game.arcade.kit.perks; - -import java.util.HashMap; - -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.Item; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.block.Action; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.util.Vector; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.game.games.smash.TeamSuperSmash; -import nautilus.game.arcade.kit.SmashPerk; - -public class PerkInferno extends SmashPerk -{ - private HashMap<Player, Long> _active = new HashMap<Player, Long>(); - - public PerkInferno() - { - super("Inferno", new String[] - { - C.cYellow + "Hold Block" + C.cGray + " to use " + C.cGreen + "Inferno" - }); - } - - @EventHandler - public void EnergyUpdate(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; - - for (Player player : Manager.GetGame().GetPlayers(true)) - { - if (!Kit.HasKit(player)) - continue; - - if (!player.isBlocking()) - player.setExp((float) Math.min(0.999, player.getExp()+0.025)); - } - } - - @EventHandler - public void Activate(PlayerInteractEvent event) - { - if (event.isCancelled()) - return; - - if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) - return; - - if (UtilBlock.usable(event.getClickedBlock())) - return; - - if (!event.getPlayer().getItemInHand().getType().toString().contains("_SWORD")) - return; - - Player player = event.getPlayer(); - - if (isSuperActive(player)) - return; - - if (!Kit.HasKit(player)) - return; - - _active.put(player, System.currentTimeMillis()); - - UtilPlayer.message(player, F.main("Skill", "You used " + F.skill("Inferno") + ".")); - } - - @EventHandler - public void Update(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; - - for (Player cur : UtilServer.getPlayers()) - { - if (!_active.containsKey(cur)) - continue; - - if (!cur.isBlocking()) - { - _active.remove(cur); - continue; - } - - cur.setExp(cur.getExp()-0.035f); - - if (cur.getExp() <= 0) - { - _active.remove(cur); - continue; - } - - //Fire - Item fire = cur.getWorld().dropItem(cur.getEyeLocation(), ItemStackFactory.Instance.CreateStack(Material.BLAZE_POWDER)); - Manager.GetFire().Add(fire, cur, 0.7, 0, 0.5, 1.25, "Inferno", false); - - fire.teleport(cur.getEyeLocation()); - double x = 0.07 - (UtilMath.r(14)/100d); - double y = 0.07 - (UtilMath.r(14)/100d); - double z = 0.07 - (UtilMath.r(14)/100d); - fire.setVelocity(cur.getLocation().getDirection().add(new Vector(x,y,z)).multiply(1.6)); - - //Effect - cur.getWorld().playSound(cur.getLocation(), Sound.GHAST_FIREBALL, 0.1f, 1f); - } - } - - @EventHandler - public void onCustomDamage(CustomDamageEvent event) - { - if (Manager.GetGame() instanceof TeamSuperSmash) - { - TeamSuperSmash smash = (TeamSuperSmash) Manager.GetGame(); - - if (event.GetDamagerPlayer(true) == null) - { - return; - } - - if (smash.GetTeam(event.GetDamagerPlayer(true)).equals(smash.GetTeam(event.GetDamageePlayer()))) - { - event.GetDamageeEntity().setFireTicks(0); - event.SetCancelled("Team Damage"); - } - } - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkIronHook.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkIronHook.java index d938dd3d9..1f9f786f4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkIronHook.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkIronHook.java @@ -6,7 +6,6 @@ import org.bukkit.entity.Item; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.block.Action; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.player.PlayerInteractEvent; @@ -15,6 +14,9 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilPlayer; import mineplex.core.itemstack.ItemStackFactory; @@ -23,99 +25,114 @@ import mineplex.core.projectile.ProjectileUser; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; +import nautilus.game.arcade.game.games.smash.TeamSuperSmash; import nautilus.game.arcade.kit.Perk; public class PerkIronHook extends Perk implements IThrown { - public PerkIronHook() + + private static final long COOLDOWN = 8000; + private static final int DAMAGE = 4; + + public PerkIronHook() { - super("Iron Hook", new String[] - { - C.cYellow + "Right-Click" + C.cGray + " with Pickaxe to " + C.cGreen + "Iron Hook" - }); + super("Iron Hook", new String[] { C.cYellow + "Right-Click" + C.cGray + " with Pickaxe to " + C.cGreen + "Iron Hook" }); } @EventHandler public void Activate(PlayerInteractEvent event) { if (event.isCancelled()) + { return; + } - if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) + if (!UtilEvent.isAction(event, ActionType.R)) + { return; + } if (UtilBlock.usable(event.getClickedBlock())) + { return; - - if (!event.getPlayer().getItemInHand().getType().toString().contains("_PICKAXE")) - return; + } Player player = event.getPlayer(); - if (!Kit.HasKit(player)) + if (!UtilItem.isPickaxe(player.getItemInHand())) + { return; + } - if (!Recharge.Instance.use(player, GetName(), 8000, true, true)) + if (!hasPerk(player)) + { return; + } - //Action + if (!Recharge.Instance.use(player, GetName(), COOLDOWN, true, true)) + { + return; + } + + // Action Item item = player.getWorld().dropItem(player.getEyeLocation().add(player.getLocation().getDirection()), ItemStackFactory.Instance.CreateStack(131)); - UtilAction.velocity(item, player.getLocation().getDirection(), - 1.8, false, 0, 0.2, 10, false); + UtilAction.velocity(item, player.getLocation().getDirection(), 1.8, false, 0, 0.2, 10, false); - Manager.GetProjectile().AddThrow(item, player, this, -1, true, true, true, true, - Sound.FIRE_IGNITE, 1.4f, 0.8f, ParticleType.CRIT, null, 0, UpdateType.TICK, 0.6f); + Manager.GetProjectile().AddThrow(item, player, this, -1, true, true, true, true, Sound.FIRE_IGNITE, 1.4f, 0.8f, ParticleType.CRIT, null, 0, UpdateType.TICK, 0.6f); - //Inform + // Inform UtilPlayer.message(player, F.main("Skill", "You used " + F.skill(GetName()) + ".")); - //Effect + // Effect item.getWorld().playSound(item.getLocation(), Sound.IRONGOLEM_THROW, 2f, 0.8f); } @Override - public void Collide(LivingEntity target, Block block, ProjectileUser data) - { - //Remove + public void Collide(LivingEntity target, Block block, ProjectileUser data) + { + // Remove double velocity = data.getThrown().getVelocity().length(); data.getThrown().remove(); if (!(data.getThrower() instanceof Player)) + { return; - - Player player = (Player)data.getThrower(); + } + + Player player = (Player) data.getThrower(); if (target == null) + { return; + } + + if(TeamSuperSmash.getTeam(Manager, player, true).contains(target)) + { + return; + } + + // Pull + UtilAction.velocity(target, UtilAlg.getTrajectory(target.getLocation(), player.getLocation()), 2, false, 0, 0.8, 1.5, true); - //Pull - UtilAction.velocity(target, - UtilAlg.getTrajectory(target.getLocation(), player.getLocation()), - 2, false, 0, 0.8, 1.5, true); - - //Condition + // Condition Manager.GetCondition().Factory().Falling(GetName(), target, player, 10, false, true); - //Damage Event - Manager.GetDamage().NewDamageEvent(target, player, null, - DamageCause.CUSTOM, velocity * 4, false, true, false, - player.getName(), GetName()); + // Damage Event + Manager.GetDamage().NewDamageEvent(target, player, null, DamageCause.CUSTOM, velocity * DAMAGE, false, true, false, player.getName(), GetName()); - //Inform + // Inform UtilPlayer.message(target, F.main("Skill", F.name(player.getName()) + " hit you with " + F.skill(GetName()) + ".")); } @Override - public void Idle(ProjectileUser data) + public void Idle(ProjectileUser data) { - //Remove data.getThrown().remove(); } @Override - public void Expire(ProjectileUser data) + public void Expire(ProjectileUser data) { - //Remove data.getThrown().remove(); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkLazer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkLazer.java index 34fdec4b0..3d416b319 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkLazer.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkLazer.java @@ -2,17 +2,17 @@ package nautilus.game.arcade.kit.perks; import java.util.HashSet; import java.util.Iterator; +import java.util.Set; +import java.util.UUID; import org.bukkit.Color; import org.bukkit.DyeColor; -import org.bukkit.FireworkEffect; +import org.bukkit.FireworkEffect.Type; import org.bukkit.Location; import org.bukkit.Sound; -import org.bukkit.FireworkEffect.Type; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.block.Action; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.player.PlayerInteractEvent; @@ -20,13 +20,16 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilFirework; -import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.particles.effects.LineParticle; +import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguiseSheep; import mineplex.core.recharge.Recharge; @@ -37,17 +40,23 @@ import nautilus.game.arcade.kit.Perk; public class PerkLazer extends Perk { + + private static final float MAX_CHARGE = 0.99F; + private static final float CHARGE_PER_TICK = 0.035F; + private static final float INCREMENTATION = 0.2F; + private static final float HIT_BOX_RADIUS = 2.5F; + private static final int DAMAGE_RADIUS = 3; + private static final int DAMAGE = 7; + private static final int KNOCKBACK_MAGNITUDE = 3; + private double _range; private long _recharge; - - private HashSet<Player> _active = new HashSet<Player>(); - public PerkLazer(double range, long recharge) + private Set<UUID> _active = new HashSet<>(); + + public PerkLazer(double range, long recharge) { - super("Static Lazer", new String[] - { - C.cYellow + "Hold Block" + C.cGray + " with Sword to use " + C.cGreen + "Static Lazer" - }); + super("Static Laser", new String[] { C.cYellow + "Hold Block" + C.cGray + " with Sword to use " + C.cGreen + "Static Laser" }); _range = range; _recharge = recharge; @@ -57,66 +66,88 @@ public class PerkLazer extends Perk public void skill(PlayerInteractEvent event) { if (event.isCancelled()) + { return; + } - if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) + if (!UtilEvent.isAction(event, ActionType.R)) + { return; + } if (UtilBlock.usable(event.getClickedBlock())) + { return; - - if (event.getPlayer().getItemInHand() == null) - return; - - if (!event.getPlayer().getItemInHand().getType().toString().contains("_SWORD")) - return; + } Player player = event.getPlayer(); - if (!Kit.HasKit(player)) + if (!UtilItem.isSword(player.getItemInHand())) + { return; - + } + + if (!hasPerk(player)) + { + return; + } + if (!Recharge.Instance.use(player, GetName(), _recharge, true, true)) + { return; - - _active.add(player); + } + + _active.add(player.getUniqueId()); } - + @EventHandler public void chargeFire(UpdateEvent event) { if (event.getType() != UpdateType.TICK) + { return; + } - Iterator<Player> playerIterator = _active.iterator(); - + Iterator<UUID> playerIterator = _active.iterator(); + while (playerIterator.hasNext()) { - Player player = playerIterator.next(); - + UUID uuid = playerIterator.next(); + Player player = UtilPlayer.searchExact(uuid); + + if (player == null) + { + playerIterator.remove(); + } + if (player.isBlocking()) { - player.setExp(Math.min(0.999f, player.getExp() + 0.035f)); - + player.setExp(Math.min(MAX_CHARGE, player.getExp() + CHARGE_PER_TICK)); + player.getWorld().playSound(player.getLocation(), Sound.FIZZ, 0.25f + player.getExp(), 0.75f + player.getExp()); - - //Wool - DisguiseBase disguise = Manager.GetDisguise().getDisguise(player); + + // Wool + DisguiseBase disguise = Manager.GetDisguise().getActiveDisguise(player); if (disguise != null && disguise instanceof DisguiseSheep) { - DisguiseSheep sheep = (DisguiseSheep)disguise; + DisguiseSheep sheep = (DisguiseSheep) disguise; + if (Math.random() > 0.5) + { sheep.setColor(DyeColor.YELLOW); + } else + { sheep.setColor(DyeColor.BLACK); - + } + sheep.setSheared(false); - + sheep.UpdateDataWatcher(); Manager.GetDisguise().updateDisguise(disguise); } - - if (player.getExp() >= 0.999f) + + if (player.getExp() >= MAX_CHARGE) { playerIterator.remove(); fire(player); @@ -129,106 +160,83 @@ public class PerkLazer extends Perk } } } - + public void fire(Player player) - { - if (player.getExp() <= 0.2f) + { + if (player.getExp() <= 0.2) { setWoolColor(player, DyeColor.WHITE); player.setExp(0f); return; } - - double curRange = 0; - while (curRange <= _range * player.getExp()) + + LineParticle lineParticle = new LineParticle(player.getEyeLocation(), player.getLocation().getDirection(), INCREMENTATION, _range * player.getExp(), null, ParticleType.FIREWORKS_SPARK, + UtilServer.getPlayers()); + + particleLoop: while (!lineParticle.update()) { - Location newTarget = player.getEyeLocation().add(player.getLocation().getDirection().multiply(curRange)); - - //Hit Player - boolean hitPlayer = false; - for (Player other : Manager.GetGame().GetPlayers(true)) + for (Player other : UtilPlayer.getNearby(lineParticle.getLastLocation(), HIT_BOX_RADIUS)) { - if (other.equals(player)) - continue; - - if (UtilMath.offset(newTarget, other.getLocation().add(0, 1, 0)) < 2.5) + if (player.equals(other)) { - hitPlayer = true; - break; + continue; } - } - if (hitPlayer) - break; - - //Hit Block - if (!UtilBlock.airFoliage(newTarget.getBlock())) - { - break; - } - //Progress Forwards - curRange += 0.2; - - //Smoke Trail - UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, newTarget, 0, 0, 0, 0, 1, - ViewDist.MAX, UtilServer.getPlayers()); + break particleLoop; + } } - //Destination - Location target = player.getLocation().add(player.getLocation().getDirection().multiply(curRange)); - - UtilParticle.PlayParticle(ParticleType.EXPLODE, target, 0, 0, 0, 0, 1, - ViewDist.MAX, UtilServer.getPlayers()); - - //Firework - UtilFirework.playFirework(player.getLocation().add(player.getLocation().getDirection().multiply(Math.max(0, curRange - 0.6))), Type.BURST, Color.YELLOW, false, false); - - for (LivingEntity other : UtilEnt.getInRadius(target, 5).keySet()) + Location target = lineParticle.getDestination(); + + UtilParticle.PlayParticle(ParticleType.EXPLODE, target, 0, 0, 0, 0, 1, ViewDist.MAX, UtilServer.getPlayers()); + + // Firework + UtilFirework.playFirework(target, Type.BURST, Color.YELLOW, false, false); + + for (LivingEntity other : UtilEnt.getInRadius(target, DAMAGE_RADIUS).keySet()) { if (other.equals(player)) - continue; - - //Do from center - if (UtilMath.offset(target, other.getLocation().add(0, 1, 0)) < 3) { - //Damage Event - Manager.GetDamage().NewDamageEvent(other, player, null, - DamageCause.CUSTOM, player.getExp() * 7, true, true, false, - player.getName(), GetName()); + continue; } + + // Damage Event + Manager.GetDamage().NewDamageEvent(other, player, null, DamageCause.CUSTOM, player.getExp() * DAMAGE, true, true, false, player.getName(), GetName()); } - - //Inform + + // Inform UtilPlayer.message(player, F.main("Game", "You fired " + F.skill(GetName()) + ".")); - - //Sound + + // Sound player.getWorld().playSound(player.getEyeLocation(), Sound.ZOMBIE_REMEDY, 0.5f + player.getExp(), 1.75f - player.getExp()); player.getWorld().playSound(player.getLocation(), Sound.SHEEP_IDLE, 2f, 1.5f); - - //Wool + + // Wool setWoolColor(player, DyeColor.WHITE); player.setExp(0f); } - + @EventHandler public void knockback(CustomDamageEvent event) { if (event.GetReason() == null || !event.GetReason().contains(GetName())) + { return; + } - event.AddKnockback(GetName(), 3); + event.AddKnockback(GetName(), KNOCKBACK_MAGNITUDE); } - - + public void setWoolColor(Player player, DyeColor color) { - DisguiseBase disguise = Manager.GetDisguise().getDisguise(player); + DisguiseBase disguise = Manager.GetDisguise().getActiveDisguise(player); + if (disguise != null && disguise instanceof DisguiseSheep) { - DisguiseSheep sheep = (DisguiseSheep)disguise; + DisguiseSheep sheep = (DisguiseSheep) disguise; sheep.setSheared(false); sheep.setColor(color); - + sheep.UpdateDataWatcher(); Manager.GetDisguise().updateDisguise(disguise); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkMagmaBoost.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkMagmaBoost.java deleted file mode 100644 index 0b8edda31..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkMagmaBoost.java +++ /dev/null @@ -1,144 +0,0 @@ -package nautilus.game.arcade.kit.perks; - -import java.util.HashMap; - -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.disguise.disguises.DisguiseMagmaCube; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.kit.Perk; - -public class PerkMagmaBoost extends Perk -{ - private HashMap<Player, Integer> _kills = new HashMap<Player, Integer>(); - - public PerkMagmaBoost() - { - super("Fuel the Fire", new String[] - { - C.cGray + "Kills give +1 Damage, -15% Knockback Taken and +1 Size.", - C.cGray + "Kill bonuses can stack 3 times, and reset on death.", - }); - } - - @EventHandler - public void Kill(CombatDeathEvent event) - { - Player killed = (Player)event.GetEvent().getEntity(); - - _kills.remove(killed); - - if (event.GetLog().GetKiller() == null) - return; - - Player killer = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName()); - - if (killer == null || killer.equals(killed) || !Kit.HasKit(killer)) - return; - - DisguiseMagmaCube slime = (DisguiseMagmaCube)Manager.GetDisguise().getDisguise(killer); - if (slime == null) - return; - - int size = 1; - if (_kills.containsKey(killer)) - size += _kills.get(killer); - - size = Math.min(3, size); - - _kills.put(killer, size); - - slime.SetSize(size + 1); - Manager.GetDisguise().updateDisguise(slime); - - killer.setExp(0.99f * (size/3f)); - } - - @EventHandler(priority = EventPriority.HIGHEST) - public void SizeDamage(CustomDamageEvent event) - { - if (event.IsCancelled()) - return; - - if (event.GetCause() != DamageCause.ENTITY_ATTACK) - return; - - Player damager = event.GetDamagerPlayer(false); - if (damager == null) return; - - if (!Kit.HasKit(damager)) - return; - - if (!_kills.containsKey(damager)) - return; - - int bonus = _kills.get(damager); - - event.AddMod(damager.getName(), GetName(), bonus, false); - } - - @EventHandler(priority = EventPriority.HIGHEST) - public void SizeKnockback(CustomDamageEvent event) - { - if (event.IsCancelled()) - return; - - if (event.GetCause() != DamageCause.ENTITY_ATTACK) - return; - - Player damagee = event.GetDamageePlayer(); - if (damagee == null) return; - - if (!Kit.HasKit(damagee)) - return; - - if (!_kills.containsKey(damagee)) - return; - - int bonus = _kills.get(damagee); - - event.AddKnockback(GetName(), bonus*0.15d); - } - - @EventHandler - public void EnergyUpdate(UpdateEvent event) - { - if (event.getType() != UpdateType.SEC && event.getType() != UpdateType.FAST && event.getType() != UpdateType.FASTER && event.getType() != UpdateType.FASTEST) - return; - - for (Player player : UtilServer.getPlayers()) - { - if (!Kit.HasKit(player)) - continue; - - float size = 0; - if (_kills.containsKey(player)) - size += _kills.get(player); - - if (size == 0 && event.getType() == UpdateType.SEC) - UtilParticle.PlayParticle(ParticleType.LAVA, player.getLocation().add(0,0.4,0), 0.15f + 0.15f * size, 0.15f + 0.15f * size, 0.15f + 0.15f * size, 0, 1, - ViewDist.LONG, UtilServer.getPlayers()); - else if (size == 1 && event.getType() == UpdateType.FAST) - UtilParticle.PlayParticle(ParticleType.LAVA, player.getLocation().add(0,0.4,0), 0.15f + 0.15f * size, 0.15f + 0.15f * size, 0.15f + 0.15f * size, 0, 1, - ViewDist.LONG, UtilServer.getPlayers()); - else if (size == 2 && event.getType() == UpdateType.FASTER) - UtilParticle.PlayParticle(ParticleType.LAVA, player.getLocation().add(0,0.4,0), 0.15f + 0.15f * size, 0.15f + 0.15f * size, 0.15f + 0.15f * size, 0, 1, - ViewDist.LONG, UtilServer.getPlayers()); - else if (size == 3 && event.getType() == UpdateType.FASTEST) - UtilParticle.PlayParticle(ParticleType.LAVA, player.getLocation().add(0,0.4,0), 0.15f + 0.15f * size, 0.15f + 0.15f * size, 0.15f + 0.15f * size, 0, 1, - ViewDist.LONG, UtilServer.getPlayers()); - } - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkMeteorShower.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkMeteorShower.java deleted file mode 100644 index 29fa5cda1..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkMeteorShower.java +++ /dev/null @@ -1,50 +0,0 @@ -package nautilus.game.arcade.kit.perks; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; - -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; - -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import nautilus.game.arcade.kit.SmashPerk; -import nautilus.game.arcade.kit.perks.data.MeteorShowerData; - -public class PerkMeteorShower extends SmashPerk -{ - private ArrayList<MeteorShowerData> _meteors = new ArrayList<MeteorShowerData>(); - - public PerkMeteorShower() - { - super("Meteor Shower", new String[] - { - }, false); - } - - @Override - public void addSuperCustom(Player player) - { - _meteors.add(new MeteorShowerData(player, player.getTargetBlock((HashSet<Byte>) null, 128).getLocation())); - } - - @EventHandler - public void update(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; - - Iterator<MeteorShowerData> meteorIter = _meteors.iterator(); - - while (meteorIter.hasNext()) - { - MeteorShowerData data = meteorIter.next(); - - if (data.update()) - { - meteorIter.remove(); - } - } - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkNotFinished.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkNotFinished.java deleted file mode 100644 index b4bbf8f94..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkNotFinished.java +++ /dev/null @@ -1,15 +0,0 @@ -package nautilus.game.arcade.kit.perks; - -import mineplex.core.common.util.C; -import nautilus.game.arcade.kit.Perk; - -public class PerkNotFinished extends Perk -{ - public PerkNotFinished() - { - super("Not Completed", new String[] - { - C.cRed + C.Bold + "KIT IS NOT FINISHED", - }); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkOvercharge.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkOvercharge.java deleted file mode 100644 index 80813cbf7..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkOvercharge.java +++ /dev/null @@ -1,204 +0,0 @@ -package nautilus.game.arcade.kit.perks; - -import java.util.Iterator; -import java.util.WeakHashMap; - -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.block.Action; -import org.bukkit.event.entity.EntityShootBowEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerQuitEvent; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.core.updater.UpdateType; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.kit.SmashPerk; - -public class PerkOvercharge extends SmashPerk -{ - private WeakHashMap<Player, Integer> _charge = new WeakHashMap<Player, Integer>(); - private WeakHashMap<Player, Long> _chargeLast = new WeakHashMap<Player, Long>(); - - private WeakHashMap<Arrow, Integer> _arrows = new WeakHashMap<Arrow, Integer>(); - - private int _max; - private long _tick; - private boolean _useExp; - - public PerkOvercharge(int max, long tick, boolean useExpBar) - { - super("Corrupted Arrow", new String[] - { - C.cYellow + "Charge" + C.cGray + " your Bow to use " + C.cGreen + "Corrupted Arrow" - }); - - _useExp = useExpBar; - _max = max; - _tick = tick; - } - - @EventHandler - public void drawBow(PlayerInteractEvent event) - { - Player player = event.getPlayer(); - - if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) - return; - - if (player.getItemInHand() == null || player.getItemInHand().getType() != Material.BOW) - return; - - if (isSuperActive(player)) - return; - - if (!Kit.HasKit(player)) - return; - - if (!player.getInventory().contains(Material.ARROW)) - return; - - if (event.getClickedBlock() != null) - if (UtilBlock.usable(event.getClickedBlock())) - return; - - // Start Charge - _charge.put(player, 0); - _chargeLast.put(player, System.currentTimeMillis()); - } - - @EventHandler - public void charge(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; - - for (Player cur : UtilServer.getPlayers()) - { - // Not Charging - if (!_charge.containsKey(cur)) - continue; - - // Max Charge - if (_charge.get(cur) >= _max) - continue; - - // Charge Interval - if (_charge.get(cur) == 0) - { - if (!UtilTime.elapsed(_chargeLast.get(cur), 1000)) - continue; - } - else - { - if (!UtilTime.elapsed(_chargeLast.get(cur), _tick)) - continue; - } - - // No Longer Holding Bow - if (cur.getItemInHand() == null || cur.getItemInHand().getType() != Material.BOW) - { - if (_useExp) - cur.setExp(0f); - - _charge.remove(cur); - _chargeLast.remove(cur); - continue; - } - - // Increase Charge - _charge.put(cur, _charge.get(cur) + 1); - - if (_useExp) - cur.setExp(Math.min(0.9999f, (float)_charge.get(cur) / (float)_max)); - - _chargeLast.put(cur, System.currentTimeMillis()); - - // Effect - cur.playSound(cur.getLocation(), Sound.CLICK, 1f, 1f + (0.1f * _charge.get(cur))); - } - } - - @EventHandler(priority = EventPriority.HIGH) - public void fireBow(EntityShootBowEvent event) - { - if (event.isCancelled()) - return; - - if (!Manager.GetGame().IsLive()) - return; - - if (!(event.getEntity() instanceof Player)) - return; - - if (!(event.getProjectile() instanceof Arrow)) - return; - - Player player = (Player) event.getEntity(); - - if (!_charge.containsKey(player)) - return; - - int charge = _charge.remove(player); - if (charge <= 0) - return; - - // Start Barrage - _arrows.put((Arrow)event.getProjectile(), charge); - - player.setExp(0f); - } - - @EventHandler(priority = EventPriority.HIGH) - public void damageBonus(CustomDamageEvent event) - { - if (event.GetProjectile() == null) - return; - - if (!_arrows.containsKey(event.GetProjectile())) - return; - - int charge = _arrows.remove(event.GetProjectile()); - - event.AddMod(GetName(), GetName(), charge, true); - } - - @EventHandler - public void clean(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; - - for (Iterator<Arrow> arrowIterator = _arrows.keySet().iterator(); arrowIterator.hasNext();) - { - Arrow arrow = arrowIterator.next(); - - if (arrow.isDead() || !arrow.isValid() || arrow.isOnGround() || arrow.getTicksLived() > 120) - arrowIterator.remove(); - else - UtilParticle.PlayParticle(ParticleType.RED_DUST, arrow.getLocation(), 0, 0, 0, 0, 1, - ViewDist.MAX, UtilServer.getPlayers()); - } - } - - @EventHandler - public void quit(PlayerQuitEvent event) - { - Player player = event.getPlayer(); - - _charge.remove(player); - _chargeLast.remove(player); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkRopedArrow.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkRopedArrow.java index 51e694be7..3d0d4b759 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkRopedArrow.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkRopedArrow.java @@ -24,7 +24,7 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import nautilus.game.arcade.kit.SmashPerk; +import nautilus.game.arcade.game.games.smash.perks.SmashPerk; public class PerkRopedArrow extends SmashPerk { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSeismicSlam.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSeismicSlam.java index 4b41a42e4..9b93d6fe8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSeismicSlam.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSeismicSlam.java @@ -1,19 +1,7 @@ package nautilus.game.arcade.kit.perks; import java.util.HashMap; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilTime; -import mineplex.core.recharge.Recharge; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.kit.Perk; +import java.util.Map; import org.bukkit.Effect; import org.bukkit.Sound; @@ -22,36 +10,56 @@ import org.bukkit.block.BlockFace; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.block.Action; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.util.Vector; -public class PerkSeismicSlam extends Perk -{ - private HashMap<LivingEntity, Long> _live = new HashMap<LivingEntity, Long>(); +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilItem; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.kit.Perk; - public PerkSeismicSlam() +public class PerkSeismicSlam extends Perk +{ + + private static final long COOLDOWN = 7000; + private static final long TIME = 1000; + private static final int DAMAGE = 10; + private static final int RADIUS = 8; + private static final float KNOCKBACK_MAGNITUDE = 2.4F; + + private Map<LivingEntity, Long> _live = new HashMap<>(); + + public PerkSeismicSlam() { - super("Seismic Slam", new String[] - { - C.cYellow + "Right-Click" + C.cGray + " with Spade to " + C.cGreen + "Seismic Slam" - }); + super("Seismic Slam", new String[] { C.cYellow + "Right-Click" + C.cGray + " with Spade to " + C.cGreen + "Seismic Slam" }); } - + @EventHandler public void deactivateDeath(PlayerDeathEvent event) { - if (!Manager.GetGame().IsLive()) - return; + Player player = event.getEntity(); - if (!Kit.HasKit(event.getEntity())) - return; - - if (_live.containsKey(event.getEntity())) + if (!hasPerk(player)) { - _live.remove(event.getEntity()); + return; + } + + if (_live.containsKey(player)) + { + _live.remove(player); } } @@ -59,101 +67,126 @@ public class PerkSeismicSlam extends Perk public void Leap(PlayerInteractEvent event) { if (event.isCancelled()) + { return; + } - if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) + if (!UtilEvent.isAction(event, ActionType.R)) + { return; + } if (UtilBlock.usable(event.getClickedBlock())) + { return; - - if (event.getPlayer().getItemInHand() == null) - return; - - if (!event.getPlayer().getItemInHand().getType().toString().contains("_SPADE")) - return; + } Player player = event.getPlayer(); - if (!Kit.HasKit(player)) + if (!UtilItem.isSpade(player.getItemInHand())) + { + return; + } + + if (!hasPerk(player)) + { + return; + } + + if (!Recharge.Instance.use(player, GetName(), COOLDOWN, true, true)) return; - if (!Recharge.Instance.use(player, GetName(), 7000, true, true)) - return; - - //Action + // Action Vector vec = player.getLocation().getDirection(); if (vec.getY() < 0) + { vec.setY(vec.getY() * -1); + } UtilAction.velocity(player, vec, 1, true, 1, 0, 1, true); - //Record + // Record _live.put(player, System.currentTimeMillis()); - //Inform + // Inform UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + ".")); } - + @EventHandler public void Slam(UpdateEvent event) { if (event.getType() != UpdateType.TICK) + { return; + } for (Player player : Manager.GetGame().GetPlayers(true)) { if (!UtilEnt.isGrounded(player)) + { continue; + } if (!_live.containsKey(player)) + { continue; + } - if (!UtilTime.elapsed(_live.get(player), 1000)) + if (!UtilTime.elapsed(_live.get(player), TIME)) + { continue; + } _live.remove(player); - - //Action - int damage = 10; - double range = 8; - - HashMap<LivingEntity, Double> targets = UtilEnt.getInRadius(player.getLocation(), range); + + // Action + + Map<LivingEntity, Double> targets = UtilEnt.getInRadius(player.getLocation(), RADIUS); + for (LivingEntity cur : targets.keySet()) { if (cur.equals(player)) + { continue; + } - if (cur instanceof Player && !Manager.IsAlive((Player) cur)) + if (UtilPlayer.isSpectator(cur)) + { continue; - - //Damage Event - Manager.GetDamage().NewDamageEvent(cur, player, null, - DamageCause.CUSTOM, damage * targets.get(cur) + 0.5, true, true, false, - player.getName(), GetName()); + } - //Condition + // Damage Event + Manager.GetDamage().NewDamageEvent(cur, player, null, DamageCause.CUSTOM, DAMAGE * targets.get(cur) + 0.5, true, true, false, player.getName(), GetName()); + + // Condition Manager.GetCondition().Factory().Falling(GetName(), cur, player, 10, false, true); - //Inform + // Inform if (cur instanceof Player) - UtilPlayer.message((Player)cur, F.main("Game", F.name(player.getName()) +" hit you with " + F.skill(GetName()) + ".")); + UtilPlayer.message((Player) cur, F.main("Game", F.name(player.getName()) + " hit you with " + F.skill(GetName()) + ".")); } - - //Effect + + // Effect player.getWorld().playSound(player.getLocation(), Sound.ZOMBIE_WOOD, 2f, 0.2f); - for (Block cur : UtilBlock.getInRadius(player.getLocation(), 4d).keySet()) + + for (Block cur : UtilBlock.getInRadius(player.getLocation(), 4).keySet()) + { if (UtilBlock.airFoliage(cur.getRelative(BlockFace.UP)) && !UtilBlock.airFoliage(cur)) - cur.getWorld().playEffect(cur.getLocation(), Effect.STEP_SOUND, cur.getTypeId()); - } + { + cur.getWorld().playEffect(cur.getLocation(), Effect.STEP_SOUND, cur.getType()); + } + } + } } - + @EventHandler public void Knockback(CustomDamageEvent event) { if (event.GetReason() == null || !event.GetReason().contains(GetName())) + { return; + } - event.AddKnockback(GetName(), 2.4); + event.AddKnockback(GetName(), KNOCKBACK_MAGNITUDE); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSkeletonArrowStorm.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSkeletonArrowStorm.java deleted file mode 100644 index a58a42b81..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSkeletonArrowStorm.java +++ /dev/null @@ -1,69 +0,0 @@ -package nautilus.game.arcade.kit.perks; - -import java.util.HashSet; -import java.util.Iterator; - -import org.bukkit.Sound; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.Player; -import org.bukkit.entity.Projectile; -import org.bukkit.event.EventHandler; -import org.bukkit.event.entity.ProjectileHitEvent; -import org.bukkit.util.Vector; - - -import mineplex.core.updater.event.UpdateEvent; -import mineplex.core.updater.UpdateType; -import nautilus.game.arcade.kit.SmashKit; -import nautilus.game.arcade.kit.SmashPerk; - -public class PerkSkeletonArrowStorm extends SmashPerk -{ - private HashSet<Projectile> _arrows = new HashSet<Projectile>(); - - public PerkSkeletonArrowStorm() - { - super("Arrow Storm", new String[] - { - - }, false); - } - - @EventHandler - public void fireArrows(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; - - for (Player cur : ((SmashKit)Kit).getSuperActive()) - { - Vector random = new Vector((Math.random() - 0.5) / 5, (Math.random() - 0.5) / 5, (Math.random() - 0.5) / 5); - Projectile arrow = cur.launchProjectile(Arrow.class); - arrow.setVelocity(cur.getLocation().getDirection().add(random).multiply(3)); - _arrows.add(arrow); - cur.getWorld().playSound(cur.getLocation(), Sound.SHOOT_ARROW, 1f, 1f); - } - } - - @EventHandler - public void projectileHit(ProjectileHitEvent event) - { - if (_arrows.remove(event.getEntity())) - event.getEntity().remove(); - } - - @EventHandler - public void clean(UpdateEvent event) - { - if (event.getType() != UpdateType.SEC) - return; - - for (Iterator<Projectile> arrowIterator = _arrows.iterator(); arrowIterator.hasNext();) - { - Projectile arrow = arrowIterator.next(); - - if (arrow.isDead() || !arrow.isValid()) - arrowIterator.remove(); - } - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSlimeSlam.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSlimeSlam.java deleted file mode 100644 index 467ce8d7c..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSlimeSlam.java +++ /dev/null @@ -1,141 +0,0 @@ -package nautilus.game.arcade.kit.perks; - -import java.util.HashMap; - -import org.bukkit.GameMode; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.block.Action; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.player.PlayerInteractEvent; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilTime; -import mineplex.core.recharge.Recharge; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.SmashPerk; - -public class PerkSlimeSlam extends SmashPerk -{ - private HashMap<LivingEntity, Long> _live = new HashMap<LivingEntity, Long>(); - - public PerkSlimeSlam() - { - super("Slime Slam", new String[] - { - C.cYellow + "Right-Click" + C.cGray + " with Axe to " + C.cGreen + "Slime Slam" - }); - } - - @EventHandler - public void Leap(PlayerInteractEvent event) - { - if (event.isCancelled()) - return; - - if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) - return; - - if (UtilBlock.usable(event.getClickedBlock())) - return; - - if (event.getPlayer().getItemInHand() == null) - return; - - if (!event.getPlayer().getItemInHand().getType().toString().contains("_AXE")) - return; - - Player player = event.getPlayer(); - - if (isSuperActive(player)) - return; - - if (!Kit.HasKit(player)) - return; - - if (!Recharge.Instance.use(player, GetName(), 6000, true, true)) - return; - - UtilAction.velocity(player, player.getLocation().getDirection(), 1.2, false, 0, 0.2, 1.2, true); - - //Record - _live.put(player, System.currentTimeMillis()); - - //Inform - UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + ".")); - } - - @EventHandler - public void End(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; - - //Collide - for (Player player : Manager.GetGame().GetPlayers(true)) - if (_live.containsKey(player)) - for (Player other : Manager.GetGame().GetPlayers(true)) - if (!Manager.isSpectator(other)) - if (!other.equals(player)) - if (UtilMath.offset(player, other) < 2) - { - DoSlam(player, other); - _live.remove(player); - return; - } - - //End - for (Player player : Manager.GetGame().GetPlayers(true)) - { - if (!UtilEnt.isGrounded(player)) - continue; - - if (!_live.containsKey(player)) - continue; - - if (!UtilTime.elapsed(_live.get(player), 1000)) - continue; - - _live.remove(player); - } - } - - public void DoSlam(Player damager, LivingEntity damagee) - { - int damage = 8; - - //Recoil Event - if (!isSuperActive(damager)) - Manager.GetDamage().NewDamageEvent(damager, damagee, null, - DamageCause.CUSTOM, damage/4d, true, true, false, - damager.getName(), GetName() + " Recoil"); - - //Damage Event - Manager.GetDamage().NewDamageEvent(damagee, damager, null, - DamageCause.CUSTOM, damage, true, true, false, - damager.getName(), GetName()); - - //Inform - UtilPlayer.message(damager, F.main("Game", "You hit " + F.name(UtilEnt.getName(damagee)) + " with " + F.skill(GetName()) + ".")); - UtilPlayer.message(damagee, F.main("Game", F.name(damager.getName()) + " hit you with " + F.skill(GetName()) + ".")); - } - - @EventHandler - public void Knockback(CustomDamageEvent event) - { - if (event.GetReason() == null || !event.GetReason().contains(GetName())) - return; - - event.AddKnockback(GetName(), 2); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSnowTurret.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSnowTurret.java deleted file mode 100644 index 710589904..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSnowTurret.java +++ /dev/null @@ -1,170 +0,0 @@ -package nautilus.game.arcade.kit.perks; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.WeakHashMap; - -import org.bukkit.Location; -import org.bukkit.Sound; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftSnowman; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.entity.Projectile; -import org.bukkit.entity.Snowball; -import org.bukkit.entity.Snowman; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.entity.ProjectileHitEvent; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.util.Vector; - -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.recharge.Recharge; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.kit.SmashPerk; -import net.minecraft.server.v1_8_R3.EntityInsentient; - -public class PerkSnowTurret extends SmashPerk -{ - private WeakHashMap<Projectile, Player> _snowball = new WeakHashMap<Projectile, Player>(); - - private HashMap<Snowman, Player> _turret = new HashMap<Snowman, Player>(); - - public PerkSnowTurret() - { - super("Snow Turret", new String[] - { - }, false); - } - - @Override - public void addSuperCustom(Player player) - { - Manager.GetGame().CreatureAllowOverride = true; - Snowman ent = player.getWorld().spawn(player.getEyeLocation(), Snowman.class); - Manager.GetGame().CreatureAllowOverride = false; - - UtilEnt.Vegetate(ent); - UtilEnt.ghost(ent, true, false); - - ent.setMaxHealth(40); - ent.setHealth(40); - - UtilAction.velocity(ent, player.getLocation().getDirection(), 1, false, 0, 0.2, 1, false); - - _turret.put(ent, player); - } - - @EventHandler - public void updateSnowman(UpdateEvent event) - { - if (event.getType() != UpdateType.FASTER) - return; - - Iterator<Snowman> turretIter = _turret.keySet().iterator(); - - while (turretIter.hasNext()) - { - Snowman snowman = turretIter.next(); - Player player = _turret.get(snowman); - - if (snowman.getTicksLived() > 400) - { - UtilParticle.PlayParticle(ParticleType.SNOWBALL_POOF, snowman.getLocation().add(0, 1, 0), 0.4f, 0.4f, 0.4f, 0, 12, - ViewDist.LONG, UtilServer.getPlayers()); - turretIter.remove(); - snowman.remove(); - continue; - } - - Player target = UtilPlayer.getClosest(snowman.getLocation(), player); - if (target == null) - continue; - - snowman.setTarget(target); - - //Snowball - double mult = 1 + Math.min(3, UtilMath.offset(snowman, target)/16); - double heightBonus = UtilMath.offset(snowman, target)/140; - Vector rand = new Vector((Math.random()-0.5)*0.2,(Math.random()-0.5)*0.2,(Math.random()-0.5)*0.2); - - _snowball.put(snowman.launchProjectile(Snowball.class, UtilAlg.getTrajectory(snowman.getLocation(), - target.getLocation()).multiply(mult).add(rand).add(new Vector(0,heightBonus,0))), player); - - //Look dir - UtilEnt.CreatureMoveFast(snowman, target.getLocation(), 0.1f); - - //Sound - snowman.getWorld().playSound(snowman.getLocation(), Sound.STEP_SNOW, 0.6f, 1f); - } - } - - @EventHandler(priority = EventPriority.LOW) - public void snowballHit(CustomDamageEvent event) - { - if (event.GetCause() != DamageCause.PROJECTILE) - return; - - Projectile proj = event.GetProjectile(); - if (proj == null) return; - - if (!(proj instanceof Snowball)) - return; - - if (!_snowball.containsKey(proj)) - return; - - LivingEntity damagee = event.GetDamageeEntity(); - if (damagee == null) return; - - event.SetCancelled("Turret"); - - if (damagee.equals(_snowball.get(proj))) - return; - - UtilAction.velocity(damagee, proj.getVelocity().multiply(0.3).add(new Vector(0, 0.3, 0))); - - //Damage Event - if (!(damagee instanceof LivingEntity)) - return; - - if (!Recharge.Instance.use((Player)damagee, GetName() + " Hit", 250, false, false)) - return; - - Manager.GetDamage().NewDamageEvent(damagee, _snowball.get(proj), null, - DamageCause.PROJECTILE, 2, false, true, false, - UtilEnt.getName(_snowball.get(proj)), GetName()); - } - - @EventHandler - public void damageCancel(CustomDamageEvent event) - { - if (_turret.containsKey(event.GetDamageeEntity())) - event.SetCancelled("Turret Immunity"); - } - - @EventHandler - public void clean(ProjectileHitEvent event) - { - _snowball.remove(event.getEntity()); - } - - @EventHandler - public void knockback(CustomDamageEvent event) - { - if (event.GetReason() == null || !event.GetReason().contains(GetName())) - return; - - event.AddKnockback(GetName(), 2.5); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitchPotion.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitchPotion.java deleted file mode 100644 index 7baa5eb0a..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitchPotion.java +++ /dev/null @@ -1,175 +0,0 @@ -package nautilus.game.arcade.kit.perks; - -import java.util.ArrayList; -import java.util.Iterator; - -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.entity.Projectile; -import org.bukkit.entity.ThrownPotion; -import org.bukkit.event.EventHandler; -import org.bukkit.event.block.Action; -import org.bukkit.event.entity.ProjectileHitEvent; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.player.PlayerInteractEvent; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.recharge.Recharge; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.kit.SmashPerk; - -public class PerkWitchPotion extends SmashPerk -{ - private ArrayList<Projectile> _proj = new ArrayList<Projectile>(); - - public PerkWitchPotion() - { - super("Daze Potion", new String[] - { - C.cYellow + "Right-Click" + C.cGray + " with Axe to use " + C.cGreen + "Daze Potion" - }); - } - - - @EventHandler - public void Activate(PlayerInteractEvent event) - { - if (event.isCancelled()) - return; - - if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) - return; - - if (UtilBlock.usable(event.getClickedBlock())) - return; - - if (!event.getPlayer().getItemInHand().getType().toString().contains("_AXE")) - return; - - Player player = event.getPlayer(); - - if (isSuperActive(player)) - return; - - if (!Kit.HasKit(player)) - return; - - if (!Recharge.Instance.use(player, GetName(), 2000, true, true)) - return; - - //Start - ThrownPotion potion = player.launchProjectile(ThrownPotion.class); - UtilAction.velocity(potion, player.getLocation().getDirection(), 1, false, 0, 0.2, 10, false); - - _proj.add(potion); - - //Inform - UtilPlayer.message(player, F.main("Skill", "You used " + F.skill(GetName()) + ".")); - } - - @EventHandler - public void Hit(ProjectileHitEvent event) - { - if (!_proj.remove(event.getEntity())) - return; - - for (Player player : Manager.GetGame().GetPlayers(true)) - { - if (player.equals(event.getEntity().getShooter())) - continue; - - if (!(event.getEntity().getShooter() instanceof Player)) - continue; - - Player thrower = (Player)event.getEntity().getShooter(); - - double range = 3; - if (isSuperActive(thrower)) - range = 4; - - if (UtilMath.offset(player.getLocation().add(0,1,0), event.getEntity().getLocation()) > range) - continue; - - //Standard - if (!isSuperActive(thrower)) - { - //Damage Event - Manager.GetDamage().NewDamageEvent(player, thrower, null, - DamageCause.CUSTOM, 5, true, true, false, - UtilEnt.getName((LivingEntity)event.getEntity().getShooter()), GetName()); - - Manager.GetCondition().Factory().Slow("Witch Potion", player, null, 3, 1, true, false, false, false); - } - //Super Effect - else - { - //Bonus Damage - double bonus = 5; - - //Damage Event - Manager.GetDamage().NewDamageEvent(player, thrower, null, - DamageCause.CUSTOM, 5 + bonus, true, true, false, - UtilEnt.getName((LivingEntity)event.getEntity().getShooter()), GetName()); - - Manager.GetCondition().Factory().Slow("Witch Potion", player, null, 7, 2, true, false, false, false); - //Manager.GetCondition().Factory().Confuse(reason, ent, source, duration, mult, extend, showIndicator, ambient) - } - } - } - - @EventHandler - public void Update(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; - - Iterator<Projectile> potionIterator = _proj.iterator(); - - while (potionIterator.hasNext()) - { - Projectile proj = potionIterator.next(); - - if (!proj.isValid()) - { - potionIterator.remove(); - continue; - } - - UtilParticle.PlayParticle(ParticleType.MOB_SPELL, proj.getLocation(), 0, 0, 0, 0, 1, - ViewDist.LONGER, UtilServer.getPlayers()); - - //Super - if (!(proj.getShooter() instanceof Player)) - continue; - - Player thrower = (Player)proj.getShooter(); - - //Super Effect - if (!isSuperActive(thrower)) - { - //XXX - } - } - } - - @EventHandler - public void Knockback(CustomDamageEvent event) - { - if (event.GetReason() == null || !event.GetReason().contains(GetName())) - return; - - event.AddKnockback(GetName(), 2); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWolf.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWolf.java deleted file mode 100644 index febca2e0a..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWolf.java +++ /dev/null @@ -1,436 +0,0 @@ -package nautilus.game.arcade.kit.perks; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; - -import org.bukkit.Effect; -import org.bukkit.GameMode; -import org.bukkit.Location; -import org.bukkit.Sound; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftCreature; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.entity.Wolf; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.block.Action; -import org.bukkit.event.entity.EntityTargetEvent; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.util.Vector; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilTime; -import mineplex.core.recharge.Recharge; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.core.updater.UpdateType; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.kit.SmashPerk; -import net.minecraft.server.v1_8_R3.EntityCreature; -import net.minecraft.server.v1_8_R3.Navigation; -import net.minecraft.server.v1_8_R3.NavigationAbstract; - -public class PerkWolf extends SmashPerk -{ - private HashMap<Wolf, Player> _owner = new HashMap<Wolf, Player>(); - private HashMap<Wolf, LivingEntity> _tackle = new HashMap<Wolf, LivingEntity>(); - - private HashMap<Player, Long> _strike = new HashMap<Player, Long>(); - - private HashMap<Player, ArrayList<Long>> _repeat = new HashMap<Player, ArrayList<Long>>(); - - private HashMap<LivingEntity, Long> _tackleStrike = new HashMap<LivingEntity, Long>(); - - public PerkWolf() - { - super("Wolf Skills", new String[] - { - C.cGray + "Attacks give +1 Damage for 3 seconds. Stacks.", - C.cYellow + "Right-Click" + C.cGray + " with Axe to use " + C.cGreen + "Cub Tackle", - C.cYellow + "Right-Click" + C.cGray + " with Spade to use " + C.cGreen + "Wolf Strike", - C.cGray + "Wolf Strike deals 300% Knockback to tackled opponents.", - }); - } - - @EventHandler - public void TackleTrigger(PlayerInteractEvent event) - { - if (event.isCancelled()) - return; - - if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) - return; - - if (UtilBlock.usable(event.getClickedBlock())) - return; - - if (event.getPlayer().getItemInHand() == null) - return; - - if (!event.getPlayer().getItemInHand().getType().toString().contains("_AXE")) - return; - - Player player = event.getPlayer(); - - if (!Kit.HasKit(player)) - return; - - if (!Recharge.Instance.use(player, "Cub Tackle", isSuperActive(player) ? 1600 : 8000, !isSuperActive(player), !isSuperActive(player))) - return; - - //Get Nearest Wolf - Manager.GetGame().CreatureAllowOverride = true; - Wolf wolf = player.getWorld().spawn(player.getEyeLocation().add(player.getLocation().getDirection()), Wolf.class); - Manager.GetGame().CreatureAllowOverride = false; - - wolf.setBaby(); - - wolf.setAngry(true); - - UtilEnt.Vegetate(wolf); - - wolf.setMaxHealth(30); - wolf.setHealth(wolf.getMaxHealth()); - - UtilAction.velocity(wolf, player.getLocation().getDirection(), 1.8, false, 0, 0.2, 1.2, true); - - player.getWorld().playSound(wolf.getLocation(), Sound.WOLF_BARK, 1f, 1.8f); - - //Record - _owner.put(wolf, player); - - //Inform - UtilPlayer.message(player, F.main("Game", "You used " + F.skill("Cub Tackle") + ".")); - } - - @EventHandler - public void TackleCollide(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; - - //Collide - Iterator<Wolf> wolfIterator = _owner.keySet().iterator(); - - while (wolfIterator.hasNext()) - { - Wolf wolf = wolfIterator.next(); - - //Hit Player - for (Player other : Manager.GetGame().GetPlayers(true)) - if (!Manager.isSpectator(other)) - if (UtilEnt.hitBox(wolf.getLocation(), other, 2, null)) - { - if (other.equals(TackleGetOwner(wolf))) - continue; - - TackleCollideAction(TackleGetOwner(wolf), other, wolf); - wolfIterator.remove(); - return; - } - - if (!wolf.isValid() ||( UtilEnt.isGrounded(wolf) && wolf.getTicksLived() > 20)) - { - wolf.remove(); - wolfIterator.remove(); - } - } - } - - public void TackleCollideAction(Player damager, LivingEntity damagee, Wolf wolf) - { - if (damager == null) - return; - - _tackle.put(wolf, damagee); - - wolf.setVelocity(new Vector(0,-0.6,0)); - UtilAction.zeroVelocity(damagee); - - //Damage - Manager.GetDamage().NewDamageEvent(damagee, damager, null, - DamageCause.CUSTOM, 5, false, true, false, - damager.getName(), "Cub Tackle"); - - //Sound - damagee.getWorld().playSound(damagee.getLocation(), Sound.WOLF_GROWL, 1.5f, 1.5f); - - //Inform - UtilPlayer.message(damager, F.main("Game", "You hit " + F.name(UtilEnt.getName(damagee)) + " with " + F.skill("Cub Tackle") + ".")); - UtilPlayer.message(damagee, F.main("Game", F.name(damager.getName()) + " hit you with " + F.skill("Cub Tackle") + ".")); - } - - @EventHandler - public void TackleUpdate(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; - - Iterator<Wolf> wolfIterator = _tackle.keySet().iterator(); - - while (wolfIterator.hasNext()) - { - Wolf wolf = wolfIterator.next(); - LivingEntity ent = _tackle.get(wolf); - - if (!wolf.isValid() || !ent.isValid() || wolf.getTicksLived() > 80) - { - wolf.remove(); - wolfIterator.remove(); - continue; - } - - if (UtilMath.offset(wolf, ent) < 2.5) - { - Manager.GetCondition().Factory().Slow("Cub Table", ent, wolf, 0.9, 1, false, false, false, false); - UtilAction.velocity(ent, new Vector(0,-0.3,0)); - } - - //Move - Location loc = ent.getLocation(); - loc.add(UtilAlg.getTrajectory2d(ent, wolf).multiply(1)); - - EntityCreature ec = ((CraftCreature)wolf).getHandle(); - NavigationAbstract nav = ec.getNavigation(); - nav.a(loc.getX(), loc.getY(), loc.getZ(), 1); - } - } - - public Player TackleGetOwner(Wolf wolf) - { - if (_owner.containsKey(wolf)) - return _owner.get(wolf); - - return null; - } - - @EventHandler - public void TackleTargetCancel(EntityTargetEvent event) - { - if (_owner.containsKey(event.getEntity())) - if (_owner.get(event.getEntity()).equals(event.getTarget())) - event.setCancelled(true); - } - - @EventHandler - public void TackleDamage(CustomDamageEvent event) - { - if (event.GetCause() != DamageCause.ENTITY_ATTACK) - return; - - LivingEntity damager = event.GetDamagerEntity(false); - if (damager == null) return; - - if (damager instanceof Wolf) - event.SetCancelled("Wolf Cub"); - } - - @EventHandler - public void StrikeTrigger(PlayerInteractEvent event) - { - if (event.isCancelled()) - return; - - if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) - return; - - if (UtilBlock.usable(event.getClickedBlock())) - return; - - if (event.getPlayer().getItemInHand() == null) - return; - - if (!event.getPlayer().getItemInHand().getType().toString().contains("_SPADE")) - return; - - Player player = event.getPlayer(); - - if (!Kit.HasKit(player)) - return; - - if (!Recharge.Instance.use(player, "Wolf Strike", isSuperActive(player) ? 1600 : 8000, !isSuperActive(player), !isSuperActive(player))) - return; - - //Velocity - UtilAction.velocity(player, player.getLocation().getDirection(), 1.6, false, 1, 0.2, 1.2, true); - - //Record - _strike.put(player, System.currentTimeMillis()); - - player.getWorld().playSound(player.getLocation(), Sound.WOLF_BARK, 1f, 1.2f); - - //Inform - UtilPlayer.message(player, F.main("Game", "You used " + F.skill("Wolf Strike") + ".")); - } - - @EventHandler - public void StrikeEnd(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; - - //Collide - Iterator<Player> playerIterator = _strike.keySet().iterator(); - - while (playerIterator.hasNext()) - { - Player player = playerIterator.next(); - - for (Player other : Manager.GetGame().GetPlayers(true)) - if (!player.equals(other)) - if (!Manager.isSpectator(other)) - if (UtilEnt.hitBox(player.getLocation().add(0, 1, 0), other, 2, null)) - { - StrikeHit(player, other); - playerIterator.remove(); - return; - } - - if (!UtilEnt.isGrounded(player)) - continue; - - if (!UtilTime.elapsed(_strike.get(player), 1500)) - continue; - - playerIterator.remove(); - } - } - - public void StrikeHit(Player damager, LivingEntity damagee) - { - UtilAction.zeroVelocity(damager); - - //Remove Tackle - Iterator<Wolf> wolfIterator = _tackle.keySet().iterator(); - while (wolfIterator.hasNext()) - { - Wolf wolf = wolfIterator.next(); - - if (_tackle.get(wolf).equals(damagee)) - { - wolf.remove(); - wolfIterator.remove(); - - _tackleStrike.put(damagee, System.currentTimeMillis()); - } - } - - Manager.GetDamage().NewDamageEvent(damagee, damager, null, - DamageCause.CUSTOM, 7, true, true, false, - damager.getName(), "Wolf Strike"); - - - //Sound - damagee.getWorld().playSound(damagee.getLocation(), Sound.WOLF_BARK, 1.5f, 1f); - - //Inform - UtilPlayer.message(damager, F.main("Game", "You hit " + F.name(UtilEnt.getName(damagee)) + " with " + F.skill("Wolf Strike") + ".")); - UtilPlayer.message(damagee, F.main("Game", F.name(damager.getName()) + " hit you with " + F.skill("Wolf Strike") + ".")); - } - - @EventHandler - public void StrikeKnockback(CustomDamageEvent event) - { - if (event.GetReason() != null && event.GetReason().contains("Wolf Strike")) - { - if (_tackleStrike.containsKey(event.GetDamageeEntity()) && !UtilTime.elapsed(_tackleStrike.get(event.GetDamageeEntity()), 100)) - { - event.AddKnockback(GetName(), 3.0); - - //Blood - event.GetDamageeEntity().getWorld().playEffect(event.GetDamageeEntity().getLocation(), Effect.STEP_SOUND, 55); - - //Double Sound - event.GetDamageeEntity().getWorld().playSound(event.GetDamageeEntity().getLocation(), Sound.WOLF_BARK, 2f, 1.5f); - } - else - { - event.AddKnockback(GetName(), 1.5); - } - } - } - - @EventHandler(priority = EventPriority.HIGHEST) - public void RepeatDamage(CustomDamageEvent event) - { - if (event.IsCancelled()) - return; - - if (event.GetCause() != DamageCause.ENTITY_ATTACK) - return; - - Player damager = event.GetDamagerPlayer(false); - if (damager == null) return; - - if (!Kit.HasKit(damager)) - return; - - if (!_repeat.containsKey(damager)) - { - _repeat.put(damager, new ArrayList<Long>()); - _repeat.get(damager).add(System.currentTimeMillis()); - - //Exp - damager.setExp(Math.min(0.9999f, _repeat.get(damager).size()/9f)); - - return; - } - - int count = _repeat.get(damager).size(); - - if (count > 0) - { - event.AddMod(damager.getName(), "Ravage", Math.min(2, count), false); - - //Sound - damager.getWorld().playSound(damager.getLocation(), Sound.WOLF_BARK, (float)(0.5 + count*0.25), (float)(1 + count*0.25)); - } - - _repeat.get(damager).add(System.currentTimeMillis()); - - //Exp - damager.setExp(Math.min(0.9999f, _repeat.get(damager).size()/9f)); - } - - @EventHandler - public void RepeatExpire(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; - - Iterator<Player> playerIterator = _repeat.keySet().iterator(); - - while (playerIterator.hasNext()) - { - Player player = playerIterator.next(); - - Iterator<Long> timeIterator = _repeat.get(player).iterator(); - - while (timeIterator.hasNext()) - { - long time = timeIterator.next(); - - if (UtilTime.elapsed(time, 3000)) - timeIterator.remove(); - } - - //Exp - player.setExp(Math.min(0.9999f, _repeat.get(player).size()/9f)); - } - } - - @Override - public void addSuperCustom(Player player) - { - Recharge.Instance.recharge(player, "Wolf Strike"); - Recharge.Instance.recharge(player, "Cub Tackle"); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWoolBomb.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWoolBomb.java index 436db672e..2a2ec4083 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWoolBomb.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWoolBomb.java @@ -3,6 +3,10 @@ package nautilus.game.arcade.kit.perks; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; import org.bukkit.Effect; import org.bukkit.Material; @@ -12,7 +16,7 @@ import org.bukkit.entity.Item; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.block.Action; +import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.player.PlayerInteractEvent; @@ -22,12 +26,15 @@ import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguiseSheep; import mineplex.core.itemstack.ItemStackFactory; @@ -38,60 +45,82 @@ import mineplex.core.recharge.RechargedEvent; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import nautilus.game.arcade.game.games.smash.TeamSuperSmash; import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.perks.data.WoolBombData; public class PerkWoolBomb extends Perk implements IThrown { - private HashMap<Player, Item> _thrown = new HashMap<Player, Item>(); - private HashMap<Player, WoolBombData> _active = new HashMap<Player, WoolBombData>(); - public PerkWoolBomb() + private static final long RATE = 800; + private static final long COOLDOWN = 8000; + private static final int DAMAGE_RADIUS = 9; + private static final int DAMAGE_EXPLODE = 14; + private static final int DAMAGE_COLLIDE = 4; + private static final int KNOCKBACK_MAGNITUDE = 2; + + private Map<UUID, Item> _thrown = new HashMap<>(); + private Map<UUID, WoolBombData> _active = new HashMap<>(); + + public PerkWoolBomb() { - super("Wool Mine", new String[] - { - C.cYellow + "Right-Click" + C.cGray + " with Axe to " + C.cGreen + "Wool Mine" - }); + super("Wool Mine", new String[] { C.cYellow + "Right-Click" + C.cGray + " with Axe to " + C.cGreen + "Wool Mine" }); } @EventHandler public void skill(PlayerInteractEvent event) { if (event.isCancelled()) + { return; + } - if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) + if (!UtilEvent.isAction(event, ActionType.R)) + { return; + } if (UtilBlock.usable(event.getClickedBlock())) + { return; - - if (event.getPlayer().getItemInHand() == null) - return; - - if (!event.getPlayer().getItemInHand().getType().toString().contains("_AXE")) - return; + } Player player = event.getPlayer(); - if (!Kit.HasKit(player)) + if (!UtilItem.isAxe(player.getItemInHand())) + { return; - + } + + if (!hasPerk(player)) + { + return; + } + if (!Recharge.Instance.usable(player, GetName() + " Rate")) + { return; + } + + UUID key = player.getUniqueId(); - if (_active.containsKey(player)) + if (_active.containsKey(key)) { if (detonate(player, true)) + { return; + } } - - if (_thrown.containsKey(player)) + + if (_thrown.containsKey(key)) { if (solidify(player, true)) + { return; + } } - + launch(player); event.setCancelled(true); @@ -99,192 +128,251 @@ public class PerkWoolBomb extends Perk implements IThrown private void launch(Player player) { - if (!Recharge.Instance.use(player, GetName(), 8000, true, true)) + if (!Recharge.Instance.usable(player, GetName(), true)) + { return; - - org.bukkit.entity.Item ent = player.getWorld().dropItem(player.getEyeLocation(), ItemStackFactory.Instance.CreateStack(Material.WOOL, (byte)0)); - - UtilAction.velocity(ent, player.getLocation().getDirection(), 1, false, 0, 0.2, 10, false); - - Manager.GetProjectile().AddThrow(ent, player, this, -1, true, true, true, true, - null, 1f, 1f, - null, 1, UpdateType.SLOW, - 0.5f); + } - _thrown.put(player, ent); + Item ent = player.getWorld().dropItem(player.getEyeLocation(), ItemStackFactory.Instance.CreateStack(Material.WOOL, (byte) 0)); - //Inform + UtilAction.velocity(ent, player.getLocation().getDirection(), 1, false, 0, 0.2, 10, false); + + Manager.GetProjectile().AddThrow(ent, player, this, -1, true, true, true, true, null, 1f, 1f, null, 1, UpdateType.SLOW, 0.5f); + + _thrown.put(player.getUniqueId(), ent); + + // Inform UtilPlayer.message(player, F.main("Game", "You launched " + F.skill(GetName()) + ".")); - //Effect + // Effect player.getWorld().playSound(player.getLocation(), Sound.SHEEP_IDLE, 2f, 1.5f); + + // Rate + Recharge.Instance.useForce(player, GetName() + " Rate", RATE); + + // Disguise + DisguiseBase disguise = Manager.GetDisguise().getActiveDisguise(player); - //Rate - Recharge.Instance.useForce(player, GetName() + " Rate", 800); - - //Disguise - DisguiseBase disguise = Manager.GetDisguise().getDisguise(player); if (disguise != null && disguise instanceof DisguiseSheep) { - DisguiseSheep sheep = (DisguiseSheep)disguise; + DisguiseSheep sheep = (DisguiseSheep) disguise; sheep.setSheared(true); - + sheep.UpdateDataWatcher(); Manager.GetDisguise().updateDisguise(disguise); } } - + @EventHandler public void rechargeWool(RechargedEvent event) { if (event.GetAbility().equals(GetName())) { - DisguiseBase disguise = Manager.GetDisguise().getDisguise(event.GetPlayer()); + DisguiseBase disguise = Manager.GetDisguise().getActiveDisguise(event.GetPlayer()); + if (disguise != null && disguise instanceof DisguiseSheep) { - DisguiseSheep sheep = (DisguiseSheep)disguise; + DisguiseSheep sheep = (DisguiseSheep) disguise; sheep.setSheared(false); - + sheep.UpdateDataWatcher(); Manager.GetDisguise().updateDisguise(disguise); } } } - + private boolean solidify(LivingEntity ent, boolean inform) { if (!(ent instanceof Player)) + { return false; + } - Player player = (Player)ent; + Player player = (Player) ent; + + Item thrown = _thrown.remove(player.getUniqueId()); - Item thrown = _thrown.remove(player); if (thrown == null) + { return false; + } - //Make Block + // Make Block Block block = thrown.getLocation().getBlock(); - + Manager.GetBlockRestore().restore(block); - - _active.put(player, new WoolBombData(block)); - - block.setTypeIdAndData(35, (byte)0, true); + + _active.put(player.getUniqueId(), new WoolBombData(block)); + + block.setType(Material.WOOL); block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType()); - - //Clean + + // Clean thrown.remove(); - - //Rate - Recharge.Instance.useForce(player, GetName() + " Rate", 1000); - - //Inform + + // Rate + Recharge.Instance.useForce(player, GetName() + " Rate", RATE); + + // Inform if (inform) { player.getWorld().playSound(player.getLocation(), Sound.SHEEP_IDLE, 2f, 1.5f); - + UtilPlayer.message(player, F.main("Game", "You armed " + F.skill(GetName()) + ".")); } - + return true; } private boolean detonate(Player player, boolean inform) { - WoolBombData data = _active.remove(player); - - if (data == null) - return false; - - //Restore - data.restore(); - - //Explode - UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, data.Block.getLocation().add(0.5, 0.5, 0.5), 0, 0, 0, 0, 1, - ViewDist.MAX, UtilServer.getPlayers()); - data.Block.getWorld().playSound(data.Block.getLocation(), Sound.EXPLODE, 3f, 0.8f); - - //Damage - HashMap<LivingEntity, Double> targets = UtilEnt.getInRadius(data.Block.getLocation().add(0.5, 0.5, 0.5), 9); - for (LivingEntity cur : targets.keySet()) - { - //Damage Event - Manager.GetDamage().NewDamageEvent(cur, player, null, - DamageCause.CUSTOM, 14 * targets.get(cur) + 0.5, false, true, false, - player.getName(), GetName()); - - //Condition - Manager.GetCondition().Factory().Falling(GetName(), cur, player, 10, false, true); - - //Knockback - UtilAction.velocity(cur, UtilAlg.getTrajectory2d(data.Block.getLocation().add(0.5, 0.5, 0.5), cur.getEyeLocation()), 0.5 + 2.5 * targets.get(cur), true, 0.8, 0, 10, true); + WoolBombData data = _active.remove(player.getUniqueId()); - //Inform - if (cur instanceof Player && !player.equals(cur)) - UtilPlayer.message((Player)cur, F.main("Game", F.name(player.getName()) +" hit you with " + F.skill(GetName()) + ".")); + if (data == null) + { + return false; } - //Rate - Recharge.Instance.useForce(player, GetName() + " Rate", 800); + if (!Recharge.Instance.use(player, GetName(), COOLDOWN, true, true)) + { + return false; + } + + // Restore + data.restore(); + + // Explode + UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, data.Block.getLocation().add(0.5, 0.5, 0.5), 0, 0, 0, 0, 1, ViewDist.MAX, UtilServer.getPlayers()); + data.Block.getWorld().playSound(data.Block.getLocation(), Sound.EXPLODE, 3f, 0.8f); + + // Damage + Map<LivingEntity, Double> targets = UtilEnt.getInRadius(data.Block.getLocation().add(0.5, 0.5, 0.5), DAMAGE_RADIUS); - //Inform + List<Player> team = TeamSuperSmash.getTeam(Manager, player, false); + for (LivingEntity cur : targets.keySet()) + { + if(cur instanceof Player) + { + if(team.contains(cur)) + { + continue; + } + } + + // Damage Event + Manager.GetDamage().NewDamageEvent(cur, player, null, DamageCause.CUSTOM, DAMAGE_EXPLODE * targets.get(cur) + 0.5, false, true, false, player.getName(), GetName()); + + // Condition + Manager.GetCondition().Factory().Falling(GetName(), cur, player, 10, false, true); + + // Knockback + UtilAction.velocity(cur, UtilAlg.getTrajectory2d(data.Block.getLocation().add(0.5, 0.5, 0.5), cur.getEyeLocation()), 0.5 + 2.5 * targets.get(cur), true, 0.8, 0, 10, true); + + // Inform + if (cur instanceof Player && !player.equals(cur)) + { + UtilPlayer.message((Player) cur, F.main("Game", F.name(player.getName()) + " hit you with " + F.skill(GetName()) + ".")); + } + + } + + // Rate + Recharge.Instance.useForce(player, GetName() + " Rate", RATE); + + // Inform if (inform) { player.getWorld().playSound(player.getLocation(), Sound.SHEEP_IDLE, 2f, 1.5f); - + UtilPlayer.message(player, F.main("Game", "You detonated " + F.skill(GetName()) + ".")); } return true; } + + @EventHandler(priority = EventPriority.HIGH) + public void onDamageSelf(CustomDamageEvent event) + { + if(event.GetDamageePlayer() == null || event.GetDamagerPlayer(true) == null) + { + return; + } + + if(!event.GetDamageePlayer().equals(event.GetDamagerPlayer(true))) + { + return; + } + + if(event.GetCause() != DamageCause.CUSTOM) + { + return; + } + + if(!event.IsCancelled()) + { + return; + } + + event.GetCancellers().remove("Team Damage"); + } @Override - public void Collide(LivingEntity target, Block block, ProjectileUser data) + public void Collide(LivingEntity target, Block block, ProjectileUser data) { solidify(data.getThrower(), false); if (target == null) + { return; - - //Damage Event - Manager.GetDamage().NewDamageEvent(target, data.getThrower(), null, - DamageCause.PROJECTILE, 4, true, true, false, - UtilEnt.getName(data.getThrower()), GetName()); + } + + // Damage Event + Manager.GetDamage().NewDamageEvent(target, data.getThrower(), null, DamageCause.PROJECTILE, DAMAGE_COLLIDE, true, true, false, UtilEnt.getName(data.getThrower()), GetName()); } @Override - public void Idle(ProjectileUser data) + public void Idle(ProjectileUser data) { solidify(data.getThrower(), false); } @Override - public void Expire(ProjectileUser data) + public void Expire(ProjectileUser data) { solidify(data.getThrower(), false); } - + @EventHandler public void colorExpireUpdate(UpdateEvent event) { if (event.getType() != UpdateType.FASTER) + { return; + } - HashSet<Player> detonate = new HashSet<Player>(); - - Iterator<Player> playerIterator = _active.keySet().iterator(); - + Set<Player> detonate = new HashSet<Player>(); + Iterator<UUID> playerIterator = _active.keySet().iterator(); + while (playerIterator.hasNext()) { - Player player = playerIterator.next(); - WoolBombData data = _active.get(player); + UUID key = playerIterator.next(); - if (UtilTime.elapsed(data.Time, 8000)) + Player player = UtilPlayer.searchExact(key); + + if (player == null) + { + playerIterator.remove(); + continue; + } + + WoolBombData data = _active.get(key); + + if (UtilTime.elapsed(data.Time, COOLDOWN)) { detonate.add(player); continue; } - + if (Recharge.Instance.usable(player, GetName() + " Rate")) { if (data.Block.getData() == 14) @@ -297,7 +385,7 @@ public class PerkWoolBomb extends Perk implements IThrown } } } - + for (Player player : detonate) { detonate(player, false); @@ -308,8 +396,10 @@ public class PerkWoolBomb extends Perk implements IThrown public void knockback(CustomDamageEvent event) { if (event.GetReason() == null || !event.GetReason().contains(GetName())) + { return; - - event.AddKnockback(GetName(), 2); + } + + event.AddKnockback(GetName(), KNOCKBACK_MAGNITUDE); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWoolCloud.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWoolCloud.java index 76b51ee71..77a9a7740 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWoolCloud.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWoolCloud.java @@ -2,14 +2,13 @@ package nautilus.game.arcade.kit.perks; import java.util.HashMap; import java.util.Iterator; +import java.util.Map; +import java.util.UUID; import org.bukkit.DyeColor; import org.bukkit.Effect; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Horse; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.block.Action; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.util.Vector; @@ -17,14 +16,18 @@ import org.bukkit.util.Vector; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguiseSheep; import mineplex.core.recharge.Recharge; @@ -35,121 +38,152 @@ import nautilus.game.arcade.kit.Perk; public class PerkWoolCloud extends Perk { - private HashMap<Player, Long> _active = new HashMap<Player, Long>(); - public PerkWoolCloud() + private static final long COOLDOWN = 10000; + private static final long MIN_VELOCITY_TIME = 200; + private static final long MAX_VELOCITY_TIME = 1200; + private static final int DAMAGE_RADIUS = 2; + private static final int DAMAGE = 8; + private static final float KNOCKBACK_MAGNITUDE = 2.5F; + + private Map<UUID, Long> _active = new HashMap<>(); + + public PerkWoolCloud() { - super("Wooly Rocket", new String[] - { - C.cYellow + "Right-Click" + C.cGray + " with Spade to " + C.cGreen + "Wooly Rocket" - }); + super("Wooly Rocket", new String[] { C.cYellow + "Right-Click" + C.cGray + " with Spade to " + C.cGreen + "Wooly Rocket" }); } - + @EventHandler public void Leap(PlayerInteractEvent event) { if (event.isCancelled()) + { return; - - if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) - return; + } - if (event.getPlayer().getItemInHand() == null) + if (!UtilEvent.isAction(event, ActionType.R)) + { return; - - if (!event.getPlayer().getItemInHand().getType().toString().contains("_SPADE")) + } + + if (UtilBlock.usable(event.getClickedBlock())) + { return; - + } + Player player = event.getPlayer(); - - if (!Kit.HasKit(player)) + + if (!UtilItem.isSpade(player.getItemInHand())) + { return; - - //Recharge - if (!Recharge.Instance.use(player, GetName(), 10000, true, true)) + } + + if (!hasPerk(player)) + { return; + } + + // Recharge + if (!Recharge.Instance.use(player, GetName(), COOLDOWN, true, true)) + { + return; + } - UtilAction.velocity(player, new Vector(0,1,0), 1, false, 0, 0, 2, true); - + UtilAction.velocity(player, new Vector(0, 1, 0), 1, false, 0, 0, 2, true); + UtilPlayer.message(player, F.main("Skill", "You used " + F.skill(GetName()) + ".")); - + player.getWorld().playEffect(player.getLocation(), Effect.BLAZE_SHOOT, 0); - - //Allow double jump + + // Allow double jump player.setAllowFlight(true); - + setWoolColor(player, DyeColor.RED); - - _active.put(player, System.currentTimeMillis()); + + _active.put(player.getUniqueId(), System.currentTimeMillis()); } - + @EventHandler public void update(UpdateEvent event) { if (event.getType() != UpdateType.TICK) + { return; + } - if (Manager.GetGame() == null) + if (!Manager.GetGame().IsLive()) + { return; + } + + Iterator<UUID> playerIterator = _active.keySet().iterator(); - Iterator<Player> playerIterator = _active.keySet().iterator(); while (playerIterator.hasNext()) { - Player player = playerIterator.next(); - - UtilParticle.PlayParticle(ParticleType.FLAME, player.getLocation(), 0.2f, 0.2f, 0.2f, 0, 4, - ViewDist.LONGER, UtilServer.getPlayers()); - - if (!UtilTime.elapsed(_active.get(player), 200)) + UUID key = playerIterator.next(); + Player player = UtilPlayer.searchExact(key); + + if (player == null) + { + playerIterator.remove(); continue; + } + + UtilParticle.PlayParticle(ParticleType.FLAME, player.getLocation(), 0.2f, 0.2f, 0.2f, 0, 4, ViewDist.LONGER, UtilServer.getPlayers()); + + if (!UtilTime.elapsed(_active.get(key), MIN_VELOCITY_TIME)) + { + continue; + } for (Player other : Manager.GetGame().GetPlayers(true)) { if (player.equals(other)) - continue; - - if (UtilMath.offset(player, other) < 2) { - //Damage Event - Manager.GetDamage().NewDamageEvent(other, player, null, - DamageCause.CUSTOM, 8, true, false, false, - player.getName(), GetName()); - - UtilParticle.PlayParticle(ParticleType.EXPLODE, other.getLocation(), 0f, 0f, 0f, 0, 1, - ViewDist.MAX, UtilServer.getPlayers()); - UtilParticle.PlayParticle(ParticleType.LAVA, player.getLocation(), 0.2f, 0.2f, 0.2f, 0, 10, - ViewDist.MAX, UtilServer.getPlayers()); + continue; + } + + if (UtilMath.offset(player, other) < DAMAGE_RADIUS) + { + // Damage Event + Manager.GetDamage().NewDamageEvent(other, player, null, DamageCause.CUSTOM, DAMAGE, true, false, false, player.getName(), GetName()); + + UtilParticle.PlayParticle(ParticleType.EXPLODE, other.getLocation(), 0f, 0f, 0f, 0, 1, ViewDist.MAX, UtilServer.getPlayers()); + UtilParticle.PlayParticle(ParticleType.LAVA, player.getLocation(), 0.2f, 0.2f, 0.2f, 0, 10, ViewDist.MAX, UtilServer.getPlayers()); } } - - if (UtilEnt.isGrounded(player) || UtilTime.elapsed(_active.get(player), 1200)) + + if (UtilEnt.isGrounded(player) || UtilTime.elapsed(_active.get(key), MAX_VELOCITY_TIME)) { playerIterator.remove(); setWoolColor(player, DyeColor.WHITE); } } } - + public void setWoolColor(Player player, DyeColor color) { - DisguiseBase disguise = Manager.GetDisguise().getDisguise(player); + DisguiseBase disguise = Manager.GetDisguise().getActiveDisguise(player); + if (disguise != null && disguise instanceof DisguiseSheep) { - DisguiseSheep sheep = (DisguiseSheep)disguise; + DisguiseSheep sheep = (DisguiseSheep) disguise; sheep.setSheared(false); sheep.setColor(color); - + sheep.UpdateDataWatcher(); Manager.GetDisguise().updateDisguise(disguise); } } - + @EventHandler public void knockback(CustomDamageEvent event) { if (event.GetReason() == null || !event.GetReason().contains(GetName())) + { return; - - event.AddKnockback(GetName(), 2.5); + } + + event.AddKnockback(GetName(), KNOCKBACK_MAGNITUDE); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkZombieNightDead.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkZombieNightDead.java deleted file mode 100644 index 61effab98..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkZombieNightDead.java +++ /dev/null @@ -1,15 +0,0 @@ -package nautilus.game.arcade.kit.perks; - -import nautilus.game.arcade.kit.SmashPerk; - -public class PerkZombieNightDead extends SmashPerk -{ - - public PerkZombieNightDead() - { - super("Night of the Dead", new String[] - { - }, false); - } - -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkZombieRot.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkZombieRot.java deleted file mode 100644 index a3869f76f..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkZombieRot.java +++ /dev/null @@ -1,66 +0,0 @@ -package nautilus.game.arcade.kit.perks; - -import java.util.HashMap; - -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import nautilus.game.arcade.kit.SmashPerk; - -public class PerkZombieRot extends SmashPerk -{ - public PerkZombieRot() - { - super("Rot", new String[] - { - C.cGray + "Leave a path that slows and prevents jumping.", - }); - } - - @EventHandler - public void SnowAura(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; - - for (Player player : Manager.GetGame().GetPlayers(true)) - { - if (!Kit.HasKit(player)) - continue; - - //Blocks - HashMap<Block, Double> blocks = UtilBlock.getInRadius(player.getLocation(), 3); - for (Block block : blocks.keySet()) - { - if (UtilBlock.solid(block.getRelative(BlockFace.UP))) - continue; - - if (!UtilBlock.solid(block)) - continue; - - //Snow - Manager.GetBlockRestore().add(block, 159, (byte) 12, 3000); - } - } - - for (Player player : Manager.GetGame().GetPlayers(true)) - { - if (Kit.HasKit(player)) - continue; - - if (player.getLocation().getBlock().getRelative(BlockFace.DOWN).getType() != Material.STAINED_CLAY || - player.getLocation().getBlock().getRelative(BlockFace.DOWN).getData() != 12) - continue; - - Manager.GetCondition().Factory().Slow(GetName(), player, null, 1.9, 1, false, false, false, false); - Manager.GetCondition().Factory().Jump(GetName(), player, null, 1.9, 244, false, false, false); - } - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/data/BlockTossData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/data/BlockTossData.java index bd1130267..98fda9f0d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/data/BlockTossData.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/data/BlockTossData.java @@ -4,10 +4,12 @@ public class BlockTossData { public int Type; public byte Data; + public long Time; - public BlockTossData(int type, byte data) + public BlockTossData(int type, byte data, long time) { Type = type; Data = data; + Time = time; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/data/EarthquakeData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/data/EarthquakeData.java deleted file mode 100644 index c3e994b14..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/data/EarthquakeData.java +++ /dev/null @@ -1,15 +0,0 @@ -package nautilus.game.arcade.kit.perks.data; - -import org.bukkit.entity.Player; - -public class EarthquakeData -{ - public Player Player; - public long Time; - - public EarthquakeData(Player player) - { - Player = player; - Time = System.currentTimeMillis(); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/data/FissureData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/data/FissureData.java index c603782f7..93e2e2754 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/data/FissureData.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/data/FissureData.java @@ -3,14 +3,6 @@ package nautilus.game.arcade.kit.perks.data; import java.util.ArrayList; import java.util.HashSet; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; -import nautilus.game.arcade.kit.perks.PerkFissure; - import org.bukkit.Effect; import org.bukkit.Location; import org.bukkit.block.Block; @@ -19,6 +11,14 @@ import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.util.Vector; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import nautilus.game.arcade.game.games.smash.perks.golem.PerkFissure; + public class FissureData { private PerkFissure Host; @@ -154,6 +154,11 @@ public class FissureData } + + if(Host.Manager.GetGame().GetTeam(_player).GetPlayers(true).contains(cur)) + { + continue; + } //Damage if (!_hit.contains(cur)) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/data/HomingSheepData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/data/HomingSheepData.java index fb17b9a25..cb23bb935 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/data/HomingSheepData.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/data/HomingSheepData.java @@ -5,13 +5,17 @@ import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import org.bukkit.DyeColor; -import org.bukkit.GameMode; import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.entity.Sheep; public class HomingSheepData { + + private static final int MAX_LIFE_TICKS = 300; + private static final int TARGET_RADIUS = 2; + private static final float VELOCITY = 0.36F; + public Player Shooter; public Player Target; public Sheep Sheep; @@ -28,15 +32,21 @@ public class HomingSheepData public boolean update() { if (!Sheep.isValid() || !Target.isValid() || UtilPlayer.isSpectator(Target)) + { return true; + } - if (Sheep.getTicksLived() > 300) + if (Sheep.getTicksLived() > MAX_LIFE_TICKS) + { return true; + } - if (UtilMath.offset(Sheep.getLocation(), Target.getEyeLocation()) < 2) + if (UtilMath.offset(Sheep.getLocation(), Target.getEyeLocation()) < TARGET_RADIUS) + { return true; + } - Sheep.setVelocity(UtilAlg.getTrajectory(Sheep.getLocation(), Target.getEyeLocation()).multiply(0.36)); + Sheep.setVelocity(UtilAlg.getTrajectory(Sheep.getLocation(), Target.getEyeLocation()).multiply(VELOCITY)); Sheep.getWorld().playSound(Sheep.getLocation(), Sound.SHEEP_IDLE, 1.5f, 1.5f); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/data/MeteorShowerData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/data/MeteorShowerData.java index 09edaeadd..ce6171251 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/data/MeteorShowerData.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/data/MeteorShowerData.java @@ -12,20 +12,23 @@ import org.bukkit.util.Vector; public class MeteorShowerData { + public Player Shooter; public Location Target; public long Time; + private long _maxTime; - public MeteorShowerData(Player shooter, Location target) + public MeteorShowerData(Player shooter, Location target, long maxTime) { Shooter = shooter; Target = target; Time = System.currentTimeMillis(); + _maxTime = maxTime; } public boolean update() { - if (UtilTime.elapsed(Time, 12000)) + if (UtilTime.elapsed(Time, _maxTime)) return true; LargeFireball ball = Target.getWorld().spawn(Target.clone().add(Math.random() * 24 - 12, 32 + Math.random() * 16, Math.random() * 24 - 12), LargeFireball.class); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/data/WoolBombData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/data/WoolBombData.java index 9699b9972..c94cd1e08 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/data/WoolBombData.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/data/WoolBombData.java @@ -21,6 +21,7 @@ public class WoolBombData public void restore() { - Block.setTypeIdAndData(Material.getId(), Data, true); + Block.setType(Material); + Block.setData(Data); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameWorldManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameWorldManager.java index fdaf4c271..43a654f57 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameWorldManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameWorldManager.java @@ -39,7 +39,7 @@ public class GameWorldManager implements Listener while (worldIterator.hasNext()) { long timeLeft = endTime - System.currentTimeMillis(); - if (timeLeft <= 0) continue; + if (timeLeft <= 0) break; final WorldData worldData = worldIterator.next(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/HolidayManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/HolidayManager.java index 89e04c909..c7b572244 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/HolidayManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/HolidayManager.java @@ -484,9 +484,10 @@ public class HolidayManager implements Listener @EventHandler public void spawnDebug(PlayerCommandPreprocessEvent event) { - if (event.getPlayer().isOp() && event.getPlayer().getName().equals("Chiss") && event.getMessage().contains("pumpkin")) + if (event.getPlayer().isOp() && event.getMessage().toLowerCase().startsWith("/pumpkin")) { spawnSpecialBlock(event.getPlayer().getLocation().getBlock()); + event.setCancelled(true); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/NextBestGameManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/NextBestGameManager.java index 75a511baa..bc24be374 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/NextBestGameManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/NextBestGameManager.java @@ -20,6 +20,7 @@ import nautilus.game.arcade.events.PlayerStateChangeEvent; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.GameTeam.PlayerState; +import nautilus.game.arcade.game.games.halloween2016.Halloween2016; import nautilus.game.arcade.game.games.minestrike.Minestrike; import nautilus.game.arcade.game.games.paintball.Paintball; import nautilus.game.arcade.game.games.wither.WitherGame; @@ -245,6 +246,7 @@ public class NextBestGameManager implements Listener if(event.GetGame() instanceof Minestrike || event.GetGame() instanceof WitherGame || event.GetGame() instanceof Paintball + || event.GetGame() instanceof Halloween2016 || event.GetGame().Manager.GetHost() != null) { return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/ProgressingKitManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/ProgressingKitManager.java index b132cf5b5..db0a72789 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/ProgressingKitManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/ProgressingKitManager.java @@ -149,19 +149,32 @@ public class ProgressingKitManager implements Listener @EventHandler public void onQuit(PlayerQuitEvent event) { - //Fail safe updating in case a player leaves the game before we do data - Player player = event.getPlayer(); - - PlayerKit playerKit = _manager.getKitProgressionManager().getDataManager().get(player.getUniqueId()); - for (Kit kit : _manager.GetGame().GetKits()) + try { - if (kit instanceof ProgressingKit) + //Fail safe updating in case a player leaves the game before we do data + Player player = event.getPlayer(); + + PlayerKit playerKit = _manager.getKitProgressionManager().getDataManager().get(player.getUniqueId()); + try { - ProgressingKit progressingKit = (ProgressingKit) kit; - _manager.getKitProgressionManager().getRepository().insertOrUpdate(playerKit, progressingKit.getInternalName()); + for (Kit kit : _manager.GetGame().GetKits()) + { + if (kit instanceof ProgressingKit) + { + ProgressingKit progressingKit = (ProgressingKit) kit; + _manager.getKitProgressionManager().getRepository().insertOrUpdate(playerKit, progressingKit.getInternalName()); + } + } + } + finally + { + _manager.getKitProgressionManager().getDataManager().remove(playerKit); } } - _manager.getKitProgressionManager().getDataManager().remove(playerKit); + finally + { + _data.remove(event.getPlayer().getUniqueId()); + } } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/current/NewGameLobbyManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/current/NewGameLobbyManager.java index 1711097d6..ca5f05faf 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/current/NewGameLobbyManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/current/NewGameLobbyManager.java @@ -528,6 +528,12 @@ public class NewGameLobbyManager extends LobbyManager { _multipleLocs.put(lastName, locations); } + } else if(name.equalsIgnoreCase("MAP_NAME")) + { + if(tokens[1].toLowerCase().contains("halloween")) + { + WORLD.setTime(13850); + } } else { lastName = tokens[1]; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/legacy/LegacyGameLobbyManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/legacy/LegacyGameLobbyManager.java index 5dda2cc42..3ecc7b3a1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/legacy/LegacyGameLobbyManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/legacy/LegacyGameLobbyManager.java @@ -271,7 +271,7 @@ public class LegacyGameLobbyManager extends LobbyManager double space = 4; double offset = (divide - 1) * space / 2d; - for (int i = 0; i < kits.size() - divide; i++) + for (int i = 1; i < kits.size() - divide; i++) { Kit kit = kits.get(i + divide); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/RecoveryMasterStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/RecoveryMasterStatTracker.java index d3e9f4447..f97b006a8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/RecoveryMasterStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/RecoveryMasterStatTracker.java @@ -7,6 +7,7 @@ import java.util.UUID; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import mineplex.core.common.util.UtilPlayer; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; @@ -46,6 +47,11 @@ public class RecoveryMasterStatTracker extends StatTracker<Game> { if (getGame().GetState() != Game.GameState.Live) return; + + if (event.GetCause() == DamageCause.VOID) + { + return; + } Player damagee = event.GetDamageePlayer(); if (damagee == null) diff --git a/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/Hub.java b/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/Hub.java index e9ab99136..632be718e 100644 --- a/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/Hub.java +++ b/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/Hub.java @@ -51,6 +51,7 @@ import mineplex.core.updater.Updater; import mineplex.core.velocity.VelocityFix; import mineplex.core.visibility.VisibilityManager; import net.minecraft.server.v1_8_R3.MinecraftServer; +import org.spigotmc.SpigotConfig; import static mineplex.core.Managers.require; @@ -156,7 +157,8 @@ public class Hub extends JavaPlugin // Updates getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1); - MinecraftServer.getServer().getPropertyManager().setProperty("debug", true); + MinecraftServer.getServer().getPropertyManager().setProperty("debug", false); + SpigotConfig.debug = false; } } diff --git a/Plugins/pom.xml b/Plugins/pom.xml index 3f9f3fbba..905d6e24b 100644 --- a/Plugins/pom.xml +++ b/Plugins/pom.xml @@ -34,7 +34,6 @@ <module>Mineplex.ServerData</module> <module>Mineplex.ServerMonitor</module> <module>Mineplex.StaffServer</module> - <module>Mineplex.Votifier</module> <module>Nautilus.Game.Arcade</module> <module>mavericks-review-hub</module> @@ -61,12 +60,6 @@ <version>2.2.1</version> <scope>compile</scope> </dependency> - <dependency> - <groupId>com.vexsoftware</groupId> - <artifactId>votifier</artifactId> - <version>1.9</version> - <scope>provided</scope> - </dependency> <dependency> <groupId>javax.mail</groupId> <artifactId>mail</artifactId>