From 0f5fcc767014977742dec2ddd6b9c289198f48a6 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 1 May 2017 10:36:45 +0100 Subject: [PATCH] Remove entity bots --- .../game/games/smash/SuperSmashTraining.java | 4 +- .../{training => }/TrainingGameModule.java | 66 +-------- .../game/modules/training/TrainingBot.java | 138 ------------------ 3 files changed, 2 insertions(+), 206 deletions(-) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/{training => }/TrainingGameModule.java (84%) delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/training/TrainingBot.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmashTraining.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmashTraining.java index 6eeb2b6a8..064ce150a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmashTraining.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmashTraining.java @@ -11,8 +11,7 @@ import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.smash.events.SmashActivateEvent; -import nautilus.game.arcade.game.modules.training.TrainingBot; -import nautilus.game.arcade.game.modules.training.TrainingGameModule; +import nautilus.game.arcade.game.modules.TrainingGameModule; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.entity.Player; @@ -62,7 +61,6 @@ public class SuperSmashTraining extends SuperSmash new TrainingGameModule() .setSkillFunction(_safeFunction) .setDamageFunction(_safeFunction) - .addBot(TrainingBot.class) .register(this); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/training/TrainingGameModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/TrainingGameModule.java similarity index 84% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/training/TrainingGameModule.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/TrainingGameModule.java index c90fe0fce..3305ba089 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/training/TrainingGameModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/TrainingGameModule.java @@ -1,6 +1,5 @@ -package nautilus.game.arcade.game.modules.training; +package nautilus.game.arcade.game.modules; -import mineplex.core.command.CommandCenter; import mineplex.core.common.events.EntityVelocityChangeEvent; import mineplex.core.common.util.*; import mineplex.core.itemstack.ItemBuilder; @@ -11,7 +10,6 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.game.modules.Module; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.ProgressingKit; import nautilus.game.arcade.managers.LobbyEnt; @@ -47,14 +45,10 @@ public class TrainingGameModule extends Module private Function _teamFunction; private Function _skillFunction; private Function _damageFunction; - private final Set> _botClasses; - private final Set _bots; public TrainingGameModule() { _kits = new HashSet<>(); - _botClasses = new HashSet<>(); - _bots = new HashSet<>(); } @EventHandler @@ -84,37 +78,6 @@ public class TrainingGameModule extends Module UtilEnt.CreatureLook(entity.GetEnt(), average); } - Map> map = getGame().WorldData.GetAllCustomLocs(); - int j = 0; - - for (Map.Entry> entry : map.entrySet()) - { - String s = entry.getKey(); - - if (s.startsWith("BOT")) - { - String[] split = s.split(" "); - - if (split.length < 2) - { - continue; - } - - String clazzName = split[1]; - - for (Class clazz : _botClasses) - { - if (clazzName.equals(clazz.getSimpleName())) - { - for (Location location : entry.getValue()) - { - spawnBot(clazz, location, ++j); - } - } - } - } - } - getGame().CreatureAllowOverride = false; } @@ -126,11 +89,6 @@ public class TrainingGameModule extends Module lobbyEnt.GetEnt().remove(); } - for (TrainingBot bot : _bots) - { - bot.cleanup(); - } - _kits.clear(); } @@ -367,22 +325,6 @@ public class TrainingGameModule extends Module } } - private T spawnBot(Class clazz, Location location, int number) - { - try - { - T bot = clazz.getConstructor(TrainingGameModule.class, Location.class, int.class).newInstance(this, location, number); - _bots.add(bot); - return bot; - } - catch (Exception e) - { - e.printStackTrace(); - } - - return null; - } - public TrainingGameModule setTeamFunction(Function function) { _teamFunction = function; @@ -401,12 +343,6 @@ public class TrainingGameModule extends Module return this; } - public TrainingGameModule addBot(Class clazz) - { - _botClasses.add(clazz); - return this; - } - private LobbyEnt getFromEntity(Entity entity) { for (LobbyEnt lobbyEnt : _kits) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/training/TrainingBot.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/training/TrainingBot.java deleted file mode 100644 index c311b5d35..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/training/TrainingBot.java +++ /dev/null @@ -1,138 +0,0 @@ -package nautilus.game.arcade.game.modules.training; - -import mineplex.core.common.skin.SkinData; -import mineplex.core.common.util.*; -import mineplex.core.disguise.disguises.DisguisePlayer; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.combat.DeathMessageType; -import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import org.bukkit.Location; -import org.bukkit.entity.ArmorStand; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; - -import java.text.DecimalFormat; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; -import java.util.concurrent.TimeUnit; - -public class TrainingBot implements Listener -{ - - private static final SkinData[] SKIN_DATAS = - { - SkinData.SNOWMAN, - SkinData.MOOSHROOM, - SkinData.WITCH - }; - private static final int DAMAGE_HOLOGRAMS_LIFE = 40; - private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("0.0"); - private static final long RESPAWN_TIME = TimeUnit.SECONDS.toMillis(5); - - private TrainingGameModule _module; - private Location _location; - private int _number; - - protected ArmorStand _stand; - private long _lastDeath; - - private final Set _damageHolograms; - - public TrainingBot(TrainingGameModule module, Location location, int number) - { - _module = module; - _location = location; - _number = number; - _lastDeath = System.currentTimeMillis(); - _damageHolograms = new HashSet<>(); - - UtilServer.RegisterEvents(this); - } - - public void cleanup() - { - UtilServer.Unregister(this); - } - - @EventHandler(priority = EventPriority.MONITOR) - public void botDamage(CustomDamageEvent event) - { - if (_stand == null || !_stand.equals(event.GetDamageeEntity())) - { - return; - } - - spawnDamageHologram(event.GetDamage()); - } - - @EventHandler - public void botDeath(CombatDeathEvent event) - { - if (_stand == null || !_stand.equals(event.GetEvent().getEntity())) - { - return; - } - - event.SetBroadcastType(DeathMessageType.Detailed); - _stand.remove(); - } - - private void spawnDamageHologram(double damage) - { - String damageSting = DECIMAL_FORMAT.format(damage); - Location location = UtilAlg.getRandomLocation(_stand.getLocation().add(0, 1, 0), 1, 0, 1); - ArmorStand stand = location.getWorld().spawn(location, ArmorStand.class); - - stand.setVisible(false); - stand.setGravity(false); - stand.setCustomName(C.cRedB + "-" + damageSting); - stand.setCustomNameVisible(true); - - _damageHolograms.add(stand); - } - - @EventHandler - public void cleanupDamageHolograms(UpdateEvent event) - { - if (event.getType() != UpdateType.FASTEST) - { - return; - } - - Iterator iterator = _damageHolograms.iterator(); - - while (iterator.hasNext()) - { - ArmorStand stand = iterator.next(); - - if (stand.getTicksLived() > DAMAGE_HOLOGRAMS_LIFE) - { - stand.remove(); - iterator.remove(); - continue; - } - - stand.teleport(stand.getLocation().add(0, 0.25, 0)); - } - } - - @EventHandler - public void respawn(UpdateEvent event) - { - if (event.getType() != UpdateType.SEC || !UtilTime.elapsed(_lastDeath, RESPAWN_TIME)) - { - return; - } - - _lastDeath = System.currentTimeMillis(); - _stand = _location.getWorld().spawn(_location, ArmorStand.class); - - DisguisePlayer disguise = new DisguisePlayer(_stand, C.cYellowB + "Bot #" + _number, SKIN_DATAS[UtilMath.r(SKIN_DATAS.length)]); - disguise.setSendSkinDataToSelf(false); - _module.getGame().getArcadeManager().GetDisguise().disguise(disguise); - } -}