From 54cda56c1196041d6d03d037b5852464e39f9300 Mon Sep 17 00:00:00 2001 From: samczsun Date: Sat, 2 Jul 2016 17:16:42 -0400 Subject: [PATCH 01/90] Initial Commit --- .../core/disguise/DisguiseManager.java | 4 + .../clans/worldevent/WorldEventType.java | 12 +- .../clans/worldevent/kinghill/KingHill.java | 3 +- .../mineplex/game/clans/items/CustomItem.java | 2 +- .../items/attributes/AttributeContainer.java | 2 +- .../clans/items/legendaries/HyperAxe.java | 2 +- .../items/legendaries/MeridianScepter.java | 2 +- .../game/core/boss/ironwizard/GolemBoss.java | 6 +- .../ironwizard/abilities/GolemCaveIn.java | 204 +++++++++--------- .../game/core/boss/slimeking/SlimeBoss.java | 5 +- .../game/core/boss/spider/SpiderBoss.java | 5 +- 11 files changed, 127 insertions(+), 120 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java index be83461c2..154ec1ba6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java @@ -40,6 +40,8 @@ import java.util.Map.Entry; public class DisguiseManager extends MiniPlugin implements IPacketHandler { + public static DisguiseManager INSTANCE; + private NautHashMap _spawnPacketMap = new NautHashMap(); private NautHashMap _movePacketMap = new NautHashMap(); private NautHashMap _moveTempMap = new NautHashMap(); @@ -71,6 +73,8 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler PacketPlayOutEntityTeleport.class, PacketPlayOutEntityMetadata.class, PacketPlayOutSpawnEntityLiving.class, PacketPlayOutUpdateAttributes.class, PacketPlayOutEntityEquipment.class, PacketPlayOutNamedSoundEffect.class); + INSTANCE = this; + try { _bedChunk = new Chunk(((CraftWorld) Bukkit.getWorlds().get(0)).getHandle(), 0, 0); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java index 3852f4451..b4734085b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java @@ -2,6 +2,9 @@ package mineplex.game.clans.clans.worldevent; import java.lang.reflect.Constructor; +import mineplex.minecraft.game.core.boss.ironwizard.GolemBoss; +import mineplex.minecraft.game.core.boss.slimeking.SlimeBoss; +import mineplex.minecraft.game.core.boss.spider.SpiderBoss; import org.bukkit.Location; import mineplex.game.clans.clans.worldevent.kinghill.KingHill; @@ -11,10 +14,11 @@ import mineplex.minecraft.game.core.boss.WorldEvent; public enum WorldEventType { - // SLIME_KING("Slime King", SlimeBoss.class, 30), -// KING_HILL("King of The Hill", KingHill.class, 30), - UNDEAD_CAMP("Undead Camp", UndeadCamp.class, 30);// , - // Golem("Iron Wizard", GolemBoss.class, 30); + SLIME_KING("Slime King", SlimeBoss.class, 30), + KING_HILL("King of The Hill", KingHill.class, 30), + UNDEAD_CAMP("Undead Camp", UndeadCamp.class, 30), + Golem("Iron Wizard",GolemBoss.class, 30), + BROOD_MOTHER("Brood Mother", SpiderBoss.class, 30); private String _name; private Class _clazz; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/kinghill/KingHill.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/kinghill/KingHill.java index 6b14c395f..d1aed67e0 100755 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/kinghill/KingHill.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/kinghill/KingHill.java @@ -7,6 +7,7 @@ import java.util.List; import java.util.Map; import mineplex.core.common.util.*; +import mineplex.minecraft.game.classcombat.Skill.SkillFactory; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; @@ -53,7 +54,7 @@ public class KingHill extends WorldEvent private long _lastOnHillMessage; private long _goldDrops; - public KingHill(WorldEventManager eventManager, Location centerLocation) + public KingHill(WorldEventManager eventManager, Location centerLocation, SkillFactory skillFactory) { super(eventManager.getClans().getDisguiseManager(), eventManager.getClans().getProjectile(), eventManager.getDamage(), eventManager.getBlockRestore(), eventManager.getClans().getCondition(), "King of the Hill", centerLocation); _clansManager = eventManager.getClans(); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/CustomItem.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/CustomItem.java index a16b7529b..02a71b2c4 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/CustomItem.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/CustomItem.java @@ -201,7 +201,7 @@ public class CustomItem implements Listener name += word.substring(0, 1).toUpperCase() + word.substring(1) + " "; } - return name; + return name.trim(); } public Material getMaterial() diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/AttributeContainer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/AttributeContainer.java index 8e1c17139..5b90f4fa4 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/AttributeContainer.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/AttributeContainer.java @@ -68,7 +68,7 @@ public class AttributeContainer if (_suffix != null) { - itemName += "of " + _suffix.getDisplayName(); + itemName += " of " + _suffix.getDisplayName(); } return itemName; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/HyperAxe.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/HyperAxe.java index c0bef5df0..7259f89e4 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/HyperAxe.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/HyperAxe.java @@ -55,7 +55,7 @@ public class HyperAxe extends LegendaryItem { event.SetIgnoreRate(true); - event.AddMod("Hyper Axe", 9); + event.AddMod("Hyper Axe", 5); _lastAttack = System.currentTimeMillis(); } else diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MeridianScepter.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MeridianScepter.java index 0ef767d7a..046d5749d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MeridianScepter.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MeridianScepter.java @@ -287,7 +287,7 @@ public class MeridianScepter extends LegendaryItem { _hit.getWorld().strikeLightningEffect(_hit.getLocation()); ClansManager.getInstance().getDamageManager().NewDamageEvent(_hit, _shooter, null, - DamageCause.CUSTOM, 6, false, true, true, + DamageCause.CUSTOM, 8, false, true, true, _shooter.getName(), "Meridian Scepter"); ClansManager.getInstance().getCondition().Factory().Blind("Meridian Scepter", _hit, _shooter, 1, 0, true, true, true); end(); diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemBoss.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemBoss.java index 2bb55096e..53168e9f5 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemBoss.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemBoss.java @@ -6,6 +6,7 @@ import mineplex.core.projectile.ProjectileManager; import mineplex.minecraft.game.core.boss.EventCreature; import mineplex.minecraft.game.core.boss.EventState; import mineplex.minecraft.game.core.boss.WorldEvent; +import mineplex.minecraft.game.core.condition.Condition; import mineplex.minecraft.game.core.condition.ConditionManager; import mineplex.minecraft.game.core.damage.DamageManager; @@ -15,10 +16,9 @@ import org.bukkit.Location; public class GolemBoss extends WorldEvent { - public GolemBoss(DisguiseManager disguiseManager, ProjectileManager projectileManager, DamageManager damageManager, - BlockRestore blockRestore, ConditionManager conditionManager, Location cornerLocation) + public GolemBoss(DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, ProjectileManager projectileManager, Location cornerLocation) { - super(disguiseManager, projectileManager, damageManager, blockRestore, conditionManager, "Iron Wizard", cornerLocation, "schematic/Golem.schematic"); + super(DisguiseManager.INSTANCE, projectileManager, damageManager, blockRestore, conditionManager, "Iron Wizard", cornerLocation, "schematic/Golem.schematic"); } @Override diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemCaveIn.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemCaveIn.java index 5f57bd4c9..622d52dc3 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemCaveIn.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemCaveIn.java @@ -223,108 +223,108 @@ public class GolemCaveIn extends BossAbility @Override public void tick() { - if (_tick++ == 0) - { - Location l = getLocation(); - - ArrayList blocks = UtilShapes.getSphereBlocks(l, 3, 3, true); - - for (Location loc : blocks) - { - if (loc.getBlockY() >= l.getBlockY()) - { - Block b = loc.getBlock(); - - if (b.getType() == Material.AIR) - { - _blocks.add(b); - - loc.setY(l.getY() - 1); - - b.setType(loc.getBlock().getType()); - - b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, loc.getBlock().getTypeId()); - } - } - } - } - - if (_tick % 5 == 0) - - { - for (Player player : UtilPlayer.getNearby(getLocation(), 2.5, true)) - { - player.teleport(player.getLocation().add(0, 4, 0)); - UtilAction.velocity(player, new Vector(UtilMath.r(10) - 5, 3, UtilMath.r(10) - 5).normalize()); - } - } - - if (_tick < 200) - - { - Location loc = getLocation(); - loc.setY(loc.getY() + 4); - - for (int i = 0; i < 30; i++) - { - loc.setY(loc.getY() + 1); - Block b = loc.getBlock(); - - if (UtilBlock.solid(b)) - { - break; - } - } - - if (!UtilBlock.solid(loc.getBlock())) - { - return; - } - - List players = UtilPlayer.getNearby(getLocation(), 50, true); - - for (int i = 0; i < players.size() * 4; i++) - { - int dist = UtilMath.r(10); - - if (dist < 3) - { - dist = 2; - } - else if (dist < 5) - { - dist = 5; - } - else - { - dist = 10; - } - - Location l = players.get(UtilMath.r(players.size())).getLocation().add(UtilMath.r(dist * 2) - dist, 0, - UtilMath.r(dist * 2) - dist); - l.setY(loc.getY()); - - Block b = l.getBlock(); - l.subtract(0, 1, 0); - - if (UtilBlock.solid(b)) - { - if (l.getBlock().getType() == Material.AIR) - { - if (UtilAlg.HasSight(l, getLocation().add(0, 4, 0))) - { - FallingBlock block = b.getWorld().spawnFallingBlock(b.getLocation().add(0.5, -1, 0.5), b.getTypeId(), - b.getData()); - - block.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, block.getBlockId()); - block.setDropItem(false); - - _fallingBlocks.add(block); - } - } - } - } - } +// if (_tick++ == 0) +// { +// Location l = getLocation(); +// +// ArrayList blocks = UtilShapes.getSphereBlocks(l, 3, 3, true); +// +// for (Location loc : blocks) +// { +// if (loc.getBlockY() >= l.getBlockY()) +// { +// Block b = loc.getBlock(); +// +// if (b.getType() == Material.AIR) +// { +// _blocks.add(b); +// +// loc.setY(l.getY() - 1); +// +// b.setType(loc.getBlock().getType()); +// +// b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, loc.getBlock().getTypeId()); +// } +// } +// } +// } +// +// if (_tick % 5 == 0) +// +// { +// for (Player player : UtilPlayer.getNearby(getLocation(), 2.5, true)) +// { +// player.teleport(player.getLocation().add(0, 4, 0)); +// UtilAction.velocity(player, new Vector(UtilMath.r(10) - 5, 3, UtilMath.r(10) - 5).normalize()); +// } +// } +// +// if (_tick < 200) +// +// { +// Location loc = getLocation(); +// loc.setY(loc.getY() + 4); +// +// for (int i = 0; i < 30; i++) +// { +// loc.setY(loc.getY() + 1); +// Block b = loc.getBlock(); +// +// if (UtilBlock.solid(b)) +// { +// break; +// } +// } +// +// if (!UtilBlock.solid(loc.getBlock())) +// { +// return; +// } +// +// List players = UtilPlayer.getNearby(getLocation(), 50, true); +// +// for (int i = 0; i < players.size() * 4; i++) +// { +// int dist = UtilMath.r(10); +// +// if (dist < 3) +// { +// dist = 2; +// } +// else if (dist < 5) +// { +// dist = 5; +// } +// else +// { +// dist = 10; +// } +// +// Location l = players.get(UtilMath.r(players.size())).getLocation().add(UtilMath.r(dist * 2) - dist, 0, +// UtilMath.r(dist * 2) - dist); +// l.setY(loc.getY()); +// +// Block b = l.getBlock(); +// l.subtract(0, 1, 0); +// +// if (UtilBlock.solid(b)) +// { +// if (l.getBlock().getType() == Material.AIR) +// { +// if (UtilAlg.HasSight(l, getLocation().add(0, 4, 0))) +// { +// FallingBlock block = b.getWorld().spawnFallingBlock(b.getLocation().add(0.5, -1, 0.5), b.getTypeId(), +// b.getData()); +// +// block.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, block.getBlockId()); +// block.setDropItem(false); +// +// _fallingBlocks.add(block); +// } +// } +// } +// } +// } } diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/slimeking/SlimeBoss.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/slimeking/SlimeBoss.java index 570fb0039..53f9d55ca 100755 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/slimeking/SlimeBoss.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/slimeking/SlimeBoss.java @@ -25,10 +25,9 @@ public class SlimeBoss extends WorldEvent private static final int MAX_SIZE = 16; private static final int MIN_SIZE = 2; - public SlimeBoss(DisguiseManager disguiseManager, ProjectileManager projectileManager, DamageManager damageManager, - BlockRestore blockRestore, ConditionManager conditionManager, Location cornerLocation) + public SlimeBoss(DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, ProjectileManager projectileManager, Location cornerLocation) { - super(disguiseManager, projectileManager, damageManager, blockRestore, conditionManager, "Slime King", cornerLocation, "schematic/ClansSlime.schematic"); + super(DisguiseManager.INSTANCE, projectileManager, damageManager, blockRestore, conditionManager, "Slime King", cornerLocation, "schematic/ClansSlime.schematic"); } @Override diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/SpiderBoss.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/SpiderBoss.java index cf2a16e35..c28fdf541 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/SpiderBoss.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/SpiderBoss.java @@ -29,10 +29,9 @@ public class SpiderBoss extends WorldEvent { private HashMap _webDurability = new HashMap(); - public SpiderBoss(DisguiseManager disguiseManager, ProjectileManager projectileManager, DamageManager damageManager, - BlockRestore blockRestore, ConditionManager conditionManager, Location cornerLocation) + public SpiderBoss(DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, ProjectileManager projectileManager, Location cornerLocation) { - super(disguiseManager, projectileManager, damageManager, blockRestore, conditionManager, "Brood Mother", cornerLocation, + super(DisguiseManager.INSTANCE, projectileManager, damageManager, blockRestore, conditionManager, "Brood Mother", cornerLocation, "schematic/Golem.schematic"); } From 1655811d4393d8735e483b791aacda39a9581884 Mon Sep 17 00:00:00 2001 From: samczsun Date: Sat, 2 Jul 2016 17:39:47 -0400 Subject: [PATCH 02/90] Added help messages to WorldEvent command --- .../clans/clans/worldevent/WorldEventManager.java | 14 ++++++++++---- .../clans/clans/worldevent/WorldEventType.java | 9 +++++++-- .../clans/worldevent/command/ClearCommand.java | 4 ++-- .../clans/worldevent/command/RandomCommand.java | 12 ++++++++++-- .../clans/worldevent/command/StartCommand.java | 12 ++++++++---- .../worldevent/command/WorldEventCommand.java | 6 +++++- 6 files changed, 42 insertions(+), 15 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java index a419b2d1c..981c34edf 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java @@ -137,18 +137,19 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement } } - public void randomEvent() + public WorldEventType randomEvent() { if (_runningEvents.size() == 0) { if (UtilServer.getPlayers().length > 0) { - tryStartEvent(); + return tryStartEvent(); } } + return null; } - private void tryStartEvent() + private WorldEventType tryStartEvent() { WorldEventType[] types = WorldEventType.values(); WorldEventType type = types[_random.nextInt(types.length)]; @@ -156,12 +157,14 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement if (location != null) { initializeEvent(type.createInstance(this, location, _skillFactory)); + return type; } else { // Try again in 5 minutes _nextEventStart = System.currentTimeMillis() + (5 * 60 * 1000); } + return null; } private void initializeEvent(WorldEvent event) @@ -194,7 +197,10 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement if (eventType != null) { WorldEvent event = eventType.createInstance(this, location, _skillFactory); - initializeEvent(event); + if (event != null) + { + initializeEvent(event); + } return event; } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java index b4734085b..42e822bc7 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java @@ -15,9 +15,9 @@ import mineplex.minecraft.game.core.boss.WorldEvent; public enum WorldEventType { SLIME_KING("Slime King", SlimeBoss.class, 30), - KING_HILL("King of The Hill", KingHill.class, 30), + KING_OF_THE_HILL("King of The Hill", KingHill.class, 30), UNDEAD_CAMP("Undead Camp", UndeadCamp.class, 30), - Golem("Iron Wizard",GolemBoss.class, 30), + IRON_WIZARD("Iron Wizard",GolemBoss.class, 30), BROOD_MOTHER("Brood Mother", SpiderBoss.class, 30); private String _name; @@ -74,4 +74,9 @@ public enum WorldEventType return worldEvent; } + + public String getName() + { + return this._name; + } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/ClearCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/ClearCommand.java index 18d845188..4439d2502 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/ClearCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/ClearCommand.java @@ -18,13 +18,13 @@ public class ClearCommand extends CommandBase { public ClearCommand(WorldEventManager plugin) { - super(plugin, Rank.EVENT, "clear"); + super(plugin, Rank.ADMIN, "clear"); } @Override public void Execute(Player caller, String[] args) { Plugin.clearEvents(); - UtilPlayer.message(caller, F.main("Clans", "All world events cleared!")); + UtilPlayer.message(caller, F.main(Plugin.getName(), "All world events cleared!")); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/RandomCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/RandomCommand.java index 9fd1762b8..ef9c08af2 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/RandomCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/RandomCommand.java @@ -17,12 +17,20 @@ public class RandomCommand extends CommandBase { public RandomCommand(WorldEventManager plugin) { - super(plugin, Rank.JNR_DEV, "random", "rand"); + super(plugin, Rank.ADMIN, "random", "rand"); } @Override public void Execute(Player caller, String[] args) { - Plugin.randomEvent(); + WorldEventType typeStarted = Plugin.randomEvent(); + if (typeStarted != null) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "Started " + F.name(typeStarted.getName()))); + } + else + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "Could not start World Event")); + } } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/StartCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/StartCommand.java index e808e9981..8020d49cb 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/StartCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/StartCommand.java @@ -14,7 +14,7 @@ public class StartCommand extends CommandBase { public StartCommand(WorldEventManager plugin) { - super(plugin, Rank.EVENT, "start", "create"); + super(plugin, Rank.ADMIN, "start", "create"); } @Override @@ -30,17 +30,21 @@ public class StartCommand extends CommandBase if (event == null) { - UtilPlayer.message(caller, F.main("WorldEvent", "Error whilst starting the world event you chose.")); + UtilPlayer.message(caller, F.main(Plugin.getName(), "Error whilst starting the world event you chose.")); } else { - UtilPlayer.message(caller, F.main("worldEvent", "Started WorldEvent " + F.elem(args[0]) + " at your current location")); + UtilPlayer.message(caller, F.main(Plugin.getName(), "Started WorldEvent " + F.elem(args[0]) + " at your current location")); } } catch (IllegalArgumentException e) { - UtilPlayer.message(caller, F.main("WorldEvent", "Could not find a WorldEvent with the name " + F.elem(args[0]))); + UtilPlayer.message(caller, F.main(Plugin.getName(), "Could not find a WorldEvent with the name " + F.elem(args[0]))); } } + else + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "No World Event type specified")); + } } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/WorldEventCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/WorldEventCommand.java index 73d55f096..e52b389b3 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/WorldEventCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/WorldEventCommand.java @@ -1,5 +1,7 @@ package mineplex.game.clans.clans.worldevent.command; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; import org.bukkit.entity.Player; import mineplex.core.command.MultiCommandBase; @@ -20,7 +22,9 @@ public class WorldEventCommand extends MultiCommandBase @Override protected void Help(Player caller, String[] args) { - + UtilPlayer.message(caller, F.help("/" + _aliasUsed + " start ", "Start a World Event where you're standing", Rank.ADMIN)); + UtilPlayer.message(caller, F.help("/" + _aliasUsed + " clear", "Clears all World Events", Rank.ADMIN)); + UtilPlayer.message(caller, F.help("/" + _aliasUsed + " random", "Starts a random World Event", Rank.ADMIN)); } } From d4be749edc098ff12da94ec795085b61384ac89d Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 2 Jul 2016 17:39:04 -0400 Subject: [PATCH 03/90] Update Iron Wizard attack priority to use Earthquake when surrounded, lower blocks thrown during Cave In and implement Iron Skin arrow resistance --- .../core/boss/ironwizard/GolemCreature.java | 22 +- .../ironwizard/abilities/GolemCaveIn.java | 204 +++++++++--------- 2 files changed, 123 insertions(+), 103 deletions(-) diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemCreature.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemCreature.java index 06f1dc23d..bd311f6bf 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemCreature.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemCreature.java @@ -6,6 +6,7 @@ import java.util.Comparator; import java.util.HashMap; import java.util.Iterator; import java.util.Map.Entry; +import java.util.Random; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; @@ -30,7 +31,9 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent; import org.bukkit.Bukkit; import org.bukkit.Location; +import org.bukkit.Sound; import org.bukkit.block.BlockFace; +import org.bukkit.entity.Arrow; import org.bukkit.entity.IronGolem; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -153,7 +156,14 @@ public class GolemCreature extends EventCreature if (!players.isEmpty()) { - weight.put(GolemMeleeAttack.class, 999); + if (players.size() >= 4) + { + weight.put(GolemEarthquake.class, 999); + } + else + { + weight.put(GolemMeleeAttack.class, 999); + } } } @@ -502,6 +512,16 @@ public class GolemCreature extends EventCreature { if (event.GetDamageePlayer() != null) { + if (event.GetProjectile() != null && event.GetProjectile() instanceof Arrow) + { + if (new Random().nextDouble() <= .5) + { + event.SetCancelled("Iron Skin Reflection"); + getEntity().getWorld().playSound(getEntity().getLocation(), Sound.ZOMBIE_METAL, 0.5f, 1.6f); + return; + } + } + double dist = event.GetDamageePlayer().getLocation().distance(getEntity().getLocation()); double maxRange = _usedFinalAttack ? 20 : 45; diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemCaveIn.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemCaveIn.java index 622d52dc3..6b6e0a11a 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemCaveIn.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemCaveIn.java @@ -223,108 +223,108 @@ public class GolemCaveIn extends BossAbility @Override public void tick() { -// if (_tick++ == 0) -// { -// Location l = getLocation(); -// -// ArrayList blocks = UtilShapes.getSphereBlocks(l, 3, 3, true); -// -// for (Location loc : blocks) -// { -// if (loc.getBlockY() >= l.getBlockY()) -// { -// Block b = loc.getBlock(); -// -// if (b.getType() == Material.AIR) -// { -// _blocks.add(b); -// -// loc.setY(l.getY() - 1); -// -// b.setType(loc.getBlock().getType()); -// -// b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, loc.getBlock().getTypeId()); -// } -// } -// } -// } -// -// if (_tick % 5 == 0) -// -// { -// for (Player player : UtilPlayer.getNearby(getLocation(), 2.5, true)) -// { -// player.teleport(player.getLocation().add(0, 4, 0)); -// UtilAction.velocity(player, new Vector(UtilMath.r(10) - 5, 3, UtilMath.r(10) - 5).normalize()); -// } -// } -// -// if (_tick < 200) -// -// { -// Location loc = getLocation(); -// loc.setY(loc.getY() + 4); -// -// for (int i = 0; i < 30; i++) -// { -// loc.setY(loc.getY() + 1); -// Block b = loc.getBlock(); -// -// if (UtilBlock.solid(b)) -// { -// break; -// } -// } -// -// if (!UtilBlock.solid(loc.getBlock())) -// { -// return; -// } -// -// List players = UtilPlayer.getNearby(getLocation(), 50, true); -// -// for (int i = 0; i < players.size() * 4; i++) -// { -// int dist = UtilMath.r(10); -// -// if (dist < 3) -// { -// dist = 2; -// } -// else if (dist < 5) -// { -// dist = 5; -// } -// else -// { -// dist = 10; -// } -// -// Location l = players.get(UtilMath.r(players.size())).getLocation().add(UtilMath.r(dist * 2) - dist, 0, -// UtilMath.r(dist * 2) - dist); -// l.setY(loc.getY()); -// -// Block b = l.getBlock(); -// l.subtract(0, 1, 0); -// -// if (UtilBlock.solid(b)) -// { -// if (l.getBlock().getType() == Material.AIR) -// { -// if (UtilAlg.HasSight(l, getLocation().add(0, 4, 0))) -// { -// FallingBlock block = b.getWorld().spawnFallingBlock(b.getLocation().add(0.5, -1, 0.5), b.getTypeId(), -// b.getData()); -// -// block.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, block.getBlockId()); -// block.setDropItem(false); -// -// _fallingBlocks.add(block); -// } -// } -// } -// } -// } + if (_tick++ == 0) + { + Location l = getLocation(); + + ArrayList blocks = UtilShapes.getSphereBlocks(l, 3, 3, true); + + for (Location loc : blocks) + { + if (loc.getBlockY() >= l.getBlockY()) + { + Block b = loc.getBlock(); + + if (b.getType() == Material.AIR) + { + _blocks.add(b); + + loc.setY(l.getY() - 1); + + b.setType(loc.getBlock().getType()); + + b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, loc.getBlock().getTypeId()); + } + } + } + } + + if (_tick % 5 == 0) + + { + for (Player player : UtilPlayer.getNearby(getLocation(), 2.5, true)) + { + player.teleport(player.getLocation().add(0, 4, 0)); + UtilAction.velocity(player, new Vector(UtilMath.r(10) - 5, 3, UtilMath.r(10) - 5).normalize()); + } + } + + if (_tick < 200) + + { + Location loc = getLocation(); + loc.setY(loc.getY() + 4); + + for (int i = 0; i < 30; i++) + { + loc.setY(loc.getY() + 1); + Block b = loc.getBlock(); + + if (UtilBlock.solid(b)) + { + break; + } + } + + if (!UtilBlock.solid(loc.getBlock())) + { + return; + } + + List players = UtilPlayer.getNearby(getLocation(), 50, true); + + for (int i = 0; i < players.size() * 2; i++) + { + int dist = UtilMath.r(10); + + if (dist < 3) + { + dist = 2; + } + else if (dist < 5) + { + dist = 5; + } + else + { + dist = 10; + } + + Location l = players.get(UtilMath.r(players.size())).getLocation().add(UtilMath.r(dist * 2) - dist, 0, + UtilMath.r(dist * 2) - dist); + l.setY(loc.getY()); + + Block b = l.getBlock(); + l.subtract(0, 1, 0); + + if (UtilBlock.solid(b)) + { + if (l.getBlock().getType() == Material.AIR) + { + if (UtilAlg.HasSight(l, getLocation().add(0, 4, 0))) + { + FallingBlock block = b.getWorld().spawnFallingBlock(b.getLocation().add(0.5, -1, 0.5), b.getTypeId(), + b.getData()); + + block.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, block.getBlockId()); + block.setDropItem(false); + + _fallingBlocks.add(block); + } + } + } + } + } } From 32c91e2e0c804f866a5ec45ab3f8e1198e881561 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 2 Jul 2016 17:52:04 -0400 Subject: [PATCH 04/90] Make start command more informative --- .../clans/worldevent/command/StartCommand.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/StartCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/StartCommand.java index 8020d49cb..d5090804b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/StartCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/StartCommand.java @@ -4,6 +4,7 @@ import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; +import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.game.clans.clans.worldevent.WorldEventManager; @@ -39,12 +40,20 @@ public class StartCommand extends CommandBase } catch (IllegalArgumentException e) { - UtilPlayer.message(caller, F.main(Plugin.getName(), "Could not find a WorldEvent with the name " + F.elem(args[0]))); + UtilPlayer.message(caller, F.main(Plugin.getName(), "Could not find a WorldEvent with the name " + F.elem(args[0]) + "! Available types:")); + for (WorldEventType type : WorldEventType.values()) + { + UtilPlayer.message(caller, C.cBlue + "- " + C.cGray + type.toString()); + } } } else { - UtilPlayer.message(caller, F.main(Plugin.getName(), "No World Event type specified")); + UtilPlayer.message(caller, F.main(Plugin.getName(), "No World Event type specified. Available types:")); + for (WorldEventType type : WorldEventType.values()) + { + UtilPlayer.message(caller, C.cBlue + "- " + C.cGray + type.toString()); + } } } } From 9898b3d95de9e4894c4ad536c6f7b4dc4812b283 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 2 Jul 2016 18:02:59 -0400 Subject: [PATCH 05/90] Fix block state not saving on restore (Untested) (PC-610) --- .../src/mineplex/core/blockrestore/BlockRestoreData.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestoreData.java b/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestoreData.java index 9a22c4358..534362923 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestoreData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestoreData.java @@ -6,6 +6,7 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.block.BlockState; public class BlockRestoreData { @@ -23,6 +24,8 @@ public class BlockRestoreData protected long _meltDelay = 0; protected long _meltLast = 0; + protected BlockState _fromState; + protected HashMap _pad = new HashMap(); protected boolean _restoreOnBreak; @@ -30,6 +33,7 @@ public class BlockRestoreData public BlockRestoreData(Block block, int toID, byte toData, int fromID, byte fromData, long expireDelay, long meltDelay, boolean restoreOnBreak) { _block = block; + _fromState = block.getState(); _fromID = fromID; _fromData = fromData; @@ -163,6 +167,8 @@ public class BlockRestoreData public void restore() { _block.setTypeIdAndData(_fromID, _fromData, true); + _fromState.update(); + handleLilypad(true); } From ffdc7b4be0067a870f257174d2124d8db217aa1e Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 2 Jul 2016 18:05:26 -0400 Subject: [PATCH 06/90] Temporarily patch random nullpointer --- .../src/mineplex/core/blockrestore/BlockRestore.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestore.java b/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestore.java index cbffb8a05..be61ca417 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestore.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestore.java @@ -160,7 +160,13 @@ public class BlockRestore extends MiniPlugin public void add(Block block, int toID, byte toData, int fromID, byte fromData, long expireTime, boolean restoreOnBreak) { if (!contains(block)) getBlocks().put(block, new BlockRestoreData(block, toID, toData, fromID, fromData, expireTime, 0, restoreOnBreak)); - else getData(block).update(toID, toData, expireTime); + else + { + if (getData(block) != null) + { + getData(block).update(toID, toData, expireTime); + } + } } public void snow(Block block, byte heightAdd, byte heightMax, long expireTime, long meltDelay, int heightJumps) From 1ce6f3f65f010ae7f3490954090020eef1c68c13 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 2 Jul 2016 18:16:04 -0400 Subject: [PATCH 07/90] Stop webs from editing banners (PC-610) --- .../mineplex/minecraft/game/classcombat/item/Throwable/Web.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Throwable/Web.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Throwable/Web.java index 023afeb5c..55e9929bb 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Throwable/Web.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Throwable/Web.java @@ -88,6 +88,6 @@ public class Web extends ItemUsable WebTossEvent webEvent = new WebTossEvent(thrower, location); Bukkit.getPluginManager().callEvent(webEvent); - return !webEvent.isCancelled() && UtilBlock.airFoliage(location.getBlock()); + return !webEvent.isCancelled() && UtilBlock.airFoliage(location.getBlock()) && !location.getBlock().getType().toString().contains("BANNER"); } } From b3c230082a0f3339c9de9579d9cf03ebc312f724 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 2 Jul 2016 18:34:35 -0400 Subject: [PATCH 08/90] Allowed Meridian Scepter to damage non-player entities --- .../items/legendaries/MeridianScepter.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MeridianScepter.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MeridianScepter.java index 046d5749d..0075f836f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MeridianScepter.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MeridianScepter.java @@ -93,22 +93,22 @@ public class MeridianScepter extends LegendaryItem { for (Entity cur : projectile.getWorld().getEntities()) { - if (cur == shooter || !(cur instanceof Player) || (cur instanceof Player && UtilPlayer.isSpectator(cur))) + if (cur == shooter || !(cur instanceof LivingEntity) || (cur instanceof Player && UtilPlayer.isSpectator(cur))) continue; - Player player = (Player) cur; + LivingEntity ent = (LivingEntity) cur; // If they are less than 0.5 blocks away - if (player.getEyeLocation().subtract(0, .3, 0).distance(projectile) <= 2) + if (ent.getEyeLocation().subtract(0, .3, 0).distance(projectile) <= 2) { - AttackAnimation aa = new AttackAnimation(player, shooter); + AttackAnimation aa = new AttackAnimation(ent, shooter); int i = UtilServer.getServer().getScheduler().scheduleSyncRepeatingTask(UtilServer.getPlugin(), () -> { aa.update(); }, 0, 1); _animations.put(aa, i); - UtilPlayer.message(player, F.main("Clans", F.elem(shooter.getName()) + " hit you with a " + F.elem("Meridian Scepter") + C.mBody + ".")); - UtilPlayer.message(shooter, F.main("Clans", "You hit " + F.elem(player.getName()) + " with your " + F.elem("Meridian Scepter") + C.mBody + ".")); + UtilPlayer.message(ent, F.main("Clans", F.elem(shooter.getName()) + " hit you with a " + F.elem("Meridian Scepter") + C.mBody + ".")); + UtilPlayer.message(shooter, F.main("Clans", "You hit " + F.elem(ent.getName()) + " with your " + F.elem("Meridian Scepter") + C.mBody + ".")); } } @@ -254,12 +254,13 @@ public class MeridianScepter extends LegendaryItem private class AttackAnimation { - private Player _hit, _shooter; + private LivingEntity _hit; + private Player _shooter; private double _step; private double _radius; private long _start, _lastStepIncrease; - public AttackAnimation(Player hit, Player shooter) + public AttackAnimation(LivingEntity hit, Player shooter) { _step = 0; _start = System.currentTimeMillis(); @@ -271,7 +272,7 @@ public class MeridianScepter extends LegendaryItem public void update() { - if (_hit == null) + if (_hit == null || !_hit.isValid() || _hit.isDead() || ((_hit instanceof Player) && !((Player)_hit).isOnline())) { end(); return; From ceb62f8dc9506d45a3ba83c339bd9c13ea6a47d9 Mon Sep 17 00:00:00 2001 From: samczsun Date: Sat, 2 Jul 2016 18:41:11 -0400 Subject: [PATCH 09/90] Fix lore --- .../src/mineplex/game/clans/items/GearManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java index 43849130c..4a9bab7a9 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java @@ -667,7 +667,7 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable List cleansed = new ArrayList<>(); for (String s : input) { - if (s.startsWith(ITEM_SERIALIZATION_TAG)) + if (!s.startsWith(ITEM_SERIALIZATION_TAG)) { cleansed.add(s); } From d0a8ee18c0818cac36caa54c61d733e35323ff8f Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 2 Jul 2016 19:07:55 -0400 Subject: [PATCH 10/90] Fix concurrent modification error caused by poison looping every tick --- .../mineplex/game/clans/items/GearManager.java | 4 ++-- .../game/core/condition/ConditionEffect.java | 18 +++++++++++------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java index 4a9bab7a9..ac12981a6 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java @@ -92,14 +92,14 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable private static final Gson GSON; // Weightings for randomly selecting number of attributes (1, 2, 3) - private static final WeightSet ATTRIBUTE_WEIGHTS = new WeightSet<>( + private static final WeightSet ATTRIBUTE_WEIGHTS = new WeightSet( new Weight<>(3, 3), new Weight<>(20, 2), new Weight<>(77, 1) ); // Weightings for randomly selecting item type (legendary/weapon/armor/bow) - private static final WeightSet TYPE_WEIGHTS = new WeightSet<>( + private static final WeightSet TYPE_WEIGHTS = new WeightSet( new Weight<>(6, ItemType.LEGENDARY), new Weight<>(9, ItemType.RARE), new Weight<>(46 - 9, ItemType.ARMOR), diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/ConditionEffect.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/ConditionEffect.java index c976c0a54..427680a56 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/ConditionEffect.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/ConditionEffect.java @@ -1,13 +1,15 @@ package mineplex.minecraft.game.core.condition; -import mineplex.minecraft.game.core.condition.Condition.ConditionType; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import mineplex.core.recharge.Recharge; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.core.updater.UpdateType; -import mineplex.core.visibility.VisibilityManager; +import java.util.Iterator; + 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 mineplex.core.visibility.VisibilityManager; +import mineplex.minecraft.game.core.condition.Condition.ConditionType; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; import org.bukkit.Bukkit; import org.bukkit.Effect; @@ -371,8 +373,10 @@ public class ConditionEffect implements Listener if (event.getType() != UpdateType.TICK) return; - for (LivingEntity ent : Manager.GetActiveConditions().keySet()) + Iterator ents = Manager.GetActiveConditions().keySet().iterator(); + while (ents.hasNext()) { + LivingEntity ent = ents.next(); Condition condition = Manager.GetActiveCondition(ent, ConditionType.POISON_SHOCK); if (condition == null || condition.GetSource() == null) continue; From af9d91faa88bdedc63b5e2f56dc60a268dbdd070 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sun, 3 Jul 2016 04:11:14 -0400 Subject: [PATCH 11/90] Further prevent nullpointer errors --- .../src/mineplex/core/blockrestore/BlockRestore.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestore.java b/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestore.java index be61ca417..bea07b8e5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestore.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestore.java @@ -174,7 +174,8 @@ public class BlockRestore extends MiniPlugin //Fill Above if (((block.getTypeId() == 78 && block.getData() >= (byte)7) || block.getTypeId() == 80) && getData(block) != null) { - getData(block).update(78, heightAdd, expireTime, meltDelay); + if (getData(block) != null) + getData(block).update(78, heightAdd, expireTime, meltDelay); if (heightJumps > 0) snow(block.getRelative(BlockFace.UP), heightAdd, heightMax, expireTime, meltDelay, heightJumps - 1); if (heightJumps == -1) snow(block.getRelative(BlockFace.UP), heightAdd, heightMax, expireTime, meltDelay, -1); @@ -219,8 +220,11 @@ public class BlockRestore extends MiniPlugin //Snow if (!contains(block)) getBlocks().put(block, new BlockRestoreData(block, 78, (byte) Math.max(0, heightAdd - 1), block.getTypeId(), block.getData(), expireTime, meltDelay, false)); - else - getData(block).update(78, heightAdd, expireTime, meltDelay); + else + { + if (getData(block) != null) + getData(block).update(78, heightAdd, expireTime, meltDelay); + } } public boolean contains(Block block) From caf7e1086d5f9e006fd13e9c1218896347c27dbf Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sun, 3 Jul 2016 04:12:05 -0400 Subject: [PATCH 12/90] Completely revamp Iron Wizard boss, add spawn and despawn messages, and retire attacks that no longer fit the arena --- .../abilities/GolemDeadlyTremor.java | 89 +++++++++ .../ironwizard/abilities/GolemIronHook.java | 170 ++++++++++++++++++ .../boss/ironwizard/abilities/GolemSpike.java | 105 +++++++++++ .../ironwizard/abilities/GroundSpike.java | 102 +++++++++++ .../boss/ironwizard/abilities/IronHook.java | 54 ++++++ 5 files changed, 520 insertions(+) create mode 100644 Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemDeadlyTremor.java create mode 100644 Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemIronHook.java create mode 100644 Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemSpike.java create mode 100644 Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GroundSpike.java create mode 100644 Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/IronHook.java diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemDeadlyTremor.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemDeadlyTremor.java new file mode 100644 index 000000000..fb15c7567 --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemDeadlyTremor.java @@ -0,0 +1,89 @@ +package mineplex.minecraft.game.core.boss.ironwizard.abilities; + +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.minecraft.game.core.boss.BossAbility; +import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature; + +import org.bukkit.Effect; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.IronGolem; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.util.Vector; + +public class GolemDeadlyTremor extends BossAbility +{ + private static final long ATTACK_DURATION = 16000; + private long _start; + + public GolemDeadlyTremor(GolemCreature creature) + { + super(creature); + _start = System.currentTimeMillis(); + } + + @Override + public boolean canMove() + { + return false; + } + + @Override + public boolean inProgress() + { + return true; + } + + @Override + public boolean hasFinished() + { + return UtilTime.elapsed(_start, ATTACK_DURATION); + } + + @Override + public void setFinished() + { + _start = System.currentTimeMillis() - ATTACK_DURATION; + } + + @Override + public void tick() + { + for (Player player : UtilPlayer.getInRadius(getLocation(), 80).keySet()) + { + player.playSound(player.getLocation(), Sound.MINECART_BASE, 0.2f, 0.2f); + + if (UtilEnt.isGrounded(player)) + { + getBoss().getEvent().getDamageManager().NewDamageEvent(player, getBoss().getEntity(), null, DamageCause.CUSTOM, (1 + 2 * Math.random()) * getBoss().getDifficulty(), false, false, false, getBoss().getEntity().getName(), "Deadly Tremor"); + + if (Recharge.Instance.use(player, "Deadly Tremor 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); + } + } + + 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()); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemIronHook.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemIronHook.java new file mode 100644 index 000000000..fb8ffd2cc --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemIronHook.java @@ -0,0 +1,170 @@ +package mineplex.minecraft.game.core.boss.ironwizard.abilities; + +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.updater.UpdateType; +import mineplex.minecraft.game.core.boss.BossAbility; +import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature; + +import org.bukkit.Bukkit; +import org.bukkit.GameMode; +import org.bukkit.Sound; +import org.bukkit.entity.IronGolem; +import org.bukkit.entity.Item; +import org.bukkit.entity.Player; + +import com.google.common.collect.Lists; + +//2-3 people +//5 impact damage +//High pull velocity +//40 block range +public class GolemIronHook extends BossAbility +{ + private static final Integer MAX_TARGETS = 3; + private boolean _shot, _complete; + + private List _hooks = Lists.newArrayList(); + + public GolemIronHook(GolemCreature creature) + { + super(creature); + _shot = false; + _complete = false; + } + + private int getPosition(Player toAdd, LinkedList ordered, HashMap distances) + { + int position = ordered.size(); + int index = 0; + for (Player player : ordered) + { + if (distances.get(player) < distances.get(toAdd)) + { + position = index; + } + index++; + } + + return position; + } + + private void shoot() + { + IronGolem wizard = getBoss().getEntity(); + LinkedList selections = new LinkedList<>(); + List targeted = Lists.newArrayList(); + + HashMap near = UtilPlayer.getInRadius(wizard.getLocation(), 40D); + + for (Player nearby : near.keySet()) + { + if (nearby.getGameMode() == GameMode.CREATIVE || nearby.getGameMode() == GameMode.SPECTATOR) + { + continue; + } + + if (selections.isEmpty()) + { + selections.addFirst(nearby); + } + else + { + selections.add(getPosition(nearby, selections, near), nearby); + } + } + + for (int i = 0; i < MAX_TARGETS; i++) + { + if (i < selections.size()) + { + targeted.add(selections.get(i)); + } + } + + if (targeted.isEmpty()) + { + _complete = true; + setFinished(); + return; + } + + for (Player target : targeted) + { + Item item = wizard.getWorld().dropItem(wizard.getEyeLocation().add(UtilAlg.getTrajectory(wizard, target)), ItemStackFactory.Instance.CreateStack(131)); + UtilAction.velocity(item, UtilAlg.getTrajectory(wizard, target).normalize(), + 2, false, 0, 0.2, 20, false); + + getBoss().getEvent().getProjectileManager().AddThrow(item, getBoss().getEntity(), new IronHook(getBoss().getEvent()), -1, true, true, true, true, + Sound.FIRE_IGNITE, 1.4f, 0.8f, ParticleType.CRIT, UpdateType.TICK, 1f); + + item.getWorld().playSound(item.getLocation(), Sound.IRONGOLEM_THROW, 2f, 0.8f); + _hooks.add(item); + } + } + + @Override + public int getCooldown() + { + return 10; + } + + @Override + public boolean canMove() + { + return true; + } + + @Override + public boolean inProgress() + { + return false; + } + + @Override + public boolean hasFinished() + { + return _complete; + } + + @Override + public void setFinished() + { + for (Item hook : _hooks) + { + if (!hook.isDead() && hook.isValid()) + { + getBoss().getEvent().getProjectileManager().deleteThrown(hook); + hook.remove(); + } + } + + _hooks.clear(); + } + + @Override + public void tick() + { + if (_shot) + { + return; + } + shoot(); + _shot = true; + Bukkit.getScheduler().runTaskLater(getBoss().getEvent().getPlugin(), new Runnable() + { + public void run() + { + _complete = true; + setFinished(); + } + }, 2 * 20); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemSpike.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemSpike.java new file mode 100644 index 000000000..4059bb4e9 --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemSpike.java @@ -0,0 +1,105 @@ +package mineplex.minecraft.game.core.boss.ironwizard.abilities; + +import java.util.List; +import java.util.Random; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.minecraft.game.core.boss.BossAbility; +import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature; + +import org.bukkit.Sound; +import org.bukkit.entity.IronGolem; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.util.Vector; + +import com.google.common.collect.Lists; + +public class GolemSpike extends BossAbility +{ + private static final int SPIKE_HEIGHT = 2; + private static final long ATTACK_DURATION = 1000 + (500 * SPIKE_HEIGHT * 2); + private static final long SPIKE_REMAIN = 1000; + private long _start; + private List _spikes; + + public GolemSpike(GolemCreature creature) + { + super(creature); + _start = System.currentTimeMillis(); + _spikes = Lists.newArrayList(); + } + + @Override + public int getCooldown() + { + return 15; + } + + @Override + public boolean canMove() + { + return true; + } + + @Override + public boolean inProgress() + { + return true; + } + + @Override + public boolean hasFinished() + { + return UtilTime.elapsed(_start, ATTACK_DURATION) && _spikes.isEmpty(); + } + + @Override + public void setFinished() + { + _start = System.currentTimeMillis() - ATTACK_DURATION; + for (GroundSpike spike : _spikes) + { + spike.finish(); + } + _spikes.clear(); + } + + @Override + public void tick() + { + if (_spikes.isEmpty()) + { + for (Player player : UtilPlayer.getInRadius(getLocation(), 20).keySet()) + { + if (UtilEnt.isGrounded(player)) + { + player.playSound(player.getLocation(), Sound.STEP_STONE, 0.2f, 0.2f); + getBoss().getEvent().getDamageManager().NewDamageEvent(player, getBoss().getEntity(), null, DamageCause.CUSTOM, 5 * getBoss().getDifficulty(), false, false, false, getBoss().getEntity().getName(), "Stone Spike"); + player.teleport(player.getLocation().add(0, SPIKE_HEIGHT, 0)); + UtilAction.velocity(player, player.getLocation().toVector().normalize().add(new Vector(0, 0.02, 0)).normalize()); + _spikes.add(new GroundSpike(player.getLocation().getBlock(), player.getLocation().getBlock().getRelative(0, -1, 0).getType(), new Random().nextInt(SPIKE_HEIGHT) + 2, SPIKE_REMAIN)); + } + } + } + else + { + List toRemove = Lists.newArrayList(); + for (GroundSpike spike : _spikes) + { + spike.tick(); + if (spike.isFinished()) + { + toRemove.add(spike); + } + } + for (GroundSpike remove : toRemove) + { + _spikes.remove(remove); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GroundSpike.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GroundSpike.java new file mode 100644 index 000000000..8aedd94de --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GroundSpike.java @@ -0,0 +1,102 @@ +package mineplex.minecraft.game.core.boss.ironwizard.abilities; + +import java.util.LinkedList; + +import mineplex.core.common.util.UtilTime; + +import org.bukkit.Material; +import org.bukkit.block.Block; + +public class GroundSpike +{ + private Block _initial; + private Material _type; + private int _max, _height; + private long _lastTick, _remain; + private LinkedList _blocks; + private boolean _shrinking, _finished; + + public GroundSpike(Block first, Material type, int maxHeight, long remainDuration) + { + _initial = first; + _type = type; + _height = 0; + _max = maxHeight; + _remain = remainDuration; + _lastTick = System.currentTimeMillis(); + _blocks = new LinkedList<>(); + _shrinking = false; + _finished = false; + } + + private void raise() + { + if ((_height + 1) < _max) + { + _lastTick = System.currentTimeMillis(); + Block b = _initial.getRelative(0, _height, 0); + b.setType(_type); + _blocks.add(b); + _height++; + } + else + { + if (UtilTime.elapsed(_lastTick, _remain)) + { + _shrinking = true; + lower(); + } + } + } + + private void lower() + { + _height = Math.min(_blocks.size() - 1, _height); + if ((_height - 1) >= 0) + { + _lastTick = System.currentTimeMillis(); + _blocks.get(_height).setType(Material.AIR); + _blocks.remove(_height); + _height--; + } + else + { + finish(); + } + } + + public boolean isFinished() + { + if (!_blocks.isEmpty()) + return false; + + return _finished; + } + + public void finish() + { + _finished = true; + for (Block block : _blocks) + { + block.setType(Material.AIR); + } + _blocks.clear(); + } + + public void tick() + { + if (isFinished()) + return; + if (!UtilTime.elapsed(_lastTick, 500)) + return; + + if (_shrinking) + { + lower(); + } + else + { + raise(); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/IronHook.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/IronHook.java new file mode 100644 index 000000000..9c402dab6 --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/IronHook.java @@ -0,0 +1,54 @@ +package mineplex.minecraft.game.core.boss.ironwizard.abilities; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.projectile.IThrown; +import mineplex.core.projectile.ProjectileUser; +import mineplex.minecraft.game.core.boss.WorldEvent; + +import org.bukkit.block.Block; +import org.bukkit.entity.IronGolem; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +public class IronHook implements IThrown +{ + private WorldEvent _host; + + public IronHook(WorldEvent event) + { + _host = event; + } + + @Override + public void Collide(LivingEntity target, Block block, ProjectileUser data) + { + data.getThrown().remove(); + + if (!(data.getThrower() instanceof IronGolem)) + return; + + IronGolem wizard = (IronGolem)data.getThrower(); + + if (target == null) + return; + + UtilAction.velocity(target, UtilAlg.getTrajectory(target.getLocation(), wizard.getLocation()), 5, false, 0, 0.7, 1.2, true); + + _host.getCondition().Factory().Falling("Iron Hook", target, wizard, 10, false, true); + + _host.getDamageManager().NewDamageEvent(target, wizard, null, DamageCause.CUSTOM, 5, false, true, false, wizard.getName(), "Iron Hook"); + } + + @Override + public void Idle(ProjectileUser data) + { + data.getThrown().remove(); + } + + @Override + public void Expire(ProjectileUser data) + { + data.getThrown().remove(); + } +} \ No newline at end of file From 37d11cdd60ebfa494518a6d5ef42bc286b5f0a3c Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sun, 3 Jul 2016 05:41:59 -0400 Subject: [PATCH 13/90] Make Meridian Scepter stronger --- .../game/clans/items/legendaries/MeridianScepter.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MeridianScepter.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MeridianScepter.java index 0075f836f..26003be99 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MeridianScepter.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MeridianScepter.java @@ -17,7 +17,6 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilShapes; import mineplex.core.common.util.UtilText; import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.recharge.Recharge; import mineplex.game.clans.clans.ClansManager; @@ -67,7 +66,7 @@ public class MeridianScepter extends LegendaryItem return; } - if (Recharge.Instance.use(wielder, "Meridian Scepter", 4000, true, true)) + if (Recharge.Instance.use(wielder, "Meridian Scepter", 2000, true, true)) { fire(wielder); @@ -199,7 +198,7 @@ public class MeridianScepter extends LegendaryItem Vector newDirection = closestPlayer.getLocation().add(0, 1, 0).toVector() .subtract(projectile.toVector()); - direction.add(newDirection.normalize().multiply(0.01)).normalize().multiply(0.15); + direction.add(newDirection.normalize().multiply(0.02)).normalize().multiply(0.25); } projectile.add(direction); @@ -277,20 +276,20 @@ public class MeridianScepter extends LegendaryItem end(); return; } - if (UtilTime.elapsed(_lastStepIncrease, UtilTime.convert(1, TimeUnit.SECONDS, TimeUnit.MILLISECONDS))) + if (UtilTime.elapsed(_lastStepIncrease, 500)) { _step++; _lastStepIncrease = System.currentTimeMillis(); } drawHelix(); - if (UtilTime.elapsed(_start, 4000)) + if (UtilTime.elapsed(_start, 2000)) { _hit.getWorld().strikeLightningEffect(_hit.getLocation()); ClansManager.getInstance().getDamageManager().NewDamageEvent(_hit, _shooter, null, DamageCause.CUSTOM, 8, false, true, true, _shooter.getName(), "Meridian Scepter"); - ClansManager.getInstance().getCondition().Factory().Blind("Meridian Scepter", _hit, _shooter, 1, 0, true, true, true); + ClansManager.getInstance().getCondition().Factory().Blind("Meridian Scepter", _hit, _shooter, 3, 0, true, true, false); end(); return; } From e57910985cea4aa2ffa97d4537432aae455f32be Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sun, 3 Jul 2016 05:42:44 -0400 Subject: [PATCH 14/90] Change earthquake animations --- .../game/core/boss/ironwizard/abilities/GolemEarthquake.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemEarthquake.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemEarthquake.java index 1d06110c2..7633b145c 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemEarthquake.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemEarthquake.java @@ -105,7 +105,7 @@ public class GolemEarthquake extends BossAbility } } - _center.getWorld().playSound(_center, Sound.DIG_GRASS, 2, 0.8F); + _center.getWorld().playSound(_center, Sound.DIG_STONE, 2, 0.8F); HashSet toDamage = new HashSet(); From f1733875ebf2379313f977966789650583eae45d Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sun, 3 Jul 2016 05:43:05 -0400 Subject: [PATCH 15/90] Change rupture animation --- .../game/core/boss/ironwizard/abilities/GolemRupture.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemRupture.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemRupture.java index ba93748e5..670ffc8e0 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemRupture.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemRupture.java @@ -348,7 +348,7 @@ public class GolemRupture extends BossAbility _items.add(item); // Effect - loc.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.DIRT.getId()); + loc.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.STONE.getId()); done++; } From 28853feb73aaf8a3e523fa33a9f83bd3f38c96ae Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sun, 3 Jul 2016 05:43:50 -0400 Subject: [PATCH 16/90] Update Iron Wizard mechanics --- .../game/core/boss/ironwizard/GolemBoss.java | 16 +++--- .../core/boss/ironwizard/GolemCreature.java | 50 ++++++++++++++----- 2 files changed, 45 insertions(+), 21 deletions(-) diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemBoss.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemBoss.java index 53168e9f5..7b2931b94 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemBoss.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemBoss.java @@ -1,12 +1,12 @@ package mineplex.minecraft.game.core.boss.ironwizard; import mineplex.core.blockrestore.BlockRestore; +import mineplex.core.common.util.F; import mineplex.core.disguise.DisguiseManager; import mineplex.core.projectile.ProjectileManager; import mineplex.minecraft.game.core.boss.EventCreature; import mineplex.minecraft.game.core.boss.EventState; import mineplex.minecraft.game.core.boss.WorldEvent; -import mineplex.minecraft.game.core.condition.Condition; import mineplex.minecraft.game.core.condition.ConditionManager; import mineplex.minecraft.game.core.damage.DamageManager; @@ -15,7 +15,6 @@ import org.bukkit.Location; public class GolemBoss extends WorldEvent { - public GolemBoss(DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, ProjectileManager projectileManager, Location cornerLocation) { super(DisguiseManager.INSTANCE, projectileManager, damageManager, blockRestore, conditionManager, "Iron Wizard", cornerLocation, "schematic/Golem.schematic"); @@ -24,21 +23,21 @@ public class GolemBoss extends WorldEvent @Override protected void customStart() { - Bukkit.broadcastMessage("Custom Start"); + Bukkit.broadcastMessage(F.main(getName(), "The mighty " + getName() + " challenges you to face him!")); spawnGolem(getCenterLocation()); setState(EventState.LIVE); announceStart(); } /** - * Check if this slime boss has been defeated + * Check if this golem boss has been defeated */ private void checkDeath() { if (getCreatures().size() == 0) { setState(EventState.COMPLETE); - Bukkit.broadcastMessage("FINISHED!"); + Bukkit.broadcastMessage(F.main(getName(), "The mighty " + getName() + " has fallen!")); } } @@ -55,9 +54,8 @@ public class GolemBoss extends WorldEvent private GolemCreature spawnGolem(Location location) { - GolemCreature slimeCreature = new GolemCreature(this, location, 2500); - registerCreature(slimeCreature); - return slimeCreature; + GolemCreature golemCreature = new GolemCreature(this, location, 2500); + registerCreature(golemCreature); + return golemCreature; } - } \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemCreature.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemCreature.java index bd311f6bf..8e73af96b 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemCreature.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemCreature.java @@ -20,16 +20,18 @@ import mineplex.minecraft.game.core.boss.BossAbility; import mineplex.minecraft.game.core.boss.EventCreature; import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemBlockHail; import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemBlockShot; -import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemCaveIn; +import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemDeadlyTremor; import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemEarthquake; import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemExplodingAura; +import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemIronHook; import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemMeleeAttack; import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemRupture; import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemSlam; -import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemWallExplode; +import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemSpike; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import org.bukkit.Bukkit; +import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Sound; import org.bukkit.block.BlockFace; @@ -54,7 +56,7 @@ public class GolemCreature extends EventCreature private Class _lastAttack; private boolean _usedFinalAttack; private ArrayList _currentAbilities = new ArrayList(); - private double _canCaveIn = 450; + private double _canDeadlyTremor = 225; private Vector _afkWalk = new Vector(); private long _lastSlam; @@ -73,7 +75,7 @@ public class GolemCreature extends EventCreature { GolemEarthquake.class, GolemRupture.class }); - _preferedCombos.put(GolemCaveIn.class, new Class[] + _preferedCombos.put(GolemDeadlyTremor.class, new Class[] { GolemMeleeAttack.class }); @@ -86,6 +88,25 @@ public class GolemCreature extends EventCreature GolemBlockShot.class }); } + + private boolean hasFurther(HashMap distances, double range) + { + for (Player player : distances.keySet()) + { + if (player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR) + { + continue; + } + + Double dist = distances.get(player); + if (dist >= range) + { + return true; + } + } + + return false; + } @Override protected void spawnCustom() @@ -166,6 +187,11 @@ public class GolemCreature extends EventCreature } } } + + if (hasFurther(dist, 15)) + { // Iron Hook + weight.put(GolemIronHook.class, 6); //6 + } if (hp < 0.7) { // Earthquake @@ -190,9 +216,9 @@ public class GolemCreature extends EventCreature } { // Wall explode - if (!getPlayers(dist, 13).isEmpty() && getPlayers(dist, 4).isEmpty()) + if (!getPlayers(dist, 20).isEmpty() && getPlayers(dist, 4).isEmpty()) { - weight.put(GolemWallExplode.class, 8); + weight.put(GolemSpike.class, 8); } } @@ -227,9 +253,9 @@ public class GolemCreature extends EventCreature } } - if (_canCaveIn <= 0) // Cave in + if (_canDeadlyTremor <= 0) // Deadly Tremor { - ArrayList players = getPlayers(dist, 30); + ArrayList players = getPlayers(dist, 80); for (BossAbility ability : _currentAbilities) { @@ -242,7 +268,7 @@ public class GolemCreature extends EventCreature if (!players.isEmpty()) { // weight.put(GolemCaveIn.class, (int) Math.min(players.size() * 2, 7)); - weight.put(GolemCaveIn.class, (int) 30); + weight.put(GolemDeadlyTremor.class, (int) 30); } } @@ -335,9 +361,9 @@ public class GolemCreature extends EventCreature { _lastAttack = ability.getClass(); - if (ability instanceof GolemCaveIn) + if (ability instanceof GolemDeadlyTremor) { - _canCaveIn = 450; + _canDeadlyTremor = 225; } else if (ability instanceof GolemSlam) { @@ -560,7 +586,7 @@ public class GolemCreature extends EventCreature @Override public void setHealth(double health) { - _canCaveIn -= getHealth() - health; + _canDeadlyTremor -= getHealth() - health; super.setHealth(health); From 0a67d381a321afa813d7efc505bceeff2cce0a79 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sun, 3 Jul 2016 05:44:05 -0400 Subject: [PATCH 17/90] Prevent bosses from leaving their arena --- .../mineplex/minecraft/game/core/boss/EventCreature.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventCreature.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventCreature.java index a41376eae..1741fbecc 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventCreature.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventCreature.java @@ -3,6 +3,7 @@ package mineplex.minecraft.game.core.boss; import java.util.UUID; import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilMath; import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguiseInsentient; @@ -273,6 +274,11 @@ public abstract class EventCreature implements Listener System.out.println("Respawning " + getName() + " because it is null or dead"); spawnEntity(); } + + if (UtilMath.offset2d(_entity.getLocation(), _spawnLocation) > 30) + { + _entity.setVelocity(UtilAlg.getTrajectory(_entity.getLocation(), _spawnLocation).normalize().multiply(2)); + } } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) From 5c37a6ceca261c36598b9528fb6c9e6e15dc97fa Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sun, 3 Jul 2016 06:33:53 -0400 Subject: [PATCH 18/90] Repair spider boss death --- .../game/core/boss/spider/SpiderBoss.java | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/SpiderBoss.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/SpiderBoss.java index c28fdf541..cb9df4fcf 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/SpiderBoss.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/SpiderBoss.java @@ -3,6 +3,17 @@ package mineplex.minecraft.game.core.boss.spider; import java.util.HashMap; import java.util.Iterator; +import mineplex.core.blockrestore.BlockRestore; +import mineplex.core.disguise.DisguiseManager; +import mineplex.core.projectile.ProjectileManager; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.boss.EventCreature; +import mineplex.minecraft.game.core.boss.EventState; +import mineplex.minecraft.game.core.boss.WorldEvent; +import mineplex.minecraft.game.core.condition.ConditionManager; +import mineplex.minecraft.game.core.damage.DamageManager; + import org.bukkit.Bukkit; import org.bukkit.Effect; import org.bukkit.Location; @@ -13,18 +24,6 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.entity.ItemSpawnEvent; -import mineplex.core.blockrestore.BlockRestore; -import mineplex.core.disguise.DisguiseManager; -import mineplex.core.projectile.ProjectileManager; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.boss.EventCreature; -import mineplex.minecraft.game.core.boss.EventState; -import mineplex.minecraft.game.core.boss.WorldEvent; -import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature; -import mineplex.minecraft.game.core.condition.ConditionManager; -import mineplex.minecraft.game.core.damage.DamageManager; - public class SpiderBoss extends WorldEvent { private HashMap _webDurability = new HashMap(); @@ -161,7 +160,7 @@ public class SpiderBoss extends WorldEvent { super.removeCreature(creature); - if (creature instanceof GolemCreature) + if (creature instanceof SpiderCreature) { checkDeath(); } From b51ee4a066367ff499b2cdafbec9e3ed795b29f3 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Tue, 5 Jul 2016 07:51:41 -0400 Subject: [PATCH 19/90] Create an event for stronger control over Velocity changes --- .../events/EntityVelocityChangeEvent.java | 60 +++++++++++++++++++ .../mineplex/core/common/util/UtilAction.java | 22 +++++++ 2 files changed, 82 insertions(+) create mode 100644 Plugins/Mineplex.Core.Common/src/mineplex/core/common/events/EntityVelocityChangeEvent.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/events/EntityVelocityChangeEvent.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/events/EntityVelocityChangeEvent.java new file mode 100644 index 000000000..12b860d19 --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/events/EntityVelocityChangeEvent.java @@ -0,0 +1,60 @@ +package mineplex.core.common.events; + +import org.bukkit.entity.Entity; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; +import org.bukkit.util.Vector; + +/** + * Called just before UtilAction#velocity changes an entity's velocity. + */ +public class EntityVelocityChangeEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private Entity _ent; + private Vector _vel; + + private boolean _cancelled; + + public EntityVelocityChangeEvent(Entity entity, Vector velocity) + { + _ent = entity; + _vel = velocity; + } + + public Entity getEntity() + { + return _ent; + } + + public boolean isCancelled() + { + return _cancelled; + } + + public Vector getVelocity() + { + return _vel; + } + + public void setVelocity(Vector velocity) + { + _vel = velocity; + } + + public void setCancelled(boolean cancelled) + { + _cancelled = cancelled; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAction.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAction.java index 50d8fe661..887369e33 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAction.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAction.java @@ -1,5 +1,8 @@ package mineplex.core.common.util; +import mineplex.core.common.events.EntityVelocityChangeEvent; + +import org.bukkit.Bukkit; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.util.Vector; @@ -49,6 +52,15 @@ public class UtilAction if (groundBoost) if (UtilEnt.isGrounded(ent)) vec.setY(vec.getY() + 0.2); + + EntityVelocityChangeEvent event = new EntityVelocityChangeEvent(ent, vec); + Bukkit.getPluginManager().callEvent(event); + + if (event.isCancelled()) + { + return; + } + vec = event.getVelocity(); //Velocity ent.setFallDistance(0); @@ -65,6 +77,16 @@ public class UtilAction public static void zeroVelocity(Entity ent) { Vector vec = new Vector(0,0,0); + + EntityVelocityChangeEvent event = new EntityVelocityChangeEvent(ent, vec); + Bukkit.getPluginManager().callEvent(event); + + if (event.isCancelled()) + { + return; + } + vec = event.getVelocity(); + ent.setFallDistance(0); //Store It! From cc7fc164bb447fc3e38b160a313787bc985aea6e Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Tue, 5 Jul 2016 07:52:21 -0400 Subject: [PATCH 20/90] Implement Necromancer boss and give it some beginning attacks --- .../clans/worldevent/WorldEventType.java | 14 +- .../boss/necromancer/NecromancerBoss.java | 72 ++++ .../boss/necromancer/NecromancerCreature.java | 309 ++++++++++++++++++ .../abilities/NecromancerHellishFlood.java | 109 ++++++ .../abilities/NecromancerPulse.java | 104 ++++++ .../abilities/NecromancerSmite.java | 104 ++++++ .../abilities/NecromancerStrike.java | 167 ++++++++++ .../abilities/NecromancerWraithSummon.java | 193 +++++++++++ .../boss/necromancer/minion/MinionType.java | 36 ++ .../minion/UndeadArcherCreature.java | 196 +++++++++++ .../minion/UndeadWarriorCreature.java | 110 +++++++ .../necromancer/minion/WraithCreature.java | 143 ++++++++ 12 files changed, 1551 insertions(+), 6 deletions(-) create mode 100644 Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/NecromancerBoss.java create mode 100644 Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/NecromancerCreature.java create mode 100644 Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/abilities/NecromancerHellishFlood.java create mode 100644 Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/abilities/NecromancerPulse.java create mode 100644 Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/abilities/NecromancerSmite.java create mode 100644 Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/abilities/NecromancerStrike.java create mode 100644 Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/abilities/NecromancerWraithSummon.java create mode 100644 Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/minion/MinionType.java create mode 100644 Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/minion/UndeadArcherCreature.java create mode 100644 Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/minion/UndeadWarriorCreature.java create mode 100644 Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/minion/WraithCreature.java diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java index 42e822bc7..566b7acf8 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java @@ -2,15 +2,16 @@ package mineplex.game.clans.clans.worldevent; import java.lang.reflect.Constructor; -import mineplex.minecraft.game.core.boss.ironwizard.GolemBoss; -import mineplex.minecraft.game.core.boss.slimeking.SlimeBoss; -import mineplex.minecraft.game.core.boss.spider.SpiderBoss; -import org.bukkit.Location; - import mineplex.game.clans.clans.worldevent.kinghill.KingHill; import mineplex.game.clans.clans.worldevent.undead.UndeadCamp; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; import mineplex.minecraft.game.core.boss.WorldEvent; +import mineplex.minecraft.game.core.boss.ironwizard.GolemBoss; +import mineplex.minecraft.game.core.boss.necromancer.NecromancerBoss; +import mineplex.minecraft.game.core.boss.slimeking.SlimeBoss; +import mineplex.minecraft.game.core.boss.spider.SpiderBoss; + +import org.bukkit.Location; public enum WorldEventType { @@ -18,7 +19,8 @@ public enum WorldEventType KING_OF_THE_HILL("King of The Hill", KingHill.class, 30), UNDEAD_CAMP("Undead Camp", UndeadCamp.class, 30), IRON_WIZARD("Iron Wizard",GolemBoss.class, 30), - BROOD_MOTHER("Brood Mother", SpiderBoss.class, 30); + BROOD_MOTHER("Brood Mother", SpiderBoss.class, 30), + NECROMANCER("Necromancer", NecromancerBoss.class, 30); private String _name; private Class _clazz; diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/NecromancerBoss.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/NecromancerBoss.java new file mode 100644 index 000000000..1684345f8 --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/NecromancerBoss.java @@ -0,0 +1,72 @@ +package mineplex.minecraft.game.core.boss.necromancer; + +import mineplex.core.blockrestore.BlockRestore; +import mineplex.core.disguise.DisguiseManager; +import mineplex.core.projectile.ProjectileManager; +import mineplex.minecraft.game.core.boss.EventCreature; +import mineplex.minecraft.game.core.boss.EventState; +import mineplex.minecraft.game.core.boss.WorldEvent; +import mineplex.minecraft.game.core.boss.necromancer.minion.MinionType; +import mineplex.minecraft.game.core.condition.ConditionManager; +import mineplex.minecraft.game.core.damage.DamageManager; + +import org.bukkit.Bukkit; +import org.bukkit.Location; + +public class NecromancerBoss extends WorldEvent +{ + public NecromancerBoss(DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, ProjectileManager projectileManager, Location cornerLocation) + { + super(DisguiseManager.INSTANCE, projectileManager, damageManager, blockRestore, conditionManager, "Necromancer", cornerLocation, + "schematic/Golem.schematic"); + } + + @Override + protected void customStart() + { + Bukkit.broadcastMessage("Custom Start"); + spawnNecromancer(getCenterLocation()); + setState(EventState.LIVE); + announceStart(); + } + + /** + * Check if this slime boss has been defeated + */ + private void checkDeath() + { + if (getCreatures().size() == 0) + { + setState(EventState.COMPLETE); + Bukkit.broadcastMessage("FINISHED!"); + } + } + + @Override + public void removeCreature(EventCreature creature) + { + super.removeCreature(creature); + + if (creature instanceof NecromancerCreature) + { + checkDeath(); + } + } + + public EventCreature spawnMinion(MinionType type, Location location) + { + EventCreature minionCreature = type.getNewInstance(this, location); + if (minionCreature != null) + { + registerCreature(minionCreature); + } + return minionCreature; + } + + private NecromancerCreature spawnNecromancer(Location location) + { + NecromancerCreature necromancerCreature = new NecromancerCreature(this, location, 2500); + registerCreature(necromancerCreature); + return necromancerCreature; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/NecromancerCreature.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/NecromancerCreature.java new file mode 100644 index 000000000..7aa78fc58 --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/NecromancerCreature.java @@ -0,0 +1,309 @@ +package mineplex.minecraft.game.core.boss.necromancer; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map.Entry; +import java.util.Random; + +import mineplex.core.common.events.EntityVelocityChangeEvent; +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.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.boss.BossAbility; +import mineplex.minecraft.game.core.boss.EventCreature; +import mineplex.minecraft.game.core.boss.necromancer.abilities.NecromancerHellishFlood; +import mineplex.minecraft.game.core.boss.necromancer.abilities.NecromancerPulse; +import mineplex.minecraft.game.core.boss.necromancer.abilities.NecromancerSmite; +import mineplex.minecraft.game.core.boss.necromancer.abilities.NecromancerStrike; +import mineplex.minecraft.game.core.boss.necromancer.abilities.NecromancerWraithSummon; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.BlockFace; +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.HandlerList; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.inventory.ItemStack; + +public class NecromancerCreature extends EventCreature +{ + private ArrayList _currentAbilities = new ArrayList(); + private int _lastAbility; + private HashMap _cooldowns = new HashMap(); + private boolean _hasUsedWraiths = false; + + public NecromancerCreature(NecromancerBoss boss, Location location, double maxHealth) + { + super(boss, location, "Necromancer", true, maxHealth, Skeleton.class); + + spawnEntity(); + } + + @Override + protected void spawnCustom() + { + UtilEnt.Vegetate(getEntity()); + getEntity().setSkeletonType(SkeletonType.WITHER); + getEntity().getEquipment().setItemInHand(new ItemStack(Material.RECORD_6)); //Meridian Scepter + getEntity().getEquipment().setItemInHandDropChance(0.f); + } + + @Override + public void dieCustom() + { + endAbility(); + } + + private void endAbility() + { + for (BossAbility ability : _currentAbilities) + { + ability.setFinished(); + HandlerList.unregisterAll(ability); + } + + _currentAbilities.clear(); + } + + @EventHandler + public void onTick(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + Iterator itel = _currentAbilities.iterator(); + boolean canDoNew = _currentAbilities.size() < 3; + + while (itel.hasNext()) + { + BossAbility ability = itel.next(); + + if (ability.hasFinished()) + { + itel.remove(); + ability.setFinished(); + _lastAbility = 20;// _currentAbility.getCooldown(); + + HandlerList.unregisterAll(ability); + System.out.print("Unregistered necromancer ability " + ability.getClass().getSimpleName()); + + _cooldowns.put(ability.getClass(), System.currentTimeMillis() + (ability.getCooldown() * 1000)); + } + else if (ability.inProgress()) + { + canDoNew = false; + _lastAbility = 20;// _currentAbility.getCooldown(); + } + } + + if (_lastAbility-- <= 0 && canDoNew && UtilBlock.solid(getEntity().getLocation().getBlock().getRelative(BlockFace.DOWN))) + { + HashMap weight = new HashMap(); + HashMap dist = new HashMap(); + + for (Player player : UtilPlayer.getNearby(getEntity().getLocation(), 50, true)) + { + if (player.hasLineOfSight(getEntity())) + { + dist.put(player, player.getLocation().distance(getEntity().getLocation())); + } + } + + if (!dist.isEmpty()) + { + {// Strike and Pulse + ArrayList players = getPlayers(dist, UtilMath.r(10) == 0 ? 10 : 6); + + if (!players.isEmpty()) + { + if (players.size() >= 4 && new Random().nextDouble() <= .45) + { + weight.put(NecromancerPulse.class, 998); + } + else + { + weight.put(NecromancerStrike.class, 6); + } + } + } + {// Smite + ArrayList players = getPlayers(dist, 10); + + if (!players.isEmpty()) + { + weight.put(NecromancerSmite.class, 6); + } + } + {//Hellish Flood + weight.put(NecromancerHellishFlood.class, 6); + } + if (getHealth() <= 90) + {// Wraith Summon + if (!_hasUsedWraiths) + { + weight.clear(); + weight.put(NecromancerWraithSummon.class, 999); + } + } + } + + for (BossAbility ability : _currentAbilities) + { + weight.remove(ability.getClass()); + } + + for (Class c : _cooldowns.keySet()) + { + if (_cooldowns.get(c) > System.currentTimeMillis()) + { + weight.remove(c); + } + } + + BossAbility ability = null; + + if (!weight.isEmpty()) + { + int i = 0; + + for (Integer entry : weight.values()) + { + i += entry; + } + + loop: for (int a = 0; a < 10; a++) + { + int luckyNumber = UtilMath.r(i); + + for (Entry entry : weight.entrySet()) + { + luckyNumber -= entry.getValue(); + + if (luckyNumber <= 0) + { + try + { + ability = (BossAbility) entry.getKey().getConstructor(NecromancerCreature.class).newInstance(this); + + if (ability.getTarget() == null || ability.hasFinished()) + { + ability = null; + } + else + { + break loop; + } + } + catch (Exception ex) + { + ex.printStackTrace(); + } + + break; + } + } + } + } + + if (ability != null && ability.getTarget() != null) + { + + Bukkit.getPluginManager().registerEvents(ability, getEvent().getPlugin()); + + System.out.print("Necromancer is using " + ability.getClass().getSimpleName()); + + if (ability instanceof NecromancerWraithSummon) + { + _hasUsedWraiths = true; + } + + _currentAbilities.add(ability); + } + + _lastAbility = 10; + } + + for (BossAbility ability : _currentAbilities) + { + ability.tick(); + } + } + + private ArrayList getPlayers(HashMap map, double maxDist) + { + return getPlayers(map, 0, maxDist); + } + + private ArrayList getPlayers(final HashMap map, double minDist, double maxDist) + { + ArrayList list = new ArrayList(); + + for (Player p : map.keySet()) + { + if (map.get(p) >= minDist && map.get(p) <= maxDist) + { + list.add(p); + } + } + + Collections.sort(list, new Comparator() + { + + @Override + public int compare(Player o1, Player o2) + { + return Double.compare(map.get(o2), map.get(o1)); + } + }); + + return list; + } + + @EventHandler + public void onNecromancerDamage(CustomDamageEvent event) + { + if (event.GetDamageeEntity().getEntityId() == getEntity().getEntityId()) + { + event.SetKnockback(false); + } + } + + @EventHandler + public void noFallDamage(CustomDamageEvent event) + { + if (getEntity() == null) + return; + + if (event.GetDamageeEntity().getEntityId() != getEntity().getEntityId()) + return; + + DamageCause cause = event.GetCause(); + + if (cause == DamageCause.FALL) + { + event.SetCancelled("Boss Invulnerability"); + } + } + + @EventHandler + public void onVelocity(EntityVelocityChangeEvent event) + { + if (event.getEntity().getEntityId() == getEntity().getEntityId()) + { + event.setCancelled(true); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/abilities/NecromancerHellishFlood.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/abilities/NecromancerHellishFlood.java new file mode 100644 index 000000000..832399221 --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/abilities/NecromancerHellishFlood.java @@ -0,0 +1,109 @@ +package mineplex.minecraft.game.core.boss.necromancer.abilities; + +import java.util.Random; +import java.util.concurrent.ConcurrentHashMap; + +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.minecraft.game.core.boss.BossAbility; +import mineplex.minecraft.game.core.boss.necromancer.NecromancerBoss; +import mineplex.minecraft.game.core.boss.necromancer.NecromancerCreature; +import mineplex.minecraft.game.core.boss.necromancer.minion.MinionType; + +import org.bukkit.Location; +import org.bukkit.entity.Skeleton; + +public class NecromancerHellishFlood extends BossAbility +{ + private static final int WAVE_COUNT = 3; + private static final int WAVE_SIZE = 5; + private static final MinionType[] POSSIBLE_MINIONS = new MinionType[] {MinionType.WARRIOR, MinionType.WRAITH}; + private static final long WAVE_DELAY = 1000; + + private ConcurrentHashMap _waves = new ConcurrentHashMap<>(); + private long _lastSpawned; + private int _current; + + public NecromancerHellishFlood(NecromancerCreature creature) + { + super(creature); + + if (WAVE_COUNT > 0) + { + for (int i = 1; i <= WAVE_COUNT; i++) + { + createWave(i); + } + } + _lastSpawned = System.currentTimeMillis(); + _current = 1; + } + + private void createWave(int number) + { + int length = POSSIBLE_MINIONS.length; + if (length <= 0 || WAVE_SIZE <= 0) + { + return; + } + MinionType[] wave = new MinionType[WAVE_SIZE]; + for (int i = 0; i < WAVE_SIZE; i++) + { + wave[i] = POSSIBLE_MINIONS[new Random().nextInt(length)]; + } + _waves.put(number, wave); + } + + @Override + public boolean canMove() + { + return false; + } + + @Override + public boolean inProgress() + { + return true; + } + + @Override + public boolean hasFinished() + { + return !_waves.isEmpty(); + } + + @Override + public void setFinished() + { + _waves.clear(); + } + + @Override + public void tick() + { + if (UtilTime.elapsed(_lastSpawned, WAVE_DELAY)) + { + if (_current <= _waves.size()) + { + for (MinionType type : _waves.get(_current)) + { + Location toSpawn = getLocation().clone(); + toSpawn.add(UtilMath.random(3, 6), 0, UtilMath.random(3, 6)); + + ((NecromancerBoss)getBoss().getEvent()).spawnMinion(type, toSpawn); + + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, toSpawn, null, 0, 2, ViewDist.MAX); + UtilParticle.PlayParticleToAll(ParticleType.SMOKE, toSpawn, null, 0, 2, ViewDist.MAX); + } + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, getEntity().getLocation(), null, 0, 2, ViewDist.MAX); + UtilParticle.PlayParticleToAll(ParticleType.SMOKE, getEntity().getLocation(), null, 0, 2, ViewDist.MAX); + _waves.remove(_current); + _current++; + _lastSpawned = System.currentTimeMillis(); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/abilities/NecromancerPulse.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/abilities/NecromancerPulse.java new file mode 100644 index 000000000..426f1f93e --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/abilities/NecromancerPulse.java @@ -0,0 +1,104 @@ +package mineplex.minecraft.game.core.boss.necromancer.abilities; + +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.UtilTime; +import mineplex.core.recharge.Recharge; +import mineplex.minecraft.game.core.boss.BossAbility; +import mineplex.minecraft.game.core.boss.necromancer.NecromancerCreature; + +import org.bukkit.GameMode; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; + +public class NecromancerPulse extends BossAbility +{ + private static final long TOTAL_ATTACK_DURATION = 3000; + private long _start, _lastIncrement; + private int _radius; + + public NecromancerPulse(NecromancerCreature creature) + { + super(creature); + _start = System.currentTimeMillis(); + _radius = 2; + _lastIncrement = System.currentTimeMillis(); + } + + private int getRadius() + { + return Math.min(6, _radius); + } + + @Override + public int getCooldown() + { + return 5; + } + + @Override + public boolean canMove() + { + return false; + } + + @Override + public boolean inProgress() + { + return true; + } + + @Override + public boolean hasFinished() + { + return UtilTime.elapsed(_start, TOTAL_ATTACK_DURATION); + } + + @Override + public void setFinished() + { + _start = System.currentTimeMillis() - TOTAL_ATTACK_DURATION; + } + + @Override + public void tick() + { + if (UtilTime.elapsed(_lastIncrement, 500)) + { + _lastIncrement = System.currentTimeMillis(); + _radius++; + } + + for (double token = 0; token <= (2 * Math.PI); token += .2) + { + double x = getRadius() * Math.cos(token); + double z = getRadius() * Math.sin(token); + + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, getEntity().getLocation().add(x, 0.3, z), null, 0, 1, ViewDist.MAX); + } + + for (Player player : UtilPlayer.getInRadius(getEntity().getLocation(), getRadius()).keySet()) + { + if (player.isDead() || !player.isValid() || !player.isOnline()) + { + continue; + } + if (player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR) + { + continue; + } + if (!Recharge.Instance.use(player, "Pulse Knockback", 400, false, false, false)) + { + continue; + } + + player.playSound(player.getLocation(), Sound.AMBIENCE_THUNDER, 1f, 1f); + UtilAction.velocity(player, UtilAlg.getTrajectory2d(getEntity(), player), .2, false, 0.6, 0, 1.4, true); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/abilities/NecromancerSmite.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/abilities/NecromancerSmite.java new file mode 100644 index 000000000..217dd7d68 --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/abilities/NecromancerSmite.java @@ -0,0 +1,104 @@ +package mineplex.minecraft.game.core.boss.necromancer.abilities; + +import java.math.BigDecimal; + +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.minecraft.game.core.boss.BossAbility; +import mineplex.minecraft.game.core.boss.necromancer.NecromancerCreature; + +import org.bukkit.GameMode; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +public class NecromancerSmite extends BossAbility +{ + private static final long TOTAL_ATTACK_DURATION = 8000; + private long _start; + private int _ticks; + private boolean _shot; + + public NecromancerSmite(NecromancerCreature creature) + { + super(creature); + _start = System.currentTimeMillis(); + _ticks = 0; + _shot = false; + } + + @Override + public int getCooldown() + { + return 15; + } + + @Override + public boolean canMove() + { + return false; + } + + @Override + public boolean inProgress() + { + return true; + } + + @Override + public boolean hasFinished() + { + return UtilTime.elapsed(_start, TOTAL_ATTACK_DURATION) && _shot; + } + + @Override + public void setFinished() + { + _start = System.currentTimeMillis() - TOTAL_ATTACK_DURATION; + _shot = true; + } + + @Override + public void tick() + { + if (_shot) + return; + + if (_ticks < (6 * 20)) + { + _ticks++; + double maxHeight = Math.min(_ticks / 20, 6); + int radius = Math.max(6 - (new BigDecimal(_ticks).divide(new BigDecimal(20)).intValue()), 0); + + for (double y = 0; y < maxHeight; y += 0.5) + { + double cos = radius * Math.cos(y); + double sin = radius * Math.sin(y); + + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, getEntity().getLocation().add(cos, y, sin), null, 0, 1, ViewDist.MAX); + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, getEntity().getLocation().add(sin, y, cos), null, 0, 1, ViewDist.MAX); + } + } + else + { + _shot = true; + for (Player player : UtilPlayer.getInRadius(getEntity().getLocation(), 10).keySet()) + { + if (player.isDead() || !player.isValid() || !player.isOnline()) + { + continue; + } + if (player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR) + { + continue; + } + + player.getWorld().strikeLightningEffect(player.getLocation()); + getBoss().getEvent().getDamageManager().NewDamageEvent(player, getEntity(), null, DamageCause.LIGHTNING, 15 * getBoss().getDifficulty(), false, true, false, getEntity().getName(), "Lightning Strike"); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/abilities/NecromancerStrike.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/abilities/NecromancerStrike.java new file mode 100644 index 000000000..cb42fbeb5 --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/abilities/NecromancerStrike.java @@ -0,0 +1,167 @@ +package mineplex.minecraft.game.core.boss.necromancer.abilities; + +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +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.minecraft.game.core.boss.BossAbility; +import mineplex.minecraft.game.core.boss.necromancer.NecromancerCreature; + +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +import com.google.common.collect.Lists; + +public class NecromancerStrike extends BossAbility +{ + private static final double MAX_RANGE = 10; + private static final Integer MAX_TARGETS = 3; + private boolean _shot; + + public NecromancerStrike(NecromancerCreature creature) + { + super(creature); + _shot = false; + } + + private int getPosition(Player toAdd, LinkedList ordered, HashMap distances) + { + int position = ordered.size(); + int index = 0; + for (Player player : ordered) + { + if (distances.get(player) >= distances.get(toAdd)) + { + position = index; + } + index++; + } + + return position; + } + + private List getTargets() + { + Skeleton necromancer = getBoss().getEntity(); + LinkedList selections = new LinkedList<>(); + List targeted = Lists.newArrayList(); + + HashMap near = UtilPlayer.getInRadius(necromancer.getLocation(), MAX_RANGE); + + for (Player nearby : near.keySet()) + { + if (nearby.getGameMode() == GameMode.CREATIVE || nearby.getGameMode() == GameMode.SPECTATOR) + { + continue; + } + + if (selections.isEmpty()) + { + selections.addFirst(nearby); + } + else + { + selections.add(getPosition(nearby, selections, near), nearby); + } + } + + for (int i = 0; i < MAX_TARGETS; i++) + { + if (i < selections.size()) + { + targeted.add(selections.get(i)); + } + } + + return targeted; + } + + private void shootAt(Player target) + { + double curRange = 0; + boolean canHit = false; + + while (curRange <= MAX_RANGE) + { + Location newTarget = getEntity().getEyeLocation().add(UtilAlg.getTrajectory(getEntity(), target).multiply(curRange)); + + if (!UtilBlock.airFoliage(newTarget.getBlock())) + { + canHit = false; + break; + } + if (UtilMath.offset(newTarget, target.getLocation()) <= 0.7) + { + canHit = true; + break; + } + + curRange += 0.2; + + UtilParticle.PlayParticle(ParticleType.WITCH_MAGIC, newTarget, 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); + + canHit = true; + } + + if (canHit) + { + getBoss().getEvent().getDamageManager().NewDamageEvent(target, getEntity(), null, DamageCause.CUSTOM, 10 * getBoss().getDifficulty(), true, true, false, getEntity().getName(), "Mystical Energy"); + } + } + + @Override + public int getCooldown() + { + return 3; + } + + @Override + public boolean canMove() + { + return false; + } + + @Override + public boolean inProgress() + { + return false; + } + + @Override + public boolean hasFinished() + { + return _shot; + } + + @Override + public void setFinished() + { + _shot = true; + } + + @Override + public void tick() + { + if (_shot) + return; + + _shot = true; + + for (Player target : getTargets()) + { + shootAt(target); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/abilities/NecromancerWraithSummon.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/abilities/NecromancerWraithSummon.java new file mode 100644 index 000000000..dc0b31e4f --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/abilities/NecromancerWraithSummon.java @@ -0,0 +1,193 @@ +package mineplex.minecraft.game.core.boss.necromancer.abilities; + +import java.util.concurrent.ConcurrentHashMap; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.minecraft.game.core.boss.BossAbility; +import mineplex.minecraft.game.core.boss.necromancer.NecromancerBoss; +import mineplex.minecraft.game.core.boss.necromancer.NecromancerCreature; +import mineplex.minecraft.game.core.boss.necromancer.minion.MinionType; +import mineplex.minecraft.game.core.boss.necromancer.minion.WraithCreature; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import org.bukkit.Bukkit; +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.util.Vector; + +public class NecromancerWraithSummon extends BossAbility +{ + private static final int WRAITH_AMOUNT = 4; + private static final double DISTANCE_FROM_NECROMANCER = 4; + + private ConcurrentHashMap _wraiths = new ConcurrentHashMap<>(); + private Location[] _spawns; + + public NecromancerWraithSummon(NecromancerCreature creature) + { + super(creature); + + _spawns = new Location[] + { + getEntity().getLocation().add(DISTANCE_FROM_NECROMANCER, 0, DISTANCE_FROM_NECROMANCER), + getEntity().getLocation().add(DISTANCE_FROM_NECROMANCER * -1, 0, DISTANCE_FROM_NECROMANCER), + getEntity().getLocation().add(DISTANCE_FROM_NECROMANCER, 0, DISTANCE_FROM_NECROMANCER * -1), + getEntity().getLocation().add(DISTANCE_FROM_NECROMANCER * -1, 0, DISTANCE_FROM_NECROMANCER * -1) + }; + if (WRAITH_AMOUNT > 0) + { + for (int i = 0; i < WRAITH_AMOUNT; i++) + { + int spawnIndex = i; + if (spawnIndex >= _spawns.length) + { + spawnIndex = spawnIndex % _spawns.length; + } + spawnWraith(_spawns[spawnIndex], i + 1); + } + + for (Player player : UtilPlayer.getInRadius(getEntity().getLocation(), 80).keySet()) + { + if (player.isDead() || !player.isValid() || !player.isOnline()) + { + continue; + } + if (player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR) + { + continue; + } + + player.sendMessage(F.main(getBoss().getEvent().getName(), "You must slay all " + WRAITH_AMOUNT + " wraiths before continuing to fight the Necromancer!")); + } + } + } + + private String getNumberString(Integer number) + { + String num = number.toString(); + char last = num.toCharArray()[num.length() - 1]; + + String formatted = number.toString(); + String ending = ""; + + if (last == '1' && !num.equals("1" + last)) + { + ending = "st"; + } + if (last == '2' && !num.equals("1" + last)) + { + ending = "nd"; + } + if (last == '3' && !num.equals("1" + last)) + { + ending = "rd"; + } + if (ending.equals("")) + { + ending = "th"; + } + + return formatted + ending; + } + + private void spawnWraith(Location loc, int number) + { + WraithCreature wraith = (WraithCreature)((NecromancerBoss)getBoss().getEvent()).spawnMinion(MinionType.WRAITH, loc); + _wraiths.put(wraith, getNumberString(number)); + } + + @Override + public int getCooldown() + { + return 9999; + } + + @Override + public boolean canMove() + { + return false; + } + + @Override + public boolean inProgress() + { + return true; + } + + @Override + public boolean hasFinished() + { + return !_wraiths.isEmpty(); + } + + @Override + public void setFinished() + { + for (WraithCreature wraith : _wraiths.keySet()) + { + wraith.remove(); + } + _wraiths.clear(); + } + + @Override + public void tick() + { + if (!hasFinished()) + { + int ticks = 10; + int hticks = 40; + boolean up = getEntity().getTicksLived() % (hticks * 2) < hticks; + int tick = getEntity().getTicksLived() % ticks; + double htick = getEntity().getTicksLived() % hticks; + int splits = 4; + + Location loc = getEntity().getLocation().add(0, 2, 0); + + for (double d = tick * (Math.PI * 2 / splits) / ticks; d < Math.PI * 2; d += Math.PI * 2 / splits) + { + Vector v = new Vector(Math.sin(d), 0, Math.cos(d)); + v.normalize().multiply(Math.max(0.2, Math.sin((htick / hticks) * Math.PI) * 1.0)); + v.setY((htick / hticks) * -2); + if (up) v.setY(-2 + 2 * (htick / hticks)); + + Location lloc = loc.clone().add(v); + + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, lloc, null, 0f, 2, ViewDist.MAX); + } + } + } + + @EventHandler + public void onWraithDie(EntityDeathEvent event) + { + for (WraithCreature wraith : _wraiths.keySet()) + { + if (wraith.getEntity().equals(event.getEntity())) + { + Bukkit.broadcastMessage(F.main(getBoss().getEvent().getName(), "The " + _wraiths.remove(wraith) + " wraith has been slain!")); + } + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onNecromancerDamage(CustomDamageEvent event) + { + if (event.GetDamageeEntity().equals(getBoss().getEntity())) + { + if (!hasFinished()) + { + event.SetCancelled("Wraiths Alive"); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/minion/MinionType.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/minion/MinionType.java new file mode 100644 index 000000000..269b83be9 --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/minion/MinionType.java @@ -0,0 +1,36 @@ +package mineplex.minecraft.game.core.boss.necromancer.minion; + +import java.lang.reflect.InvocationTargetException; + +import org.bukkit.Location; + +import mineplex.minecraft.game.core.boss.EventCreature; +import mineplex.minecraft.game.core.boss.WorldEvent; + +public enum MinionType +{ + WARRIOR(UndeadWarriorCreature.class), + ARCHER(UndeadArcherCreature.class), + WRAITH(WraithCreature.class); + + private Class _code; + + private MinionType(Class code) + { + _code = code; + } + + public EventCreature getNewInstance(WorldEvent event, Location spawn) + { + try + { + return _code.getConstructor(WorldEvent.class, Location.class).newInstance(event, spawn); + } + catch (Exception e) + { + e.printStackTrace(); + } + + return null; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/minion/UndeadArcherCreature.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/minion/UndeadArcherCreature.java new file mode 100644 index 000000000..cd40ddc23 --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/minion/UndeadArcherCreature.java @@ -0,0 +1,196 @@ +package mineplex.minecraft.game.core.boss.necromancer.minion; + +import java.util.HashSet; +import java.util.Iterator; + +import mineplex.core.common.util.UtilMath; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.boss.EventCreature; +import mineplex.minecraft.game.core.boss.WorldEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.entity.Skeleton; +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.inventory.EntityEquipment; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +public class UndeadArcherCreature extends EventCreature +{ + private static final int BARBED_LEVEL = 1; + private static final int LIFETIME = 40; + + private HashSet _arrows = new HashSet(); + + public UndeadArcherCreature(WorldEvent event, Location spawnLocation) + { + super(event, spawnLocation, "Undead Archer", true, 100, Skeleton.class); + + spawnEntity(); + } + + @Override + protected void spawnCustom() + { + Skeleton entity = getEntity(); + EntityEquipment eq = entity.getEquipment(); + eq.setItemInHand(new ItemStack(Material.BOW)); + eq.setHelmet(new ItemStack(Material.CHAINMAIL_HELMET)); + eq.setChestplate(new ItemStack(Material.CHAINMAIL_CHESTPLATE)); + eq.setLeggings(new ItemStack(Material.CHAINMAIL_LEGGINGS)); + eq.setBoots(new ItemStack(Material.CHAINMAIL_BOOTS)); + eq.setItemInHandDropChance(0.f); + eq.setHelmetDropChance(0.f); + eq.setChestplateDropChance(0.f); + eq.setLeggingsDropChance(0.f); + eq.setBootsDropChance(0.f); + entity.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 999999, 0)); + } + + @Override + public void dieCustom() + { + if (LIFETIME >= 0 && getEntity().getTicksLived() >= (20 * LIFETIME)) + { + return; + } + + if (Math.random() > 0.97) + { + getEntity().getWorld().dropItem(getEntity().getLocation(), new org.bukkit.inventory.ItemStack(Material.CHAINMAIL_HELMET)); + } + + if (Math.random() > 0.97) + { + getEntity().getWorld().dropItem(getEntity().getLocation(), new org.bukkit.inventory.ItemStack(Material.CHAINMAIL_CHESTPLATE)); + } + + if (Math.random() > 0.97) + { + getEntity().getWorld().dropItem(getEntity().getLocation(), new org.bukkit.inventory.ItemStack(Material.CHAINMAIL_LEGGINGS)); + } + + if (Math.random() > 0.97) + { + getEntity().getWorld().dropItem(getEntity().getLocation(), new org.bukkit.inventory.ItemStack(Material.CHAINMAIL_BOOTS)); + } + + if (Math.random() > 0.90) + { + getEntity().getWorld().dropItem(getEntity().getLocation(), new org.bukkit.inventory.ItemStack(Material.BOW)); + } + + getEntity().getWorld().dropItem(getEntity().getLocation(), new org.bukkit.inventory.ItemStack(Material.ARROW, UtilMath.r(12) + 1)); + + getEntity().getWorld().dropItem(getEntity().getLocation(), new ItemStack(Material.EMERALD, UtilMath.r(5) + 1)); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void bowShoot(EntityShootBowEvent event) + { + if (BARBED_LEVEL == 0) + { + return; + } + + if (!(event.getProjectile() instanceof Arrow)) + { + return; + } + + if (event.getEntity().getEntityId() != getEntity().getEntityId()) + { + return; + } + + _arrows.add((Projectile) event.getProjectile()); + } + + @EventHandler(priority = EventPriority.HIGH) + public void damage(CustomDamageEvent event) + { + if (event.IsCancelled()) + { + return; + } + + if (event.GetCause() != DamageCause.PROJECTILE) + { + return; + } + + Projectile projectile = event.GetProjectile(); + LivingEntity damagee = event.GetDamageeEntity(); + LivingEntity damager = event.GetDamagerEntity(true); + + if (projectile == null) + { + return; + } + + if (damagee == null) + { + return; + } + + if (damager == null) + { + return; + } + + // Level + if (BARBED_LEVEL == 0) + { + return; + } + + Player damageePlayer = event.GetDamageePlayer(); + + if (damageePlayer != null) + { + damageePlayer.setSprinting(false); + } + + // Damage + event.AddMod(damager.getName(), "Barbed Arrows", 0, false); + + // Condition + getEvent().getCondition().Factory().Slow("Barbed Arrows", damagee, damager, (projectile.getVelocity().length() / 3) * (2 + BARBED_LEVEL), 0, false, true, true, true); + } + + @EventHandler + public void clean(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + + if (LIFETIME >= 0 && getEntity().getTicksLived() >= (20 * LIFETIME)) + { + remove(); + return; + } + + for (Iterator arrowIterator = _arrows.iterator(); arrowIterator.hasNext();) + { + Projectile arrow = arrowIterator.next(); + + if (arrow.isDead() || !arrow.isValid()) + { + arrowIterator.remove(); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/minion/UndeadWarriorCreature.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/minion/UndeadWarriorCreature.java new file mode 100644 index 000000000..f568eaf94 --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/minion/UndeadWarriorCreature.java @@ -0,0 +1,110 @@ +package mineplex.minecraft.game.core.boss.necromancer.minion; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilMath; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.boss.EventCreature; +import mineplex.minecraft.game.core.boss.WorldEvent; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Zombie; +import org.bukkit.event.EventHandler; +import org.bukkit.inventory.EntityEquipment; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +public class UndeadWarriorCreature extends EventCreature +{ + private static final int LIFETIME = 40; + + public UndeadWarriorCreature(WorldEvent event, Location spawnLocation) + { + super(event, spawnLocation, "Undead Warrior", true, 100, Zombie.class); + spawnEntity(); + } + + @Override + protected void spawnCustom() + { + Zombie entity = getEntity(); + EntityEquipment eq = entity.getEquipment(); + eq.setHelmet(new ItemStack(Material.IRON_HELMET)); + eq.setChestplate(new ItemStack(Material.IRON_CHESTPLATE)); + eq.setLeggings(new ItemStack(Material.IRON_LEGGINGS)); + eq.setBoots(new ItemStack(Material.IRON_BOOTS)); + eq.setItemInHand(new ItemStack(Material.STONE_SWORD)); + eq.setHelmetDropChance(0.f); + eq.setChestplateDropChance(0.f); + eq.setLeggingsDropChance(0.f); + eq.setBootsDropChance(0.f); + eq.setItemInHandDropChance(0.f); + entity.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 999999, 0)); + } + + @Override + public void dieCustom() + { + if (LIFETIME >= 0 && getEntity().getTicksLived() >= (20 * LIFETIME)) + { + return; + } + + if (Math.random() > 0.97) + getEntity().getWorld().dropItem(getEntity().getLocation(), new ItemStack(Material.IRON_HELMET)); + + if (Math.random() > 0.97) + getEntity().getWorld().dropItem(getEntity().getLocation(), new ItemStack(Material.IRON_CHESTPLATE)); + + if (Math.random() > 0.97) + getEntity().getWorld().dropItem(getEntity().getLocation(), new ItemStack(Material.IRON_LEGGINGS)); + + if (Math.random() > 0.97) + getEntity().getWorld().dropItem(getEntity().getLocation(), new ItemStack(Material.IRON_BOOTS)); + + getEntity().getWorld().dropItem(getEntity().getLocation(), new ItemStack(Material.EMERALD, UtilMath.r(5) + 1)); + } + + @EventHandler + public void leap(UpdateEvent event) + { + if (getEntity() == null) + return; + + if (event.getType() != UpdateType.FAST) + return; + + if (LIFETIME >= 0 && getEntity().getTicksLived() >= (20 * LIFETIME)) + { + remove(); + return; + } + + if (Math.random() < 0.9) + return; + + Zombie zombie = getEntity(); + + if (zombie.getTarget() == null) + return; + + double dist = UtilMath.offset(zombie.getTarget(), zombie); + + if (dist <= 3 || dist > 16) + return; + + + double power = 0.8 + (1.2 * ((dist-3)/13d)); + + //Leap + UtilAction.velocity(zombie, UtilAlg.getTrajectory(zombie, zombie.getTarget()), + power, false, 0, 0.2, 1, true); + + //Effect + zombie.getWorld().playSound(zombie.getLocation(), Sound.ZOMBIE_HURT, 1f, 2f); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/minion/WraithCreature.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/minion/WraithCreature.java new file mode 100644 index 000000000..eb7e2fefa --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/minion/WraithCreature.java @@ -0,0 +1,143 @@ +package mineplex.minecraft.game.core.boss.necromancer.minion; + +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.itemstack.ItemBuilder; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.boss.EventCreature; +import mineplex.minecraft.game.core.boss.WorldEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import org.bukkit.Color; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Zombie; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.inventory.EntityEquipment; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +public class WraithCreature extends EventCreature +{ + private static final int LIFETIME = -1; + + public WraithCreature(WorldEvent event, Location spawnLocation) + { + super(event, spawnLocation, "Wraith", true, 200, Zombie.class); + spawnEntity(); + } + + @Override + protected void spawnCustom() + { + Zombie entity = getEntity(); + EntityEquipment eq = entity.getEquipment(); + eq.setHelmet(new ItemStack(Material.SKULL_ITEM, 1, (short)1)); + eq.setChestplate(new ItemBuilder(Material.LEATHER_CHESTPLATE).setColor(Color.BLACK).build()); + eq.setLeggings(new ItemBuilder(Material.LEATHER_LEGGINGS).setColor(Color.BLACK).build()); + eq.setBoots(new ItemBuilder(Material.LEATHER_BOOTS).setColor(Color.BLACK).build()); + eq.setItemInHand(new ItemStack(Material.IRON_SWORD)); + eq.setHelmetDropChance(0.f); + eq.setChestplateDropChance(0.f); + eq.setLeggingsDropChance(0.f); + eq.setBootsDropChance(0.f); + eq.setItemInHandDropChance(0.f); + entity.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 999999, 0)); + entity.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 999999, 0)); + entity.addPotionEffect(new PotionEffect(PotionEffectType.WATER_BREATHING, 999999, 0)); + entity.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 999999, 1)); + } + + @Override + public void dieCustom() + { + if (LIFETIME >= 0 && getEntity().getTicksLived() >= (20 * LIFETIME)) + { + return; + } + + if (Math.random() > 0.97) + getEntity().getWorld().dropItem(getEntity().getLocation(), new ItemStack(Material.DIAMOND_HELMET)); + + if (Math.random() > 0.97) + getEntity().getWorld().dropItem(getEntity().getLocation(), new ItemStack(Material.DIAMOND_CHESTPLATE)); + + if (Math.random() > 0.97) + getEntity().getWorld().dropItem(getEntity().getLocation(), new ItemStack(Material.DIAMOND_LEGGINGS)); + + if (Math.random() > 0.97) + getEntity().getWorld().dropItem(getEntity().getLocation(), new ItemStack(Material.DIAMOND_BOOTS)); + + getEntity().getWorld().dropItem(getEntity().getLocation(), new ItemStack(Material.EMERALD, UtilMath.r(10) + 1)); + } + + @EventHandler(priority = EventPriority.HIGH) + public void damage(CustomDamageEvent event) + { + if (event.IsCancelled()) + { + return; + } + + LivingEntity damagee = event.GetDamageeEntity(); + LivingEntity damager = event.GetDamagerEntity(false); + + if (damagee == null) + { + return; + } + + if (damager == null) + { + return; + } + + // Damage + event.AddMod(damager.getName(), "Mystical Darkness", 2, false); + + // Condition + getEvent().getCondition().Factory().Poison("Mystical Darkness", damagee, damager, 5, 0, false, true, false); + } + + @EventHandler + public void blink(UpdateEvent event) + { + if (getEntity() == null) + return; + + if (event.getType() != UpdateType.FAST) + return; + + if (LIFETIME >= 0 && getEntity().getTicksLived() >= (20 * LIFETIME)) + { + remove(); + return; + } + + if (Math.random() < 0.6) + return; + + Zombie zombie = getEntity(); + + if (zombie.getTarget() == null) + return; + + double dist = UtilMath.offset(zombie.getTarget(), zombie); + + if (dist <= 10 || dist > 25) + return; + + UtilParticle.PlayParticleToAll(ParticleType.SMOKE, zombie.getLocation(), 0, 0, 0, 0, 5, ViewDist.MAX); + zombie.getWorld().playSound(zombie.getLocation(), Sound.ENDERMAN_TELEPORT, 1f, 2f); + zombie.teleport(zombie.getTarget().getLocation().add(UtilMath.random(0, 1.5), 0, UtilMath.random(0, 1.5))); + UtilParticle.PlayParticleToAll(ParticleType.SMOKE, zombie.getLocation(), 0, 0, 0, 0, 5, ViewDist.MAX); + zombie.getWorld().playSound(zombie.getLocation(), Sound.ENDERMAN_TELEPORT, 1f, 2f); + } +} \ No newline at end of file From b4090090690c7e668141e829acaa552f933451fa Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Tue, 5 Jul 2016 10:05:53 -0400 Subject: [PATCH 21/90] Create a way to remove siege weapons for testing --- .../game/clans/clans/siege/weapon/SiegeWeapon.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/SiegeWeapon.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/SiegeWeapon.java index c09ec8f6d..b7f2daefd 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/SiegeWeapon.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/SiegeWeapon.java @@ -3,6 +3,7 @@ package mineplex.game.clans.clans.siege.weapon; import java.util.UUID; import org.apache.commons.lang.Validate; +import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; @@ -487,6 +488,12 @@ public abstract class SiegeWeapon implements Listener protected void handleLeftClick(Player player) { + if (player.getGameMode() == GameMode.CREATIVE && player.isSneaking()) + { + removeHealth(getHealth()); + return; + } + if (_lastLeft == -1) { _lastLeft = System.currentTimeMillis(); From 8c93f92a921ad24a85a912a3503bc4583bbd5015 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Tue, 5 Jul 2016 17:08:38 -0400 Subject: [PATCH 22/90] Tweak all Necromancer abilities so they function well together and give the Necromancer a semi-AI for movement --- .../game/core/boss/EventCreature.java | 2 +- .../boss/necromancer/NecromancerBoss.java | 15 +- .../boss/necromancer/NecromancerCreature.java | 147 ++++++++++++++---- .../abilities/NecromancerHellishFlood.java | 27 +++- .../abilities/NecromancerPulse.java | 7 +- .../abilities/NecromancerSmite.java | 2 +- .../abilities/NecromancerStrike.java | 6 +- .../abilities/NecromancerWraithSummon.java | 74 ++++----- .../abilities/WraithDeathEvent.java | 33 ++++ .../necromancer/minion/WraithCreature.java | 7 +- 10 files changed, 231 insertions(+), 89 deletions(-) create mode 100644 Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/abilities/WraithDeathEvent.java diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventCreature.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventCreature.java index 1741fbecc..9103fca7f 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventCreature.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventCreature.java @@ -275,7 +275,7 @@ public abstract class EventCreature implements Listener spawnEntity(); } - if (UtilMath.offset2d(_entity.getLocation(), _spawnLocation) > 30) + if (UtilMath.offset2d(_entity.getLocation(), _spawnLocation) > 24) { _entity.setVelocity(UtilAlg.getTrajectory(_entity.getLocation(), _spawnLocation).normalize().multiply(2)); } diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/NecromancerBoss.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/NecromancerBoss.java index 1684345f8..1ee7c078e 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/NecromancerBoss.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/NecromancerBoss.java @@ -1,12 +1,15 @@ package mineplex.minecraft.game.core.boss.necromancer; import mineplex.core.blockrestore.BlockRestore; +import mineplex.core.common.util.F; import mineplex.core.disguise.DisguiseManager; import mineplex.core.projectile.ProjectileManager; import mineplex.minecraft.game.core.boss.EventCreature; import mineplex.minecraft.game.core.boss.EventState; import mineplex.minecraft.game.core.boss.WorldEvent; +import mineplex.minecraft.game.core.boss.necromancer.abilities.WraithDeathEvent; import mineplex.minecraft.game.core.boss.necromancer.minion.MinionType; +import mineplex.minecraft.game.core.boss.necromancer.minion.WraithCreature; import mineplex.minecraft.game.core.condition.ConditionManager; import mineplex.minecraft.game.core.damage.DamageManager; @@ -24,21 +27,21 @@ public class NecromancerBoss extends WorldEvent @Override protected void customStart() { - Bukkit.broadcastMessage("Custom Start"); + Bukkit.broadcastMessage(F.main(getName(), "The evils of the world have manifested in the form of the " + getName() + "! Become the champion of Light and destroy him!")); spawnNecromancer(getCenterLocation()); setState(EventState.LIVE); announceStart(); } /** - * Check if this slime boss has been defeated + * Check if this necromancer boss has been defeated */ private void checkDeath() { if (getCreatures().size() == 0) { setState(EventState.COMPLETE); - Bukkit.broadcastMessage("FINISHED!"); + Bukkit.broadcastMessage(F.main(getName(), "The demonic " + getName() + " has been slain!")); } } @@ -51,6 +54,12 @@ public class NecromancerBoss extends WorldEvent { checkDeath(); } + if (creature instanceof WraithCreature) + { + WraithDeathEvent event = new WraithDeathEvent((WraithCreature)creature); + Bukkit.getPluginManager().callEvent(event); + Bukkit.broadcastMessage("Calling Wraith Death"); + } } public EventCreature spawnMinion(MinionType type, Location location) diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/NecromancerCreature.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/NecromancerCreature.java index 7aa78fc58..0f920912e 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/NecromancerCreature.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/NecromancerCreature.java @@ -5,14 +5,16 @@ import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.Iterator; +import java.util.List; import java.util.Map.Entry; import java.util.Random; -import mineplex.core.common.events.EntityVelocityChangeEvent; +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.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.boss.BossAbility; @@ -35,13 +37,18 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.HandlerList; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; public class NecromancerCreature extends EventCreature { private ArrayList _currentAbilities = new ArrayList(); private int _lastAbility; private HashMap _cooldowns = new HashMap(); - private boolean _hasUsedWraiths = false; + private boolean _hasUsedWraiths; + private List _movePoints; + private Location _movingTo; + private boolean _moving; + private long _lastMoved; public NecromancerCreature(NecromancerBoss boss, Location location, double maxHealth) { @@ -111,8 +118,8 @@ public class NecromancerCreature extends EventCreature if (_lastAbility-- <= 0 && canDoNew && UtilBlock.solid(getEntity().getLocation().getBlock().getRelative(BlockFace.DOWN))) { - HashMap weight = new HashMap(); - HashMap dist = new HashMap(); + HashMap, Integer> weight = new HashMap<>(); + HashMap dist = new HashMap<>(); for (Player player : UtilPlayer.getNearby(getEntity().getLocation(), 50, true)) { @@ -125,13 +132,14 @@ public class NecromancerCreature extends EventCreature if (!dist.isEmpty()) { {// Strike and Pulse - ArrayList players = getPlayers(dist, UtilMath.r(10) == 0 ? 10 : 6); - + ArrayList players = getPlayers(dist, UtilMath.r(10) == 0 ? 20 : 16); + ArrayList near = getPlayers(dist, 5); + if (!players.isEmpty()) { - if (players.size() >= 4 && new Random().nextDouble() <= .45) + if (!near.isEmpty() && near.size() >= 4 && new Random().nextDouble() <= .45) { - weight.put(NecromancerPulse.class, 998); + weight.put(NecromancerPulse.class, 999); } else { @@ -140,23 +148,36 @@ public class NecromancerCreature extends EventCreature } } {// Smite - ArrayList players = getPlayers(dist, 10); + ArrayList players = getPlayers(dist, 15); if (!players.isEmpty()) { weight.put(NecromancerSmite.class, 6); } } + if (getHealthPercent() < .7) {//Hellish Flood - weight.put(NecromancerHellishFlood.class, 6); - } - if (getHealth() <= 90) - {// Wraith Summon - if (!_hasUsedWraiths) + ArrayList players = getPlayers(dist, 20); + double score = 0; + for (Player player : players) { - weight.clear(); - weight.put(NecromancerWraithSummon.class, 999); + score += (18 - dist.get(player)) / 2; } + if (players.size() >= 4 || (!players.isEmpty() && players.get(0).isOp())) + { + score += 17; + } + if (score > 0) + { + weight.put(NecromancerHellishFlood.class, (int) Math.ceil(score)); + } + } + Bukkit.broadcastMessage(_hasUsedWraiths + ""); + if (getHealth() <= 90 && !_hasUsedWraiths) + {// Wraith Summon + _hasUsedWraiths = true; + weight.clear(); + weight.put(NecromancerWraithSummon.class, 999); } } @@ -173,6 +194,25 @@ public class NecromancerCreature extends EventCreature } } + if (_moving) + { + Iterator> trying = weight.keySet().iterator(); + while (trying.hasNext()) + { + Class abilityClass = trying.next(); + + try + { + BossAbility ability = abilityClass.newInstance(); + if (!ability.canMove()) + { + trying.remove(); + } + } + catch (Exception e) {} + } + } + BossAbility ability = null; if (!weight.isEmpty()) @@ -188,7 +228,7 @@ public class NecromancerCreature extends EventCreature { int luckyNumber = UtilMath.r(i); - for (Entry entry : weight.entrySet()) + for (Entry, Integer> entry : weight.entrySet()) { luckyNumber -= entry.getValue(); @@ -196,7 +236,7 @@ public class NecromancerCreature extends EventCreature { try { - ability = (BossAbility) entry.getKey().getConstructor(NecromancerCreature.class).newInstance(this); + ability = entry.getKey().getConstructor(NecromancerCreature.class).newInstance(this); if (ability.getTarget() == null || ability.hasFinished()) { @@ -224,11 +264,6 @@ public class NecromancerCreature extends EventCreature Bukkit.getPluginManager().registerEvents(ability, getEvent().getPlugin()); System.out.print("Necromancer is using " + ability.getClass().getSimpleName()); - - if (ability instanceof NecromancerWraithSummon) - { - _hasUsedWraiths = true; - } _currentAbilities.add(ability); } @@ -240,6 +275,63 @@ public class NecromancerCreature extends EventCreature { ability.tick(); } + + boolean canMove = true; + for (BossAbility ability : _currentAbilities) + { + if (!ability.canMove()) + { + canMove = false; + } + } + + if (_moving) + { + if (_movingTo == null) + { + _movingTo = selectWalkTarget(); + } + if (UtilMath.offset(getEntity().getLocation(), _movingTo) > 1.3) + { + _lastMoved = System.currentTimeMillis(); + _movingTo = null; + _moving = false; + return; + } + UtilEnt.LookAt(getEntity(), _movingTo); + Vector walk = UtilAlg.getTrajectory(getEntity().getLocation(), _movingTo); + walk.multiply(walk.length()); + getEntity().setVelocity(walk); + } + else + { + if (!UtilTime.elapsed(_lastMoved, 7000) || !canMove) + { + return; + } + _movingTo = selectWalkTarget(); + _moving = true; + } + } + + private Location selectWalkTarget() + { + if (_movePoints.isEmpty()) + { + generateWalkPoints(getEntity().getLocation()); + } + Location selected = _movePoints.get(new Random().nextInt(_movePoints.size())); + _movePoints.remove(selected); + + return selected; + } + + private void generateWalkPoints(Location base) + { + _movePoints.add(base.clone().add(5 + UtilMath.random(1, 3), 0, 5 + UtilMath.random(1, 3))); + _movePoints.add(base.clone().add(-5 + UtilMath.random(1, 3), 0, 5 + UtilMath.random(1, 3))); + _movePoints.add(base.clone().add(5 + UtilMath.random(1, 3), 0, -5 + UtilMath.random(1, 3))); + _movePoints.add(base.clone().add(-5 + UtilMath.random(1, 3), 0, -5 + UtilMath.random(1, 3))); } private ArrayList getPlayers(HashMap map, double maxDist) @@ -297,13 +389,4 @@ public class NecromancerCreature extends EventCreature event.SetCancelled("Boss Invulnerability"); } } - - @EventHandler - public void onVelocity(EntityVelocityChangeEvent event) - { - if (event.getEntity().getEntityId() == getEntity().getEntityId()) - { - event.setCancelled(true); - } - } } \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/abilities/NecromancerHellishFlood.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/abilities/NecromancerHellishFlood.java index 832399221..69d986ca2 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/abilities/NecromancerHellishFlood.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/abilities/NecromancerHellishFlood.java @@ -13,6 +13,7 @@ import mineplex.minecraft.game.core.boss.necromancer.NecromancerBoss; import mineplex.minecraft.game.core.boss.necromancer.NecromancerCreature; import mineplex.minecraft.game.core.boss.necromancer.minion.MinionType; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Skeleton; @@ -20,12 +21,13 @@ public class NecromancerHellishFlood extends BossAbility _waves = new ConcurrentHashMap<>(); + private ConcurrentHashMap _waves = new ConcurrentHashMap<>(); private long _lastSpawned; private int _current; + private int _ticks; public NecromancerHellishFlood(NecromancerCreature creature) { @@ -54,7 +56,13 @@ public class NecromancerHellishFlood extends BossAbility ((WAVE_DELAY / 1000) * 20 * (WAVE_COUNT - 1)); } @Override public void setFinished() { _waves.clear(); + _ticks = 60; } @Override public void tick() { + _ticks++; if (UtilTime.elapsed(_lastSpawned, WAVE_DELAY)) { - if (_current <= _waves.size()) + Bukkit.broadcastMessage("Current: " + _current + ", Size: " + WAVE_COUNT); + if (_current <= WAVE_COUNT) { - for (MinionType type : _waves.get(_current)) + for (MinionType type : _waves.get("Wave " + _current)) { Location toSpawn = getLocation().clone(); toSpawn.add(UtilMath.random(3, 6), 0, UtilMath.random(3, 6)); @@ -100,7 +111,9 @@ public class NecromancerHellishFlood extends BossAbility private static final long TOTAL_ATTACK_DURATION = 3000; private long _start, _lastIncrement; private int _radius; + private Location _center; public NecromancerPulse(NecromancerCreature creature) { @@ -28,6 +30,7 @@ public class NecromancerPulse extends BossAbility _start = System.currentTimeMillis(); _radius = 2; _lastIncrement = System.currentTimeMillis(); + _center = creature.getEntity().getLocation(); } private int getRadius() @@ -38,7 +41,7 @@ public class NecromancerPulse extends BossAbility @Override public int getCooldown() { - return 5; + return 7; } @Override @@ -79,7 +82,7 @@ public class NecromancerPulse extends BossAbility double x = getRadius() * Math.cos(token); double z = getRadius() * Math.sin(token); - UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, getEntity().getLocation().add(x, 0.3, z), null, 0, 1, ViewDist.MAX); + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, _center.clone().add(x, 0.3, z), null, 0, 1, ViewDist.MAX); } for (Player player : UtilPlayer.getInRadius(getEntity().getLocation(), getRadius()).keySet()) diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/abilities/NecromancerSmite.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/abilities/NecromancerSmite.java index 217dd7d68..d7e1a3daa 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/abilities/NecromancerSmite.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/abilities/NecromancerSmite.java @@ -85,7 +85,7 @@ public class NecromancerSmite extends BossAbility else { _shot = true; - for (Player player : UtilPlayer.getInRadius(getEntity().getLocation(), 10).keySet()) + for (Player player : UtilPlayer.getInRadius(getEntity().getLocation(), 15).keySet()) { if (player.isDead() || !player.isValid() || !player.isOnline()) { diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/abilities/NecromancerStrike.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/abilities/NecromancerStrike.java index cb42fbeb5..914858890 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/abilities/NecromancerStrike.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/abilities/NecromancerStrike.java @@ -25,7 +25,7 @@ import com.google.common.collect.Lists; public class NecromancerStrike extends BossAbility { - private static final double MAX_RANGE = 10; + private static final double MAX_RANGE = 20; private static final Integer MAX_TARGETS = 3; private boolean _shot; @@ -124,13 +124,13 @@ public class NecromancerStrike extends BossAbility @@ -31,6 +30,7 @@ public class NecromancerWraithSummon extends BossAbility _wraiths = new ConcurrentHashMap<>(); private Location[] _spawns; + private int _ticks; public NecromancerWraithSummon(NecromancerCreature creature) { @@ -43,32 +43,7 @@ public class NecromancerWraithSummon extends BossAbility 0) - { - for (int i = 0; i < WRAITH_AMOUNT; i++) - { - int spawnIndex = i; - if (spawnIndex >= _spawns.length) - { - spawnIndex = spawnIndex % _spawns.length; - } - spawnWraith(_spawns[spawnIndex], i + 1); - } - - for (Player player : UtilPlayer.getInRadius(getEntity().getLocation(), 80).keySet()) - { - if (player.isDead() || !player.isValid() || !player.isOnline()) - { - continue; - } - if (player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR) - { - continue; - } - - player.sendMessage(F.main(getBoss().getEvent().getName(), "You must slay all " + WRAITH_AMOUNT + " wraiths before continuing to fight the Necromancer!")); - } - } + Bukkit.broadcastMessage("Instantiated Wraith"); } private String getNumberString(Integer number) @@ -126,7 +101,7 @@ public class NecromancerWraithSummon extends BossAbility 40; } @Override @@ -137,11 +112,42 @@ public class NecromancerWraithSummon extends BossAbility 0) + { + for (int i = 0; i < WRAITH_AMOUNT; i++) + { + int spawnIndex = i; + if (spawnIndex >= _spawns.length) + { + spawnIndex = spawnIndex % _spawns.length; + } + spawnWraith(_spawns[spawnIndex], i + 1); + } + + for (Player player : UtilPlayer.getInRadius(getEntity().getLocation(), 80).keySet()) + { + if (player.isDead() || !player.isValid() || !player.isOnline()) + { + continue; + } + if (player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR) + { + continue; + } + + player.sendMessage(F.main(getBoss().getEvent().getName(), "You must slay all " + WRAITH_AMOUNT + " wraiths before continuing to fight the Necromancer!")); + } + } + } + _ticks++; if (!hasFinished()) { int ticks = 10; @@ -168,14 +174,12 @@ public class NecromancerWraithSummon extends BossAbility } // Damage - event.AddMod(damager.getName(), "Mystical Darkness", 2, false); - - // Condition - getEvent().getCondition().Factory().Poison("Mystical Darkness", damagee, damager, 5, 0, false, true, false); + event.AddMult(damager.getName(), "Mystical Darkness", 2, false); } @EventHandler @@ -136,7 +133,7 @@ public class WraithCreature extends EventCreature UtilParticle.PlayParticleToAll(ParticleType.SMOKE, zombie.getLocation(), 0, 0, 0, 0, 5, ViewDist.MAX); zombie.getWorld().playSound(zombie.getLocation(), Sound.ENDERMAN_TELEPORT, 1f, 2f); - zombie.teleport(zombie.getTarget().getLocation().add(UtilMath.random(0, 1.5), 0, UtilMath.random(0, 1.5))); + zombie.teleport(zombie.getTarget().getLocation().add(Math.random() + 1, 0, Math.random() + 1)); UtilParticle.PlayParticleToAll(ParticleType.SMOKE, zombie.getLocation(), 0, 0, 0, 0, 5, ViewDist.MAX); zombie.getWorld().playSound(zombie.getLocation(), Sound.ENDERMAN_TELEPORT, 1f, 2f); } From 0be317e5be60414cf1ae16b90dafe9439bbc4443 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 11 Jul 2016 11:36:48 -0400 Subject: [PATCH 23/90] Implement tweaks and finalize implementations for bosses and fix loot dropping bugs --- .../common/block/schematic/Schematic.java | 20 +- .../block/schematic/SchematicRunnable.java | 11 +- .../core/blockrestore/BlockRestoreMap.java | 11 +- .../mineplex/game/clans/clans/ClanTips.java | 4 +- .../clans/clans/nether/NetherManager.java | 431 ++++++++++++------ .../game/clans/clans/nether/NetherPortal.java | 166 +++++++ .../game/clans/clans/nether/Portal.java | 143 ------ .../clans/nether/command/CreateCommand.java | 21 + .../clans/nether/command/DeleteCommand.java | 44 ++ .../clans/nether/command/ListCommand.java | 21 + .../clans/nether/command/PortalCommand.java | 32 ++ .../clans/nether/command/SpawnCommand.java | 24 + .../clans/nether/command/WandCommand.java | 21 + .../clans/clans/nether/data/ClaimData.java | 43 ++ .../clans/nether/miniboss/NetherMiniBoss.java | 85 ++++ .../miniboss/NetherMinibossManager.java | 61 +++ .../nether/miniboss/NetherMinibossType.java | 34 ++ .../clans/worldevent/WorldEventManager.java | 50 +- .../clans/worldevent/WorldEventType.java | 4 +- .../game/clans/items/GearManager.java | 16 +- .../minecraft/game/core/boss/BossPassive.java | 41 ++ .../game/core/boss/EventCreature.java | 11 +- .../core/boss/EventCreatureDeathEvent.java | 31 ++ .../minecraft/game/core/boss/WorldEvent.java | 22 +- .../game/core/boss/ironwizard/GolemBoss.java | 2 +- .../core/boss/ironwizard/GolemCreature.java | 29 +- .../ironwizard/abilities/GolemBlockHail.java | 2 +- .../abilities/GolemDeadlyTremor.java | 4 +- .../abilities/WraithDeathEvent.java | 33 -- .../SkeletonBoss.java} | 54 ++- .../SkeletonCreature.java} | 140 ++++-- .../abilities/SkeletonArcherShield.java | 186 ++++++++ .../abilities/SkeletonHellishFlood.java} | 20 +- .../abilities/SkeletonPassive.java | 121 +++++ .../abilities/SkeletonPulse.java} | 21 +- .../abilities/SkeletonSmite.java} | 8 +- .../abilities/SkeletonStrike.java} | 25 +- .../abilities/SkeletonWraithSummon.java} | 77 +++- .../minion/MinionType.java | 2 +- .../minion/UndeadArcherCreature.java | 71 ++- .../minion/UndeadWarriorCreature.java | 84 +++- .../minion/WraithCreature.java | 53 ++- 42 files changed, 1790 insertions(+), 489 deletions(-) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java delete mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/Portal.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/CreateCommand.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/DeleteCommand.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/ListCommand.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/PortalCommand.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/SpawnCommand.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/WandCommand.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/data/ClaimData.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMiniBoss.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossManager.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossType.java create mode 100644 Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/BossPassive.java create mode 100644 Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventCreatureDeathEvent.java delete mode 100644 Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/abilities/WraithDeathEvent.java rename Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/{necromancer/NecromancerBoss.java => skeletonking/SkeletonBoss.java} (58%) rename Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/{necromancer/NecromancerCreature.java => skeletonking/SkeletonCreature.java} (67%) create mode 100644 Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/abilities/SkeletonArcherShield.java rename Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/{necromancer/abilities/NecromancerHellishFlood.java => skeletonking/abilities/SkeletonHellishFlood.java} (78%) create mode 100644 Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/abilities/SkeletonPassive.java rename Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/{necromancer/abilities/NecromancerPulse.java => skeletonking/abilities/SkeletonPulse.java} (77%) rename Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/{necromancer/abilities/NecromancerSmite.java => skeletonking/abilities/SkeletonSmite.java} (89%) rename Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/{necromancer/abilities/NecromancerStrike.java => skeletonking/abilities/SkeletonStrike.java} (81%) rename Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/{necromancer/abilities/NecromancerWraithSummon.java => skeletonking/abilities/SkeletonWraithSummon.java} (55%) rename Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/{necromancer => skeletonking}/minion/MinionType.java (91%) rename Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/{necromancer => skeletonking}/minion/UndeadArcherCreature.java (76%) rename Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/{necromancer => skeletonking}/minion/UndeadWarriorCreature.java (63%) rename Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/{necromancer => skeletonking}/minion/WraithCreature.java (80%) 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 4545425ec..16d2e9188 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 @@ -190,13 +190,29 @@ public class Schematic return index < _blocks.length; } - public short getBlock(int x, int y, int z) + public Short getBlock(int x, int y, int z) { + if (getIndex(x, y, z) >= _blocks.length) + { + return null; + } + if (getIndex(x, y, z) < 0) + { + return null; + } return _blocks[getIndex(x, y, z)]; } - public byte getData(int x, int y, int z) + public Byte getData(int x, int y, int z) { + if (getIndex(x, y, z) >= _blocks.length) + { + return null; + } + if (getIndex(x, y, z) < 0) + { + return null; + } return _blockData[getIndex(x, y, z)]; } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/block/schematic/SchematicRunnable.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/block/schematic/SchematicRunnable.java index e3b8c1d0a..b45c9b682 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/block/schematic/SchematicRunnable.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/block/schematic/SchematicRunnable.java @@ -99,10 +99,13 @@ public class SchematicRunnable implements Runnable private void setBlock(Block block, int x, int y, int z) { - - int materialId = _schematic.getBlock(x, y, z); - byte data = _schematic.getData(x, y, z); - + Short materialId = _schematic.getBlock(x, y, z); + Byte data = _schematic.getData(x, y, z); + + if (materialId == null || data == null) + { + return; + } Material material = Material.getMaterial(materialId); if (material == null) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestoreMap.java b/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestoreMap.java index fb123e315..37ac4bb86 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestoreMap.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestoreMap.java @@ -41,9 +41,14 @@ public class BlockRestoreMap public void addBlockData(BlockData blockData) { Block block = blockData.Block; - - if (!_blocks[block.getY()].containsKey(block)) - _blocks[block.getY()].put(block, blockData); + + if (block.getY() > 0 && block.getY() < _blocks.length) + { + if (!_blocks[block.getY()].containsKey(block)) + { + _blocks[block.getY()].put(block, blockData); + } + } _changedBlocks.add(blockData.Block); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanTips.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanTips.java index 4f2c6e166..0520548b8 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanTips.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanTips.java @@ -226,8 +226,8 @@ public class ClanTips extends MiniPlugin }), ENTER_NETHER( new String[] { - C.cDAqua + "The Nether", - C.cAqua + "Welcome to the Nether. This is a very scary place full of fire and is a place for people to battle to the death! TODO: Write something better about the nether here" + C.cDRedB + "The Nether", + C.cRed + "The Nether is the home of all that is evil and monstrous, the true origin of demonic power. While here you can slay terrible creatures to find amazing loot, but remember that its darkness will slowly poison your body and kill you after 20 minutes!" }), ; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java index b17121c43..bca49b00d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java @@ -1,8 +1,36 @@ package mineplex.game.clans.clans.nether; import java.io.File; +import java.io.IOException; +import java.util.HashMap; import java.util.List; +import mineplex.core.MiniPlugin; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +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.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.common.util.UtilWorld; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.event.ClansCommandExecutedEvent; +import mineplex.game.clans.clans.nether.command.PortalCommand; +import mineplex.game.clans.clans.nether.data.ClaimData; +import mineplex.game.clans.spawn.Spawn; +import mineplex.minecraft.game.core.boss.EventCreatureDeathEvent; +import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature; +import mineplex.minecraft.game.core.boss.skeletonking.SkeletonCreature; +import mineplex.minecraft.game.core.boss.spider.SpiderCreature; +import mineplex.minecraft.game.core.condition.Condition.ConditionType; + import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Location; @@ -10,56 +38,64 @@ import org.bukkit.Material; import org.bukkit.World; import org.bukkit.WorldBorder; import org.bukkit.block.Block; +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.configuration.file.YamlConfiguration; 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.block.BlockBreakEvent; import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityPortalEvent; +import org.bukkit.event.player.PlayerDropItemEvent; +import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerPortalEvent; +import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.inventory.ItemStack; import com.google.common.collect.Lists; -import mineplex.core.MiniPlugin; -import mineplex.core.common.Rank; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilCollections; -import mineplex.core.common.util.UtilFile; -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.common.util.UtilWorld; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.game.clans.clans.ClanTips.TipType; -import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.core.repository.ClanTerritory; - public class NetherManager extends MiniPlugin { - private ClansManager _clansManager; - + private static final long PORTAL_OPEN_DURATION = UtilTime.convert(30, TimeUnit.MINUTES, TimeUnit.SECONDS) * 20; + private static final long NETHER_SLOW_WARMUP = UtilTime.convert(17, TimeUnit.MINUTES, TimeUnit.MILLISECONDS); + private static final long NETHER_BLIND_WARMUP = UtilTime.convert(18, TimeUnit.MINUTES, TimeUnit.MILLISECONDS); + private static final long NETHER_ALLOWED_DURATION = UtilTime.convert(20, TimeUnit.MINUTES, TimeUnit.MILLISECONDS); + private static final String CLAIM_WAND_NAME = C.cRedB + "Portal Claim Wand"; + private static final String[] CLAIM_WAND_LORE = new String[] {C.cYellow + "Left Click to select the Portal's first corner", C.cYellow + "Right Click to select the Portal's second corner"}; + private static final ItemStack CLAIM_WAND = new ItemBuilder(Material.WOOD_AXE).setTitle(CLAIM_WAND_NAME).setLore(CLAIM_WAND_LORE).build(); private World _netherWorld; - - private List _portals = Lists.newArrayList(); - + public List Portals = Lists.newArrayList(); private File _portalCfg; + private YamlConfiguration _portalConfig; + public HashMap InNether = new HashMap<>(); + public HashMap Claiming = new HashMap<>(); - public NetherManager(ClansManager clansManager) + public NetherManager(ClansManager manager) { - super("Nether Manager", clansManager.getPlugin()); - _clansManager = clansManager; + super("Nether Manager", manager.getPlugin()); - _portalCfg = new File(UtilServer.getServer().getWorlds().get(0).getWorldFolder().getPath() + File.separator + ".." + File.separator + "nether.cfg"); + _portalCfg = new File(UtilServer.getServer().getWorlds().get(0).getWorldFolder().getPath() + File.separator + ".." + File.separator + "portals.yml"); + + try + { + if (!_portalCfg.exists()) + { + _portalCfg.createNewFile(); + } + _portalConfig = YamlConfiguration.loadConfiguration(_portalCfg); + } + catch (Exception e) + { + e.printStackTrace(); + } begin(); + addCommand(new PortalCommand(this)); } - public void begin() + private void begin() { _netherWorld = Bukkit.getWorld("world_nether"); @@ -67,52 +103,54 @@ public class NetherManager extends MiniPlugin worldBorder.setCenter(0, 0); worldBorder.setSize(200 * 2); - parsePortals(); + loadPortals(); } - private void parsePortals() + private void loadPortals() { - String data = UtilFile.read(_portalCfg); - - if (data.length() < 5) + try { - return; + if (!_portalConfig.isInt("PortalCount")) + { + _portalConfig.set("PortalCount", 0); + _portalConfig.save(_portalCfg); + } + if (!_portalConfig.isConfigurationSection("Portals")); + { + _portalConfig.createSection("Portals"); + _portalConfig.save(_portalCfg); + } + + log("Loading " + _portalConfig.getInt("PortalCount") + " Nether Portals!"); + for (String portalSectionPath : _portalConfig.getConfigurationSection("Portals").getValues(false).keySet()) + { + ConfigurationSection portal = _portalConfig.getConfigurationSection("Portals." + portalSectionPath); + Location firstCorner = UtilWorld.strToLoc(portal.getString("CornerOne")); + Location secondCorner = UtilWorld.strToLoc(portal.getString("CornerTwo")); + + NetherPortal netherPortal = new NetherPortal(firstCorner, secondCorner); + Portals.add(netherPortal); + } + } + catch (Exception e) + { + e.printStackTrace(); } - - UtilCollections.forEach(data.split("\n"), string -> string.trim(), sPortal -> { - - String[] destinations = sPortal.split(">>"); - - Location from = UtilWorld.strToLoc(destinations[0]); - Location to = UtilWorld.strToLoc(destinations[1].split(":")[0]); - - Portal portal = Portal.create(from, to, UtilWorld.strToLoc(to.getWorld().getName() + "," + destinations[1].split(":")[1])); - - if (portal == null) - { - log("FAILED TO LOAD PORTAL [" + sPortal + "]"); - } - else - { - _portals.add(portal); - } - }); } - - - @EventHandler - public void cmd(PlayerCommandPreprocessEvent event) + + public void savePortals() throws IOException { - if (!_clansManager.getClientManager().hasRank(event.getPlayer(), Rank.JNR_DEV)) + _portalConfig.set("PortalCount", Portals.size()); + _portalConfig.set("Portals", null); + _portalConfig.createSection("Portals"); + for (int i = 0; i < Portals.size(); i++) { - return; + int id = i + 1; + _portalConfig.set("Portals." + id + ".CornerOne", Portals.get(0).getCorners()[0]); + _portalConfig.set("Portals." + id + ".CornerTwo", Portals.get(0).getCorners()[1]); } - if (event.getMessage().startsWith("/nether")) - { - event.getPlayer().teleport(new Location(_netherWorld, 0, 90, 0)); - event.setCancelled(true); - } + _portalConfig.save(_portalCfg); } @EventHandler @@ -132,28 +170,12 @@ public class NetherManager extends MiniPlugin return; } - _portals - .stream() - .filter(portal -> UtilAlg.getAverageBlockLocation(portal.getToBlocks()).distance(block.getLocation()) < 15) - .limit(1) - .forEach(portal -> { - UtilPlayer.message(player, F.main("Clans", "You are not allowed to break this block.")); - event.setCancelled(true); - }); - if (!item.getType().equals(Material.GOLD_PICKAXE)) { UtilPlayer.message(player, F.main("Clans", "You can only break blocks in the Nether with a " + F.elem("Golden Pickaxe") + ".")); event.setCancelled(true); return; } - - if (block.getType().equals(Material.OBSIDIAN) || block.getType().equals(Material.PORTAL)) - { - UtilPlayer.message(player, F.main("Clans", "You are not allowed to break this block.")); - event.setCancelled(true); - return; - } } @EventHandler @@ -179,22 +201,29 @@ public class NetherManager extends MiniPlugin event.setCancelled(true); return; } - - _portals - .stream() - .filter(portal -> UtilAlg.getAverageBlockLocation(portal.getToBlocks()).distance(block.getLocation()) < 15) - .limit(1) - .forEach(portal -> { - UtilPlayer.message(player, F.main("Clans", "You are not allowed to place blocks here.")); - event.setCancelled(true); - }); - - if (block.getType().equals(Material.OBSIDIAN) || block.getType().equals(Material.PORTAL)) + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onPortal(PlayerPortalEvent event) + { + if (event.getTo().getWorld().equals(_netherWorld)) { - UtilPlayer.message(player, F.main("Clans", "You are not allowed to place blocks here.")); - event.setCancelled(true); return; } + event.setCancelled(true); + runSyncLater(() -> + { + InNether.remove(event.getPlayer()); + ClansManager.getInstance().getCondition().Clean(event.getPlayer()); + event.getPlayer().teleport(Spawn.getNorthSpawn()); + UtilPlayer.message(event.getPlayer(), F.main(getName(), "You have escaped " + F.clansNether("The Nether") + "!")); + }, 1); + } + + @EventHandler + public void onPortal(EntityPortalEvent event) + { + event.setCancelled(true); } @EventHandler @@ -202,66 +231,129 @@ public class NetherManager extends MiniPlugin { if (event.getType() == UpdateType.FAST) { + List netherKeys = Lists.newArrayList(); + netherKeys.addAll(InNether.keySet()); + for (Player player : netherKeys) + { + if (UtilTime.elapsed(InNether.get(player), NETHER_ALLOWED_DURATION)) + { + InNether.remove(player); + if (isInNether(player)) + { + ClansManager.getInstance().getCondition().Clean(player); + UtilPlayer.message(player, F.main(getName(), "You have failed to escape " + F.clansNether("The Nether") + " and have been destroyed by its demonic poisons!")); + ClansManager.getInstance().getDamageManager().NewDamageEvent(player, null, null, DamageCause.CUSTOM, 9999, false, true, true, C.cDRed + "The Nether", "Nether Poison"); + } + continue; + } + if (UtilTime.elapsed(InNether.get(player), NETHER_SLOW_WARMUP)) + { + if (!ClansManager.getInstance().getCondition().HasCondition(player, ConditionType.SLOW, "Nether Corruption")) + { + ClansManager.getInstance().getCondition().Factory().Slow("Nether Corruption", player, null, 9999, 1, false, true, false, false); + } + } + if (UtilTime.elapsed(InNether.get(player), NETHER_BLIND_WARMUP)) + { + if (!ClansManager.getInstance().getCondition().HasCondition(player, ConditionType.BLINDNESS, "Nether Corruption")) + { + ClansManager.getInstance().getCondition().Factory().Blind("Nether Corruption", player, null, 9999, 1, false, true, false); + } + } + } + UtilServer.getPlayersCollection() .stream() - .filter(player -> player.getWorld().equals(_netherWorld)) + .filter(player -> isInNether(player)) .forEach(player -> { player.setCompassTarget(new Location(_netherWorld, -200.d + UtilMath.r(400), player.getLocation().getY(), -200.d + UtilMath.r(400))); - _clansManager.getItemMapManager().removeMap(player); + ClansManager.getInstance().getItemMapManager().removeMap(player); }); } - - if (event.getType() == UpdateType.SLOW) - { - _portals.forEach(portal -> { - portal.getFromObsidianBlocks().forEach(block -> UtilBlock.setSilent(block, Material.OBSIDIAN)); - portal.getFromPortalBlocks().forEach(block -> UtilBlock.setSilent(block, Material.PORTAL)); - - portal.getToObsidianBlocks().forEach(block -> UtilBlock.setSilent(block, Material.OBSIDIAN)); - portal.getToPortalBlocks().forEach(block -> UtilBlock.setSilent(block, Material.PORTAL)); - }); - } } - @EventHandler(priority = EventPriority.HIGHEST) - public void onPortal(PlayerPortalEvent event) + @EventHandler(priority = EventPriority.LOWEST) + public void onQuit(PlayerQuitEvent event) { - Player player = event.getPlayer(); - Location location = player.getLocation(); - - ClanTerritory territory = _clansManager.getClanUtility().getClaim(location); - - if (event.getTo().getWorld().equals(_netherWorld)) + if (isInNether(event.getPlayer())) { - if (territory != null && territory.Owner.equals("Borderlands")) + InNether.remove(event.getPlayer()); + ClansManager.getInstance().getCondition().Clean(event.getPlayer()); + ClansManager.getInstance().getDamageManager().NewDamageEvent(event.getPlayer(), null, null, DamageCause.CUSTOM, 9999, false, true, true, C.cDRed + "The Nether", "Nether Poison"); + } + Claiming.remove(event.getPlayer()); + } + + @EventHandler + public void onTpHome(ClansCommandExecutedEvent event) + { + if (event.getCommand().equalsIgnoreCase("tphome")) + { + if (isInNether(event.getPlayer())) { - _portals - .stream() - .filter(portal -> - portal.getFromPortalBlocks() - .stream() - .filter(block -> player.getLocation().distance(block.getLocation()) <= 2) - .iterator().hasNext() - ).limit(1) - .forEach(portal -> { - event.setTo(portal.getToOut()); - _clansManager.ClanTips.displayTip(TipType.ENTER_NETHER, player); - }); + event.setCancelled(true); + UtilPlayer.message(event.getPlayer(), F.main(getName(), "You cannot teleport to your Clan home while in " + F.clansNether("The Nether") + "!")); } } - else + } + + @EventHandler + public void onDropWand(PlayerDropItemEvent event) + { + ItemStack item = event.getItemDrop().getItemStack(); + if (item.getItemMeta().hasDisplayName() && item.getItemMeta().getDisplayName().equalsIgnoreCase(CLAIM_WAND_NAME)) { - _portals - .stream() - .filter(portal -> - portal.getToPortalBlocks() - .stream() - .filter(block -> player.getLocation().distance(block.getLocation()) <= 2) - .iterator().hasNext() - ).limit(1) - .forEach(portal -> { - event.setTo(UtilAlg.getAverageBlockLocation(portal.getFromPortalBlocks())); - }); + runSyncLater(() -> + { + event.getItemDrop().remove(); + }, 1L); + } + } + + @EventHandler + public void onUseWand(PlayerInteractEvent event) + { + if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.LEFT_CLICK_BLOCK) + { + return; + } + if (!event.hasBlock() || !event.hasItem()) + { + return; + } + if (!ClansManager.getInstance().getClientManager().hasRank(event.getPlayer(), Rank.ADMIN)) + { + return; + } + ItemStack item = event.getItem(); + if (item.getItemMeta().hasDisplayName() && item.getItemMeta().getDisplayName().equalsIgnoreCase(CLAIM_WAND_NAME)) + { + Block block = event.getClickedBlock(); + if (!Claiming.containsKey(event.getPlayer())) + { + Claiming.put(event.getPlayer(), new ClaimData()); + } + ClaimData data = Claiming.get(event.getPlayer()); + if (event.getAction() == Action.RIGHT_CLICK_BLOCK) + { + data.setSecondCorner(block); + UtilPlayer.message(event.getPlayer(), F.main(getName(), "You have selected the Portal's second corner!")); + } + else + { + data.setFirstCorner(block); + UtilPlayer.message(event.getPlayer(), F.main(getName(), "You have selected the Portal's first corner!")); + } + } + } + + @EventHandler + public void onBossDeath(EventCreatureDeathEvent event) + { + if (event.getCreature() instanceof GolemCreature || event.getCreature() instanceof SkeletonCreature || event.getCreature() instanceof SpiderCreature) + { + //spawnPortal(); + Bukkit.broadcastMessage("A PORTAL SPAWN WOULD BE CALLED HERE IF IT WASN'T DISABLED"); } } @@ -274,4 +366,61 @@ public class NetherManager extends MiniPlugin { return player.getWorld().equals(_netherWorld); } -} + + public void spawnPortal() + { + if (Portals.isEmpty()) + { + return; + } + NetherPortal portal = Portals.get(UtilMath.r(Portals.size())); + portal.open(); + UtilTextMiddle.display(F.clansNether("Nether Portal"), "Has opened at " + F.elem(UtilWorld.locToStrClean(portal.getLocation()))); + Bukkit.broadcastMessage(F.main(getName(), "A " + F.clansNether("Nether Portal") + " has opened at " + F.elem(UtilWorld.locToStrClean(portal.getLocation())))); + runSyncLater(() -> + { + portal.close(); + }, PORTAL_OPEN_DURATION); + } + + public void createPortal(Player creator) + { + if (Claiming.getOrDefault(creator, new ClaimData()).getTotalSelected() < 2) + { + UtilPlayer.message(creator, F.main(getName(), "You do not have a top and bottom corner selected!")); + return; + } + + ClaimData data = Claiming.remove(creator); + NetherPortal portal = new NetherPortal(data.getFirstCorner().getLocation(), data.getSecondCorner().getLocation()); + Portals.add(portal); + + try + { + savePortals(); + } + catch (Exception e) + { + UtilPlayer.message(creator, F.main(getName(), "An error occurred while creating that portal! Please report this immediately!")); + return; + } + } + + public void showPortalList(Player player) + { + UtilPlayer.message(player, F.main(getName(), "Portal List:")); + for (int i = 0; i < Portals.size(); i++) + { + int id = i + 1; + NetherPortal portal = Portals.get(i); + + UtilPlayer.message(player, C.cBlue + "- " + F.elem("Portal " + id + ": " + C.cGray + UtilWorld.locToStrClean(portal.getLocation()).replace("(", "").replace(")", ""))); + } + } + + public void giveWand(Player player) + { + player.getInventory().addItem(CLAIM_WAND.clone()); + UtilPlayer.message(player, F.main(getName(), "You have been given a Portal Claim Wand!")); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java new file mode 100644 index 000000000..2c485ba79 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java @@ -0,0 +1,166 @@ +package mineplex.game.clans.clans.nether; + +import java.util.List; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.game.clans.clans.ClanTips.TipType; +import mineplex.game.clans.clans.ClansManager; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.entity.EntityPortalEnterEvent; +import org.bukkit.event.entity.EntityPortalEvent; +import org.bukkit.event.player.PlayerPortalEvent; + +import com.google.common.collect.Lists; + +public class NetherPortal implements Listener +{ + private List _frame = Lists.newArrayList(); + private List _portal = Lists.newArrayList(); + private Location _loc; + private Location[] _corners; + + public NetherPortal(Location firstCorner, Location secondCorner) + { + int maxX = Math.max(firstCorner.getBlockX(), secondCorner.getBlockX()); + int minX = Math.min(firstCorner.getBlockX(), secondCorner.getBlockX()); + int maxY = Math.max(firstCorner.getBlockX(), secondCorner.getBlockX()); + int minY = Math.min(firstCorner.getBlockX(), secondCorner.getBlockX()); + int maxZ = Math.max(firstCorner.getBlockX(), secondCorner.getBlockX()); + int minZ = Math.min(firstCorner.getBlockX(), secondCorner.getBlockX()); + + for (int x = minX; x <= maxX; x++) + { + for (int y = minY; y <= maxY; y++) + { + for (int z = minZ; z <= maxZ; z++) + { + if (minX == maxX) + { + if ((y != minY && y != maxY) && (z != minZ && z != maxZ)) + { + _portal.add(firstCorner.getWorld().getBlockAt(x, y, z)); + } + else + { + _frame.add(firstCorner.getWorld().getBlockAt(x, y, z)); + } + } + else + { + if ((x != minX && x != maxX) && (y != minY && y != maxY)) + { + _portal.add(firstCorner.getWorld().getBlockAt(x, y, z)); + } + else + { + _frame.add(firstCorner.getWorld().getBlockAt(x, y, z)); + } + } + } + } + } + + _loc = new Location(firstCorner.getWorld(), minX + ((maxX - minX) / 2), maxY, minZ + ((maxZ - minZ) / 2)); + _corners = new Location[] {firstCorner, secondCorner}; + } + + private boolean isInPortal(Block block) + { + return _frame.contains(block) || _portal.contains(block); + } + + public Location getLocation() + { + return _loc; + } + + public Location[] getCorners() + { + return _corners; + } + + public void open() + { + for (Block block : _frame) + { + block.setType(Material.OBSIDIAN); + } + for (Block block : _portal) + { + block.setType(Material.PORTAL); + } + Bukkit.getPluginManager().registerEvents(this, ClansManager.getInstance().getPlugin()); + } + + public void close() + { + HandlerList.unregisterAll(this); + for (Block block : _frame) + { + block.setType(Material.AIR); + } + for (Block block : _portal) + { + block.setType(Material.AIR); + } + } + + @EventHandler + public void onBreak(BlockBreakEvent event) + { + if (isInPortal(event.getBlock())) + { + event.setCancelled(true); + UtilPlayer.message(event.getPlayer(), F.main("Clans", "You cannot destroy a " + F.clansNether("Nether Portal"))); + } + } + + @EventHandler(priority = EventPriority.LOW) + public void playerPortalEvent(PlayerPortalEvent event) + { + if (isInPortal(event.getFrom().getBlock())) + { + event.setCancelled(true); + } + } + + @EventHandler(priority = EventPriority.LOW) + public void entityPortalEvent(EntityPortalEvent event) + { + if (isInPortal(event.getFrom().getBlock())) + { + event.setCancelled(true); + } + } + + @EventHandler + public void onEnterPortal(EntityPortalEnterEvent event) + { + if (event.getEntity() instanceof Player) + { + if (isInPortal(event.getLocation().getBlock())) + { + Bukkit.getScheduler().runTaskLater(ClansManager.getInstance().getPlugin(), () -> + { + if (isInPortal(event.getEntity().getLocation().getBlock())) + { + ClansManager.getInstance().getNetherManager().InNether.put((Player)event.getEntity(), System.currentTimeMillis()); + event.getEntity().teleport(event.getLocation()); //MAKE NETHER SPAWN + ClansManager.getInstance().ClanTips.displayTip(TipType.ENTER_NETHER, (Player)event.getEntity()); + } + }, 5 * 20); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/Portal.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/Portal.java deleted file mode 100644 index 362599881..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/Portal.java +++ /dev/null @@ -1,143 +0,0 @@ -package mineplex.game.clans.clans.nether; - -import java.util.ArrayList; -import java.util.List; - -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; - -import com.google.common.collect.Lists; - -import mineplex.core.common.util.UtilBlock; - -public class Portal -{ - private List _fromPortalBlocks; - private List _fromObsidianBlocks; - - private List _toPortalBlocks; - private List _toObsidianBlocks; - - private List _fromBlocks; - private List _toBlocks; - - private Location _toOut; - - public final boolean Success; - - public Portal(Location from, Location to, Location toOut) - { - _fromPortalBlocks = Lists.newArrayList(); - _fromObsidianBlocks = Lists.newArrayList(); - - _toPortalBlocks = Lists.newArrayList(); - _toObsidianBlocks = Lists.newArrayList(); - - _toOut = toOut; - - if (!isValidPortalBlock(from.getBlock()) || !isValidPortalBlock(to.getBlock())) - { - if (!isValidPortalBlock(from.getBlock())) - from = UtilBlock.getInRadius(from.getBlock(), 4).keySet().stream().filter(this::isValidPortalBlock).limit(1).iterator().next().getLocation(); - - if (!isValidPortalBlock(to.getBlock())) - to = UtilBlock.getInRadius(to.getBlock(), 4).keySet().stream().filter(this::isValidPortalBlock).limit(1).iterator().next().getLocation(); - - if (to == null || from == null) - { - System.out.println("[PORTAL] INVALID PORTAL PROVIDED (" + from + " --> " + to + ")"); - - Success = false; - - return; - } - } - - for (Block other : UtilBlock.getInRadius(from, 25).keySet()) - { - if (other.getType() == Material.OBSIDIAN) - { - _fromObsidianBlocks.add(other); - } - else if (other.getType() == Material.PORTAL) - { - _fromPortalBlocks.add(other); - } - } - - for (Block other : UtilBlock.getInRadius(to, 7.5d).keySet()) - { - if (other.getType() == Material.OBSIDIAN) - { - _toObsidianBlocks.add(other); - } - else if (other.getType() == Material.PORTAL) - { - _toPortalBlocks.add(other); - } - } - - _fromBlocks = new ArrayList<>(); - _toBlocks = new ArrayList<>(); - - _fromBlocks.addAll(_fromObsidianBlocks); - _fromBlocks.addAll(_fromPortalBlocks); - _toBlocks.addAll(_toObsidianBlocks); - _toBlocks.addAll(_toPortalBlocks); - - Success = true; - } - - public Location getToOut() - { - return _toOut; - } - - public List getFromPortalBlocks() - { - return _fromPortalBlocks; - } - - public List getFromObsidianBlocks() - { - return _fromObsidianBlocks; - } - - public List getToPortalBlocks() - { - return _toPortalBlocks; - } - - public List getToObsidianBlocks() - { - return _toObsidianBlocks; - } - - public List getFromBlocks() - { - return _fromBlocks; - } - - public List getToBlocks() - { - return _toBlocks; - } - - private boolean isValidPortalBlock(Block block) - { - return block.getType() == Material.OBSIDIAN || block.getType() == Material.PORTAL; - } - - public static Portal create(Location from, Location to, Location toOut) - { - Portal portal = new Portal(from, to, toOut); - - if (!portal.Success) - { - return null; - } - - return portal; - } -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/CreateCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/CreateCommand.java new file mode 100644 index 000000000..2697b97ac --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/CreateCommand.java @@ -0,0 +1,21 @@ +package mineplex.game.clans.clans.nether.command; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.game.clans.clans.nether.NetherManager; + +import org.bukkit.entity.Player; + +public class CreateCommand extends CommandBase +{ + public CreateCommand(NetherManager plugin) + { + super(plugin, Rank.ADMIN, "create"); + } + + @Override + public void Execute(Player caller, String[] args) + { + Plugin.createPortal(caller); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/DeleteCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/DeleteCommand.java new file mode 100644 index 000000000..1a8b70d81 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/DeleteCommand.java @@ -0,0 +1,44 @@ +package mineplex.game.clans.clans.nether.command; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.game.clans.clans.nether.NetherManager; + +import org.bukkit.entity.Player; + +public class DeleteCommand extends CommandBase +{ + public DeleteCommand(NetherManager plugin) + { + super(plugin, Rank.ADMIN, "delete", "remove"); + } + + @Override + public void Execute(Player caller, String[] args) + { + Integer id = null; + try + { + id = Integer.parseInt(args[0]); + } + catch (Exception e) {} + if (id == null || id >= Plugin.Portals.size() || id < 1) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "Usage: " + F.elem("/portal " + _aliasUsed + " "))); + return; + } + UtilPlayer.message(caller, F.main(Plugin.getName(), "Deleting the " + F.clansNether("Nether Portal" + " with ID " + id + "!"))); + Plugin.Portals.remove(id - 1); + try + { + Plugin.savePortals(); + } + catch (Exception e) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "An error occurred while deleting that portal! Please report this immediately!")); + return; + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/ListCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/ListCommand.java new file mode 100644 index 000000000..b9bc31495 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/ListCommand.java @@ -0,0 +1,21 @@ +package mineplex.game.clans.clans.nether.command; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.game.clans.clans.nether.NetherManager; + +import org.bukkit.entity.Player; + +public class ListCommand extends CommandBase +{ + public ListCommand(NetherManager plugin) + { + super(plugin, Rank.ADMIN, "list"); + } + + @Override + public void Execute(Player caller, String[] args) + { + Plugin.showPortalList(caller); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/PortalCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/PortalCommand.java new file mode 100644 index 000000000..e146a980d --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/PortalCommand.java @@ -0,0 +1,32 @@ +package mineplex.game.clans.clans.nether.command; + +import mineplex.core.command.MultiCommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.game.clans.clans.nether.NetherManager; + +import org.bukkit.entity.Player; + +public class PortalCommand extends MultiCommandBase +{ + public PortalCommand(NetherManager plugin) + { + super(plugin, Rank.ADMIN, "netherportal", "portal"); + AddCommand(new CreateCommand(plugin)); + AddCommand(new DeleteCommand(plugin)); + AddCommand(new ListCommand(plugin)); + AddCommand(new SpawnCommand(plugin)); + AddCommand(new WandCommand(plugin)); + } + + @Override + protected void Help(Player caller, String[] args) + { + UtilPlayer.message(caller, F.help("/" + _aliasUsed + " spawn", "Forces a Nether Portal to spawn", Rank.ADMIN)); + UtilPlayer.message(caller, F.help("/" + _aliasUsed + " lists", "Lists all loaded Nether Portals", Rank.ADMIN)); + UtilPlayer.message(caller, F.help("/" + _aliasUsed + " wand", "Gives you a Nether Portal claim wand", Rank.ADMIN)); + UtilPlayer.message(caller, F.help("/" + _aliasUsed + " create", "Creates a Nether Portal with the corners you have selected", Rank.ADMIN)); + UtilPlayer.message(caller, F.help("/" + _aliasUsed + " delete", "Deletes a loaded Nether Portal", Rank.ADMIN)); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/SpawnCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/SpawnCommand.java new file mode 100644 index 000000000..9ab0efd52 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/SpawnCommand.java @@ -0,0 +1,24 @@ +package mineplex.game.clans.clans.nether.command; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.game.clans.clans.nether.NetherManager; + +public class SpawnCommand extends CommandBase +{ + public SpawnCommand(NetherManager plugin) + { + super(plugin, Rank.ADMIN, "spawn"); + } + + @Override + public void Execute(Player caller, String[] args) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "Spawning a " + F.clansNether("Nether Portal" + "!"))); + Plugin.spawnPortal(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/WandCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/WandCommand.java new file mode 100644 index 000000000..2e1bced57 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/WandCommand.java @@ -0,0 +1,21 @@ +package mineplex.game.clans.clans.nether.command; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.game.clans.clans.nether.NetherManager; + +import org.bukkit.entity.Player; + +public class WandCommand extends CommandBase +{ + public WandCommand(NetherManager plugin) + { + super(plugin, Rank.ADMIN, "wand"); + } + + @Override + public void Execute(Player caller, String[] args) + { + Plugin.giveWand(caller); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/data/ClaimData.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/data/ClaimData.java new file mode 100644 index 000000000..2549921c9 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/data/ClaimData.java @@ -0,0 +1,43 @@ +package mineplex.game.clans.clans.nether.data; + +import org.bukkit.block.Block; + +public class ClaimData +{ + private Block _first, _second; + + public Block getFirstCorner() + { + return _first; + } + + public Block getSecondCorner() + { + return _second; + } + + public int getTotalSelected() + { + int total = 2; + if (_first == null) + { + total--; + } + if (_second == null) + { + total--; + } + + return total; + } + + public void setFirstCorner(Block block) + { + _first = block; + } + + public void setSecondCorner(Block block) + { + _second = block; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMiniBoss.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMiniBoss.java new file mode 100644 index 000000000..92fa2bb5f --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMiniBoss.java @@ -0,0 +1,85 @@ +package mineplex.game.clans.clans.nether.miniboss; + +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClansManager; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDeathEvent; + +public abstract class NetherMiniBoss implements Listener +{ + private Mob _entity; + private EntityType _type; + private String _name; + private double _maxHealth; + private Location _spawn; + + public NetherMiniBoss(String displayName, Double maxHealth, Location spawn, EntityType type) + { + _name = displayName; + _maxHealth = maxHealth; + _spawn = spawn; + _type = type; + + spawn(); + } + + @SuppressWarnings("unchecked") + private void spawn() + { + _entity = (Mob) _spawn.getWorld().spawnEntity(_spawn, _type); + _entity.setMaxHealth(_maxHealth); + _entity.setHealth(_maxHealth); + _entity.setCustomName(_name); + _entity.setCustomNameVisible(true); + + customSpawn(); + Bukkit.getPluginManager().registerEvents(this, ClansManager.getInstance().getPlugin()); + } + + public abstract void customSpawn(); + + public abstract void customDeath(); + + public abstract void customDespawn(); + + public void update() {}; + + @EventHandler + public void onDeath(EntityDeathEvent event) + { + if (event.getEntity().equals(_entity)) + { + HandlerList.unregisterAll(this); + customDeath(); + } + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + if (!_entity.isValid()) + { + HandlerList.unregisterAll(this); + customDespawn(); + return; + } + + if (_entity.getFireTicks() > 0) + { + _entity.setFireTicks(-1); + } + update(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossManager.java new file mode 100644 index 000000000..1e5ae3352 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossManager.java @@ -0,0 +1,61 @@ +package mineplex.game.clans.clans.nether.miniboss; + +import java.util.List; + +import mineplex.core.common.util.UtilMath; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.nether.NetherManager; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; + +import com.google.common.collect.Lists; + +public class NetherMinibossManager implements Listener +{ + private static final long TIME_BETWEEN_MINIBOSS_TARGET_PLAYER = 30000; + private NetherManager _manager; + + public NetherMinibossManager(NetherManager manager) + { + _manager = manager; + Bukkit.getPluginManager().registerEvents(this, manager.getPlugin()); + } + + private void spawnAttacker(Player player) + { + Location toSpawn = new Location(_manager.getNetherWorld(), player.getLocation().getX() + UtilMath.random(6, 10), player.getLocation().getY(), player.getLocation().getZ() + UtilMath.random(6, 10)); + NetherMinibossType bossType = NetherMinibossType.values()[UtilMath.r(NetherMinibossType.values().length)]; + + bossType.getNewInstance(toSpawn); + } + + @EventHandler + public void onSpawnThreat(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + + List targets = Lists.newArrayList(); + targets.addAll(_manager.InNether.keySet()); + + for (Player player : targets) + { + if (player.isDead() || !player.isValid()) + { + continue; + } + if (_manager.isInNether(player) && Recharge.Instance.use(player, "Nether Miniboss Spawn", TIME_BETWEEN_MINIBOSS_TARGET_PLAYER, false, false)) + { + spawnAttacker(player); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossType.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossType.java new file mode 100644 index 000000000..bcb82999e --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossType.java @@ -0,0 +1,34 @@ +package mineplex.game.clans.clans.nether.miniboss; + +import org.bukkit.Location; +import org.bukkit.entity.EntityType; + +public enum NetherMinibossType +{ + ; + + private Class _code; + private String _name; + private Double _maxHealth; + private EntityType _type; + + private NetherMinibossType(String name, Double maxHealth, EntityType type, Class code) + { + _name = name; + _maxHealth = maxHealth; + _type = type; + _code = code; + } + + public NetherMiniBoss getNewInstance(Location spawn) + { + try + { + return _code.getConstructor(String.class, Double.class, Location.class, EntityType.class).newInstance(_name, _maxHealth, spawn, _type); + } + catch (Exception e) + { + return null; + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java index 981c34edf..f3a896df3 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java @@ -6,13 +6,6 @@ import java.util.LinkedList; import java.util.List; import java.util.Random; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.HandlerList; -import org.bukkit.plugin.java.JavaPlugin; - import mineplex.core.MiniPlugin; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.common.util.C; @@ -26,10 +19,22 @@ import mineplex.game.clans.clans.loot.LootManager; import mineplex.game.clans.clans.regions.ClansRegions; import mineplex.game.clans.clans.worldevent.command.WorldEventCommand; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; +import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; +import mineplex.minecraft.game.core.boss.EventCreatureDeathEvent; import mineplex.minecraft.game.core.boss.EventState; import mineplex.minecraft.game.core.boss.WorldEvent; +import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature; +import mineplex.minecraft.game.core.boss.skeletonking.SkeletonCreature; +import mineplex.minecraft.game.core.boss.spider.SpiderCreature; import mineplex.minecraft.game.core.damage.DamageManager; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.plugin.java.JavaPlugin; + public class WorldEventManager extends MiniPlugin implements ScoreboardElement { private final List _runningEvents; @@ -90,6 +95,37 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement return false; } + @EventHandler + public void onIcePrison(SkillTriggerEvent event) + { + if (event.GetSkillName().equalsIgnoreCase("Ice Prison")) + { + for (WorldEvent e : _runningEvents) + { + if (e.isInBounds(event.GetPlayer().getLocation())) + { + event.SetCancelled(true); + } + } + } + } + + @EventHandler + public void onBossDeath(EventCreatureDeathEvent event) + { + if (event.getCreature() instanceof GolemCreature || event.getCreature() instanceof SkeletonCreature || event.getCreature() instanceof SpiderCreature) + { + Location drop = event.getCreature().getLastKnownLocation(); + if (drop != null) + { + runSyncLater(() -> + { + ClansManager.getInstance().getLootManager().dropRare(drop); + }, 20 * 2); + } + } + } + @EventHandler public void update(UpdateEvent event) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java index 566b7acf8..5a200d3bf 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java @@ -7,7 +7,7 @@ import mineplex.game.clans.clans.worldevent.undead.UndeadCamp; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; import mineplex.minecraft.game.core.boss.WorldEvent; import mineplex.minecraft.game.core.boss.ironwizard.GolemBoss; -import mineplex.minecraft.game.core.boss.necromancer.NecromancerBoss; +import mineplex.minecraft.game.core.boss.skeletonking.SkeletonBoss; import mineplex.minecraft.game.core.boss.slimeking.SlimeBoss; import mineplex.minecraft.game.core.boss.spider.SpiderBoss; @@ -20,7 +20,7 @@ public enum WorldEventType UNDEAD_CAMP("Undead Camp", UndeadCamp.class, 30), IRON_WIZARD("Iron Wizard",GolemBoss.class, 30), BROOD_MOTHER("Brood Mother", SpiderBoss.class, 30), - NECROMANCER("Necromancer", NecromancerBoss.class, 30); + SKELETON_KING("Skeleton King", SkeletonBoss.class, 30); private String _name; private Class _clazz; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java index ac12981a6..170d99155 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java @@ -13,12 +13,14 @@ import java.util.Set; import java.util.UUID; import com.google.gson.JsonSyntaxException; + import mineplex.core.account.CoreClient; import mineplex.core.common.Rank; import mineplex.game.clans.clans.ClansManager; import net.minecraft.server.v1_8_R3.NBTBase; import net.minecraft.server.v1_8_R3.NBTTagByte; import net.minecraft.server.v1_8_R3.NBTTagString; + import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Location; @@ -36,6 +38,7 @@ import com.google.gson.GsonBuilder; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilServer; import mineplex.core.common.weight.Weight; import mineplex.core.common.weight.WeightSet; @@ -303,8 +306,7 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable factory.setType(Material.BOW); } - if (itemType != ItemType.LEGENDARY) // Only non-legendaries have - // attributes + if (itemType != ItemType.LEGENDARY || (UtilMath.random.nextDouble() <= .35 && factory.getMaterial() != Material.RECORD_6)) // Melee Legendaries have a chance to spawn with attributes { AttributeContainer attributes = new AttributeContainer(); generateAttributes(attributes, itemType, attributeCount); @@ -352,6 +354,9 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable case WEAPON: sampleAttribute = instantiate(WEAPON_ATTRIBUTES.generateRandom()); break; + case LEGENDARY: + sampleAttribute = instantiate(WEAPON_ATTRIBUTES.generateRandom()); + break; case BOW: sampleAttribute = instantiate(BOW_ATTRIBUTES.generateRandom()); break; @@ -366,8 +371,11 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable attempts++; } - - container.addAttribute(attribute); + + if (attribute != null) + { + container.addAttribute(attribute); + } } } diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/BossPassive.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/BossPassive.java new file mode 100644 index 000000000..0f06c5d90 --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/BossPassive.java @@ -0,0 +1,41 @@ +package mineplex.minecraft.game.core.boss; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.entity.Entity; +import org.bukkit.event.Listener; + +public abstract class BossPassive implements Listener +{ + private T _creature; + + public BossPassive(T creature) + { + _creature = creature; + Bukkit.getPluginManager().registerEvents(this, creature.getEvent().getPlugin()); + } + + public int getCooldown() + { + return 3; + } + + public Y getEntity() + { + return (Y) getBoss().getEntity(); + } + + public T getBoss() + { + return _creature; + } + + public Location getLocation() + { + return getEntity().getLocation(); + } + + public abstract boolean isProgressing(); + + public abstract void tick(); +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventCreature.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventCreature.java index 9103fca7f..60de4a488 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventCreature.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventCreature.java @@ -28,7 +28,7 @@ public abstract class EventCreature implements Listener // Spawn Data private T _entity; private Class _entityClass; - private Location _spawnLocation; + private Location _spawnLocation, _lastLocation; // Creature Data private String _name; @@ -183,6 +183,11 @@ public abstract class EventCreature implements Listener { return _spawnLocation; } + + public Location getLastKnownLocation() + { + return _lastLocation; + } public void setSpawnLocation(Location spawnLocation) { @@ -275,10 +280,12 @@ public abstract class EventCreature implements Listener spawnEntity(); } - if (UtilMath.offset2d(_entity.getLocation(), _spawnLocation) > 24) + if (UtilMath.offset2d(_entity.getLocation(), _spawnLocation) > 44) { _entity.setVelocity(UtilAlg.getTrajectory(_entity.getLocation(), _spawnLocation).normalize().multiply(2)); } + + _lastLocation = _entity.getLocation(); } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventCreatureDeathEvent.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventCreatureDeathEvent.java new file mode 100644 index 000000000..892827cc8 --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventCreatureDeathEvent.java @@ -0,0 +1,31 @@ +package mineplex.minecraft.game.core.boss; + +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class EventCreatureDeathEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private EventCreature _creature; + + public EventCreatureDeathEvent(EventCreature creature) + { + _creature = creature; + } + + public EventCreature getCreature() + { + return _creature; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/WorldEvent.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/WorldEvent.java index 6f10d660c..1841cb81d 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/WorldEvent.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/WorldEvent.java @@ -7,16 +7,6 @@ import java.util.List; import java.util.Random; import java.util.Set; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.HandlerList; -import org.bukkit.event.Listener; -import org.bukkit.plugin.java.JavaPlugin; -import org.bukkit.util.Vector; - import mineplex.core.blockrestore.BlockRestore; import mineplex.core.blockrestore.BlockRestoreMap; import mineplex.core.common.block.BlockData; @@ -40,6 +30,17 @@ import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.condition.ConditionManager; import mineplex.minecraft.game.core.damage.DamageManager; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.util.Vector; + public abstract class WorldEvent implements Listener, ScoreboardElement { // 20 Minutes @@ -269,6 +270,7 @@ public abstract class WorldEvent implements Listener, ScoreboardElement public void removeCreature(EventCreature creature) { + Bukkit.getPluginManager().callEvent(new EventCreatureDeathEvent(creature)); HandlerList.unregisterAll(creature); _creatures.remove(creature); } diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemBoss.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemBoss.java index 7b2931b94..81d3db9a0 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemBoss.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemBoss.java @@ -54,7 +54,7 @@ public class GolemBoss extends WorldEvent private GolemCreature spawnGolem(Location location) { - GolemCreature golemCreature = new GolemCreature(this, location, 2500); + GolemCreature golemCreature = new GolemCreature(this, location, 3000); registerCreature(golemCreature); return golemCreature; } diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemCreature.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemCreature.java index 8e73af96b..6133a6426 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemCreature.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemCreature.java @@ -45,6 +45,11 @@ import org.bukkit.util.Vector; public class GolemCreature extends EventCreature { + //private static final double HEALTH_PER_REGEN = 5; + //private static final long HEALTH_REGEN_DELAY = 1000; + //private static final long REGEN_SAFE_TIME_NEED = 10000; + //private static final double CROWD_CONTROL_DAMAGE_REDUCTION = .70; + //private final double MAX_HEALTH; private GolemBoss _boss; // private GolemAbility _currentAbility; private int _lastAbility; @@ -59,10 +64,14 @@ public class GolemCreature extends EventCreature private double _canDeadlyTremor = 225; private Vector _afkWalk = new Vector(); private long _lastSlam; + //private long _lastHit; + //private long _lastRegenerate; public GolemCreature(GolemBoss boss, Location location, double maxHealth) { super(boss, location, "Iron Wizard", true, maxHealth, IronGolem.class); + //MAX_HEALTH = maxHealth; + //_lastRegenerate = System.currentTimeMillis() + 20000; _boss = boss; spawnEntity(); @@ -87,6 +96,10 @@ public class GolemCreature extends EventCreature { GolemBlockShot.class }); + _preferedCombos.put(GolemBlockHail.class, new Class[] + { + GolemDeadlyTremor.class + }); } private boolean hasFurther(HashMap distances, double range) @@ -130,6 +143,13 @@ public class GolemCreature extends EventCreature _standing = getEntity().getLocation(); return; } + + /*if (UtilTime.elapsed(_lastHit, REGEN_SAFE_TIME_NEED) && UtilTime.elapsed(_lastRegenerate, HEALTH_REGEN_DELAY)) + { + _lastRegenerate = System.currentTimeMillis(); + super.setHealth(Math.min(MAX_HEALTH, getHealth() + HEALTH_PER_REGEN)); + setHealth(getHealth() + HEALTH_PER_REGEN); + }*/ // if (_currentAbility == null || _currentAbility.hasFinished()) // { @@ -277,7 +297,7 @@ public class GolemCreature extends EventCreature if (!players.isEmpty()) { - int we = _lastAttack == GolemEarthquake.class ? 5 : UtilMath.r(4) - 2; + int we = _lastAttack == GolemEarthquake.class ? 20 : UtilMath.r(15) - 2; if (we > 0) { @@ -528,6 +548,11 @@ public class GolemCreature extends EventCreature if (event.GetDamageeEntity().equals(getEntity())) { event.AddKnockback("Heavy Golem", 0.3); + //_lastHit = System.currentTimeMillis(); + /*if (UtilPlayer.getInRadius(getEntity().getLocation(), 10).size() >= 3) + { + event.AddMult(getEntity().getName(), "Level Field", CROWD_CONTROL_DAMAGE_REDUCTION, false); + }*/ } } @@ -587,9 +612,7 @@ public class GolemCreature extends EventCreature public void setHealth(double health) { _canDeadlyTremor -= getHealth() - health; - super.setHealth(health); - if (getHealth() <= 100 && !_usedFinalAttack) { endAbility(); diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemBlockHail.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemBlockHail.java index 4a32cb525..f31a05798 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemBlockHail.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemBlockHail.java @@ -407,7 +407,7 @@ public class GolemBlockHail extends BossAbility for (int i = 1; i <= _currentLevel; i++) { - if (_floatingBlocks.containsKey(i)) + if (_floatingBlocks.containsKey(i) && !_floatingBlocks.get(i).isEmpty()) { floatingBlock = _floatingBlocks.get(i).remove(0); diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemDeadlyTremor.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemDeadlyTremor.java index fb15c7567..94fb81098 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemDeadlyTremor.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemDeadlyTremor.java @@ -20,7 +20,7 @@ import org.bukkit.util.Vector; public class GolemDeadlyTremor extends BossAbility { - private static final long ATTACK_DURATION = 16000; + private static final long ATTACK_DURATION = 10000; private long _start; public GolemDeadlyTremor(GolemCreature creature) @@ -56,7 +56,7 @@ public class GolemDeadlyTremor extends BossAbility @Override public void tick() { - for (Player player : UtilPlayer.getInRadius(getLocation(), 80).keySet()) + for (Player player : UtilPlayer.getInRadius(getLocation(), 40).keySet()) { player.playSound(player.getLocation(), Sound.MINECART_BASE, 0.2f, 0.2f); diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/abilities/WraithDeathEvent.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/abilities/WraithDeathEvent.java deleted file mode 100644 index ff853ef28..000000000 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/abilities/WraithDeathEvent.java +++ /dev/null @@ -1,33 +0,0 @@ -package mineplex.minecraft.game.core.boss.necromancer.abilities; - -import mineplex.minecraft.game.core.boss.necromancer.minion.WraithCreature; - -import org.bukkit.event.Event; -import org.bukkit.event.HandlerList; - -public class WraithDeathEvent extends Event -{ - private static final HandlerList handlers = new HandlerList(); - - private WraithCreature _wraith; - - public WraithDeathEvent(WraithCreature wraith) - { - _wraith = wraith; - } - - public WraithCreature getWraith() - { - return _wraith; - } - - public HandlerList getHandlers() - { - return handlers; - } - - public static HandlerList getHandlerList() - { - return handlers; - } -} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/NecromancerBoss.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/SkeletonBoss.java similarity index 58% rename from Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/NecromancerBoss.java rename to Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/SkeletonBoss.java index 1ee7c078e..dd785dfb8 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/NecromancerBoss.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/SkeletonBoss.java @@ -1,4 +1,4 @@ -package mineplex.minecraft.game.core.boss.necromancer; +package mineplex.minecraft.game.core.boss.skeletonking; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.common.util.F; @@ -7,20 +7,20 @@ import mineplex.core.projectile.ProjectileManager; import mineplex.minecraft.game.core.boss.EventCreature; import mineplex.minecraft.game.core.boss.EventState; import mineplex.minecraft.game.core.boss.WorldEvent; -import mineplex.minecraft.game.core.boss.necromancer.abilities.WraithDeathEvent; -import mineplex.minecraft.game.core.boss.necromancer.minion.MinionType; -import mineplex.minecraft.game.core.boss.necromancer.minion.WraithCreature; +import mineplex.minecraft.game.core.boss.skeletonking.minion.MinionType; import mineplex.minecraft.game.core.condition.ConditionManager; import mineplex.minecraft.game.core.damage.DamageManager; import org.bukkit.Bukkit; import org.bukkit.Location; -public class NecromancerBoss extends WorldEvent +public class SkeletonBoss extends WorldEvent { - public NecromancerBoss(DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, ProjectileManager projectileManager, Location cornerLocation) + protected boolean canMove = false; + + public SkeletonBoss(DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, ProjectileManager projectileManager, Location cornerLocation) { - super(DisguiseManager.INSTANCE, projectileManager, damageManager, blockRestore, conditionManager, "Necromancer", cornerLocation, + super(DisguiseManager.INSTANCE, projectileManager, damageManager, blockRestore, conditionManager, "Skeleton King", cornerLocation, "schematic/Golem.schematic"); } @@ -34,11 +34,11 @@ public class NecromancerBoss extends WorldEvent } /** - * Check if this necromancer boss has been defeated + * Check if this skeleton boss has been defeated */ private void checkDeath() { - if (getCreatures().size() == 0) + if (getBossesAlive() == 0) { setState(EventState.COMPLETE); Bukkit.broadcastMessage(F.main(getName(), "The demonic " + getName() + " has been slain!")); @@ -50,15 +50,22 @@ public class NecromancerBoss extends WorldEvent { super.removeCreature(creature); - if (creature instanceof NecromancerCreature) + if (creature instanceof SkeletonCreature) { checkDeath(); } - if (creature instanceof WraithCreature) + } + + @Override + protected void setState(EventState state) + { + super.setState(state); + if (state == EventState.LIVE) { - WraithDeathEvent event = new WraithDeathEvent((WraithCreature)creature); - Bukkit.getPluginManager().callEvent(event); - Bukkit.broadcastMessage("Calling Wraith Death"); + Bukkit.getScheduler().runTaskLater(getPlugin(), () -> + { + canMove = true; + }, 20 * 3); } } @@ -72,10 +79,25 @@ public class NecromancerBoss extends WorldEvent return minionCreature; } - private NecromancerCreature spawnNecromancer(Location location) + private SkeletonCreature spawnNecromancer(Location location) { - NecromancerCreature necromancerCreature = new NecromancerCreature(this, location, 2500); + SkeletonCreature necromancerCreature = new SkeletonCreature(this, location, 2500); registerCreature(necromancerCreature); return necromancerCreature; } + + private int getBossesAlive() + { + int alive = 0; + + for (EventCreature creature : getCreatures()) + { + if (creature instanceof SkeletonCreature) + { + alive++; + } + } + + return alive; + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/NecromancerCreature.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/SkeletonCreature.java similarity index 67% rename from Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/NecromancerCreature.java rename to Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/SkeletonCreature.java index 0f920912e..8b0e4865c 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/NecromancerCreature.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/SkeletonCreature.java @@ -1,10 +1,11 @@ -package mineplex.minecraft.game.core.boss.necromancer; +package mineplex.minecraft.game.core.boss.skeletonking; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.Iterator; +import java.util.LinkedList; import java.util.List; import java.util.Map.Entry; import java.util.Random; @@ -19,42 +20,60 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.boss.BossAbility; import mineplex.minecraft.game.core.boss.EventCreature; -import mineplex.minecraft.game.core.boss.necromancer.abilities.NecromancerHellishFlood; -import mineplex.minecraft.game.core.boss.necromancer.abilities.NecromancerPulse; -import mineplex.minecraft.game.core.boss.necromancer.abilities.NecromancerSmite; -import mineplex.minecraft.game.core.boss.necromancer.abilities.NecromancerStrike; -import mineplex.minecraft.game.core.boss.necromancer.abilities.NecromancerWraithSummon; +import mineplex.minecraft.game.core.boss.skeletonking.abilities.SkeletonArcherShield; +import mineplex.minecraft.game.core.boss.skeletonking.abilities.SkeletonPassive; +import mineplex.minecraft.game.core.boss.skeletonking.abilities.SkeletonPulse; +import mineplex.minecraft.game.core.boss.skeletonking.abilities.SkeletonSmite; +import mineplex.minecraft.game.core.boss.skeletonking.abilities.SkeletonStrike; +import mineplex.minecraft.game.core.boss.skeletonking.abilities.SkeletonWraithSummon; +import mineplex.minecraft.game.core.boss.skeletonking.minion.UndeadArcherCreature; +import mineplex.minecraft.game.core.boss.skeletonking.minion.UndeadWarriorCreature; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.BlockFace; +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.HandlerList; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; -public class NecromancerCreature extends EventCreature +import com.google.common.collect.Lists; + +public class SkeletonCreature extends EventCreature { - private ArrayList _currentAbilities = new ArrayList(); + private ArrayList _currentAbilities = Lists.newArrayList(); + private SkeletonPassive _passive; private int _lastAbility; - private HashMap _cooldowns = new HashMap(); - private boolean _hasUsedWraiths; - private List _movePoints; + private HashMap _cooldowns = new HashMap<>(); + private LinkedList _wraithTriggers = new LinkedList<>(); + private List _movePoints = Lists.newArrayList(); private Location _movingTo; private boolean _moving; private long _lastMoved; + private long _lastUsedPassive; + public List Archers = Lists.newArrayList(); + public List Warriors = Lists.newArrayList(); - public NecromancerCreature(NecromancerBoss boss, Location location, double maxHealth) + public SkeletonCreature(SkeletonBoss boss, Location location, double maxHealth) { - super(boss, location, "Necromancer", true, maxHealth, Skeleton.class); + super(boss, location, "Skeleton King", true, maxHealth, Skeleton.class); spawnEntity(); + _passive = new SkeletonPassive(this); + _wraithTriggers.add(1500D); + _wraithTriggers.add(1000D); + _wraithTriggers.add(500D); + _wraithTriggers.add(100D); + getEntity().getWorld().setThunderDuration(10000000); + getEntity().getWorld().setThundering(true); } @Override @@ -69,7 +88,11 @@ public class NecromancerCreature extends EventCreature @Override public void dieCustom() { + HandlerList.unregisterAll(_passive); + _passive = null; endAbility(); + getEntity().getWorld().setThunderDuration(0); + getEntity().getWorld().setThundering(false); } private void endAbility() @@ -90,6 +113,15 @@ public class NecromancerCreature extends EventCreature { return; } + + if (_passive != null && ((SkeletonBoss)getEvent()).canMove) + { + if (UtilTime.elapsed(_lastUsedPassive, _passive.getCooldown() * 20) || _passive.isProgressing()) + { + _lastUsedPassive = System.currentTimeMillis(); + _passive.tick(); + } + } Iterator itel = _currentAbilities.iterator(); boolean canDoNew = _currentAbilities.size() < 3; @@ -131,19 +163,19 @@ public class NecromancerCreature extends EventCreature if (!dist.isEmpty()) { - {// Strike and Pulse - ArrayList players = getPlayers(dist, UtilMath.r(10) == 0 ? 20 : 16); + {// Pulse & Strike + ArrayList players = getPlayers(dist, UtilMath.r(10) == 0 ? 25 : 20); ArrayList near = getPlayers(dist, 5); if (!players.isEmpty()) { if (!near.isEmpty() && near.size() >= 4 && new Random().nextDouble() <= .45) { - weight.put(NecromancerPulse.class, 999); + weight.put(SkeletonPulse.class, 999); } else { - weight.put(NecromancerStrike.class, 6); + weight.put(SkeletonStrike.class, 6); } } } @@ -152,32 +184,43 @@ public class NecromancerCreature extends EventCreature if (!players.isEmpty()) { - weight.put(NecromancerSmite.class, 6); + weight.put(SkeletonSmite.class, 6); } } - if (getHealthPercent() < .7) - {//Hellish Flood + {//Archer Shield ArrayList players = getPlayers(dist, 20); double score = 0; for (Player player : players) { score += (18 - dist.get(player)) / 2; } - if (players.size() >= 4 || (!players.isEmpty() && players.get(0).isOp())) + if (players.size() >= 4) { score += 17; } if (score > 0) { - weight.put(NecromancerHellishFlood.class, (int) Math.ceil(score)); + weight.put(SkeletonArcherShield.class, (int) Math.ceil(score)); } } - Bukkit.broadcastMessage(_hasUsedWraiths + ""); - if (getHealth() <= 90 && !_hasUsedWraiths) + Double wraithUse = null; + for (Double test : _wraithTriggers) + { + if (wraithUse == null) + { + if (getHealth() <= test) + { + Bukkit.broadcastMessage(test + "Verified"); + wraithUse = test; + break; + } + } + } + if (wraithUse != null) {// Wraith Summon - _hasUsedWraiths = true; + _wraithTriggers.remove(wraithUse); weight.clear(); - weight.put(NecromancerWraithSummon.class, 999); + weight.put(SkeletonWraithSummon.class, 999); } } @@ -236,7 +279,7 @@ public class NecromancerCreature extends EventCreature { try { - ability = entry.getKey().getConstructor(NecromancerCreature.class).newInstance(this); + ability = entry.getKey().getConstructor(SkeletonCreature.class).newInstance(this); if (ability.getTarget() == null || ability.hasFinished()) { @@ -284,6 +327,10 @@ public class NecromancerCreature extends EventCreature canMove = false; } } + if (!((SkeletonBoss)getEvent()).canMove) + { + return; + } if (_moving) { @@ -291,7 +338,7 @@ public class NecromancerCreature extends EventCreature { _movingTo = selectWalkTarget(); } - if (UtilMath.offset(getEntity().getLocation(), _movingTo) > 1.3) + if (UtilMath.offset(getEntity().getLocation(), _movingTo) <= 1.3) { _lastMoved = System.currentTimeMillis(); _movingTo = null; @@ -301,6 +348,7 @@ public class NecromancerCreature extends EventCreature UtilEnt.LookAt(getEntity(), _movingTo); Vector walk = UtilAlg.getTrajectory(getEntity().getLocation(), _movingTo); walk.multiply(walk.length()); + walk.multiply(.2); getEntity().setVelocity(walk); } else @@ -318,7 +366,9 @@ public class NecromancerCreature extends EventCreature { if (_movePoints.isEmpty()) { - generateWalkPoints(getEntity().getLocation()); + Location base = getSpawnLocation().clone(); + base.setY(getEntity().getLocation().getY()); + generateWalkPoints(base); } Location selected = _movePoints.get(new Random().nextInt(_movePoints.size())); _movePoints.remove(selected); @@ -365,7 +415,7 @@ public class NecromancerCreature extends EventCreature } @EventHandler - public void onNecromancerDamage(CustomDamageEvent event) + public void onSkeletonDamage(CustomDamageEvent event) { if (event.GetDamageeEntity().getEntityId() == getEntity().getEntityId()) { @@ -389,4 +439,34 @@ public class NecromancerCreature extends EventCreature event.SetCancelled("Boss Invulnerability"); } } + + @EventHandler(priority = EventPriority.HIGH) + public void protect(CustomDamageEvent event) + { + if (event.IsCancelled()) + { + return; + } + + LivingEntity damagee = event.GetDamageeEntity(); + LivingEntity damager = event.GetDamagerEntity(event.GetCause() == DamageCause.PROJECTILE); + + if (damagee == null) + { + return; + } + + if (damager == null) + { + return; + } + + if (getEntity().equals(damagee)) + { + if (!(damager instanceof Player)) + { + event.SetCancelled("Allied Attacker"); + } + } + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/abilities/SkeletonArcherShield.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/abilities/SkeletonArcherShield.java new file mode 100644 index 000000000..c393c73e3 --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/abilities/SkeletonArcherShield.java @@ -0,0 +1,186 @@ +package mineplex.minecraft.game.core.boss.skeletonking.abilities; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +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.UtilTime; +import mineplex.minecraft.game.core.boss.BossAbility; +import mineplex.minecraft.game.core.boss.skeletonking.SkeletonCreature; +import mineplex.minecraft.game.core.boss.skeletonking.minion.UndeadArcherCreature; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftSkeleton; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.metadata.FixedMetadataValue; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.util.Vector; + +public class SkeletonArcherShield extends BossAbility +{ + private static long ATTACK_DURATION = 10000; + private static long ARROW_DELAY = 100; + private static long ARROW_WARMUP = 2000; + private static double PULL_RANGE = 12; + private long _start; + private long _lastShoot; + private boolean _teleported; + + public SkeletonArcherShield(SkeletonCreature creature) + { + super(creature); + _start = System.currentTimeMillis(); + } + + @Override + public int getCooldown() + { + return 20; + } + + @Override + public boolean canMove() + { + return false; + } + + @Override + public boolean inProgress() + { + return false; + } + + @Override + public boolean hasFinished() + { + return UtilTime.elapsed(_start, ATTACK_DURATION); + } + + @Override + public void setFinished() + { + _start = System.currentTimeMillis() - ATTACK_DURATION; + for (UndeadArcherCreature creature : getBoss().Archers) + { + creature.getEntity().remove(); + } + } + + private void run(boolean initial) + { + for (int i = 0; i < getBoss().Archers.size(); i++) + { + Skeleton archer = getBoss().Archers.get(i).getEntity(); + UtilEnt.Vegetate(archer); + ((CraftSkeleton)archer).setVegetated(false); + + double lead = i * ((2d * Math.PI)/getBoss().Archers.size()); + + double sizeMod = 2; + + //Orbit + double speed = 10d; + double oX = -Math.sin(getEntity().getTicksLived()/speed + lead) * 2 * sizeMod; + double oY = 0; + double oZ = Math.cos(getEntity().getTicksLived()/speed + lead) * 2 * sizeMod; + + if (initial) + { + archer.teleport(getEntity().getLocation().add(oX, oY, oZ)); + UtilEnt.Vegetate(archer); + } + else + { + Location to = getEntity().getLocation().add(oX, oY, oZ); + UtilEnt.LookAt(archer, to); + UtilAction.velocity(archer, UtilAlg.getTrajectory(archer.getLocation(), to), 0.4, false, 0, 0.1, 1, true); + } + } + } + + private void shoot() + { + if (UtilTime.elapsed(_start, ARROW_WARMUP) && UtilTime.elapsed(_lastShoot, ARROW_DELAY)) + { + _lastShoot = System.currentTimeMillis(); + for (UndeadArcherCreature archer : getBoss().Archers) + { + Location spawn = archer.getEntity().getEyeLocation().add(UtilAlg.getTrajectory(getEntity().getEyeLocation(), archer.getEntity().getEyeLocation()).normalize()); + Vector vector = UtilAlg.getTrajectory(getEntity().getEyeLocation(), spawn); + Arrow arrow = archer.getEntity().getWorld().spawnArrow(spawn, vector, 0.6f, 12f); + arrow.setMetadata("SHIELD_SHOT", new FixedMetadataValue(getBoss().getEvent().getPlugin(), true)); + arrow.setMetadata("BARBED_ARROW", new FixedMetadataValue(getBoss().getEvent().getPlugin(), 10)); + arrow.setShooter(archer.getEntity()); + } + } + } + + @Override + public void tick() + { + if (!_teleported) + { + run(true); + _teleported = true; + for (Player near : UtilPlayer.getInRadius(getEntity().getLocation(), PULL_RANGE).keySet()) + { + Vector velocity = UtilAlg.getTrajectory(near, getEntity()); + UtilAction.velocity(near, velocity, 2, false, 0, 0, 1, true); + near.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 5 * 20, -2)); + for (int i = 0; i < 6; i++) + { + Vector random = new Vector(Math.random() * 4 - 2, Math.random() * 4 - 2, Math.random() * 4 - 2); + + Location origin = getEntity().getLocation().add(0, 1.3, 0); + origin.add(velocity.clone().multiply(10)); + origin.add(random); + + Vector vel = UtilAlg.getTrajectory(origin, getEntity().getLocation().add(0, 1.3, 0)); + vel.multiply(7); + + UtilParticle.PlayParticleToAll(ParticleType.MAGIC_CRIT, origin, (float)vel.getX(), (float)vel.getY(), (float)vel.getZ(), 1, 0, ViewDist.LONG); + } + } + } + else + { + run(false); + shoot(); + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onDamage(CustomDamageEvent event) + { + if (event.GetDamageeEntity().equals(getBoss().getEntity())) + { + if (!hasFinished()) + { + event.SetCancelled("Wraiths Alive"); + } + } + } + + @EventHandler + public void onArrowHit(ProjectileHitEvent event) + { + if (event.getEntity().hasMetadata("SHIELD_SHOT")) + { + Bukkit.getScheduler().runTaskLater(getBoss().getEvent().getPlugin(), () -> + { + event.getEntity().remove(); + }, 20L); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/abilities/NecromancerHellishFlood.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/abilities/SkeletonHellishFlood.java similarity index 78% rename from Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/abilities/NecromancerHellishFlood.java rename to Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/abilities/SkeletonHellishFlood.java index 69d986ca2..089db01b8 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/abilities/NecromancerHellishFlood.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/abilities/SkeletonHellishFlood.java @@ -1,23 +1,22 @@ -package mineplex.minecraft.game.core.boss.necromancer.abilities; +package mineplex.minecraft.game.core.boss.skeletonking.abilities; import java.util.Random; import java.util.concurrent.ConcurrentHashMap; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; -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.UtilTime; import mineplex.minecraft.game.core.boss.BossAbility; -import mineplex.minecraft.game.core.boss.necromancer.NecromancerBoss; -import mineplex.minecraft.game.core.boss.necromancer.NecromancerCreature; -import mineplex.minecraft.game.core.boss.necromancer.minion.MinionType; +import mineplex.minecraft.game.core.boss.skeletonking.SkeletonBoss; +import mineplex.minecraft.game.core.boss.skeletonking.SkeletonCreature; +import mineplex.minecraft.game.core.boss.skeletonking.minion.MinionType; -import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Skeleton; -public class NecromancerHellishFlood extends BossAbility +public class SkeletonHellishFlood extends BossAbility { private static final int WAVE_COUNT = 3; private static final int WAVE_SIZE = 5; @@ -29,7 +28,7 @@ public class NecromancerHellishFlood extends BossAbility +{ + private static final int MAX_ARCHERS = 10; + private static final int MAX_WARRIORS = 8; + private static final long SPAWN_RATE = 1000; + private List _queuedArchers = Lists.newArrayList(); + private List _queuedWarriors = Lists.newArrayList(); + private long _lastASpawned; + private long _lastWSpawned; + + public SkeletonPassive(SkeletonCreature creature) + { + super(creature); + } + + @Override + public int getCooldown() + { + return 20; + } + + @Override + public boolean isProgressing() + { + return !_queuedArchers.isEmpty() || !_queuedWarriors.isEmpty(); + } + + @Override + public void tick() + { + if (getBoss().Archers.size() < MAX_ARCHERS && _queuedArchers.isEmpty()) + { + for (int i = 0; i < (MAX_ARCHERS - getBoss().Archers.size()); i++) + { + Location spawn = getLocation().clone(); + spawn.add(UtilMath.random(3, 6), 0, UtilMath.random(3, 6)); + _queuedArchers.add(spawn); + } + } + if (getBoss().Warriors.size() < MAX_WARRIORS && _queuedWarriors.isEmpty()) + { + for (int i = 0; i < (MAX_WARRIORS - getBoss().Warriors.size()); i++) + { + Location spawn = getLocation().clone(); + spawn.add(UtilMath.random(3, 6), 0, UtilMath.random(3, 6)); + _queuedWarriors.add(spawn); + } + } + + for (Location animate : _queuedArchers) + { + UtilParticle.PlayParticleToAll(ParticleType.BLOCK_DUST.getParticle(Material.DIRT, 0), + animate.clone().add(0, 0.2, 0), null, 0, 4, ViewDist.NORMAL); + } + for (Location animate : _queuedWarriors) + { + UtilParticle.PlayParticleToAll(ParticleType.BLOCK_DUST.getParticle(Material.DIRT, 0), + animate.clone().add(0, 0.2, 0), null, 0, 4, ViewDist.NORMAL); + } + + if (!_queuedArchers.isEmpty() && UtilTime.elapsed(_lastASpawned, SPAWN_RATE)) + { + _lastASpawned = System.currentTimeMillis(); + Location spawn = _queuedArchers.remove(0); + getBoss().Archers.add((UndeadArcherCreature) ((SkeletonBoss)getBoss().getEvent()).spawnMinion(MinionType.ARCHER, spawn)); + + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, spawn, null, 0, 2, ViewDist.MAX); + UtilParticle.PlayParticleToAll(ParticleType.SMOKE, spawn, null, 0, 2, ViewDist.MAX); + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, getEntity().getLocation(), null, 0, 2, ViewDist.MAX); + UtilParticle.PlayParticleToAll(ParticleType.SMOKE, getEntity().getLocation(), null, 0, 2, ViewDist.MAX); + } + if (!_queuedWarriors.isEmpty() && UtilTime.elapsed(_lastWSpawned, SPAWN_RATE)) + { + _lastWSpawned = System.currentTimeMillis(); + Location spawn = _queuedWarriors.remove(0); + getBoss().Warriors.add((UndeadWarriorCreature) ((SkeletonBoss)getBoss().getEvent()).spawnMinion(MinionType.WARRIOR, spawn)); + + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, spawn, null, 0, 2, ViewDist.MAX); + UtilParticle.PlayParticleToAll(ParticleType.SMOKE, spawn, null, 0, 2, ViewDist.MAX); + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, getEntity().getLocation(), null, 0, 2, ViewDist.MAX); + UtilParticle.PlayParticleToAll(ParticleType.SMOKE, getEntity().getLocation(), null, 0, 2, ViewDist.MAX); + } + } + + @EventHandler + public void onArcherDeath(EventCreatureDeathEvent event) + { + if (event.getCreature() instanceof UndeadArcherCreature) + { + getBoss().Archers.remove(event.getCreature()); + } + if (event.getCreature() instanceof UndeadWarriorCreature) + { + getBoss().Warriors.remove(event.getCreature()); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/abilities/NecromancerPulse.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/abilities/SkeletonPulse.java similarity index 77% rename from Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/abilities/NecromancerPulse.java rename to Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/abilities/SkeletonPulse.java index d279a1ef7..2e457e60d 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/abilities/NecromancerPulse.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/abilities/SkeletonPulse.java @@ -1,4 +1,4 @@ -package mineplex.minecraft.game.core.boss.necromancer.abilities; +package mineplex.minecraft.game.core.boss.skeletonking.abilities; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; @@ -9,7 +9,7 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; import mineplex.core.recharge.Recharge; import mineplex.minecraft.game.core.boss.BossAbility; -import mineplex.minecraft.game.core.boss.necromancer.NecromancerCreature; +import mineplex.minecraft.game.core.boss.skeletonking.SkeletonCreature; import org.bukkit.GameMode; import org.bukkit.Location; @@ -17,14 +17,15 @@ import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.entity.Skeleton; -public class NecromancerPulse extends BossAbility +public class SkeletonPulse extends BossAbility { - private static final long TOTAL_ATTACK_DURATION = 3000; + private static final long TOTAL_ATTACK_DURATION = 8000; + private static final long TOTAL_ATTACK_PROGRESS = 3000; private long _start, _lastIncrement; private int _radius; private Location _center; - public NecromancerPulse(NecromancerCreature creature) + public SkeletonPulse(SkeletonCreature creature) { super(creature); _start = System.currentTimeMillis(); @@ -35,7 +36,7 @@ public class NecromancerPulse extends BossAbility private int getRadius() { - return Math.min(6, _radius); + return Math.min(8, _radius); } @Override @@ -47,13 +48,13 @@ public class NecromancerPulse extends BossAbility @Override public boolean canMove() { - return false; + return UtilTime.elapsed(_start, TOTAL_ATTACK_PROGRESS); } @Override public boolean inProgress() { - return true; + return UtilTime.elapsed(_start, TOTAL_ATTACK_PROGRESS); } @Override @@ -82,7 +83,7 @@ public class NecromancerPulse extends BossAbility double x = getRadius() * Math.cos(token); double z = getRadius() * Math.sin(token); - UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, _center.clone().add(x, 0.3, z), null, 0, 1, ViewDist.MAX); + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, _center.clone().add(x, 1.5, z), null, 0, 1, ViewDist.MAX); } for (Player player : UtilPlayer.getInRadius(getEntity().getLocation(), getRadius()).keySet()) @@ -101,7 +102,7 @@ public class NecromancerPulse extends BossAbility } player.playSound(player.getLocation(), Sound.AMBIENCE_THUNDER, 1f, 1f); - UtilAction.velocity(player, UtilAlg.getTrajectory2d(getEntity(), player), .2, false, 0.6, 0, 1.4, true); + UtilAction.velocity(player, UtilAlg.getTrajectory2d(getEntity(), player), 2, false, 0.6, 0, 1.4, true); } } } \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/abilities/NecromancerSmite.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/abilities/SkeletonSmite.java similarity index 89% rename from Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/abilities/NecromancerSmite.java rename to Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/abilities/SkeletonSmite.java index d7e1a3daa..6d3bfa4fc 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/abilities/NecromancerSmite.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/abilities/SkeletonSmite.java @@ -1,4 +1,4 @@ -package mineplex.minecraft.game.core.boss.necromancer.abilities; +package mineplex.minecraft.game.core.boss.skeletonking.abilities; import java.math.BigDecimal; @@ -8,21 +8,21 @@ import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; import mineplex.minecraft.game.core.boss.BossAbility; -import mineplex.minecraft.game.core.boss.necromancer.NecromancerCreature; +import mineplex.minecraft.game.core.boss.skeletonking.SkeletonCreature; import org.bukkit.GameMode; import org.bukkit.entity.Player; import org.bukkit.entity.Skeleton; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -public class NecromancerSmite extends BossAbility +public class SkeletonSmite extends BossAbility { private static final long TOTAL_ATTACK_DURATION = 8000; private long _start; private int _ticks; private boolean _shot; - public NecromancerSmite(NecromancerCreature creature) + public SkeletonSmite(SkeletonCreature creature) { super(creature); _start = System.currentTimeMillis(); diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/abilities/NecromancerStrike.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/abilities/SkeletonStrike.java similarity index 81% rename from Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/abilities/NecromancerStrike.java rename to Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/abilities/SkeletonStrike.java index 914858890..e61791a45 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/abilities/NecromancerStrike.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/abilities/SkeletonStrike.java @@ -1,4 +1,4 @@ -package mineplex.minecraft.game.core.boss.necromancer.abilities; +package mineplex.minecraft.game.core.boss.skeletonking.abilities; import java.util.HashMap; import java.util.LinkedList; @@ -13,7 +13,7 @@ import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.minecraft.game.core.boss.BossAbility; -import mineplex.minecraft.game.core.boss.necromancer.NecromancerCreature; +import mineplex.minecraft.game.core.boss.skeletonking.SkeletonCreature; import org.bukkit.GameMode; import org.bukkit.Location; @@ -23,27 +23,28 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import com.google.common.collect.Lists; -public class NecromancerStrike extends BossAbility +public class SkeletonStrike extends BossAbility { - private static final double MAX_RANGE = 20; - private static final Integer MAX_TARGETS = 3; + private static final double MAX_RANGE = 25; + private static final Integer MAX_TARGETS = 1; private boolean _shot; - public NecromancerStrike(NecromancerCreature creature) + public SkeletonStrike(SkeletonCreature creature) { super(creature); _shot = false; } - private int getPosition(Player toAdd, LinkedList ordered, HashMap distances) + private int getPosition(Player toAdd, LinkedList ordered) { int position = ordered.size(); int index = 0; for (Player player : ordered) { - if (distances.get(player) >= distances.get(toAdd)) + if (player.getHealth() < toAdd.getHealth()) { position = index; + return position; } index++; } @@ -72,7 +73,7 @@ public class NecromancerStrike extends BossAbility +public class SkeletonWraithSummon extends BossAbility { private static final int WRAITH_AMOUNT = 4; - private static final double DISTANCE_FROM_NECROMANCER = 4; + private static final double DISTANCE_FROM_KING = 4; + private static final double FINAL_SKELETON_HEALTH = 100; + private static final double FINAL_WRAITH_MULTIPLIER = 2; + private final int WRAITH_AMOUNT_THIS_USE; private ConcurrentHashMap _wraiths = new ConcurrentHashMap<>(); private Location[] _spawns; private int _ticks; - public NecromancerWraithSummon(NecromancerCreature creature) + public SkeletonWraithSummon(SkeletonCreature creature) { super(creature); _spawns = new Location[] { - getEntity().getLocation().add(DISTANCE_FROM_NECROMANCER, 0, DISTANCE_FROM_NECROMANCER), - getEntity().getLocation().add(DISTANCE_FROM_NECROMANCER * -1, 0, DISTANCE_FROM_NECROMANCER), - getEntity().getLocation().add(DISTANCE_FROM_NECROMANCER, 0, DISTANCE_FROM_NECROMANCER * -1), - getEntity().getLocation().add(DISTANCE_FROM_NECROMANCER * -1, 0, DISTANCE_FROM_NECROMANCER * -1) + getEntity().getLocation().add(DISTANCE_FROM_KING, 0, DISTANCE_FROM_KING), + getEntity().getLocation().add(DISTANCE_FROM_KING * -1, 0, DISTANCE_FROM_KING), + getEntity().getLocation().add(DISTANCE_FROM_KING, 0, DISTANCE_FROM_KING * -1), + getEntity().getLocation().add(DISTANCE_FROM_KING * -1, 0, DISTANCE_FROM_KING * -1), + getEntity().getLocation().add(DISTANCE_FROM_KING / 2, 0, DISTANCE_FROM_KING / 2), + getEntity().getLocation().add((DISTANCE_FROM_KING / 2) * -1, 0, DISTANCE_FROM_KING / 2), + getEntity().getLocation().add(DISTANCE_FROM_KING / 2, 0, (DISTANCE_FROM_KING / 2) * -1), + getEntity().getLocation().add((DISTANCE_FROM_KING / 2) * -1, 0, (DISTANCE_FROM_KING / 2) * -1) }; - Bukkit.broadcastMessage("Instantiated Wraith"); + + if (creature.getHealth() <= FINAL_SKELETON_HEALTH) + { + WRAITH_AMOUNT_THIS_USE = (int)(WRAITH_AMOUNT * FINAL_WRAITH_MULTIPLIER); + } + else + { + WRAITH_AMOUNT_THIS_USE = WRAITH_AMOUNT; + } } private String getNumberString(Integer number) @@ -76,14 +95,14 @@ public class NecromancerWraithSummon extends BossAbility 0) { - for (int i = 0; i < WRAITH_AMOUNT; i++) + for (int i = 0; i < WRAITH_AMOUNT_THIS_USE; i++) { int spawnIndex = i; if (spawnIndex >= _spawns.length) @@ -143,7 +162,7 @@ public class NecromancerWraithSummon extends BossAbility { private static final int BARBED_LEVEL = 1; - private static final int LIFETIME = 40; - - private HashSet _arrows = new HashSet(); + private static final int LIFETIME = -1; public UndeadArcherCreature(WorldEvent event, Location spawnLocation) { - super(event, spawnLocation, "Undead Archer", true, 100, Skeleton.class); + super(event, spawnLocation, "Undead Archer", true, 25, Skeleton.class); spawnEntity(); } @@ -114,7 +111,7 @@ public class UndeadArcherCreature extends EventCreature return; } - _arrows.add((Projectile) event.getProjectile()); + event.getProjectile().setMetadata("BARBED_ARROW", new FixedMetadataValue(getEvent().getPlugin(), 2)); } @EventHandler(priority = EventPriority.HIGH) @@ -139,6 +136,11 @@ public class UndeadArcherCreature extends EventCreature return; } + if (!projectile.hasMetadata("BARBED_ARROW")) + { + return; + } + if (damagee == null) { return; @@ -149,6 +151,11 @@ public class UndeadArcherCreature extends EventCreature return; } + if (!getEntity().equals(damager)) + { + return; + } + // Level if (BARBED_LEVEL == 0) { @@ -163,7 +170,7 @@ public class UndeadArcherCreature extends EventCreature } // Damage - event.AddMod(damager.getName(), "Barbed Arrows", 0, false); + event.AddMod(damager.getName(), "Barbed Arrows", projectile.getMetadata("BARBED_ARROW").get(0).asDouble(), false); // Condition getEvent().getCondition().Factory().Slow("Barbed Arrows", damagee, damager, (projectile.getVelocity().length() / 3) * (2 + BARBED_LEVEL), 0, false, true, true, true); @@ -182,14 +189,46 @@ public class UndeadArcherCreature extends EventCreature remove(); return; } - - for (Iterator arrowIterator = _arrows.iterator(); arrowIterator.hasNext();) + } + + @EventHandler + public void onTarget(EntityTargetLivingEntityEvent event) + { + if (getEntity().equals(event.getEntity())) { - Projectile arrow = arrowIterator.next(); - - if (arrow.isDead() || !arrow.isValid()) + if (!(event.getTarget() instanceof Player)) { - arrowIterator.remove(); + event.setCancelled(true); + } + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void protect(CustomDamageEvent event) + { + if (event.IsCancelled()) + { + return; + } + + LivingEntity damagee = event.GetDamageeEntity(); + LivingEntity damager = event.GetDamagerEntity(event.GetCause() == DamageCause.PROJECTILE); + + if (damagee == null) + { + return; + } + + if (damager == null) + { + return; + } + + if (getEntity().equals(damagee)) + { + if (!(damager instanceof Player)) + { + event.SetCancelled("Allied Attacker"); } } } diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/minion/UndeadWarriorCreature.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/minion/UndeadWarriorCreature.java similarity index 63% rename from Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/minion/UndeadWarriorCreature.java rename to Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/minion/UndeadWarriorCreature.java index f568eaf94..4cad77cb0 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/minion/UndeadWarriorCreature.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/minion/UndeadWarriorCreature.java @@ -1,4 +1,4 @@ -package mineplex.minecraft.game.core.boss.necromancer.minion; +package mineplex.minecraft.game.core.boss.skeletonking.minion; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; @@ -7,12 +7,18 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.boss.EventCreature; import mineplex.minecraft.game.core.boss.WorldEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; import org.bukkit.entity.Zombie; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityTargetLivingEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.inventory.EntityEquipment; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; @@ -20,11 +26,11 @@ import org.bukkit.potion.PotionEffectType; public class UndeadWarriorCreature extends EventCreature { - private static final int LIFETIME = 40; + private static final int LIFETIME = -1; public UndeadWarriorCreature(WorldEvent event, Location spawnLocation) { - super(event, spawnLocation, "Undead Warrior", true, 100, Zombie.class); + super(event, spawnLocation, "Undead Warrior", true, 30, Zombie.class); spawnEntity(); } @@ -107,4 +113,76 @@ public class UndeadWarriorCreature extends EventCreature //Effect zombie.getWorld().playSound(zombie.getLocation(), Sound.ZOMBIE_HURT, 1f, 2f); } + + @EventHandler + public void onTarget(EntityTargetLivingEntityEvent event) + { + if (getEntity().equals(event.getEntity())) + { + if (!(event.getTarget() instanceof Player)) + { + event.setCancelled(true); + } + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void attack(CustomDamageEvent event) + { + if (event.IsCancelled()) + { + return; + } + + LivingEntity damagee = event.GetDamageeEntity(); + LivingEntity damager = event.GetDamagerEntity(false); + + if (damagee == null) + { + return; + } + + if (damager == null) + { + return; + } + + if (getEntity().equals(damager)) + { + if (damagee instanceof Player) + { + ((Player)damagee).setFoodLevel(((Player)damagee).getFoodLevel() - 1); + } + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void protect(CustomDamageEvent event) + { + if (event.IsCancelled()) + { + return; + } + + LivingEntity damagee = event.GetDamageeEntity(); + LivingEntity damager = event.GetDamagerEntity(event.GetCause() == DamageCause.PROJECTILE); + + if (damagee == null) + { + return; + } + + if (damager == null) + { + return; + } + + if (getEntity().equals(damagee)) + { + if (!(damager instanceof Player)) + { + event.SetCancelled("Allied Attacker"); + } + } + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/minion/WraithCreature.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/minion/WraithCreature.java similarity index 80% rename from Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/minion/WraithCreature.java rename to Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/minion/WraithCreature.java index 02794e979..f8331971e 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/necromancer/minion/WraithCreature.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/minion/WraithCreature.java @@ -1,4 +1,4 @@ -package mineplex.minecraft.game.core.boss.necromancer.minion; +package mineplex.minecraft.game.core.boss.skeletonking.minion; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; @@ -16,9 +16,12 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; import org.bukkit.entity.Zombie; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityTargetLivingEntityEvent; import org.bukkit.inventory.EntityEquipment; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; @@ -99,8 +102,10 @@ public class WraithCreature extends EventCreature return; } - // Damage - event.AddMult(damager.getName(), "Mystical Darkness", 2, false); + if (getEntity().equals(damager)) + { + event.AddMult(damager.getName(), "Mystical Darkness", 2, false); + } } @EventHandler @@ -137,4 +142,46 @@ public class WraithCreature extends EventCreature UtilParticle.PlayParticleToAll(ParticleType.SMOKE, zombie.getLocation(), 0, 0, 0, 0, 5, ViewDist.MAX); zombie.getWorld().playSound(zombie.getLocation(), Sound.ENDERMAN_TELEPORT, 1f, 2f); } + + @EventHandler + public void onTarget(EntityTargetLivingEntityEvent event) + { + if (getEntity().equals(event.getEntity())) + { + if (!(event.getTarget() instanceof Player)) + { + event.setCancelled(true); + } + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void protect(CustomDamageEvent event) + { + if (event.IsCancelled()) + { + return; + } + + LivingEntity damagee = event.GetDamageeEntity(); + LivingEntity damager = event.GetDamagerEntity(event.GetCause() == DamageCause.PROJECTILE); + + if (damagee == null) + { + return; + } + + if (damager == null) + { + return; + } + + if (getEntity().equals(damagee)) + { + if (!(damager instanceof Player)) + { + event.SetCancelled("Allied Attacker"); + } + } + } } \ No newline at end of file From 3acca23e7e9c47eca99ffae2da99988b27cd0510 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Tue, 12 Jul 2016 05:20:22 -0400 Subject: [PATCH 24/90] Remove emerald drops from Skeleton King minions and decrease the range EventCreatures can go from their spawn --- .../mineplex/minecraft/game/core/boss/EventCreature.java | 2 +- .../boss/skeletonking/minion/UndeadArcherCreature.java | 2 -- .../boss/skeletonking/minion/UndeadWarriorCreature.java | 4 +--- .../core/boss/skeletonking/minion/WraithCreature.java | 9 ++++++--- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventCreature.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventCreature.java index 60de4a488..7f1f2bdfa 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventCreature.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventCreature.java @@ -280,7 +280,7 @@ public abstract class EventCreature implements Listener spawnEntity(); } - if (UtilMath.offset2d(_entity.getLocation(), _spawnLocation) > 44) + if (UtilMath.offset2d(_entity.getLocation(), _spawnLocation) > 34) { _entity.setVelocity(UtilAlg.getTrajectory(_entity.getLocation(), _spawnLocation).normalize().multiply(2)); } diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/minion/UndeadArcherCreature.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/minion/UndeadArcherCreature.java index d32007933..395eb8fa5 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/minion/UndeadArcherCreature.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/minion/UndeadArcherCreature.java @@ -89,8 +89,6 @@ public class UndeadArcherCreature extends EventCreature } getEntity().getWorld().dropItem(getEntity().getLocation(), new org.bukkit.inventory.ItemStack(Material.ARROW, UtilMath.r(12) + 1)); - - getEntity().getWorld().dropItem(getEntity().getLocation(), new ItemStack(Material.EMERALD, UtilMath.r(5) + 1)); } @EventHandler(priority = EventPriority.MONITOR) diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/minion/UndeadWarriorCreature.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/minion/UndeadWarriorCreature.java index 4cad77cb0..c0b254717 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/minion/UndeadWarriorCreature.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/minion/UndeadWarriorCreature.java @@ -17,8 +17,8 @@ import org.bukkit.entity.Player; import org.bukkit.entity.Zombie; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; -import org.bukkit.event.entity.EntityTargetLivingEntityEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityTargetLivingEntityEvent; import org.bukkit.inventory.EntityEquipment; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; @@ -71,8 +71,6 @@ public class UndeadWarriorCreature extends EventCreature if (Math.random() > 0.97) getEntity().getWorld().dropItem(getEntity().getLocation(), new ItemStack(Material.IRON_BOOTS)); - - getEntity().getWorld().dropItem(getEntity().getLocation(), new ItemStack(Material.EMERALD, UtilMath.r(5) + 1)); } @EventHandler diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/minion/WraithCreature.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/minion/WraithCreature.java index f8331971e..c8bc96291 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/minion/WraithCreature.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/minion/WraithCreature.java @@ -77,8 +77,6 @@ public class WraithCreature extends EventCreature if (Math.random() > 0.97) getEntity().getWorld().dropItem(getEntity().getLocation(), new ItemStack(Material.DIAMOND_BOOTS)); - - getEntity().getWorld().dropItem(getEntity().getLocation(), new ItemStack(Material.EMERALD, UtilMath.r(10) + 1)); } @EventHandler(priority = EventPriority.HIGH) @@ -136,9 +134,14 @@ public class WraithCreature extends EventCreature if (dist <= 10 || dist > 25) return; + Location teleport = zombie.getTarget().getLocation().add(Math.random() + 1, 0, Math.random() + 1); + if (UtilMath.offset(getSpawnLocation(), teleport) > 34) + { + return; + } UtilParticle.PlayParticleToAll(ParticleType.SMOKE, zombie.getLocation(), 0, 0, 0, 0, 5, ViewDist.MAX); zombie.getWorld().playSound(zombie.getLocation(), Sound.ENDERMAN_TELEPORT, 1f, 2f); - zombie.teleport(zombie.getTarget().getLocation().add(Math.random() + 1, 0, Math.random() + 1)); + zombie.teleport(teleport); UtilParticle.PlayParticleToAll(ParticleType.SMOKE, zombie.getLocation(), 0, 0, 0, 0, 5, ViewDist.MAX); zombie.getWorld().playSound(zombie.getLocation(), Sound.ENDERMAN_TELEPORT, 1f, 2f); } From f0db20dbc2799a18547dc66dd7be00840b8e9088 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Tue, 12 Jul 2016 05:21:50 -0400 Subject: [PATCH 25/90] Fix some minor spelling and grammar issues and implement a requested player freezing system for Clans --- .../game/clans/clans/ban/ClansBanManager.java | 201 +++++++++++++++++- .../clans/ban/commands/ClansBanCommand.java | 4 +- .../clans/ban/commands/FreezeCommand.java | 41 ++++ .../clans/ban/commands/UnfreezeCommand.java | 41 ++++ 4 files changed, 284 insertions(+), 3 deletions(-) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/FreezeCommand.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/UnfreezeCommand.java diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java index 62e7be42a..2c22de324 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java @@ -1,23 +1,48 @@ package mineplex.game.clans.clans.ban; +import java.util.HashMap; +import java.util.UUID; + import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; +import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; +import mineplex.core.common.util.F; +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.donation.DonationManager; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ban.commands.ClansBanCommand; +import mineplex.game.clans.clans.event.ClansCommandExecutedEvent; +import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityTargetLivingEntityEvent; import org.bukkit.event.player.AsyncPlayerPreLoginEvent; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.java.JavaPlugin; public class ClansBanManager extends MiniPlugin { + private static final long FREEZE_MESSAGE_INTERVAL = 10000; private final CoreClientManager _clientManager; private final DonationManager _donationManager; private final ClansBanRepository _repository; + private final HashMap _frozen = new HashMap<>(); public ClansBanManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager) { @@ -74,6 +99,180 @@ public class ClansBanManager extends MiniPlugin } } catch (Exception ignored) {} } + + @EventHandler(priority = EventPriority.LOWEST) + public void onQuit(PlayerQuitEvent event) + { + Float walkSpeed = _frozen.remove(event.getPlayer().getUniqueId()); + if (walkSpeed != null) + { + event.getPlayer().setWalkSpeed(walkSpeed); + for (Player staff : UtilServer.GetPlayers()) + { + if (_clientManager.hasRank(staff, Rank.HELPER)) + { + UtilPlayer.message(staff, F.main(getName(), F.elem(event.getPlayer().getName()) + " has logged out while frozen!")); + } + } + } + } + + @EventHandler + public void onMove(PlayerMoveEvent event) + { + if (isFrozen(event.getPlayer()) && UtilMath.offset2d(event.getFrom(), event.getTo()) >= 1) + { + event.setCancelled(true); + } + } + + @EventHandler + public void onDisplayFreezeMessage(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + + for (UUID frozenUUID : _frozen.keySet()) + { + Player frozen = Bukkit.getPlayer(frozenUUID); + if (Recharge.Instance.use(frozen, "Freeze Message", FREEZE_MESSAGE_INTERVAL, false, false)) + { + String border = C.cGray + C.Strike + "-----------------------------------------------------"; + String sq = "\u2589"; + + UtilPlayer.message(frozen, border); + UtilPlayer.message(frozen, C.Reset + ""); + UtilPlayer.message(frozen, C.cWhite + sq + sq + sq + sq + C.cRed + sq + C.cWhite + sq + sq + sq + sq); + UtilPlayer.message(frozen, C.cWhite + sq + sq + sq + C.cRed + sq + C.cBlack + sq + C.cRed + sq + C.cWhite + sq + sq + sq); + UtilPlayer.message(frozen, C.cWhite + sq + sq + C.cRed + sq + C.cGold + sq + C.cBlack + sq + C.cGold + sq + C.cRed + sq + C.cWhite + sq + sq); + UtilPlayer.message(frozen, C.cWhite + sq + sq + C.cRed + sq + C.cGold + sq + C.cBlack + sq + C.cGold + sq + C.cRed + sq + C.cWhite + sq + sq); + UtilPlayer.message(frozen, C.cWhite + sq + sq + C.cRed + sq + C.cGold + sq + C.cBlack + sq + C.cGold + sq + C.cRed + sq + C.cWhite + sq + sq); + UtilPlayer.message(frozen, C.cWhite + sq + C.cRed + sq + C.cGold + sq + sq + sq + C.cGold + sq + sq + C.cRed + sq + C.cWhite + sq); + UtilPlayer.message(frozen, C.cRed + sq + C.cGold + sq + sq + sq + C.cBlack + sq + C.cGold + sq + sq + sq + C.cRed + sq); + UtilPlayer.message(frozen, C.cRed + sq + sq + sq + sq + sq + sq + sq + sq + sq); + UtilPlayer.message(frozen, C.Reset + ""); + UtilPlayer.message(frozen, C.cRed + "You have been frozen by a staff member!"); + UtilPlayer.message(frozen, C.cRed + "Do not log out or you will be banned!"); + UtilPlayer.message(frozen, C.Reset + ""); + UtilPlayer.message(frozen, border); + } + } + } + + @EventHandler + public void handleMobs(EntityTargetLivingEntityEvent event) + { + if (event.getTarget() instanceof Player) + { + Player player = (Player) event.getTarget(); + if (!isFrozen(player)) + { + return; + } + + event.setCancelled(true); + } + } + + @EventHandler + public void onDamage(CustomDamageEvent event) + { + Player damager = event.GetDamagerPlayer(event.GetCause() == DamageCause.PROJECTILE); + Player damagee = event.GetDamageePlayer(); + + if (damager != null && isFrozen(damager)) + { + event.SetCancelled("Frozen Attacker"); + UtilPlayer.message(damager, F.main(getName(), "You cannot attack others while frozen!")); + } + if (damagee != null && isFrozen(damagee)) + { + event.SetCancelled("Frozen Damagee"); + if (damager != null) + { + UtilPlayer.message(damager, F.main(getName(), "You cannot attack " + F.elem(damagee.getName()) + " while they are frozen!")); + } + } + } + + @EventHandler + public void onUseSkill(SkillTriggerEvent event) + { + if (isFrozen(event.GetPlayer())) + { + event.SetCancelled(true); + UtilPlayer.message(event.GetPlayer(), "You cannot use " + F.skill(event.GetSkillName()) + " while frozen!"); + } + } + + @EventHandler + public void onBreak(BlockBreakEvent event) + { + if (isFrozen(event.getPlayer())) + { + event.setCancelled(true); + UtilPlayer.message(event.getPlayer(), F.main(getName(), "You cannot break blocks while frozen!")); + } + } + + @EventHandler + public void onPlace(BlockPlaceEvent event) + { + if (isFrozen(event.getPlayer())) + { + event.setCancelled(true); + UtilPlayer.message(event.getPlayer(), F.main(getName(), "You cannot place blocks while frozen!")); + } + } + + @EventHandler + public void onTpHome(ClansCommandExecutedEvent event) + { + if (event.getCommand().equalsIgnoreCase("tphome")) + { + if (isFrozen(event.getPlayer())) + { + event.setCancelled(true); + UtilPlayer.message(event.getPlayer(), F.main(getName(), "You cannot teleport to your Clan home while frozen!")); + } + } + } + + public boolean isFrozen(Player player) + { + return _frozen.containsKey(player.getUniqueId()); + } + + public void freeze(Player player, Player staff) + { + _frozen.put(player.getUniqueId(), player.getWalkSpeed()); + player.setWalkSpeed(0); + for (Player alert : UtilServer.GetPlayers()) + { + if (_clientManager.hasRank(alert, Rank.HELPER)) + { + UtilPlayer.message(alert, F.main(getName(), F.elem(player.getName()) + " has been frozen by " + F.elem(staff.getName()) + "!")); + } + } + } + + public void unfreeze(Player player, Player staff) + { + Float walkSpeed = _frozen.remove(player.getUniqueId()); + if (walkSpeed != null) + { + player.setWalkSpeed(walkSpeed); + for (Player alert : UtilServer.GetPlayers()) + { + if (_clientManager.hasRank(alert, Rank.HELPER)) + { + UtilPlayer.message(alert, F.main(getName(), F.elem(player.getName()) + " has been unfrozen by " + F.elem(staff.getName()) + "!")); + } + } + } + } public void unban(ClansBanClient target, ClansBan ban, Callback callback) { @@ -87,4 +286,4 @@ public class ClansBanManager extends MiniPlugin callback.run(target); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/ClansBanCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/ClansBanCommand.java index 39923ea27..e43c9f130 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/ClansBanCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/ClansBanCommand.java @@ -22,7 +22,7 @@ public class ClansBanCommand extends CommandBase { if (args == null || args.length < 1) { - UtilPlayer.message(caller, C.cBlue + "/cb " + C.cGray + " - " + C.cYellow + "Displays the \"Clans Punish\" GUI, allowing you to ban the player, and view thier past bans."); + UtilPlayer.message(caller, C.cBlue + "/cb " + C.cGray + " - " + C.cYellow + "Displays the \"Clans Punish\" GUI, allowing you to ban the player, and view their past bans."); } else if (args.length > 1) { @@ -52,7 +52,7 @@ public class ClansBanCommand extends CommandBase } else { - UtilPlayer.message(caller, C.cBlue + "/cb " + C.cGray + " - " + C.cYellow + "Displays the \"Clans Punish\" GUI, allowing you to ban the player, and view thier past bans."); + UtilPlayer.message(caller, C.cBlue + "/cb " + C.cGray + " - " + C.cYellow + "Displays the \"Clans Punish\" GUI, allowing you to ban the player, and view their past bans."); } } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/FreezeCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/FreezeCommand.java new file mode 100644 index 000000000..5b6ee7158 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/FreezeCommand.java @@ -0,0 +1,41 @@ +package mineplex.game.clans.clans.ban.commands; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.game.clans.clans.ban.ClansBanManager; + +import org.bukkit.entity.Player; + +public class FreezeCommand extends CommandBase +{ + public FreezeCommand(ClansBanManager plugin) + { + super(plugin, Rank.CMOD, "freeze"); + } + + @Override + public void Execute(Player caller, String[] args) + { + if (args == null || args.length < 1) + { + UtilPlayer.message(caller, C.cBlue + "/freeze " + C.cGray + " - " + C.cYellow + "Freezes a player, restricting their movement and ability to interact with the game."); + } + else if (args.length > 0) + { + Player target = UtilPlayer.searchOnline(caller, args[0], true); + if (target == null) + { + return; + } + if (Plugin.isFrozen(target)) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), F.elem(args[0]) + " is already frozen!")); + return; + } + Plugin.freeze(target, caller); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/UnfreezeCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/UnfreezeCommand.java new file mode 100644 index 000000000..3494ee20c --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/UnfreezeCommand.java @@ -0,0 +1,41 @@ +package mineplex.game.clans.clans.ban.commands; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.game.clans.clans.ban.ClansBanManager; + +import org.bukkit.entity.Player; + +public class UnfreezeCommand extends CommandBase +{ + public UnfreezeCommand(ClansBanManager plugin) + { + super(plugin, Rank.CMOD, "unfreeze"); + } + + @Override + public void Execute(Player caller, String[] args) + { + if (args == null || args.length < 1) + { + UtilPlayer.message(caller, C.cBlue + "/unfreeze " + C.cGray + " - " + C.cYellow + "Unfreezes a player, restoring their movement and ability to interact with the game."); + } + else if (args.length > 0) + { + Player target = UtilPlayer.searchOnline(caller, args[0], true); + if (target == null) + { + return; + } + if (!Plugin.isFrozen(target)) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), F.elem(args[0]) + " is not frozen!")); + return; + } + Plugin.unfreeze(target, caller); + } + } +} \ No newline at end of file From 2034b5536e15a9a625eae1031a7a887820112e40 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Wed, 13 Jul 2016 09:42:46 -0400 Subject: [PATCH 26/90] Update and enable Clans Freezing --- .../game/clans/clans/ban/ClansBanManager.java | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java index 2c22de324..157c84755 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java @@ -19,6 +19,8 @@ import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ban.commands.ClansBanCommand; +import mineplex.game.clans.clans.ban.commands.FreezeCommand; +import mineplex.game.clans.clans.ban.commands.UnfreezeCommand; import mineplex.game.clans.clans.event.ClansCommandExecutedEvent; import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; @@ -35,6 +37,8 @@ import org.bukkit.event.player.AsyncPlayerPreLoginEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; public class ClansBanManager extends MiniPlugin { @@ -59,6 +63,8 @@ public class ClansBanManager extends MiniPlugin public void addCommands() { addCommand(new ClansBanCommand(this)); + addCommand(new FreezeCommand(this)); + addCommand(new UnfreezeCommand(this)); } public CoreClientManager getClientManager() @@ -107,6 +113,7 @@ public class ClansBanManager extends MiniPlugin if (walkSpeed != null) { event.getPlayer().setWalkSpeed(walkSpeed); + event.getPlayer().removePotionEffect(PotionEffectType.JUMP); for (Player staff : UtilServer.GetPlayers()) { if (_clientManager.hasRank(staff, Rank.HELPER)) @@ -120,9 +127,10 @@ public class ClansBanManager extends MiniPlugin @EventHandler public void onMove(PlayerMoveEvent event) { - if (isFrozen(event.getPlayer()) && UtilMath.offset2d(event.getFrom(), event.getTo()) >= 1) + if (isFrozen(event.getPlayer()) && UtilMath.offset2d(event.getFrom().getBlock().getLocation(), event.getTo().getBlock().getLocation()) >= 1) { event.setCancelled(true); + event.getPlayer().teleport(event.getFrom().getBlock().getLocation().add(0, 1, 0)); } } @@ -167,12 +175,10 @@ public class ClansBanManager extends MiniPlugin if (event.getTarget() instanceof Player) { Player player = (Player) event.getTarget(); - if (!isFrozen(player)) + if (isFrozen(player)) { - return; + event.setCancelled(true); } - - event.setCancelled(true); } } @@ -203,7 +209,7 @@ public class ClansBanManager extends MiniPlugin if (isFrozen(event.GetPlayer())) { event.SetCancelled(true); - UtilPlayer.message(event.GetPlayer(), "You cannot use " + F.skill(event.GetSkillName()) + " while frozen!"); + UtilPlayer.message(event.GetPlayer(), F.main(getName(), "You cannot use " + F.skill(event.GetSkillName()) + " while frozen!")); } } @@ -249,6 +255,7 @@ public class ClansBanManager extends MiniPlugin { _frozen.put(player.getUniqueId(), player.getWalkSpeed()); player.setWalkSpeed(0); + player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 999999, -10)); for (Player alert : UtilServer.GetPlayers()) { if (_clientManager.hasRank(alert, Rank.HELPER)) @@ -264,11 +271,17 @@ public class ClansBanManager extends MiniPlugin if (walkSpeed != null) { player.setWalkSpeed(walkSpeed); + player.removePotionEffect(PotionEffectType.JUMP); for (Player alert : UtilServer.GetPlayers()) { if (_clientManager.hasRank(alert, Rank.HELPER)) { UtilPlayer.message(alert, F.main(getName(), F.elem(player.getName()) + " has been unfrozen by " + F.elem(staff.getName()) + "!")); + continue; + } + if (alert.getName().equals(player.getName())) + { + UtilPlayer.message(alert, F.main(getName(), "You have been unfrozen!")); } } } From 08850d909f4ea16948dc5a7486ece343d5e00438 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 16 Jul 2016 21:59:03 -0400 Subject: [PATCH 27/90] Further work on brood mother boss and nether --- .../clans/clans/nether/NetherManager.java | 2 +- .../clans/worldevent/WorldEventManager.java | 2 +- .../clans/worldevent/WorldEventType.java | 2 +- .../game/clans/gameplay/Gameplay.java | 14 ++- .../{spider => broodmother}/SpiderBoss.java | 105 +++--------------- .../SpiderCreature.java | 77 ++++++------- .../SpiderMinionCreature.java | 34 +++--- .../attacks/SpiderCeilingCling.java | 6 +- .../broodmother/attacks/SpiderCocoon.java | 71 ++++++++++++ .../attacks/SpiderEggAbility.java | 40 +++---- .../attacks/SpiderEggScatter.java | 4 +- .../attacks/SpiderEggplosm.java | 4 +- .../attacks/SpiderPoison.java | 2 +- .../attacks/SpiderPoisonBarrage.java | 30 ++--- .../attacks/SpiderWebBarrage.java | 27 +++-- .../attacks/SpiderWebStomp.java | 17 +-- .../game/games/bossbattles/BattleBoss.java | 2 +- .../game/games/bossbattles/BossBattles.java | 2 +- 18 files changed, 216 insertions(+), 225 deletions(-) rename Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/{spider => broodmother}/SpiderBoss.java (50%) rename Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/{spider => broodmother}/SpiderCreature.java (88%) rename Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/{spider => broodmother}/SpiderMinionCreature.java (86%) rename Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/{spider => broodmother}/attacks/SpiderCeilingCling.java (94%) create mode 100644 Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderCocoon.java rename Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/{spider => broodmother}/attacks/SpiderEggAbility.java (95%) rename Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/{spider => broodmother}/attacks/SpiderEggScatter.java (90%) rename Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/{spider => broodmother}/attacks/SpiderEggplosm.java (89%) rename Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/{spider => broodmother}/attacks/SpiderPoison.java (96%) rename Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/{spider => broodmother}/attacks/SpiderPoisonBarrage.java (94%) rename Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/{spider => broodmother}/attacks/SpiderWebBarrage.java (91%) rename Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/{spider => broodmother}/attacks/SpiderWebStomp.java (83%) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java index bca49b00d..260a94132 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java @@ -26,9 +26,9 @@ import mineplex.game.clans.clans.nether.command.PortalCommand; import mineplex.game.clans.clans.nether.data.ClaimData; import mineplex.game.clans.spawn.Spawn; import mineplex.minecraft.game.core.boss.EventCreatureDeathEvent; +import mineplex.minecraft.game.core.boss.broodmother.SpiderCreature; import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature; import mineplex.minecraft.game.core.boss.skeletonking.SkeletonCreature; -import mineplex.minecraft.game.core.boss.spider.SpiderCreature; import mineplex.minecraft.game.core.condition.Condition.ConditionType; import org.bukkit.Bukkit; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java index f3a896df3..63408e797 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java @@ -23,9 +23,9 @@ import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; import mineplex.minecraft.game.core.boss.EventCreatureDeathEvent; import mineplex.minecraft.game.core.boss.EventState; import mineplex.minecraft.game.core.boss.WorldEvent; +import mineplex.minecraft.game.core.boss.broodmother.SpiderCreature; import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature; import mineplex.minecraft.game.core.boss.skeletonking.SkeletonCreature; -import mineplex.minecraft.game.core.boss.spider.SpiderCreature; import mineplex.minecraft.game.core.damage.DamageManager; import org.bukkit.Bukkit; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java index 5a200d3bf..9f402551f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java @@ -6,10 +6,10 @@ import mineplex.game.clans.clans.worldevent.kinghill.KingHill; import mineplex.game.clans.clans.worldevent.undead.UndeadCamp; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; import mineplex.minecraft.game.core.boss.WorldEvent; +import mineplex.minecraft.game.core.boss.broodmother.SpiderBoss; import mineplex.minecraft.game.core.boss.ironwizard.GolemBoss; import mineplex.minecraft.game.core.boss.skeletonking.SkeletonBoss; import mineplex.minecraft.game.core.boss.slimeking.SlimeBoss; -import mineplex.minecraft.game.core.boss.spider.SpiderBoss; import org.bukkit.Location; 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 05e00963b..3807c267e 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 @@ -357,9 +357,19 @@ public class Gameplay extends MiniPlugin @EventHandler public void WebBreak(BlockDamageEvent event) { - if (event.isCancelled()) return; + if (event.isCancelled()) + { + return; + } + if (_clansManager.getWorldEvent().isInEvent(event.getBlock().getLocation())) + { + return; + } - if (event.getBlock().getType() == Material.WEB) event.setInstaBreak(true); + if (event.getBlock().getType() == Material.WEB) + { + event.setInstaBreak(true); + } } @EventHandler diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/SpiderBoss.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/SpiderBoss.java similarity index 50% rename from Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/SpiderBoss.java rename to Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/SpiderBoss.java index cb9df4fcf..612113429 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/SpiderBoss.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/SpiderBoss.java @@ -1,13 +1,8 @@ -package mineplex.minecraft.game.core.boss.spider; - -import java.util.HashMap; -import java.util.Iterator; +package mineplex.minecraft.game.core.boss.broodmother; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.disguise.DisguiseManager; import mineplex.core.projectile.ProjectileManager; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.boss.EventCreature; import mineplex.minecraft.game.core.boss.EventState; import mineplex.minecraft.game.core.boss.WorldEvent; @@ -15,89 +10,21 @@ import mineplex.minecraft.game.core.condition.ConditionManager; import mineplex.minecraft.game.core.damage.DamageManager; import org.bukkit.Bukkit; -import org.bukkit.Effect; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; -import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.entity.ItemSpawnEvent; public class SpiderBoss extends WorldEvent { - private HashMap _webDurability = new HashMap(); - public SpiderBoss(DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, ProjectileManager projectileManager, Location cornerLocation) { super(DisguiseManager.INSTANCE, projectileManager, damageManager, blockRestore, conditionManager, "Brood Mother", cornerLocation, "schematic/Golem.schematic"); } - @EventHandler - public void onWebDura(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - { - return; - } - - for (Player player : getCenterLocation().getWorld().getPlayers()) - { - if (!getEventMap().isInMap(player.getLocation())) - { - continue; - } - - loop: for (double x = -0.3; x <= 0.3; x += 0.6) - { - for (double z = -0.3; z <= 0.3; z += 0.6) - { - for (double y = -0.9; y <= 0.9; y += 1.8) - { - Block block = player.getLocation().add(x, 0.9 + y, z).getBlock(); - - if (block.getType() != Material.WEB) - { - continue; - } - - if (!_webDurability.containsKey(block)) - { - _webDurability.put(block, 0D); - } - - _webDurability.put(block, _webDurability.get(block) + 0.1); - - if (_webDurability.get(block) > 1) - { - _webDurability.remove(block); - - block.setType(Material.AIR); - block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.WEB); - } - - break loop; - } - } - } - } - - Iterator itel = _webDurability.keySet().iterator(); - - while (itel.hasNext()) - { - Block block = itel.next(); - - _webDurability.put(block, _webDurability.get(block) - 0.01); - - if (_webDurability.get(block) < 0) - { - itel.remove(); - } - } - } - @EventHandler public void onBreak(BlockBreakEvent event) { @@ -113,9 +40,8 @@ public class SpiderBoss extends WorldEvent return; } - _webDurability.remove(block); - - event.setCancelled(false); + event.setCancelled(true); + event.getBlock().setType(Material.AIR); } @EventHandler @@ -138,13 +64,13 @@ public class SpiderBoss extends WorldEvent protected void customStart() { Bukkit.broadcastMessage("Custom Start"); - spawnGolem(getCenterLocation()); + spawnSpider(getCenterLocation()); setState(EventState.LIVE); announceStart(); } /** - * Check if this slime boss has been defeated + * Check if this spider boss has been defeated */ private void checkDeath() { @@ -168,16 +94,19 @@ public class SpiderBoss extends WorldEvent public SpiderMinionCreature spawnMinion(Location location) { - SpiderMinionCreature slimeCreature = new SpiderMinionCreature(this, location, 5); - registerCreature(slimeCreature); - return slimeCreature; + if (getState() != EventState.LIVE) + { + return null; + } + SpiderMinionCreature minionCreature = new SpiderMinionCreature(this, location, 15); + registerCreature(minionCreature); + return minionCreature; } - private SpiderCreature spawnGolem(Location location) + private SpiderCreature spawnSpider(Location location) { - SpiderCreature slimeCreature = new SpiderCreature(this, location, 2500); - registerCreature(slimeCreature); - return slimeCreature; + SpiderCreature spiderCreature = new SpiderCreature(this, location, 2500); + registerCreature(spiderCreature); + return spiderCreature; } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/SpiderCreature.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/SpiderCreature.java similarity index 88% rename from Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/SpiderCreature.java rename to Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/SpiderCreature.java index 8c813ed28..b17578cd7 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/SpiderCreature.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/SpiderCreature.java @@ -1,48 +1,46 @@ -package mineplex.minecraft.game.core.boss.spider; +package mineplex.minecraft.game.core.boss.broodmother; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.Iterator; +import java.util.List; import java.util.Map.Entry; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.entity.Entity; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Pig; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.HandlerList; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.util.Vector; - 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.disguise.disguises.DisguiseSpider; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.boss.BossAbility; import mineplex.minecraft.game.core.boss.EventCreature; -import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature; -import mineplex.minecraft.game.core.boss.spider.attacks.SpiderCeilingCling; -import mineplex.minecraft.game.core.boss.spider.attacks.SpiderEggScatter; -import mineplex.minecraft.game.core.boss.spider.attacks.SpiderEggplosm; -import mineplex.minecraft.game.core.boss.spider.attacks.SpiderPoisonBarrage; -import mineplex.minecraft.game.core.boss.spider.attacks.SpiderWebBarrage; -import mineplex.minecraft.game.core.boss.spider.attacks.SpiderWebStomp; -import mineplex.minecraft.game.core.condition.Condition.ConditionType; +import mineplex.minecraft.game.core.boss.broodmother.attacks.SpiderCocoon; +import mineplex.minecraft.game.core.boss.broodmother.attacks.SpiderEggScatter; +import mineplex.minecraft.game.core.boss.broodmother.attacks.SpiderEggplosm; +import mineplex.minecraft.game.core.boss.broodmother.attacks.SpiderPoisonBarrage; +import mineplex.minecraft.game.core.boss.broodmother.attacks.SpiderWebBarrage; +import mineplex.minecraft.game.core.boss.broodmother.attacks.SpiderWebStomp; import mineplex.minecraft.game.core.damage.CustomDamageEvent; -public class SpiderCreature extends EventCreature +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; +import org.bukkit.entity.Spider; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.util.Vector; + +import com.google.common.collect.Lists; + +public class SpiderCreature extends EventCreature { private ArrayList _currentAbilities = new ArrayList(); private int _lastAbility; @@ -52,27 +50,15 @@ public class SpiderCreature extends EventCreature private Vector _afkWalk = new Vector(); private HashMap _cooldowns = new HashMap(); private long _lastAttack; + public List Webs = Lists.newArrayList(); public SpiderCreature(SpiderBoss boss, Location location, double maxHealth) { - super(boss, location, "Brood Mother", true, maxHealth, Pig.class); + super(boss, location, "Brood Mother", true, maxHealth, Spider.class); spawnEntity(); } - @Override - public void setEntity(Pig entity) - { - super.setEntity(entity); - - if (entity != null) - { - DisguiseSpider disguise = new DisguiseSpider(getEntity()); - - ((SpiderBoss) getEvent()).getDisguiseManager().disguise(disguise); - } - } - @Override protected void spawnCustom() { @@ -82,6 +68,10 @@ public class SpiderCreature extends EventCreature @Override public void dieCustom() { + for (Block block : Webs) + { + block.setType(Material.AIR); + } } @EventHandler @@ -141,10 +131,10 @@ public class SpiderCreature extends EventCreature } } - { // Ceiling Cling + { // Cocoon if (getEvent().getCreatures().size() < 5) { - weight.put(SpiderCeilingCling.class, 2); + weight.put(SpiderCocoon.class, 2); } } @@ -318,7 +308,7 @@ public class SpiderCreature extends EventCreature getEvent().getCondition().Factory() .Blind("Brood Mother Bite", target, getEntity(), 1.5, 0, false, true, true); getEvent().getCondition().Factory() - .Slow("Brood Mother Bite", target, getEntity(), 4, 0, false, true, true, true); + .Slow("Brood Mother Bite", target, getEntity(), 4, 1, false, true, true, true); getEvent().getDamageManager().NewDamageEvent(target, getEntity(), null, DamageCause.ENTITY_ATTACK, 2 * getDifficulty(), true, false, false, "Brood Mother Attack", "Brood Mother Attack"); @@ -449,5 +439,4 @@ public class SpiderCreature extends EventCreature if (cause == DamageCause.FALL) event.SetCancelled("Cancel"); } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/SpiderMinionCreature.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/SpiderMinionCreature.java similarity index 86% rename from Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/SpiderMinionCreature.java rename to Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/SpiderMinionCreature.java index 255f2406e..15eb9a843 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/SpiderMinionCreature.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/SpiderMinionCreature.java @@ -1,37 +1,34 @@ -package mineplex.minecraft.game.core.boss.spider; +package mineplex.minecraft.game.core.boss.broodmother; import java.util.HashMap; -import org.bukkit.GameMode; -import org.bukkit.Location; -import org.bukkit.Sound; -import org.bukkit.entity.Pig; -import org.bukkit.entity.Player; -import org.bukkit.entity.Silverfish; -import org.bukkit.event.EventHandler; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.util.Vector; - import mineplex.core.common.util.UtilAlg; 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.disguise.disguises.DisguiseCaveSpider; -import mineplex.core.disguise.disguises.DisguiseSpider; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.boss.EventCreature; import mineplex.minecraft.game.core.damage.CustomDamageEvent; -public class SpiderMinionCreature extends EventCreature +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.entity.CaveSpider; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.util.Vector; + +public class SpiderMinionCreature extends EventCreature { private long _lastAttack; private Location _moveTo; public SpiderMinionCreature(SpiderBoss boss, Location location, double maxHealth) { - super(boss, location, "Spider Minion", true, maxHealth, Pig.class); + super(boss, location, "Spider Minion", true, maxHealth, CaveSpider.class); spawnEntity(); } @@ -55,10 +52,6 @@ public class SpiderMinionCreature extends EventCreature UtilEnt.Vegetate(getEntity(), true); getEntity().setVelocity(new Vector(UtilMath.rr(0.5, true), 0.4, UtilMath.rr(0.4, true))); - - DisguiseCaveSpider disguise = new DisguiseCaveSpider(getEntity()); - - getEvent().getDisguiseManager().disguise(disguise); } @Override @@ -141,5 +134,4 @@ public class SpiderMinionCreature extends EventCreature if (cause == DamageCause.FALL) event.SetCancelled("Cancel"); } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/attacks/SpiderCeilingCling.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderCeilingCling.java similarity index 94% rename from Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/attacks/SpiderCeilingCling.java rename to Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderCeilingCling.java index 01f28b569..b041e1ecf 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/attacks/SpiderCeilingCling.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderCeilingCling.java @@ -1,4 +1,4 @@ -package mineplex.minecraft.game.core.boss.spider.attacks; +package mineplex.minecraft.game.core.boss.broodmother.attacks; import java.util.Collections; import java.util.List; @@ -20,7 +20,7 @@ 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.UtilShapes; -import mineplex.minecraft.game.core.boss.spider.SpiderCreature; +import mineplex.minecraft.game.core.boss.broodmother.SpiderCreature; import mineplex.minecraft.game.core.damage.CustomDamageEvent; public class SpiderCeilingCling extends SpiderEggAbility @@ -41,7 +41,7 @@ public class SpiderCeilingCling extends SpiderEggAbility for (int i = 0; i < 10; i++) { - Location loc = getLocation().add(UtilMath.rr(10, true), 12, UtilMath.rr(10, true)); + Location loc = getBoss().getSpawnLocation().clone().add(0, -27, 0).add(UtilMath.rr(5, true), 12, UtilMath.rr(5, true)); if (UtilAlg.HasSight(getLocation(), loc)) { diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderCocoon.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderCocoon.java new file mode 100644 index 000000000..cb1a5651a --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderCocoon.java @@ -0,0 +1,71 @@ +package mineplex.minecraft.game.core.boss.broodmother.attacks; + +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.UtilShapes; +import mineplex.core.common.util.UtilTime; +import mineplex.minecraft.game.core.boss.BossAbility; +import mineplex.minecraft.game.core.boss.broodmother.SpiderCreature; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import org.bukkit.Location; +import org.bukkit.entity.Spider; +import org.bukkit.event.EventHandler; + +public class SpiderCocoon extends BossAbility +{ + private static final long ABILITY_DURATION = 7000; + private long _start; + + public SpiderCocoon(SpiderCreature creature) + { + super(creature); + } + + @Override + public boolean canMove() + { + return false; + } + + @Override + public boolean inProgress() + { + return true; + } + + @Override + public boolean hasFinished() + { + return UtilTime.elapsed(_start, ABILITY_DURATION); + } + + @Override + public void setFinished() + { + _start = System.currentTimeMillis() - ABILITY_DURATION; + } + + @Override + public void tick() + { + for (Location loc : UtilShapes.getSphereBlocks(getEntity().getLocation(), 3, 3, false)) + { + UtilParticle.PlayParticleToAll(ParticleType.FIREWORKS_SPARK, loc, null, 0, 1, ViewDist.NORMAL); + } + } + + @EventHandler + public void onDamage(CustomDamageEvent event) + { + if (hasFinished()) + { + return; + } + if (event.GetDamageeEntity() != null && event.GetDamageeEntity().equals(getEntity())) + { + event.SetCancelled("Cocoon Defense"); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/attacks/SpiderEggAbility.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderEggAbility.java similarity index 95% rename from Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/attacks/SpiderEggAbility.java rename to Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderEggAbility.java index 9636a1da6..fcf6b9127 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/attacks/SpiderEggAbility.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderEggAbility.java @@ -1,10 +1,26 @@ -package mineplex.minecraft.game.core.boss.spider.attacks; +package mineplex.minecraft.game.core.boss.broodmother.attacks; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.Map.Entry; +import mineplex.core.common.util.UtilBlock; +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.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.boss.BossAbility; +import mineplex.minecraft.game.core.boss.broodmother.SpiderBoss; +import mineplex.minecraft.game.core.boss.broodmother.SpiderCreature; +import net.minecraft.server.v1_8_R3.MathHelper; +import net.minecraft.server.v1_8_R3.MovingObjectPosition; +import net.minecraft.server.v1_8_R3.Vec3D; + import org.bukkit.Effect; import org.bukkit.GameMode; import org.bukkit.Material; @@ -13,29 +29,13 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.entity.FallingBlock; -import org.bukkit.entity.Pig; +import org.bukkit.entity.Spider; import org.bukkit.event.EventHandler; import org.bukkit.event.block.BlockFromToEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.util.Vector; -import mineplex.core.common.util.UtilBlock; -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.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.boss.BossAbility; -import mineplex.minecraft.game.core.boss.spider.SpiderBoss; -import mineplex.minecraft.game.core.boss.spider.SpiderCreature; -import net.minecraft.server.v1_8_R3.MathHelper; -import net.minecraft.server.v1_8_R3.MovingObjectPosition; -import net.minecraft.server.v1_8_R3.Vec3D; - -public abstract class SpiderEggAbility extends BossAbility +public abstract class SpiderEggAbility extends BossAbility { private HashMap _eggs = new HashMap(); private ArrayList _fallingBlocks = new ArrayList(); @@ -206,7 +206,7 @@ public abstract class SpiderEggAbility extends BossAbility && block.getRelative(BlockFace.DOWN).getType() != Material.DRAGON_EGG) { block.setType(Material.DRAGON_EGG); - _eggs.put(block, System.currentTimeMillis() + 10000 + UtilMath.r(10000)); + _eggs.put(block, System.currentTimeMillis() + 5000 + UtilMath.r(5000)); } fallingIterator.remove(); diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/attacks/SpiderEggScatter.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderEggScatter.java similarity index 90% rename from Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/attacks/SpiderEggScatter.java rename to Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderEggScatter.java index b6ea531a6..a01753e0a 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/attacks/SpiderEggScatter.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderEggScatter.java @@ -1,10 +1,10 @@ -package mineplex.minecraft.game.core.boss.spider.attacks; +package mineplex.minecraft.game.core.boss.broodmother.attacks; import org.bukkit.util.Vector; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; -import mineplex.minecraft.game.core.boss.spider.SpiderCreature; +import mineplex.minecraft.game.core.boss.broodmother.SpiderCreature; public class SpiderEggScatter extends SpiderEggAbility { diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/attacks/SpiderEggplosm.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderEggplosm.java similarity index 89% rename from Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/attacks/SpiderEggplosm.java rename to Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderEggplosm.java index c1dd81bfc..de527b47c 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/attacks/SpiderEggplosm.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderEggplosm.java @@ -1,10 +1,10 @@ -package mineplex.minecraft.game.core.boss.spider.attacks; +package mineplex.minecraft.game.core.boss.broodmother.attacks; import org.bukkit.util.Vector; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; -import mineplex.minecraft.game.core.boss.spider.SpiderCreature; +import mineplex.minecraft.game.core.boss.broodmother.SpiderCreature; public class SpiderEggplosm extends SpiderEggAbility { diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/attacks/SpiderPoison.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderPoison.java similarity index 96% rename from Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/attacks/SpiderPoison.java rename to Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderPoison.java index 3135945b0..b1bc6cc24 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/attacks/SpiderPoison.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderPoison.java @@ -1,4 +1,4 @@ -package mineplex.minecraft.game.core.boss.spider.attacks; +package mineplex.minecraft.game.core.boss.broodmother.attacks; import org.bukkit.Material; import org.bukkit.block.Block; diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/attacks/SpiderPoisonBarrage.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderPoisonBarrage.java similarity index 94% rename from Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/attacks/SpiderPoisonBarrage.java rename to Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderPoisonBarrage.java index 1e44b90f9..1361921e6 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/attacks/SpiderPoisonBarrage.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderPoisonBarrage.java @@ -1,25 +1,25 @@ -package mineplex.minecraft.game.core.boss.spider.attacks; - -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.Item; -import org.bukkit.entity.Pig; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.util.Vector; +package mineplex.minecraft.game.core.boss.broodmother.attacks; 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.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.boss.BossAbility; -import mineplex.minecraft.game.core.boss.spider.SpiderCreature; +import mineplex.minecraft.game.core.boss.broodmother.SpiderCreature; -public class SpiderPoisonBarrage extends BossAbility +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Item; +import org.bukkit.entity.Player; +import org.bukkit.entity.Spider; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; + +public class SpiderPoisonBarrage extends BossAbility { private int _poisonAmount = UtilMath.r(20) + 30; private int _tick; @@ -56,7 +56,7 @@ public class SpiderPoisonBarrage extends BossAbility @Override public int getCooldown() { - return 100; + return 10; } /*@Override @@ -129,7 +129,7 @@ public class SpiderPoisonBarrage extends BossAbility vec.setY(0.35 + UtilMath.rr(0.3, false)); Item item = getLocation().getWorld() - .dropItem(getLocation().add(0, 0.5, 0), new ItemStack(Material.EMERALD_BLOCK)); + .dropItem(getLocation().add(0, 0.5, 0), new ItemStack(Material.SLIME_BALL)); item.setVelocity(vec); diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/attacks/SpiderWebBarrage.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderWebBarrage.java similarity index 91% rename from Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/attacks/SpiderWebBarrage.java rename to Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderWebBarrage.java index 1e0eab120..7ec04a2e8 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/attacks/SpiderWebBarrage.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderWebBarrage.java @@ -1,17 +1,7 @@ -package mineplex.minecraft.game.core.boss.spider.attacks; +package mineplex.minecraft.game.core.boss.broodmother.attacks; import java.util.ArrayList; -import java.util.HashMap; import java.util.Iterator; -import java.util.Map.Entry; - -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.block.Block; -import org.bukkit.entity.FallingBlock; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.util.Vector; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; @@ -19,10 +9,18 @@ import mineplex.core.common.util.UtilMath; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.boss.BossAbility; -import mineplex.minecraft.game.core.boss.EventCreature; -import mineplex.minecraft.game.core.boss.spider.SpiderCreature; +import mineplex.minecraft.game.core.boss.broodmother.SpiderCreature; -public class SpiderWebBarrage extends BossAbility +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.entity.FallingBlock; +import org.bukkit.entity.Player; +import org.bukkit.entity.Spider; +import org.bukkit.event.EventHandler; +import org.bukkit.util.Vector; + +public class SpiderWebBarrage extends BossAbility { private int _canShoot; private ArrayList _fallingBlocks = new ArrayList(); @@ -130,6 +128,7 @@ public class SpiderWebBarrage extends BossAbility if (UtilBlock.airFoliage(block) || block.getType() == Material.WEB) { block.setType(Material.WEB); + getBoss().Webs.add(block); } // Expire diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/attacks/SpiderWebStomp.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderWebStomp.java similarity index 83% rename from Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/attacks/SpiderWebStomp.java rename to Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderWebStomp.java index 9ea40cfc9..d209c671d 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/attacks/SpiderWebStomp.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderWebStomp.java @@ -1,20 +1,20 @@ -package mineplex.minecraft.game.core.boss.spider.attacks; +package mineplex.minecraft.game.core.boss.broodmother.attacks; + +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.minecraft.game.core.boss.BossAbility; +import mineplex.minecraft.game.core.boss.broodmother.SpiderCreature; import org.bukkit.Effect; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.entity.Player; - -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilMath; -import mineplex.minecraft.game.core.boss.BossAbility; -import mineplex.minecraft.game.core.boss.EventCreature; -import mineplex.minecraft.game.core.boss.spider.SpiderCreature; +import org.bukkit.entity.Spider; /** * A attack where webs appear all around the spider in a kinda maze formation, making it hard to approach it. */ -public class SpiderWebStomp extends BossAbility +public class SpiderWebStomp extends BossAbility { private int _tick; @@ -81,6 +81,7 @@ public class SpiderWebStomp extends BossAbility block.setType(Material.WEB); block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.WEB); + getBoss().Webs.add(block); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/BattleBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/BattleBoss.java index ac364d49c..6567784a5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/BattleBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/BattleBoss.java @@ -1,9 +1,9 @@ package nautilus.game.arcade.game.games.bossbattles; +import mineplex.minecraft.game.core.boss.broodmother.SpiderBoss; import mineplex.minecraft.game.core.boss.ironwizard.GolemBoss; import mineplex.minecraft.game.core.boss.slimeking.SlimeBoss; import mineplex.minecraft.game.core.boss.snake.SnakeBoss; -import mineplex.minecraft.game.core.boss.spider.SpiderBoss; import nautilus.game.arcade.game.games.bossbattles.displays.*; import org.bukkit.Material; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/BossBattles.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/BossBattles.java index 0ecfe91f4..5511d0842 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/BossBattles.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/BossBattles.java @@ -22,8 +22,8 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.boss.EventState; import mineplex.minecraft.game.core.boss.WorldEvent; +import mineplex.minecraft.game.core.boss.broodmother.SpiderBoss; import mineplex.minecraft.game.core.boss.slimeking.SlimeBoss; -import mineplex.minecraft.game.core.boss.spider.SpiderBoss; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; From 98e88d1b77dea52b799d1cc30b9d07186de9360f Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 16 Jul 2016 22:00:38 -0400 Subject: [PATCH 28/90] Disable bosses not scheduled for initial releases --- .../game/clans/clans/worldevent/WorldEventType.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java index 9f402551f..75b0b5b6c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java @@ -2,24 +2,20 @@ package mineplex.game.clans.clans.worldevent; import java.lang.reflect.Constructor; -import mineplex.game.clans.clans.worldevent.kinghill.KingHill; -import mineplex.game.clans.clans.worldevent.undead.UndeadCamp; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; import mineplex.minecraft.game.core.boss.WorldEvent; -import mineplex.minecraft.game.core.boss.broodmother.SpiderBoss; import mineplex.minecraft.game.core.boss.ironwizard.GolemBoss; import mineplex.minecraft.game.core.boss.skeletonking.SkeletonBoss; -import mineplex.minecraft.game.core.boss.slimeking.SlimeBoss; import org.bukkit.Location; public enum WorldEventType { - SLIME_KING("Slime King", SlimeBoss.class, 30), - KING_OF_THE_HILL("King of The Hill", KingHill.class, 30), - UNDEAD_CAMP("Undead Camp", UndeadCamp.class, 30), + //SLIME_KING("Slime King", SlimeBoss.class, 30), + //KING_OF_THE_HILL("King of The Hill", KingHill.class, 30), + //UNDEAD_CAMP("Undead Camp", UndeadCamp.class, 30), IRON_WIZARD("Iron Wizard",GolemBoss.class, 30), - BROOD_MOTHER("Brood Mother", SpiderBoss.class, 30), + //BROOD_MOTHER("Brood Mother", SpiderBoss.class, 30), SKELETON_KING("Skeleton King", SkeletonBoss.class, 30); private String _name; From 4238a1c38522398b39a0a39f4d64564a5f28db03 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sun, 17 Jul 2016 07:14:08 -0400 Subject: [PATCH 29/90] Implement rune system and main nether minibosses --- .../clans/nether/miniboss/NetherMiniBoss.java | 11 +- .../nether/miniboss/NetherMinibossType.java | 5 + .../nether/miniboss/ghast/GhastMiniboss.java | 56 ++++ .../nether/miniboss/ghast/PigmanMiniboss.java | 35 ++ .../game/clans/items/GearManager.java | 53 +-- .../clans/items/commands/RuneCommand.java | 51 +++ .../game/clans/items/runes/RuneManager.java | 301 ++++++++++++++++++ 7 files changed, 484 insertions(+), 28 deletions(-) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/ghast/GhastMiniboss.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/ghast/PigmanMiniboss.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/commands/RuneCommand.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/runes/RuneManager.java diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMiniBoss.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMiniBoss.java index 92fa2bb5f..c698d0546 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMiniBoss.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMiniBoss.java @@ -44,11 +44,16 @@ public abstract class NetherMiniBoss implements Listen Bukkit.getPluginManager().registerEvents(this, ClansManager.getInstance().getPlugin()); } - public abstract void customSpawn(); + public Mob getEntity() + { + return _entity; + } - public abstract void customDeath(); + public void customSpawn() {}; - public abstract void customDespawn(); + public void customDeath() {}; + + public void customDespawn() {}; public void update() {}; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossType.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossType.java index bcb82999e..c158596a4 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossType.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossType.java @@ -1,10 +1,15 @@ package mineplex.game.clans.clans.nether.miniboss; +import mineplex.game.clans.clans.nether.miniboss.ghast.GhastMiniboss; +import mineplex.game.clans.clans.nether.miniboss.ghast.PigmanMiniboss; + import org.bukkit.Location; import org.bukkit.entity.EntityType; public enum NetherMinibossType { + GHAST("Ghast", 25D, EntityType.GHAST, GhastMiniboss.class), + PIGMAN("Zombie Pigman", 30D, EntityType.PIG_ZOMBIE, PigmanMiniboss.class) ; private Class _code; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/ghast/GhastMiniboss.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/ghast/GhastMiniboss.java new file mode 100644 index 000000000..e510f752f --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/ghast/GhastMiniboss.java @@ -0,0 +1,56 @@ +package mineplex.game.clans.clans.nether.miniboss.ghast; + +import mineplex.core.common.util.UtilTime; +import mineplex.game.clans.clans.nether.miniboss.NetherMiniBoss; + +import org.bukkit.Location; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Ghast; +import org.bukkit.entity.SmallFireball; + +public class GhastMiniboss extends NetherMiniBoss +{ + private static final long MAIN_FIREBALL_COOLDOWN = 15000; + private static final long FIREBALL_LAUNCH_RATE = 500; + private static final int FIREBALLS_PER_USE = 5; + private long _lastFireballUse; + private int _fireballsRemaining; + + public GhastMiniboss(String displayName, Double maxHealth, Location spawn, EntityType type) + { + super(displayName, maxHealth, spawn, type); + } + + private void tryFireballVolley() + { + if (_fireballsRemaining > 0) + { + if (UtilTime.elapsed(_lastFireballUse, FIREBALL_LAUNCH_RATE)) + { + _fireballsRemaining--; + _lastFireballUse = System.currentTimeMillis(); + getEntity().launchProjectile(SmallFireball.class); + } + } + else + { + if (UtilTime.elapsed(_lastFireballUse, MAIN_FIREBALL_COOLDOWN)) + { + _fireballsRemaining = FIREBALLS_PER_USE; + } + } + } + + @Override + public void customSpawn() + { + _lastFireballUse = System.currentTimeMillis(); + _fireballsRemaining = 0; + } + + @Override + public void update() + { + tryFireballVolley(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/ghast/PigmanMiniboss.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/ghast/PigmanMiniboss.java new file mode 100644 index 000000000..ed073f23e --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/ghast/PigmanMiniboss.java @@ -0,0 +1,35 @@ +package mineplex.game.clans.clans.nether.miniboss.ghast; + +import java.util.Random; + +import mineplex.game.clans.clans.nether.miniboss.NetherMiniBoss; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.PigZombie; +import org.bukkit.event.EventHandler; + +public class PigmanMiniboss extends NetherMiniBoss +{ + private static final double IRON_SKIN_CHANCE = .33; + + public PigmanMiniboss(String displayName, Double maxHealth, Location spawn, EntityType type) + { + super(displayName, maxHealth, spawn, type); + } + + @EventHandler + public void onDamage(CustomDamageEvent event) + { + if (event.GetDamageeEntity() != null && event.GetDamageeEntity().equals(getEntity())) + { + if (new Random().nextDouble() <= IRON_SKIN_CHANCE) + { + event.SetCancelled("Iron Skin Deflection"); + event.GetDamageeEntity().getWorld().playSound(event.GetDamageeEntity().getLocation(), Sound.ZOMBIE_METAL, 0.5f, 1.6f); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java index 170d99155..d3110e2e4 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java @@ -1,8 +1,6 @@ package mineplex.game.clans.items; -import java.lang.reflect.Field; import java.util.ArrayList; -import java.util.Collection; import java.util.Collections; import java.util.EnumSet; import java.util.HashMap; @@ -12,29 +10,6 @@ import java.util.Map; import java.util.Set; import java.util.UUID; -import com.google.gson.JsonSyntaxException; - -import mineplex.core.account.CoreClient; -import mineplex.core.common.Rank; -import mineplex.game.clans.clans.ClansManager; -import net.minecraft.server.v1_8_R3.NBTBase; -import net.minecraft.server.v1_8_R3.NBTTagByte; -import net.minecraft.server.v1_8_R3.NBTTagString; - -import org.bukkit.Bukkit; -import org.bukkit.GameMode; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.OfflinePlayer; -import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.plugin.java.JavaPlugin; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; - import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.common.util.C; @@ -68,6 +43,7 @@ import mineplex.game.clans.items.attributes.weapon.HasteAttribute; import mineplex.game.clans.items.attributes.weapon.JaggedAttribute; import mineplex.game.clans.items.attributes.weapon.SharpAttribute; import mineplex.game.clans.items.commands.GearCommand; +import mineplex.game.clans.items.commands.RuneCommand; import mineplex.game.clans.items.economy.GoldToken; import mineplex.game.clans.items.legendaries.AlligatorsTooth; import mineplex.game.clans.items.legendaries.GiantsBroadsword; @@ -78,14 +54,33 @@ import mineplex.game.clans.items.legendaries.MeridianScepter; import mineplex.game.clans.items.legendaries.WindBlade; import mineplex.game.clans.items.rares.RareItem; import mineplex.game.clans.items.rares.RunedPickaxe; +import mineplex.game.clans.items.runes.RuneManager; import mineplex.game.clans.items.smelting.SmeltingListener; import mineplex.game.clans.items.ui.GearShop; import mineplex.serverdata.serialization.RuntimeTypeAdapterFactory; +import net.minecraft.server.v1_8_R3.NBTBase; +import net.minecraft.server.v1_8_R3.NBTTagByte; import net.minecraft.server.v1_8_R3.NBTTagCompound; +import net.minecraft.server.v1_8_R3.NBTTagString; import net.minecraft.server.v1_8_R3.Packet; import net.minecraft.server.v1_8_R3.PacketPlayOutSetSlot; import net.minecraft.server.v1_8_R3.PacketPlayOutWindowItems; +import org.bukkit.Bukkit; +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.OfflinePlayer; +import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.plugin.java.JavaPlugin; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonSyntaxException; + /** * Handles converting legendary itemstacks to their respective CustomItem objects */ @@ -218,6 +213,7 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable private Map _playerGears = new HashMap<>(); private GearShop _shop; + private RuneManager _rune; public GearManager(JavaPlugin plugin, PacketHandler packetHandler, CoreClientManager clientManager, DonationManager donationManager) { @@ -231,6 +227,7 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable _instance = this; _shop = new GearShop(this, clientManager, donationManager); + _rune = new RuneManager("Rune"); // Register listeners UtilServer.getServer().getPluginManager().registerEvents(new ItemListener(getPlugin()), getPlugin()); @@ -245,6 +242,12 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable public void addCommands() { addCommand(new GearCommand(this)); + addCommand(new RuneCommand(this)); + } + + public RuneManager getRuneManager() + { + return _rune; } /** diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/commands/RuneCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/commands/RuneCommand.java new file mode 100644 index 000000000..f51bf58af --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/commands/RuneCommand.java @@ -0,0 +1,51 @@ +package mineplex.game.clans.items.commands; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilPlayer; +import mineplex.game.clans.items.GearManager; +import mineplex.game.clans.items.runes.RuneManager; +import mineplex.game.clans.items.runes.RuneManager.RuneAttribute; + +import org.bukkit.entity.Player; + +public class RuneCommand extends CommandBase +{ + private RuneManager _rune; + + public RuneCommand(GearManager plugin) + { + super(plugin, Rank.ADMIN, "rune", "giverune", "getrune"); + _rune = Plugin.getRuneManager(); + } + + @Override + public void Execute(Player caller, String[] args) + { + if (args.length < 1) + { + UtilPlayer.message(caller, F.main("Rune", "Usage: /" + _aliasUsed + " ")); + UtilPlayer.message(caller, F.main(Plugin.getName(), "Available types:")); + for (RuneAttribute rune : RuneAttribute.values()) + { + UtilPlayer.message(caller, C.cBlue + "- " + C.cGray + rune.toString()); + } + return; + } + RuneAttribute rune = RuneAttribute.valueOf(args[0].toUpperCase()); + if (rune == null) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "Invalid rune type! Available types:")); + for (RuneAttribute type : RuneAttribute.values()) + { + UtilPlayer.message(caller, C.cBlue + "- " + C.cGray + type.toString()); + } + return; + } + UtilInv.insert(caller, _rune.getRune(rune)); + UtilPlayer.message(caller, F.main("Rune", "You have been given a(n) " + F.elem(rune.getDisplay()) + " rune!")); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/runes/RuneManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/runes/RuneManager.java new file mode 100644 index 000000000..be46a6b5d --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/runes/RuneManager.java @@ -0,0 +1,301 @@ +package mineplex.game.clans.items.runes; + +import java.util.Arrays; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilItem; +import mineplex.core.common.util.UtilPlayer; +import mineplex.game.clans.items.CustomItem; +import mineplex.game.clans.items.GearManager; +import mineplex.game.clans.items.attributes.ItemAttribute; +import mineplex.game.clans.items.attributes.armor.ConqueringArmorAttribute; +import mineplex.game.clans.items.attributes.armor.LavaAttribute; +import mineplex.game.clans.items.attributes.armor.PaddedAttribute; +import mineplex.game.clans.items.attributes.armor.ReinforcedAttribute; +import mineplex.game.clans.items.attributes.armor.SlantedAttribute; +import mineplex.game.clans.items.attributes.bow.HeavyArrowsAttribute; +import mineplex.game.clans.items.attributes.bow.HuntingAttribute; +import mineplex.game.clans.items.attributes.bow.InverseAttribute; +import mineplex.game.clans.items.attributes.bow.LeechingAttribute; +import mineplex.game.clans.items.attributes.bow.RecursiveAttribute; +import mineplex.game.clans.items.attributes.bow.ScorchingAttribute; +import mineplex.game.clans.items.attributes.bow.SlayingAttribute; +import mineplex.game.clans.items.attributes.weapon.ConqueringAttribute; +import mineplex.game.clans.items.attributes.weapon.FlamingAttribute; +import mineplex.game.clans.items.attributes.weapon.FrostedAttribute; +import mineplex.game.clans.items.attributes.weapon.HasteAttribute; +import mineplex.game.clans.items.attributes.weapon.JaggedAttribute; +import mineplex.game.clans.items.attributes.weapon.SharpAttribute; + +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.Listener; +import org.bukkit.event.inventory.CraftItemEvent; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryType; +import org.bukkit.event.inventory.PrepareItemCraftEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +public class RuneManager implements Listener +{ + private static final String RUNE_NAME = C.cGold + "Ancient Rune"; + private String _managerName; + + public RuneManager(String name) + { + _managerName = name; + } + + public boolean isRune(ItemStack item) + { + if (item == null || item.getType() == Material.AIR) + { + return false; + } + ItemMeta im = item.getItemMeta(); + return im.hasDisplayName() && im.getDisplayName().equals(RUNE_NAME) && im.hasLore() && im.getLore().size() > 0; + } + + public RuneAttribute decodeRune(ItemStack rune) + { + if (!isRune(rune)) + { + return null; + } + RuneAttribute attribute = RuneAttribute.getFromDisplay(rune.getItemMeta().getLore().get(0)); + + return attribute; + } + + public ItemStack getRune(RuneAttribute attribute) + { + ItemStack rune = new ItemStack(Material.NETHER_STAR); + ItemMeta im = rune.getItemMeta(); + + im.setDisplayName(RUNE_NAME); + im.setLore(Arrays.asList(attribute.getDisplay())); + rune.setItemMeta(im); + + return rune; + } + + public ItemStack applyToItem(RuneAttribute rune, ItemStack to) + { + if (!rune.canApplyTo(to.getType())) + { + return to; + } + if (GearManager.isCustomItem(to)) + { + try + { + ItemAttribute attribute = rune.getAttributeClass().newInstance(); + CustomItem item = GearManager.parseItem(to); + item.getAttributes().addAttribute(attribute); + return item.toItemStack(); + } + catch (Exception e) + { + e.printStackTrace(); + return to; + } + } + else + { + try + { + CustomItem item = new CustomItem(to.getType()); + item.addDullEnchantment(); + ItemAttribute attribute = rune.getAttributeClass().newInstance(); + item.getAttributes().addAttribute(attribute); + return item.toItemStack(); + } + catch (Exception e) + { + e.printStackTrace(); + return to; + } + } + } + + @EventHandler(priority=EventPriority.HIGHEST) + public void onMakeBeaconWithRune(PrepareItemCraftEvent event) + { + if (event.getInventory().getResult() == null || !event.getInventory().getResult().getType().equals(Material.BEACON)) + { + return; + } + if (!isRune(event.getInventory().getItem(5))) + { + return; + } + event.getInventory().setResult(null); + } + + @EventHandler(priority=EventPriority.HIGHEST) + public void onCraftBeaconWithRune(CraftItemEvent event) + { + if (event.getInventory().getResult() == null || event.getInventory().getResult().getType() != Material.BEACON) + { + return; + } + if (!isRune(event.getInventory().getItem(5))) + { + return; + } + event.setCancelled(true); + } + + @EventHandler(priority=EventPriority.HIGHEST) + public void onPlaceRuneInAnvil(InventoryClickEvent event) + { + if (!(event.getWhoClicked() instanceof Player)) + { + return; + } + if (!event.getInventory().getType().equals(InventoryType.ANVIL)) + { + return; + } + if (!isRune(event.getCursor()) && !isRune(event.getCurrentItem())) + { + return; + } + event.setCancelled(true); + if (event.getInventory().getItem(0) == null && event.getInventory().getItem(1) == null) + { + event.getWhoClicked().closeInventory(); + } + UtilPlayer.message(event.getWhoClicked(), F.main(_managerName, "To use a rune, place it on an item!")); + } + + @SuppressWarnings("deprecation") + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onUseRune(InventoryClickEvent event) + { + if(!(event.getWhoClicked() instanceof Player)) + { + return; + } + + Player player = (Player) event.getWhoClicked(); + + if (!isRune(event.getCursor())) + { + return; + } + if (event.getCurrentItem() == null || event.getCurrentItem().getType() == Material.AIR) + { + return; + } + + RuneAttribute rune = decodeRune(event.getCursor()); + if (!rune.canApplyTo(event.getCurrentItem().getType())) + { + UtilPlayer.message(player, F.main(_managerName, "That rune seems to reject that type of item!")); + return; + } + event.setCancelled(true); + event.setCursor(new ItemStack(Material.AIR)); + ItemStack after = applyToItem(rune, event.getCurrentItem()); + event.getInventory().setItem(event.getSlot(), after); + player.playSound(player.getLocation(), Sound.ANVIL_USE, 1.5f, 5f); + + player.updateInventory(); + } + + public static enum RuneAttribute + { + FROSTED(FrostedAttribute.class, "Frosted", true, false, false), + SHARP(SharpAttribute.class, "Sharp", true, false, false), + JAGGED(JaggedAttribute.class, "Jagged", true, false, false), + HASTE(HasteAttribute.class, "Haste", true, false, false), + FLAMING(FlamingAttribute.class, "Flaming", true, false, false), + CONQUERING(ConqueringAttribute.class, "Conquering", true, false, false), + SLANTED(SlantedAttribute.class, "Slanted", false, true, false), + REINFORCED(ReinforcedAttribute.class, "Reinforced", false, true, false), + CONQUERING_ARMOR(ConqueringArmorAttribute.class, "Conquering", false, true, false), + PADDED(PaddedAttribute.class, "Padded", false, true, false), + LAVA(LavaAttribute.class, "Lava Forged", false, true, false), + HEAVY(HeavyArrowsAttribute.class, "Heavy", false, false, true), + HUNTING(HuntingAttribute.class, "Hunting", false, false, true), + INVERSE(InverseAttribute.class, "Inverse", false, false, true), + LEECHING(LeechingAttribute.class, "Leeching", false, false, true), + RECURSIVE(RecursiveAttribute.class, "Recursive", false, false, true), + SCORCHING(ScorchingAttribute.class, "Scorching", false, false, true), + SLAYING(SlayingAttribute.class, "Slaying", false, false, true) + ; + + private Class _class; + private String _display; + private boolean _weapon, _armor, _bow; + + private RuneAttribute(Class attributeClass, String display, boolean weapon, boolean armor, boolean bow) + { + _class = attributeClass; + _display = display; + _weapon = weapon; + _armor = armor; + _bow = bow; + + if (weapon) + { + _display = C.cRed + C.Italics + _display; + } + if (armor) + { + _display = C.cGreen + C.Italics + _display; + } + if (bow) + { + _display = C.cDAqua + C.Italics + _display; + } + } + + public String getDisplay() + { + return _display; + } + + public Class getAttributeClass() + { + return _class; + } + + public boolean canApplyTo(Material type) + { + if (_weapon && (UtilItem.isSword(type) || UtilItem.isAxe(type))) + { + return true; + } + if (_armor && UtilItem.isArmor(type)) + { + return true; + } + if (_bow && type == Material.BOW) + { + return true; + } + + return false; + } + + public static RuneAttribute getFromDisplay(String display) + { + for (RuneAttribute rune : RuneAttribute.values()) + { + if (rune.getDisplay().equals(display)) + { + return rune; + } + } + + return null; + } + } +} \ No newline at end of file From c58d2266808988cb4aaa059c83f980183b99d29f Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 18 Jul 2016 16:26:05 -0400 Subject: [PATCH 30/90] More work on Nether and Runes --- .../game/clans/clans/ClansManager.java | 2 +- .../clans/clans/nether/NetherManager.java | 57 +++++++++++++--- .../game/clans/clans/nether/NetherPortal.java | 56 +++++++++++----- .../clans/nether/command/CloseCommand.java | 24 +++++++ .../clans/nether/command/DeleteCommand.java | 2 +- .../clans/nether/command/PortalCommand.java | 4 +- .../mineplex/game/clans/items/CustomItem.java | 14 ++++ .../game/clans/items/GearManager.java | 2 +- .../clans/items/commands/RuneCommand.java | 8 ++- .../game/clans/items/runes/RuneManager.java | 66 +++++++++++++++---- 10 files changed, 192 insertions(+), 43 deletions(-) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/CloseCommand.java diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index 08157bd5d..8f53fec8d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -422,7 +422,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati _siegeManager = new SiegeManager(this); -// _netherManager = new NetherManager(this); + _netherManager = new NetherManager(this); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java index 260a94132..52a8b9356 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java @@ -37,6 +37,7 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.WorldBorder; +import org.bukkit.WorldCreator; import org.bukkit.block.Block; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.YamlConfiguration; @@ -58,7 +59,7 @@ import com.google.common.collect.Lists; public class NetherManager extends MiniPlugin { - private static final long PORTAL_OPEN_DURATION = UtilTime.convert(30, TimeUnit.MINUTES, TimeUnit.SECONDS) * 20; + private static final long PORTAL_OPEN_DURATION = UtilTime.convert(30, TimeUnit.MINUTES, TimeUnit.MILLISECONDS); private static final long NETHER_SLOW_WARMUP = UtilTime.convert(17, TimeUnit.MINUTES, TimeUnit.MILLISECONDS); private static final long NETHER_BLIND_WARMUP = UtilTime.convert(18, TimeUnit.MINUTES, TimeUnit.MILLISECONDS); private static final long NETHER_ALLOWED_DURATION = UtilTime.convert(20, TimeUnit.MINUTES, TimeUnit.MILLISECONDS); @@ -97,7 +98,11 @@ public class NetherManager extends MiniPlugin private void begin() { - _netherWorld = Bukkit.getWorld("world_nether"); + if (Bukkit.getWorld("nether") == null) + { + Bukkit.createWorld(new WorldCreator("nether")); + } + _netherWorld = Bukkit.getWorld("nether"); WorldBorder worldBorder = _netherWorld.getWorldBorder(); worldBorder.setCenter(0, 0); @@ -138,6 +143,25 @@ public class NetherManager extends MiniPlugin } } + @Override + public void disable() + { + closePortals(); + try + { + savePortals(); + } + catch (IOException e) + { + e.printStackTrace(); + } + for (Player player : InNether.keySet()) + { + player.teleport(Spawn.getNorthSpawn()); + } + InNether.clear(); + } + public void savePortals() throws IOException { _portalConfig.set("PortalCount", Portals.size()); @@ -146,8 +170,8 @@ public class NetherManager extends MiniPlugin for (int i = 0; i < Portals.size(); i++) { int id = i + 1; - _portalConfig.set("Portals." + id + ".CornerOne", Portals.get(0).getCorners()[0]); - _portalConfig.set("Portals." + id + ".CornerTwo", Portals.get(0).getCorners()[1]); + _portalConfig.set("Portals." + id + ".CornerOne", UtilWorld.locToStr(Portals.get(i).getCorners()[0])); + _portalConfig.set("Portals." + id + ".CornerTwo", UtilWorld.locToStr(Portals.get(i).getCorners()[1])); } _portalConfig.save(_portalCfg); @@ -206,7 +230,7 @@ public class NetherManager extends MiniPlugin @EventHandler(priority = EventPriority.HIGHEST) public void onPortal(PlayerPortalEvent event) { - if (event.getTo().getWorld().equals(_netherWorld)) + if (event.getTo() == null || event.getTo().getWorld().equals(_netherWorld)) { return; } @@ -344,6 +368,7 @@ public class NetherManager extends MiniPlugin data.setFirstCorner(block); UtilPlayer.message(event.getPlayer(), F.main(getName(), "You have selected the Portal's first corner!")); } + event.setCancelled(true); } } @@ -352,8 +377,7 @@ public class NetherManager extends MiniPlugin { if (event.getCreature() instanceof GolemCreature || event.getCreature() instanceof SkeletonCreature || event.getCreature() instanceof SpiderCreature) { - //spawnPortal(); - Bukkit.broadcastMessage("A PORTAL SPAWN WOULD BE CALLED HERE IF IT WASN'T DISABLED"); + spawnPortal(); } } @@ -367,7 +391,7 @@ public class NetherManager extends MiniPlugin return player.getWorld().equals(_netherWorld); } - public void spawnPortal() + public void spawnPortal(long duration) { if (Portals.isEmpty()) { @@ -376,11 +400,16 @@ public class NetherManager extends MiniPlugin NetherPortal portal = Portals.get(UtilMath.r(Portals.size())); portal.open(); UtilTextMiddle.display(F.clansNether("Nether Portal"), "Has opened at " + F.elem(UtilWorld.locToStrClean(portal.getLocation()))); - Bukkit.broadcastMessage(F.main(getName(), "A " + F.clansNether("Nether Portal") + " has opened at " + F.elem(UtilWorld.locToStrClean(portal.getLocation())))); + Bukkit.broadcastMessage(F.main(getName(), "A " + F.clansNether("Nether Portal") + " has opened at " + F.elem(UtilWorld.locToStrClean(portal.getLocation())) + " for " + F.elem(UtilTime.MakeStr(duration)) + "!")); runSyncLater(() -> { portal.close(); - }, PORTAL_OPEN_DURATION); + }, (duration / 1000) * 20); + } + + public void spawnPortal() + { + spawnPortal(PORTAL_OPEN_DURATION); } public void createPortal(Player creator) @@ -406,6 +435,14 @@ public class NetherManager extends MiniPlugin } } + public void closePortals() + { + for (NetherPortal portal : Portals) + { + portal.close(); + } + } + public void showPortalList(Player player) { UtilPlayer.message(player, F.main(getName(), "Portal List:")); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java index 2c485ba79..d6d9b0aa5 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java @@ -6,6 +6,7 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.game.clans.clans.ClanTips.TipType; import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.spawn.Spawn; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -17,6 +18,7 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockPhysicsEvent; import org.bukkit.event.entity.EntityPortalEnterEvent; import org.bukkit.event.entity.EntityPortalEvent; import org.bukkit.event.player.PlayerPortalEvent; @@ -25,19 +27,21 @@ import com.google.common.collect.Lists; public class NetherPortal implements Listener { + private static final int SECONDS_UNTIL_PORTAL = 5; private List _frame = Lists.newArrayList(); private List _portal = Lists.newArrayList(); private Location _loc; private Location[] _corners; + private boolean _returnPortal; - public NetherPortal(Location firstCorner, Location secondCorner) + public NetherPortal(Location firstCorner, Location secondCorner, boolean returnPortal) { int maxX = Math.max(firstCorner.getBlockX(), secondCorner.getBlockX()); int minX = Math.min(firstCorner.getBlockX(), secondCorner.getBlockX()); - int maxY = Math.max(firstCorner.getBlockX(), secondCorner.getBlockX()); - int minY = Math.min(firstCorner.getBlockX(), secondCorner.getBlockX()); - int maxZ = Math.max(firstCorner.getBlockX(), secondCorner.getBlockX()); - int minZ = Math.min(firstCorner.getBlockX(), secondCorner.getBlockX()); + int maxY = Math.max(firstCorner.getBlockY(), secondCorner.getBlockY()); + int minY = Math.min(firstCorner.getBlockY(), secondCorner.getBlockY()); + int maxZ = Math.max(firstCorner.getBlockZ(), secondCorner.getBlockZ()); + int minZ = Math.min(firstCorner.getBlockZ(), secondCorner.getBlockZ()); for (int x = minX; x <= maxX; x++) { @@ -73,6 +77,7 @@ public class NetherPortal implements Listener _loc = new Location(firstCorner.getWorld(), minX + ((maxX - minX) / 2), maxY, minZ + ((maxZ - minZ) / 2)); _corners = new Location[] {firstCorner, secondCorner}; + _returnPortal = returnPortal; } private boolean isInPortal(Block block) @@ -90,8 +95,14 @@ public class NetherPortal implements Listener return _corners; } + public boolean isReturnPortal() + { + return _returnPortal; + } + public void open() { + Bukkit.getPluginManager().registerEvents(this, ClansManager.getInstance().getPlugin()); for (Block block : _frame) { block.setType(Material.OBSIDIAN); @@ -99,24 +110,20 @@ public class NetherPortal implements Listener for (Block block : _portal) { block.setType(Material.PORTAL); + Bukkit.broadcastMessage("Creating Portal Piece"); } - Bukkit.getPluginManager().registerEvents(this, ClansManager.getInstance().getPlugin()); } public void close() { HandlerList.unregisterAll(this); - for (Block block : _frame) - { - block.setType(Material.AIR); - } for (Block block : _portal) { block.setType(Material.AIR); } } - @EventHandler + @EventHandler(priority = EventPriority.HIGHEST) public void onBreak(BlockBreakEvent event) { if (isInPortal(event.getBlock())) @@ -155,12 +162,31 @@ public class NetherPortal implements Listener { if (isInPortal(event.getEntity().getLocation().getBlock())) { - ClansManager.getInstance().getNetherManager().InNether.put((Player)event.getEntity(), System.currentTimeMillis()); - event.getEntity().teleport(event.getLocation()); //MAKE NETHER SPAWN - ClansManager.getInstance().ClanTips.displayTip(TipType.ENTER_NETHER, (Player)event.getEntity()); + if (isReturnPortal()) + { + ClansManager.getInstance().getNetherManager().InNether.remove((Player)event.getEntity()); + ClansManager.getInstance().getCondition().Clean((Player)event.getEntity()); + event.getEntity().teleport(Spawn.getNorthSpawn()); + UtilPlayer.message(event.getEntity(), F.main(ClansManager.getInstance().getNetherManager().getName(), "You have escaped " + F.clansNether("The Nether") + "!")); + } + else + { + ClansManager.getInstance().getNetherManager().InNether.put((Player)event.getEntity(), System.currentTimeMillis()); + event.getEntity().teleport(ClansManager.getInstance().getNetherManager().getNetherWorld().getSpawnLocation()); + ClansManager.getInstance().ClanTips.displayTip(TipType.ENTER_NETHER, (Player)event.getEntity()); + } } - }, 5 * 20); + }, SECONDS_UNTIL_PORTAL * 20); } } } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onBlockPhysics(BlockPhysicsEvent event) + { + if (isInPortal(event.getBlock())) + { + event.setCancelled(true); + } + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/CloseCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/CloseCommand.java new file mode 100644 index 000000000..cfc778e90 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/CloseCommand.java @@ -0,0 +1,24 @@ +package mineplex.game.clans.clans.nether.command; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.game.clans.clans.nether.NetherManager; + +public class CloseCommand extends CommandBase +{ + public CloseCommand(NetherManager plugin) + { + super(plugin, Rank.ADMIN, "close"); + } + + @Override + public void Execute(Player caller, String[] args) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "Closing all " + F.clansNether("Nether Portals" + "!"))); + Plugin.closePortals(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/DeleteCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/DeleteCommand.java index 1a8b70d81..ed5f70ac0 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/DeleteCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/DeleteCommand.java @@ -24,7 +24,7 @@ public class DeleteCommand extends CommandBase id = Integer.parseInt(args[0]); } catch (Exception e) {} - if (id == null || id >= Plugin.Portals.size() || id < 1) + if (id == null || id > Plugin.Portals.size() || id < 1) { UtilPlayer.message(caller, F.main(Plugin.getName(), "Usage: " + F.elem("/portal " + _aliasUsed + " "))); return; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/PortalCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/PortalCommand.java index e146a980d..b0c0f1551 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/PortalCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/PortalCommand.java @@ -17,6 +17,7 @@ public class PortalCommand extends MultiCommandBase AddCommand(new DeleteCommand(plugin)); AddCommand(new ListCommand(plugin)); AddCommand(new SpawnCommand(plugin)); + AddCommand(new CloseCommand(plugin)); AddCommand(new WandCommand(plugin)); } @@ -24,7 +25,8 @@ public class PortalCommand extends MultiCommandBase protected void Help(Player caller, String[] args) { UtilPlayer.message(caller, F.help("/" + _aliasUsed + " spawn", "Forces a Nether Portal to spawn", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/" + _aliasUsed + " lists", "Lists all loaded Nether Portals", Rank.ADMIN)); + UtilPlayer.message(caller, F.help("/" + _aliasUsed + " close", "Closes all Nether Portals", Rank.ADMIN)); + UtilPlayer.message(caller, F.help("/" + _aliasUsed + " list", "Lists all loaded Nether Portals", Rank.ADMIN)); UtilPlayer.message(caller, F.help("/" + _aliasUsed + " wand", "Gives you a Nether Portal claim wand", Rank.ADMIN)); UtilPlayer.message(caller, F.help("/" + _aliasUsed + " create", "Creates a Nether Portal with the corners you have selected", Rank.ADMIN)); UtilPlayer.message(caller, F.help("/" + _aliasUsed + " delete", "Deletes a loaded Nether Portal", Rank.ADMIN)); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/CustomItem.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/CustomItem.java index 02a71b2c4..667bbdee1 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/CustomItem.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/CustomItem.java @@ -186,6 +186,11 @@ public class CustomItem implements Listener meta.setLore(lore); item.setItemMeta(meta); + + if (_dullEnchantment) + { + UtilInv.addDullEnchantment(item); + } GearManager.writeNBT(this, item); } @@ -213,4 +218,13 @@ public class CustomItem implements Listener { return _attributes; } + + public void setMaterial(Material material) + { + if (_material == null) + { + _displayName = prettifyName(material); + } + _material = material; + } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java index d3110e2e4..27b8900b0 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java @@ -227,7 +227,7 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable _instance = this; _shop = new GearShop(this, clientManager, donationManager); - _rune = new RuneManager("Rune"); + _rune = new RuneManager("Rune", plugin); // Register listeners UtilServer.getServer().getPluginManager().registerEvents(new ItemListener(getPlugin()), getPlugin()); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/commands/RuneCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/commands/RuneCommand.java index f51bf58af..6ae4cc5ed 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/commands/RuneCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/commands/RuneCommand.java @@ -19,12 +19,16 @@ public class RuneCommand extends CommandBase public RuneCommand(GearManager plugin) { super(plugin, Rank.ADMIN, "rune", "giverune", "getrune"); - _rune = Plugin.getRuneManager(); } @Override public void Execute(Player caller, String[] args) { + if (_rune == null) + { + _rune = Plugin.getRuneManager(); + } + if (args.length < 1) { UtilPlayer.message(caller, F.main("Rune", "Usage: /" + _aliasUsed + " ")); @@ -35,7 +39,7 @@ public class RuneCommand extends CommandBase } return; } - RuneAttribute rune = RuneAttribute.valueOf(args[0].toUpperCase()); + RuneAttribute rune = RuneAttribute.getFromString(args[0]); if (rune == null) { UtilPlayer.message(caller, F.main(Plugin.getName(), "Invalid rune type! Available types:")); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/runes/RuneManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/runes/RuneManager.java index be46a6b5d..d4c349ded 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/runes/RuneManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/runes/RuneManager.java @@ -28,6 +28,7 @@ import mineplex.game.clans.items.attributes.weapon.HasteAttribute; import mineplex.game.clans.items.attributes.weapon.JaggedAttribute; import mineplex.game.clans.items.attributes.weapon.SharpAttribute; +import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.Player; @@ -40,15 +41,17 @@ import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.inventory.PrepareItemCraftEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.plugin.java.JavaPlugin; public class RuneManager implements Listener { private static final String RUNE_NAME = C.cGold + "Ancient Rune"; private String _managerName; - public RuneManager(String name) + public RuneManager(String name, JavaPlugin plugin) { _managerName = name; + Bukkit.getPluginManager().registerEvents(this, plugin); } public boolean isRune(ItemStack item) @@ -88,7 +91,7 @@ public class RuneManager implements Listener { if (!rune.canApplyTo(to.getType())) { - return to; + return null; } if (GearManager.isCustomItem(to)) { @@ -96,13 +99,20 @@ public class RuneManager implements Listener { ItemAttribute attribute = rune.getAttributeClass().newInstance(); CustomItem item = GearManager.parseItem(to); + if (!item.getAttributes().getRemainingTypes().contains(attribute.getType())) + { + return null; + } item.getAttributes().addAttribute(attribute); - return item.toItemStack(); + ItemStack stack = to.clone(); + item.setMaterial(stack.getType()); + item.update(stack); + return stack; } catch (Exception e) { e.printStackTrace(); - return to; + return null; } } else @@ -113,12 +123,14 @@ public class RuneManager implements Listener item.addDullEnchantment(); ItemAttribute attribute = rune.getAttributeClass().newInstance(); item.getAttributes().addAttribute(attribute); - return item.toItemStack(); + ItemStack stack = to.clone(); + item.update(stack); + return stack; } catch (Exception e) { e.printStackTrace(); - return to; + return null; } } } @@ -195,15 +207,25 @@ public class RuneManager implements Listener } RuneAttribute rune = decodeRune(event.getCursor()); - if (!rune.canApplyTo(event.getCurrentItem().getType())) + if (rune == null) { - UtilPlayer.message(player, F.main(_managerName, "That rune seems to reject that type of item!")); return; } + if (!rune.canApplyTo(event.getCurrentItem().getType())) + { + UtilPlayer.message(player, F.main(_managerName, "The rune seems to reject that type of item!")); + return; + } + ItemStack after = applyToItem(rune, event.getCurrentItem()); + if (after == null) + { + UtilPlayer.message(player, F.main(_managerName, "The rune seems to reject that item!")); + return; + } + event.setCancelled(true); event.setCursor(new ItemStack(Material.AIR)); - ItemStack after = applyToItem(rune, event.getCurrentItem()); - event.getInventory().setItem(event.getSlot(), after); + event.getClickedInventory().setItem(event.getSlot(), after); player.playSound(player.getLocation(), Sound.ANVIL_USE, 1.5f, 5f); player.updateInventory(); @@ -269,9 +291,16 @@ public class RuneManager implements Listener public boolean canApplyTo(Material type) { - if (_weapon && (UtilItem.isSword(type) || UtilItem.isAxe(type))) + if (_weapon) { - return true; + if (UtilItem.isSword(type) || UtilItem.isAxe(type)) + { + return true; + } + if (type == Material.RECORD_4 || type == Material.GOLD_RECORD || type == Material.RECORD_3 || type == Material.RECORD_5 || type == Material.GREEN_RECORD) + { + return true; + } } if (_armor && UtilItem.isArmor(type)) { @@ -297,5 +326,18 @@ public class RuneManager implements Listener return null; } + + public static RuneAttribute getFromString(String string) + { + for (RuneAttribute rune : RuneAttribute.values()) + { + if (rune.toString().equalsIgnoreCase(string)) + { + return rune; + } + } + + return null; + } } } \ No newline at end of file From 29d52ac075025685695db70c503d366e8ad0fd41 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Wed, 20 Jul 2016 10:42:24 -0400 Subject: [PATCH 31/90] More work on Nether --- .../clans/clans/nether/NetherManager.java | 233 +++++++++--------- .../game/clans/clans/nether/NetherPortal.java | 27 +- .../clans/nether/command/CreateCommand.java | 17 +- .../clans/nether/command/DeleteCommand.java | 2 +- .../nether/miniboss/MinibossFireball.java | 71 ++++++ .../clans/nether/miniboss/NetherMiniBoss.java | 6 +- .../miniboss/NetherMinibossManager.java | 24 +- .../nether/miniboss/NetherMinibossType.java | 9 +- .../miniboss/bosses/ArcherMiniboss.java | 192 +++++++++++++++ .../nether/miniboss/bosses/GhastMiniboss.java | 91 +++++++ .../{ghast => bosses}/PigmanMiniboss.java | 2 +- .../miniboss/bosses/WarriorMiniboss.java | 133 ++++++++++ .../nether/miniboss/ghast/GhastMiniboss.java | 56 ----- 13 files changed, 677 insertions(+), 186 deletions(-) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/MinibossFireball.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/ArcherMiniboss.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/GhastMiniboss.java rename Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/{ghast => bosses}/PigmanMiniboss.java (94%) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/WarriorMiniboss.java delete mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/ghast/GhastMiniboss.java diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java index 52a8b9356..427b61e35 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java @@ -7,6 +7,7 @@ import java.util.List; import mineplex.core.MiniPlugin; import mineplex.core.common.Rank; +import mineplex.core.common.generator.VoidGenerator; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilItem; @@ -24,12 +25,12 @@ import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.event.ClansCommandExecutedEvent; import mineplex.game.clans.clans.nether.command.PortalCommand; import mineplex.game.clans.clans.nether.data.ClaimData; +import mineplex.game.clans.clans.nether.miniboss.NetherMinibossManager; import mineplex.game.clans.spawn.Spawn; import mineplex.minecraft.game.core.boss.EventCreatureDeathEvent; import mineplex.minecraft.game.core.boss.broodmother.SpiderCreature; import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature; import mineplex.minecraft.game.core.boss.skeletonking.SkeletonCreature; -import mineplex.minecraft.game.core.condition.Condition.ConditionType; import org.bukkit.Bukkit; import org.bukkit.GameMode; @@ -47,7 +48,6 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityPortalEvent; import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerInteractEvent; @@ -59,18 +59,19 @@ import com.google.common.collect.Lists; public class NetherManager extends MiniPlugin { - private static final long PORTAL_OPEN_DURATION = UtilTime.convert(30, TimeUnit.MINUTES, TimeUnit.MILLISECONDS); - private static final long NETHER_SLOW_WARMUP = UtilTime.convert(17, TimeUnit.MINUTES, TimeUnit.MILLISECONDS); - private static final long NETHER_BLIND_WARMUP = UtilTime.convert(18, TimeUnit.MINUTES, TimeUnit.MILLISECONDS); - private static final long NETHER_ALLOWED_DURATION = UtilTime.convert(20, TimeUnit.MINUTES, TimeUnit.MILLISECONDS); + private static final long PORTAL_OPEN_DURATION = UtilTime.convert(5, TimeUnit.MINUTES, TimeUnit.MILLISECONDS); + private static final long NETHER_ALLOWED_DURATION = UtilTime.convert(5, TimeUnit.MINUTES, TimeUnit.MILLISECONDS); private static final String CLAIM_WAND_NAME = C.cRedB + "Portal Claim Wand"; private static final String[] CLAIM_WAND_LORE = new String[] {C.cYellow + "Left Click to select the Portal's first corner", C.cYellow + "Right Click to select the Portal's second corner"}; private static final ItemStack CLAIM_WAND = new ItemBuilder(Material.WOOD_AXE).setTitle(CLAIM_WAND_NAME).setLore(CLAIM_WAND_LORE).build(); + private NetherMinibossManager _miniboss; private World _netherWorld; public List Portals = Lists.newArrayList(); + private List _returnPortals = Lists.newArrayList(); private File _portalCfg; private YamlConfiguration _portalConfig; public HashMap InNether = new HashMap<>(); + public HashMap OverworldOrigins = new HashMap<>(); public HashMap Claiming = new HashMap<>(); public NetherManager(ClansManager manager) @@ -93,6 +94,7 @@ public class NetherManager extends MiniPlugin } begin(); + _miniboss = new NetherMinibossManager(this); addCommand(new PortalCommand(this)); } @@ -100,7 +102,9 @@ public class NetherManager extends MiniPlugin { if (Bukkit.getWorld("nether") == null) { - Bukkit.createWorld(new WorldCreator("nether")); + WorldCreator creator = new WorldCreator("nether"); + creator.generator(new VoidGenerator()); + Bukkit.createWorld(creator); } _netherWorld = Bukkit.getWorld("nether"); @@ -129,12 +133,18 @@ public class NetherManager extends MiniPlugin log("Loading " + _portalConfig.getInt("PortalCount") + " Nether Portals!"); for (String portalSectionPath : _portalConfig.getConfigurationSection("Portals").getValues(false).keySet()) { + log("Loading Portal"); ConfigurationSection portal = _portalConfig.getConfigurationSection("Portals." + portalSectionPath); Location firstCorner = UtilWorld.strToLoc(portal.getString("CornerOne")); Location secondCorner = UtilWorld.strToLoc(portal.getString("CornerTwo")); + boolean returnPortal = portal.getBoolean("ReturnPortal"); - NetherPortal netherPortal = new NetherPortal(firstCorner, secondCorner); + NetherPortal netherPortal = new NetherPortal(firstCorner, secondCorner, returnPortal); Portals.add(netherPortal); + if (returnPortal) + { + _returnPortals.add(netherPortal); + } } } catch (Exception e) @@ -162,6 +172,97 @@ public class NetherManager extends MiniPlugin InNether.clear(); } + public NetherMinibossManager getMinibossManager() + { + return _miniboss; + } + + public World getNetherWorld() + { + return _netherWorld; + } + + public boolean isInNether(Player player) + { + return player.getWorld().equals(_netherWorld); + } + + public Location getReturnLocation(Player player) + { + return OverworldOrigins.getOrDefault(player, Spawn.getNorthSpawn()); + } + + public void spawnPortal(long duration) + { + if (Portals.isEmpty()) + { + return; + } + NetherPortal portal = Portals.get(UtilMath.r(Portals.size())); + portal.open(); + UtilTextMiddle.display(F.clansNether("Nether Portal"), "Has opened at " + F.elem(UtilWorld.locToStrClean(portal.getLocation()))); + Bukkit.broadcastMessage(F.main(getName(), "A " + F.clansNether("Nether Portal") + " has opened at " + F.elem(UtilWorld.locToStrClean(portal.getLocation())) + " for " + F.elem(UtilTime.MakeStr(duration)) + "!")); + runSyncLater(() -> + { + portal.close(); + }, (duration / 1000) * 20); + } + + public void spawnPortal() + { + spawnPortal(PORTAL_OPEN_DURATION); + } + + public void createPortal(Player creator, boolean returnPortal) + { + if (Claiming.getOrDefault(creator, new ClaimData()).getTotalSelected() < 2) + { + UtilPlayer.message(creator, F.main(getName(), "You do not have a top and bottom corner selected!")); + return; + } + + ClaimData data = Claiming.remove(creator); + NetherPortal portal = new NetherPortal(data.getFirstCorner().getLocation(), data.getSecondCorner().getLocation(), returnPortal); + Portals.add(portal); + + try + { + savePortals(); + UtilPlayer.message(creator, F.main(getName(), "Portal successfully created!")); + } + catch (Exception e) + { + UtilPlayer.message(creator, F.main(getName(), "An error occurred while creating that portal! Please report this immediately!")); + return; + } + } + + public void closePortals() + { + for (NetherPortal portal : Portals) + { + portal.close(); + } + } + + public void showPortalList(Player player) + { + UtilPlayer.message(player, F.main(getName(), "Portal List:")); + for (int i = 0; i < Portals.size(); i++) + { + int id = i + 1; + NetherPortal portal = Portals.get(i); + + UtilPlayer.message(player, C.cBlue + "- " + F.elem("Portal " + id + ": " + C.cGray + UtilWorld.locToStrClean(portal.getLocation()).replace("(", "").replace(")", ""))); + } + } + + public void giveWand(Player player) + { + player.getInventory().addItem(CLAIM_WAND.clone()); + UtilPlayer.message(player, F.main(getName(), "You have been given a Portal Claim Wand!")); + } + public void savePortals() throws IOException { _portalConfig.set("PortalCount", Portals.size()); @@ -169,9 +270,10 @@ public class NetherManager extends MiniPlugin _portalConfig.createSection("Portals"); for (int i = 0; i < Portals.size(); i++) { - int id = i + 1; - _portalConfig.set("Portals." + id + ".CornerOne", UtilWorld.locToStr(Portals.get(i).getCorners()[0])); - _portalConfig.set("Portals." + id + ".CornerTwo", UtilWorld.locToStr(Portals.get(i).getCorners()[1])); + Integer id = i + 1; + _portalConfig.set("Portals." + id.toString() + ".CornerOne", UtilWorld.locToStr(Portals.get(i).getCorners()[0])); + _portalConfig.set("Portals." + id.toString() + ".CornerTwo", UtilWorld.locToStr(Portals.get(i).getCorners()[1])); + _portalConfig.set("Portals." + id.toString() + ".ReturnPortal", Portals.get(i).isReturnPortal()); } _portalConfig.save(_portalCfg); @@ -238,8 +340,8 @@ public class NetherManager extends MiniPlugin runSyncLater(() -> { InNether.remove(event.getPlayer()); - ClansManager.getInstance().getCondition().Clean(event.getPlayer()); - event.getPlayer().teleport(Spawn.getNorthSpawn()); + event.getPlayer().teleport(getReturnLocation(event.getPlayer())); + OverworldOrigins.remove(event.getPlayer()); UtilPlayer.message(event.getPlayer(), F.main(getName(), "You have escaped " + F.clansNether("The Nether") + "!")); }, 1); } @@ -264,24 +366,9 @@ public class NetherManager extends MiniPlugin InNether.remove(player); if (isInNether(player)) { - ClansManager.getInstance().getCondition().Clean(player); - UtilPlayer.message(player, F.main(getName(), "You have failed to escape " + F.clansNether("The Nether") + " and have been destroyed by its demonic poisons!")); - ClansManager.getInstance().getDamageManager().NewDamageEvent(player, null, null, DamageCause.CUSTOM, 9999, false, true, true, C.cDRed + "The Nether", "Nether Poison"); - } - continue; - } - if (UtilTime.elapsed(InNether.get(player), NETHER_SLOW_WARMUP)) - { - if (!ClansManager.getInstance().getCondition().HasCondition(player, ConditionType.SLOW, "Nether Corruption")) - { - ClansManager.getInstance().getCondition().Factory().Slow("Nether Corruption", player, null, 9999, 1, false, true, false, false); - } - } - if (UtilTime.elapsed(InNether.get(player), NETHER_BLIND_WARMUP)) - { - if (!ClansManager.getInstance().getCondition().HasCondition(player, ConditionType.BLINDNESS, "Nether Corruption")) - { - ClansManager.getInstance().getCondition().Factory().Blind("Nether Corruption", player, null, 9999, 1, false, true, false); + player.teleport(getReturnLocation(player)); + OverworldOrigins.remove(player); + UtilPlayer.message(player, F.main(getName(), "You have been forced to escape " + F.clansNether("The Nether") + " to survive its demonic poisons!")); } } } @@ -302,8 +389,8 @@ public class NetherManager extends MiniPlugin if (isInNether(event.getPlayer())) { InNether.remove(event.getPlayer()); - ClansManager.getInstance().getCondition().Clean(event.getPlayer()); - ClansManager.getInstance().getDamageManager().NewDamageEvent(event.getPlayer(), null, null, DamageCause.CUSTOM, 9999, false, true, true, C.cDRed + "The Nether", "Nether Poison"); + event.getPlayer().teleport(getReturnLocation(event.getPlayer())); + OverworldOrigins.remove(event.getPlayer()); } Claiming.remove(event.getPlayer()); } @@ -380,84 +467,4 @@ public class NetherManager extends MiniPlugin spawnPortal(); } } - - public World getNetherWorld() - { - return _netherWorld; - } - - public boolean isInNether(Player player) - { - return player.getWorld().equals(_netherWorld); - } - - public void spawnPortal(long duration) - { - if (Portals.isEmpty()) - { - return; - } - NetherPortal portal = Portals.get(UtilMath.r(Portals.size())); - portal.open(); - UtilTextMiddle.display(F.clansNether("Nether Portal"), "Has opened at " + F.elem(UtilWorld.locToStrClean(portal.getLocation()))); - Bukkit.broadcastMessage(F.main(getName(), "A " + F.clansNether("Nether Portal") + " has opened at " + F.elem(UtilWorld.locToStrClean(portal.getLocation())) + " for " + F.elem(UtilTime.MakeStr(duration)) + "!")); - runSyncLater(() -> - { - portal.close(); - }, (duration / 1000) * 20); - } - - public void spawnPortal() - { - spawnPortal(PORTAL_OPEN_DURATION); - } - - public void createPortal(Player creator) - { - if (Claiming.getOrDefault(creator, new ClaimData()).getTotalSelected() < 2) - { - UtilPlayer.message(creator, F.main(getName(), "You do not have a top and bottom corner selected!")); - return; - } - - ClaimData data = Claiming.remove(creator); - NetherPortal portal = new NetherPortal(data.getFirstCorner().getLocation(), data.getSecondCorner().getLocation()); - Portals.add(portal); - - try - { - savePortals(); - } - catch (Exception e) - { - UtilPlayer.message(creator, F.main(getName(), "An error occurred while creating that portal! Please report this immediately!")); - return; - } - } - - public void closePortals() - { - for (NetherPortal portal : Portals) - { - portal.close(); - } - } - - public void showPortalList(Player player) - { - UtilPlayer.message(player, F.main(getName(), "Portal List:")); - for (int i = 0; i < Portals.size(); i++) - { - int id = i + 1; - NetherPortal portal = Portals.get(i); - - UtilPlayer.message(player, C.cBlue + "- " + F.elem("Portal " + id + ": " + C.cGray + UtilWorld.locToStrClean(portal.getLocation()).replace("(", "").replace(")", ""))); - } - } - - public void giveWand(Player player) - { - player.getInventory().addItem(CLAIM_WAND.clone()); - UtilPlayer.message(player, F.main(getName(), "You have been given a Portal Claim Wand!")); - } } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java index d6d9b0aa5..8db21cebf 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java @@ -6,18 +6,18 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.game.clans.clans.ClanTips.TipType; import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.spawn.Spawn; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; +import org.bukkit.block.BlockState; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; -import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockDamageEvent; import org.bukkit.event.block.BlockPhysicsEvent; import org.bukkit.event.entity.EntityPortalEnterEvent; import org.bukkit.event.entity.EntityPortalEvent; @@ -33,6 +33,7 @@ public class NetherPortal implements Listener private Location _loc; private Location[] _corners; private boolean _returnPortal; + private byte _portalFacing; public NetherPortal(Location firstCorner, Location secondCorner, boolean returnPortal) { @@ -78,6 +79,15 @@ public class NetherPortal implements Listener _loc = new Location(firstCorner.getWorld(), minX + ((maxX - minX) / 2), maxY, minZ + ((maxZ - minZ) / 2)); _corners = new Location[] {firstCorner, secondCorner}; _returnPortal = returnPortal; + + if (maxX == minX) + { + _portalFacing = (byte)2; + } + else + { + _portalFacing = (byte)0; + } } private boolean isInPortal(Block block) @@ -100,6 +110,7 @@ public class NetherPortal implements Listener return _returnPortal; } + @SuppressWarnings("deprecation") public void open() { Bukkit.getPluginManager().registerEvents(this, ClansManager.getInstance().getPlugin()); @@ -110,6 +121,7 @@ public class NetherPortal implements Listener for (Block block : _portal) { block.setType(Material.PORTAL); + block.setData(_portalFacing); Bukkit.broadcastMessage("Creating Portal Piece"); } } @@ -121,13 +133,18 @@ public class NetherPortal implements Listener { block.setType(Material.AIR); } + for (Block block : _frame) + { + block.setType(Material.AIR); + } } @EventHandler(priority = EventPriority.HIGHEST) - public void onBreak(BlockBreakEvent event) + public void onBreak(BlockDamageEvent event) { if (isInPortal(event.getBlock())) { + event.setInstaBreak(false); event.setCancelled(true); UtilPlayer.message(event.getPlayer(), F.main("Clans", "You cannot destroy a " + F.clansNether("Nether Portal"))); } @@ -165,8 +182,8 @@ public class NetherPortal implements Listener if (isReturnPortal()) { ClansManager.getInstance().getNetherManager().InNether.remove((Player)event.getEntity()); - ClansManager.getInstance().getCondition().Clean((Player)event.getEntity()); - event.getEntity().teleport(Spawn.getNorthSpawn()); + event.getEntity().teleport(ClansManager.getInstance().getNetherManager().getReturnLocation((Player)event.getEntity())); + ClansManager.getInstance().getNetherManager().OverworldOrigins.remove((Player)event.getEntity()); UtilPlayer.message(event.getEntity(), F.main(ClansManager.getInstance().getNetherManager().getName(), "You have escaped " + F.clansNether("The Nether") + "!")); } else diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/CreateCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/CreateCommand.java index 2697b97ac..0fe76df8b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/CreateCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/CreateCommand.java @@ -2,6 +2,8 @@ package mineplex.game.clans.clans.nether.command; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; import mineplex.game.clans.clans.nether.NetherManager; import org.bukkit.entity.Player; @@ -16,6 +18,19 @@ public class CreateCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - Plugin.createPortal(caller); + Boolean returnPortal = null; + try + { + returnPortal = Boolean.parseBoolean(args[0]); + } + catch (Exception e) {} + + if (returnPortal == null) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "Usage: " + F.elem("/portal " + _aliasUsed + " "))); + return; + } + + Plugin.createPortal(caller, returnPortal); } } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/DeleteCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/DeleteCommand.java index ed5f70ac0..ebbc9dec8 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/DeleteCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/DeleteCommand.java @@ -29,7 +29,7 @@ public class DeleteCommand extends CommandBase UtilPlayer.message(caller, F.main(Plugin.getName(), "Usage: " + F.elem("/portal " + _aliasUsed + " "))); return; } - UtilPlayer.message(caller, F.main(Plugin.getName(), "Deleting the " + F.clansNether("Nether Portal" + " with ID " + id + "!"))); + UtilPlayer.message(caller, F.main(Plugin.getName(), "Deleting the " + F.clansNether("Nether Portal") + " with ID " + id + "!")); Plugin.Portals.remove(id - 1); try { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/MinibossFireball.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/MinibossFireball.java new file mode 100644 index 000000000..2df5fe663 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/MinibossFireball.java @@ -0,0 +1,71 @@ +package mineplex.game.clans.clans.nether.miniboss; + +import java.util.HashMap; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.game.clans.clans.ClansManager; + +import org.bukkit.Bukkit; +import org.bukkit.Sound; +import org.bukkit.entity.LargeFireball; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Projectile; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.metadata.FixedMetadataValue; +import org.bukkit.util.Vector; + +public class MinibossFireball implements Listener +{ + public MinibossFireball() + { + Bukkit.getPluginManager().registerEvents(this, ClansManager.getInstance().getPlugin()); + } + + @EventHandler + public void onHit(ProjectileHitEvent event) + { + Projectile proj = event.getEntity(); + + if (!(proj instanceof LargeFireball)) + { + return; + } + if (!proj.hasMetadata("MINIBOSS_FIREBALL")) + { + return; + } + + HashMap hitMap = UtilEnt.getInRadius(proj.getLocation(), 5); + for (LivingEntity cur : hitMap.keySet()) + { + double range = hitMap.get(cur); + + ClansManager.getInstance().getCondition().Factory().Ignite("Fireball", cur, ((LivingEntity)proj.getMetadata("MINIBOSS_FIREBALL").get(0)), 7 * range, false, false); + ClansManager.getInstance().getCondition().Factory().Falling("Fireball", cur, ((LivingEntity)proj.getMetadata("MINIBOSS_FIREBALL").get(0)), 10, false, true); + UtilAction.velocity(cur, UtilAlg.getTrajectory(proj.getLocation().add(0, -0.5, 0), cur.getEyeLocation()), + 1.6 * range, false, 0, 0.8 * range, 1.2, true); + } + } + + public static boolean isFireball(Projectile entity) + { + return entity.hasMetadata("MINIBOSS_FIREBALL"); + } + + public static void launchFireball(LivingEntity shooter) + { + LargeFireball ball = shooter.launchProjectile(LargeFireball.class); + ball.setShooter(shooter); + ball.setIsIncendiary(false); + ball.setYield(0); + ball.setBounce(false); + ball.teleport(shooter.getEyeLocation().add(shooter.getLocation().getDirection().multiply(1))); + ball.setVelocity(new Vector(0,0,0)); + ball.setMetadata("MINIBOSS_FIREBALL", new FixedMetadataValue(ClansManager.getInstance().getPlugin(), shooter)); + shooter.getWorld().playSound(shooter.getLocation(), Sound.GHAST_FIREBALL, 1f, 0.8f); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMiniBoss.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMiniBoss.java index c698d0546..dad0324d5 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMiniBoss.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMiniBoss.java @@ -51,7 +51,7 @@ public abstract class NetherMiniBoss implements Listen public void customSpawn() {}; - public void customDeath() {}; + public void customDeath(Location deathLocation) {}; public void customDespawn() {}; @@ -62,8 +62,10 @@ public abstract class NetherMiniBoss implements Listen { if (event.getEntity().equals(_entity)) { + event.setDroppedExp(0); + event.getDrops().clear(); HandlerList.unregisterAll(this); - customDeath(); + customDeath(event.getEntity().getLocation()); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossManager.java index 1e5ae3352..e52e58967 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossManager.java @@ -9,30 +9,46 @@ import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.nether.NetherManager; import org.bukkit.Bukkit; -import org.bukkit.Location; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntitySpawnEvent; import com.google.common.collect.Lists; public class NetherMinibossManager implements Listener { - private static final long TIME_BETWEEN_MINIBOSS_TARGET_PLAYER = 30000; + private static final long TIME_BETWEEN_MINIBOSS_TARGET_PLAYER = 5000; private NetherManager _manager; + private boolean _allowSpawn = false; public NetherMinibossManager(NetherManager manager) { _manager = manager; + new MinibossFireball(); Bukkit.getPluginManager().registerEvents(this, manager.getPlugin()); } private void spawnAttacker(Player player) { - Location toSpawn = new Location(_manager.getNetherWorld(), player.getLocation().getX() + UtilMath.random(6, 10), player.getLocation().getY(), player.getLocation().getZ() + UtilMath.random(6, 10)); NetherMinibossType bossType = NetherMinibossType.values()[UtilMath.r(NetherMinibossType.values().length)]; - bossType.getNewInstance(toSpawn); + _allowSpawn = true; + bossType.getNewInstance(player.getLocation()); + _allowSpawn = false; + } + + @EventHandler + public void onSpawnNormal(EntitySpawnEvent event) + { + if (event.getEntity() instanceof LivingEntity && _manager.getNetherWorld().equals(event.getLocation().getWorld())) + { + if (!_allowSpawn) + { + event.setCancelled(true); + } + } } @EventHandler diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossType.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossType.java index c158596a4..36d2e79f0 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossType.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossType.java @@ -1,7 +1,8 @@ package mineplex.game.clans.clans.nether.miniboss; -import mineplex.game.clans.clans.nether.miniboss.ghast.GhastMiniboss; -import mineplex.game.clans.clans.nether.miniboss.ghast.PigmanMiniboss; +import mineplex.game.clans.clans.nether.miniboss.bosses.ArcherMiniboss; +import mineplex.game.clans.clans.nether.miniboss.bosses.GhastMiniboss; +import mineplex.game.clans.clans.nether.miniboss.bosses.WarriorMiniboss; import org.bukkit.Location; import org.bukkit.entity.EntityType; @@ -9,7 +10,9 @@ import org.bukkit.entity.EntityType; public enum NetherMinibossType { GHAST("Ghast", 25D, EntityType.GHAST, GhastMiniboss.class), - PIGMAN("Zombie Pigman", 30D, EntityType.PIG_ZOMBIE, PigmanMiniboss.class) + WARRIOR("Undead Warrior", 30D, EntityType.ZOMBIE, WarriorMiniboss.class), + ARCHER("Undead Archer", 25D, EntityType.SKELETON, ArcherMiniboss.class) + //PIGMAN("Zombie Pigman", 30D, EntityType.PIG_ZOMBIE, PigmanMiniboss.class) ; private Class _code; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/ArcherMiniboss.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/ArcherMiniboss.java new file mode 100644 index 000000000..73b6841db --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/ArcherMiniboss.java @@ -0,0 +1,192 @@ +package mineplex.game.clans.clans.nether.miniboss.bosses; + +import java.util.Random; + +import mineplex.core.common.util.UtilMath; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.nether.miniboss.NetherMiniBoss; +import mineplex.game.clans.items.runes.RuneManager.RuneAttribute; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.entity.Skeleton; +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.EntityTargetLivingEntityEvent; +import org.bukkit.inventory.EntityEquipment; +import org.bukkit.inventory.ItemStack; +import org.bukkit.metadata.FixedMetadataValue; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +public class ArcherMiniboss extends NetherMiniBoss +{ + private static final int BARBED_LEVEL = 1; + + public ArcherMiniboss(String displayName, Double maxHealth, Location spawn, EntityType type) + { + super(displayName, maxHealth, spawn, type); + } + + @Override + public void customSpawn() + { + Skeleton entity = getEntity(); + EntityEquipment eq = entity.getEquipment(); + eq.setItemInHand(new ItemStack(Material.BOW)); + eq.setHelmet(new ItemStack(Material.CHAINMAIL_HELMET)); + eq.setChestplate(new ItemStack(Material.CHAINMAIL_CHESTPLATE)); + eq.setLeggings(new ItemStack(Material.CHAINMAIL_LEGGINGS)); + eq.setBoots(new ItemStack(Material.CHAINMAIL_BOOTS)); + eq.setItemInHandDropChance(0.f); + eq.setHelmetDropChance(0.f); + eq.setChestplateDropChance(0.f); + eq.setLeggingsDropChance(0.f); + eq.setBootsDropChance(0.f); + entity.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 999999, 0)); + } + + @Override + public void customDeath(Location deathLocation) + { + deathLocation.getWorld().dropItemNaturally(deathLocation, new ItemStack(Material.DIAMOND, UtilMath.r(5) + 1)); + if (new Random().nextDouble() <= .1) + { + RuneAttribute runeType = RuneAttribute.values()[UtilMath.r(RuneAttribute.values().length)]; + deathLocation.getWorld().dropItemNaturally(deathLocation, ClansManager.getInstance().getGearManager().getRuneManager().getRune(runeType)); + } + } + + @EventHandler + public void onTarget(EntityTargetLivingEntityEvent event) + { + if (getEntity().equals(event.getEntity())) + { + if (!(event.getTarget() instanceof Player)) + { + event.setCancelled(true); + } + } + } + + @EventHandler(priority = EventPriority.MONITOR) + public void bowShoot(EntityShootBowEvent event) + { + if (BARBED_LEVEL == 0) + { + return; + } + + if (!(event.getProjectile() instanceof Arrow)) + { + return; + } + + if (event.getEntity().getEntityId() != getEntity().getEntityId()) + { + return; + } + + event.getProjectile().setMetadata("BARBED_ARROW", new FixedMetadataValue(ClansManager.getInstance().getPlugin(), 2)); + } + + @EventHandler(priority = EventPriority.HIGH) + public void damage(CustomDamageEvent event) + { + if (event.IsCancelled()) + { + return; + } + + if (event.GetCause() != DamageCause.PROJECTILE) + { + return; + } + + Projectile projectile = event.GetProjectile(); + LivingEntity damagee = event.GetDamageeEntity(); + LivingEntity damager = event.GetDamagerEntity(true); + + if (projectile == null) + { + return; + } + + if (!projectile.hasMetadata("BARBED_ARROW")) + { + return; + } + + if (damagee == null) + { + return; + } + + if (damager == null) + { + return; + } + + if (!getEntity().equals(damager)) + { + return; + } + + // Level + if (BARBED_LEVEL == 0) + { + return; + } + + Player damageePlayer = event.GetDamageePlayer(); + + if (damageePlayer != null) + { + damageePlayer.setSprinting(false); + } + + // Damage + event.AddMod(damager.getName(), "Barbed Arrows", projectile.getMetadata("BARBED_ARROW").get(0).asDouble(), false); + + // Condition + ClansManager.getInstance().getCondition().Factory().Slow("Barbed Arrows", damagee, damager, (projectile.getVelocity().length() / 3) * (2 + BARBED_LEVEL), 0, false, true, true, true); + } + + @EventHandler(priority = EventPriority.HIGH) + public void protect(CustomDamageEvent event) + { + if (event.IsCancelled()) + { + return; + } + + LivingEntity damagee = event.GetDamageeEntity(); + LivingEntity damager = event.GetDamagerEntity(event.GetCause() == DamageCause.PROJECTILE); + + if (damagee == null) + { + return; + } + + if (damager == null) + { + return; + } + + if (getEntity().equals(damagee)) + { + if (!(damager instanceof Player)) + { + event.SetCancelled("Allied Attacker"); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/GhastMiniboss.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/GhastMiniboss.java new file mode 100644 index 000000000..15c642384 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/GhastMiniboss.java @@ -0,0 +1,91 @@ +package mineplex.game.clans.clans.nether.miniboss.bosses; + +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilTime; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.nether.miniboss.MinibossFireball; +import mineplex.game.clans.clans.nether.miniboss.NetherMiniBoss; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Ghast; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.ProjectileLaunchEvent; +import org.bukkit.inventory.ItemStack; + +public class GhastMiniboss extends NetherMiniBoss +{ + private static final long MAIN_FIREBALL_COOLDOWN = 5000; + private static final long FIREBALL_LAUNCH_RATE = 500; + private static final int FIREBALLS_PER_USE = 5; + private long _lastFireballUse; + private int _fireballsRemaining; + + public GhastMiniboss(String displayName, Double maxHealth, Location spawn, EntityType type) + { + super(displayName, maxHealth, spawn, type); + } + + private void tryFireballVolley() + { + if (_fireballsRemaining > 0) + { + if (UtilTime.elapsed(_lastFireballUse, FIREBALL_LAUNCH_RATE)) + { + _fireballsRemaining--; + _lastFireballUse = System.currentTimeMillis(); + MinibossFireball.launchFireball(getEntity()); + } + } + else + { + if (UtilTime.elapsed(_lastFireballUse, MAIN_FIREBALL_COOLDOWN)) + { + _fireballsRemaining = FIREBALLS_PER_USE; + } + } + } + + @Override + public void customSpawn() + { + _lastFireballUse = System.currentTimeMillis(); + _fireballsRemaining = 0; + } + + @Override + public void customDeath(Location deathLocation) + { + deathLocation.getWorld().dropItemNaturally(deathLocation, new ItemStack(Material.DIAMOND, UtilMath.r(5) + 1)); + } + + @Override + public void update() + { + tryFireballVolley(); + } + + @EventHandler + public void onShoot(ProjectileLaunchEvent event) + { + if (event.getEntity().getShooter() != null && event.getEntity().getShooter().equals(getEntity())) + { + if (!MinibossFireball.isFireball(event.getEntity())) + { + event.setCancelled(true); + } + ClansManager.getInstance().runSyncLater(() -> + { + if (event.getEntity() == null || event.getEntity().isDead() || !event.getEntity().isValid()) + { + return; + } + if (!MinibossFireball.isFireball(event.getEntity())) + { + event.getEntity().remove(); + } + }, 1L); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/ghast/PigmanMiniboss.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/PigmanMiniboss.java similarity index 94% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/ghast/PigmanMiniboss.java rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/PigmanMiniboss.java index ed073f23e..2cc84b4aa 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/ghast/PigmanMiniboss.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/PigmanMiniboss.java @@ -1,4 +1,4 @@ -package mineplex.game.clans.clans.nether.miniboss.ghast; +package mineplex.game.clans.clans.nether.miniboss.bosses; import java.util.Random; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/WarriorMiniboss.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/WarriorMiniboss.java new file mode 100644 index 000000000..8d8a8fc17 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/WarriorMiniboss.java @@ -0,0 +1,133 @@ +package mineplex.game.clans.clans.nether.miniboss.bosses; + +import java.util.Random; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilMath; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.nether.miniboss.NetherMiniBoss; +import mineplex.game.clans.items.runes.RuneManager.RuneAttribute; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Zombie; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityTargetLivingEntityEvent; +import org.bukkit.inventory.EntityEquipment; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +public class WarriorMiniboss extends NetherMiniBoss +{ + public WarriorMiniboss(String displayName, Double maxHealth, Location spawn, EntityType type) + { + super(displayName, maxHealth, spawn, type); + } + + @Override + public void customSpawn() + { + Zombie entity = getEntity(); + EntityEquipment eq = entity.getEquipment(); + eq.setHelmet(new ItemStack(Material.IRON_HELMET)); + eq.setChestplate(new ItemStack(Material.IRON_CHESTPLATE)); + eq.setLeggings(new ItemStack(Material.IRON_LEGGINGS)); + eq.setBoots(new ItemStack(Material.IRON_BOOTS)); + eq.setItemInHand(new ItemStack(Material.STONE_SWORD)); + eq.setHelmetDropChance(0.f); + eq.setChestplateDropChance(0.f); + eq.setLeggingsDropChance(0.f); + eq.setBootsDropChance(0.f); + eq.setItemInHandDropChance(0.f); + entity.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 999999, 0)); + } + + @Override + public void customDeath(Location deathLocation) + { + deathLocation.getWorld().dropItemNaturally(deathLocation, new ItemStack(Material.DIAMOND, UtilMath.r(5) + 1)); + if (new Random().nextDouble() <= .1) + { + RuneAttribute runeType = RuneAttribute.values()[UtilMath.r(RuneAttribute.values().length)]; + deathLocation.getWorld().dropItemNaturally(deathLocation, ClansManager.getInstance().getGearManager().getRuneManager().getRune(runeType)); + } + } + + @Override + public void update() + { + if (Math.random() < 0.9) + return; + + Zombie zombie = getEntity(); + + if (zombie.getTarget() == null) + return; + + double dist = UtilMath.offset(zombie.getTarget(), zombie); + + if (dist <= 3 || dist > 16) + return; + + + double power = 0.8 + (1.2 * ((dist-3)/13d)); + + //Leap + UtilAction.velocity(zombie, UtilAlg.getTrajectory(zombie, zombie.getTarget()), + power, false, 0, 0.2, 1, true); + + //Effect + zombie.getWorld().playSound(zombie.getLocation(), Sound.ZOMBIE_HURT, 1f, 2f); + } + + @EventHandler + public void onTarget(EntityTargetLivingEntityEvent event) + { + if (getEntity().equals(event.getEntity())) + { + if (!(event.getTarget() instanceof Player)) + { + event.setCancelled(true); + } + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void protect(CustomDamageEvent event) + { + if (event.IsCancelled()) + { + return; + } + + LivingEntity damagee = event.GetDamageeEntity(); + LivingEntity damager = event.GetDamagerEntity(event.GetCause() == DamageCause.PROJECTILE); + + if (damagee == null) + { + return; + } + + if (damager == null) + { + return; + } + + if (getEntity().equals(damagee)) + { + if (!(damager instanceof Player)) + { + event.SetCancelled("Allied Attacker"); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/ghast/GhastMiniboss.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/ghast/GhastMiniboss.java deleted file mode 100644 index e510f752f..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/ghast/GhastMiniboss.java +++ /dev/null @@ -1,56 +0,0 @@ -package mineplex.game.clans.clans.nether.miniboss.ghast; - -import mineplex.core.common.util.UtilTime; -import mineplex.game.clans.clans.nether.miniboss.NetherMiniBoss; - -import org.bukkit.Location; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Ghast; -import org.bukkit.entity.SmallFireball; - -public class GhastMiniboss extends NetherMiniBoss -{ - private static final long MAIN_FIREBALL_COOLDOWN = 15000; - private static final long FIREBALL_LAUNCH_RATE = 500; - private static final int FIREBALLS_PER_USE = 5; - private long _lastFireballUse; - private int _fireballsRemaining; - - public GhastMiniboss(String displayName, Double maxHealth, Location spawn, EntityType type) - { - super(displayName, maxHealth, spawn, type); - } - - private void tryFireballVolley() - { - if (_fireballsRemaining > 0) - { - if (UtilTime.elapsed(_lastFireballUse, FIREBALL_LAUNCH_RATE)) - { - _fireballsRemaining--; - _lastFireballUse = System.currentTimeMillis(); - getEntity().launchProjectile(SmallFireball.class); - } - } - else - { - if (UtilTime.elapsed(_lastFireballUse, MAIN_FIREBALL_COOLDOWN)) - { - _fireballsRemaining = FIREBALLS_PER_USE; - } - } - } - - @Override - public void customSpawn() - { - _lastFireballUse = System.currentTimeMillis(); - _fireballsRemaining = 0; - } - - @Override - public void update() - { - tryFireballVolley(); - } -} \ No newline at end of file From 1dedde41a896c8dd659c45cba837e06d8b9799b3 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 21 Jul 2016 05:09:31 -0400 Subject: [PATCH 32/90] Banners and beginning javadocs --- Plugins/Mineplex.EnjinTranslator/plugin.yml | 4 + .../src/mineplex/enjinTranslator/Enjin.java | 9 +- .../game/clans/clans/ClansManager.java | 62 +++++++-- .../clans/amplifiers/AmplifierManager.java | 6 + .../clans/clans/banners/BannerManager.java | 117 +++++++++++++++++ .../clans/banners/BannerPacketManager.java | 101 +++++++++++++++ .../clans/clans/banners/BannerPattern.java | 61 +++++++++ .../clans/clans/banners/BannerRepository.java | 101 +++++++++++++++ .../game/clans/clans/banners/ClanBanner.java | 83 ++++++++++++ .../clans/banners/command/BannerCommand.java | 72 +++++++++++ .../clans/clans/banners/gui/BannerGUI.java | 97 ++++++++++++++ .../gui/creation/BaseColorSelectionGUI.java | 75 +++++++++++ .../creation/PatternColorSelectionGUI.java | 77 +++++++++++ .../gui/creation/PatternTypeSelectionGUI.java | 84 ++++++++++++ .../gui/nonedit/NonEditOverviewGUI.java | 58 +++++++++ .../banners/gui/overview/OverviewGUI.java | 121 ++++++++++++++++++ .../clans/clans/nether/NetherManager.java | 88 +++++++------ .../game/clans/clans/nether/NetherPortal.java | 55 ++++++-- .../clans/nether/command/CloseCommand.java | 5 +- .../clans/nether/command/CreateCommand.java | 3 + .../clans/nether/command/DeleteCommand.java | 3 + .../nether/command/ForceTeleportCommand.java | 63 +++++++++ .../clans/nether/command/ListCommand.java | 3 + .../clans/nether/command/PortalCommand.java | 3 + .../clans/nether/command/SpawnCommand.java | 3 + .../clans/nether/command/WandCommand.java | 3 + .../clans/clans/nether/data/ClaimData.java | 23 ++++ .../miniboss/NetherMinibossManager.java | 2 +- .../miniboss/bosses/ArcherMiniboss.java | 3 + .../nether/miniboss/bosses/GhastMiniboss.java | 3 + .../miniboss/bosses/PigmanMiniboss.java | 3 + .../miniboss/bosses/WarriorMiniboss.java | 3 + 32 files changed, 1332 insertions(+), 62 deletions(-) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierManager.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerManager.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerPacketManager.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerPattern.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerRepository.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/ClanBanner.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/command/BannerCommand.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/BannerGUI.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/creation/BaseColorSelectionGUI.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/creation/PatternColorSelectionGUI.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/creation/PatternTypeSelectionGUI.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/nonedit/NonEditOverviewGUI.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/overview/OverviewGUI.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/ForceTeleportCommand.java diff --git a/Plugins/Mineplex.EnjinTranslator/plugin.yml b/Plugins/Mineplex.EnjinTranslator/plugin.yml index ef3eac20a..e3996d524 100644 --- a/Plugins/Mineplex.EnjinTranslator/plugin.yml +++ b/Plugins/Mineplex.EnjinTranslator/plugin.yml @@ -6,6 +6,10 @@ commands: description: Translates enjin commands to mineplex. usage: Don't use it, you get kicked. aliases: + enjin_clans: + description: Translates enjin commands to mineplex. + usage: Don't use it, you get kicked. + aliases: pull: description: Translates enjin commands to mineplex. usage: Don't use it, you get kicked. diff --git a/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java b/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java index 3c569acb1..d1887f960 100644 --- a/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java +++ b/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java @@ -55,6 +55,7 @@ public class Enjin extends MiniPlugin implements CommandExecutor plugin.getCommand("enjin_mineplex").setExecutor(this); plugin.getCommand("pull").setExecutor(this); + plugin.getCommand("enjin_clans").setExecutor(this); } @EventHandler @@ -81,7 +82,13 @@ public class Enjin extends MiniPlugin implements CommandExecutor { if (sender instanceof Player) ((Player)sender).kickPlayer("Like bananas? I don't. Here take these and go have fun."); - + + if (label.equalsIgnoreCase("enjin_clans")) + { + String clansServer = args[0]; + Long minutes = Long.parseLong(args[1]); + } + if (label.equalsIgnoreCase("enjin_mineplex")) { final String name = args[1]; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index 8f53fec8d..bc5f5bfb9 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -1,7 +1,14 @@ package mineplex.game.clans.clans; -import com.google.common.io.ByteArrayDataOutput; -import com.google.common.io.ByteStreams; +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.TimeZone; +import java.util.UUID; + import mineplex.core.MiniClientPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; @@ -10,7 +17,13 @@ import mineplex.core.chat.Chat; import mineplex.core.common.Pair; import mineplex.core.common.Rank; import mineplex.core.common.events.PlayerMessageEvent; -import mineplex.core.common.util.*; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.creature.Creature; import mineplex.core.creature.event.CreatureSpawnCustomEvent; import mineplex.core.disguise.DisguiseManager; @@ -40,7 +53,15 @@ import mineplex.game.clans.Clans; import mineplex.game.clans.clans.ClanTips.TipType; import mineplex.game.clans.clans.ClansUtility.ClanRelation; import mineplex.game.clans.clans.ban.ClansBanManager; -import mineplex.game.clans.clans.commands.*; +import mineplex.game.clans.clans.banners.BannerManager; +import mineplex.game.clans.clans.commands.ClanManagementCommand; +import mineplex.game.clans.clans.commands.ClansAllyChatCommand; +import mineplex.game.clans.clans.commands.ClansChatCommand; +import mineplex.game.clans.clans.commands.ClansCommand; +import mineplex.game.clans.clans.commands.KillCommand; +import mineplex.game.clans.clans.commands.MapCommand; +import mineplex.game.clans.clans.commands.RegionsCommand; +import mineplex.game.clans.clans.commands.SpeedCommand; import mineplex.game.clans.clans.data.PlayerClan; import mineplex.game.clans.clans.event.ClansPlayerDeathEvent; import mineplex.game.clans.clans.gui.ClanShop; @@ -82,8 +103,8 @@ import mineplex.minecraft.game.classcombat.Class.ClientClass; import mineplex.minecraft.game.classcombat.Class.IPvpClass; import mineplex.minecraft.game.classcombat.Class.repository.token.CustomBuildToken; import mineplex.minecraft.game.classcombat.Condition.SkillConditionManager; -import mineplex.minecraft.game.classcombat.Skill.Mage.events.FissureModifyBlockEvent; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; +import mineplex.minecraft.game.classcombat.Skill.Mage.events.FissureModifyBlockEvent; import mineplex.minecraft.game.classcombat.item.ItemFactory; import mineplex.minecraft.game.classcombat.shop.ClassCombatShop; import mineplex.minecraft.game.classcombat.shop.ClassShopManager; @@ -96,7 +117,7 @@ import mineplex.minecraft.game.core.damage.DamageManager; import mineplex.minecraft.game.core.fire.Fire; import mineplex.minecraft.game.core.mechanics.Weapon; import mineplex.serverdata.commands.ServerCommandManager; -import net.md_5.bungee.api.ChatColor; + import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -113,13 +134,18 @@ import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.event.player.*; +import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerLoginEvent; +import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.vehicle.VehicleEnterEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; -import java.io.File; -import java.util.*; +import com.google.common.io.ByteArrayDataOutput; +import com.google.common.io.ByteStreams; public class ClansManager extends MiniClientPluginimplements IRelation { @@ -166,6 +192,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati private mineplex.game.clans.legacytutorial.TutorialManager _legacyTutorial; private ClassManager _classManager; + private BannerManager _bannerManager; public ClassManager getClassManager() { @@ -208,6 +235,8 @@ public class ClansManager extends MiniClientPluginimplements IRelati private ClansBanManager _clansBans; + private PacketHandler _packetHandler; + public ClanTips ClanTips; // Spawn area @@ -221,6 +250,8 @@ public class ClansManager extends MiniClientPluginimplements IRelati _clansBans = clansBans; _punish = punish; + _packetHandler = packetHandler; + _incognitoManager = incognitoManager; _serverName = serverName; _clientManager = clientManager; @@ -423,6 +454,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati _siegeManager = new SiegeManager(this); _netherManager = new NetherManager(this); + _bannerManager = new BannerManager(plugin); } @Override @@ -450,6 +482,8 @@ public class ClansManager extends MiniClientPluginimplements IRelati for (ClanTerritoryToken territoryToken : clanToken.Territories) _claimMap.put(territoryToken.Chunk, new ClanTerritory(territoryToken)); + + _bannerManager.loadBanner(clan); } public DisguiseManager getDisguiseManager() @@ -492,6 +526,16 @@ public class ClansManager extends MiniClientPluginimplements IRelati return _explosion; } + public PacketHandler getPacketHandler() + { + return _packetHandler; + } + + public BannerManager getBannerManager() + { + return _bannerManager; + } + public int getInviteExpire() { return _inviteExpire; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierManager.java new file mode 100644 index 000000000..14aaf0505 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierManager.java @@ -0,0 +1,6 @@ +package mineplex.game.clans.clans.amplifiers; + +public class AmplifierManager +{ + +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerManager.java new file mode 100644 index 000000000..6726e6102 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerManager.java @@ -0,0 +1,117 @@ +package mineplex.game.clans.clans.banners; + +import java.util.HashMap; + +import mineplex.core.MiniPlugin; +import mineplex.core.common.Rank; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClanInfo; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.banners.command.BannerCommand; + +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.block.Banner; +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.BlockBreakEvent; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.inventory.meta.BannerMeta; +import org.bukkit.plugin.java.JavaPlugin; + +public class BannerManager extends MiniPlugin +{ + private static final long BANNER_PLACE_DURATION = UtilTime.convert(30, TimeUnit.MINUTES, TimeUnit.MILLISECONDS); + public final HashMap LoadedBanners = new HashMap<>(); + private final HashMap _placedBanners = new HashMap<>(); + private BannerRepository _repo; + + public BannerManager(JavaPlugin plugin) + { + super("Clan Banners", plugin); + _repo = new BannerRepository(plugin, this); + + new BannerPacketManager(); + addCommand(new BannerCommand(this)); + } + + public int getBannerUnlockLevel(Player player) + { + int level = 0; + if (ClansManager.getInstance().getDonationManager().Get(player).OwnsUnknownPackage("UseClanBanner")) + { + level = 1; + } + if (ClansManager.getInstance().getDonationManager().Get(player).OwnsUnknownPackage("MakeClanBanner")) + { + level = 2; + } + if (ClansManager.getInstance().getClientManager().hasRank(player, Rank.ADMIN)) + { + level = 2; + } + return level; + } + + public void loadBanner(ClanInfo clan) + { + _repo.loadBanner(LoadedBanners, clan); + } + + public void saveBanner(ClanBanner banner) + { + _repo.saveBanner(banner); + } + + public void placeBanner(Player placing, ClanBanner banner) + { + Block block = placing.getLocation().getBlock(); + BlockPlaceEvent event = new BlockPlaceEvent(block, block.getState(), block, placing.getItemInHand(), placing, false); + Bukkit.getPluginManager().callEvent(event); + if (!event.isCancelled()) + { + ClansManager.getInstance().getBlockRestore().restore(block); + if (block.getType() == Material.AIR && UtilBlock.fullSolid(block.getRelative(BlockFace.DOWN))) + { + block.setType(Material.STANDING_BANNER); + Banner state = (Banner) block.getState(); + state.setBaseColor(banner.getBaseColor()); + state.setPatterns(((BannerMeta)banner.getBanner().getItemMeta()).getPatterns()); + state.update(); + _placedBanners.put(block, System.currentTimeMillis()); + } + } + } + + @EventHandler + public void onBreak(BlockBreakEvent event) + { + if (_placedBanners.containsKey(event.getBlock())) + { + _placedBanners.remove(event.getBlock()); + event.setCancelled(true); + event.getBlock().setType(Material.AIR); + } + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() == UpdateType.FAST) + { + for (Block reset : _placedBanners.keySet()) + { + if (UtilTime.elapsed(_placedBanners.get(reset), BANNER_PLACE_DURATION)) + { + reset.setType(Material.AIR); + } + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerPacketManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerPacketManager.java new file mode 100644 index 000000000..9c7c76007 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerPacketManager.java @@ -0,0 +1,101 @@ +package mineplex.game.clans.clans.banners; + +import java.lang.reflect.Field; +import java.util.HashMap; + +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.packethandler.IPacketHandler; +import mineplex.core.packethandler.PacketInfo; +import mineplex.game.clans.clans.ClansManager; +import net.minecraft.server.v1_8_R3.PacketPlayOutEntityEquipment; +import net.minecraft.server.v1_8_R3.PacketPlayOutSetSlot; + +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.inventory.ItemStack; + +public class BannerPacketManager implements Listener +{ + private Field _itemField; + private static BannerPacketManager Instance; + private final HashMap _wearing = new HashMap<>(); + + public BannerPacketManager() + { + try + { + _itemField = PacketPlayOutSetSlot.class.getDeclaredField("c"); + _itemField.setAccessible(true); + + Bukkit.getPluginManager().registerEvents(this, ClansManager.getInstance().getPlugin()); + } + catch (Exception e) + { + e.printStackTrace(); + } + + Instance = this; + } + + public static BannerPacketManager getInstance() + { + return Instance; + } + + public void toggleBanner(Player player, ItemStack banner) + { + if (_wearing.containsKey(player)) + { + IPacketHandler bannerHandler = _wearing.remove(player); + ClansManager.getInstance().getPacketHandler().removePacketHandler(bannerHandler); + for (Player refresh : Bukkit.getOnlinePlayers()) + { + ItemStack helmet = new ItemStack(Material.AIR); + if (player.getInventory().getHelmet() != null) + { + helmet = player.getInventory().getHelmet(); + } + UtilPlayer.sendPacket(refresh, new PacketPlayOutEntityEquipment(player.getEntityId(), 4, CraftItemStack.asNMSCopy(helmet))); + } + } + else + { + IPacketHandler bannerHandler = new IPacketHandler() + { + @Override + public void handle(PacketInfo packetInfo) + { + if (packetInfo.getPacket() instanceof PacketPlayOutEntityEquipment) + { + PacketPlayOutEntityEquipment equip = (PacketPlayOutEntityEquipment) packetInfo.getPacket(); + + if (equip.a == player.getEntityId() && equip.b == 4) + { + equip.c = CraftItemStack.asNMSCopy(banner); + } + } + } + }; + _wearing.put(player, bannerHandler); + ClansManager.getInstance().getPacketHandler().addPacketHandler(bannerHandler, PacketPlayOutEntityEquipment.class); + for (Player refresh : Bukkit.getOnlinePlayers()) + { + UtilPlayer.sendPacket(refresh, new PacketPlayOutEntityEquipment(player.getEntityId(), 4, CraftItemStack.asNMSCopy(banner))); + } + } + } + + @EventHandler + public void onQuit(PlayerQuitEvent event) + { + if (_wearing.containsKey(event.getPlayer())) + { + ClansManager.getInstance().getPacketHandler().removePacketHandler(_wearing.remove(event.getPlayer())); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerPattern.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerPattern.java new file mode 100644 index 000000000..a3ea8ad8a --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerPattern.java @@ -0,0 +1,61 @@ +package mineplex.game.clans.clans.banners; + +import org.bukkit.DyeColor; +import org.bukkit.block.banner.Pattern; +import org.bukkit.block.banner.PatternType; + +public class BannerPattern +{ + private int _layer; + private DyeColor _color; + private PatternType _type; + + public BannerPattern(int layer, DyeColor color, PatternType type) + { + _layer = layer; + _color = color; + _type = type; + } + + public BannerPattern(int layer) + { + _layer = layer; + _color = null; + _type = null; + } + + public int getLayer() + { + return _layer; + } + + public Pattern getBukkitPattern() + { + if (_color == null || _type == null) + { + return null; + } + + return new Pattern(_color, _type); + } + + public String getDatabaseForm() + { + if (_color == null || _type == null) + { + return "Blank"; + } + + return _color.toString() + "," + _type.toString(); + } + + public void setColor(DyeColor color) + { + _color = color; + } + + public void setPatternType(PatternType type) + { + _type = type; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerRepository.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerRepository.java new file mode 100644 index 000000000..ae972f6b2 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerRepository.java @@ -0,0 +1,101 @@ +package mineplex.game.clans.clans.banners; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; + +import mineplex.core.database.MinecraftRepository; +import mineplex.game.clans.clans.ClanInfo; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.column.ColumnInt; +import mineplex.serverdata.database.column.ColumnVarChar; + +import org.bukkit.DyeColor; +import org.bukkit.block.banner.PatternType; +import org.bukkit.plugin.java.JavaPlugin; + +public class BannerRepository extends MinecraftRepository +{ + private static final String CREATE = "CREATE TABLE IF NOT EXISTS clanBanners (clanId INT NOT NULL," + + "baseColor VARCHAR(15)," + + "patterns VARCHAR(300)," + + "PRIMARY KEY (clanId));"; + + private static final String GET_BANNER_BY_CLAN = "SELECT * FROM clanBanners WHERE clanId=? LIMIT 1;"; + private static final String INSERT_BANNER = "INSERT INTO clanBanners (clanId, baseColor, patterns) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE baseColor=VALUES(baseColor), patterns=VALUES(patterns);"; + + private BannerManager _bannerManager; + + public BannerRepository(JavaPlugin plugin, BannerManager bannerManager) + { + super(plugin, DBPool.getAccount()); + _bannerManager = bannerManager; + } + + public void loadBanner(final HashMap map, ClanInfo clan) + { + _bannerManager.runAsync(() -> + { + executeQuery(GET_BANNER_BY_CLAN, resultSet -> + { + while(resultSet.next()) + { + DyeColor baseColor = DyeColor.valueOf(resultSet.getString("baseColor")); + List patternStrs = Arrays.asList(resultSet.getString("patterns").split("/")); + LinkedList patterns = new LinkedList<>(); + int layer = 1; + for (String patternStr : patternStrs) + { + if (patternStr.equalsIgnoreCase("Blank")) + { + patterns.add(new BannerPattern(layer)); + } + else + { + try + { + DyeColor patternColor = DyeColor.valueOf(patternStr.split(",")[0]); + PatternType patternType = PatternType.valueOf(patternStr.split(",")[1]); + patterns.add(new BannerPattern(layer, patternColor, patternType)); + } + catch (Exception e) + { + e.printStackTrace(); + patterns.add(new BannerPattern(layer)); + } + } + layer++; + } + map.put(clan.getName(), new ClanBanner(_bannerManager, clan, baseColor, patterns)); + } + }, new ColumnInt("clanId", clan.getId())); + }); + } + + public void saveBanner(ClanBanner banner) + { + _bannerManager.runAsync(() -> + { + String patternStr = ""; + for (BannerPattern pattern : banner.getPatterns()) + { + if (!patternStr.equalsIgnoreCase("")) + { + patternStr = patternStr + "/"; + } + patternStr = patternStr + pattern.getDatabaseForm(); + } + executeUpdate(INSERT_BANNER, new ColumnInt("clanId", banner.getClan().getId()), new ColumnVarChar("baseColor", 15, banner.getBaseColor().toString()), new ColumnVarChar("patterns", 300, patternStr)); + }); + } + + @Override + protected void initialize() + { + executeUpdate(CREATE); + } + + @Override + protected void update() {} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/ClanBanner.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/ClanBanner.java new file mode 100644 index 000000000..e5531df42 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/ClanBanner.java @@ -0,0 +1,83 @@ +package mineplex.game.clans.clans.banners; + +import java.util.LinkedList; +import java.util.List; + +import mineplex.core.common.util.C; +import mineplex.game.clans.clans.ClanInfo; + +import org.bukkit.DyeColor; +import org.bukkit.Material; +import org.bukkit.block.banner.Pattern; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.BannerMeta; + +import com.google.common.collect.Lists; + +public class ClanBanner +{ + private BannerManager _manager; + private ClanInfo _clan; + private DyeColor _baseColor; + private LinkedList _patterns; + + public ClanBanner(BannerManager manager, ClanInfo clan, DyeColor baseColor, LinkedList patterns) + { + _manager = manager; + _clan = clan; + _baseColor = baseColor; + _patterns = patterns; + } + + public ClanInfo getClan() + { + return _clan; + } + + public DyeColor getBaseColor() + { + return _baseColor; + } + + public LinkedList getPatterns() + { + return _patterns; + } + + public ItemStack getBanner() + { + ItemStack banner = new ItemStack(Material.BANNER); + BannerMeta im = (BannerMeta) banner.getItemMeta(); + + im.setDisplayName(C.cGray + _clan.getName() + "'s Banner"); + im.setBaseColor(_baseColor); + List patterns = Lists.newArrayList(); + for (BannerPattern bp : _patterns) + { + if (bp.getBukkitPattern() != null) + { + patterns.add(bp.getBukkitPattern()); + } + } + im.setPatterns(patterns); + banner.setItemMeta(im); + + return banner; + } + + public void setBaseColor(DyeColor color) + { + _baseColor = color; + } + + public void save() + { + _manager.saveBanner(this); + } + + public void place(Player player) + { + _manager.placeBanner(player, this); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/command/BannerCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/command/BannerCommand.java new file mode 100644 index 000000000..66cb36aa2 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/command/BannerCommand.java @@ -0,0 +1,72 @@ +package mineplex.game.clans.clans.banners.command; + +import java.util.LinkedList; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.game.clans.clans.ClanInfo; +import mineplex.game.clans.clans.ClanRole; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.banners.BannerManager; +import mineplex.game.clans.clans.banners.BannerPattern; +import mineplex.game.clans.clans.banners.ClanBanner; +import mineplex.game.clans.clans.banners.gui.nonedit.NonEditOverviewGUI; +import mineplex.game.clans.clans.banners.gui.overview.OverviewGUI; + +import org.bukkit.DyeColor; +import org.bukkit.entity.Player; + +public class BannerCommand extends CommandBase +{ + public BannerCommand(BannerManager plugin) + { + super(plugin, Rank.ALL, "banner"); + } + + @Override + public void Execute(Player caller, String[] args) + { + if (ClansManager.getInstance().getClan(caller) == null) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "You are not in a Clan!")); + return; + } + ClanInfo clan = ClansManager.getInstance().getClan(caller); + if (clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER || Plugin.getBannerUnlockLevel(caller) < 2) + { + if (Plugin.getBannerUnlockLevel(caller) < 1) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "You have not purchased the ability to use Clan banners! Buy it at http://www.mineplex.com/shop!")); + return; + } + if (!Plugin.LoadedBanners.containsKey(clan.getName())) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "Your Clan does not have a set banner!")); + return; + } + new NonEditOverviewGUI(caller, Plugin.LoadedBanners.get(clan.getName())); + } + else + { + if (!Plugin.LoadedBanners.containsKey(clan.getName())) + { + LinkedList patterns = new LinkedList<>(); + for (int i = 0; i < 12; i++) + { + patterns.add(new BannerPattern(i + 1)); + } + ClanBanner banner = new ClanBanner(Plugin, clan, DyeColor.WHITE, patterns); + Plugin.LoadedBanners.put(clan.getName(), banner); + banner.save(); + new OverviewGUI(caller, banner); + } + else + { + ClanBanner banner = Plugin.LoadedBanners.get(clan.getName()); + new OverviewGUI(caller, banner); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/BannerGUI.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/BannerGUI.java new file mode 100644 index 000000000..2b274547a --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/BannerGUI.java @@ -0,0 +1,97 @@ +package mineplex.game.clans.clans.banners.gui; + +import java.util.HashMap; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.game.clans.clans.ClansManager; + +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryCloseEvent; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; + +public abstract class BannerGUI implements Listener +{ + private Player _viewer; + private Inventory _inventory; + private final HashMap _items = new HashMap<>(); + + public BannerGUI(Player viewer, String pageName, int slots) + { + _viewer = viewer; + _inventory = Bukkit.createInventory(viewer, slots, pageName); + Bukkit.getPluginManager().registerEvents(this, ClansManager.getInstance().getPlugin()); + } + + public Player getViewer() + { + return _viewer; + } + + public HashMap getItems() + { + return _items; + } + + public abstract void propagate(); + + public abstract void onClick(Integer slot, ClickType type); + + public void open() + { + _viewer.openInventory(_inventory); + } + + public void refresh() + { + for (Integer slot : _items.keySet()) + { + _inventory.setItem(slot, _items.get(slot)); + } + for (Integer slot = 0; slot < _inventory.getSize(); slot++) + { + if (!_items.containsKey(slot)) + { + _inventory.setItem(slot, new ItemBuilder(Material.STAINED_GLASS_PANE).setTitle(C.cGray).setData((short)7).build()); + } + } + _viewer.updateInventory(); + } + + @EventHandler + public void handleClick(InventoryClickEvent event) + { + if (event.getClickedInventory() == null || !event.getClickedInventory().equals(_inventory)) + { + return; + } + if (!_viewer.getName().equals(event.getWhoClicked().getName())) + { + return; + } + event.setCancelled(true); + Integer slot = event.getSlot(); + if (!_items.containsKey(slot)) + { + return; + } + onClick(slot, event.getClick()); + } + + @EventHandler + public void onClose(InventoryCloseEvent event) + { + if (event.getPlayer().getUniqueId().equals(_viewer.getUniqueId())) + { + HandlerList.unregisterAll(this); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/creation/BaseColorSelectionGUI.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/creation/BaseColorSelectionGUI.java new file mode 100644 index 000000000..daf486024 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/creation/BaseColorSelectionGUI.java @@ -0,0 +1,75 @@ +package mineplex.game.clans.clans.banners.gui.creation; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.banners.ClanBanner; +import mineplex.game.clans.clans.banners.gui.BannerGUI; +import mineplex.game.clans.clans.banners.gui.overview.OverviewGUI; + +import org.bukkit.DyeColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +public class BaseColorSelectionGUI extends BannerGUI +{ + private ClanBanner _banner; + + public BaseColorSelectionGUI(Player viewer, ClanBanner banner) + { + super(viewer, "Background Color", 27); + _banner = banner; + + propagate(); + open(); + } + + @Override + public void propagate() + { + Integer slot = 1; + for (short data = 0; data <= 15; data++) + { + getItems().put(slot, new ItemBuilder(Material.INK_SACK).setData(data).setTitle(C.cGray).build()); + if ((slot + 1) == 8) + { + slot = 10; + } + else if ((slot + 1) == 17) + { + slot = 21; + } + else if ((slot + 1) == 22) + { + slot = 23; + } + else + { + slot++; + } + } + refresh(); + } + + @SuppressWarnings("deprecation") + @Override + public void onClick(Integer slot, ClickType type) + { + if (getItems().get(slot).getType() == Material.INK_SACK) + { + DyeColor color = DyeColor.getByDyeData(getItems().get(slot).getData().getData()); + _banner.setBaseColor(color); + _banner.save(); + + ClansManager.getInstance().runSyncLater(() -> + { + getViewer().closeInventory(); + }, 1L); + ClansManager.getInstance().runSyncLater(() -> + { + new OverviewGUI(getViewer(), _banner); + }, 2L); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/creation/PatternColorSelectionGUI.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/creation/PatternColorSelectionGUI.java new file mode 100644 index 000000000..73f823fd4 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/creation/PatternColorSelectionGUI.java @@ -0,0 +1,77 @@ +package mineplex.game.clans.clans.banners.gui.creation; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.banners.BannerPattern; +import mineplex.game.clans.clans.banners.ClanBanner; +import mineplex.game.clans.clans.banners.gui.BannerGUI; + +import org.bukkit.DyeColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +public class PatternColorSelectionGUI extends BannerGUI +{ + private ClanBanner _banner; + private int _bannerPos; + + public PatternColorSelectionGUI(Player viewer, ClanBanner banner, int bannerPosition) + { + super(viewer, "Pattern Color", 27); + _banner = banner; + _bannerPos = bannerPosition; + + propagate(); + open(); + } + + @Override + public void propagate() + { + Integer slot = 1; + for (short data = 0; data <= 15; data++) + { + getItems().put(slot, new ItemBuilder(Material.INK_SACK).setData(data).setTitle(C.cGray).build()); + if ((slot + 1) == 8) + { + slot = 10; + } + else if ((slot + 1) == 17) + { + slot = 21; + } + else if ((slot + 1) == 22) + { + slot = 23; + } + else + { + slot++; + } + } + refresh(); + } + + @SuppressWarnings("deprecation") + @Override + public void onClick(Integer slot, ClickType type) + { + if (getItems().get(slot).getType() == Material.INK_SACK) + { + DyeColor color = DyeColor.getByDyeData(getItems().get(slot).getData().getData()); + BannerPattern pattern = _banner.getPatterns().get(_bannerPos); + pattern.setColor(color); + + ClansManager.getInstance().runSyncLater(() -> + { + getViewer().closeInventory(); + }, 1L); + ClansManager.getInstance().runSyncLater(() -> + { + new PatternTypeSelectionGUI(getViewer(), _banner, _bannerPos, color); + }, 2L); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/creation/PatternTypeSelectionGUI.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/creation/PatternTypeSelectionGUI.java new file mode 100644 index 000000000..11a88dc31 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/creation/PatternTypeSelectionGUI.java @@ -0,0 +1,84 @@ +package mineplex.game.clans.clans.banners.gui.creation; + +import java.util.LinkedList; + +import mineplex.core.common.util.C; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.banners.BannerPattern; +import mineplex.game.clans.clans.banners.ClanBanner; +import mineplex.game.clans.clans.banners.gui.BannerGUI; +import mineplex.game.clans.clans.banners.gui.overview.OverviewGUI; + +import org.bukkit.DyeColor; +import org.bukkit.Material; +import org.bukkit.block.banner.Pattern; +import org.bukkit.block.banner.PatternType; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.BannerMeta; + +public class PatternTypeSelectionGUI extends BannerGUI +{ + private ClanBanner _banner; + private int _bannerPos; + private DyeColor _color; + + public PatternTypeSelectionGUI(Player viewer, ClanBanner banner, int bannerPosition, DyeColor patternColor) + { + super(viewer, "Pattern Color", 45); + _banner = banner; + _bannerPos = bannerPosition; + _color = patternColor; + + propagate(); + open(); + } + + @Override + public void propagate() + { + for (int i = 0; i < PatternType.values().length; i++) + { + ItemStack item = new ItemStack(Material.BANNER); + BannerMeta im = (BannerMeta) item.getItemMeta(); + im.setBaseColor(_banner.getBaseColor()); + LinkedList patterns = new LinkedList<>(); + for (int patternId = 0; patternId < _bannerPos; patternId++) + { + BannerPattern show = _banner.getPatterns().get(patternId); + if (show.getBukkitPattern() != null) + { + patterns.add(show.getBukkitPattern()); + } + } + patterns.add(new Pattern(_color, PatternType.values()[i])); + im.setPatterns(patterns); + im.setDisplayName(C.cGray); + item.setItemMeta(im); + getItems().put(i, item); + } + refresh(); + } + + @Override + public void onClick(Integer slot, ClickType ctype) + { + if (getItems().get(slot).getType() == Material.BANNER) + { + PatternType type = ((BannerMeta)getItems().get(slot).getItemMeta()).getPatterns().get(Math.min(_bannerPos, ((BannerMeta)getItems().get(slot).getItemMeta()).getPatterns().size() - 1)).getPattern(); + BannerPattern pattern = _banner.getPatterns().get(_bannerPos); + pattern.setPatternType(type); + _banner.save(); + + ClansManager.getInstance().runSyncLater(() -> + { + getViewer().closeInventory(); + }, 1L); + ClansManager.getInstance().runSyncLater(() -> + { + new OverviewGUI(getViewer(), _banner); + }, 2L); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/nonedit/NonEditOverviewGUI.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/nonedit/NonEditOverviewGUI.java new file mode 100644 index 000000000..d7a233e14 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/nonedit/NonEditOverviewGUI.java @@ -0,0 +1,58 @@ +package mineplex.game.clans.clans.banners.gui.nonedit; + +import java.util.Arrays; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.game.clans.clans.banners.BannerPacketManager; +import mineplex.game.clans.clans.banners.ClanBanner; +import mineplex.game.clans.clans.banners.gui.BannerGUI; + +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +public class NonEditOverviewGUI extends BannerGUI +{ + private ClanBanner _banner; + + public NonEditOverviewGUI(Player viewer, ClanBanner banner) + { + super(viewer, "Clan Banner", 9); + _banner = banner; + + propagate(); + open(); + } + + @Override + public void propagate() + { + ItemStack banner = _banner.getBanner().clone(); + ItemMeta im = banner.getItemMeta(); + im.setDisplayName(C.cGreen + "Clan Banner"); + im.setLore(Arrays.asList(new String[] {F.elem("Left Click") + " to toggle wearing your banner", F.elem("Right Click") + " to place down your banner"})); + banner.setItemMeta(im); + getItems().put(4, banner); + refresh(); + } + + @Override + public void onClick(Integer slot, ClickType type) + { + if (slot == 4) + { + if (type == ClickType.LEFT) + { + BannerPacketManager.getInstance().toggleBanner(getViewer(), _banner.getBanner()); + UtilPlayer.message(getViewer(), F.main("Clan Banners", "You have toggled your banner!")); + } + else if (type == ClickType.RIGHT) + { + _banner.place(getViewer()); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/overview/OverviewGUI.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/overview/OverviewGUI.java new file mode 100644 index 000000000..59553930d --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/overview/OverviewGUI.java @@ -0,0 +1,121 @@ +package mineplex.game.clans.clans.banners.gui.overview; + +import java.util.Arrays; + +import mineplex.core.common.util.C; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.banners.BannerPattern; +import mineplex.game.clans.clans.banners.ClanBanner; +import mineplex.game.clans.clans.banners.gui.BannerGUI; +import mineplex.game.clans.clans.banners.gui.creation.BaseColorSelectionGUI; +import mineplex.game.clans.clans.banners.gui.creation.PatternColorSelectionGUI; +import mineplex.game.clans.clans.banners.gui.nonedit.NonEditOverviewGUI; + +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 org.bukkit.material.MaterialData; + +public class OverviewGUI extends BannerGUI +{ + private static final int MAX_BANNER_LAYERS = 12; + private static final int PATTERN_DISPLAY_START_SLOT = 27; + private final ClanBanner _banner; + + public OverviewGUI(Player viewer, ClanBanner banner) + { + super(viewer, "Clan Banner", 45); + _banner = banner; + + propagate(); + open(); + } + + @Override + @SuppressWarnings("deprecation") + public void propagate() + { + getItems().put(4, _banner.getBanner()); + ItemStack color = new MaterialData(Material.INK_SACK, _banner.getBaseColor().getDyeData()).toItemStack(1); + ItemMeta colorMeta = color.getItemMeta(); + colorMeta.setDisplayName(C.cGray); + color.setItemMeta(colorMeta); + getItems().put(22, color); + Integer slot = PATTERN_DISPLAY_START_SLOT; + for (int i = 0; i < MAX_BANNER_LAYERS; i++) + { + ItemStack item = new ItemStack(Material.INK_SACK, 1, (short)8); + if (i < _banner.getPatterns().size()) + { + BannerPattern pattern = _banner.getPatterns().get(i); + if (pattern.getBukkitPattern() != null) + { + ItemStack representation = new ItemStack(Material.BANNER); + BannerMeta im = (BannerMeta) representation.getItemMeta(); + im.setBaseColor(_banner.getBaseColor()); + im.setDisplayName(C.cGray); + im.setPatterns(Arrays.asList(pattern.getBukkitPattern())); + representation.setItemMeta(im); + item = representation; + } + } + getItems().put(slot, item); + slot++; + } + refresh(); + } + + @Override + public void onClick(Integer slot, ClickType type) + { + if (slot == 4) + { + ClansManager.getInstance().runSyncLater(() -> + { + getViewer().closeInventory(); + }, 1L); + ClansManager.getInstance().runSyncLater(() -> + { + new NonEditOverviewGUI(getViewer(), _banner); + }, 2L); + } + if (slot == 22) + { + ClansManager.getInstance().runSyncLater(() -> + { + getViewer().closeInventory(); + }, 1L); + ClansManager.getInstance().runSyncLater(() -> + { + new BaseColorSelectionGUI(getViewer(), _banner); + }, 2L); + } + if (slot >= PATTERN_DISPLAY_START_SLOT) + { + if (type == ClickType.RIGHT) + { + _banner.getPatterns().get(slot - PATTERN_DISPLAY_START_SLOT).setColor(null); + ClansManager.getInstance().runSyncLater(() -> + { + getItems().clear(); + propagate(); + refresh(); + }, 1L); + } + else + { + ClansManager.getInstance().runSyncLater(() -> + { + getViewer().closeInventory(); + }, 1L); + ClansManager.getInstance().runSyncLater(() -> + { + new PatternColorSelectionGUI(getViewer(), _banner, slot - PATTERN_DISPLAY_START_SLOT); + }, 2L); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java index 427b61e35..dc79d705a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java @@ -10,7 +10,6 @@ import mineplex.core.common.Rank; import mineplex.core.common.generator.VoidGenerator; import mineplex.core.common.util.C; import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; @@ -23,6 +22,7 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.event.ClansCommandExecutedEvent; +import mineplex.game.clans.clans.nether.command.ForceTeleportCommand; import mineplex.game.clans.clans.nether.command.PortalCommand; import mineplex.game.clans.clans.nether.data.ClaimData; import mineplex.game.clans.clans.nether.miniboss.NetherMinibossManager; @@ -49,6 +49,7 @@ import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.EntityPortalEvent; +import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerPortalEvent; @@ -59,8 +60,7 @@ import com.google.common.collect.Lists; public class NetherManager extends MiniPlugin { - private static final long PORTAL_OPEN_DURATION = UtilTime.convert(5, TimeUnit.MINUTES, TimeUnit.MILLISECONDS); - private static final long NETHER_ALLOWED_DURATION = UtilTime.convert(5, TimeUnit.MINUTES, TimeUnit.MILLISECONDS); + private static final long PORTAL_OPEN_DURATION = UtilTime.convert(10, TimeUnit.MINUTES, TimeUnit.MILLISECONDS); private static final String CLAIM_WAND_NAME = C.cRedB + "Portal Claim Wand"; private static final String[] CLAIM_WAND_LORE = new String[] {C.cYellow + "Left Click to select the Portal's first corner", C.cYellow + "Right Click to select the Portal's second corner"}; private static final ItemStack CLAIM_WAND = new ItemBuilder(Material.WOOD_AXE).setTitle(CLAIM_WAND_NAME).setLore(CLAIM_WAND_LORE).build(); @@ -76,7 +76,7 @@ public class NetherManager extends MiniPlugin public NetherManager(ClansManager manager) { - super("Nether Manager", manager.getPlugin()); + super("Nether", manager.getPlugin()); _portalCfg = new File(UtilServer.getServer().getWorlds().get(0).getWorldFolder().getPath() + File.separator + ".." + File.separator + "portals.yml"); @@ -96,6 +96,7 @@ public class NetherManager extends MiniPlugin begin(); _miniboss = new NetherMinibossManager(this); addCommand(new PortalCommand(this)); + addCommand(new ForceTeleportCommand(this)); } private void begin() @@ -124,17 +125,12 @@ public class NetherManager extends MiniPlugin _portalConfig.set("PortalCount", 0); _portalConfig.save(_portalCfg); } - if (!_portalConfig.isConfigurationSection("Portals")); - { - _portalConfig.createSection("Portals"); - _portalConfig.save(_portalCfg); - } log("Loading " + _portalConfig.getInt("PortalCount") + " Nether Portals!"); - for (String portalSectionPath : _portalConfig.getConfigurationSection("Portals").getValues(false).keySet()) + ConfigurationSection portalSection = _portalConfig.getConfigurationSection("Portals"); + for (String portalSectionPath : portalSection.getKeys(false)) { - log("Loading Portal"); - ConfigurationSection portal = _portalConfig.getConfigurationSection("Portals." + portalSectionPath); + ConfigurationSection portal = portalSection.getConfigurationSection(portalSectionPath); Location firstCorner = UtilWorld.strToLoc(portal.getString("CornerOne")); Location secondCorner = UtilWorld.strToLoc(portal.getString("CornerTwo")); boolean returnPortal = portal.getBoolean("ReturnPortal"); @@ -194,18 +190,28 @@ public class NetherManager extends MiniPlugin public void spawnPortal(long duration) { - if (Portals.isEmpty()) + if (Portals.isEmpty() || _returnPortals.isEmpty()) { return; } - NetherPortal portal = Portals.get(UtilMath.r(Portals.size())); - portal.open(); + List available = Lists.newArrayList(); + available.addAll(Portals); + for (NetherPortal remove : _returnPortals) + { + available.remove(remove); + } + if (available.isEmpty()) + { + return; + } + NetherPortal portal = available.get(UtilMath.r(available.size())); + portal.open(duration); + for (NetherPortal returnPortal : _returnPortals) + { + returnPortal.open(-1); + } UtilTextMiddle.display(F.clansNether("Nether Portal"), "Has opened at " + F.elem(UtilWorld.locToStrClean(portal.getLocation()))); Bukkit.broadcastMessage(F.main(getName(), "A " + F.clansNether("Nether Portal") + " has opened at " + F.elem(UtilWorld.locToStrClean(portal.getLocation())) + " for " + F.elem(UtilTime.MakeStr(duration)) + "!")); - runSyncLater(() -> - { - portal.close(); - }, (duration / 1000) * 20); } public void spawnPortal() @@ -224,6 +230,10 @@ public class NetherManager extends MiniPlugin ClaimData data = Claiming.remove(creator); NetherPortal portal = new NetherPortal(data.getFirstCorner().getLocation(), data.getSecondCorner().getLocation(), returnPortal); Portals.add(portal); + if (returnPortal) + { + _returnPortals.add(portal); + } try { @@ -284,7 +294,6 @@ public class NetherManager extends MiniPlugin { Block block = event.getBlock(); Player player = event.getPlayer(); - ItemStack item = player.getItemInHand(); if (player.getGameMode() == GameMode.CREATIVE) { @@ -296,12 +305,8 @@ public class NetherManager extends MiniPlugin return; } - if (!item.getType().equals(Material.GOLD_PICKAXE)) - { - UtilPlayer.message(player, F.main("Clans", "You can only break blocks in the Nether with a " + F.elem("Golden Pickaxe") + ".")); - event.setCancelled(true); - return; - } + event.setCancelled(true); + UtilPlayer.message(player, F.main(getName(), "You cannot build in " + F.clansNether("The Nether") + "!")); } @EventHandler @@ -309,7 +314,6 @@ public class NetherManager extends MiniPlugin { Block block = event.getBlock(); Player player = event.getPlayer(); - ItemStack item = player.getItemInHand(); if (player.getGameMode() == GameMode.CREATIVE) { @@ -321,12 +325,8 @@ public class NetherManager extends MiniPlugin return; } - if (!UtilItem.isFromNether(item)) - { - UtilPlayer.message(player, F.main("Clans", "You can only place blocks here that come from " + F.clansNether("The Nether") + ".")); - event.setCancelled(true); - return; - } + event.setCancelled(true); + UtilPlayer.message(player, F.main(getName(), "You cannot build in " + F.clansNether("The Nether") + "!")); } @EventHandler(priority = EventPriority.HIGHEST) @@ -361,7 +361,7 @@ public class NetherManager extends MiniPlugin netherKeys.addAll(InNether.keySet()); for (Player player : netherKeys) { - if (UtilTime.elapsed(InNether.get(player), NETHER_ALLOWED_DURATION)) + if (System.currentTimeMillis() >= InNether.get(player)) { InNether.remove(player); if (isInNether(player)) @@ -374,12 +374,12 @@ public class NetherManager extends MiniPlugin } UtilServer.getPlayersCollection() - .stream() - .filter(player -> isInNether(player)) - .forEach(player -> { - player.setCompassTarget(new Location(_netherWorld, -200.d + UtilMath.r(400), player.getLocation().getY(), -200.d + UtilMath.r(400))); - ClansManager.getInstance().getItemMapManager().removeMap(player); - }); + .stream() + .filter(player -> isInNether(player)) + .forEach(player -> + { + ClansManager.getInstance().getItemMapManager().removeMap(player); + }); } } @@ -395,6 +395,14 @@ public class NetherManager extends MiniPlugin Claiming.remove(event.getPlayer()); } + @EventHandler(priority = EventPriority.LOWEST) + public void onQuit(PlayerDeathEvent event) + { + InNether.remove(event.getEntity()); + OverworldOrigins.remove(event.getEntity()); + Claiming.remove(event.getEntity()); + } + @EventHandler public void onTpHome(ClansCommandExecutedEvent event) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java index 8db21cebf..fa6e8c14b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java @@ -4,6 +4,8 @@ import java.util.List; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClanTips.TipType; import mineplex.game.clans.clans.ClansManager; @@ -11,7 +13,6 @@ import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; -import org.bukkit.block.BlockState; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -35,6 +36,9 @@ public class NetherPortal implements Listener private boolean _returnPortal; private byte _portalFacing; + public boolean Open = false; + public long Expire = -1; + public NetherPortal(Location firstCorner, Location secondCorner, boolean returnPortal) { int maxX = Math.max(firstCorner.getBlockX(), secondCorner.getBlockX()); @@ -111,23 +115,39 @@ public class NetherPortal implements Listener } @SuppressWarnings("deprecation") - public void open() + public void open(long duration) { - Bukkit.getPluginManager().registerEvents(this, ClansManager.getInstance().getPlugin()); - for (Block block : _frame) + if (Open) { - block.setType(Material.OBSIDIAN); + if (Expire != -1) + { + Expire = Expire + duration; + } } - for (Block block : _portal) + else { - block.setType(Material.PORTAL); - block.setData(_portalFacing); - Bukkit.broadcastMessage("Creating Portal Piece"); + if (!_returnPortal) + { + Expire = System.currentTimeMillis() + duration; + } + Open = true; + Bukkit.getPluginManager().registerEvents(this, ClansManager.getInstance().getPlugin()); + for (Block block : _frame) + { + block.setType(Material.OBSIDIAN); + } + for (Block block : _portal) + { + block.setType(Material.PORTAL); + block.setData(_portalFacing); + } } } public void close() { + Open = false; + Expire = -1; HandlerList.unregisterAll(this); for (Block block : _portal) { @@ -188,7 +208,9 @@ public class NetherPortal implements Listener } else { - ClansManager.getInstance().getNetherManager().InNether.put((Player)event.getEntity(), System.currentTimeMillis()); + ClansManager.getInstance().getNetherManager().InNether.put((Player)event.getEntity(), Expire); + Location from = event.getEntity().getLocation(); + ClansManager.getInstance().getNetherManager().OverworldOrigins.put((Player)event.getEntity(), from); event.getEntity().teleport(ClansManager.getInstance().getNetherManager().getNetherWorld().getSpawnLocation()); ClansManager.getInstance().ClanTips.displayTip(TipType.ENTER_NETHER, (Player)event.getEntity()); } @@ -206,4 +228,17 @@ public class NetherPortal implements Listener event.setCancelled(true); } } + + @EventHandler + public void handleExpiration(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + if (Open && Expire != -1 && System.currentTimeMillis() >= Expire) + { + close(); + } + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/CloseCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/CloseCommand.java index cfc778e90..d6a456fad 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/CloseCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/CloseCommand.java @@ -8,6 +8,9 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.game.clans.clans.nether.NetherManager; +/** + * Command to close all nether portals + */ public class CloseCommand extends CommandBase { public CloseCommand(NetherManager plugin) @@ -18,7 +21,7 @@ public class CloseCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - UtilPlayer.message(caller, F.main(Plugin.getName(), "Closing all " + F.clansNether("Nether Portals" + "!"))); + UtilPlayer.message(caller, F.main(Plugin.getName(), "Closing all " + F.clansNether("Nether Portals") + "!")); Plugin.closePortals(); } } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/CreateCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/CreateCommand.java index 0fe76df8b..c7395e4f3 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/CreateCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/CreateCommand.java @@ -8,6 +8,9 @@ import mineplex.game.clans.clans.nether.NetherManager; import org.bukkit.entity.Player; +/** + * Command to create a nether portal + */ public class CreateCommand extends CommandBase { public CreateCommand(NetherManager plugin) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/DeleteCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/DeleteCommand.java index ebbc9dec8..2b6ac0f41 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/DeleteCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/DeleteCommand.java @@ -8,6 +8,9 @@ import mineplex.game.clans.clans.nether.NetherManager; import org.bukkit.entity.Player; +/** + * Command to delete a nether portal + */ public class DeleteCommand extends CommandBase { public DeleteCommand(NetherManager plugin) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/ForceTeleportCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/ForceTeleportCommand.java new file mode 100644 index 000000000..5640d6526 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/ForceTeleportCommand.java @@ -0,0 +1,63 @@ +package mineplex.game.clans.clans.nether.command; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.game.clans.clans.ClanTips.TipType; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.nether.NetherManager; +import mineplex.game.clans.spawn.Spawn; + +import org.bukkit.entity.Player; + +/** + * Command to artificially portal + */ +public class ForceTeleportCommand extends CommandBase +{ + public ForceTeleportCommand(NetherManager plugin) + { + super(plugin, Rank.ADMIN, "forcePortal"); + } + + @Override + public void Execute(Player caller, String[] args) + { + boolean natural = false; + + if (args.length > 0 && (args[0].equalsIgnoreCase("true") || args[0].equalsIgnoreCase("false"))) + { + natural = Boolean.parseBoolean(args[0]); + } + + if (Plugin.isInNether(caller)) + { + if (natural) + { + Plugin.InNether.remove(caller); + caller.teleport(Plugin.getReturnLocation(caller)); + Plugin.OverworldOrigins.remove(caller); + UtilPlayer.message(caller, F.main(ClansManager.getInstance().getNetherManager().getName(), "You have escaped " + F.clansNether("The Nether") + "!")); + } + else + { + caller.teleport(Spawn.getNorthSpawn()); + } + } + else + { + if (natural) + { + Plugin.InNether.put(caller, System.currentTimeMillis()); + Plugin.OverworldOrigins.put(caller, caller.getLocation()); + caller.teleport(Plugin.getNetherWorld().getSpawnLocation()); + ClansManager.getInstance().ClanTips.displayTip(TipType.ENTER_NETHER, caller); + } + else + { + caller.teleport(Plugin.getNetherWorld().getSpawnLocation()); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/ListCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/ListCommand.java index b9bc31495..d475cf342 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/ListCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/ListCommand.java @@ -6,6 +6,9 @@ import mineplex.game.clans.clans.nether.NetherManager; import org.bukkit.entity.Player; +/** + * Command to list all nether portals + */ public class ListCommand extends CommandBase { public ListCommand(NetherManager plugin) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/PortalCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/PortalCommand.java index b0c0f1551..f39d5276f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/PortalCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/PortalCommand.java @@ -8,6 +8,9 @@ import mineplex.game.clans.clans.nether.NetherManager; import org.bukkit.entity.Player; +/** + * Base portal command + */ public class PortalCommand extends MultiCommandBase { public PortalCommand(NetherManager plugin) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/SpawnCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/SpawnCommand.java index 9ab0efd52..2763dff60 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/SpawnCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/SpawnCommand.java @@ -8,6 +8,9 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.game.clans.clans.nether.NetherManager; +/** + * Command to open a nether portal + */ public class SpawnCommand extends CommandBase { public SpawnCommand(NetherManager plugin) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/WandCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/WandCommand.java index 2e1bced57..ef57df1db 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/WandCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/WandCommand.java @@ -6,6 +6,9 @@ import mineplex.game.clans.clans.nether.NetherManager; import org.bukkit.entity.Player; +/** + * Command to give yourself a portal creation wand + */ public class WandCommand extends CommandBase { public WandCommand(NetherManager plugin) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/data/ClaimData.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/data/ClaimData.java index 2549921c9..96570e1be 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/data/ClaimData.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/data/ClaimData.java @@ -2,20 +2,35 @@ package mineplex.game.clans.clans.nether.data; import org.bukkit.block.Block; +/** + * Data class to hold specified player portal corners + */ public class ClaimData { private Block _first, _second; + /** + * Fetches the first selected corner + * @return The first selected corner + */ public Block getFirstCorner() { return _first; } + /** + * Fetches the second selected corner + * @return The second selected corner + */ public Block getSecondCorner() { return _second; } + /** + * Fetches the total count of selected corners + * @return The number of selected corners + */ public int getTotalSelected() { int total = 2; @@ -31,11 +46,19 @@ public class ClaimData return total; } + /** + * Sets the first selected corner + * @param block The block to set the corner to + */ public void setFirstCorner(Block block) { _first = block; } + /** + * Sets the first selected corner + * @param block The block to set the corner to + */ public void setSecondCorner(Block block) { _second = block; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossManager.java index e52e58967..d486c3188 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossManager.java @@ -19,7 +19,7 @@ import com.google.common.collect.Lists; public class NetherMinibossManager implements Listener { - private static final long TIME_BETWEEN_MINIBOSS_TARGET_PLAYER = 5000; + private static final long TIME_BETWEEN_MINIBOSS_TARGET_PLAYER = 10000; private NetherManager _manager; private boolean _allowSpawn = false; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/ArcherMiniboss.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/ArcherMiniboss.java index 73b6841db..d41f3f8e1 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/ArcherMiniboss.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/ArcherMiniboss.java @@ -27,6 +27,9 @@ import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; +/** + * Class for running an individual Archer miniboss + */ public class ArcherMiniboss extends NetherMiniBoss { private static final int BARBED_LEVEL = 1; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/GhastMiniboss.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/GhastMiniboss.java index 15c642384..800106b0d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/GhastMiniboss.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/GhastMiniboss.java @@ -14,6 +14,9 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.entity.ProjectileLaunchEvent; import org.bukkit.inventory.ItemStack; +/** + * Class for running an individual Ghast miniboss + */ public class GhastMiniboss extends NetherMiniBoss { private static final long MAIN_FIREBALL_COOLDOWN = 5000; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/PigmanMiniboss.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/PigmanMiniboss.java index 2cc84b4aa..1e15f0758 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/PigmanMiniboss.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/PigmanMiniboss.java @@ -11,6 +11,9 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.PigZombie; import org.bukkit.event.EventHandler; +/** + * Class for running an individual Pigman miniboss + */ public class PigmanMiniboss extends NetherMiniBoss { private static final double IRON_SKIN_CHANCE = .33; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/WarriorMiniboss.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/WarriorMiniboss.java index 8d8a8fc17..2e275f6e4 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/WarriorMiniboss.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/WarriorMiniboss.java @@ -26,6 +26,9 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; +/** + * Class for running an individual Warrior miniboss + */ public class WarriorMiniboss extends NetherMiniBoss { public WarriorMiniboss(String displayName, Double maxHealth, Location spawn, EntityType type) From e5cd38c11b229965308bc3651fd38c4301fd3525 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 21 Jul 2016 05:20:47 -0400 Subject: [PATCH 33/90] Revert enjin changes --- Plugins/Mineplex.EnjinTranslator/plugin.yml | 4 - .../src/mineplex/enjinTranslator/Enjin.java | 9 +- .../game/games/minestrike/Minestrike.java | 1347 ----------------- 3 files changed, 1 insertion(+), 1359 deletions(-) delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/Minestrike.java diff --git a/Plugins/Mineplex.EnjinTranslator/plugin.yml b/Plugins/Mineplex.EnjinTranslator/plugin.yml index e3996d524..ef3eac20a 100644 --- a/Plugins/Mineplex.EnjinTranslator/plugin.yml +++ b/Plugins/Mineplex.EnjinTranslator/plugin.yml @@ -6,10 +6,6 @@ commands: description: Translates enjin commands to mineplex. usage: Don't use it, you get kicked. aliases: - enjin_clans: - description: Translates enjin commands to mineplex. - usage: Don't use it, you get kicked. - aliases: pull: description: Translates enjin commands to mineplex. usage: Don't use it, you get kicked. diff --git a/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java b/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java index d1887f960..3c569acb1 100644 --- a/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java +++ b/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java @@ -55,7 +55,6 @@ public class Enjin extends MiniPlugin implements CommandExecutor plugin.getCommand("enjin_mineplex").setExecutor(this); plugin.getCommand("pull").setExecutor(this); - plugin.getCommand("enjin_clans").setExecutor(this); } @EventHandler @@ -82,13 +81,7 @@ public class Enjin extends MiniPlugin implements CommandExecutor { if (sender instanceof Player) ((Player)sender).kickPlayer("Like bananas? I don't. Here take these and go have fun."); - - if (label.equalsIgnoreCase("enjin_clans")) - { - String clansServer = args[0]; - Long minutes = Long.parseLong(args[1]); - } - + if (label.equalsIgnoreCase("enjin_mineplex")) { final String name = args[1]; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/Minestrike.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/Minestrike.java deleted file mode 100644 index 862ead445..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/Minestrike.java +++ /dev/null @@ -1,1347 +0,0 @@ -package nautilus.game.arcade.game.games.minestrike; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Color; -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.craftbukkit.v1_8_R3.entity.CraftPlayer; -import org.bukkit.entity.Entity; -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.inventory.InventoryClickEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerMoveEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.LeatherArmorMeta; -import org.bukkit.scoreboard.DisplaySlot; -import org.bukkit.scoreboard.NameTagVisibility; -import org.bukkit.scoreboard.Objective; -import org.bukkit.scoreboard.Team; -import org.bukkit.util.Vector; - -import mineplex.core.common.util.C; -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.UtilGear; -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.common.util.UtilTime; -import mineplex.core.common.util.UtilEvent.ActionType; -import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.gamemodifiers.GameModifierType; -import mineplex.core.gadget.gadgets.gamemodifiers.minestrike.GameModifierMineStrikeSkin; -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.combat.event.CombatDeathEvent; -import mineplex.minecraft.game.core.condition.Condition.ConditionType; -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.events.PlayerKitGiveEvent; -import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.game.TeamGame; -import nautilus.game.arcade.game.GameTeam.PlayerState; -import nautilus.game.arcade.game.games.minestrike.GunModule.RoundOverEvent; -import nautilus.game.arcade.game.games.minestrike.data.Bomb; -import nautilus.game.arcade.game.games.minestrike.items.guns.Gun; -import nautilus.game.arcade.game.games.minestrike.items.guns.GunStats; -import nautilus.game.arcade.game.games.minestrike.kits.KitPlayer; -import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.managers.chat.ChatStatData; -import nautilus.game.arcade.stats.KaboomStatTracker; -import nautilus.game.arcade.stats.KillAllOpposingMineStrikeRoundStatTracker; -import nautilus.game.arcade.stats.KillFastStatTracker; -import nautilus.game.arcade.stats.KillReasonStatTracker; -import nautilus.game.arcade.stats.KillsWithConditionStatTracker; -import nautilus.game.arcade.stats.MineStrikeGunStats; -import nautilus.game.arcade.stats.MineStrikeLastAliveKillStatTracker; -import nautilus.game.arcade.stats.TeamDeathsStatTracker; -import nautilus.game.arcade.stats.TeamKillsStatTracker; - -/** - * Minestrike - * - * @author xXVevzZXx - */ -public class Minestrike extends TeamGame -{ - - //Managers - private ShopManager _shopManager; - - //Data - private int _roundsToWin = 8; - private long _roundTime = 120000; - - //Round Data - private String _winText = null; - private boolean _roundOver = false; - - //Money Data - private boolean _bombPlanted = false; - private boolean _ctWonLast = false; - private int _winStreak = 0; - - private HashMap _score = new HashMap(); - - //Map Data - private ArrayList _bombSites; - - private Player _bombPlanter; - private Player _bombDefuser; - private Player _bombPlantedBy; - - private boolean _bombScoreboardFlash = false; - - private GunModule _gunModule; - - //Scoreboard - private Objective _scoreObj; - - public Minestrike(ArcadeManager manager) - { - super(manager, GameType.MineStrike, - - new Kit[] - { - new KitPlayer(manager), - }, - - new String[] - { - C.cAqua + "SWAT" + C.cWhite + " Defend the Bomb Sites", - C.cAqua + "SWAT" + C.cWhite + " Kill the Bombers", - " ", - C.cRed + "Bombers" + C.cWhite + " Plant the Bomb at Bomb Site", - C.cRed + "Bombers" + C.cWhite + " Kill the SWAT Team", - }); - - _shopManager = new ShopManager(this); - Manager.getCosmeticManager().setHideParticles(true); - - this.StrictAntiHack = true; - - AnnounceStay = false; - - this.HungerSet = 20; - - this.ItemDrop = true; - - this.DeathTeleport = false; - - this.InventoryClick = true; - - this.JoinInProgress = true; - - this.DontAllowOverfill = true; - - _scoreObj = Scoreboard.GetScoreboard().registerNewObjective("HP", "dummy"); - _scoreObj.setDisplaySlot(DisplaySlot.BELOW_NAME); - - this._help = new String[] - { - //"Tap Crouch when close to an ally to Boost", - "Open Inventory at spawn to buy guns", - "Hold Right-Click to Plant Bomb", - "Look at the Bomb to Defuse it", - "Moving decreases accuracy", - "Sprinting heavily decreases accuracy", - "Jumping massively decreases accuracy", - "Crouching increases accuracy", - "Left-Click to drop Grenades", - "Right-Click to throw Grenades", - "Burst Fire for greater accuracy", - "Sniper Rifles are only accurate while scoped", - "Rifles have 30% recoil reduction while scoped", - "Pick up better weapons from dead players" - }; - - registerStatTrackers( - new KillReasonStatTracker(this, "Headshot", "BoomHeadshot", true), - new KillAllOpposingMineStrikeRoundStatTracker(this), - new KaboomStatTracker(this), - new KillReasonStatTracker(this, "Backstab", "Assassination", false), - new MineStrikeLastAliveKillStatTracker(this), - new KillFastStatTracker(this, 4, 5, "KillingSpree"), - new KillsWithConditionStatTracker(this, "Blindfolded", ConditionType.BLINDNESS, "Flash Bang", 2), - - new TeamDeathsStatTracker(this), - new TeamKillsStatTracker(this), - - new MineStrikeGunStats(this) - ); - - registerChatStats( - Kills, - Deaths, - KDRatio, - BlankLine, - new ChatStatData("BoomHeadshot", "Headshots", true), - Assists - ); - - _gunModule = new GunModule(this); - } - - @EventHandler - public void CustomTeamGeneration(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Recruit) - return; - - this.GetTeamList().get(0).SetColor(ChatColor.AQUA); - this.GetTeamList().get(0).SetName("SWAT"); - - this.GetTeamList().get(1).SetColor(ChatColor.RED); - this.GetTeamList().get(1).SetName("Bombers"); - } - - @EventHandler - public void SetScoreboardNameVisibility(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Prepare) - return; - - System.out.println("Hiding Scoreboard Nametags for Other Teams"); - for (Team curTeam : Scoreboard.GetScoreboard().getTeams()) - { - curTeam.setNameTagVisibility(NameTagVisibility.HIDE_FOR_OTHER_TEAMS); - //UtilServer.getServer().dispatchCommand(UtilServer.getServer().getConsoleSender(), - // "scoreboard teams option " + curTeam.getName() + " nametagVisibility hideForOtherTeams"); - } - } - - @Override - public void ParseData() - { - _bombSites = WorldData.GetDataLocs("RED"); - } - - @EventHandler - public void giveStartEquipment(PlayerKitGiveEvent event) - { - GameTeam team = GetTeam(event.getPlayer()); - if (team == null) - return; - - GadgetManager gadgetManager = Manager.getCosmeticManager().getGadgetManager(); - GameModifierMineStrikeSkin knifeSkin = (GameModifierMineStrikeSkin) gadgetManager.getActiveGameModifier(event.getPlayer(), - GameModifierType.MineStrike, GameModifierMineStrikeSkin.getWeaponFilter("Knife")); - - Material mat = Material.IRON_AXE; - byte data = 0; - String name = "Knife"; - - if(knifeSkin != null) - { - mat = knifeSkin.getSkinMaterial(); - data = knifeSkin.getSkinData(); - name = knifeSkin.getName(); - } - - ItemStack knife = ItemStackFactory.Instance.CreateStack(mat, data, 1, name); - - if (team.GetColor() == ChatColor.RED) - { - if (IsAlive(event.getPlayer())) - { - //Pistol - Gun gun = new Gun(GunStats.GLOCK_18, _gunModule); - _gunModule.registerGun(gun, event.getPlayer()); - gun.giveToPlayer(event.getPlayer(), true); - gun.updateSkin(event.getPlayer(), getArcadeManager().getCosmeticManager().getGadgetManager()); - gun.updateWeaponName(event.getPlayer(), _gunModule); - - //Knife - if(knifeSkin == null) knife.setType(Material.IRON_AXE); - - event.getPlayer().getInventory().setItem(2, knife); - - //Armor - giveTeamArmor(event.getPlayer(), Color.fromRGB(255, 75, 75)); - } - } - else if (team.GetColor() == ChatColor.AQUA) - { - if (IsAlive(event.getPlayer())) - { - //Pistol - Gun gun = new Gun(GunStats.P2000, _gunModule); - _gunModule.registerGun(gun, event.getPlayer()); - gun.giveToPlayer(event.getPlayer(), true); - gun.updateWeaponName(event.getPlayer(), _gunModule); - gun.updateSkin(event.getPlayer(), getArcadeManager().getCosmeticManager().getGadgetManager()); - - //Knife - if(knifeSkin == null) knife.setType(Material.IRON_SWORD); - - event.getPlayer().getInventory().setItem(2, knife); - - //Armor - giveTeamArmor(event.getPlayer(), Color.fromRGB(125, 200, 255)); - } - } - - //Enter Shop - _shopManager.enterShop(event.getPlayer()); - } - - public void giveTeamArmor(Player player, Color color) - { - ItemStack armor = new ItemStack(Material.LEATHER_CHESTPLATE); - LeatherArmorMeta meta = (LeatherArmorMeta)armor.getItemMeta(); - meta.setColor(color); - armor.setItemMeta(meta); - player.getInventory().setChestplate(armor); - - ItemStack legs = new ItemStack(Material.LEATHER_LEGGINGS); - LeatherArmorMeta metaLegs = (LeatherArmorMeta)legs.getItemMeta(); - metaLegs.setColor(color); - legs.setItemMeta(metaLegs); - player.getInventory().setLeggings(legs); - - ItemStack boots = new ItemStack(Material.LEATHER_BOOTS); - LeatherArmorMeta metaBoots = (LeatherArmorMeta)boots.getItemMeta(); - metaBoots.setColor(color); - boots.setItemMeta(metaBoots); - player.getInventory().setBoots(boots); - } - - @EventHandler - public void shopInventoryClick(InventoryClickEvent event) - { - _shopManager.inventoryClick(event); - } - - @EventHandler - public void shopUpdate(UpdateEvent event) - { - if (event.getType() != UpdateType.SEC) - return; - - _shopManager.update(); - } - - @EventHandler - public void quitClean(PlayerQuitEvent event) - { - _shopManager.leaveShop(event.getPlayer(), false, true); - _gunModule.undisguise(event.getPlayer()); - _gunModule.removeScope(event.getPlayer()); - _gunModule.dropInventory(event.getPlayer()); - } - - @EventHandler - public void giveBombInitial(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Prepare) - return; - - UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() - { - public void run() - { - Player player = UtilAlg.Random(GetTeam(ChatColor.RED).GetPlayers(true)); - - _gunModule.giveBombToPlayer(player); - } - }, 40); - } - - - @EventHandler - public void killReward(CombatDeathEvent event) - { - if (!(event.GetEvent().getEntity() instanceof Player)) - return; - - Player killed = (Player)event.GetEvent().getEntity(); - - if (event.GetLog().GetKiller() != null) - { - Player killer = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName()); - - if (killer == null || killer.equals(killed)) - return; - - if (GetTeam(killed).equals(GetTeam(killer))) - return; - - int amount = 300; - - if (event.GetLog().GetLastDamager().GetReason().contains("AWP")) - amount = 100; - - else if (event.GetLog().GetLastDamager().GetReason().contains("PP-Bizon")) - amount = 600; - - else if (event.GetLog().GetLastDamager().GetReason().contains("Nova")) - amount = 900; - - else if (event.GetLog().GetLastDamager().GetReason().contains("Knife")) - amount = 1500; - - _shopManager.addMoney(killer, amount, "kill with " + event.GetLog().GetLastDamager().GetReason()); - - /* - if(event.GetLog().GetLastDamager().GetReason().contains("Knife")) - { - GadgetManager gadgetManager = Manager.getCosmeticManager().getGadgetManager(); - GameModifierMineStrikeSkin knifeSkin = (GameModifierMineStrikeSkin) gadgetManager.getActiveGameModifier(event.getPlayer(), - GameModifierType.MineStrike, GameModifierMineStrikeSkin.getWeaponFilter("Knife")); - - if(knifeSkin != null) - { - int kills = GetStats().get(killer).get("") - ItemStack item = killer.getInventory().getItem(2); - ItemMeta im = item.getItemMeta(); - im.setDisplayName(C.cYellow + C.Bold + knifeSkin.GetName() + " - Kills: " + kills); - - AddStat(killer, "Knife." + knifeSkin.GetName() + ".Kills", 1, false, false); - } - } - */ - } - } - - @EventHandler - public void plantBomb(PlayerInteractEvent event) - { - Player player = event.getPlayer(); - - if (!UtilGear.isMat(player.getItemInHand(), Material.GOLD_SWORD)) - return; - - // Fixed bomb able to be planted after the round is over. - if (_roundOver) - { - UtilPlayer.message(player, F.main("Game", "You cannot plant the bomb once the round is over.")); - event.setCancelled(true); - return; - } - - // Added a small tip for players that are trying to right-click with the bomb. - if (UtilEvent.isAction(event, ActionType.L)) - { - UtilPlayer.message(player, F.main("Game", "You must " + F.elem("Right-Click") + " while holding the bomb to plant it.")); - event.setCancelled(true); - return; - } - - if (!UtilEnt.isGrounded(player)) - { - UtilPlayer.message(player, F.main("Game", "You can only plant the bomb on the ground.")); - event.setCancelled(true); - return; - } - - //Should never occur with 1 Bomb - if (_bombPlanter != null) - { - UtilPlayer.message(player, F.main("Game", "Someone else is planting the bomb.")); - event.setCancelled(true); - return; - } - - //Check Bomb Sites - boolean near = false; - for (Location loc : _bombSites) - { - if (UtilMath.offset(player.getLocation(), loc) < 5) - { - near = true; - break; - } - } - - //Too Far - if (!near) - { - UtilPlayer.message(player, F.main("Game", "You can only plant the bomb at a bomb site.")); - event.setCancelled(true); - return; - } - - _bombPlanter = player; - _bombPlanter.setExp(0f); - - UtilPlayer.message(player, F.main("Game", "You are now placing the bomb.")); - - //Radio - _gunModule.playSound(Radio.T_BOMB_PLANT, null, GetTeam(_bombPlanter)); - } - - @EventHandler - public void plantBombUpdate(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; - - // Added to check if the round is over when a bomb is being planted. - if (_roundOver) - return; - - if (_bombPlanter == null) - return; - - if (!_bombPlanter.isBlocking() || !_bombPlanter.isOnline()) - { - _bombPlanter.setExp(0f); - UtilTextMiddle.clear(_bombPlanter); - _bombPlanter = null; - return; - } - - _bombPlanter.setExp(Math.min(_bombPlanter.getExp() + 0.017f, 0.99999f)); - - if (Math.random() > 0.90) - _bombPlanter.getWorld().playSound(_bombPlanter.getLocation(), Sound.NOTE_PLING, 2f, 3f); - - UtilTextMiddle.display(C.cRed + C.Bold + "Planting Bomb", UtilTextMiddle.progress(_bombPlanter.getExp()), 0, 10, 0, _bombPlanter); - - if (_bombPlanter.getExp() >= 0.98f) - { - _gunModule.setBomb(new Bomb(_bombPlanter)); - - _shopManager.addMoney(_bombPlanter, 300, "planting the bomb"); - - Announce(C.cRed + C.Bold + _bombPlanter.getName() + " has planted the bomb!"); - - _bombPlantedBy = _bombPlanter; - - _bombPlanter.setExp(0f); - _bombPlanter.setItemInHand(null); - _bombPlanter = null; - _gunModule.setBombHolder(null); - - //Sound - _gunModule.playSound(Radio.BOMB_PLANT, null, null); - - //Title - UtilTextMiddle.display(null, C.cRed + C.Bold + "Bomb has been planted!", 10, 50, 10); - } - } - - @EventHandler - public void plantDefuseBombRestrictMovement(PlayerMoveEvent event) - { - if (_bombPlanter != null && _bombPlanter.equals(event.getPlayer())) - if (UtilMath.offset(event.getFrom(), event.getTo()) > 0) - event.setTo(event.getFrom()); - - // if (_bombDefuser != null && _bombDefuser.equals(event.getPlayer())) - // if (UtilMath.offset(event.getFrom(), event.getTo()) > 0) - // event.setTo(event.getFrom()); - } - - @EventHandler - public void defuseKitMessage(PlayerInteractEvent event) - { - Player player = event.getPlayer(); - - if (!UtilGear.isMat(player.getItemInHand(), Material.SHEARS)) - return; - - UtilPlayer.message(player, F.main("Game", "Look at the Bomb to defuse it.")); - } - - public void startDefuse() - { - for (Player player : GetTeam(ChatColor.AQUA).GetPlayers(true)) - { - HashSet ignoreBlocks = new HashSet(); - ignoreBlocks.add(Material.AIR); - ignoreBlocks.add(Material.PORTAL); - - Block block = player.getTargetBlock(ignoreBlocks, 5); - - if (block == null || !_gunModule.getBomb().isBlock(block)) - continue; - - if (UtilMath.offset(player.getLocation(), block.getLocation().add(0.5, 0, 0.5)) > 3) - continue; - - if (_bombDefuser != null) - { - if (Recharge.Instance.use(player, "Defuse Message", 2000, false, false)) - UtilPlayer.message(player, F.main("Game", _bombDefuser.getName() + " is already defusing the Bomb.")); - - continue; - } - - _bombDefuser = player; - _bombDefuser.setExp(0f); - - UtilPlayer.message(player, F.main("Game", "You are defusing the Bomb.")); - - _bombDefuser.getWorld().playSound(_bombDefuser.getLocation(), Sound.PISTON_RETRACT, 2f, 1f); - } - } - - @EventHandler - public void defuseBombUpdate(UpdateEvent event) - { - if (_gunModule.getBomb() == null) - return; - - if (!IsLive()) - return; - - if (event.getType() != UpdateType.TICK) - return; - - if (_bombDefuser == null) - { - startDefuse(); - } - - if (_bombDefuser == null) - return; - - HashSet ignoreBlocks = new HashSet(); - ignoreBlocks.add(Material.AIR); - ignoreBlocks.add(Material.PORTAL); - - Block block = _bombDefuser.getTargetBlock(ignoreBlocks, 5); - - if (!IsAlive(_bombDefuser) || block == null || !_gunModule.getBomb().isBlock(block) || !_bombDefuser.isOnline() || UtilMath.offset(_bombDefuser.getLocation(), block.getLocation().add(0.5, 0, 0.5)) > 3) - { - _bombDefuser.setExp(0f); - _bombDefuser = null; - return; - } - - //Kit or Not? - float defuseRate = 0.005f; - if (UtilGear.isMat(_bombDefuser.getInventory().getItem(8), Material.SHEARS)) - defuseRate = 0.01f; - - _bombDefuser.setExp(Math.min(_bombDefuser.getExp() + defuseRate, 0.99999f)); - - UtilTextMiddle.display(C.cAqua + C.Bold + "Defusing Bomb", UtilTextMiddle.progress(_bombDefuser.getExp()), 0, 10, 0, _bombDefuser); - - if (_bombDefuser.getExp() >= 0.98f) - { - _gunModule.getBomb().defuse(); - - _winText = _bombDefuser.getName() + " defused the bomb!"; - - _gunModule.setBomb(null); - _bombDefuser.setExp(0f); - _bombDefuser = null; - - //Sound - _gunModule.playSound(Radio.BOMB_DEFUSE, null, null); - - setWinner(GetTeam(ChatColor.AQUA), true); - } - } - - @EventHandler - public void bombUpdate(UpdateEvent event) - { - if (!IsLive()) - return; - - if (event.getType() != UpdateType.TICK) - return; - - if (_gunModule.getBomb() == null) - return; - - if (!_gunModule.getBomb().update()) - return; - - /* - Set blocks = UtilBlock.getInRadius(_bomb.Block.getLocation(), 10d).keySet(); - - Iterator blockIterator = blocks.iterator(); - while (blockIterator.hasNext()) - { - Block block = blockIterator.next(); - - if (block.getY() < 2) - blockIterator.remove(); - } - - Manager.GetExplosion().BlockExplosion(blocks, _bomb.Block.getLocation(), false); - */ - - - HashMap players = UtilPlayer.getInRadius(_gunModule.getBomb().Block.getLocation(), 48); - for (Player player : players.keySet()) - { - if (!IsAlive(player)) - continue; - - // Damage Event - Manager.GetDamage().NewDamageEvent(player, null, null, - DamageCause.CUSTOM, 1 + (players.get(player) * 40), - true, true, false, "Bomb", "C4 Explosion"); - } - - - _gunModule.setBomb(null); - - _winText = _bombPlantedBy.getName() + " destroyed the bomb site!"; - - setWinner(GetTeam(ChatColor.RED), false); - } - - public int getScore(GameTeam team) - { - if (!_score.containsKey(team)) - _score.put(team, 0); - - return _score.get(team); - } - - public void addScore(GameTeam team) - { - _score.put(team, getScore(team) + 1); - } - - @EventHandler - public void roundTimerUpdate(UpdateEvent event) - { - if (!IsLive()) - return; - - if (event.getType() != UpdateType.TICK) - return; - - if (_gunModule.getBomb() != null) - return; - - if (UtilTime.elapsed(GetStateTime(), _roundTime)) - { - _winText = "Bomb sites were successfully defended!"; - drawScoreboard(); - setWinner(GetTeam(ChatColor.AQUA), false); - } - } - - @EventHandler - public void roundPlayerCheck(UpdateEvent event) - { - if (!IsLive()) - return; - - if (event.getType() != UpdateType.TICK) - return; - - ArrayList teamsAlive = new ArrayList(); - - for (GameTeam team : this.GetTeamList()) - if (team.GetPlayers(true).size() > 0) - teamsAlive.add(team); - - if (teamsAlive.size() == 1) - { - //Bomb Planted - CT cannot win without defusing - if (_gunModule.getBomb() != null) - { - if (teamsAlive.size() > 0) - { - if (teamsAlive.get(0).GetColor() == ChatColor.AQUA) - { - return; - } - } - } - - setWinner(teamsAlive.get(0), false); - } - else if (teamsAlive.size() == 0) - { - if (_gunModule.getBomb() == null) - { - _winText = "Bomb sites were successfully defended!"; - setWinner(GetTeam(ChatColor.AQUA), false); - } - else - { - _winText = "Bomb site will be destroyed!"; - setWinner(GetTeam(ChatColor.RED), false); - } - } - } - - public void setWinner(final GameTeam winner, boolean defuse) - { - if (_roundOver) - return; - - Bukkit.getPluginManager().callEvent(new RoundOverEvent(this)); - - _roundOver = true; - - String winnerLine = C.Bold + "The round was a draw!"; - ChatColor color = ChatColor.GRAY; - if (winner != null) - { - if(winner.GetName().contains("Bombers")) { - winnerLine= winner.GetColor() + C.Bold + winner.GetName() + " have won the round!"; - } else { - winnerLine= winner.GetColor() + C.Bold + winner.GetName() + " has won the round!"; - } - addScore(winner); - drawScoreboard(); - color = winner.GetColor(); - - - } - - //Sound - if (winner != null) - { - UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() - { - public void run() - { - if (winner.GetColor() == ChatColor.RED) - _gunModule.playSound(Radio.T_WIN, null, null); - else - _gunModule.playSound(Radio.CT_WIN, null, null); - } - }, defuse ? 60 : 0); - } - - //Record Streak for Money - if (winner.GetColor() == ChatColor.RED) - { - _winStreak++; - - if (_ctWonLast) - { - _ctWonLast = false; - _winStreak = 0; - } - } - else - { - _winStreak++; - - if (!_ctWonLast) - { - _ctWonLast = true; - _winStreak = 0; - } - } - - //Announce - Announce("", false); - Announce(color + "===================================", false); - Announce("", false); - Announce(winnerLine, false); - if (_winText != null) - Announce(_winText, false); - Announce("", false); - Announce(color + "===================================", false); - - for (Player player : UtilServer.getPlayers()) - { - player.playSound(player.getLocation(), Sound.LEVEL_UP, 1f, 1f); - _gunModule.removeScope(player); - - Recharge.Instance.Reset(player, "reload"); - } - - UtilTextMiddle.display(null, winnerLine, 20, 120, 20); - - //Check for total game win - EndCheck(); - - //Next Round (if not over) - if (IsLive()) - { - UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() - { - public void run() - { - restartRound(); - } - }, 100); - } - } - - public void restartRound() - { - giveMoney(); - - //Clean - resetGame(); - - //Teleport to Spawn - for (GameTeam team : GetTeamList()) - team.SpawnTeleport(false); - - //Revive Dead Players - for (Player player : GetPlayers(false)) - if (!IsAlive(player)) - { - SetPlayerState(player, PlayerState.IN); - - GameTeam team = GetTeam(player); - - //Teleport - team.SpawnTeleport(player); - - Manager.Clear(player); - UtilInv.Clear(player); - - ValidateKit(player, GetTeam(player)); - - if (GetKit(player) != null) - GetKit(player).ApplyKit(player); - } - - //Remove Scope - for (Player player : GetPlayers(false)) - _gunModule.removeScope(player); - - //Get Hit By Bullets - for (Player player : GetPlayers(false)) - ((CraftPlayer) player).getHandle().spectating = false; - - //Prepare Sound - for (Player player : GetPlayers(false)) - { - player.playSound(player.getLocation(), Sound.HORSE_ARMOR, 1f, 2f); - Manager.GetCondition().Factory().Blind("Respawn", player, null, 2, 0, false, false, false); - UtilPlayer.message(player, F.main("Game", "You have " + F.elem(C.cGreen + "$" + _shopManager.getMoney(player)) + ". Open your Inventory to spend it.")); - - UtilTextMiddle.display(C.cGreen + "$" + _shopManager.getMoney(player), "Open your Inventory to buy new equipment", 10, 120, 10, player); - } - - //Update Scoreboard Teams - for (GameTeam team : GetTeamList()) - for (Player teamMember : team.GetPlayers(true)) - GetScoreboard().SetPlayerTeam(teamMember, team.GetName().toUpperCase()); - - //Alternate Bullets - if (_gunModule.BulletAlternate) - _gunModule.BulletInstant = (_gunModule.BulletInstant + 1)%3; - - //Debug Details - if (_gunModule.Debug) - { - Announce(C.cDPurple + C.Bold + "ROUND SETTINGS:"); - - if (_gunModule.CustomHitbox) - Announce(C.cPurple + C.Bold + "Hitbox: " + ChatColor.RESET + "Accurate with Headshots"); - else - Announce(C.cPurple + C.Bold + "Hitbox: " + ChatColor.RESET + "Default with No Headshot"); - - if (_gunModule.BulletInstant == 0) - Announce(C.cPurple + C.Bold + "Bullets: " + ChatColor.RESET + "Slow and Visible"); - else if (_gunModule.BulletInstant == 1) - Announce(C.cPurple + C.Bold + "Bullets: " + ChatColor.RESET + "Instant and Invisible"); - else - Announce(C.cPurple + C.Bold + "Bullets: " + ChatColor.RESET + "Slow and Visible with Instant Sniper"); - } - } - - public void giveMoney() - { - if (_ctWonLast) - { - int ctMoney = 3250; - int tMoney = 1400 + (Math.min(4,_winStreak) * 500); - - if (_bombPlanted) - { - ctMoney += 250; - tMoney += 800; - } - - //Award - for (Player player : GetTeam(ChatColor.RED).GetPlayers(false)) - _shopManager.addMoney(player, tMoney, "losing the round"); - - for (Player player : GetTeam(ChatColor.AQUA).GetPlayers(false)) - _shopManager.addMoney(player, ctMoney, "winning the round"); - } - else - { - int tMoney = 3250; - int ctMoney = 1400 + (Math.min(4,_winStreak) * 500); - - //Award - for (Player player : GetTeam(ChatColor.RED).GetPlayers(false)) - _shopManager.addMoney(player, tMoney, "winning the round"); - - for (Player player : GetTeam(ChatColor.AQUA).GetPlayers(false)) - _shopManager.addMoney(player, ctMoney, "losing the round"); - } - } - - public void resetGame() - { - //General - _roundOver = false; - SetStateTime(System.currentTimeMillis()); - _gunModule.setFreezeTime(10); - _winText = null; - - //Bomb - if (_gunModule.getBomb() != null) - _gunModule.getBomb().clean(); - - if (_gunModule.getBombItem() != null) - _gunModule.getBombItem().remove(); - - if (_gunModule.getBombHolder() != null) - { - _gunModule.getBombHolder().getInventory().remove(Material.GOLD_SWORD); - _gunModule.setBombHolder(null); - } - - _gunModule.setBomb(null); - _gunModule.setBombItem(null); - - _bombPlanter = null; - _bombDefuser = null; - _bombPlantedBy = null; - _bombPlanted = false; - - _gunModule.reset(); - - //Health - for (Player player : UtilServer.getPlayers()) - player.setHealth(20); - - //Reset Shop - for (Player player : UtilServer.getPlayers()) - _shopManager.leaveShop(player, false, false); - } - - @EventHandler(priority = EventPriority.HIGHEST) - public void specToTeam(PlayerJoinEvent event) - { - if (GetState() == GameState.Recruit || GetState() == GameState.Loading) - return; - - //Target Team - GameTeam targetTeam = null; - if (GetTeamList().get(0).GetPlayers(false).size() < GetTeamList().get(1).GetPlayers(false).size()) - targetTeam = GetTeamList().get(0); - else if (GetTeamList().get(0).GetPlayers(false).size() > GetTeamList().get(1).GetPlayers(false).size()) - targetTeam = GetTeamList().get(1); - else if (Math.random() > 0.5) - targetTeam = GetTeamList().get(1); - else - targetTeam = GetTeamList().get(0); - - SetPlayerTeam(event.getPlayer(), targetTeam, false); - - ((CraftPlayer) event.getPlayer()).getHandle().spectating = true; - } - - @EventHandler(priority = EventPriority.HIGHEST) - public void quitLeaveTeam(PlayerQuitEvent event) - { - GameTeam team = GetTeam(event.getPlayer()); - - if (team != null) - { - team.RemovePlayer(event.getPlayer()); - } - } - - @EventHandler - public void restartFreezeCountdown(UpdateEvent event) - { - if (event.getType() != UpdateType.SEC) - return; - - if (_gunModule.getFreezeTime() <= 0) - return; - - _gunModule.setFreezeTime(_gunModule.getFreezeTime() - 1); - - for (Player player : UtilServer.getPlayers()) - { - if (_gunModule.getFreezeTime() > 0) - player.playSound(player.getLocation(), Sound.NOTE_STICKS, 1f, 1f); - else - player.playSound(player.getLocation(), Sound.NOTE_SNARE_DRUM, 1f, 1f); - } - - if (_gunModule.getFreezeTime() == 0) - { - //Give Bomb - Player bombPlayer = UtilAlg.Random(GetTeam(ChatColor.RED).GetPlayers(true)); - _gunModule.giveBombToPlayer(bombPlayer); - - //Sound - _gunModule.playSound(Radio.CT_START, null, GetTeam(ChatColor.AQUA)); - _gunModule.playSound(Radio.T_START, null, GetTeam(ChatColor.RED)); - } - } - - @Override - @EventHandler - public void ScoreboardUpdate(UpdateEvent event) - { - if (event != null && event.getType() != UpdateType.FAST) - return; - - drawScoreboard(); - } - - public void drawScoreboard() - { - Scoreboard.Reset(); - - for (GameTeam team : this.GetTeamList()) - { - - Scoreboard.WriteBlank(); - - Scoreboard.Write(getScore(team) + " " + team.GetColor() + C.Bold + team.GetName()); - //Scoreboard.Write(team.GetColor() + "" + getScore(team) + "" + " Wins" + team.GetColor()); - Scoreboard.Write(team.GetPlayers(true).size() + "" + " Alive" + team.GetColor()); - - } - - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cGold + C.Bold + "Playing To"); - Scoreboard.Write(_roundsToWin + " Wins"); - - if (InProgress()) - { - Scoreboard.WriteBlank(); - - if (_gunModule.getBomb() == null) - { - Scoreboard.Write(C.cGold + C.Bold + "Time Left"); - Scoreboard.Write(UtilTime.MakeStr(_roundTime - (System.currentTimeMillis() - this.GetStateTime()), 1)); - } - else - { - if (_bombScoreboardFlash) - Scoreboard.Write(C.cRed + C.Bold + "Bomb Active"); - else - Scoreboard.Write(C.cWhite + C.Bold + "Bomb Active"); - - _bombScoreboardFlash = !_bombScoreboardFlash; - } - } - - - Scoreboard.Draw(); - } - - @Override - public void EndCheck() - { - endCheckScore(); - endCheckPlayer(); - } - - public void endCheckScore() - { - if (!IsLive()) - return; - - for (GameTeam team : GetTeamList()) - { - if (getScore(team) >= _roundsToWin) - { - //Announce - AnnounceEnd(team); - - for (GameTeam other : GetTeamList()) - { - if (WinnerTeam != null && other.equals(WinnerTeam)) - { - for (Player player : other.GetPlayers(false)) - AddGems(player, 10, "Winning Team", false, false); - } - - for (Player player : other.GetPlayers(false)) - if (player.isOnline()) - AddGems(player, 10, "Participation", false, false); - } - - //End - SetState(GameState.End); - } - } - } - - public void endCheckPlayer() - { - if (!IsLive()) - return; - - ArrayList teamsAlive = new ArrayList(); - - for (GameTeam team : this.GetTeamList()) - if (team.GetPlayers(false).size() > 0) - teamsAlive.add(team); - - if (teamsAlive.size() <= 1) - { - //Announce - if (teamsAlive.size() > 0) - AnnounceEnd(teamsAlive.get(0)); - - for (GameTeam team : GetTeamList()) - { - if (WinnerTeam != null && team.equals(WinnerTeam)) - { - for (Player player : team.GetPlayers(false)) - AddGems(player, 10, "Winning Team", false, false); - } - - for (Player player : team.GetPlayers(false)) - if (player.isOnline()) - AddGems(player, 10, "Participation", false, false); - } - - //End - SetState(GameState.End); - } - } - - @EventHandler - public void healthUpdate(UpdateEvent event) - { - if (!IsLive()) - return; - - if (event.getType() != UpdateType.SEC) - return; - - for (Player player : UtilServer.getPlayers()) - _scoreObj.getScore(player.getName()).setScore((int)(player.getHealth() * 5)); - } - - @EventHandler(priority = EventPriority.MONITOR) - public void damageHealth(CustomDamageEvent event) - { - Player player = event.GetDamagerPlayer(true); - if (player == null) - return; - - _scoreObj.getScore(player.getName()).setScore((int)(player.getHealth() * 5)); - } - - @EventHandler - public void debug(PlayerCommandPreprocessEvent event) - { - if (!event.getPlayer().isOp()) - return; - - if (event.getMessage().contains("money")) - { - _shopManager.addMoney(event.getPlayer(), 16000, "Debug"); - event.setCancelled(true); - } - } - - //Used for fire grenade spread - public int getRound() - { - int rounds = 0; - - for (int i : _score.values()) - rounds += i; - - return rounds; - } - - @Override - public Location GetSpectatorLocation() - { - if (SpectatorSpawn != null) - return SpectatorSpawn; - - Vector vec = new Vector(0, 0, 0); - double count = 0; - - for (GameTeam team : this.GetTeamList()) - { - for (Location spawn : team.GetSpawns()) - { - count++; - vec.add(spawn.toVector()); - } - } - - SpectatorSpawn = new Location(this.WorldData.World, 0, 0, 0); - - vec.multiply(1d / count); - - SpectatorSpawn.setX(vec.getX()); - SpectatorSpawn.setY(vec.getY() + 7); //ADD 7 - SpectatorSpawn.setZ(vec.getZ()); - - // Move Up - Out Of Blocks - while (!UtilBlock.airFoliage(SpectatorSpawn.getBlock()) - || !UtilBlock.airFoliage(SpectatorSpawn.getBlock().getRelative(BlockFace.UP))) - { - SpectatorSpawn.add(0, 1, 0); - } - - int Up = 0; - - // Move Up - Through Air - for (int i = 0; i < 15; i++) - { - if (UtilBlock.airFoliage(SpectatorSpawn.getBlock().getRelative(BlockFace.UP))) - { - SpectatorSpawn.add(0, 1, 0); - Up++; - } - else - { - break; - } - } - - // Move Down - Out Of Blocks - while (Up > 0 && !UtilBlock.airFoliage(SpectatorSpawn.getBlock()) - || !UtilBlock.airFoliage(SpectatorSpawn.getBlock().getRelative(BlockFace.UP))) - { - SpectatorSpawn.subtract(0, 1, 0); - Up--; - } - - SpectatorSpawn = SpectatorSpawn.getBlock().getLocation().add(0.5, 0.1, 0.5); - - while (SpectatorSpawn.getBlock().getTypeId() != 0 || SpectatorSpawn.getBlock().getRelative(BlockFace.UP).getTypeId() != 0) - SpectatorSpawn.add(0, 1, 0); - - return SpectatorSpawn; - } - - public GunModule getGunModule() - { - return _gunModule; - } -} \ No newline at end of file From 1f2b1557d513d0f4eac1a801f27bb4b5e6a9890a Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 21 Jul 2016 13:20:45 -0400 Subject: [PATCH 34/90] Work on amplifiers and deleting banners when the clan is deleted --- .../src/mineplex/game/clans/Clans.java | 4 +- .../game/clans/clans/ClansManager.java | 10 +- .../clans/clans/amplifiers/Amplifier.java | 13 ++ .../clans/clans/amplifiers/AmplifierGUI.java | 125 ++++++++++++++++++ .../clans/amplifiers/AmplifierManager.java | 54 +++++++- .../clans/clans/banners/BannerManager.java | 11 ++ .../clans/clans/banners/BannerRepository.java | 9 ++ .../clans/clans/banners/gui/BannerGUI.java | 1 + 8 files changed, 222 insertions(+), 5 deletions(-) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/Amplifier.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierGUI.java 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 6895d2741..7612eaf8a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java @@ -137,7 +137,7 @@ public class Clans extends JavaPlugin new MemoryFix(this); new FoodDupeFix(this); new Explosion(this, blockRestore); - new InventoryManager(this, _clientManager); + InventoryManager inventory = new InventoryManager(this, _clientManager); ResourcePackManager resourcePackManager = new ResourcePackManager(this, portal); resourcePackManager.setResourcePack(new Pair[] { @@ -154,7 +154,7 @@ public class Clans extends JavaPlugin GearManager customGear = new GearManager(this, packetHandler, _clientManager, _donationManager); HologramManager hologram = new HologramManager(this, packetHandler); - _clansManager = new ClansManager(this, clansBans, serverStatusManager.getCurrentServerName(), incognito, packetHandler, punish, _clientManager, _donationManager, preferenceManager, blockRestore, statsManager, teleport, chat, customGear, hologram, webServerAddress); + _clansManager = new ClansManager(this, clansBans, serverStatusManager.getCurrentServerName(), incognito, packetHandler, punish, _clientManager, _donationManager, preferenceManager, blockRestore, statsManager, teleport, chat, customGear, hologram, inventory, webServerAddress); new Recipes(this); new Farming(this); new BuildingShop(_clansManager, _clientManager, _donationManager); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index bc5f5bfb9..017703571 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -35,6 +35,7 @@ import mineplex.core.hologram.Hologram; import mineplex.core.hologram.HologramManager; import mineplex.core.incognito.IncognitoManager; import mineplex.core.incognito.events.IncognitoStatusChangeEvent; +import mineplex.core.inventory.InventoryManager; import mineplex.core.movement.Movement; import mineplex.core.npc.NpcManager; import mineplex.core.packethandler.PacketHandler; @@ -179,6 +180,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati private GearManager _gearManager; private LootManager _lootManager; private DonationManager _donationManager; + private InventoryManager _inventoryManager; private NetherManager _netherManager; private DamageManager _damageManager; private SiegeManager _siegeManager; @@ -241,7 +243,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati // Spawn area - public ClansManager(JavaPlugin plugin, ClansBanManager clansBans, String serverName, IncognitoManager incognitoManager, PacketHandler packetHandler, Punish punish, CoreClientManager clientManager, DonationManager donationManager, PreferencesManager preferencesManager, BlockRestore blockRestore, StatsManager statsManager, Teleport teleport, Chat chat, GearManager gearManager, HologramManager hologramManager, String webServerAddress) + public ClansManager(JavaPlugin plugin, ClansBanManager clansBans, String serverName, IncognitoManager incognitoManager, PacketHandler packetHandler, Punish punish, CoreClientManager clientManager, DonationManager donationManager, PreferencesManager preferencesManager, BlockRestore blockRestore, StatsManager statsManager, Teleport teleport, Chat chat, GearManager gearManager, HologramManager hologramManager, InventoryManager inventoryManager, String webServerAddress) { super("Clans Manager", plugin); @@ -264,6 +266,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati _warManager = new WarManager(plugin, this); _donationManager = donationManager; + _inventoryManager = inventoryManager; _blacklist = new ClansBlacklist(plugin); @@ -516,6 +519,11 @@ public class ClansManager extends MiniClientPluginimplements IRelati return _donationManager; } + public InventoryManager getInventoryManager() + { + return _inventoryManager; + } + public ItemMapManager getItemMapManager() { return _itemMapManager; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/Amplifier.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/Amplifier.java new file mode 100644 index 000000000..3c35c28d9 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/Amplifier.java @@ -0,0 +1,13 @@ +package mineplex.game.clans.clans.amplifiers; + +import mineplex.game.clans.clans.amplifiers.AmplifierManager.AmplifierType; + +import org.bukkit.entity.Player; + +public class Amplifier +{ + public Amplifier(Player owner, AmplifierType type) + { + + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierGUI.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierGUI.java new file mode 100644 index 000000000..5fad8f14e --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierGUI.java @@ -0,0 +1,125 @@ +package mineplex.game.clans.clans.amplifiers; + +import java.util.HashMap; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.amplifiers.AmplifierManager.AmplifierType; + +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryCloseEvent; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; + +public abstract class AmplifierGUI implements Listener +{ + private Player _viewer; + private AmplifierManager _manager; + private Inventory _inventory; + private final HashMap _items = new HashMap<>(); + private final HashMap _boundSlots = new HashMap<>(); + private AmplifierType _selected; + + public AmplifierGUI(Player viewer, AmplifierManager manager) + { + _viewer = viewer; + _inventory = Bukkit.createInventory(viewer, 9 * Math.max(1, AmplifierType.values().length % 9), C.cClansNether + "Rune Amplifiers"); + Bukkit.getPluginManager().registerEvents(this, ClansManager.getInstance().getPlugin()); + } + + public Player getViewer() + { + return _viewer; + } + + public HashMap getItems() + { + return _items; + } + + public void propagate() + { + getItems().clear(); + Integer slot = 0; + for (AmplifierType type : AmplifierType.values()) + { + getItems().put(slot, new ItemBuilder(Material.NETHER_STAR).setAmount(_manager.getAmountOwned(getViewer(), type)).setTitle(type.getDisplayName()).build()); + _boundSlots.put(slot, type); + } + } + + public void propagateConfirmation() + { + getItems().clear(); + _boundSlots.clear(); + getItems().put(3, new ItemBuilder(Material.STAINED_GLASS_PANE).setData((short) 5).setTitle(C.cGreen + "Confirm").build()); + getItems().put(5, new ItemBuilder(Material.STAINED_GLASS_PANE).setData((short) 14).setTitle(C.cRed + "Cancel").build()); + } + + public void onClick(Integer slot, ClickType type) + { + if (_boundSlots.containsKey(slot)) + { + + } + } + + public void open() + { + _viewer.openInventory(_inventory); + } + + public void refresh() + { + _inventory.clear(); + for (Integer slot : _items.keySet()) + { + _inventory.setItem(slot, _items.get(slot)); + } + for (Integer slot = 0; slot < _inventory.getSize(); slot++) + { + if (!_items.containsKey(slot)) + { + _inventory.setItem(slot, new ItemBuilder(Material.STAINED_GLASS_PANE).setTitle(C.cGray).setData((short)7).build()); + } + } + _viewer.updateInventory(); + } + + @EventHandler + public void handleClick(InventoryClickEvent event) + { + if (event.getClickedInventory() == null || !event.getClickedInventory().equals(_inventory)) + { + return; + } + if (!_viewer.getName().equals(event.getWhoClicked().getName())) + { + return; + } + event.setCancelled(true); + Integer slot = event.getSlot(); + if (!_items.containsKey(slot)) + { + return; + } + onClick(slot, event.getClick()); + } + + @EventHandler + public void onClose(InventoryCloseEvent event) + { + if (event.getPlayer().getUniqueId().equals(_viewer.getUniqueId())) + { + HandlerList.unregisterAll(this); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierManager.java index 14aaf0505..c8d2cca37 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierManager.java @@ -1,6 +1,56 @@ package mineplex.game.clans.clans.amplifiers; -public class AmplifierManager -{ +import mineplex.core.MiniPlugin; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.game.clans.clans.ClansManager; +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; + +public class AmplifierManager extends MiniPlugin +{ + private static final String AMPLIFIER_NAME = "Rune Amplifier"; + + public AmplifierManager(JavaPlugin plugin) + { + super("Rune Amplifiers", plugin); + } + + public int getAmountOwned(Player player, AmplifierType type) + { + return ClansManager.getInstance().getInventoryManager().Get(player).getItemCount(type.getFullItemName()); + } + + public static enum AmplifierType + { + TWENTY("20", "Twenty Minute Amplifier", UtilTime.convert(20, TimeUnit.MINUTES, TimeUnit.MILLISECONDS)), + SIXTY("60", "One Hour Amplifier", UtilTime.convert(60, TimeUnit.MINUTES, TimeUnit.MILLISECONDS)); + + private String _extension, _display; + private long _duration; + + private AmplifierType(String extension, String displayName, long duration) + { + _extension = extension; + _display = C.cClansNether + displayName; + _duration = duration; + } + + public String getFullItemName() + { + return AMPLIFIER_NAME + " " + _extension; + } + + public String getDisplayName() + { + return _display; + } + + public long getDuration() + { + return _duration; + } + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerManager.java index 6726e6102..b2d437f4b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerManager.java @@ -69,6 +69,17 @@ public class BannerManager extends MiniPlugin _repo.saveBanner(banner); } + public void deleteBanner(ClanInfo clan) + { + _repo.deleteBanner(clan); + LoadedBanners.remove(clan.getName()); + } + + public void deleteBanner(ClanBanner banner) + { + deleteBanner(banner.getClan()); + } + public void placeBanner(Player placing, ClanBanner banner) { Block block = placing.getLocation().getBlock(); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerRepository.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerRepository.java index ae972f6b2..d0c6ac27f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerRepository.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerRepository.java @@ -24,6 +24,7 @@ public class BannerRepository extends MinecraftRepository private static final String GET_BANNER_BY_CLAN = "SELECT * FROM clanBanners WHERE clanId=? LIMIT 1;"; private static final String INSERT_BANNER = "INSERT INTO clanBanners (clanId, baseColor, patterns) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE baseColor=VALUES(baseColor), patterns=VALUES(patterns);"; + private static final String DELETE_BANNER = "DELETE FROM clanBanners WHERE clanId=?;"; private BannerManager _bannerManager; @@ -89,6 +90,14 @@ public class BannerRepository extends MinecraftRepository executeUpdate(INSERT_BANNER, new ColumnInt("clanId", banner.getClan().getId()), new ColumnVarChar("baseColor", 15, banner.getBaseColor().toString()), new ColumnVarChar("patterns", 300, patternStr)); }); } + + public void deleteBanner(ClanInfo clan) + { + _bannerManager.runAsync(() -> + { + executeUpdate(DELETE_BANNER, new ColumnInt("clanId", clan.getId())); + }); + } @Override protected void initialize() diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/BannerGUI.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/BannerGUI.java index 2b274547a..20753905a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/BannerGUI.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/BannerGUI.java @@ -52,6 +52,7 @@ public abstract class BannerGUI implements Listener public void refresh() { + _inventory.clear(); for (Integer slot : _items.keySet()) { _inventory.setItem(slot, _items.get(slot)); From b87c6cfff0863e7f73ea09807c9d4472ad39c93b Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 21 Jul 2016 17:27:41 -0400 Subject: [PATCH 35/90] Fix git removing class --- .../game/games/minestrike/Minestrike.java | 1347 +++++++++++++++++ 1 file changed, 1347 insertions(+) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/Minestrike.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/Minestrike.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/Minestrike.java new file mode 100644 index 000000000..862ead445 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/Minestrike.java @@ -0,0 +1,1347 @@ +package nautilus.game.arcade.game.games.minestrike; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Color; +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.craftbukkit.v1_8_R3.entity.CraftPlayer; +import org.bukkit.entity.Entity; +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.inventory.InventoryClickEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.LeatherArmorMeta; +import org.bukkit.scoreboard.DisplaySlot; +import org.bukkit.scoreboard.NameTagVisibility; +import org.bukkit.scoreboard.Objective; +import org.bukkit.scoreboard.Team; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.C; +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.UtilGear; +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.common.util.UtilTime; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.gamemodifiers.GameModifierType; +import mineplex.core.gadget.gadgets.gamemodifiers.minestrike.GameModifierMineStrikeSkin; +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.combat.event.CombatDeathEvent; +import mineplex.minecraft.game.core.condition.Condition.ConditionType; +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.events.PlayerKitGiveEvent; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.TeamGame; +import nautilus.game.arcade.game.GameTeam.PlayerState; +import nautilus.game.arcade.game.games.minestrike.GunModule.RoundOverEvent; +import nautilus.game.arcade.game.games.minestrike.data.Bomb; +import nautilus.game.arcade.game.games.minestrike.items.guns.Gun; +import nautilus.game.arcade.game.games.minestrike.items.guns.GunStats; +import nautilus.game.arcade.game.games.minestrike.kits.KitPlayer; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.managers.chat.ChatStatData; +import nautilus.game.arcade.stats.KaboomStatTracker; +import nautilus.game.arcade.stats.KillAllOpposingMineStrikeRoundStatTracker; +import nautilus.game.arcade.stats.KillFastStatTracker; +import nautilus.game.arcade.stats.KillReasonStatTracker; +import nautilus.game.arcade.stats.KillsWithConditionStatTracker; +import nautilus.game.arcade.stats.MineStrikeGunStats; +import nautilus.game.arcade.stats.MineStrikeLastAliveKillStatTracker; +import nautilus.game.arcade.stats.TeamDeathsStatTracker; +import nautilus.game.arcade.stats.TeamKillsStatTracker; + +/** + * Minestrike + * + * @author xXVevzZXx + */ +public class Minestrike extends TeamGame +{ + + //Managers + private ShopManager _shopManager; + + //Data + private int _roundsToWin = 8; + private long _roundTime = 120000; + + //Round Data + private String _winText = null; + private boolean _roundOver = false; + + //Money Data + private boolean _bombPlanted = false; + private boolean _ctWonLast = false; + private int _winStreak = 0; + + private HashMap _score = new HashMap(); + + //Map Data + private ArrayList _bombSites; + + private Player _bombPlanter; + private Player _bombDefuser; + private Player _bombPlantedBy; + + private boolean _bombScoreboardFlash = false; + + private GunModule _gunModule; + + //Scoreboard + private Objective _scoreObj; + + public Minestrike(ArcadeManager manager) + { + super(manager, GameType.MineStrike, + + new Kit[] + { + new KitPlayer(manager), + }, + + new String[] + { + C.cAqua + "SWAT" + C.cWhite + " Defend the Bomb Sites", + C.cAqua + "SWAT" + C.cWhite + " Kill the Bombers", + " ", + C.cRed + "Bombers" + C.cWhite + " Plant the Bomb at Bomb Site", + C.cRed + "Bombers" + C.cWhite + " Kill the SWAT Team", + }); + + _shopManager = new ShopManager(this); + Manager.getCosmeticManager().setHideParticles(true); + + this.StrictAntiHack = true; + + AnnounceStay = false; + + this.HungerSet = 20; + + this.ItemDrop = true; + + this.DeathTeleport = false; + + this.InventoryClick = true; + + this.JoinInProgress = true; + + this.DontAllowOverfill = true; + + _scoreObj = Scoreboard.GetScoreboard().registerNewObjective("HP", "dummy"); + _scoreObj.setDisplaySlot(DisplaySlot.BELOW_NAME); + + this._help = new String[] + { + //"Tap Crouch when close to an ally to Boost", + "Open Inventory at spawn to buy guns", + "Hold Right-Click to Plant Bomb", + "Look at the Bomb to Defuse it", + "Moving decreases accuracy", + "Sprinting heavily decreases accuracy", + "Jumping massively decreases accuracy", + "Crouching increases accuracy", + "Left-Click to drop Grenades", + "Right-Click to throw Grenades", + "Burst Fire for greater accuracy", + "Sniper Rifles are only accurate while scoped", + "Rifles have 30% recoil reduction while scoped", + "Pick up better weapons from dead players" + }; + + registerStatTrackers( + new KillReasonStatTracker(this, "Headshot", "BoomHeadshot", true), + new KillAllOpposingMineStrikeRoundStatTracker(this), + new KaboomStatTracker(this), + new KillReasonStatTracker(this, "Backstab", "Assassination", false), + new MineStrikeLastAliveKillStatTracker(this), + new KillFastStatTracker(this, 4, 5, "KillingSpree"), + new KillsWithConditionStatTracker(this, "Blindfolded", ConditionType.BLINDNESS, "Flash Bang", 2), + + new TeamDeathsStatTracker(this), + new TeamKillsStatTracker(this), + + new MineStrikeGunStats(this) + ); + + registerChatStats( + Kills, + Deaths, + KDRatio, + BlankLine, + new ChatStatData("BoomHeadshot", "Headshots", true), + Assists + ); + + _gunModule = new GunModule(this); + } + + @EventHandler + public void CustomTeamGeneration(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Recruit) + return; + + this.GetTeamList().get(0).SetColor(ChatColor.AQUA); + this.GetTeamList().get(0).SetName("SWAT"); + + this.GetTeamList().get(1).SetColor(ChatColor.RED); + this.GetTeamList().get(1).SetName("Bombers"); + } + + @EventHandler + public void SetScoreboardNameVisibility(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + return; + + System.out.println("Hiding Scoreboard Nametags for Other Teams"); + for (Team curTeam : Scoreboard.GetScoreboard().getTeams()) + { + curTeam.setNameTagVisibility(NameTagVisibility.HIDE_FOR_OTHER_TEAMS); + //UtilServer.getServer().dispatchCommand(UtilServer.getServer().getConsoleSender(), + // "scoreboard teams option " + curTeam.getName() + " nametagVisibility hideForOtherTeams"); + } + } + + @Override + public void ParseData() + { + _bombSites = WorldData.GetDataLocs("RED"); + } + + @EventHandler + public void giveStartEquipment(PlayerKitGiveEvent event) + { + GameTeam team = GetTeam(event.getPlayer()); + if (team == null) + return; + + GadgetManager gadgetManager = Manager.getCosmeticManager().getGadgetManager(); + GameModifierMineStrikeSkin knifeSkin = (GameModifierMineStrikeSkin) gadgetManager.getActiveGameModifier(event.getPlayer(), + GameModifierType.MineStrike, GameModifierMineStrikeSkin.getWeaponFilter("Knife")); + + Material mat = Material.IRON_AXE; + byte data = 0; + String name = "Knife"; + + if(knifeSkin != null) + { + mat = knifeSkin.getSkinMaterial(); + data = knifeSkin.getSkinData(); + name = knifeSkin.getName(); + } + + ItemStack knife = ItemStackFactory.Instance.CreateStack(mat, data, 1, name); + + if (team.GetColor() == ChatColor.RED) + { + if (IsAlive(event.getPlayer())) + { + //Pistol + Gun gun = new Gun(GunStats.GLOCK_18, _gunModule); + _gunModule.registerGun(gun, event.getPlayer()); + gun.giveToPlayer(event.getPlayer(), true); + gun.updateSkin(event.getPlayer(), getArcadeManager().getCosmeticManager().getGadgetManager()); + gun.updateWeaponName(event.getPlayer(), _gunModule); + + //Knife + if(knifeSkin == null) knife.setType(Material.IRON_AXE); + + event.getPlayer().getInventory().setItem(2, knife); + + //Armor + giveTeamArmor(event.getPlayer(), Color.fromRGB(255, 75, 75)); + } + } + else if (team.GetColor() == ChatColor.AQUA) + { + if (IsAlive(event.getPlayer())) + { + //Pistol + Gun gun = new Gun(GunStats.P2000, _gunModule); + _gunModule.registerGun(gun, event.getPlayer()); + gun.giveToPlayer(event.getPlayer(), true); + gun.updateWeaponName(event.getPlayer(), _gunModule); + gun.updateSkin(event.getPlayer(), getArcadeManager().getCosmeticManager().getGadgetManager()); + + //Knife + if(knifeSkin == null) knife.setType(Material.IRON_SWORD); + + event.getPlayer().getInventory().setItem(2, knife); + + //Armor + giveTeamArmor(event.getPlayer(), Color.fromRGB(125, 200, 255)); + } + } + + //Enter Shop + _shopManager.enterShop(event.getPlayer()); + } + + public void giveTeamArmor(Player player, Color color) + { + ItemStack armor = new ItemStack(Material.LEATHER_CHESTPLATE); + LeatherArmorMeta meta = (LeatherArmorMeta)armor.getItemMeta(); + meta.setColor(color); + armor.setItemMeta(meta); + player.getInventory().setChestplate(armor); + + ItemStack legs = new ItemStack(Material.LEATHER_LEGGINGS); + LeatherArmorMeta metaLegs = (LeatherArmorMeta)legs.getItemMeta(); + metaLegs.setColor(color); + legs.setItemMeta(metaLegs); + player.getInventory().setLeggings(legs); + + ItemStack boots = new ItemStack(Material.LEATHER_BOOTS); + LeatherArmorMeta metaBoots = (LeatherArmorMeta)boots.getItemMeta(); + metaBoots.setColor(color); + boots.setItemMeta(metaBoots); + player.getInventory().setBoots(boots); + } + + @EventHandler + public void shopInventoryClick(InventoryClickEvent event) + { + _shopManager.inventoryClick(event); + } + + @EventHandler + public void shopUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + return; + + _shopManager.update(); + } + + @EventHandler + public void quitClean(PlayerQuitEvent event) + { + _shopManager.leaveShop(event.getPlayer(), false, true); + _gunModule.undisguise(event.getPlayer()); + _gunModule.removeScope(event.getPlayer()); + _gunModule.dropInventory(event.getPlayer()); + } + + @EventHandler + public void giveBombInitial(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + return; + + UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() + { + public void run() + { + Player player = UtilAlg.Random(GetTeam(ChatColor.RED).GetPlayers(true)); + + _gunModule.giveBombToPlayer(player); + } + }, 40); + } + + + @EventHandler + public void killReward(CombatDeathEvent event) + { + if (!(event.GetEvent().getEntity() instanceof Player)) + return; + + Player killed = (Player)event.GetEvent().getEntity(); + + if (event.GetLog().GetKiller() != null) + { + Player killer = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName()); + + if (killer == null || killer.equals(killed)) + return; + + if (GetTeam(killed).equals(GetTeam(killer))) + return; + + int amount = 300; + + if (event.GetLog().GetLastDamager().GetReason().contains("AWP")) + amount = 100; + + else if (event.GetLog().GetLastDamager().GetReason().contains("PP-Bizon")) + amount = 600; + + else if (event.GetLog().GetLastDamager().GetReason().contains("Nova")) + amount = 900; + + else if (event.GetLog().GetLastDamager().GetReason().contains("Knife")) + amount = 1500; + + _shopManager.addMoney(killer, amount, "kill with " + event.GetLog().GetLastDamager().GetReason()); + + /* + if(event.GetLog().GetLastDamager().GetReason().contains("Knife")) + { + GadgetManager gadgetManager = Manager.getCosmeticManager().getGadgetManager(); + GameModifierMineStrikeSkin knifeSkin = (GameModifierMineStrikeSkin) gadgetManager.getActiveGameModifier(event.getPlayer(), + GameModifierType.MineStrike, GameModifierMineStrikeSkin.getWeaponFilter("Knife")); + + if(knifeSkin != null) + { + int kills = GetStats().get(killer).get("") + ItemStack item = killer.getInventory().getItem(2); + ItemMeta im = item.getItemMeta(); + im.setDisplayName(C.cYellow + C.Bold + knifeSkin.GetName() + " - Kills: " + kills); + + AddStat(killer, "Knife." + knifeSkin.GetName() + ".Kills", 1, false, false); + } + } + */ + } + } + + @EventHandler + public void plantBomb(PlayerInteractEvent event) + { + Player player = event.getPlayer(); + + if (!UtilGear.isMat(player.getItemInHand(), Material.GOLD_SWORD)) + return; + + // Fixed bomb able to be planted after the round is over. + if (_roundOver) + { + UtilPlayer.message(player, F.main("Game", "You cannot plant the bomb once the round is over.")); + event.setCancelled(true); + return; + } + + // Added a small tip for players that are trying to right-click with the bomb. + if (UtilEvent.isAction(event, ActionType.L)) + { + UtilPlayer.message(player, F.main("Game", "You must " + F.elem("Right-Click") + " while holding the bomb to plant it.")); + event.setCancelled(true); + return; + } + + if (!UtilEnt.isGrounded(player)) + { + UtilPlayer.message(player, F.main("Game", "You can only plant the bomb on the ground.")); + event.setCancelled(true); + return; + } + + //Should never occur with 1 Bomb + if (_bombPlanter != null) + { + UtilPlayer.message(player, F.main("Game", "Someone else is planting the bomb.")); + event.setCancelled(true); + return; + } + + //Check Bomb Sites + boolean near = false; + for (Location loc : _bombSites) + { + if (UtilMath.offset(player.getLocation(), loc) < 5) + { + near = true; + break; + } + } + + //Too Far + if (!near) + { + UtilPlayer.message(player, F.main("Game", "You can only plant the bomb at a bomb site.")); + event.setCancelled(true); + return; + } + + _bombPlanter = player; + _bombPlanter.setExp(0f); + + UtilPlayer.message(player, F.main("Game", "You are now placing the bomb.")); + + //Radio + _gunModule.playSound(Radio.T_BOMB_PLANT, null, GetTeam(_bombPlanter)); + } + + @EventHandler + public void plantBombUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + // Added to check if the round is over when a bomb is being planted. + if (_roundOver) + return; + + if (_bombPlanter == null) + return; + + if (!_bombPlanter.isBlocking() || !_bombPlanter.isOnline()) + { + _bombPlanter.setExp(0f); + UtilTextMiddle.clear(_bombPlanter); + _bombPlanter = null; + return; + } + + _bombPlanter.setExp(Math.min(_bombPlanter.getExp() + 0.017f, 0.99999f)); + + if (Math.random() > 0.90) + _bombPlanter.getWorld().playSound(_bombPlanter.getLocation(), Sound.NOTE_PLING, 2f, 3f); + + UtilTextMiddle.display(C.cRed + C.Bold + "Planting Bomb", UtilTextMiddle.progress(_bombPlanter.getExp()), 0, 10, 0, _bombPlanter); + + if (_bombPlanter.getExp() >= 0.98f) + { + _gunModule.setBomb(new Bomb(_bombPlanter)); + + _shopManager.addMoney(_bombPlanter, 300, "planting the bomb"); + + Announce(C.cRed + C.Bold + _bombPlanter.getName() + " has planted the bomb!"); + + _bombPlantedBy = _bombPlanter; + + _bombPlanter.setExp(0f); + _bombPlanter.setItemInHand(null); + _bombPlanter = null; + _gunModule.setBombHolder(null); + + //Sound + _gunModule.playSound(Radio.BOMB_PLANT, null, null); + + //Title + UtilTextMiddle.display(null, C.cRed + C.Bold + "Bomb has been planted!", 10, 50, 10); + } + } + + @EventHandler + public void plantDefuseBombRestrictMovement(PlayerMoveEvent event) + { + if (_bombPlanter != null && _bombPlanter.equals(event.getPlayer())) + if (UtilMath.offset(event.getFrom(), event.getTo()) > 0) + event.setTo(event.getFrom()); + + // if (_bombDefuser != null && _bombDefuser.equals(event.getPlayer())) + // if (UtilMath.offset(event.getFrom(), event.getTo()) > 0) + // event.setTo(event.getFrom()); + } + + @EventHandler + public void defuseKitMessage(PlayerInteractEvent event) + { + Player player = event.getPlayer(); + + if (!UtilGear.isMat(player.getItemInHand(), Material.SHEARS)) + return; + + UtilPlayer.message(player, F.main("Game", "Look at the Bomb to defuse it.")); + } + + public void startDefuse() + { + for (Player player : GetTeam(ChatColor.AQUA).GetPlayers(true)) + { + HashSet ignoreBlocks = new HashSet(); + ignoreBlocks.add(Material.AIR); + ignoreBlocks.add(Material.PORTAL); + + Block block = player.getTargetBlock(ignoreBlocks, 5); + + if (block == null || !_gunModule.getBomb().isBlock(block)) + continue; + + if (UtilMath.offset(player.getLocation(), block.getLocation().add(0.5, 0, 0.5)) > 3) + continue; + + if (_bombDefuser != null) + { + if (Recharge.Instance.use(player, "Defuse Message", 2000, false, false)) + UtilPlayer.message(player, F.main("Game", _bombDefuser.getName() + " is already defusing the Bomb.")); + + continue; + } + + _bombDefuser = player; + _bombDefuser.setExp(0f); + + UtilPlayer.message(player, F.main("Game", "You are defusing the Bomb.")); + + _bombDefuser.getWorld().playSound(_bombDefuser.getLocation(), Sound.PISTON_RETRACT, 2f, 1f); + } + } + + @EventHandler + public void defuseBombUpdate(UpdateEvent event) + { + if (_gunModule.getBomb() == null) + return; + + if (!IsLive()) + return; + + if (event.getType() != UpdateType.TICK) + return; + + if (_bombDefuser == null) + { + startDefuse(); + } + + if (_bombDefuser == null) + return; + + HashSet ignoreBlocks = new HashSet(); + ignoreBlocks.add(Material.AIR); + ignoreBlocks.add(Material.PORTAL); + + Block block = _bombDefuser.getTargetBlock(ignoreBlocks, 5); + + if (!IsAlive(_bombDefuser) || block == null || !_gunModule.getBomb().isBlock(block) || !_bombDefuser.isOnline() || UtilMath.offset(_bombDefuser.getLocation(), block.getLocation().add(0.5, 0, 0.5)) > 3) + { + _bombDefuser.setExp(0f); + _bombDefuser = null; + return; + } + + //Kit or Not? + float defuseRate = 0.005f; + if (UtilGear.isMat(_bombDefuser.getInventory().getItem(8), Material.SHEARS)) + defuseRate = 0.01f; + + _bombDefuser.setExp(Math.min(_bombDefuser.getExp() + defuseRate, 0.99999f)); + + UtilTextMiddle.display(C.cAqua + C.Bold + "Defusing Bomb", UtilTextMiddle.progress(_bombDefuser.getExp()), 0, 10, 0, _bombDefuser); + + if (_bombDefuser.getExp() >= 0.98f) + { + _gunModule.getBomb().defuse(); + + _winText = _bombDefuser.getName() + " defused the bomb!"; + + _gunModule.setBomb(null); + _bombDefuser.setExp(0f); + _bombDefuser = null; + + //Sound + _gunModule.playSound(Radio.BOMB_DEFUSE, null, null); + + setWinner(GetTeam(ChatColor.AQUA), true); + } + } + + @EventHandler + public void bombUpdate(UpdateEvent event) + { + if (!IsLive()) + return; + + if (event.getType() != UpdateType.TICK) + return; + + if (_gunModule.getBomb() == null) + return; + + if (!_gunModule.getBomb().update()) + return; + + /* + Set blocks = UtilBlock.getInRadius(_bomb.Block.getLocation(), 10d).keySet(); + + Iterator blockIterator = blocks.iterator(); + while (blockIterator.hasNext()) + { + Block block = blockIterator.next(); + + if (block.getY() < 2) + blockIterator.remove(); + } + + Manager.GetExplosion().BlockExplosion(blocks, _bomb.Block.getLocation(), false); + */ + + + HashMap players = UtilPlayer.getInRadius(_gunModule.getBomb().Block.getLocation(), 48); + for (Player player : players.keySet()) + { + if (!IsAlive(player)) + continue; + + // Damage Event + Manager.GetDamage().NewDamageEvent(player, null, null, + DamageCause.CUSTOM, 1 + (players.get(player) * 40), + true, true, false, "Bomb", "C4 Explosion"); + } + + + _gunModule.setBomb(null); + + _winText = _bombPlantedBy.getName() + " destroyed the bomb site!"; + + setWinner(GetTeam(ChatColor.RED), false); + } + + public int getScore(GameTeam team) + { + if (!_score.containsKey(team)) + _score.put(team, 0); + + return _score.get(team); + } + + public void addScore(GameTeam team) + { + _score.put(team, getScore(team) + 1); + } + + @EventHandler + public void roundTimerUpdate(UpdateEvent event) + { + if (!IsLive()) + return; + + if (event.getType() != UpdateType.TICK) + return; + + if (_gunModule.getBomb() != null) + return; + + if (UtilTime.elapsed(GetStateTime(), _roundTime)) + { + _winText = "Bomb sites were successfully defended!"; + drawScoreboard(); + setWinner(GetTeam(ChatColor.AQUA), false); + } + } + + @EventHandler + public void roundPlayerCheck(UpdateEvent event) + { + if (!IsLive()) + return; + + if (event.getType() != UpdateType.TICK) + return; + + ArrayList teamsAlive = new ArrayList(); + + for (GameTeam team : this.GetTeamList()) + if (team.GetPlayers(true).size() > 0) + teamsAlive.add(team); + + if (teamsAlive.size() == 1) + { + //Bomb Planted - CT cannot win without defusing + if (_gunModule.getBomb() != null) + { + if (teamsAlive.size() > 0) + { + if (teamsAlive.get(0).GetColor() == ChatColor.AQUA) + { + return; + } + } + } + + setWinner(teamsAlive.get(0), false); + } + else if (teamsAlive.size() == 0) + { + if (_gunModule.getBomb() == null) + { + _winText = "Bomb sites were successfully defended!"; + setWinner(GetTeam(ChatColor.AQUA), false); + } + else + { + _winText = "Bomb site will be destroyed!"; + setWinner(GetTeam(ChatColor.RED), false); + } + } + } + + public void setWinner(final GameTeam winner, boolean defuse) + { + if (_roundOver) + return; + + Bukkit.getPluginManager().callEvent(new RoundOverEvent(this)); + + _roundOver = true; + + String winnerLine = C.Bold + "The round was a draw!"; + ChatColor color = ChatColor.GRAY; + if (winner != null) + { + if(winner.GetName().contains("Bombers")) { + winnerLine= winner.GetColor() + C.Bold + winner.GetName() + " have won the round!"; + } else { + winnerLine= winner.GetColor() + C.Bold + winner.GetName() + " has won the round!"; + } + addScore(winner); + drawScoreboard(); + color = winner.GetColor(); + + + } + + //Sound + if (winner != null) + { + UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() + { + public void run() + { + if (winner.GetColor() == ChatColor.RED) + _gunModule.playSound(Radio.T_WIN, null, null); + else + _gunModule.playSound(Radio.CT_WIN, null, null); + } + }, defuse ? 60 : 0); + } + + //Record Streak for Money + if (winner.GetColor() == ChatColor.RED) + { + _winStreak++; + + if (_ctWonLast) + { + _ctWonLast = false; + _winStreak = 0; + } + } + else + { + _winStreak++; + + if (!_ctWonLast) + { + _ctWonLast = true; + _winStreak = 0; + } + } + + //Announce + Announce("", false); + Announce(color + "===================================", false); + Announce("", false); + Announce(winnerLine, false); + if (_winText != null) + Announce(_winText, false); + Announce("", false); + Announce(color + "===================================", false); + + for (Player player : UtilServer.getPlayers()) + { + player.playSound(player.getLocation(), Sound.LEVEL_UP, 1f, 1f); + _gunModule.removeScope(player); + + Recharge.Instance.Reset(player, "reload"); + } + + UtilTextMiddle.display(null, winnerLine, 20, 120, 20); + + //Check for total game win + EndCheck(); + + //Next Round (if not over) + if (IsLive()) + { + UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() + { + public void run() + { + restartRound(); + } + }, 100); + } + } + + public void restartRound() + { + giveMoney(); + + //Clean + resetGame(); + + //Teleport to Spawn + for (GameTeam team : GetTeamList()) + team.SpawnTeleport(false); + + //Revive Dead Players + for (Player player : GetPlayers(false)) + if (!IsAlive(player)) + { + SetPlayerState(player, PlayerState.IN); + + GameTeam team = GetTeam(player); + + //Teleport + team.SpawnTeleport(player); + + Manager.Clear(player); + UtilInv.Clear(player); + + ValidateKit(player, GetTeam(player)); + + if (GetKit(player) != null) + GetKit(player).ApplyKit(player); + } + + //Remove Scope + for (Player player : GetPlayers(false)) + _gunModule.removeScope(player); + + //Get Hit By Bullets + for (Player player : GetPlayers(false)) + ((CraftPlayer) player).getHandle().spectating = false; + + //Prepare Sound + for (Player player : GetPlayers(false)) + { + player.playSound(player.getLocation(), Sound.HORSE_ARMOR, 1f, 2f); + Manager.GetCondition().Factory().Blind("Respawn", player, null, 2, 0, false, false, false); + UtilPlayer.message(player, F.main("Game", "You have " + F.elem(C.cGreen + "$" + _shopManager.getMoney(player)) + ". Open your Inventory to spend it.")); + + UtilTextMiddle.display(C.cGreen + "$" + _shopManager.getMoney(player), "Open your Inventory to buy new equipment", 10, 120, 10, player); + } + + //Update Scoreboard Teams + for (GameTeam team : GetTeamList()) + for (Player teamMember : team.GetPlayers(true)) + GetScoreboard().SetPlayerTeam(teamMember, team.GetName().toUpperCase()); + + //Alternate Bullets + if (_gunModule.BulletAlternate) + _gunModule.BulletInstant = (_gunModule.BulletInstant + 1)%3; + + //Debug Details + if (_gunModule.Debug) + { + Announce(C.cDPurple + C.Bold + "ROUND SETTINGS:"); + + if (_gunModule.CustomHitbox) + Announce(C.cPurple + C.Bold + "Hitbox: " + ChatColor.RESET + "Accurate with Headshots"); + else + Announce(C.cPurple + C.Bold + "Hitbox: " + ChatColor.RESET + "Default with No Headshot"); + + if (_gunModule.BulletInstant == 0) + Announce(C.cPurple + C.Bold + "Bullets: " + ChatColor.RESET + "Slow and Visible"); + else if (_gunModule.BulletInstant == 1) + Announce(C.cPurple + C.Bold + "Bullets: " + ChatColor.RESET + "Instant and Invisible"); + else + Announce(C.cPurple + C.Bold + "Bullets: " + ChatColor.RESET + "Slow and Visible with Instant Sniper"); + } + } + + public void giveMoney() + { + if (_ctWonLast) + { + int ctMoney = 3250; + int tMoney = 1400 + (Math.min(4,_winStreak) * 500); + + if (_bombPlanted) + { + ctMoney += 250; + tMoney += 800; + } + + //Award + for (Player player : GetTeam(ChatColor.RED).GetPlayers(false)) + _shopManager.addMoney(player, tMoney, "losing the round"); + + for (Player player : GetTeam(ChatColor.AQUA).GetPlayers(false)) + _shopManager.addMoney(player, ctMoney, "winning the round"); + } + else + { + int tMoney = 3250; + int ctMoney = 1400 + (Math.min(4,_winStreak) * 500); + + //Award + for (Player player : GetTeam(ChatColor.RED).GetPlayers(false)) + _shopManager.addMoney(player, tMoney, "winning the round"); + + for (Player player : GetTeam(ChatColor.AQUA).GetPlayers(false)) + _shopManager.addMoney(player, ctMoney, "losing the round"); + } + } + + public void resetGame() + { + //General + _roundOver = false; + SetStateTime(System.currentTimeMillis()); + _gunModule.setFreezeTime(10); + _winText = null; + + //Bomb + if (_gunModule.getBomb() != null) + _gunModule.getBomb().clean(); + + if (_gunModule.getBombItem() != null) + _gunModule.getBombItem().remove(); + + if (_gunModule.getBombHolder() != null) + { + _gunModule.getBombHolder().getInventory().remove(Material.GOLD_SWORD); + _gunModule.setBombHolder(null); + } + + _gunModule.setBomb(null); + _gunModule.setBombItem(null); + + _bombPlanter = null; + _bombDefuser = null; + _bombPlantedBy = null; + _bombPlanted = false; + + _gunModule.reset(); + + //Health + for (Player player : UtilServer.getPlayers()) + player.setHealth(20); + + //Reset Shop + for (Player player : UtilServer.getPlayers()) + _shopManager.leaveShop(player, false, false); + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void specToTeam(PlayerJoinEvent event) + { + if (GetState() == GameState.Recruit || GetState() == GameState.Loading) + return; + + //Target Team + GameTeam targetTeam = null; + if (GetTeamList().get(0).GetPlayers(false).size() < GetTeamList().get(1).GetPlayers(false).size()) + targetTeam = GetTeamList().get(0); + else if (GetTeamList().get(0).GetPlayers(false).size() > GetTeamList().get(1).GetPlayers(false).size()) + targetTeam = GetTeamList().get(1); + else if (Math.random() > 0.5) + targetTeam = GetTeamList().get(1); + else + targetTeam = GetTeamList().get(0); + + SetPlayerTeam(event.getPlayer(), targetTeam, false); + + ((CraftPlayer) event.getPlayer()).getHandle().spectating = true; + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void quitLeaveTeam(PlayerQuitEvent event) + { + GameTeam team = GetTeam(event.getPlayer()); + + if (team != null) + { + team.RemovePlayer(event.getPlayer()); + } + } + + @EventHandler + public void restartFreezeCountdown(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + return; + + if (_gunModule.getFreezeTime() <= 0) + return; + + _gunModule.setFreezeTime(_gunModule.getFreezeTime() - 1); + + for (Player player : UtilServer.getPlayers()) + { + if (_gunModule.getFreezeTime() > 0) + player.playSound(player.getLocation(), Sound.NOTE_STICKS, 1f, 1f); + else + player.playSound(player.getLocation(), Sound.NOTE_SNARE_DRUM, 1f, 1f); + } + + if (_gunModule.getFreezeTime() == 0) + { + //Give Bomb + Player bombPlayer = UtilAlg.Random(GetTeam(ChatColor.RED).GetPlayers(true)); + _gunModule.giveBombToPlayer(bombPlayer); + + //Sound + _gunModule.playSound(Radio.CT_START, null, GetTeam(ChatColor.AQUA)); + _gunModule.playSound(Radio.T_START, null, GetTeam(ChatColor.RED)); + } + } + + @Override + @EventHandler + public void ScoreboardUpdate(UpdateEvent event) + { + if (event != null && event.getType() != UpdateType.FAST) + return; + + drawScoreboard(); + } + + public void drawScoreboard() + { + Scoreboard.Reset(); + + for (GameTeam team : this.GetTeamList()) + { + + Scoreboard.WriteBlank(); + + Scoreboard.Write(getScore(team) + " " + team.GetColor() + C.Bold + team.GetName()); + //Scoreboard.Write(team.GetColor() + "" + getScore(team) + "" + " Wins" + team.GetColor()); + Scoreboard.Write(team.GetPlayers(true).size() + "" + " Alive" + team.GetColor()); + + } + + Scoreboard.WriteBlank(); + Scoreboard.Write(C.cGold + C.Bold + "Playing To"); + Scoreboard.Write(_roundsToWin + " Wins"); + + if (InProgress()) + { + Scoreboard.WriteBlank(); + + if (_gunModule.getBomb() == null) + { + Scoreboard.Write(C.cGold + C.Bold + "Time Left"); + Scoreboard.Write(UtilTime.MakeStr(_roundTime - (System.currentTimeMillis() - this.GetStateTime()), 1)); + } + else + { + if (_bombScoreboardFlash) + Scoreboard.Write(C.cRed + C.Bold + "Bomb Active"); + else + Scoreboard.Write(C.cWhite + C.Bold + "Bomb Active"); + + _bombScoreboardFlash = !_bombScoreboardFlash; + } + } + + + Scoreboard.Draw(); + } + + @Override + public void EndCheck() + { + endCheckScore(); + endCheckPlayer(); + } + + public void endCheckScore() + { + if (!IsLive()) + return; + + for (GameTeam team : GetTeamList()) + { + if (getScore(team) >= _roundsToWin) + { + //Announce + AnnounceEnd(team); + + for (GameTeam other : GetTeamList()) + { + if (WinnerTeam != null && other.equals(WinnerTeam)) + { + for (Player player : other.GetPlayers(false)) + AddGems(player, 10, "Winning Team", false, false); + } + + for (Player player : other.GetPlayers(false)) + if (player.isOnline()) + AddGems(player, 10, "Participation", false, false); + } + + //End + SetState(GameState.End); + } + } + } + + public void endCheckPlayer() + { + if (!IsLive()) + return; + + ArrayList teamsAlive = new ArrayList(); + + for (GameTeam team : this.GetTeamList()) + if (team.GetPlayers(false).size() > 0) + teamsAlive.add(team); + + if (teamsAlive.size() <= 1) + { + //Announce + if (teamsAlive.size() > 0) + AnnounceEnd(teamsAlive.get(0)); + + for (GameTeam team : GetTeamList()) + { + if (WinnerTeam != null && team.equals(WinnerTeam)) + { + for (Player player : team.GetPlayers(false)) + AddGems(player, 10, "Winning Team", false, false); + } + + for (Player player : team.GetPlayers(false)) + if (player.isOnline()) + AddGems(player, 10, "Participation", false, false); + } + + //End + SetState(GameState.End); + } + } + + @EventHandler + public void healthUpdate(UpdateEvent event) + { + if (!IsLive()) + return; + + if (event.getType() != UpdateType.SEC) + return; + + for (Player player : UtilServer.getPlayers()) + _scoreObj.getScore(player.getName()).setScore((int)(player.getHealth() * 5)); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void damageHealth(CustomDamageEvent event) + { + Player player = event.GetDamagerPlayer(true); + if (player == null) + return; + + _scoreObj.getScore(player.getName()).setScore((int)(player.getHealth() * 5)); + } + + @EventHandler + public void debug(PlayerCommandPreprocessEvent event) + { + if (!event.getPlayer().isOp()) + return; + + if (event.getMessage().contains("money")) + { + _shopManager.addMoney(event.getPlayer(), 16000, "Debug"); + event.setCancelled(true); + } + } + + //Used for fire grenade spread + public int getRound() + { + int rounds = 0; + + for (int i : _score.values()) + rounds += i; + + return rounds; + } + + @Override + public Location GetSpectatorLocation() + { + if (SpectatorSpawn != null) + return SpectatorSpawn; + + Vector vec = new Vector(0, 0, 0); + double count = 0; + + for (GameTeam team : this.GetTeamList()) + { + for (Location spawn : team.GetSpawns()) + { + count++; + vec.add(spawn.toVector()); + } + } + + SpectatorSpawn = new Location(this.WorldData.World, 0, 0, 0); + + vec.multiply(1d / count); + + SpectatorSpawn.setX(vec.getX()); + SpectatorSpawn.setY(vec.getY() + 7); //ADD 7 + SpectatorSpawn.setZ(vec.getZ()); + + // Move Up - Out Of Blocks + while (!UtilBlock.airFoliage(SpectatorSpawn.getBlock()) + || !UtilBlock.airFoliage(SpectatorSpawn.getBlock().getRelative(BlockFace.UP))) + { + SpectatorSpawn.add(0, 1, 0); + } + + int Up = 0; + + // Move Up - Through Air + for (int i = 0; i < 15; i++) + { + if (UtilBlock.airFoliage(SpectatorSpawn.getBlock().getRelative(BlockFace.UP))) + { + SpectatorSpawn.add(0, 1, 0); + Up++; + } + else + { + break; + } + } + + // Move Down - Out Of Blocks + while (Up > 0 && !UtilBlock.airFoliage(SpectatorSpawn.getBlock()) + || !UtilBlock.airFoliage(SpectatorSpawn.getBlock().getRelative(BlockFace.UP))) + { + SpectatorSpawn.subtract(0, 1, 0); + Up--; + } + + SpectatorSpawn = SpectatorSpawn.getBlock().getLocation().add(0.5, 0.1, 0.5); + + while (SpectatorSpawn.getBlock().getTypeId() != 0 || SpectatorSpawn.getBlock().getRelative(BlockFace.UP).getTypeId() != 0) + SpectatorSpawn.add(0, 1, 0); + + return SpectatorSpawn; + } + + public GunModule getGunModule() + { + return _gunModule; + } +} \ No newline at end of file From 891a3231d8c7f262097bb0520a21f3b5475dd8e4 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 21 Jul 2016 17:37:02 -0400 Subject: [PATCH 36/90] Change banner GUI --- .../clans/clans/banners/BannerManager.java | 9 +++++++ .../clans/banners/command/BannerCommand.java | 27 +++++++------------ .../gui/nonedit/NonEditOverviewGUI.java | 22 +++++++++++++++ 3 files changed, 40 insertions(+), 18 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerManager.java index b2d437f4b..689404b76 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerManager.java @@ -41,6 +41,15 @@ public class BannerManager extends MiniPlugin addCommand(new BannerCommand(this)); } + @Override + public void disable() + { + for (Block changed : _placedBanners.keySet()) + { + changed.setType(Material.AIR); + } + } + public int getBannerUnlockLevel(Player player) { int level = 0; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/command/BannerCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/command/BannerCommand.java index 66cb36aa2..1f93b5e94 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/command/BannerCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/command/BannerCommand.java @@ -13,7 +13,6 @@ import mineplex.game.clans.clans.banners.BannerManager; import mineplex.game.clans.clans.banners.BannerPattern; import mineplex.game.clans.clans.banners.ClanBanner; import mineplex.game.clans.clans.banners.gui.nonedit.NonEditOverviewGUI; -import mineplex.game.clans.clans.banners.gui.overview.OverviewGUI; import org.bukkit.DyeColor; import org.bukkit.entity.Player; @@ -34,23 +33,15 @@ public class BannerCommand extends CommandBase return; } ClanInfo clan = ClansManager.getInstance().getClan(caller); - if (clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER || Plugin.getBannerUnlockLevel(caller) < 2) + + if (Plugin.getBannerUnlockLevel(caller) < 1) { - if (Plugin.getBannerUnlockLevel(caller) < 1) - { - UtilPlayer.message(caller, F.main(Plugin.getName(), "You have not purchased the ability to use Clan banners! Buy it at http://www.mineplex.com/shop!")); - return; - } - if (!Plugin.LoadedBanners.containsKey(clan.getName())) - { - UtilPlayer.message(caller, F.main(Plugin.getName(), "Your Clan does not have a set banner!")); - return; - } - new NonEditOverviewGUI(caller, Plugin.LoadedBanners.get(clan.getName())); + UtilPlayer.message(caller, F.main(Plugin.getName(), "You have not purchased the ability to use Clan banners! Buy it at http://www.mineplex.com/shop!")); + return; } - else + if (!Plugin.LoadedBanners.containsKey(clan.getName())) { - if (!Plugin.LoadedBanners.containsKey(clan.getName())) + if (Plugin.getBannerUnlockLevel(caller) >= 2 && clan.getMembers().get(caller.getUniqueId()).getRole() == ClanRole.LEADER) { LinkedList patterns = new LinkedList<>(); for (int i = 0; i < 12; i++) @@ -60,13 +51,13 @@ public class BannerCommand extends CommandBase ClanBanner banner = new ClanBanner(Plugin, clan, DyeColor.WHITE, patterns); Plugin.LoadedBanners.put(clan.getName(), banner); banner.save(); - new OverviewGUI(caller, banner); } else { - ClanBanner banner = Plugin.LoadedBanners.get(clan.getName()); - new OverviewGUI(caller, banner); + UtilPlayer.message(caller, F.main(Plugin.getName(), "Your Clan does not have a set banner!")); + return; } } + new NonEditOverviewGUI(caller, Plugin.LoadedBanners.get(clan.getName())); } } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/nonedit/NonEditOverviewGUI.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/nonedit/NonEditOverviewGUI.java index d7a233e14..474007915 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/nonedit/NonEditOverviewGUI.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/nonedit/NonEditOverviewGUI.java @@ -5,15 +5,21 @@ import java.util.Arrays; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.game.clans.clans.ClanRole; +import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.banners.BannerPacketManager; import mineplex.game.clans.clans.banners.ClanBanner; import mineplex.game.clans.clans.banners.gui.BannerGUI; +import mineplex.game.clans.clans.banners.gui.overview.OverviewGUI; +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.ItemMeta; + public class NonEditOverviewGUI extends BannerGUI { private ClanBanner _banner; @@ -36,6 +42,11 @@ public class NonEditOverviewGUI extends BannerGUI im.setLore(Arrays.asList(new String[] {F.elem("Left Click") + " to toggle wearing your banner", F.elem("Right Click") + " to place down your banner"})); banner.setItemMeta(im); getItems().put(4, banner); + + if (_banner.getClan().getMembers().get(getViewer().getUniqueId()).getRole() == ClanRole.LEADER && ClansManager.getInstance().getBannerManager().getBannerUnlockLevel(getViewer()) >= 2) + { + getItems().put(8, new ItemBuilder(Material.ANVIL).setTitle(C.cGold + "Edit Your Banner").build()); + } refresh(); } @@ -54,5 +65,16 @@ public class NonEditOverviewGUI extends BannerGUI _banner.place(getViewer()); } } + if (slot == 8) + { + ClansManager.getInstance().runSyncLater(() -> + { + getViewer().closeInventory(); + }, 1L); + ClansManager.getInstance().runSyncLater(() -> + { + new OverviewGUI(getViewer(), _banner); + }, 2L); + } } } \ No newline at end of file From 869dfc1dfa7529f30fb77633f283e52af0be8f68 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 21 Jul 2016 20:21:11 -0400 Subject: [PATCH 37/90] Finalize Amplifier system --- .../game/clans/clans/ClansManager.java | 11 ++- .../clans/clans/amplifiers/Amplifier.java | 21 +++++- .../clans/amplifiers/AmplifierCommand.java | 20 ++++++ .../clans/clans/amplifiers/AmplifierGUI.java | 56 +++++++++++++-- .../clans/amplifiers/AmplifierManager.java | 65 +++++++++++++++++ .../miniboss/bosses/ArcherMiniboss.java | 8 ++- .../nether/miniboss/bosses/GhastMiniboss.java | 14 ++++ .../miniboss/bosses/WarriorMiniboss.java | 9 ++- .../game/clans/gameplay/Gameplay.java | 71 ++++++++++--------- 9 files changed, 232 insertions(+), 43 deletions(-) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierCommand.java diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index 017703571..0aee9a4bb 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -53,6 +53,7 @@ import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.Clans; import mineplex.game.clans.clans.ClanTips.TipType; import mineplex.game.clans.clans.ClansUtility.ClanRelation; +import mineplex.game.clans.clans.amplifiers.AmplifierManager; import mineplex.game.clans.clans.ban.ClansBanManager; import mineplex.game.clans.clans.banners.BannerManager; import mineplex.game.clans.clans.commands.ClanManagementCommand; @@ -195,6 +196,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati private ClassManager _classManager; private BannerManager _bannerManager; + private AmplifierManager _amplifierManager; public ClassManager getClassManager() { @@ -394,6 +396,8 @@ public class ClansManager extends MiniClientPluginimplements IRelati _scoreboard = new ClansScoreboardManager(plugin, this, _warManager, _worldEvent, _tutorial, clientManager, donationManager); _clanDataAccess = new ClansDataAccessLayer(this, _scoreboard); + _bannerManager = new BannerManager(plugin); + for (ClanToken token : _clanDataAccess.getRepository().retrieveClans()) { loadClan(token); @@ -457,7 +461,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati _siegeManager = new SiegeManager(this); _netherManager = new NetherManager(this); - _bannerManager = new BannerManager(plugin); + _amplifierManager = new AmplifierManager(plugin); } @Override @@ -544,6 +548,11 @@ public class ClansManager extends MiniClientPluginimplements IRelati return _bannerManager; } + public AmplifierManager getAmplifierManager() + { + return _amplifierManager; + } + public int getInviteExpire() { return _inviteExpire; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/Amplifier.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/Amplifier.java index 3c35c28d9..b07268b6f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/Amplifier.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/Amplifier.java @@ -6,8 +6,27 @@ import org.bukkit.entity.Player; public class Amplifier { + private Player _owner; + private long _end; + public Amplifier(Player owner, AmplifierType type) { - + _owner = owner; + _end = System.currentTimeMillis() + type.getDuration(); + } + + public Player getOwner() + { + return _owner; + } + + public long getRemainingTime() + { + return Math.max(0, _end - System.currentTimeMillis()); + } + + public boolean isEnded() + { + return System.currentTimeMillis() >= _end; } } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierCommand.java new file mode 100644 index 000000000..9c593a3b3 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierCommand.java @@ -0,0 +1,20 @@ +package mineplex.game.clans.clans.amplifiers; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; + +import org.bukkit.entity.Player; + +public class AmplifierCommand extends CommandBase +{ + public AmplifierCommand(AmplifierManager plugin) + { + super(plugin, Rank.ALL, "amplifier", "runeamplifier"); + } + + @Override + public void Execute(Player caller, String[] args) + { + new AmplifierGUI(caller, Plugin); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierGUI.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierGUI.java index 5fad8f14e..33962d83d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierGUI.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierGUI.java @@ -3,8 +3,9 @@ package mineplex.game.clans.clans.amplifiers; import java.util.HashMap; import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; import mineplex.core.itemstack.ItemBuilder; -import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.amplifiers.AmplifierManager.AmplifierType; import org.bukkit.Bukkit; @@ -19,7 +20,7 @@ import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; -public abstract class AmplifierGUI implements Listener +public class AmplifierGUI implements Listener { private Player _viewer; private AmplifierManager _manager; @@ -31,8 +32,12 @@ public abstract class AmplifierGUI implements Listener public AmplifierGUI(Player viewer, AmplifierManager manager) { _viewer = viewer; - _inventory = Bukkit.createInventory(viewer, 9 * Math.max(1, AmplifierType.values().length % 9), C.cClansNether + "Rune Amplifiers"); - Bukkit.getPluginManager().registerEvents(this, ClansManager.getInstance().getPlugin()); + _manager = manager; + _inventory = Bukkit.createInventory(viewer, 9, C.cClansNether + "Rune Amplifiers"); + Bukkit.getPluginManager().registerEvents(this, manager.getPlugin()); + + propagate(); + open(); } public Player getViewer() @@ -51,9 +56,13 @@ public abstract class AmplifierGUI implements Listener Integer slot = 0; for (AmplifierType type : AmplifierType.values()) { - getItems().put(slot, new ItemBuilder(Material.NETHER_STAR).setAmount(_manager.getAmountOwned(getViewer(), type)).setTitle(type.getDisplayName()).build()); + int owned = _manager.getAmountOwned(getViewer(), type); + owned = Math.max(owned, 0); + getItems().put(slot, new ItemBuilder(Material.NETHER_STAR).setAmount(Math.min(owned, 1)).setTitle(type.getDisplayName()).setLore(F.elem(owned) + " Owned").build()); _boundSlots.put(slot, type); + slot++; } + refresh(); } public void propagateConfirmation() @@ -62,13 +71,48 @@ public abstract class AmplifierGUI implements Listener _boundSlots.clear(); getItems().put(3, new ItemBuilder(Material.STAINED_GLASS_PANE).setData((short) 5).setTitle(C.cGreen + "Confirm").build()); getItems().put(5, new ItemBuilder(Material.STAINED_GLASS_PANE).setData((short) 14).setTitle(C.cRed + "Cancel").build()); + refresh(); } public void onClick(Integer slot, ClickType type) { if (_boundSlots.containsKey(slot)) { - + if (_manager.hasActiveAmplifier()) + { + UtilPlayer.message(getViewer(), F.main(_manager.getName(), "An amplifier is already active!")); + _manager.runSyncLater(() -> + { + getViewer().closeInventory(); + }, 1L); + } + else + { + _selected = _boundSlots.get(slot); + if (_manager.getAmountOwned(getViewer(), _selected) > 0) + { + propagateConfirmation(); + } + else + { + UtilPlayer.message(getViewer(), F.main(_manager.getName(), "You do not have enough of that amplifier! Purchase some at http://www.mineplex.com/shop!")); + } + } + return; + } + + if (slot == 3) + { + _manager.runSyncLater(() -> + { + _manager.useAmplifier(getViewer(), _selected); + getViewer().closeInventory(); + }, 1L); + } + if (slot == 5) + { + _selected = null; + propagate(); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierManager.java index c8d2cca37..8995f38c5 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierManager.java @@ -2,20 +2,36 @@ package mineplex.game.clans.clans.amplifiers; import mineplex.core.MiniPlugin; import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClansManager; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.plugin.java.JavaPlugin; public class AmplifierManager extends MiniPlugin { private static final String AMPLIFIER_NAME = "Rune Amplifier"; + private Amplifier _active; public AmplifierManager(JavaPlugin plugin) { super("Rune Amplifiers", plugin); + + addCommand(new AmplifierCommand(this)); + } + + public boolean hasActiveAmplifier() + { + return _active != null; } public int getAmountOwned(Player player, AmplifierType type) @@ -23,6 +39,55 @@ public class AmplifierManager extends MiniPlugin return ClansManager.getInstance().getInventoryManager().Get(player).getItemCount(type.getFullItemName()); } + public void useAmplifier(Player user, AmplifierType type) + { + if (getAmountOwned(user, type) < 1) + { + return; + } + if (hasActiveAmplifier()) + { + return; + } + ClansManager.getInstance().getInventoryManager().addItemToInventory(user, type.getFullItemName(), -1); + UtilTextMiddle.display(C.cClansNether + AMPLIFIER_NAME, "Has been activated by " + F.elem(user.getName())); + Bukkit.broadcastMessage(F.main(getName(), "A " + F.clansNether(AMPLIFIER_NAME) + " has been activated on this server by " + F.elem(user.getName()) + " for " + F.elem(UtilTime.MakeStr(type.getDuration())) + "!")); + _active = new Amplifier(user, type); + runSyncLater(() -> + { + ClansManager.getInstance().getNetherManager().spawnPortal(type.getDuration()); + }, 60L); + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + if (_active != null && _active.isEnded()) + { + Bukkit.broadcastMessage(F.main(getName(), "The " + F.clansNether(AMPLIFIER_NAME) + " owned by " + F.elem(_active.getOwner()) + " has run out! You can purchase another at http://www.mineplex.com/shop!")); + _active = null; + } + } + + @EventHandler + public void onJoin(PlayerJoinEvent event) + { + if (_active != null) + { + runSyncLater(() -> + { + if (_active != null) + { + UtilPlayer.message(event.getPlayer(), F.main(getName(), "A " + F.clansNether(AMPLIFIER_NAME) + " owned by " + F.elem(_active.getOwner().getName()) + " is active on this server with " + F.elem(UtilTime.MakeStr(_active.getRemainingTime())) + " remaining!")); + } + }, 40L); + } + } + public static enum AmplifierType { TWENTY("20", "Twenty Minute Amplifier", UtilTime.convert(20, TimeUnit.MINUTES, TimeUnit.MILLISECONDS)), diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/ArcherMiniboss.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/ArcherMiniboss.java index d41f3f8e1..8248772bb 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/ArcherMiniboss.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/ArcherMiniboss.java @@ -33,6 +33,7 @@ import org.bukkit.potion.PotionEffectType; public class ArcherMiniboss extends NetherMiniBoss { private static final int BARBED_LEVEL = 1; + private static final double RUNE_DROP_CHANCE = .1; public ArcherMiniboss(String displayName, Double maxHealth, Location spawn, EntityType type) { @@ -61,7 +62,12 @@ public class ArcherMiniboss extends NetherMiniBoss public void customDeath(Location deathLocation) { deathLocation.getWorld().dropItemNaturally(deathLocation, new ItemStack(Material.DIAMOND, UtilMath.r(5) + 1)); - if (new Random().nextDouble() <= .1) + double runeDropChance = RUNE_DROP_CHANCE; + if (ClansManager.getInstance().getAmplifierManager().hasActiveAmplifier()) + { + runeDropChance *= 2; + } + if (new Random().nextDouble() <= runeDropChance) { RuneAttribute runeType = RuneAttribute.values()[UtilMath.r(RuneAttribute.values().length)]; deathLocation.getWorld().dropItemNaturally(deathLocation, ClansManager.getInstance().getGearManager().getRuneManager().getRune(runeType)); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/GhastMiniboss.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/GhastMiniboss.java index 800106b0d..79d2ae5ea 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/GhastMiniboss.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/GhastMiniboss.java @@ -1,10 +1,13 @@ package mineplex.game.clans.clans.nether.miniboss.bosses; +import java.util.Random; + import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilTime; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.nether.miniboss.MinibossFireball; import mineplex.game.clans.clans.nether.miniboss.NetherMiniBoss; +import mineplex.game.clans.items.runes.RuneManager.RuneAttribute; import org.bukkit.Location; import org.bukkit.Material; @@ -22,6 +25,7 @@ public class GhastMiniboss extends NetherMiniBoss private static final long MAIN_FIREBALL_COOLDOWN = 5000; private static final long FIREBALL_LAUNCH_RATE = 500; private static final int FIREBALLS_PER_USE = 5; + private static final double RUNE_DROP_CHANCE = .1; private long _lastFireballUse; private int _fireballsRemaining; @@ -61,6 +65,16 @@ public class GhastMiniboss extends NetherMiniBoss public void customDeath(Location deathLocation) { deathLocation.getWorld().dropItemNaturally(deathLocation, new ItemStack(Material.DIAMOND, UtilMath.r(5) + 1)); + double runeDropChance = RUNE_DROP_CHANCE; + if (ClansManager.getInstance().getAmplifierManager().hasActiveAmplifier()) + { + runeDropChance *= 2; + } + if (new Random().nextDouble() <= runeDropChance) + { + RuneAttribute runeType = RuneAttribute.values()[UtilMath.r(RuneAttribute.values().length)]; + deathLocation.getWorld().dropItemNaturally(deathLocation, ClansManager.getInstance().getGearManager().getRuneManager().getRune(runeType)); + } } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/WarriorMiniboss.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/WarriorMiniboss.java index 2e275f6e4..b0f0c98b3 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/WarriorMiniboss.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/WarriorMiniboss.java @@ -31,6 +31,8 @@ import org.bukkit.potion.PotionEffectType; */ public class WarriorMiniboss extends NetherMiniBoss { + private static final double RUNE_DROP_CHANCE = .1; + public WarriorMiniboss(String displayName, Double maxHealth, Location spawn, EntityType type) { super(displayName, maxHealth, spawn, type); @@ -58,7 +60,12 @@ public class WarriorMiniboss extends NetherMiniBoss public void customDeath(Location deathLocation) { deathLocation.getWorld().dropItemNaturally(deathLocation, new ItemStack(Material.DIAMOND, UtilMath.r(5) + 1)); - if (new Random().nextDouble() <= .1) + double runeDropChance = RUNE_DROP_CHANCE; + if (ClansManager.getInstance().getAmplifierManager().hasActiveAmplifier()) + { + runeDropChance *= 2; + } + if (new Random().nextDouble() <= runeDropChance) { RuneAttribute runeType = RuneAttribute.values()[UtilMath.r(RuneAttribute.values().length)]; deathLocation.getWorld().dropItemNaturally(deathLocation, ClansManager.getInstance().getGearManager().getRuneManager().getRune(runeType)); 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 3807c267e..df5d6e2cb 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 @@ -4,6 +4,38 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; +import mineplex.core.MiniPlugin; +import mineplex.core.blockrestore.BlockRestore; +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.UtilGear; +import mineplex.core.common.util.UtilInv; +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.common.util.UtilTime; +import mineplex.core.common.weight.Weight; +import mineplex.core.common.weight.WeightSet; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClanInfo; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.event.ClansWaterPlaceEvent; +import mineplex.game.clans.clans.event.IronDoorOpenEvent; +import mineplex.game.clans.core.repository.ClanTerritory; +import mineplex.game.clans.items.GearManager; +import mineplex.minecraft.game.classcombat.Class.ClientClass; +import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; +import mineplex.minecraft.game.classcombat.Skill.event.BlockTossEvent; +import mineplex.minecraft.game.classcombat.Skill.event.BlockTossLandEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import mineplex.minecraft.game.core.damage.DamageManager; + import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.DyeColor; @@ -14,7 +46,6 @@ import org.bukkit.Sound; import org.bukkit.block.Biome; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; -import org.bukkit.block.Chest; import org.bukkit.entity.EntityType; import org.bukkit.entity.ItemFrame; import org.bukkit.entity.Player; @@ -47,38 +78,6 @@ import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.material.Dye; import org.bukkit.plugin.java.JavaPlugin; -import mineplex.core.MiniPlugin; -import mineplex.core.blockrestore.BlockRestore; -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.UtilGear; -import mineplex.core.common.util.UtilInv; -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.common.util.UtilTime; -import mineplex.core.common.util.UtilWorld; -import mineplex.core.common.weight.Weight; -import mineplex.core.common.weight.WeightSet; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.recharge.Recharge; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.game.clans.clans.ClanInfo; -import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.clans.event.ClansWaterPlaceEvent; -import mineplex.game.clans.clans.event.IronDoorOpenEvent; -import mineplex.game.clans.core.repository.ClanTerritory; -import mineplex.minecraft.game.classcombat.Class.ClientClass; -import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; -import mineplex.minecraft.game.classcombat.Skill.event.BlockTossEvent; -import mineplex.minecraft.game.classcombat.Skill.event.BlockTossLandEvent; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import mineplex.minecraft.game.core.damage.DamageManager; - public class Gameplay extends MiniPlugin { private ClansManager _clansManager; @@ -828,6 +827,12 @@ public class Gameplay extends MiniPlugin return; } + if (GearManager.isCustomItem(item)) + { + UtilPlayer.message(player, F.main("Repair", "You cannot repair " + F.item(item.getItemMeta().getDisplayName()) + ".")); + return; + } + int repairs = ItemStackFactory.Instance.GetLoreVar(item, "Repaired", 0); boolean canRepair = canRepair(item); From 818ed4c9a9d7479a8ee60e90c630a48ef95e7233 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 22 Jul 2016 00:18:34 -0400 Subject: [PATCH 38/90] Set up clans monetization features in the shop and fix some hardcoded names in core --- .../mineplex/core/message/MessageManager.java | 7 +- .../src/mineplex/enjinTranslator/Enjin.java | 92 ++++++++++++++++--- .../clans/clans/banners/BannerManager.java | 4 +- .../src/mineplex/staffServer/StaffServer.java | 3 +- .../salespackage/SalesPackageManager.java | 9 ++ .../salespackages/ClanBannerEditor.java | 20 ++++ .../salespackages/ClanBannerUsage.java | 20 ++++ .../salespackages/RuneAmplifier.java | 22 +++++ 8 files changed, 157 insertions(+), 20 deletions(-) create mode 100644 Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/ClanBannerEditor.java create mode 100644 Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/ClanBannerUsage.java create mode 100644 Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/RuneAmplifier.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java b/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java index 3faaee528..cc1c8d686 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java @@ -215,12 +215,7 @@ public class MessageManager extends MiniClientPlugin Get(from).LastToTime = System.currentTimeMillis(); // Chiss or defek7 - if (to.getName().equals("Chiss") || to.getName().equals("defek7") || to.getName().equals("Phinary") || to.getName().equals("AlexTheCoder")) - { - UtilPlayer.message(from, C.cPurple + to.getName() + " is often AFK or minimized, due to plugin development."); - UtilPlayer.message(from, C.cPurple + "Please be patient if he does not reply instantly."); - } - if (to.getName().equals("xXVevzZXx")) + if (GetClientManager().Get(to).GetRank() == Rank.DEVELOPER) { UtilPlayer.message(from, C.cPurple + to.getName() + " is often AFK or minimized, due to plugin development."); UtilPlayer.message(from, C.cPurple + "Please be patient if she does not reply instantly."); diff --git a/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java b/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java index 3c569acb1..c04d1b6a9 100644 --- a/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java +++ b/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java @@ -120,23 +120,26 @@ public class Enjin extends MiniPlugin implements CommandExecutor final UUID playerUUID = uuid; _cachedUUIDs.put(name, new AbstractMap.SimpleEntry(playerUUID, System.currentTimeMillis() + 240000)); - - if (!checkForBoosterPurchase(args, name, playerUUID, client)) + + if (!checkForClansPurchase(args, name, client)) { - if (!checkForCoinPurchase(args, name, playerUUID, client)) + if (!checkForBoosterPurchase(args, name, playerUUID, client)) { - if (!checkForRankPurchase(args, name, playerUUID, client)) + if (!checkForCoinPurchase(args, name, playerUUID, client)) { - if (!checkForPurchase(args, name, client)) + if (!checkForRankPurchase(args, name, playerUUID, client)) { - StringBuilder sb = new StringBuilder(); - - for (String arg : args) + if (!checkForPurchase(args, name, client)) { - sb.append(arg + " "); - } + StringBuilder sb = new StringBuilder(); - System.out.println("Received Command : " + sb.toString()); + for (String arg : args) + { + sb.append(arg + " "); + } + + System.out.println("Received Command : " + sb.toString()); + } } } } @@ -293,4 +296,71 @@ public class Enjin extends MiniPlugin implements CommandExecutor return true; } + + protected boolean checkForClansPurchase(String[] args, final String name, final CoreClient client) + { + if (args.length >= 3 && args[0].equalsIgnoreCase("clansBanner")) + { + String purchase = "Clan Banner Usage"; + if (args[2].equalsIgnoreCase("true")) + { + purchase = "Clan Banner Editor"; + } + final String packageName = purchase; + + _donationManager.PurchaseUnknownSalesPackage(new Callback() + { + public void run(TransactionResponse data) + { + if (data == TransactionResponse.Success) + { + _inventoryManager.addItemToInventoryForOffline(new Callback() + { + public void run(Boolean success) + { + if (success) + { + _purchaseManager.addAccountPurchaseToQueue(client.getAccountId(), packageName, 1, true); + System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " received their " + packageName + " access."); + } + else + { + System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + name + " " + packageName + ". Queuing for run later."); + _purchaseManager.addAccountPurchaseToQueue(client.getAccountId(), packageName, 1, false); + } + } + }, client.getAccountId(), packageName, 1); + } + else + { + System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + name + " 1" + ". Queuing for run later."); + _purchaseManager.addAccountPurchaseToQueue(client.getAccountId(), packageName, 1, data == TransactionResponse.Success); + } + } + }, name, client.getAccountId(), packageName, CurrencyType.GEM, 0, false); + //enjin_mineplex clansBanner AlexTheCoder true + return true; + } + if (args.length >= 4 && args[0].equalsIgnoreCase("clansAmplifier")) + { + //enjin_mineplex clansAmplifier AlexTheCoder 20 1 + final String item = "Rune Amplifier " + args[2]; + final int amount = Integer.parseInt(args[3]); + + _inventoryManager.addItemToInventoryForOffline(new Callback() + { + public void run (Boolean response) + { + if (response) + System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " received " + amount + " rune amplifiers."); + else + System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + name + " " + amount + " rune amplifiers. Queuing for run later."); + + _purchaseManager.addAccountPurchaseToQueue(client.getAccountId(), item, amount, response); + } + }, client.getAccountId(), item, amount); + } + + return false; + } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerManager.java index 689404b76..9877b5c91 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerManager.java @@ -53,11 +53,11 @@ public class BannerManager extends MiniPlugin public int getBannerUnlockLevel(Player player) { int level = 0; - if (ClansManager.getInstance().getDonationManager().Get(player).OwnsUnknownPackage("UseClanBanner")) + if (ClansManager.getInstance().getDonationManager().Get(player).OwnsUnknownPackage("Clan Banner Usage")) { level = 1; } - if (ClansManager.getInstance().getDonationManager().Get(player).OwnsUnknownPackage("MakeClanBanner")) + if (ClansManager.getInstance().getDonationManager().Get(player).OwnsUnknownPackage("Clan Banner Editor")) { level = 2; } diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java index 282933d23..89a6523c0 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java @@ -82,12 +82,13 @@ public class StaffServer extends JavaPlugin ((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("377bdea3-badc-448d-81c1-65db43b17ea4"), "Strutt20")); ((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("cf1b629c-cc55-4eb4-be9e-3ca86dfc7b9d"), "mannalou")); - ((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("04a484d0-93e0-4777-a70c-808046917e3a"), "EvilEsther")); + ((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("04a484d0-93e0-4777-a70c-808046917e3a"), "EstherCS")); ((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("adaa7613-6683-400f-baf8-7272c04b2cb4"), "Timmy48081_")); ((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("231fb752-9556-489b-8428-f47c7598e061"), "Nuclear_Poptart")); ((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("efaf9a17-2304-4f42-8433-421523c308dc"), "B2_mp")); ((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("492ff708-fe76-4c5a-b9ed-a747b5fa20a0"), "Cherdy8s")); ((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("6edf17d5-6bb2-4ed9-92e9-bed8e96fff68"), "BlueBeetleHD")); + ((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("a47a4d04-9f51-44ba-9d35-8de6053e9289"), "AlexTheCoder")); ((CraftServer)getServer()).getHandle().addOp(new GameProfile(UUID.fromString("377bdea3-badc-448d-81c1-65db43b17ea4"), "Strutt20")); diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java index 67dea4d96..97bc832c7 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java @@ -54,6 +54,10 @@ public class SalesPackageManager extends MiniPlugin //AddSalesPackage(new ValentinesGift(this)); AddSalesPackage(new FrostLord(this)); AddSalesPackage(new EasterBunny(this)); + AddSalesPackage(new ClanBannerUsage(this)); + AddSalesPackage(new ClanBannerEditor(this)); + AddSalesPackage(new RuneAmplifier(this, 20)); + AddSalesPackage(new RuneAmplifier(this, 60)); } private void AddSalesPackage(SalesPackageBase salesPackage) @@ -97,6 +101,7 @@ public class SalesPackageManager extends MiniPlugin JsonMessage coinBuilder = new JsonMessage("Shards : ").color("blue"); JsonMessage packageBuilder = new JsonMessage("Rank Packages : ").color("blue"); JsonMessage chestBuilder = new JsonMessage("Chest Packages : ").color("blue"); + JsonMessage clanBuilder = new JsonMessage("Clan Packages : ").color("blue"); for (SalesPackageBase salesPackage : _salesPackages.values()) { @@ -108,6 +113,10 @@ public class SalesPackageManager extends MiniPlugin { chestBuilder = chestBuilder.extra("[").color("gray").extra(salesPackage.getName()).color("green").click("run_command", "/display " + playerName + " " + salesPackage.getName()).extra("] ").color("gray"); } + else if (salesPackage instanceof ClanBannerEditor || salesPackage instanceof ClanBannerUsage || salesPackage instanceof RuneAmplifier) + { + clanBuilder = clanBuilder.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"); diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/ClanBannerEditor.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/ClanBannerEditor.java new file mode 100644 index 000000000..7c998baeb --- /dev/null +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/ClanBannerEditor.java @@ -0,0 +1,20 @@ +package mineplex.staffServer.salespackage.salespackages; + +import mineplex.staffServer.salespackage.SalesPackageManager; + +import org.bukkit.entity.Player; + +public class ClanBannerEditor extends SalesPackageBase +{ + public ClanBannerEditor(SalesPackageManager manager) + { + super(manager, "Clan Banner Editor Access"); + } + + public void displayToAgent(Player agent, String playerName) + { + addButton(agent, "/sales item " + playerName + " 1 Unlock Clan Banner Editor", "Give Clan Banner Editor access."); + agent.sendMessage(" "); + addBackButton(agent, playerName); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/ClanBannerUsage.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/ClanBannerUsage.java new file mode 100644 index 000000000..4edce3544 --- /dev/null +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/ClanBannerUsage.java @@ -0,0 +1,20 @@ +package mineplex.staffServer.salespackage.salespackages; + +import mineplex.staffServer.salespackage.SalesPackageManager; + +import org.bukkit.entity.Player; + +public class ClanBannerUsage extends SalesPackageBase +{ + public ClanBannerUsage(SalesPackageManager manager) + { + super(manager, "Clan Banner Usage Access"); + } + + public void displayToAgent(Player agent, String playerName) + { + addButton(agent, "/sales item " + playerName + " 1 Unlock Clan Banner Usage", "Give Clan Banner Usage access."); + agent.sendMessage(" "); + addBackButton(agent, playerName); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/RuneAmplifier.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/RuneAmplifier.java new file mode 100644 index 000000000..18c1054fb --- /dev/null +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/RuneAmplifier.java @@ -0,0 +1,22 @@ +package mineplex.staffServer.salespackage.salespackages; + +import mineplex.staffServer.salespackage.SalesPackageManager; +import org.bukkit.entity.Player; + +public class RuneAmplifier extends SalesPackageBase +{ + private int _minutes; + + public RuneAmplifier(SalesPackageManager manager, int minutes) + { + super(manager, "1 " + minutes + " minutes Rune Amplifier"); + _minutes = minutes; + } + + public void displayToAgent(Player agent, String playerName) + { + addButton(agent, "/sales item " + playerName + " 1 Item Rune Amplifier " + _minutes, "Give 1 " + _minutes + " minute Rune Amplifier."); + agent.sendMessage(" "); + addBackButton(agent, playerName); + } +} \ No newline at end of file From 9fab8366b7f6357f3cd49c27fa600b6967b0607f Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 25 Jul 2016 10:52:48 -0400 Subject: [PATCH 39/90] Add support for clans hub connection inside bungees --- .../src/mineplex/bungee/Mineplexer.java | 9 +-- .../bungee/lobbyBalancer/LobbyBalancer.java | 67 ++++++++++++++----- .../src/mineplex/bungee/motd/MotdManager.java | 57 +++++++++++----- 3 files changed, 96 insertions(+), 37 deletions(-) diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/Mineplexer.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/Mineplexer.java index 56e179590..e780804a7 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/Mineplexer.java +++ b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/Mineplexer.java @@ -16,9 +16,11 @@ public class Mineplexer extends Plugin { @Override public void onEnable() { - getProxy().getScheduler().runAsync(this, new Runnable() { + getProxy().getScheduler().runAsync(this, new Runnable() + { @Override - public void run() { + public void run() + { // Sentry setup Handler sentry = new SentryHandler(new DefaultRavenFactory().createRavenInstance( new Dsn("https://470f12378af3453ba089e0c0a0c9aae6:292516b722594784807aebb06db8ec38@app.getsentry.com/66323" @@ -30,10 +32,9 @@ public class Mineplexer extends Plugin new MotdManager(this); new LobbyBalancer(this); - PlayerCount playerCount = new PlayerCount(this); + new PlayerCount(this); new FileUpdater(this); new PlayerStats(this); - //new InternetStatus(this); new PlayerTracker(this); } } 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 5f7153ae9..0c57abfea 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/lobbyBalancer/LobbyBalancer.java +++ b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/lobbyBalancer/LobbyBalancer.java @@ -2,7 +2,6 @@ package mineplex.bungee.lobbyBalancer; import java.io.File; import java.net.InetSocketAddress; -import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; @@ -12,21 +11,24 @@ import mineplex.serverdata.Region; import mineplex.serverdata.data.MinecraftServer; import mineplex.serverdata.servers.ServerManager; import mineplex.serverdata.servers.ServerRepository; -import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.api.event.ServerConnectEvent; import net.md_5.bungee.api.plugin.Listener; import net.md_5.bungee.api.plugin.Plugin; import net.md_5.bungee.event.EventHandler; +import com.google.common.collect.Lists; + public class LobbyBalancer implements Listener, Runnable { private Plugin _plugin; private ServerRepository _repository; - private List _sortedLobbies = new ArrayList(); + private List _sortedLobbies = Lists.newArrayList(); + private List _sortedClans = Lists.newArrayList(); private static Object _serverLock = new Object(); private int _lobbyIndex = 0; + private int _clansIndex = 0; public LobbyBalancer(Plugin plugin) { @@ -35,7 +37,7 @@ public class LobbyBalancer implements Listener, Runnable Region region = !new File("eu.dat").exists() ? Region.US : Region.EU; _repository = ServerManager.getServerRepository(region); - loadLobbyServers(); + run(); _plugin.getProxy().getPluginManager().registerListener(_plugin, this); _plugin.getProxy().getScheduler().schedule(_plugin, this, 500L, 500L, TimeUnit.MILLISECONDS); @@ -44,27 +46,49 @@ public class LobbyBalancer implements Listener, Runnable @EventHandler public void playerConnect(ServerConnectEvent event) { - if (!event.getTarget().getName().equalsIgnoreCase("Lobby")) - return; - - synchronized (_serverLock) + if (event.getTarget().getName().equalsIgnoreCase("Lobby")) { - if (_lobbyIndex >= _sortedLobbies.size() || _sortedLobbies.get(_lobbyIndex).getPlayerCount() >= _sortedLobbies.get(_lobbyIndex).getMaxPlayerCount()) - _lobbyIndex = 0; - - event.setTarget(_plugin.getProxy().getServerInfo(_sortedLobbies.get(_lobbyIndex).getName())); - _sortedLobbies.get(_lobbyIndex).incrementPlayerCount(1); - System.out.println("Sending " + event.getPlayer().getName() + " to " + _sortedLobbies.get(_lobbyIndex).getName() + "(" + _sortedLobbies.get(_lobbyIndex).getPublicAddress() + ")"); - _lobbyIndex++; + synchronized (_serverLock) + { + if (_lobbyIndex >= _sortedLobbies.size() || _sortedLobbies.get(_lobbyIndex).getPlayerCount() >= _sortedLobbies.get(_lobbyIndex).getMaxPlayerCount()) + _lobbyIndex = 0; + + event.setTarget(_plugin.getProxy().getServerInfo(_sortedLobbies.get(_lobbyIndex).getName())); + _sortedLobbies.get(_lobbyIndex).incrementPlayerCount(1); + System.out.println("Sending " + event.getPlayer().getName() + " to " + _sortedLobbies.get(_lobbyIndex).getName() + "(" + _sortedLobbies.get(_lobbyIndex).getPublicAddress() + ")"); + _lobbyIndex++; + } + } + if (event.getTarget().getName().equalsIgnoreCase("ClansHub")) + { + synchronized (_serverLock) + { + if (_clansIndex >= _sortedClans.size() || _sortedClans.get(_clansIndex).getPlayerCount() >= _sortedClans.get(_clansIndex).getMaxPlayerCount()) + _clansIndex = 0; + + event.setTarget(_plugin.getProxy().getServerInfo(_sortedClans.get(_clansIndex).getName())); + _sortedClans.get(_clansIndex).incrementPlayerCount(1); + System.out.println("Sending " + event.getPlayer().getName() + " to " + _sortedClans.get(_clansIndex).getName() + "(" + _sortedClans.get(_clansIndex).getPublicAddress() + ")"); + _clansIndex++; + } } } public void run() { - loadLobbyServers(); + loadServers(); + + if (!_plugin.getProxy().getServers().containsKey("ClansHub")) + { + _plugin.getProxy().getServers().put("ClansHub", _plugin.getProxy().constructServerInfo("ClansHub", new InetSocketAddress("lobby.mineplex.com", 25565), "LobbyBalancer", false)); + } + if (!_plugin.getProxy().getServers().containsKey("Lobby")) + { + _plugin.getProxy().getServers().put("Lobby", _plugin.getProxy().constructServerInfo("Lobby", new InetSocketAddress("lobby.mineplex.com", 25565), "LobbyBalancer", false)); + } } - public void loadLobbyServers() + public void loadServers() { Collection servers = _repository.getServerStatuses(); @@ -72,6 +96,7 @@ public class LobbyBalancer implements Listener, Runnable { long startTime = System.currentTimeMillis(); _sortedLobbies.clear(); + _sortedClans.clear(); for (MinecraftServer server : servers) { @@ -88,9 +113,17 @@ public class LobbyBalancer implements Listener, Runnable _sortedLobbies.add(server); } } + if (server.getName().toUpperCase().startsWith("CLANSHUB")) + { + if (server.getMotd() == null || !server.getMotd().contains("Restarting")) + { + _sortedClans.add(server); + } + } } Collections.sort(_sortedLobbies, new LobbySorter()); + Collections.sort(_sortedClans, new LobbySorter()); long timeSpentInLock = System.currentTimeMillis() - startTime; diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/motd/MotdManager.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/motd/MotdManager.java index 1f5bc2b09..aa2565f27 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/motd/MotdManager.java +++ b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/motd/MotdManager.java @@ -1,20 +1,18 @@ package mineplex.bungee.motd; -import java.awt.Color; import java.io.File; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Random; import java.util.concurrent.TimeUnit; import mineplex.serverdata.Region; -import mineplex.serverdata.data.BungeeServer; import mineplex.serverdata.data.DataRepository; import mineplex.serverdata.redis.RedisDataRepository; import mineplex.serverdata.servers.ConnectionData; -import mineplex.serverdata.servers.ServerManager; import mineplex.serverdata.servers.ConnectionData.ConnectionType; -import net.md_5.bungee.api.ChatColor; +import mineplex.serverdata.servers.ServerManager; import net.md_5.bungee.api.event.ProxyPingEvent; import net.md_5.bungee.api.plugin.Listener; import net.md_5.bungee.api.plugin.Plugin; @@ -31,6 +29,8 @@ public class MotdManager implements Listener, Runnable private Random _random = new Random(); private String _firstLine = " §b§l§m §8§l§m[ §r §9§lMineplex§r §f§lGames§r §8§l§m ]§b§l§m §r"; private List _motdLines; + private String _firstCLine = " §b§l§m §8§l§m[ §r §9§lMineplex§r §f§lGames§r §8§l§m ]§b§l§m §r"; + private List _motdCLines; public MotdManager(Plugin plugin) { @@ -70,25 +70,50 @@ public class MotdManager implements Listener, Runnable public void serverPing(ProxyPingEvent event) { net.md_5.bungee.api.ServerPing serverPing = event.getResponse(); - - String motd = _firstLine; - if (_motdLines != null && _motdLines.size() > 0) + if (event.getConnection().getListener() != null && event.getConnection().getListener().getDefaultServer().equalsIgnoreCase("ClansHub")) { - motd += "\n" + _motdLines.get(_random.nextInt(_motdLines.size())); + String motd = _firstCLine; + if (_motdCLines != null && _motdCLines.size() > 0) + { + motd += "\n" + _motdCLines.get(_random.nextInt(_motdCLines.size())); + } + event.setResponse(new net.md_5.bungee.api.ServerPing(serverPing.getVersion(), serverPing.getPlayers(), motd, serverPing.getFaviconObject())); + } + else + { + String motd = _firstLine; + if (_motdLines != null && _motdLines.size() > 0) + { + motd += "\n" + _motdLines.get(_random.nextInt(_motdLines.size())); + } + event.setResponse(new net.md_5.bungee.api.ServerPing(serverPing.getVersion(), serverPing.getPlayers(), motd, serverPing.getFaviconObject())); } - - event.setResponse(new net.md_5.bungee.api.ServerPing(serverPing.getVersion(), serverPing.getPlayers(), motd, serverPing.getFaviconObject())); } @Override public void run() { - GlobalMotd motd = _repository.getElement("MainMotd"); - - if (motd != null) - { - _motdLines = motd.getMotd(); - _firstLine = motd.getHeadline(); + { + GlobalMotd motd = _repository.getElement("MainMotd"); + + if (motd != null) + { + _motdLines = motd.getMotd(); + _firstLine = motd.getHeadline(); + } + } + { + GlobalMotd motd = _repository.getElement("ClansMotd"); + + if (motd != null) + { + _motdCLines = motd.getMotd(); + _firstCLine = motd.getHeadline(); + } + else + { + _repository.addElement(new GlobalMotd("ClansMotd", "§4§lMineplex Clans§r", Arrays.asList("Default MOTD"))); + } } } From 275ab52f790ca93b4ebd5a961930df8515ac89c0 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 25 Jul 2016 10:55:18 -0400 Subject: [PATCH 40/90] Create a clans-only hub --- Plugins/Mineplex.Hub.Clans/plugin.yml | 3 + Plugins/Mineplex.Hub.Clans/pom.xml | 28 + .../src/mineplex/clanshub/ClansHub.java | 164 ++++ .../mineplex/clanshub/ClansServerPage.java | 144 +++ .../mineplex/clanshub/ClansServerShop.java | 40 + .../clanshub/ClansTransferManager.java | 259 +++++ .../mineplex/clanshub/ForcefieldManager.java | 96 ++ .../src/mineplex/clanshub/HubManager.java | 912 ++++++++++++++++++ .../clanshub/HubVisibilityManager.java | 80 ++ .../mineplex/clanshub/JoinServerButton.java | 50 + .../src/mineplex/clanshub/ServerInfo.java | 13 + .../src/mineplex/clanshub/WorldManager.java | 208 ++++ .../clanshub/commands/ForcefieldRadius.java | 21 + .../clanshub/commands/GadgetToggle.java | 21 + .../clanshub/commands/GameModeCommand.java | 49 + .../clanshub/profile/buttons/ButtonPrefs.java | 55 ++ .../clanshub/profile/buttons/ButtonStats.java | 63 ++ .../clanshub/profile/gui/GUIProfile.java | 36 + 18 files changed, 2242 insertions(+) create mode 100644 Plugins/Mineplex.Hub.Clans/plugin.yml create mode 100644 Plugins/Mineplex.Hub.Clans/pom.xml create mode 100644 Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java create mode 100644 Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansServerPage.java create mode 100644 Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansServerShop.java create mode 100644 Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansTransferManager.java create mode 100644 Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ForcefieldManager.java create mode 100644 Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java create mode 100644 Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubVisibilityManager.java create mode 100644 Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/JoinServerButton.java create mode 100644 Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ServerInfo.java create mode 100644 Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/WorldManager.java create mode 100644 Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/ForcefieldRadius.java create mode 100644 Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/GadgetToggle.java create mode 100644 Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/GameModeCommand.java create mode 100644 Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/profile/buttons/ButtonPrefs.java create mode 100644 Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/profile/buttons/ButtonStats.java create mode 100644 Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/profile/gui/GUIProfile.java diff --git a/Plugins/Mineplex.Hub.Clans/plugin.yml b/Plugins/Mineplex.Hub.Clans/plugin.yml new file mode 100644 index 000000000..5bc1ff2f7 --- /dev/null +++ b/Plugins/Mineplex.Hub.Clans/plugin.yml @@ -0,0 +1,3 @@ +name: ClansHub +main: mineplex.clanshub.ClansHub +version: 0.1 \ No newline at end of file diff --git a/Plugins/Mineplex.Hub.Clans/pom.xml b/Plugins/Mineplex.Hub.Clans/pom.xml new file mode 100644 index 000000000..b5bc14c36 --- /dev/null +++ b/Plugins/Mineplex.Hub.Clans/pom.xml @@ -0,0 +1,28 @@ + + + 4.0.0 + + + com.mineplex + mineplex-plugin + dev-SNAPSHOT + ../plugin.xml + + + ClansHub + mineplex-clanshub + + + + ${project.groupId} + mineplex-game-clans-core + ${project.version} + + + ${project.groupId} + mineplex-minecraft-game-core + ${project.version} + + + diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java new file mode 100644 index 000000000..9360191e5 --- /dev/null +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java @@ -0,0 +1,164 @@ +package mineplex.clanshub; + +import mineplex.core.CustomTagFix; +import mineplex.core.PacketsInteractionFix; +import mineplex.core.account.CoreClientManager; +import mineplex.core.achievement.AchievementManager; +import mineplex.core.antihack.AntiHack; +import mineplex.core.aprilfools.AprilFoolsManager; +import mineplex.core.blockrestore.BlockRestore; +import mineplex.core.boosters.BoosterManager; +import mineplex.core.chat.Chat; +import mineplex.core.command.CommandCenter; +import mineplex.core.common.events.ServerShutdownEvent; +import mineplex.core.creature.Creature; +import mineplex.core.customdata.CustomDataManager; +import mineplex.core.disguise.DisguiseManager; +import mineplex.core.donation.DonationManager; +import mineplex.core.elo.EloManager; +import mineplex.core.friend.FriendManager; +import mineplex.core.give.Give; +import mineplex.core.globalpacket.GlobalPacketManager; +import mineplex.core.hologram.HologramManager; +import mineplex.core.ignore.IgnoreManager; +import mineplex.core.incognito.IncognitoManager; +import mineplex.core.inventory.InventoryManager; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.memory.MemoryFix; +import mineplex.core.message.MessageManager; +import mineplex.core.monitor.LagMeter; +import mineplex.core.npc.NpcManager; +import mineplex.core.packethandler.PacketHandler; +import mineplex.core.party.PartyManager; +import mineplex.core.pet.PetManager; +import mineplex.core.poll.PollManager; +import mineplex.core.portal.Portal; +import mineplex.core.preferences.PreferencesManager; +import mineplex.core.profileCache.ProfileCacheManager; +import mineplex.core.projectile.ProjectileManager; +import mineplex.core.punish.Punish; +import mineplex.core.recharge.Recharge; +import mineplex.core.resourcepack.ResourcePackManager; +import mineplex.core.serverConfig.ServerConfiguration; +import mineplex.core.stats.StatsManager; +import mineplex.core.status.ServerStatusManager; +import mineplex.core.task.TaskManager; +import mineplex.core.teleport.Teleport; +import mineplex.core.titangiveaway.TitanGiveawayManager; +import mineplex.core.updater.FileUpdater; +import mineplex.core.updater.Updater; +import mineplex.core.velocity.VelocityFix; +import mineplex.core.visibility.VisibilityManager; +import mineplex.minecraft.game.core.combat.CombatManager; +import mineplex.minecraft.game.core.condition.ConditionManager; +import mineplex.minecraft.game.core.damage.DamageManager; + +import org.bukkit.Bukkit; +import org.bukkit.plugin.java.JavaPlugin; + +public class ClansHub extends JavaPlugin +{ + private String WEB_CONFIG = "webServer"; + + @Override + public void onEnable() + { + Bukkit.setSpawnRadius(0); + getConfig().addDefault(WEB_CONFIG, "http://accounts.mineplex.com/"); + getConfig().set(WEB_CONFIG, getConfig().getString(WEB_CONFIG)); + saveConfig(); + + String webServerAddress = getConfig().getString(WEB_CONFIG); + + //Logger.initialize(this); + + //Velocity Fix + new VelocityFix(this); + + //Static Modules + new ProfileCacheManager(this); + CommandCenter.Initialize(this); + CoreClientManager clientManager = new CoreClientManager(this, webServerAddress); + CommandCenter.Instance.setClientManager(clientManager); + +// new ProfileCacheManager(this); + ItemStackFactory.Initialize(this, false); + Recharge.Initialize(this); + VisibilityManager.Initialize(this); Give.Initialize(this); + Punish punish = new Punish(this, webServerAddress, clientManager); + BlockRestore blockRestore = new BlockRestore(this); + DonationManager donationManager = new DonationManager(this, clientManager, webServerAddress); + + ServerConfiguration serverConfiguration = new ServerConfiguration(this, clientManager); + + //Other Modules + PacketHandler packetHandler = new PacketHandler(this); + DisguiseManager disguiseManager = new DisguiseManager(this, packetHandler); + IncognitoManager incognito = new IncognitoManager(this, clientManager, packetHandler); + PreferencesManager preferenceManager = new PreferencesManager(this, incognito, clientManager, donationManager); + + incognito.setPreferencesManager(preferenceManager); + + preferenceManager.GiveItem = true; + Creature creature = new Creature(this); + NpcManager npcManager = new NpcManager(this, creature); + InventoryManager inventoryManager = new InventoryManager(this, clientManager); + PetManager petManager = new PetManager(this, clientManager, donationManager, inventoryManager, disguiseManager, creature, blockRestore, webServerAddress); + PollManager pollManager = new PollManager(this, clientManager, donationManager); + + //Main Modules + ServerStatusManager serverStatusManager = new ServerStatusManager(this, clientManager, new LagMeter(this, clientManager)); + new TitanGiveawayManager(this, clientManager, serverStatusManager); + + Portal portal = new Portal(this, clientManager, serverStatusManager.getCurrentServerName()); + + AntiHack.Initialize(this, punish, portal, preferenceManager, clientManager); + + IgnoreManager ignoreManager = new IgnoreManager(this, clientManager, preferenceManager, portal); + + FriendManager friendManager = new FriendManager(this, clientManager, preferenceManager, portal); + + StatsManager statsManager = new StatsManager(this, clientManager); + EloManager eloManager = new EloManager(this, clientManager); + AchievementManager achievementManager = new AchievementManager(statsManager, clientManager, donationManager, incognito, eloManager); + + PartyManager partyManager = new PartyManager(this, portal, clientManager, preferenceManager); + + CustomDataManager customDataManager = new CustomDataManager(this, clientManager); + + ConditionManager condition = new ConditionManager(this); + BoosterManager boosterManager = new BoosterManager(this, "", clientManager, donationManager, inventoryManager); + HubManager hubManager = new HubManager(this, blockRestore, clientManager, incognito, donationManager, inventoryManager, condition, disguiseManager, new TaskManager(this, clientManager, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this, packetHandler), npcManager, packetHandler, punish, serverStatusManager, customDataManager, boosterManager); + HologramManager hologramManager = new HologramManager(this, packetHandler); + + ClansTransferManager serverManager = new ClansTransferManager(this, clientManager, donationManager, partyManager, portal, hubManager); + + Chat chat = new Chat(this, incognito, clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName()); + new MessageManager(this, incognito, clientManager, preferenceManager, ignoreManager, punish, friendManager, chat); + new MemoryFix(this); + new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion()); + new CustomTagFix(this, packetHandler); + new PacketsInteractionFix(this, packetHandler); + new ResourcePackManager(this, portal); + new GlobalPacketManager(this, clientManager, serverStatusManager, inventoryManager, donationManager, petManager, statsManager, hubManager.getBonusManager().getRewardManager()); + + AprilFoolsManager.Initialize(this, clientManager, disguiseManager); + + CombatManager combatManager = new CombatManager(this); + + ProjectileManager throwManager = new ProjectileManager(this); + + DamageManager damage = new DamageManager(this, combatManager, npcManager, disguiseManager, condition); + + Teleport teleport = new Teleport(this, clientManager); + + //Updates + getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1); + } + + @Override + public void onDisable() + { + getServer().getPluginManager().callEvent(new ServerShutdownEvent(this)); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansServerPage.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansServerPage.java new file mode 100644 index 000000000..9d1f26115 --- /dev/null +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansServerPage.java @@ -0,0 +1,144 @@ +package mineplex.clanshub; + +import java.util.Collection; +import java.util.Comparator; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.donation.DonationManager; +import mineplex.core.shop.item.ShopItem; +import mineplex.core.shop.page.ShopPageBase; +import mineplex.game.clans.core.repository.tokens.SimpleClanToken; + +import org.bukkit.Material; +import org.bukkit.entity.Player; + +public class ClansServerPage extends ShopPageBase +{ + public ClansServerPage(ClansTransferManager plugin, ClansServerShop shop, CoreClientManager clientManager, + DonationManager donationManager, Player player) + { + super(plugin, shop, clientManager, donationManager, "Clans", player, 54); + + buildPage(); + } + + @Override + protected void buildPage() + { + if (!getPlugin().Get(_player).getClanName().isEmpty()) + { + buildClanPage(getPlugin().Get(_player)); + } + else + { + buildNoClanPage(); + } + } + + private void buildClanPage(SimpleClanToken clan) + { + if (getClientManager().hasRank(_player, Rank.HELPER)) + { + buildStaffJoinServers(clan); + } + else + { + buildJoinHomeServer(clan); + } + } + + private void buildNoClanPage() + { + Collection servers = UtilAlg.sortSet(getPlugin().getServers(), new Comparator() + { + @Override + public int compare(ServerInfo o1, ServerInfo o2) + { + return o1.Name.compareTo(o2.Name); + } + }); + + int currentSlot = 9; + for (ServerInfo server : servers) + { + buildJoinServer(currentSlot, server); + currentSlot++; + } + } + + private void buildJoinHomeServer(SimpleClanToken clan) + { + ServerInfo serverInfo = getServerInfo(clan.getHomeServer()); + boolean serverOnline = (serverInfo != null); + String serverStatus = serverOnline ? C.cGreen + "Online" : C.cRed + "Offline"; + + String title = (serverOnline ? C.cGreen : C.cRed) + C.Bold + "Join Home Server!"; + String serverName = C.cYellow + "Server Name: " + C.cWhite + clan.getHomeServer(); + String serverDesc = C.cYellow + "Server Status: " + C.cWhite + serverStatus; + String players = (serverOnline ? C.cYellow + "Players: " + C.cWhite + serverInfo.CurrentPlayers + "/" + serverInfo.MaxPlayers : "" ); + String change = C.cRed + "Note: " + C.cWhite + "You must leave your Clan to "; + String change2 = C.cWhite + "play on a different Clans Server!"; + ShopItem shopItem = new ShopItem(Material.EMERALD_BLOCK, title, new String[] {" ", serverName, serverDesc, players, " ", change, change2, " "}, 0, true, true); + addButton(13, shopItem, new JoinServerButton(this, getPlugin(), getServerInfo(clan.getHomeServer()))); + } + + private void buildJoinServer(int slot, ServerInfo server) + { + String title = C.cGreen + C.Bold + "Join Clans Server!"; + String desc1 = C.cYellow + "Server Name " + C.cWhite + server.Name; + String desc2 = C.cYellow + "Players " + C.cWhite + server.CurrentPlayers + "/" + server.MaxPlayers; + String desc3 = C.cRed + "Note: " + C.cWhite + "Creating or Joining a clan on this"; + String desc4 = C.cWhite + "server will set your Home Server!"; + + ShopItem shopItem = new ShopItem(Material.GOLD_BLOCK, title, new String[] {" ", desc1, desc2, " ", desc3, desc4}, 0, true, true); + addButton(slot, shopItem, new JoinServerButton(this, getPlugin(), server)); + } + + private void buildStaffJoinServers(SimpleClanToken clan) + { + ServerInfo serverInfo = getServerInfo(clan.getHomeServer()); + boolean serverOnline = (serverInfo != null); + String serverStatus = serverOnline ? C.cGreen + "Online" : C.cRed + "Offline"; + + String title = (serverOnline ? C.cGreen : C.cRed) + C.Bold + "Join Home Server!"; + String serverName = C.cYellow + "Server Name: " + C.cWhite + clan.getHomeServer(); + String serverDesc = C.cYellow + "Server Status: " + C.cWhite + serverStatus; + String players = (serverOnline ? C.cYellow + "Players: " + C.cWhite + serverInfo.CurrentPlayers + "/" + serverInfo.MaxPlayers : "" ); + ShopItem shopItem = new ShopItem(Material.EMERALD_BLOCK, title, new String[] {" ", serverName, serverDesc, players, " "}, 0, true, true); + addButton(13, shopItem, new JoinServerButton(this, getPlugin(), getServerInfo(clan.getHomeServer()))); + + Collection servers = UtilAlg.sortSet(getPlugin().getServers(), new Comparator() + { + @Override + public int compare(ServerInfo o1, ServerInfo o2) + { + return o1.Name.compareTo(o2.Name); + } + }); + + int currentSlot = 27; + for (ServerInfo server : servers) + { + if (server.Name.equalsIgnoreCase(clan.getHomeServer())) + { + continue; + } + buildJoinServer(currentSlot, server); + currentSlot++; + } + } + + private ServerInfo getServerInfo(String serverName) + { + return getPlugin().getServer(serverName); + } + + public void update() + { + getButtonMap().clear(); + buildPage(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansServerShop.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansServerShop.java new file mode 100644 index 000000000..00502e5ef --- /dev/null +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansServerShop.java @@ -0,0 +1,40 @@ +package mineplex.clanshub; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.F; +import mineplex.core.donation.DonationManager; +import mineplex.core.party.Party; +import mineplex.core.shop.ShopBase; +import mineplex.core.shop.page.ShopPageBase; + +import org.bukkit.Sound; +import org.bukkit.entity.Player; + +public class ClansServerShop extends ShopBase +{ + public ClansServerShop(ClansTransferManager plugin, CoreClientManager clientManager, DonationManager donationManager) + { + super(plugin, clientManager, donationManager, "Clans"); + } + + @Override + protected ShopPageBase> buildPagesFor(Player player) + { + return new ClansServerPage(getPlugin(), this, getClientManager(), getDonationManager(), player); + } + + @Override + protected boolean canOpenShop(Player player) + { + Party party = getPlugin().getPartyManager().getParty(player); + + if (party != null) + { + player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1, .6f); + player.sendMessage(F.main("Party", "You cannot join Clans while in a party.")); + return false; + } + + return true; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansTransferManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansTransferManager.java new file mode 100644 index 000000000..fb16e0e0b --- /dev/null +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansTransferManager.java @@ -0,0 +1,259 @@ +package mineplex.clanshub; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.HashMap; +import java.util.List; + +import mineplex.core.MiniDbClientPlugin; +import mineplex.core.account.CoreClientManager; +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.UtilTime; +import mineplex.core.donation.DonationManager; +import mineplex.core.npc.event.NpcDamageByEntityEvent; +import mineplex.core.npc.event.NpcInteractEntityEvent; +import mineplex.core.party.Lang; +import mineplex.core.party.Party; +import mineplex.core.party.PartyManager; +import mineplex.core.portal.Portal; +import mineplex.core.recharge.Recharge; +import mineplex.core.shop.page.ShopPageBase; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.core.repository.tokens.SimpleClanToken; +import mineplex.serverdata.Region; +import mineplex.serverdata.data.MinecraftServer; +import mineplex.serverdata.servers.ServerManager; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityPortalEnterEvent; +import org.bukkit.plugin.java.JavaPlugin; + +import com.google.common.collect.Lists; + +public class ClansTransferManager extends MiniDbClientPlugin +{ + private static final long SERVER_RELOAD_INTERVAL = 5000; + private PartyManager _party; + private Portal _portal; + private HubManager _hub; + private Region _region; + private final HashMap _servers = new HashMap(); + private boolean _loading = false; + private long _lastLoaded; + private ClansServerShop _serverShop; + + public ClansTransferManager(JavaPlugin plugin, CoreClientManager client, DonationManager donation, PartyManager party, Portal portal, HubManager hub) + { + super("Server Transfer", plugin, client); + + _party = party; + _portal = portal; + _hub = hub; + _region = plugin.getConfig().getBoolean("serverstatus.us") ? Region.US : Region.EU; + _serverShop = new ClansServerShop(this, client, donation); + } + + public PartyManager getPartyManager() + { + return _party; + } + + public List getServers() + { + List servers = Lists.newArrayList(); + servers.addAll(_servers.values()); + return servers; + } + + public ServerInfo getServer(String name) + { + for (ServerInfo server : _servers.values()) + { + if (server.Name.equalsIgnoreCase(name)) + { + return server; + } + } + + return null; + } + + public void reload() + { + _servers.clear(); + for (MinecraftServer server : ServerManager.getServerRepository(_region).getServerStatusesByPrefix("Clans-")) + { + ServerInfo info = new ServerInfo(); + info.Name = server.getName(); + info.CurrentPlayers = server.getPlayerCount(); + info.MaxPlayers = server.getMaxPlayerCount(); + _servers.put(server, info); + } + } + + public void selectServer(Player player, ServerInfo serverInfo) + { + Party party = _party.getParty(player); + if (party != null) + { + if(!party.getOwner().equalsIgnoreCase(player.getName())) + { + Lang.NOT_OWNER_SERVER.send(player); + return; + } + _party.getJoinManager().requestServerJoin(serverInfo.Name, party); + return; + } + player.leaveVehicle(); + player.eject(); + + _portal.sendPlayerToServer(player, serverInfo.Name); + } + + @EventHandler + public void reloadServers(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC || _loading || !UtilTime.elapsed(_lastLoaded, SERVER_RELOAD_INTERVAL)) + { + return; + } + _loading = true; + final Runnable after = new Runnable() + { + public void run() + { + _lastLoaded = System.currentTimeMillis(); + _loading = false; + } + }; + runAsync(() -> + { + reload(); + runSync(after); + }); + } + + @SuppressWarnings("rawtypes") + @EventHandler + public void refreshPages(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + return; + + for (ShopPageBase page : _serverShop.getPageMap().values()) + { + if (page instanceof ClansServerPage) + { + ((ClansServerPage)page).update(); + } + } + } + + @EventHandler + public void onEnterPortal(EntityPortalEnterEvent event) + { + if (!(event.getEntity() instanceof Player)) + { + UtilAction.velocity(event.getEntity(), UtilAlg.getTrajectory(event.getEntity().getLocation(), _hub.GetSpawn()), 1, true, 0.5, 0, 1.0, true); + return; + } + + Player player = (Player) event.getEntity(); + if (!_hub.CanPortal(player)) + { + UtilAction.velocity(player, UtilAlg.getTrajectory(player.getLocation(), _hub.GetSpawn()), 1, true, 0.5, 0, 1.0, true); + return; + } + + if (!Recharge.Instance.use(player, "Transfer Portal", 5000, false, false)) + { + return; + } + + if (Get(player) == null || Get(player).getHomeServer() == null || Get(player).getHomeServer().isEmpty()) + { + player.teleport(_hub.GetSpawn()); + runSyncLater(() -> + { + _serverShop.attemptShopOpen(player); + }, 20L); + return; + } + + if (getServer(Get(player).getHomeServer()) != null) + { + UtilPlayer.message(player, F.main(getName(), "You are being transferred to your Clan's home server!")); + selectServer(player, getServer(Get(player).getHomeServer())); + } + else + { + UtilPlayer.message(player, F.main(getName(), "Your Clan's home server is not online!")); + } + } + + @EventHandler + public void onUseNPC(NpcInteractEntityEvent event) + { + if (event.getNpc().getName().contains("Clans")) + { + _serverShop.attemptShopOpen(event.getPlayer()); + } + if (event.getNpc().getName().contains("Return")) + { + _portal.sendToHub(event.getPlayer(), "Returning to Mineplex!"); + } + } + + @EventHandler + public void onUseNPC(NpcDamageByEntityEvent event) + { + if (!(event.getDamager() instanceof Player)) + { + return; + } + Player player = (Player) event.getDamager(); + + if (event.getNpc().getName().contains("Clans") && Recharge.Instance.use(player, "Go to Clans", 1000, false, false)) + { + _serverShop.attemptShopOpen(player); + } + if (event.getNpc().getName().contains("Return") && Recharge.Instance.use(player, "Return to Mineplex", 1000, false, false)) + { + _portal.sendToHub(player, "Returning to Mineplex!"); + } + } + + @Override + public String getQuery(int accountId, String uuid, String name) + { + return "SELECT clans.name, accountClan.clanRole, clanServer.serverName, clans.id FROM accountClan INNER JOIN clans ON clans.id = accountClan.clanId INNER JOIN clanServer ON clans.serverId = clanServer.id WHERE accountClan.accountId = " + accountId + ";"; + } + + @Override + public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException + { + SimpleClanToken clanToken = new SimpleClanToken(); + + while (resultSet.next()) + { + String clanName = resultSet.getString(1); + String clanRole = resultSet.getString(2); + String homeServer = resultSet.getString(3); + int clanId = resultSet.getInt(4); + clanToken = new SimpleClanToken(clanName, clanRole, homeServer, clanId); + } + + Set(playerName, clanToken); + } + + @Override + protected SimpleClanToken addPlayer(String player) + { + return new SimpleClanToken(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ForcefieldManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ForcefieldManager.java new file mode 100644 index 000000000..20f1752d3 --- /dev/null +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ForcefieldManager.java @@ -0,0 +1,96 @@ +package mineplex.clanshub; + +import java.util.HashMap; + +import mineplex.core.MiniPlugin; +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilMath; +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 org.bukkit.Sound; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerQuitEvent; + +public class ForcefieldManager extends MiniPlugin +{ + public HubManager Manager; + + private HashMap _radius = new HashMap(); + + public ForcefieldManager(HubManager manager) + { + super("Forcefield", manager.getPlugin()); + + Manager = manager; + } + + @EventHandler + public void ForcefieldUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTER) + return; + + for (Player player : UtilServer.getPlayers()) + { + if (Manager.getPreferences().Get(player).HubForcefield && (Manager.GetClients().Get(player).GetRank().has(Rank.ADMIN) || Manager.GetClients().Get(player).GetRank() == Rank.JNR_DEV || Manager.GetClients().Get(player).GetRank() == Rank.YOUTUBE || Manager.GetClients().Get(player).GetRank() == Rank.TWITCH || Manager.GetClients().Get(player).GetRank() == Rank.YOUTUBE_SMALL)) + { + for (Player other : UtilServer.getPlayers()) + { + if (player.equals(other)) + continue; + + int range = 5; + if (_radius.containsKey(player)) + range = _radius.get(player); + + if (UtilMath.offset(other, player) > range) + continue; + + if (Manager.GetClients().Get(other).GetRank().has(Rank.JNR_DEV)) + continue; + + if (Recharge.Instance.use(other, "Forcefield Bump", 500, false, false)) + { + Entity bottom = other; + while (bottom.getVehicle() != null) + bottom = bottom.getVehicle(); + + UtilAction.velocity(bottom, UtilAlg.getTrajectory2d(player, bottom), 1.6, true, 0.8, 0, 10, true); + other.getWorld().playSound(other.getLocation(), Sound.CHICKEN_EGG_POP, 2f, 0.5f); + } + } + } + } + } + + public void ForcefieldRadius(Player caller, String[] args) + { + try + { + int range = Integer.parseInt(args[0]); + + _radius.put(caller, range); + + UtilPlayer.message(caller, F.main(getName(), "Radius set to " + F.elem(range + "") + ".")); + } + catch (Exception e) + { + UtilPlayer.message(caller, F.main(getName(), "Invalid Input. Correct input is " + F.elem("/radius #") + ".")); + } + } + + @EventHandler + public void ForcefieldReset(PlayerQuitEvent event) + { + _radius.remove(event.getPlayer()); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java new file mode 100644 index 000000000..df2addd07 --- /dev/null +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java @@ -0,0 +1,912 @@ +package mineplex.clanshub; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; + +import mineplex.clanshub.commands.ForcefieldRadius; +import mineplex.clanshub.commands.GadgetToggle; +import mineplex.clanshub.commands.GameModeCommand; +import mineplex.clanshub.profile.gui.GUIProfile; +import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClient; +import mineplex.core.account.CoreClientManager; +import mineplex.core.achievement.AchievementManager; +import mineplex.core.benefit.BenefitManager; +import mineplex.core.blockrestore.BlockRestore; +import mineplex.core.bonuses.BonusManager; +import mineplex.core.boosters.BoosterManager; +import mineplex.core.botspam.BotSpamManager; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +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.UtilTextBottom; +import mineplex.core.common.util.UtilTextTop; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilWorld; +import mineplex.core.cosmetic.CosmeticManager; +import mineplex.core.customdata.CustomDataManager; +import mineplex.core.disguise.DisguiseManager; +import mineplex.core.disguise.PlayerDisguiseManager; +import mineplex.core.disguise.disguises.DisguiseBase; +import mineplex.core.disguise.disguises.DisguiseWither; +import mineplex.core.donation.DonationManager; +import mineplex.core.facebook.FacebookManager; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.event.GadgetCollideEntityEvent; +import mineplex.core.gadget.gadgets.morph.MorphWither; +import mineplex.core.gadget.types.Gadget; +import mineplex.core.gadget.types.GadgetType; +import mineplex.core.hologram.HologramManager; +import mineplex.core.incognito.IncognitoManager; +import mineplex.core.incognito.events.IncognitoHidePlayerEvent; +import mineplex.core.inventory.InventoryManager; +import mineplex.core.message.PrivateMessageEvent; +import mineplex.core.mount.Mount; +import mineplex.core.mount.MountManager; +import mineplex.core.mount.types.MountDragon; +import mineplex.core.notifier.NotificationManager; +import mineplex.core.npc.NpcManager; +import mineplex.core.packethandler.PacketHandler; +import mineplex.core.party.Party; +import mineplex.core.party.PartyManager; +import mineplex.core.pet.PetManager; +import mineplex.core.playerCount.PlayerCountManager; +import mineplex.core.poll.PollManager; +import mineplex.core.portal.Portal; +import mineplex.core.preferences.PreferencesManager; +import mineplex.core.projectile.ProjectileManager; +import mineplex.core.punish.Punish; +import mineplex.core.stats.StatsManager; +import mineplex.core.status.ServerStatusManager; +import mineplex.core.task.TaskManager; +import mineplex.core.treasure.TreasureLocation; +import mineplex.core.treasure.TreasureManager; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.valentines.ValentinesGiftManager; +import mineplex.core.youtube.YoutubeManager; +import mineplex.minecraft.game.core.combat.DeathMessageType; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import mineplex.minecraft.game.core.condition.ConditionManager; +import net.md_5.bungee.api.chat.ComponentBuilder; +import net.md_5.bungee.api.chat.HoverEvent; +import net.md_5.bungee.api.chat.HoverEvent.Action; +import net.md_5.bungee.api.chat.TextComponent; +import net.minecraft.server.v1_8_R3.EntityInsentient; +import net.minecraft.server.v1_8_R3.EntityPlayer; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.entity.Creature; +import org.bukkit.entity.Egg; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityTargetEvent.TargetReason; +import org.bukkit.event.entity.ItemSpawnEvent; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerLoginEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerRespawnEvent; +import org.bukkit.event.player.PlayerVelocityEvent; +import org.bukkit.event.server.ServerListPingEvent; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.scoreboard.DisplaySlot; +import org.bukkit.scoreboard.Objective; +import org.bukkit.scoreboard.Scoreboard; + +public class HubManager extends MiniPlugin +{ + private BlockRestore _blockRestore; + private CoreClientManager _clientManager; + private ConditionManager _conditionManager; + private DonationManager _donationManager; + private DisguiseManager _disguiseManager; + private PartyManager _partyManager; + private ForcefieldManager _forcefieldManager; + private PollManager _pollManager; + private Portal _portal; + private StatsManager _statsManager; + private GadgetManager _gadgetManager; + private MountManager _mountManager; + private HubVisibilityManager _visibilityManager; + private PreferencesManager _preferences; + private InventoryManager _inventoryManager; + private AchievementManager _achievementManager; + private TreasureManager _treasureManager; + private PetManager _petManager; + private PacketHandler _packetHandler; + private PlayerCountManager _playerCountManager; + private CustomDataManager _customDataManager; + private Punish _punishManager; + private IncognitoManager _incognito; + private BonusManager _bonusManager; + + private Location _spawn; + private int _scoreboardTick = 0; + + private HashMap _scoreboards = new HashMap(); + + private String _serverName = ""; + private int _lastPlayerCount = 0; + private boolean _shuttingDown; + + private HashMap _portalTime = new HashMap(); + + private HashMap> _creativeAdmin = new HashMap>(); + + public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, IncognitoManager incognito, DonationManager donationManager, InventoryManager inventoryManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager, NpcManager npcManager, PacketHandler packetHandler, Punish punish, ServerStatusManager serverStatusManager, CustomDataManager customDataManager, BoosterManager boosterManager) + { + super("Hub Manager", plugin); + + _incognito = incognito; + + _blockRestore = blockRestore; + _clientManager = clientManager; + _conditionManager = conditionManager; + _donationManager = donationManager; + _disguiseManager = disguiseManager; + _pollManager = pollManager; + + _portal = portal; + + _spawn = new Location(UtilWorld.getWorld("world"), 0.5, 179, 0.5); + ((CraftWorld) _spawn.getWorld()).getHandle().spigotConfig.itemMerge = 0; + + new WorldManager(this); + _mountManager = new MountManager(_plugin, clientManager, donationManager, blockRestore, _disguiseManager); + _inventoryManager = inventoryManager; + new BenefitManager(plugin, clientManager, _inventoryManager); + _gadgetManager = new GadgetManager(_plugin, clientManager, donationManager, _inventoryManager, _mountManager, petManager, preferences, disguiseManager, blockRestore, new ProjectileManager(plugin), achievementManager, packetHandler, hologramManager); + + FacebookManager facebookManager = new FacebookManager(plugin, clientManager, donationManager, inventoryManager); + YoutubeManager youtubeManager = new YoutubeManager(plugin, clientManager, donationManager); + _bonusManager = new BonusManager(plugin, clientManager, serverStatusManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, facebookManager, youtubeManager, _gadgetManager, boosterManager); + + World world = _spawn.getWorld(); + _treasureManager = new TreasureManager(_plugin, clientManager, serverStatusManager, donationManager, _inventoryManager, petManager, _gadgetManager, _blockRestore, hologramManager, statsManager, _bonusManager.getRewardManager()); + _treasureManager.disable(); + { + Block chestBlock = world.getBlockAt(-1, 178, -9); + Block chestLoc1 = world.getBlockAt(-4, 178, -8); + Block chestLoc2 = world.getBlockAt(-4, 178, -10); + Block chestLoc3 = world.getBlockAt(-2, 178, -12); + Block chestLoc4 = world.getBlockAt(0, 178, -12); + Block chestLoc5 = world.getBlockAt(2, 178, -10); + Block chestLoc6 = world.getBlockAt(2, 178, -8); + Block chestLoc7 = world.getBlockAt(0, 178, -6); + Block chestLoc8 = world.getBlockAt(-2, 178, -6); + TreasureLocation loc = new TreasureLocation(_treasureManager, _inventoryManager, clientManager, donationManager, chestBlock, new Block[]{chestLoc1, chestLoc2, chestLoc3, chestLoc4, chestLoc5, chestLoc6, chestLoc7, chestLoc8}, _spawn, hologramManager, _gadgetManager, serverStatusManager); + _treasureManager.addTreasureLocation(loc); + } + { + Block chestBlock = world.getBlockAt(-1, 178, 9); + Block chestLoc1 = world.getBlockAt(-4, 178, 10); + Block chestLoc2 = world.getBlockAt(-4, 178, 8); + Block chestLoc3 = world.getBlockAt(-2, 178, 6); + Block chestLoc4 = world.getBlockAt(0, 178, 6); + Block chestLoc5 = world.getBlockAt(2, 178, 8); + Block chestLoc6 = world.getBlockAt(2, 178, 10); + Block chestLoc7 = world.getBlockAt(0, 178, 12); + Block chestLoc8 = world.getBlockAt(-2, 178, 12); + TreasureLocation loc = new TreasureLocation(_treasureManager, _inventoryManager, clientManager, donationManager, chestBlock, new Block[]{chestLoc1, chestLoc2, chestLoc3, chestLoc4, chestLoc5, chestLoc6, chestLoc7, chestLoc8}, _spawn, hologramManager, _gadgetManager, serverStatusManager); + _treasureManager.addTreasureLocation(loc); + } + + new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, _treasureManager, boosterManager); + + _petManager = petManager; + _partyManager = partyManager; + _preferences = preferences; + _visibilityManager = new HubVisibilityManager(this); + + _forcefieldManager = new ForcefieldManager(this); + addCommand(new ForcefieldRadius(_forcefieldManager)); + + _statsManager = statsManager; + _achievementManager = achievementManager; + _achievementManager.setGiveInterfaceItem(true); + _packetHandler = packetHandler; + + new NotificationManager(getPlugin(), clientManager, _preferences); + new BotSpamManager(plugin, clientManager, punish); + + ((CraftWorld)Bukkit.getWorlds().get(0)).getHandle().pvpMode = true; + + new PlayerDisguiseManager(plugin, _clientManager); + new ValentinesGiftManager(plugin, clientManager, _bonusManager.getRewardManager(), inventoryManager, _gadgetManager, statsManager); + + _playerCountManager = new PlayerCountManager(plugin); + + _customDataManager = new CustomDataManager(plugin, clientManager); + + _punishManager = punish; + + _serverName = getPlugin().getConfig().getString("serverstatus.name"); + _serverName = _serverName.substring(0, Math.min(16, _serverName.length())); + } + + @Override + public void addCommands() + { + addCommand(new GadgetToggle(this)); + addCommand(new GameModeCommand(this)); + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void reflectMotd(ServerListPingEvent event) + { + if (_shuttingDown) + { + event.setMotd("Restarting soon"); + } + } + + public boolean BumpDisabled(Entity ent) + { + if (ent == null) + return false; + + if (ent instanceof Player) + { + return !_preferences.Get((Player)ent).HubGames; + } + + return true; + } + + @EventHandler + public void redirectStopCommand(PlayerCommandPreprocessEvent event) + { + if (event.getPlayer().isOp() && event.getMessage().equalsIgnoreCase("/stop")) + { + _shuttingDown = true; + + Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(_plugin, new Runnable() + { + public void run() + { + _portal.sendAllPlayers("Lobby"); + + Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(_plugin, new Runnable() + { + public void run() + { + Bukkit.shutdown(); + } + }, 40L); + } + }, 60L); + + event.setCancelled(true); + } + } + + @EventHandler + public void preventEggSpawn(ItemSpawnEvent event) + { + if (event.getEntity() instanceof Egg) + { + event.setCancelled(true); + } + } + + @EventHandler(priority = EventPriority.LOW) + public void login(final PlayerLoginEvent event) + { + CoreClient client = _clientManager.Get(event.getPlayer().getName()); + + // Reserved Slot Check + if (Bukkit.getOnlinePlayers().size() - Bukkit.getServer().getMaxPlayers() >= 20) + { + if (!client.GetRank().has(Rank.ULTRA)) + { + Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() + { + public void run() + { + _portal.sendPlayerToServer(event.getPlayer(), "Lobby"); + } + }); + + event.allow(); + } + } + else + event.allow(); + } + + @EventHandler(priority = EventPriority.LOW) + public void handleOP(PlayerJoinEvent event) + { + if (_clientManager.Get(event.getPlayer()).GetRank().has(Rank.ADMIN)) + event.getPlayer().setOp(true); + else + event.getPlayer().setOp(false); + } + + @EventHandler + public void PlayerRespawn(PlayerRespawnEvent event) + { + event.setRespawnLocation(GetSpawn()); + } + + @EventHandler(priority = EventPriority.LOW) + public void PlayerJoin(PlayerJoinEvent event) + { + Player player = event.getPlayer(); + + //Public Message + event.setJoinMessage(null); + + //Teleport + player.teleport(GetSpawn()); + + //Survival + player.setGameMode(GameMode.SURVIVAL); + + //Clear Inv + UtilInv.Clear(player); + + //Health + player.setHealth(20); + + //Scoreboard + Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard(); + player.setScoreboard(board); + _scoreboards.put(player, board); + + //Objective + Objective obj = board.registerNewObjective(C.Bold + "Player Data", "dummy"); + obj.setDisplaySlot(DisplaySlot.SIDEBAR); + + for (Rank rank : Rank.values()) + { + if (rank != Rank.ALL) + board.registerNewTeam(rank.Name).setPrefix(rank.getTag(true, true) + ChatColor.RESET + " "); + else + board.registerNewTeam(rank.Name).setPrefix(""); + } + + for (Player otherPlayer : Bukkit.getOnlinePlayers()) + { + if (_clientManager.Get(otherPlayer) == null) + continue; + + String rankName = _clientManager.Get(player).GetRank().Name; + String otherRankName = _clientManager.Get(otherPlayer).GetRank().Name; + + //Add Other to Self + board.getTeam(otherRankName).addPlayer(otherPlayer); + + //Add Self to Other + otherPlayer.getScoreboard().getTeam(rankName).addPlayer(player); + } + } + + @EventHandler + public void PlayerQuit(PlayerQuitEvent event) + { + event.setQuitMessage(null); + + event.getPlayer().leaveVehicle(); + event.getPlayer().eject(); + event.getPlayer().setOp(false); + + for (Player player : UtilServer.getPlayers()) + player.getScoreboard().resetScores(event.getPlayer().getName()); + + _scoreboards.remove(event.getPlayer()); + + _portalTime.remove(event.getPlayer().getName()); + } + + @EventHandler + public void playerPrivateMessage(PrivateMessageEvent event) + { + //Dont Let PM Near Spawn! + if (UtilMath.offset2d(GetSpawn(), event.getSender().getLocation()) == 0 && !_clientManager.Get(event.getSender()).GetRank().has(Rank.HELPER)) + { + UtilPlayer.message(event.getSender(), F.main("Chat", "You must leave spawn before you can Private Message!")); + event.setCancelled(true); + } + } + + @EventHandler + public void Incog(IncognitoHidePlayerEvent event) + { + if (!_clientManager.hasRank(event.getPlayer(), Rank.CMOD)) + { + event.setCancelled(true); + } + } + + @EventHandler + public void PlayerChat(AsyncPlayerChatEvent event) + { + if (event.isCancelled()) + return; + + //Dont Let Chat Near Spawn! + if (UtilMath.offset2d(GetSpawn(), event.getPlayer().getLocation()) == 0 && !_clientManager.Get(event.getPlayer()).GetRank().has(Rank.HELPER)) + { + UtilPlayer.message(event.getPlayer(), F.main("Chat", "You must leave spawn before you can chat!")); + event.setCancelled(true); + return; + } + + Player player = event.getPlayer(); + String playerName = player.getName(); + + Rank rank = GetClients().Get(player).GetRank(); + + if (GetClients().Get(player).isDisguised()) + rank = GetClients().Get(player).getDisguisedRank(); + + //Level Prefix + String levelStr = _achievementManager.getMineplexLevel(player, rank); + + //Rank Prefix + String rankStr = ""; + if (rank != Rank.ALL) + rankStr = rank.getTag(true, true) + " "; + //Party Chat + if (event.getMessage().charAt(0) == '#') + { + Party party = _partyManager.getParty(player); + if (party != null) + { + event.getRecipients().clear(); + + event.setMessage(event.getMessage().substring(1, event.getMessage().length())); + event.setFormat(levelStr + C.cDPurple + C.Bold + "Party " + C.cWhite + C.Bold + playerName + " " + C.cPurple + "%2$s"); + + for (String name : party.getMembers()) + { + Player other = UtilPlayer.searchExact(name); + + if (other != null) + event.getRecipients().add(other); + } + } + else + { + UtilPlayer.message(player, F.main("Party", "You are not in a Party.")); + event.setCancelled(true); + } + + return; + } + else + { + TextComponent rankComponent = new TextComponent(rankStr); + TextComponent playerNameText = new TextComponent(ChatColor.YELLOW + playerName); + TextComponent component = new TextComponent(); + + rankComponent.setHoverEvent(new HoverEvent(Action.SHOW_TEXT, new ComponentBuilder(rank.getColor() + rank.getTag(true, true) + ChatColor.WHITE + "\n" + rank.getDescription()).create())); + + component.setText(levelStr); + component.addExtra(rankComponent); + component.addExtra(playerNameText); + component.addExtra(" " + ChatColor.WHITE + event.getMessage()); + + for (Player other : UtilServer.getPlayers()) + { + if (!event.isCancelled()) + other.spigot().sendMessage(component); + } + event.setCancelled(true); + } + } + + @EventHandler + public void Damage(EntityDamageEvent event) + { + if (event.getCause() == DamageCause.VOID) + { + if (event.getEntity() instanceof Player) + { + event.getEntity().eject(); + event.getEntity().leaveVehicle(); + event.getEntity().teleport(GetSpawn()); + } + else + { + event.getEntity().remove(); + } + } + + event.setCancelled(true); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void handleDeath(PlayerDeathEvent event) + { + event.setKeepInventory(true); + event.getDrops().clear(); + event.getEntity().setHealth(20); + event.getEntity().teleport(GetSpawn()); + } + + @EventHandler + public void combatDeath(CombatDeathEvent event) + { + event.SetBroadcastType(DeathMessageType.None); + } + + @EventHandler + public void FoodHealthUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + return; + + for (Player player : UtilServer.getPlayers()) + { + player.setFoodLevel(20); + player.setExhaustion(0f); + player.setSaturation(3f); + } + } + + @EventHandler + public void InventoryCancel(InventoryClickEvent event) + { + if (event.getWhoClicked() instanceof Player && ((Player)event.getWhoClicked()).getGameMode() != GameMode.CREATIVE) + event.setCancelled(true); + } + + @EventHandler + public void UpdateScoreboard(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + _scoreboardTick = (_scoreboardTick + 1)%3; + + if (_scoreboardTick != 0) + return; + + int playerCount = _playerCountManager.getPlayerCount(); + + for (Player player : UtilServer.getPlayers()) + { + //Return to Main Scoreboard + if (!player.getScoreboard().equals(_scoreboards.get(player))) + player.setScoreboard(_scoreboards.get(player)); + + //Objective + Objective obj = player.getScoreboard().getObjective(DisplaySlot.SIDEBAR); + + //Title + obj.setDisplayName(C.cRed + C.Bold + C.Line + "Mineplex Clans"); + + int line = 15; + + //Space + obj.getScore(" ").setScore(line--); + + //Server + obj.getScore(C.cAqua + C.Bold + "Server").setScore(line--); + obj.getScore(_serverName).setScore(line--); + + //Space + obj.getScore(" ").setScore(line--); + + //Players + obj.getScore(C.cYellow + C.Bold + "Players").setScore(line--); + player.getScoreboard().resetScores(_lastPlayerCount + ""); + obj.getScore(playerCount + "").setScore(line--); + + //Space + obj.getScore(" ").setScore(line--); + + //Display Rank + obj.getScore(C.cGold + C.Bold + "Rank").setScore(line--); + //Remove Old + player.getScoreboard().resetScores(_clientManager.Get(player).GetLastRank(false).Name); + player.getScoreboard().resetScores(_clientManager.Get(player).GetLastRank(true).Name); + player.getScoreboard().resetScores("No Rank"); + //Add New + if (GetClients().Get(player).GetRank() != Rank.ALL) + obj.getScore(GetClients().Get(player).GetRank().Name).setScore(line--); + else + obj.getScore("No Rank").setScore(line--); + + //Space + obj.getScore(" ").setScore(line--); + + //Website + obj.getScore(C.cRed + C.Bold + "Website").setScore(line--); + obj.getScore("www.mineplex.com").setScore(line--); + } + + _lastPlayerCount = playerCount; + Bukkit.getOnlinePlayers().stream().filter(player -> _clientManager.Get(player).GetRank() == Rank.ALL).forEach(player -> + { + UtilTextBottom.display(C.cGray + "Visit " + F.elem("http://www.mineplex.com/shop") + " for exclusive perks!", player); + }); + } + + public BlockRestore GetBlockRestore() + { + return _blockRestore; + } + + public CoreClientManager GetClients() + { + return _clientManager; + } + + public ConditionManager GetCondition() + { + return _conditionManager; + } + + public DonationManager GetDonation() + { + return _donationManager; + } + + public DisguiseManager GetDisguise() + { + return _disguiseManager; + } + + public GadgetManager GetGadget() + { + return _gadgetManager; + } + + public TreasureManager GetTreasure() + { + return _treasureManager; + } + + public MountManager GetMount() + { + return _mountManager; + } + + public PreferencesManager getPreferences() + { + return _preferences; + } + + public Location GetSpawn() + { + return _spawn.clone(); + } + + public PetManager getPetManager() + { + return _petManager; + } + + public BonusManager getBonusManager() + { + return _bonusManager; + } + + public StatsManager GetStats() + { + return _statsManager; + } + + public HubVisibilityManager GetVisibility() + { + return _visibilityManager; + } + + public CustomDataManager getCustomDataManager() + { + return _customDataManager; + } + + public Punish getPunishments() + { + return _punishManager; + } + + public IncognitoManager getIncognitoManager() + { + return _incognito; + } + + @EventHandler(priority = EventPriority.MONITOR) + public void gadgetCollide(GadgetCollideEntityEvent event) + { + if (!event.isCancelled()) + { + SetPortalDelay(event.getOther()); + } + } + + public void SetPortalDelay(Entity ent) + { + if (ent instanceof Player) + { + _portalTime.put(((Player)ent).getName(), System.currentTimeMillis()); + } + } + + public boolean CanPortal(Player player) + { + //Riding + if (player.getVehicle() != null || player.getPassenger() != null) + return false; + + //Portal Delay + if (!_portalTime.containsKey(player.getName())) + return true; + + return UtilTime.elapsed(_portalTime.get(player.getName()), 5000); + } + + @EventHandler + public void ignoreVelocity(PlayerVelocityEvent event) + { + if (_clientManager.Get(event.getPlayer()).GetRank().has(Rank.TWITCH) && _preferences.Get(event.getPlayer()).IgnoreVelocity) + { + event.setCancelled(true); + } + } + + public void ToggleGadget(Player caller) + { + toggleGadget(); + } + + public void toggleGadget() + { + GetGadget().toggleGadgetEnabled(); + + for (Player player : UtilServer.getPlayers()) + player.sendMessage(C.cWhite + C.Bold + "Gadgets/Mounts are now " + F.elem(GetGadget().isGadgetEnabled() ? C.cGreen + C.Bold + "Enabled" : C.cRed + C.Bold + "Disabled")); + } + + public void addGameMode(Player caller, Player target) + { + if (!_creativeAdmin.containsKey(caller.getName())) + _creativeAdmin.put(caller.getName(), new ArrayList()); + + if (target.getGameMode() == GameMode.CREATIVE) + { + _creativeAdmin.get(caller.getName()).add(target.getName()); + } + else + { + _creativeAdmin.get(caller.getName()).remove(target.getName()); + } + } + + @EventHandler + public void clearEntityTargets(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + return; + + for (Entity entity : Bukkit.getWorlds().get(0).getEntities()) + { + if (entity instanceof EntityInsentient) + { + EntityInsentient entityMonster = (EntityInsentient)entity; + + if (entityMonster.getGoalTarget() != null && entityMonster.getGoalTarget() instanceof EntityPlayer) + { + if (((EntityPlayer)entityMonster.getGoalTarget()).playerConnection.isDisconnected()) + entityMonster.setGoalTarget(null, TargetReason.FORGOT_TARGET, false); + } + } + } + } + + @EventHandler + public void clearGameMode(PlayerQuitEvent event) + { + ArrayList creative = _creativeAdmin.remove(event.getPlayer().getName()); + + if (creative == null) + return; + + for (String name : creative) + { + Player player = UtilPlayer.searchExact(name); + if (player == null) + continue; + + player.setGameMode(GameMode.SURVIVAL); + + UtilPlayer.message(player, F.main("Game Mode", event.getPlayer().getName() + " left the game. Creative Mode: " + F.tf(false))); + } + } + + public PacketHandler getPacketHandler() + { + return _packetHandler; + } + + @EventHandler + public void openProfile(PlayerInteractEvent event) + { + if(event.getItem() == null || event.getItem().getType() != Material.SKULL_ITEM) + return; + + new GUIProfile(getPlugin(), event.getPlayer(), _preferences, _achievementManager).openInventory();; + } + + @EventHandler + public void trackPortalDelayPlayers(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + for (Iterator playerNameIterator = _portalTime.keySet().iterator(); playerNameIterator.hasNext();) + { + String playerName = playerNameIterator.next(); + + if (UtilTime.elapsed(_portalTime.get(playerName), 5000)) + { + playerNameIterator.remove(); + } + } + } + + @EventHandler + public void showHeader(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTEST) + { + return; + } + + String text = C.cRed + "Welcome to Mineplex Clans"; + UtilTextTop.display(text, UtilServer.getPlayers()); + + //Fix Entity Names + for (Creature pet : _petManager.getPets()) + { + DisguiseBase disguise = _disguiseManager.getDisguise(pet); + + if (disguise instanceof DisguiseWither) + { + ((DisguiseWither) disguise).setName(text); + disguise.resendMetadata(); + } + } + + for (Mount mount : _mountManager.getMounts()) + { + if (mount instanceof MountDragon) + { + ((MountDragon)mount).SetName(text); + } + } + + for (Gadget gadget : _gadgetManager.getGadgets(GadgetType.MORPH)) + { + if (gadget instanceof MorphWither) + { + ((MorphWither)gadget).setWitherData(text, 100); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubVisibilityManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubVisibilityManager.java new file mode 100644 index 000000000..4e2088aa8 --- /dev/null +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubVisibilityManager.java @@ -0,0 +1,80 @@ +package mineplex.clanshub; + +import java.util.HashSet; + +import mineplex.core.MiniPlugin; +import mineplex.core.common.Rank; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilServer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.visibility.VisibilityManager; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerQuitEvent; + +public class HubVisibilityManager extends MiniPlugin +{ + public HubManager Manager; + + private HashSet _hiddenPlayers = new HashSet(); + + public HubVisibilityManager(HubManager manager) + { + super("Visibility Manager", manager.getPlugin()); + + Manager = manager; + } + + public void addHiddenPlayer(Player player) + { + _hiddenPlayers.add(player); + + } + + public void removeHiddenPlayer(Player player) + { + _hiddenPlayers.remove(player); + } + + @EventHandler + public void removeHiddenPlayerOnQuit(PlayerQuitEvent event) + { + _hiddenPlayers.remove(event.getPlayer()); + } + + @EventHandler + public void updateVisibility(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + return; + + for (Player player : UtilServer.getPlayers()) + { + Rank rank = Manager.GetClients().Get(player).GetRank(); + boolean hideMe = UtilMath.offset2d(player.getLocation(), Manager.GetSpawn()) == 0 || + (Manager.getPreferences().Get(player).Invisibility && (rank.has(Rank.MODERATOR) || rank == Rank.YOUTUBE || rank == Rank.TWITCH)) || + _hiddenPlayers.contains(player); + + for (Player other : UtilServer.getPlayers()) + { + boolean localHideMe = hideMe; + if (player.equals(other)) + continue; + + if (Manager.GetClients().Get(other).GetRank().has(Rank.MODERATOR)) + localHideMe = false; + + if (localHideMe || !Manager.getPreferences().Get(other).ShowPlayers) + { + VisibilityManager.Instance.setVisibility(player, false, other); + } + else + { + VisibilityManager.Instance.setVisibility(player, true, other); + } + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/JoinServerButton.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/JoinServerButton.java new file mode 100644 index 000000000..c28510a35 --- /dev/null +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/JoinServerButton.java @@ -0,0 +1,50 @@ +package mineplex.clanshub; + +import mineplex.core.common.Rank; +import mineplex.core.shop.item.IButton; +import mineplex.core.shop.page.ShopPageBase; + +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +public class JoinServerButton implements IButton +{ + private ShopPageBase _page; + private ClansTransferManager _transferManager; + private ServerInfo _serverInfo; + + public JoinServerButton(ShopPageBase page, ClansTransferManager transferManager, ServerInfo serverInfo) + { + _page = page; + _transferManager = transferManager; + _serverInfo = serverInfo; + } + + @Override + public void onClick(Player player, ClickType clickType) + { + selectServer(player, _serverInfo); + } + + public void selectServer(Player player, ServerInfo serverInfo) + { + if (serverInfo != null) + { + System.out.println("Selecting server :" + serverInfo.Name); + int slots = 1; + + if (serverInfo.getAvailableSlots() < slots && !_page.getClient().GetRank().has(Rank.ULTRA)) + { + _page.playDenySound(player); + } + else + { + _transferManager.selectServer(player, serverInfo); + } + } + else + { + _page.playDenySound(player); + } + } +} diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ServerInfo.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ServerInfo.java new file mode 100644 index 000000000..9624ee5b8 --- /dev/null +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ServerInfo.java @@ -0,0 +1,13 @@ +package mineplex.clanshub; + +public class ServerInfo +{ + public String Name; + public int CurrentPlayers = 0; + public int MaxPlayers = 0; + + public int getAvailableSlots() + { + return MaxPlayers - CurrentPlayers; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/WorldManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/WorldManager.java new file mode 100644 index 000000000..e91694063 --- /dev/null +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/WorldManager.java @@ -0,0 +1,208 @@ +package mineplex.clanshub; + +import mineplex.core.MiniPlugin; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilWorld; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import org.bukkit.GameMode; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.entity.Boat; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Item; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockBurnEvent; +import org.bukkit.event.block.BlockFormEvent; +import org.bukkit.event.block.BlockIgniteEvent; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.block.BlockSpreadEvent; +import org.bukkit.event.block.LeavesDecayEvent; +import org.bukkit.event.entity.CreatureSpawnEvent; +import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; +import org.bukkit.event.entity.EntityChangeBlockEvent; +import org.bukkit.event.entity.EntityCombustEvent; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.player.PlayerDropItemEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; +import org.bukkit.event.weather.WeatherChangeEvent; + +public class WorldManager extends MiniPlugin +{ + public HubManager Manager; + + public WorldManager(HubManager manager) + { + super("World Manager", manager.getPlugin()); + + Manager = manager; + + World world = UtilWorld.getWorld("world"); + + world.setGameRuleValue("doDaylightCycle", "false"); + + world.setTime(6000); + world.setStorm(false); + world.setThundering(false); + } + + @EventHandler + public void onBlockBreak(BlockBreakEvent event) + { + if (event.getPlayer().getGameMode() == GameMode.CREATIVE) + return; + + event.setCancelled(true); + } + + @EventHandler + public void onBlockBurn(BlockBurnEvent event) + { + event.setCancelled(true); + } + + @EventHandler + public void onBlockIgnite(BlockIgniteEvent event) + { + event.setCancelled(true); + } + + @EventHandler + public void onEntityChangeBlock(EntityChangeBlockEvent event) + { + event.setCancelled(true); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onExplosion(EntityExplodeEvent event) + { + event.blockList().clear(); + } + + @EventHandler + public void onVineGrow(BlockSpreadEvent event) + { + event.setCancelled(true); + } + + @EventHandler + public void onLeafDecay(LeavesDecayEvent event) + { + event.setCancelled(true); + } + + @EventHandler + public void onBlockPlace(BlockPlaceEvent event) + { + if (event.getPlayer().getGameMode() == GameMode.CREATIVE) + return; + + event.setCancelled(true); + } + + @EventHandler + public void onBorderUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTEST) + return; + + for (Player player : UtilServer.getPlayers()) + { + if (UtilMath.offset(player.getLocation(), Manager.GetSpawn()) > 50) + { + player.eject(); + player.leaveVehicle(); + player.teleport(Manager.GetSpawn()); + } + } + } + + @EventHandler(priority = EventPriority.LOW) + public void onItemPickup(PlayerPickupItemEvent event) + { + if (event.getPlayer().getGameMode() == GameMode.CREATIVE) + return; + + event.setCancelled(true); + } + + @EventHandler(priority = EventPriority.LOW) + public void onItemDrop(PlayerDropItemEvent event) + { + if (event.getPlayer().getGameMode() == GameMode.CREATIVE) + return; + + event.setCancelled(true); + } + + @EventHandler(priority = EventPriority.LOW) + public void onItemDespawn(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + return; + + for (Entity ent : UtilWorld.getWorld("world").getEntities()) + { + if (!(ent instanceof Item)) + continue; + + if (((Item)ent).getItemStack().getType() == Material.MONSTER_EGG) + continue; + + if (UtilEnt.GetMetadata(ent, "UtilItemSpawning") != null) + continue; + + if (ent.getTicksLived() > 1200) + ent.remove(); + } + } + + @EventHandler + public void onWeather(WeatherChangeEvent event) + { + if (!event.getWorld().getName().equals("world")) + return; + + event.setCancelled(true); + } + + @EventHandler + public void onBlockForm(BlockFormEvent event) + { + event.setCancelled(true); + } + + @EventHandler + public void onBoatBreak(CustomDamageEvent event) + { + if (event.GetDamageeEntity() instanceof Boat) + { + event.SetCancelled("Boat Cancel"); + } + } + + @EventHandler + public void prevenCombustiont(EntityCombustEvent event) + { + if (event.getEntity() instanceof Player) + { + event.setCancelled(true); + } + } + + @EventHandler + public void preventMobs(CreatureSpawnEvent event) + { + if (event.getSpawnReason() == SpawnReason.NATURAL || event.getSpawnReason() == SpawnReason.NETHER_PORTAL) + { + event.setCancelled(true); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/ForcefieldRadius.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/ForcefieldRadius.java new file mode 100644 index 000000000..2b6c166ed --- /dev/null +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/ForcefieldRadius.java @@ -0,0 +1,21 @@ +package mineplex.clanshub.commands; + +import mineplex.clanshub.ForcefieldManager; +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; + +import org.bukkit.entity.Player; + +public class ForcefieldRadius extends CommandBase +{ + public ForcefieldRadius(ForcefieldManager plugin) + { + super(plugin, Rank.ADMIN, "radius", "forcefield"); + } + + @Override + public void Execute(Player caller, String[] args) + { + Plugin.ForcefieldRadius(caller, args); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/GadgetToggle.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/GadgetToggle.java new file mode 100644 index 000000000..974b73f2f --- /dev/null +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/GadgetToggle.java @@ -0,0 +1,21 @@ +package mineplex.clanshub.commands; + +import mineplex.clanshub.HubManager; +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; + +import org.bukkit.entity.Player; + +public class GadgetToggle extends CommandBase +{ + public GadgetToggle(HubManager plugin) + { + super(plugin, Rank.ADMIN, "gadget"); + } + + @Override + public void Execute(Player caller, String[] args) + { + Plugin.ToggleGadget(caller); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/GameModeCommand.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/GameModeCommand.java new file mode 100644 index 000000000..aaf978085 --- /dev/null +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/GameModeCommand.java @@ -0,0 +1,49 @@ +package mineplex.clanshub.commands; + +import mineplex.clanshub.HubManager; +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; + +import org.bukkit.GameMode; +import org.bukkit.entity.Player; + +public class GameModeCommand extends CommandBase +{ + public GameModeCommand(HubManager plugin) + { + super(plugin, Rank.ADMIN, "gamemode", "gm"); + } + + @Override + public void Execute(Player caller, String[] args) + { + Player target = caller; + + if (args != null && args.length >= 1) + { + target = UtilPlayer.searchOnline(caller, args[0], true); + + if (target == null) + return; + } + + if (target.getGameMode() == GameMode.SURVIVAL) + { + target.setGameMode(GameMode.CREATIVE); + } + else + { + target.setGameMode(GameMode.SURVIVAL); + } + + if (!target.equals(caller)) + { + Plugin.addGameMode(caller, target); + UtilPlayer.message(target, F.main("Game Mode", caller.getName() + " toggled your Creative Mode: " + F.tf(target.getGameMode() == GameMode.CREATIVE))); + } + + UtilPlayer.message(caller, F.main("Game Mode", target.getName() + " Creative Mode: " + F.tf(target.getGameMode() == GameMode.CREATIVE))); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/profile/buttons/ButtonPrefs.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/profile/buttons/ButtonPrefs.java new file mode 100644 index 000000000..39f535112 --- /dev/null +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/profile/buttons/ButtonPrefs.java @@ -0,0 +1,55 @@ +package mineplex.clanshub.profile.buttons; + +import mineplex.clanshub.profile.gui.GUIProfile; +import mineplex.core.common.util.C; +import mineplex.core.gui.GuiItem; +import mineplex.core.itemstack.ItemBuilder; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; + +public class ButtonPrefs implements GuiItem +{ + private GUIProfile _profile; + private Player _player; + + public ButtonPrefs(GUIProfile profile, Player player) + { + _profile = profile; + _player = player; + } + + @Override + public void click(ClickType clickType) + { + _profile.getPrefManager().openShop(_player); + } + + @Override + public ItemStack getObject() + { + return new ItemBuilder(Material.REDSTONE_COMPARATOR).setTitle(C.Reset + C.cYellow + "Preferences").addLore(new String[] + { + "", + C.cWhite + "Set your preferences to your liking", + C.cWhite + "so you can enjoy the game more!", + + "", + C.cWhite + "Type " + C.cGreen + "/prefs" + C.cWhite + " to access this anywhere!" + }).build(); + } + + @Override + public void setup() + { + + } + + @Override + public void close() + { + + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/profile/buttons/ButtonStats.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/profile/buttons/ButtonStats.java new file mode 100644 index 000000000..b53c707bb --- /dev/null +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/profile/buttons/ButtonStats.java @@ -0,0 +1,63 @@ +package mineplex.clanshub.profile.buttons; + +import mineplex.clanshub.profile.gui.GUIProfile; +import mineplex.core.common.util.C; +import mineplex.core.gui.GuiItem; +import mineplex.core.itemstack.ItemStackFactory; + +import org.bukkit.ChatColor; +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.SkullMeta; + +public class ButtonStats implements GuiItem +{ + private GUIProfile _profile; + private Player _player; + + public ButtonStats(GUIProfile profile, Player player) + { + _profile = profile; + _player = player; + } + + @Override + public void click(ClickType clickType) + { + _profile.getAchievementManager().openShop(_player); + } + + @Override + public ItemStack getObject() + { + ItemStack item = ItemStackFactory.Instance.CreateStack(Material.SKULL_ITEM, (byte) 3, 1, + ChatColor.RESET + C.cYellow + "Stats and Achievements", + new String[] + { + "", + C.cWhite + "View your Statistics and Achievements", + C.cWhite + "for all of the games on Mineplex!", + + "", + C.cWhite + "Type " + C.cGreen + "/stats" + C.cWhite + " to access this anywhere!" + }); + SkullMeta meta = ((SkullMeta) item.getItemMeta()); + meta.setOwner(_player.getName()); + item.setItemMeta(meta); + return item; + } + + @Override + public void setup() + { + + } + + @Override + public void close() + { + + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/profile/gui/GUIProfile.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/profile/gui/GUIProfile.java new file mode 100644 index 000000000..2f243c289 --- /dev/null +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/profile/gui/GUIProfile.java @@ -0,0 +1,36 @@ +package mineplex.clanshub.profile.gui; + +import mineplex.clanshub.profile.buttons.ButtonPrefs; +import mineplex.clanshub.profile.buttons.ButtonStats; +import mineplex.core.achievement.AchievementManager; +import mineplex.core.gui.SimpleGui; +import mineplex.core.preferences.PreferencesManager; + +import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; + +public class GUIProfile extends SimpleGui +{ + private PreferencesManager _preferencesManager; + private AchievementManager _achievementManager; + + public GUIProfile(Plugin plugin, Player player, PreferencesManager preferencesManager, AchievementManager achievementManager) + { + super(plugin, player, "My Profile", 9*3); + _preferencesManager = preferencesManager; + _achievementManager = achievementManager; + + setItem(12, new ButtonStats(this, player)); + setItem(14, new ButtonPrefs(this, player)); + } + + public PreferencesManager getPrefManager() + { + return _preferencesManager; + } + + public AchievementManager getAchievementManager() + { + return _achievementManager; + } +} \ No newline at end of file From 25b0ae5916771aec29c27f010bf366141a5abbcd Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 25 Jul 2016 10:56:30 -0400 Subject: [PATCH 41/90] Add support for sending players back to any clans hub via portal --- Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java b/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java index 813744f5d..d1fe301e7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java @@ -91,7 +91,7 @@ public class Portal extends MiniPlugin ServerTransferEvent event = new ServerTransferEvent(player, serverName, draggedByParty); Bukkit.getPluginManager().callEvent(event); - final boolean override = serverName.equalsIgnoreCase("Lobby"); + final boolean override = serverName.equalsIgnoreCase("Lobby") || serverName.equalsIgnoreCase("ClansHub"); final Rank playerRank = _clientManager.Get(player).GetRank(); if(event.isCancel() && !event.isDraggedByParty()) From 979bb920347ec96ec565f55b0ddc5ffdd327bfeb Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 25 Jul 2016 10:57:15 -0400 Subject: [PATCH 42/90] Allow treasure chests to be placed in other locations instead of fixing them in the main hub's configuration --- .../src/mineplex/core/treasure/TreasureManager.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java index 2b82b9779..8ea52f005 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java @@ -4,11 +4,13 @@ import java.util.ArrayList; import java.util.List; import mineplex.core.gadget.GadgetManager; + import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; @@ -121,13 +123,21 @@ public class TreasureManager extends MiniPlugin for (TreasureLocation treasureLocation : _treasureLocations) { treasureLocation.cleanup(); + HandlerList.unregisterAll(treasureLocation); } + _treasureLocations.clear(); } public void addOpenStat(Player player, TreasureType treasureType) { _statsManager.incrementStat(player, "Global.Treasure." + treasureType.getStatName(), 1); } + + public void addTreasureLocation(TreasureLocation loc) + { + _treasureLocations.add(loc); + _plugin.getServer().getPluginManager().registerEvents(loc, _plugin); + } public Reward[] getRewards(Player player, RewardPool.Type pool, RewardType rewardType) { From 0ecdce4edc28fccc946ad5a2996568a733fecb66 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 25 Jul 2016 10:58:32 -0400 Subject: [PATCH 43/90] Add clans hub to maven --- Plugins/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/Plugins/pom.xml b/Plugins/pom.xml index a23ba8dc2..7b2863778 100644 --- a/Plugins/pom.xml +++ b/Plugins/pom.xml @@ -27,6 +27,7 @@ Mineplex.Game.Clans Mineplex.Game.Clans.Core Mineplex.Hub + Mineplex.Hub.Clans Mineplex.MapParser Mineplex.Minecraft.Game.ClassCombat Mineplex.Minecraft.Game.Core From 6f0d21120e015093608e658a4f400d9bd139b950 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 25 Jul 2016 10:59:03 -0400 Subject: [PATCH 44/90] Serious tweaks to gameplay and begin documentation --- Plugins/Mineplex.Game.Clans/plugin.yml | 2 +- .../src/mineplex/game/clans/Clans.java | 8 +- .../game/clans/clans/ClansBetaManager.java | 27 --- .../mineplex/game/clans/clans/ClansGame.java | 18 -- .../game/clans/clans/ClansManager.java | 14 +- .../clans/clans/banners/BannerManager.java | 21 +- .../clans/clans/commands/ClansCommand.java | 6 + .../clans/clans/nether/NetherManager.java | 174 ++++++--------- .../game/clans/clans/nether/NetherPortal.java | 23 +- .../clans/clans/nether/PortalRepository.java | 93 ++++++++ .../clans/nether/command/DeleteCommand.java | 15 +- .../nether/command/ForceTeleportCommand.java | 6 +- .../nether/miniboss/MinibossFireball.java | 4 +- .../miniboss/NetherMinibossManager.java | 67 ++++-- .../nether/miniboss/bosses/GhastMiniboss.java | 23 +- .../scoreboard/ClansScoreboardManager.java | 2 +- .../elements/ScoreboardElementClan.java | 25 ++- .../elements/ScoreboardElementPlayer.java | 28 ++- .../game/clans/clans/siege/SiegeManager.java | 35 +-- .../siege/command/GiveWeaponCommand.java | 26 +++ .../clans/siege/weapon/projectile/Crater.java | 137 +----------- .../game/clans/clans/war/WarManager.java | 207 +++++++++--------- .../war/{WarInvasion.java => WarSiege.java} | 22 +- ...ionEndEvent.java => WarSiegeEndEvent.java} | 20 +- ...tartEvent.java => WarSiegeStartEvent.java} | 20 +- .../clans/worldevent/EventTerrainFinder.java | 131 +++++++---- .../clans/worldevent/WorldEventManager.java | 20 +- .../worldevent/command/StartCommand.java | 4 +- .../game/classcombat/item/ItemUsable.java | 5 +- .../game/core/boss/ironwizard/GolemBoss.java | 2 +- .../abilities/GolemDeadlyTremor.java | 2 +- .../core/boss/skeletonking/SkeletonBoss.java | 3 +- .../boss/skeletonking/SkeletonCreature.java | 1 - 33 files changed, 636 insertions(+), 555 deletions(-) delete mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansBetaManager.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/PortalRepository.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/command/GiveWeaponCommand.java rename Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/{WarInvasion.java => WarSiege.java} (54%) rename Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/event/{WarInvasionEndEvent.java => WarSiegeEndEvent.java} (52%) rename Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/event/{WarInvasionStartEvent.java => WarSiegeStartEvent.java} (51%) diff --git a/Plugins/Mineplex.Game.Clans/plugin.yml b/Plugins/Mineplex.Game.Clans/plugin.yml index 7365566e7..3bebeab2e 100644 --- a/Plugins/Mineplex.Game.Clans/plugin.yml +++ b/Plugins/Mineplex.Game.Clans/plugin.yml @@ -1,3 +1,3 @@ name: Clans main: mineplex.game.clans.Clans -version: 0.1 \ No newline at end of file +version: 1.0 \ No newline at end of file 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 7612eaf8a..0fd3594cf 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java @@ -63,7 +63,7 @@ import net.minecraft.server.v1_8_R3.MinecraftServer; public class Clans extends JavaPlugin { - public static final String VERSION = "Beta 1.0"; + public static final String MAP = "Map 1"; private String WEB_CONFIG = "webServer"; // Modules @@ -201,8 +201,8 @@ public class Clans extends JavaPlugin getServer().getPluginManager().callEvent(new ServerShutdownEvent(this)); } - public static String version() + public static String getMap() { - return VERSION; + return MAP; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansBetaManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansBetaManager.java deleted file mode 100644 index a669ca6f4..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansBetaManager.java +++ /dev/null @@ -1,27 +0,0 @@ -package mineplex.game.clans.clans; - -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.player.PlayerJoinEvent; - -import mineplex.core.MiniPlugin; -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.task.TaskManager; -import mineplex.game.clans.Clans; - -public class ClansBetaManager extends MiniPlugin -{ - public ClansBetaManager(ClansManager manager, TaskManager taskManager) - { - super("Clans Beta", manager.getPlugin()); - } - - @EventHandler(priority = EventPriority.HIGHEST) - public void onPlayerJoin(final PlayerJoinEvent event) - { - UtilPlayer.message(event.getPlayer(), C.cDAquaB + "Welcome to Mineplex Clans " + Clans.VERSION); - - } - -} 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 7ec9d898a..8784ee3f3 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 @@ -230,12 +230,6 @@ public class ClansGame extends MiniPlugin return; } - if (_clans.getWarManager().allowFromInvade(event.getBlock().getLocation(), event.getPlayer())) - { - // Allow because of invasion - return; - } - // Disallow event.setCancelled(true); @@ -287,12 +281,6 @@ public class ClansGame extends MiniPlugin Location loc = event.getClickedBlock().getRelative(event.getBlockFace()).getLocation(); if (UtilBlock.usable(event.getClickedBlock())) loc = event.getClickedBlock().getLocation(); - if (_clans.getWarManager().allowFromInvade(loc, event.getPlayer())) - { - // Allow because of invasion - return; - } - // Borderlands if (player.getGameMode() != GameMode.CREATIVE && player.getItemInHand() != null && _clans.getClanBlocks().denyUsePlace(player.getItemInHand().getTypeId()) && _clans.getClanUtility().isBorderlands(event.getClickedBlock().getLocation())) { @@ -564,12 +552,6 @@ public class ClansGame extends MiniPlugin ClanInfo clan = _clans.getClanUtility().getOwner(event.getEntity().getLocation()); if (clan == null) return; - - if (_clans.getWarManager().isBeingInvaded(clan)) - { - // Allow because of invasion - return; - } if (!clan.isProtected()) event.setCancelled(true); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index 0aee9a4bb..a7c10a0df 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -325,8 +325,6 @@ public class ClansManager extends MiniClientPluginimplements IRelati new ClanEnergyTracker(plugin, this); // new StuckManager(this); - new ClansBetaManager(this, _taskManager); - new PotatoManager(plugin, this); new Weapon(plugin, energy); @@ -451,8 +449,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati for (Location location : welcomeHolograms) { Hologram hologram = new Hologram(hologramManager, location, - C.cGreenB + "Welcome to Clans Beta", - C.cWhite + "Please be aware there may be bugs", + C.cGreenB + "Welcome to Clans!", C.cWhite + "Type " + C.cYellow + "/clan" + C.cWhite + " to get started!" ); hologram.start(); @@ -663,6 +660,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati public void Join(PlayerJoinEvent event) { event.setJoinMessage(null); + UtilPlayer.message(event.getPlayer(), C.cDAquaB + "Welcome to Mineplex Clans!"); if (_incognitoManager.Get(event.getPlayer()).Status) { @@ -801,7 +799,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati continue; } - UtilPlayer.message(event.getPlayer(), F.main("Clans", "Server is on version: " + F.elem(Clans.version()))); + UtilPlayer.message(event.getPlayer(), F.main("Clans", "Server is running Mineplex Clans version " + _plugin.getDescription().getVersion() + "!")); event.setCancelled(true); } } @@ -1221,8 +1219,8 @@ public class ClansManager extends MiniClientPluginimplements IRelati if (online >= UtilServer.getServer().getMaxPlayers() && !rank.has(Rank.ADMIN) && !event.getPlayer().isWhitelisted() && !event.getPlayer().isOp()) { - event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Clans Beta is full! Try again soon"); - event.setKickMessage("Clans Beta is full! Try again soon"); + event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "This Clans server is full! Try again soon"); + event.setKickMessage("This Clans server is full! Try again soon"); } else { @@ -1245,7 +1243,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati { if (event.getMessage().toLowerCase().equals("/lobby") || event.getMessage().toLowerCase().equals("/hub") || event.getMessage().toLowerCase().equals("/leave")) { - Portal.getInstance().sendPlayerToServer(event.getPlayer(), "Lobby"); + Portal.getInstance().sendPlayerToServer(event.getPlayer(), "ClansHub"); event.setCancelled(true); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerManager.java index 9877b5c91..c5b168900 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerManager.java @@ -4,14 +4,18 @@ import java.util.HashMap; import mineplex.core.MiniPlugin; import mineplex.core.common.Rank; +import mineplex.core.common.util.F; import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.banners.command.BannerCommand; +import mineplex.game.clans.core.repository.ClanTerritory; import org.bukkit.Bukkit; import org.bukkit.Material; @@ -91,11 +95,21 @@ public class BannerManager extends MiniPlugin public void placeBanner(Player placing, ClanBanner banner) { + if (!Recharge.Instance.use(placing, "Place Banner", 30000, true, false)) + { + return; + } Block block = placing.getLocation().getBlock(); - BlockPlaceEvent event = new BlockPlaceEvent(block, block.getState(), block, placing.getItemInHand(), placing, false); + BlockPlaceEvent event = new BlockPlaceEvent(block, block.getState(), block, placing.getItemInHand(), placing, true); Bukkit.getPluginManager().callEvent(event); if (!event.isCancelled()) { + ClanTerritory claim = ClansManager.getInstance().getClanUtility().getClaim(block.getLocation()); + if (claim != null && !claim.Owner.equals(banner.getClan().getName())) + { + UtilPlayer.message(placing, F.main("Clans", "You cannot place your Clan Banner there.")); + return; + } ClansManager.getInstance().getBlockRestore().restore(block); if (block.getType() == Material.AIR && UtilBlock.fullSolid(block.getRelative(BlockFace.DOWN))) { @@ -106,6 +120,11 @@ public class BannerManager extends MiniPlugin state.update(); _placedBanners.put(block, System.currentTimeMillis()); } + else + { + UtilPlayer.message(placing, F.main("Clans", "You cannot place your Clan Banner there.")); + return; + } } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java index 059e55d54..fa710b71f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java @@ -349,6 +349,12 @@ public class ClansCommand extends CommandBase return; } + if (Plugin.getTutorial().inTutorial(caller)) + { + UtilPlayer.message(caller, F.main("Clans", "You cannot invite others while in a tutorial.")); + return; + } + if (args.length < 2) { UtilPlayer.message(caller, F.main("Clans", "You did not input an invitee.")); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java index dc79d705a..50b4c210b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java @@ -1,7 +1,6 @@ package mineplex.game.clans.clans.nether; -import java.io.File; -import java.io.IOException; +import java.util.Comparator; import java.util.HashMap; import java.util.List; @@ -40,8 +39,6 @@ import org.bukkit.World; import org.bukkit.WorldBorder; import org.bukkit.WorldCreator; import org.bukkit.block.Block; -import org.bukkit.configuration.ConfigurationSection; -import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -55,6 +52,8 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerPortalEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; import com.google.common.collect.Lists; @@ -64,12 +63,11 @@ public class NetherManager extends MiniPlugin private static final String CLAIM_WAND_NAME = C.cRedB + "Portal Claim Wand"; private static final String[] CLAIM_WAND_LORE = new String[] {C.cYellow + "Left Click to select the Portal's first corner", C.cYellow + "Right Click to select the Portal's second corner"}; private static final ItemStack CLAIM_WAND = new ItemBuilder(Material.WOOD_AXE).setTitle(CLAIM_WAND_NAME).setLore(CLAIM_WAND_LORE).build(); + private PortalRepository _repo; private NetherMinibossManager _miniboss; private World _netherWorld; - public List Portals = Lists.newArrayList(); + private List _portals = Lists.newArrayList(); private List _returnPortals = Lists.newArrayList(); - private File _portalCfg; - private YamlConfiguration _portalConfig; public HashMap InNether = new HashMap<>(); public HashMap OverworldOrigins = new HashMap<>(); public HashMap Claiming = new HashMap<>(); @@ -78,21 +76,6 @@ public class NetherManager extends MiniPlugin { super("Nether", manager.getPlugin()); - _portalCfg = new File(UtilServer.getServer().getWorlds().get(0).getWorldFolder().getPath() + File.separator + ".." + File.separator + "portals.yml"); - - try - { - if (!_portalCfg.exists()) - { - _portalCfg.createNewFile(); - } - _portalConfig = YamlConfiguration.loadConfiguration(_portalCfg); - } - catch (Exception e) - { - e.printStackTrace(); - } - begin(); _miniboss = new NetherMinibossManager(this); addCommand(new PortalCommand(this)); @@ -108,59 +91,24 @@ public class NetherManager extends MiniPlugin Bukkit.createWorld(creator); } _netherWorld = Bukkit.getWorld("nether"); - + _netherWorld.setSpawnLocation(43, 135, 113); WorldBorder worldBorder = _netherWorld.getWorldBorder(); worldBorder.setCenter(0, 0); - worldBorder.setSize(200 * 2); + worldBorder.setSize(800 * 2); + _repo = new PortalRepository(getPlugin(), this); loadPortals(); } private void loadPortals() { - try - { - if (!_portalConfig.isInt("PortalCount")) - { - _portalConfig.set("PortalCount", 0); - _portalConfig.save(_portalCfg); - } - - log("Loading " + _portalConfig.getInt("PortalCount") + " Nether Portals!"); - ConfigurationSection portalSection = _portalConfig.getConfigurationSection("Portals"); - for (String portalSectionPath : portalSection.getKeys(false)) - { - ConfigurationSection portal = portalSection.getConfigurationSection(portalSectionPath); - Location firstCorner = UtilWorld.strToLoc(portal.getString("CornerOne")); - Location secondCorner = UtilWorld.strToLoc(portal.getString("CornerTwo")); - boolean returnPortal = portal.getBoolean("ReturnPortal"); - - NetherPortal netherPortal = new NetherPortal(firstCorner, secondCorner, returnPortal); - Portals.add(netherPortal); - if (returnPortal) - { - _returnPortals.add(netherPortal); - } - } - } - catch (Exception e) - { - e.printStackTrace(); - } + _repo.loadPortals(); } @Override public void disable() { closePortals(); - try - { - savePortals(); - } - catch (IOException e) - { - e.printStackTrace(); - } for (Player player : InNether.keySet()) { player.teleport(Spawn.getNorthSpawn()); @@ -188,14 +136,55 @@ public class NetherManager extends MiniPlugin return OverworldOrigins.getOrDefault(player, Spawn.getNorthSpawn()); } + public NetherPortal getPortal(int id) + { + for (NetherPortal portal : _portals) + { + if (portal.getId() == id) + { + return portal; + } + } + + return null; + } + + public void addPortal(NetherPortal portal) + { + _portals.add(portal); + if (portal.isReturnPortal()) + { + _returnPortals.add(portal); + } + _portals.sort(new Comparator() + { + public int compare(NetherPortal o1, NetherPortal o2) + { + if (o1.getId() > o2.getId()) + { + return 1; + } + return -1; + } + }); + } + + public void deletePortal(NetherPortal portal) + { + portal.close(); + _portals.remove(portal); + _returnPortals.remove(portal); + _repo.deletePortal(portal.getId()); + } + public void spawnPortal(long duration) { - if (Portals.isEmpty() || _returnPortals.isEmpty()) + if (_portals.isEmpty() || _returnPortals.isEmpty()) { return; } List available = Lists.newArrayList(); - available.addAll(Portals); + available.addAll(_portals); for (NetherPortal remove : _returnPortals) { available.remove(remove); @@ -228,28 +217,13 @@ public class NetherManager extends MiniPlugin } ClaimData data = Claiming.remove(creator); - NetherPortal portal = new NetherPortal(data.getFirstCorner().getLocation(), data.getSecondCorner().getLocation(), returnPortal); - Portals.add(portal); - if (returnPortal) - { - _returnPortals.add(portal); - } - - try - { - savePortals(); - UtilPlayer.message(creator, F.main(getName(), "Portal successfully created!")); - } - catch (Exception e) - { - UtilPlayer.message(creator, F.main(getName(), "An error occurred while creating that portal! Please report this immediately!")); - return; - } + _repo.addPortal(UtilWorld.locToStr(data.getFirstCorner().getLocation()), UtilWorld.locToStr(data.getSecondCorner().getLocation()), returnPortal); + UtilPlayer.message(creator, F.main(getName(), "Portal successfully created!")); } public void closePortals() { - for (NetherPortal portal : Portals) + for (NetherPortal portal : _portals) { portal.close(); } @@ -258,12 +232,9 @@ public class NetherManager extends MiniPlugin public void showPortalList(Player player) { UtilPlayer.message(player, F.main(getName(), "Portal List:")); - for (int i = 0; i < Portals.size(); i++) - { - int id = i + 1; - NetherPortal portal = Portals.get(i); - - UtilPlayer.message(player, C.cBlue + "- " + F.elem("Portal " + id + ": " + C.cGray + UtilWorld.locToStrClean(portal.getLocation()).replace("(", "").replace(")", ""))); + for (NetherPortal portal : _portals) + { + UtilPlayer.message(player, C.cBlue + "- " + F.elem("Portal " + portal.getId() + ": " + C.cGray + UtilWorld.locToStrClean(portal.getLocation()).replace("(", "").replace(")", ""))); } } @@ -273,22 +244,6 @@ public class NetherManager extends MiniPlugin UtilPlayer.message(player, F.main(getName(), "You have been given a Portal Claim Wand!")); } - public void savePortals() throws IOException - { - _portalConfig.set("PortalCount", Portals.size()); - _portalConfig.set("Portals", null); - _portalConfig.createSection("Portals"); - for (int i = 0; i < Portals.size(); i++) - { - Integer id = i + 1; - _portalConfig.set("Portals." + id.toString() + ".CornerOne", UtilWorld.locToStr(Portals.get(i).getCorners()[0])); - _portalConfig.set("Portals." + id.toString() + ".CornerTwo", UtilWorld.locToStr(Portals.get(i).getCorners()[1])); - _portalConfig.set("Portals." + id.toString() + ".ReturnPortal", Portals.get(i).isReturnPortal()); - } - - _portalConfig.save(_portalCfg); - } - @EventHandler public void breakBlock(BlockBreakEvent event) { @@ -342,6 +297,7 @@ public class NetherManager extends MiniPlugin InNether.remove(event.getPlayer()); event.getPlayer().teleport(getReturnLocation(event.getPlayer())); OverworldOrigins.remove(event.getPlayer()); + event.getPlayer().removePotionEffect(PotionEffectType.NIGHT_VISION); UtilPlayer.message(event.getPlayer(), F.main(getName(), "You have escaped " + F.clansNether("The Nether") + "!")); }, 1); } @@ -368,9 +324,18 @@ public class NetherManager extends MiniPlugin { player.teleport(getReturnLocation(player)); OverworldOrigins.remove(player); + player.removePotionEffect(PotionEffectType.NIGHT_VISION); UtilPlayer.message(player, F.main(getName(), "You have been forced to escape " + F.clansNether("The Nether") + " to survive its demonic poisons!")); } } + else + { + if (!player.hasPotionEffect(PotionEffectType.NIGHT_VISION)) + { + int ticks = (int)((InNether.get(player) - System.currentTimeMillis()) / 1000) * 20; + player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, ticks, 0)); + } + } } UtilServer.getPlayersCollection() @@ -391,12 +356,13 @@ public class NetherManager extends MiniPlugin InNether.remove(event.getPlayer()); event.getPlayer().teleport(getReturnLocation(event.getPlayer())); OverworldOrigins.remove(event.getPlayer()); + event.getPlayer().removePotionEffect(PotionEffectType.NIGHT_VISION); } Claiming.remove(event.getPlayer()); } @EventHandler(priority = EventPriority.LOWEST) - public void onQuit(PlayerDeathEvent event) + public void onDie(PlayerDeathEvent event) { InNether.remove(event.getEntity()); OverworldOrigins.remove(event.getEntity()); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java index fa6e8c14b..d1def8de8 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java @@ -23,12 +23,15 @@ import org.bukkit.event.block.BlockPhysicsEvent; import org.bukkit.event.entity.EntityPortalEnterEvent; import org.bukkit.event.entity.EntityPortalEvent; import org.bukkit.event.player.PlayerPortalEvent; +import org.bukkit.event.world.ChunkUnloadEvent; +import org.bukkit.potion.PotionEffectType; import com.google.common.collect.Lists; public class NetherPortal implements Listener { private static final int SECONDS_UNTIL_PORTAL = 5; + private int _id; private List _frame = Lists.newArrayList(); private List _portal = Lists.newArrayList(); private Location _loc; @@ -39,8 +42,9 @@ public class NetherPortal implements Listener public boolean Open = false; public long Expire = -1; - public NetherPortal(Location firstCorner, Location secondCorner, boolean returnPortal) + public NetherPortal(int id, Location firstCorner, Location secondCorner, boolean returnPortal) { + _id = id; int maxX = Math.max(firstCorner.getBlockX(), secondCorner.getBlockX()); int minX = Math.min(firstCorner.getBlockX(), secondCorner.getBlockX()); int maxY = Math.max(firstCorner.getBlockY(), secondCorner.getBlockY()); @@ -99,6 +103,11 @@ public class NetherPortal implements Listener return _frame.contains(block) || _portal.contains(block); } + public int getId() + { + return _id; + } + public Location getLocation() { return _loc; @@ -148,7 +157,6 @@ public class NetherPortal implements Listener { Open = false; Expire = -1; - HandlerList.unregisterAll(this); for (Block block : _portal) { block.setType(Material.AIR); @@ -157,6 +165,7 @@ public class NetherPortal implements Listener { block.setType(Material.AIR); } + HandlerList.unregisterAll(this); } @EventHandler(priority = EventPriority.HIGHEST) @@ -204,6 +213,7 @@ public class NetherPortal implements Listener ClansManager.getInstance().getNetherManager().InNether.remove((Player)event.getEntity()); event.getEntity().teleport(ClansManager.getInstance().getNetherManager().getReturnLocation((Player)event.getEntity())); ClansManager.getInstance().getNetherManager().OverworldOrigins.remove((Player)event.getEntity()); + ((Player)event.getEntity()).removePotionEffect(PotionEffectType.NIGHT_VISION); UtilPlayer.message(event.getEntity(), F.main(ClansManager.getInstance().getNetherManager().getName(), "You have escaped " + F.clansNether("The Nether") + "!")); } else @@ -241,4 +251,13 @@ public class NetherPortal implements Listener close(); } } + + @EventHandler + public void onUnload(ChunkUnloadEvent event) + { + if (event.getChunk().getX() == _loc.getChunk().getX() && event.getChunk().getZ() == _loc.getChunk().getZ()) + { + event.setCancelled(true); + } + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/PortalRepository.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/PortalRepository.java new file mode 100644 index 000000000..7a57e144a --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/PortalRepository.java @@ -0,0 +1,93 @@ +package mineplex.game.clans.clans.nether; + +import mineplex.core.common.util.UtilWorld; +import mineplex.core.database.MinecraftRepository; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.column.ColumnBoolean; +import mineplex.serverdata.database.column.ColumnInt; +import mineplex.serverdata.database.column.ColumnVarChar; + +import org.bukkit.plugin.java.JavaPlugin; + +public class PortalRepository extends MinecraftRepository +{ + private static final String CREATE = "CREATE TABLE IF NOT EXISTS clansNetherPortals (id INT NOT NULL AUTO_INCREMENT," + + "cornerOne VARCHAR(30)," + + "cornerTwo VARCHAR(30)," + + "returnPortal BOOL," + + "PRIMARY KEY (id));"; + + private static final String GET_PORTALS = "SELECT * FROM clansNetherPortals;"; + private static final String INSERT_PORTAL = "INSERT INTO clansNetherPortals (cornerOne, cornerTwo, returnPortal) VALUES (?, ?, ?);"; + private static final String DELETE_PORTAL = "DELETE FROM clansNetherPortals WHERE id=?;"; + + private NetherManager _nether; + + public PortalRepository(JavaPlugin plugin, NetherManager portalManager) + { + super(plugin, DBPool.getAccount()); + + _nether = portalManager; + } + + public void loadPortals() + { + _nether.runAsync(() -> + { + executeQuery(GET_PORTALS, resultSet -> + { + while (resultSet.next()) + { + final int id = resultSet.getInt("id"); + final String cornerOne = resultSet.getString("cornerOne"); + final String cornerTwo = resultSet.getString("cornerTwo"); + final boolean returnPortal = resultSet.getBoolean("returnPortal"); + + _nether.runSync(() -> + { + NetherPortal portal = new NetherPortal(id, UtilWorld.strToLoc(cornerOne), UtilWorld.strToLoc(cornerTwo), returnPortal); + _nether.addPortal(portal); + }); + } + }); + }); + } + + public void addPortal(final String cornerOne, final String cornerTwo, final boolean returnPortal) + { + _nether.runAsync(() -> + { + executeInsert(INSERT_PORTAL, resultSet -> + { + while (resultSet.next()) + { + final int id = resultSet.getInt(1); + _nether.runSync(() -> + { + NetherPortal portal = new NetherPortal(id, UtilWorld.strToLoc(cornerOne), UtilWorld.strToLoc(cornerTwo), returnPortal); + _nether.addPortal(portal); + }); + } + }, new ColumnVarChar("cornerOne", 30, cornerOne), new ColumnVarChar("cornerTwo", 30, cornerTwo), new ColumnBoolean("returnPortal", returnPortal)); + }); + } + + public void deletePortal(final int id) + { + _nether.runAsync(() -> + { + executeUpdate(DELETE_PORTAL, new ColumnInt("id", id)); + }); + } + + @Override + protected void initialize() + { + executeUpdate(CREATE); + } + + @Override + protected void update() + { + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/DeleteCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/DeleteCommand.java index 2b6ac0f41..cb513218c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/DeleteCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/DeleteCommand.java @@ -5,6 +5,7 @@ import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.game.clans.clans.nether.NetherManager; +import mineplex.game.clans.clans.nether.NetherPortal; import org.bukkit.entity.Player; @@ -27,21 +28,13 @@ public class DeleteCommand extends CommandBase id = Integer.parseInt(args[0]); } catch (Exception e) {} - if (id == null || id > Plugin.Portals.size() || id < 1) + if (id == null || Plugin.getPortal(id) == null) { UtilPlayer.message(caller, F.main(Plugin.getName(), "Usage: " + F.elem("/portal " + _aliasUsed + " "))); return; } + NetherPortal portal = Plugin.getPortal(id); UtilPlayer.message(caller, F.main(Plugin.getName(), "Deleting the " + F.clansNether("Nether Portal") + " with ID " + id + "!")); - Plugin.Portals.remove(id - 1); - try - { - Plugin.savePortals(); - } - catch (Exception e) - { - UtilPlayer.message(caller, F.main(Plugin.getName(), "An error occurred while deleting that portal! Please report this immediately!")); - return; - } + Plugin.deletePortal(portal); } } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/ForceTeleportCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/ForceTeleportCommand.java index 5640d6526..18ce12cc1 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/ForceTeleportCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/ForceTeleportCommand.java @@ -4,12 +4,15 @@ 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.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.game.clans.clans.ClanTips.TipType; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.nether.NetherManager; import mineplex.game.clans.spawn.Spawn; import org.bukkit.entity.Player; +import org.bukkit.potion.PotionEffectType; /** * Command to artificially portal @@ -38,6 +41,7 @@ public class ForceTeleportCommand extends CommandBase Plugin.InNether.remove(caller); caller.teleport(Plugin.getReturnLocation(caller)); Plugin.OverworldOrigins.remove(caller); + caller.removePotionEffect(PotionEffectType.NIGHT_VISION); UtilPlayer.message(caller, F.main(ClansManager.getInstance().getNetherManager().getName(), "You have escaped " + F.clansNether("The Nether") + "!")); } else @@ -49,7 +53,7 @@ public class ForceTeleportCommand extends CommandBase { if (natural) { - Plugin.InNether.put(caller, System.currentTimeMillis()); + Plugin.InNether.put(caller, System.currentTimeMillis() + UtilTime.convert(10, TimeUnit.MINUTES, TimeUnit.MILLISECONDS)); Plugin.OverworldOrigins.put(caller, caller.getLocation()); caller.teleport(Plugin.getNetherWorld().getSpawnLocation()); ClansManager.getInstance().ClanTips.displayTip(TipType.ENTER_NETHER, caller); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/MinibossFireball.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/MinibossFireball.java index 2df5fe663..e085b326b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/MinibossFireball.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/MinibossFireball.java @@ -44,8 +44,8 @@ public class MinibossFireball implements Listener { double range = hitMap.get(cur); - ClansManager.getInstance().getCondition().Factory().Ignite("Fireball", cur, ((LivingEntity)proj.getMetadata("MINIBOSS_FIREBALL").get(0)), 7 * range, false, false); - ClansManager.getInstance().getCondition().Factory().Falling("Fireball", cur, ((LivingEntity)proj.getMetadata("MINIBOSS_FIREBALL").get(0)), 10, false, true); + ClansManager.getInstance().getCondition().Factory().Ignite("Fireball", cur, ((LivingEntity)proj.getMetadata("MINIBOSS_FIREBALL").get(0).value()), 7 * range, false, false); + ClansManager.getInstance().getCondition().Factory().Falling("Fireball", cur, ((LivingEntity)proj.getMetadata("MINIBOSS_FIREBALL").get(0).value()), 10, false, true); UtilAction.velocity(cur, UtilAlg.getTrajectory(proj.getLocation().add(0, -0.5, 0), cur.getEyeLocation()), 1.6 * range, false, 0, 0.8 * range, 1.2, true); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossManager.java index d486c3188..3d4da1f7e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossManager.java @@ -1,16 +1,18 @@ package mineplex.game.clans.clans.nether.miniboss; +import java.util.Comparator; +import java.util.HashMap; import java.util.List; import mineplex.core.common.util.UtilMath; -import mineplex.core.recharge.Recharge; +import mineplex.core.common.util.UtilTime; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.nether.NetherManager; import org.bukkit.Bukkit; +import org.bukkit.Location; import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntitySpawnEvent; @@ -19,23 +21,60 @@ import com.google.common.collect.Lists; public class NetherMinibossManager implements Listener { - private static final long TIME_BETWEEN_MINIBOSS_TARGET_PLAYER = 10000; + private static final long MINIBOSS_SPAWN_RATE = 10000; private NetherManager _manager; + private HashMap _spawns = new HashMap<>(); + private long _lastSpawned; private boolean _allowSpawn = false; public NetherMinibossManager(NetherManager manager) { _manager = manager; new MinibossFireball(); - Bukkit.getPluginManager().registerEvents(this, manager.getPlugin()); + manager.runSyncLater(() -> + { + List sort = Lists.newArrayList(); + sort.add(new Location(manager.getNetherWorld(), -18, 142, 61)); + sort.add(new Location(manager.getNetherWorld(), -39, 133, -25)); + sort.add(new Location(manager.getNetherWorld(), -102, 133, -99)); + sort.add(new Location(manager.getNetherWorld(), -27, 141, -140)); + sort.add(new Location(manager.getNetherWorld(), 32, 143, -95)); + sort.add(new Location(manager.getNetherWorld(), 43, 134, 22)); + sort.add(new Location(manager.getNetherWorld(), 102, 141, -31)); + sort.add(new Location(manager.getNetherWorld(), 151, 136, 34)); + sort.sort(new Comparator() + { + public int compare(Location o1, Location o2) + { + if (UtilMath.offset2d(o1, manager.getNetherWorld().getSpawnLocation()) < UtilMath.offset(o2, manager.getNetherWorld().getSpawnLocation())) + { + return -1; + } + return 1; + } + }); + for (int i = 0; i < 3; i++) + { + _spawns.put(sort.get(i).add(0.5, 1.5, 0.5), NetherMinibossType.ARCHER); + } + for (int i = 3; i < 6; i++) + { + _spawns.put(sort.get(i).add(0.5, 1.5, 0.5), NetherMinibossType.WARRIOR); + } + for (int i = 6; i < 8; i++) + { + _spawns.put(sort.get(i).add(0.5, 1.5, 0.5), NetherMinibossType.GHAST); + } + Bukkit.getPluginManager().registerEvents(this, manager.getPlugin()); + }, 20L); } - private void spawnAttacker(Player player) + private void spawnAttacker(Location loc) { - NetherMinibossType bossType = NetherMinibossType.values()[UtilMath.r(NetherMinibossType.values().length)]; + NetherMinibossType bossType = _spawns.get(loc); _allowSpawn = true; - bossType.getNewInstance(player.getLocation()); + bossType.getNewInstance(loc); _allowSpawn = false; } @@ -59,18 +98,12 @@ public class NetherMinibossManager implements Listener return; } - List targets = Lists.newArrayList(); - targets.addAll(_manager.InNether.keySet()); - - for (Player player : targets) + if (!_manager.InNether.isEmpty() && UtilTime.elapsed(_lastSpawned, MINIBOSS_SPAWN_RATE)) { - if (player.isDead() || !player.isValid()) + _lastSpawned = System.currentTimeMillis(); + for (Location spawn : _spawns.keySet()) { - continue; - } - if (_manager.isInNether(player) && Recharge.Instance.use(player, "Nether Miniboss Spawn", TIME_BETWEEN_MINIBOSS_TARGET_PLAYER, false, false)) - { - spawnAttacker(player); + spawnAttacker(spawn); } } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/GhastMiniboss.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/GhastMiniboss.java index 79d2ae5ea..150814f82 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/GhastMiniboss.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/GhastMiniboss.java @@ -2,17 +2,21 @@ package mineplex.game.clans.clans.nether.miniboss.bosses; import java.util.Random; +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.game.clans.clans.ClansManager; import mineplex.game.clans.clans.nether.miniboss.MinibossFireball; import mineplex.game.clans.clans.nether.miniboss.NetherMiniBoss; import mineplex.game.clans.items.runes.RuneManager.RuneAttribute; +import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.EntityType; import org.bukkit.entity.Ghast; +import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.ProjectileLaunchEvent; import org.bukkit.inventory.ItemStack; @@ -80,7 +84,20 @@ public class GhastMiniboss extends NetherMiniBoss @Override public void update() { - tryFireballVolley(); + Player target = null; + for (Player test : UtilPlayer.getInRadius(getEntity().getLocation(), 25).keySet()) + { + if (test.getGameMode() == GameMode.SURVIVAL && !ClansManager.getInstance().getIncognitoManager().Get(test).Hidden) + { + target = test; + break; + } + } + if (target != null) + { + UtilEnt.LookAt(getEntity(), target.getLocation()); + tryFireballVolley(); + } } @EventHandler @@ -88,10 +105,6 @@ public class GhastMiniboss extends NetherMiniBoss { if (event.getEntity().getShooter() != null && event.getEntity().getShooter().equals(getEntity())) { - if (!MinibossFireball.isFireball(event.getEntity())) - { - event.setCancelled(true); - } ClansManager.getInstance().runSyncLater(() -> { if (event.getEntity() == null || event.getEntity().isDead() || !event.getEntity().isValid()) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansScoreboardManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansScoreboardManager.java index de615ec5f..a1fe7a874 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansScoreboardManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansScoreboardManager.java @@ -44,7 +44,7 @@ public class ClansScoreboardManager extends ScoreboardManager private void init() { - setTitle("Clans " + Clans.VERSION); + setTitle("Clans " + Clans.getMap()); ScoreboardData data = getData("default", true); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementClan.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementClan.java index 5252cb23d..1227c8edb 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementClan.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementClan.java @@ -1,10 +1,7 @@ package mineplex.game.clans.clans.scoreboard.elements; -import java.util.ArrayList; import java.util.List; -import org.bukkit.entity.Player; - import mineplex.core.common.util.C; import mineplex.core.common.util.UtilTime; import mineplex.core.scoreboard.ScoreboardManager; @@ -12,6 +9,10 @@ import mineplex.core.scoreboard.elements.ScoreboardElement; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClansManager; +import org.bukkit.entity.Player; + +import com.google.common.collect.Lists; + public class ScoreboardElementClan implements ScoreboardElement { private ClansManager _clansManager; @@ -24,22 +25,28 @@ public class ScoreboardElementClan implements ScoreboardElement @Override public List getLines(ScoreboardManager manager, Player player, List out) { - List output = new ArrayList(); + List output = Lists.newArrayList(); ClanInfo clanInfo = _clansManager.getClan(player); if (clanInfo != null) { - output.add(C.cYellow + "Clan " + C.cWhite + clanInfo.getName()); - output.add(C.cYellow + "Online " + C.cWhite + clanInfo.getOnlinePlayers().size() + "/" + clanInfo.getMembers().size()); - + output.add(C.cYellowB + "Clan"); + output.add(_clansManager.getClanUtility().mRel(_clansManager.getRelation(player, player), clanInfo.getName(), false)); + output.add(" "); // Energy if (clanInfo.getEnergyCostPerMinute() > 0) - output.add(C.cYellow + "Energy " + C.cWhite + UtilTime.convertString((clanInfo.getEnergy() / clanInfo.getEnergyCostPerMinute()) * 60000L, 1, UtilTime.TimeUnit.FIT)); + { + output.add(C.cYellowB + "Clan Energy"); + output.add(C.cGreen + UtilTime.convertString((clanInfo.getEnergy() / clanInfo.getEnergyCostPerMinute()) * 60000L, 1, UtilTime.TimeUnit.FIT)); + output.add(" "); + } } else { - output.add(C.cYellow + "You are not in a Clan"); + output.add(C.cYellowB + "Clan"); + output.add("No Clan"); + output.add(" "); } return output; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java index 5b6cb24f4..c514a2119 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java @@ -5,6 +5,8 @@ import java.util.List; import org.bukkit.entity.Player; +import com.google.common.collect.Lists; + import mineplex.core.common.CurrencyType; import mineplex.core.common.util.C; import mineplex.core.scoreboard.ScoreboardManager; @@ -25,11 +27,14 @@ public class ScoreboardElementPlayer implements ScoreboardElement @Override public List getLines(ScoreboardManager manager, Player player, List out) { - List output = new ArrayList(); - output.add(C.cYellow + "Gold " + C.cWhite + manager.getDonation().Get(player).GetBalance(CurrencyType.GOLD) + ""); - String regionString = C.xWilderness + "Wilderness"; + List output = Lists.newArrayList(); + output.add(C.cYellowB + "Gold"); + output.add(C.cGold + manager.getDonation().Get(player).GetBalance(CurrencyType.GOLD)); - output.add(" "); + output.add(" "); + + output.add(C.cYellowB + "Territory"); + String regionString = C.xWilderness + "Wilderness"; ClanTerritory claim = _clansManager.getClanUtility().getClaim(player.getLocation()); if (claim != null) { @@ -41,17 +46,18 @@ public class ScoreboardElementPlayer implements ScoreboardElement //Trust if (relation == ClansUtility.ClanRelation.ALLY_TRUST) + { regionString += C.mBody + "(" + C.mElem + "Trusted" + C.mBody + ")"; - + } } -// if (_clansManager.getNetherManager().isInNether(player)) -// { -// regionString = C.cRed + "The Nether"; -// } + if (_clansManager.getNetherManager().isInNether(player)) + { + regionString = C.cClansNether + "The Nether"; + } output.add(regionString); - + return output; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java index 1c26486b8..4c0b4939f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java @@ -1,15 +1,5 @@ package mineplex.game.clans.clans.siege; -import org.bukkit.Location; -import org.bukkit.entity.ArmorStand; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; -import org.bukkit.entity.Slime; -import org.bukkit.event.EventHandler; -import org.bukkit.event.block.BlockPlaceEvent; - -import com.google.gson.Gson; - import mineplex.core.MiniPlugin; import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; @@ -21,6 +11,7 @@ import mineplex.core.common.util.UtilTime; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.siege.command.GiveWeaponCommand; import mineplex.game.clans.clans.siege.outpost.OutpostManager; import mineplex.game.clans.clans.siege.repository.SiegeWeaponRepository; import mineplex.game.clans.clans.siege.repository.tokens.SiegeWeaponToken; @@ -30,6 +21,16 @@ import mineplex.game.clans.core.repository.ClanTerritory; import mineplex.game.clans.spawn.Spawn; import net.minecraft.server.v1_8_R3.Material; +import org.bukkit.Location; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Slime; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.BlockPlaceEvent; + +import com.google.gson.Gson; + public class SiegeManager extends MiniPlugin { private ClansManager _clansManager; @@ -79,6 +80,8 @@ public class SiegeManager extends MiniPlugin }) ) ); + + addCommand(new GiveWeaponCommand(this)); } @EventHandler @@ -222,12 +225,12 @@ public class SiegeManager extends MiniPlugin public boolean trySpawnCannon(Player player, Location location) { -// if (_clansManager.getNetherManager().isInNether(player)) -// { -// _clansManager.message(player, "You are not allowed to place this in " + F.clansNether("The Nether") + "."); -// -// return false; -// } + if (_clansManager.getNetherManager().isInNether(player)) + { + _clansManager.message(player, "You are not allowed to place this in " + F.clansNether("The Nether") + "."); + + return false; + } if (!_clansManager.isInClan(player)) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/command/GiveWeaponCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/command/GiveWeaponCommand.java new file mode 100644 index 000000000..2a2589632 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/command/GiveWeaponCommand.java @@ -0,0 +1,26 @@ +package mineplex.game.clans.clans.siege.command; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilPlayer; +import mineplex.game.clans.clans.siege.SiegeManager; +import mineplex.game.clans.clans.siege.weapon.Cannon; + +public class GiveWeaponCommand extends CommandBase +{ + public GiveWeaponCommand(SiegeManager plugin) + { + super(plugin, Rank.ADMIN, "giveweapon", "siegeweapon", "givecannon"); + } + + @Override + public void Execute(Player caller, String[] args) + { + UtilInv.insert(caller, Cannon.CANNON_ITEM.clone()); + UtilPlayer.message(caller, F.main(Plugin.getName(), "You have been given a cannon!")); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/Crater.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/Crater.java index 7f270cd9a..883211b4f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/Crater.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/Crater.java @@ -1,95 +1,24 @@ package mineplex.game.clans.clans.siege.weapon.projectile; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map.Entry; - -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.block.Chest; -import org.bukkit.event.EventHandler; -import org.bukkit.event.HandlerList; -import org.bukkit.event.Listener; -import org.bukkit.inventory.ItemStack; -import org.bukkit.util.Vector; - -import mineplex.core.common.util.UtilBlock; -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.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.siege.weapon.SiegeWeapon; import mineplex.game.clans.core.repository.ClanTerritory; -import net.minecraft.server.v1_8_R3.Explosion; -public class Crater implements Listener +import org.bukkit.Location; + +public class Crater { - public static final Material CHARRED_TYPE = Material.OBSIDIAN; - private final SiegeWeapon _weapon; private final Location _origin; - private final long _birthTime; - - private final List _blocks; - public Crater(SiegeWeapon weapon, WeaponProjectile projectile, Location origin) { _weapon = weapon; _origin = origin; - - _birthTime = System.currentTimeMillis(); - _blocks = new ArrayList<>(); - - UtilServer.getPluginManager().registerEvents(this, _weapon.getClans().getPlugin()); - createExplosion(); } - @EventHandler - public void updateEffects(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - { - return; - } - - _blocks.stream().filter(block -> block.Type == CHARRED_TYPE).forEach(block -> { - long lifetime = System.currentTimeMillis() - _birthTime; - - long max = 80000; - - if (block.Location.getBlock().getType() != CHARRED_TYPE) - { - return; - } - - // Water touching the charred blocks - if (UtilBlock.getInRadius(block.Location, 1.6).keySet().stream().filter(water -> water.getType() == Material.WATER).iterator().hasNext()) - { - return; - } - - if (lifetime < max) - { - UtilParticle.PlayParticleToAll(ParticleType.FLAME, block.Location.clone().add(.5, 1, .5), new Vector(0, 0, 0), .0f, 3, ViewDist.MAX); - UtilParticle.PlayParticleToAll(lifetime >= max / 1.4 ? ParticleType.SMOKE : ParticleType.LARGE_SMOKE, block.Location.clone().add(.5, .8, .5), new Vector(0, 0, 0), .0f, 1, ViewDist.MAX); - } - else - { - HandlerList.unregisterAll(this); - } - }); - } - private void createExplosion() { ClanTerritory terr = _weapon.getClans().getClanUtility().getClaim(_origin); @@ -98,58 +27,12 @@ public class Crater implements Listener { return; } - - boolean explosion = _origin.getWorld().createExplosion(_origin, 2.6f); - - boolean floating = _origin.distance(UtilBlock.nearestFloor(_origin)) > 0.6; - - if (explosion) + ClanInfo clan = ClansManager.getInstance().getClanUtility().getOwner(terr); + if (clan != null && !ClansManager.getInstance().getWarManager().isBeingBesiegedBy(clan, _weapon.getOwner())) { - for (Block block : UtilBlock.getInRadius(_origin.getBlock(), 2.6f).keySet()) - { - boolean charred = false; - double dist = block.getLocation().distance(_origin); - - if (floating) - { - if (!block.getRelative(BlockFace.DOWN).getType().equals(CHARRED_TYPE) - && !block.getRelative(BlockFace.DOWN).getType().equals(Material.AIR) - && Math.random() > 0.79) - { - charred = true; - } - } - else - { - if (block.getRelative(BlockFace.UP).getType().equals(Material.AIR) - && !block.getRelative(BlockFace.DOWN).getType().equals(CHARRED_TYPE) - && !block.getRelative(BlockFace.DOWN).getType().equals(Material.AIR) - && Math.random() > 0.79) - { - charred = true; - } - } - - if (block.getType().equals(Material.SMOOTH_BRICK)) - { - charred = false; - } - - if (block.getType().equals(Material.BEDROCK)) - { - charred = false; - } - - if (charred) - { - CraterBlock charredBlock = new CraterBlock(block.getLocation(), dist, CHARRED_TYPE, (byte) 0); - - charredBlock.set(); - - _blocks.add(charredBlock); - } - } + return; } + + _origin.getWorld().createExplosion(_origin, 2.6f); } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java index 39a1e2680..1892dae30 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java @@ -7,12 +7,6 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.plugin.java.JavaPlugin; - import mineplex.core.MiniPlugin; import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; @@ -31,10 +25,18 @@ import mineplex.game.clans.clans.ClansUtility; import mineplex.game.clans.clans.event.ClanDisbandedEvent; import mineplex.game.clans.clans.event.ClansPlayerDeathEvent; import mineplex.game.clans.clans.war.command.WarPointsCommand; -import mineplex.game.clans.clans.war.event.WarInvasionEndEvent; -import mineplex.game.clans.clans.war.event.WarInvasionStartEvent; +import mineplex.game.clans.clans.war.event.WarSiegeEndEvent; +import mineplex.game.clans.clans.war.event.WarSiegeStartEvent; import mineplex.game.clans.core.war.ClanWarData; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.BlockDispenseEvent; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.plugin.java.JavaPlugin; + public class WarManager extends MiniPlugin implements ScoreboardElement { public static final int WAR_START_POINTS = 0; @@ -45,18 +47,17 @@ public class WarManager extends MiniPlugin implements ScoreboardElement private final ClansManager _clansManager; /** - * Map of the active war invasions. This is indexed by the clan that is being invaded on - * We will need to access this when blocks are broken in the invaded on clan's land! + * Map of the active war sieges. This is indexed by the clan that is being besieged */ - private Map> _invadedMap; - private Map> _invaderMap; + private Map> _besiegedMap; + private Map> _besiegerMap; public WarManager(JavaPlugin plugin, ClansManager clansManager) { super("ClanWar Manager", plugin); _clansManager = clansManager; - _invadedMap = new HashMap>(); - _invaderMap = new HashMap>(); + _besiegedMap = new HashMap<>(); + _besiegerMap = new HashMap<>(); } public ClansManager getClansManager() @@ -64,41 +65,38 @@ public class WarManager extends MiniPlugin implements ScoreboardElement return _clansManager; } - public List getInvasionsOn(ClanInfo invaded) + public List getSiegesOn(ClanInfo besieged) { - return _invadedMap.get(invaded.getName()); + return _besiegedMap.get(besieged.getName()); } - public List getInvasionsFor(ClanInfo invader) + public List getSiegesFor(ClanInfo besieger) { - return _invaderMap.get(invader.getName()); + return _besiegerMap.get(besieger.getName()); } - public boolean isBeingInvaded(ClanInfo clanInfo) + public boolean isBeingBesieged(ClanInfo clanInfo) { - List invasions = _invadedMap.get(clanInfo.getName()); - return invasions != null && !invasions.isEmpty(); + List sieges = _besiegedMap.get(clanInfo.getName()); + return sieges != null && !sieges.isEmpty(); } - public boolean isInvading(ClanInfo clanInfo) + public boolean isBesieging(ClanInfo clanInfo) { - List invasions = _invaderMap.get(clanInfo.getName()); - return invasions != null && !invasions.isEmpty(); + List sieges = _besiegerMap.get(clanInfo.getName()); + return sieges != null && !sieges.isEmpty(); } - - public boolean allowFromInvade(Location location, Player player) + + public boolean isBeingBesiegedBy(ClanInfo besieged, ClanInfo besieger) { - ClanInfo clanInfo = _clansManager.getClanUtility().getOwner(location); - ClanInfo playerClan = _clansManager.getClan(player); - if (clanInfo != null) + List sieges = _besiegedMap.get(besieged.getName()); + if (sieges != null && !sieges.isEmpty()) { - List invasions = _invadedMap.get(clanInfo.getName()); - if (invasions != null) + for (WarSiege siege : sieges) { - for (WarInvasion invasion : invasions) + if (siege.getBesiegingClan().equals(besieger.getName())) { - if (invasion.getInvaderClan().equals(playerClan.getName())) - return true; + return true; } } } @@ -106,14 +104,6 @@ public class WarManager extends MiniPlugin implements ScoreboardElement return false; } - /** - * Clear all invasions against clan. This is typically used for when a clan is deleted - */ -// public void clearInvasions(String clan) -// { -// List invasions = -// } - @EventHandler public void handleDeath(final ClansPlayerDeathEvent event) { @@ -184,106 +174,107 @@ public class WarManager extends MiniPlugin implements ScoreboardElement private void checkWarComplete(ClanWarData war) { - String invaderClan = null; - String invadedClan = null; + String besiegerClan = null; + String besiegedClan = null; if (war.getClanAPoints() >= WAR_FINISH_POINTS) { - // Clan A invades Clan B - invaderClan = war.getClanA(); - invadedClan = war.getClanB(); + besiegerClan = war.getClanA(); + besiegedClan = war.getClanB(); } else if (war.getClanBPoints() >= WAR_FINISH_POINTS) { - // Clan B invades Clan A - invaderClan = war.getClanB(); - invadedClan = war.getClanA(); + besiegerClan = war.getClanB(); + besiegedClan = war.getClanA(); } - if (invadedClan != null && invaderClan != null) + if (besiegedClan != null && besiegerClan != null) { // Reset War to 0:0 war.resetPoints(); war.setCooldown(WAR_COOLDOWN); - WarInvasion invasion = new WarInvasion(invadedClan, invaderClan); - startInvasion(invasion); + WarSiege siege = new WarSiege(besiegedClan, besiegerClan); + startSiege(siege); } } - private void startInvasion(WarInvasion invasion) + private void startSiege(WarSiege siege) { - String invaded = invasion.getInvadedClan(); - String invader = invasion.getInvaderClan(); + String besieged = siege.getBesiegedClan(); + String besieger = siege.getBesiegingClan(); - addInvasion(invaded, invasion, _invadedMap); - addInvasion(invader, invasion, _invaderMap); + addSiege(besieged, siege, _besiegedMap); + addSiege(besieger, siege, _besiegerMap); - WarInvasionStartEvent event = new WarInvasionStartEvent(invasion); + WarSiegeStartEvent event = new WarSiegeStartEvent(siege); UtilServer.getServer().getPluginManager().callEvent(event); } - private void addInvasion(String name, WarInvasion invasion, Map> invasionMap) + private void addSiege(String name, WarSiege siege, Map> siegeMap) { - if (invasionMap.containsKey(name)) + if (siegeMap.containsKey(name)) { - invasionMap.get(name).add(invasion); + siegeMap.get(name).add(siege); } else { - LinkedList invasions = new LinkedList(); - invasions.add(invasion); - invasionMap.put(name, invasions); + LinkedList sieges = new LinkedList<>(); + sieges.add(siege); + siegeMap.put(name, sieges); } } @EventHandler - public void clearInvasions(UpdateEvent event) + public void clearSieges(UpdateEvent event) { if (event.getType() != UpdateType.SEC) return; long currentTime = System.currentTimeMillis(); - Iterator>> iterator = _invadedMap.entrySet().iterator(); + Iterator>> iterator = _besiegedMap.entrySet().iterator(); while (iterator.hasNext()) { - List invasions = iterator.next().getValue(); - Iterator invasionIterator = invasions.iterator(); - while (invasionIterator.hasNext()) + List sieges = iterator.next().getValue(); + Iterator siegeIterator = sieges.iterator(); + while (siegeIterator.hasNext()) { - WarInvasion invasion = invasionIterator.next(); - if (currentTime >= invasion.getEndTime()) + WarSiege siege = siegeIterator.next(); + if (currentTime >= siege.getEndTime()) { - WarInvasionEndEvent endEvent = new WarInvasionEndEvent(invasion); + WarSiegeEndEvent endEvent = new WarSiegeEndEvent(siege); Bukkit.getServer().getPluginManager().callEvent(endEvent); - List invaderList = _invaderMap.get(invasion.getInvaderClan()); - if (invaderList != null) + List besiegerList = _besiegerMap.get(siege.getBesiegingClan()); + if (besiegerList != null) { - invaderList.remove(invasion); - if (invaderList.isEmpty()) _invaderMap.remove(invasion.getInvaderClan()); + besiegerList.remove(siege); + if (besiegerList.isEmpty()) + { + _besiegerMap.remove(siege.getBesiegingClan()); + } } - invasionIterator.remove(); + siegeIterator.remove(); } } - if (invasions.isEmpty()) + if (sieges.isEmpty()) iterator.remove(); } } @EventHandler - public void onInvasionStart(WarInvasionStartEvent event) + public void onSiegeStart(WarSiegeStartEvent event) { - Bukkit.broadcastMessage(F.main("War", F.elem(event.getWarInvasion().getInvaderClan()) + " can now invade " + F.elem(event.getWarInvasion().getInvadedClan()))); + Bukkit.broadcastMessage(F.main("War", F.elem(event.getWarSiege().getBesiegingClan()) + " can now besiege " + F.elem(event.getWarSiege().getBesiegedClan()))); } @EventHandler - public void onInvasionEnd(WarInvasionEndEvent event) + public void onSiegeEnd(WarSiegeEndEvent event) { - Bukkit.broadcastMessage(F.main("War", F.elem(event.getWarInvasion().getInvaderClan()) + "'s invasion against " + F.elem(event.getWarInvasion().getInvadedClan()) + " has ended.")); + Bukkit.broadcastMessage(F.main("War", F.elem(event.getWarSiege().getBesiegingClan()) + "'s siege against " + F.elem(event.getWarSiege().getBesiegedClan()) + " has ended.")); } @@ -297,9 +288,29 @@ public class WarManager extends MiniPlugin implements ScoreboardElement public void cancelDisband(ClanDisbandedEvent event) { ClanInfo clan = event.getClan(); - if (isBeingInvaded(clan) || isInvading(clan)) + if (isBeingBesieged(clan) || isBesieging(clan)) + { + UtilPlayer.message(event.getDisbander(), F.main("Clans", "Clans cannot be disbanded in the middle of a siege")); + event.setCancelled(true); + } + } + + @EventHandler + public void onPlaceTNT(BlockPlaceEvent event) + { + if (event.getBlockPlaced().getType() == Material.TNT) + { + event.setCancelled(true); + event.setBuild(false); + UtilPlayer.message(event.getPlayer(), F.main("Clans", "TNT cannot be used outside of a siege cannon!")); + } + } + + @EventHandler + public void onTNTDispense(BlockDispenseEvent event) + { + if (event.getItem().getType() == Material.TNT) { - UtilPlayer.message(event.getDisbander(), F.main("Clans", "Clans cannot be disbanded in the middle of an invasion")); event.setCancelled(true); } } @@ -313,32 +324,32 @@ public class WarManager extends MiniPlugin implements ScoreboardElement if (clan != null) { - List invadedList = _invadedMap.get(clan.getName()); - List invaderList = _invaderMap.get(clan.getName()); + List besiegedList = _besiegedMap.get(clan.getName()); + List besiegerList = _besiegerMap.get(clan.getName()); - if (invaderList != null && !invaderList.isEmpty()) + if (besiegerList != null && !besiegerList.isEmpty()) { - for (WarInvasion invasion : invaderList) + for (WarSiege siege : besiegerList) { element.add(" "); - element.add(C.cPurpleB + "Invading"); - element.add(" " + invasion.getInvadedClan()); - element.add(" " + UtilTime.convertString(invasion.getTimeLeft(), 1, UtilTime.TimeUnit.FIT)); + element.add(C.cPurpleB + "Besieging"); + element.add(" " + siege.getBesiegedClan()); + element.add(" " + UtilTime.convertString(siege.getTimeLeft(), 1, UtilTime.TimeUnit.FIT)); } } - if (invadedList != null && !invadedList.isEmpty()) + if (besiegedList != null && !besiegedList.isEmpty()) { - for (WarInvasion invasion : invadedList) + for (WarSiege siege : besiegedList) { element.add(" "); - element.add(C.cRedB + "Invaded"); - element.add(" " + invasion.getInvaderClan()); - element.add(" " + UtilTime.convertString(invasion.getTimeLeft(), 1, UtilTime.TimeUnit.FIT)); + element.add(C.cRedB + "Besieged"); + element.add(" " + siege.getBesiegingClan()); + element.add(" " + UtilTime.convertString(siege.getTimeLeft(), 1, UtilTime.TimeUnit.FIT)); } } } return element; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarInvasion.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarSiege.java similarity index 54% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarInvasion.java rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarSiege.java index 1358aa376..12f124c72 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarInvasion.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarSiege.java @@ -1,16 +1,16 @@ package mineplex.game.clans.clans.war; -public class WarInvasion +public class WarSiege { - private String _invadedClan; - private String _invaderClan; + private String _besiegedClan; + private String _besiegingClan; private long _startTime; private long _endTime; - public WarInvasion(String invadedClan, String invaderClan) + public WarSiege(String besiegedClan, String besiegingClan) { - _invadedClan = invadedClan; - _invaderClan = invaderClan; + _besiegedClan = besiegedClan; + _besiegingClan = besiegingClan; _startTime = System.currentTimeMillis(); _endTime = _startTime + WarManager.INVADE_LENGTH; } @@ -20,14 +20,14 @@ public class WarInvasion return _endTime - System.currentTimeMillis(); } - public String getInvadedClan() + public String getBesiegedClan() { - return _invadedClan; + return _besiegedClan; } - public String getInvaderClan() + public String getBesiegingClan() { - return _invaderClan; + return _besiegingClan; } public long getStartTime() @@ -39,4 +39,4 @@ public class WarInvasion { return _endTime; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/event/WarInvasionEndEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/event/WarSiegeEndEvent.java similarity index 52% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/event/WarInvasionEndEvent.java rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/event/WarSiegeEndEvent.java index 048ed8dd1..dcd300afb 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/event/WarInvasionEndEvent.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/event/WarSiegeEndEvent.java @@ -1,29 +1,29 @@ package mineplex.game.clans.clans.war.event; +import mineplex.game.clans.clans.war.WarSiege; + import org.bukkit.event.Event; import org.bukkit.event.HandlerList; -import mineplex.game.clans.clans.war.WarInvasion; - /** - * Called when a war invasion is ended + * Called when a war siege is ended */ -public class WarInvasionEndEvent extends Event +public class WarSiegeEndEvent extends Event { - private WarInvasion _warInvasion; + private WarSiege _warSiege; - public WarInvasionEndEvent(WarInvasion warInvasion) + public WarSiegeEndEvent(WarSiege warSiege) { - _warInvasion = warInvasion; + _warSiege = warSiege; } - public WarInvasion getWarInvasion() + public WarSiege getWarSiege() { - return _warInvasion; + return _warSiege; } // Bukkit event stuff private static final HandlerList handlers = new HandlerList(); public static HandlerList getHandlerList() { return handlers; } public HandlerList getHandlers() { return handlers; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/event/WarInvasionStartEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/event/WarSiegeStartEvent.java similarity index 51% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/event/WarInvasionStartEvent.java rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/event/WarSiegeStartEvent.java index 9f3d10f0b..30e7d2d79 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/event/WarInvasionStartEvent.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/event/WarSiegeStartEvent.java @@ -1,29 +1,29 @@ package mineplex.game.clans.clans.war.event; +import mineplex.game.clans.clans.war.WarSiege; + import org.bukkit.event.Event; import org.bukkit.event.HandlerList; -import mineplex.game.clans.clans.war.WarInvasion; - /** - * Called when a war invasion is started + * Called when a war siege is started */ -public class WarInvasionStartEvent extends Event +public class WarSiegeStartEvent extends Event { - private WarInvasion _warInvasion; + private WarSiege _warSiege; - public WarInvasionStartEvent(WarInvasion warInvasion) + public WarSiegeStartEvent(WarSiege warSiege) { - _warInvasion = warInvasion; + _warSiege = warSiege; } - public WarInvasion getWarInvasion() + public WarSiege getWarSiege() { - return _warInvasion; + return _warSiege; } // Bukkit event stuff private static final HandlerList handlers = new HandlerList(); public static HandlerList getHandlerList() { return handlers; } public HandlerList getHandlers() { return handlers; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/EventTerrainFinder.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/EventTerrainFinder.java index 4cc189f34..6e4f8dcb2 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/EventTerrainFinder.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/EventTerrainFinder.java @@ -1,74 +1,74 @@ package mineplex.game.clans.clans.worldevent; +import java.util.Arrays; +import java.util.Comparator; +import java.util.List; +import java.util.Random; import java.util.Set; -import org.bukkit.Chunk; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.common.util.UtilWorld; +import mineplex.game.clans.clans.ClansManager; + import org.bukkit.Location; -import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; -import mineplex.core.common.util.EnclosedObject; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilWorld; -import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.clans.regions.ClansRegions; +import com.google.common.collect.Lists; public class EventTerrainFinder { - private WorldEventManager _eventManager; + private static final long EVENT_AREA_COOLDOWN = UtilTime.convert(3, TimeUnit.HOURS, TimeUnit.MILLISECONDS); private ClansManager _clansManager; - private ClansRegions _clansRegions; - public EventTerrainFinder(WorldEventManager eventManager, ClansManager clansManager, ClansRegions clansRegions) + public EventTerrainFinder(ClansManager clansManager) { - _eventManager = eventManager; _clansManager = clansManager; - _clansRegions = clansRegions; } - public double posNeg() + public Location findAreaInBorderlands(boolean force) { - if (Math.random() > 0.5) return -1; - return 1; - } - - public Location findAreaInBorderlands(World world, int size, int vert) - { - for (int i = 0; i < 150; i++) + List locs = Lists.newArrayList(); + locs.addAll(Arrays.asList(EventLocation.values())); + locs.sort(new Comparator() { - EnclosedObject loc = new EnclosedObject<>(); - - if (_clansManager.getClanUtility().getClanByClanName("Borderlands") == null) + public int compare(EventLocation loc1, EventLocation loc2) { - System.out.println("[WORLD EVENT] FATAL ERROR: CLAN BORDERLANDS NOT FOUND."); - break; + if (!UtilTime.elapsed(loc1.getLastUsed(), EVENT_AREA_COOLDOWN)) + { + return 1; + } + if (!UtilTime.elapsed(loc2.getLastUsed(), EVENT_AREA_COOLDOWN)) + { + return -1; + } + int[] rand = new int[] {1, -1}; + return rand[new Random().nextInt(rand.length)]; } - - _clansManager.getClanUtility().getClanByClanName("Borderlands").getClaimSet().stream().filter(claim -> Math.random() > .5).filter(claim -> Math.random() > .5).filter(claim -> Math.random() > .3).filter(claim -> Math.random() > .7).limit(1).forEach(claim -> { - Chunk chunk = UtilWorld.strToChunk(claim); - - loc.Set(UtilBlock.getHighest(chunk.getWorld(), chunk.getBlock(0, 0, 0)).getLocation()); - }); - - if (!UtilWorld.isBoxInWorldBorder(world, loc.Get().clone().subtract(size * 2, vert, size * 2), loc.Get().clone().add(size * 2, vert, size * 2))) + }); + + for (EventLocation loc : locs) + { + if (!UtilTime.elapsed(loc.getLastUsed(), EVENT_AREA_COOLDOWN)) { continue; } - - if (loc.Get() == null) + if (_clansManager.getClanUtility().getClaim(loc.getLocation()) == null || _clansManager.getClanUtility().getClaim(loc.getLocation()).Owner.contains("Borderlands")) { - continue; + loc.use(); + return loc.getLocation(); } - - System.out.println("Done finding area... [success]"); - - // Success - return loc.Get(); } - System.out.println("Failed to find area..."); + if (force && !locs.isEmpty()) + { + EventLocation loc = locs.get(UtilMath.r(locs.size())); + loc.use(); + return loc.getLocation(); + } return null; } @@ -129,4 +129,47 @@ public class EventTerrainFinder return null; } -} + + private static enum EventLocation + { + NORTH_1("world", -495, 73, -1028), + NORTH_2("world", 197, 66, -1018), + NORTH_3("world", 948, 71, -959), + EAST_1("world", 1109, 66, -753), + EAST_2("world", 1141, 68, 31), + EAST_3("world", 1044, 71, 603), + SOUTH_1("world", 690, 71, 895), + SOUTH_2("world", 144, 66, 1012), + SOUTH_3("world", -1093, 71, 895), + WEST_1("world", -937, 71, 559), + WEST_2("world", -1092, 67, -9), + WEST_3("world", -969, 71, -441); + + private String _world; + private double _x, _y, _z; + private long _last = 0; + + private EventLocation(String worldName, double x, double y, double z) + { + _world = worldName; + _x = x; + _y = y; + _z = z; + } + + public Location getLocation() + { + return new Location(UtilWorld.getWorld(_world), _x, _y, _z); + } + + public Long getLastUsed() + { + return _last; + } + + public void use() + { + _last = System.currentTimeMillis(); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java index 63408e797..c8b82fea9 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java @@ -1,6 +1,5 @@ package mineplex.game.clans.clans.worldevent; -import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedList; import java.util.List; @@ -9,6 +8,7 @@ import java.util.Random; import mineplex.core.MiniPlugin; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilServer; import mineplex.core.scoreboard.ScoreboardManager; import mineplex.core.scoreboard.elements.ScoreboardElement; @@ -35,8 +35,11 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.HandlerList; import org.bukkit.plugin.java.JavaPlugin; +import com.google.common.collect.Lists; + public class WorldEventManager extends MiniPlugin implements ScoreboardElement { + private static final double ARENA_RADIUS = 40; private final List _runningEvents; private Random _random; @@ -55,7 +58,7 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement super("World Event", plugin); _random = new Random(); - _terrainFinder = new EventTerrainFinder(this, clansManager, clansRegions); + _terrainFinder = new EventTerrainFinder(clansManager); _clansManager = clansManager; _damageManager = damageManager; _lootManager = lootManager; @@ -86,7 +89,7 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement { for (WorldEvent event : _runningEvents) { - if (event.isInBounds(location)) + if (UtilMath.offset2d(location, event.getCenterLocation()) <= ARENA_RADIUS) { return true; } @@ -102,7 +105,7 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement { for (WorldEvent e : _runningEvents) { - if (e.isInBounds(event.GetPlayer().getLocation())) + if (isInEvent(event.GetPlayer().getLocation())) { event.SetCancelled(true); } @@ -189,7 +192,7 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement { WorldEventType[] types = WorldEventType.values(); WorldEventType type = types[_random.nextInt(types.length)]; - Location location = _terrainFinder.findAreaInBorderlands(Bukkit.getWorlds().get(0), type.getAreaNeeded(), type.getAreaNeeded()); + Location location = _terrainFinder.findAreaInBorderlands(false); if (location != null) { initializeEvent(type.createInstance(this, location, _skillFactory)); @@ -228,10 +231,11 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement return null; } - public WorldEvent startEventFromType(Location location, WorldEventType eventType) + public WorldEvent startEventFromType(WorldEventType eventType) { if (eventType != null) { + Location location = _terrainFinder.findAreaInBorderlands(true); WorldEvent event = eventType.createInstance(this, location, _skillFactory); if (event != null) { @@ -287,7 +291,7 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement @Override public List getLines(ScoreboardManager manager, Player player, List out) { - List output = new ArrayList(); + List output = Lists.newArrayList(); Iterator iterator = _runningEvents.iterator(); while (iterator.hasNext()) @@ -296,7 +300,7 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement if (event.getState() == EventState.LIVE) { - output.add(" "); + output.add(" "); output.add(C.cAqua + C.Bold + "Event"); Location eventLocation = event.getCenterLocation(); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/StartCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/StartCommand.java index d5090804b..e95f7fa48 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/StartCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/StartCommand.java @@ -27,7 +27,7 @@ public class StartCommand extends CommandBase try { WorldEventType eventType = WorldEventType.valueOf(args[0]); - WorldEvent event = Plugin.startEventFromType(caller.getLocation(), eventType); + WorldEvent event = Plugin.startEventFromType(eventType); if (event == null) { @@ -35,7 +35,7 @@ public class StartCommand extends CommandBase } else { - UtilPlayer.message(caller, F.main(Plugin.getName(), "Started WorldEvent " + F.elem(args[0]) + " at your current location")); + UtilPlayer.message(caller, F.main(Plugin.getName(), "Started WorldEvent " + F.elem(args[0]) + "!")); } } catch (IllegalArgumentException e) diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/ItemUsable.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/ItemUsable.java index 4ebc47b56..00d5ef316 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/ItemUsable.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/ItemUsable.java @@ -6,7 +6,8 @@ import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilInv; -import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.common.util.UtilMath; +import mineplex.core.itemstack.ItemBuilder; import mineplex.core.projectile.IThrown; import mineplex.core.projectile.ProjectileUser; import mineplex.core.recharge.Recharge; @@ -155,7 +156,7 @@ public abstract class ItemUsable extends Item implements IThrown if (_throwExpire >= 0) expire = _throwExpire; - org.bukkit.entity.Item ent = player.getWorld().dropItem(player.getEyeLocation(), ItemStackFactory.Instance.CreateStack(GetType())); + org.bukkit.entity.Item ent = player.getWorld().dropItem(player.getEyeLocation(), new ItemBuilder(GetType()).setTitle(UtilMath.random.nextDouble() + "").build()); UtilAction.velocity(ent, player.getLocation().getDirection(), _throwPower, false, 0, 0.2, 10, false); Factory.Throw().AddThrow(ent, player, this, expire, _throwPlayer, _throwPlayer, _throwBlock, _throwIdle, _throwPickup, 0.5f); diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemBoss.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemBoss.java index 81d3db9a0..1e6c7ffc7 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemBoss.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemBoss.java @@ -17,7 +17,7 @@ public class GolemBoss extends WorldEvent { public GolemBoss(DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, ProjectileManager projectileManager, Location cornerLocation) { - super(DisguiseManager.INSTANCE, projectileManager, damageManager, blockRestore, conditionManager, "Iron Wizard", cornerLocation, "schematic/Golem.schematic"); + super(DisguiseManager.INSTANCE, projectileManager, damageManager, blockRestore, conditionManager, "Iron Wizard", cornerLocation); } @Override diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemDeadlyTremor.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemDeadlyTremor.java index 94fb81098..36c72f340 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemDeadlyTremor.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemDeadlyTremor.java @@ -56,7 +56,7 @@ public class GolemDeadlyTremor extends BossAbility @Override public void tick() { - for (Player player : UtilPlayer.getInRadius(getLocation(), 40).keySet()) + for (Player player : UtilPlayer.getInRadius(getLocation(), 30).keySet()) { player.playSound(player.getLocation(), Sound.MINECART_BASE, 0.2f, 0.2f); diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/SkeletonBoss.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/SkeletonBoss.java index dd785dfb8..f6a1a6af7 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/SkeletonBoss.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/SkeletonBoss.java @@ -20,8 +20,7 @@ public class SkeletonBoss extends WorldEvent public SkeletonBoss(DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, ProjectileManager projectileManager, Location cornerLocation) { - super(DisguiseManager.INSTANCE, projectileManager, damageManager, blockRestore, conditionManager, "Skeleton King", cornerLocation, - "schematic/Golem.schematic"); + super(DisguiseManager.INSTANCE, projectileManager, damageManager, blockRestore, conditionManager, "Skeleton King", cornerLocation); } @Override diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/SkeletonCreature.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/SkeletonCreature.java index 8b0e4865c..885e1814a 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/SkeletonCreature.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/SkeletonCreature.java @@ -210,7 +210,6 @@ public class SkeletonCreature extends EventCreature { if (getHealth() <= test) { - Bukkit.broadcastMessage(test + "Verified"); wraithUse = test; break; } From 9a73784b7c468a0200cb446a6bbe028613286a69 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 25 Jul 2016 11:18:10 -0400 Subject: [PATCH 45/90] Make clans in the hub route through clans hubs --- .../mineplex/hub/server/ServerManager.java | 106 ++++++----------- .../hub/server/ui/clans/ClansServerPage.java | 108 ++---------------- .../hub/server/ui/clans/ClansServerShop.java | 10 +- 3 files changed, 51 insertions(+), 173 deletions(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java index 32ba26c92..dfd80ec8d 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java @@ -1,7 +1,5 @@ package mineplex.hub.server; -import java.sql.ResultSet; -import java.sql.SQLException; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -11,10 +9,44 @@ import java.util.List; import java.util.Random; import java.util.Set; +import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClientManager; import mineplex.core.boosters.BoosterManager; import mineplex.core.brawl.fountain.BrawlShopProvider; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.F; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.donation.DonationManager; +import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.party.Lang; +import mineplex.core.party.Party; +import mineplex.core.party.PartyManager; import mineplex.core.party.event.PartySelectServerEvent; +import mineplex.core.portal.Portal; +import mineplex.core.recharge.Recharge; +import mineplex.core.shop.ShopBase; +import mineplex.core.status.ServerStatusManager; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.hub.HubManager; +import mineplex.hub.modules.StackerManager; +import mineplex.hub.queue.QueueManager; +import mineplex.hub.server.ui.LobbyShop; +import mineplex.hub.server.ui.QuickShop; +import mineplex.hub.server.ui.ServerCountSorter; +import mineplex.hub.server.ui.ServerNpcShop; +import mineplex.hub.server.ui.clans.ClansServerShop; +import mineplex.serverdata.Region; +import mineplex.serverdata.data.MinecraftServer; +import mineplex.serverdata.data.ServerGroup; + import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -32,42 +64,7 @@ import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.util.Vector; -import mineplex.core.MiniDbClientPlugin; -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; -import mineplex.core.common.util.C; -import mineplex.core.common.util.Callback; -import mineplex.core.common.util.F; -import mineplex.core.common.util.NautHashMap; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilTime.TimeUnit; -import mineplex.core.donation.DonationManager; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.party.Party; -import mineplex.core.party.PartyManager; -import mineplex.core.portal.Portal; -import mineplex.core.recharge.Recharge; -import mineplex.core.shop.ShopBase; -import mineplex.core.status.ServerStatusManager; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.game.clans.core.repository.tokens.SimpleClanToken; -import mineplex.hub.HubManager; -import mineplex.hub.modules.StackerManager; -import mineplex.hub.queue.QueueManager; -import mineplex.hub.server.ui.LobbyShop; -import mineplex.hub.server.ui.QuickShop; -import mineplex.hub.server.ui.ServerCountSorter; -import mineplex.hub.server.ui.ServerNpcShop; -import mineplex.hub.server.ui.clans.ClansServerShop; -import mineplex.serverdata.Region; -import mineplex.serverdata.data.MinecraftServer; -import mineplex.serverdata.data.ServerGroup; - -public class ServerManager extends MiniDbClientPlugin implements BrawlShopProvider +public class ServerManager extends MiniPlugin implements BrawlShopProvider { private static final Long FREE_PORTAL_TIMER = -1L; private static final Long BETA_PORTAL_TIMER = 120000L; @@ -107,7 +104,7 @@ public class ServerManager extends MiniDbClientPlugin implement public ServerManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, Portal portal, PartyManager partyManager, ServerStatusManager statusManager, HubManager hubManager, StackerManager stackerManager, QueueManager queueManager, BoosterManager boosterManager) { - super("Server Manager", plugin, clientManager); + super("Server Manager", plugin); _clientManager = clientManager; _donationManager = donationManager; @@ -919,38 +916,9 @@ public class ServerManager extends MiniDbClientPlugin implement { return _serverNpcShopMap.get("Bawk Bawk Battles"); } - - @Override - public String getQuery(int accountId, String uuid, String name) - { - return "SELECT clans.name, accountClan.clanRole, clanServer.serverName, clans.id FROM accountClan INNER JOIN clans ON clans.id = accountClan.clanId INNER JOIN clanServer ON clans.serverId = clanServer.id WHERE accountClan.accountId = " + accountId + ";"; - } - - @Override - public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException - { - SimpleClanToken clanToken = new SimpleClanToken(); - - while (resultSet.next()) - { - String clanName = resultSet.getString(1); - String clanRole = resultSet.getString(2); - String homeServer = resultSet.getString(3); - int clanId = resultSet.getInt(4); - clanToken = new SimpleClanToken(clanName, clanRole, homeServer, clanId); - } - - Set(playerName, clanToken); - } - - @Override - protected SimpleClanToken addPlayer(String player) - { - return new SimpleClanToken(); - } public BoosterManager getBoosterManager() { return _boosterManager; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/clans/ClansServerPage.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/clans/ClansServerPage.java index fe5ceaeea..564af32e8 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/clans/ClansServerPage.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/clans/ClansServerPage.java @@ -2,35 +2,26 @@ package mineplex.hub.server.ui.clans; import java.util.Collection; import java.util.Comparator; -import java.util.TreeSet; - -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; import mineplex.core.account.CoreClientManager; import mineplex.core.common.util.C; -import mineplex.core.common.util.Callback; import mineplex.core.common.util.UtilAlg; import mineplex.core.donation.DonationManager; -import mineplex.core.shop.item.DisplayButton; -import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.ShopItem; import mineplex.core.shop.page.ShopPageBase; -import mineplex.game.clans.core.repository.ClanRepository; -import mineplex.game.clans.core.repository.tokens.SimpleClanToken; import mineplex.hub.server.ServerInfo; import mineplex.hub.server.ServerManager; import mineplex.hub.server.ui.button.JoinServerButton; -import mineplex.serverdata.data.DataRepository; + +import org.bukkit.Material; +import org.bukkit.entity.Player; public class ClansServerPage extends ShopPageBase { public ClansServerPage(ServerManager plugin, ClansServerShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player) { - super(plugin, shop, clientManager, donationManager, "Clans Beta", player, 54); + super(plugin, shop, clientManager, donationManager, "Clans", player, 54); buildPage(); } @@ -38,29 +29,12 @@ public class ClansServerPage extends ShopPageBase servers = UtilAlg.sortSet(getPlugin().getServerList("Clans"), new Comparator() + Collection servers = UtilAlg.sortSet(getPlugin().getServerList("ClansHub"), new Comparator() { @Override public int compare(ServerInfo o1, ServerInfo o2) @@ -77,72 +51,12 @@ public class ClansServerPage extends ShopPageBase -{ - private ClanRepository _repository; - +{ public ClansServerShop(ServerManager plugin, CoreClientManager clientManager, DonationManager donationManager) { - super(plugin, clientManager, donationManager, "Clans Beta"); - - _repository = new ClanRepository(plugin.getPlugin(), plugin.getStatusManager().getCurrentServerName()); + super(plugin, clientManager, donationManager, "Clans"); } @Override From aecaa8944308c66daece8cc88ab11a41dfcf2c09 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 25 Jul 2016 12:08:37 -0400 Subject: [PATCH 46/90] Update clans hub spawn location --- .../Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java index df2addd07..90f62bd06 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java @@ -169,7 +169,7 @@ public class HubManager extends MiniPlugin _portal = portal; - _spawn = new Location(UtilWorld.getWorld("world"), 0.5, 179, 0.5); + _spawn = new Location(UtilWorld.getWorld("world"), 0.5, 179, 0.5, -90f, 0f); ((CraftWorld) _spawn.getWorld()).getHandle().spigotConfig.itemMerge = 0; new WorldManager(this); From b41ad2e087efc198ea6a6c7b70af522226fd056c Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 25 Jul 2016 12:28:25 -0400 Subject: [PATCH 47/90] Fix NPC orientation in clans hub --- .../src/mineplex/clanshub/HubManager.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java index 90f62bd06..347b81551 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java @@ -170,6 +170,16 @@ public class HubManager extends MiniPlugin _portal = portal; _spawn = new Location(UtilWorld.getWorld("world"), 0.5, 179, 0.5, -90f, 0f); + runSyncLater(() -> + { + for (Entity e : _spawn.getWorld().getEntities()) + { + if (npcManager.getNpcByEntity(e) != null) + { + e.teleport(new Location(e.getWorld(), e.getLocation().getX(), e.getLocation().getY(), e.getLocation().getZ(), 90f, 0f)); + } + } + }, 120L); ((CraftWorld) _spawn.getWorld()).getHandle().spigotConfig.itemMerge = 0; new WorldManager(this); From 7b358adba1d9fbc1313bfc08785b9f49375cfa5f Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 25 Jul 2016 20:26:23 -0400 Subject: [PATCH 48/90] Prevent runed pickaxe from destroying the nether --- .../src/mineplex/game/clans/items/rares/RunedPickaxe.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 2bd901525..8905742d1 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 @@ -77,7 +77,7 @@ public class RunedPickaxe extends RareItem { return; } - + RunedPickaxe pick = (RunedPickaxe) gear.getWeapon(); String playerClan = ClansManager.getInstance().getClanUtility().getClanByPlayer(event.getPlayer()) == null ? null : ClansManager.getInstance().getClanUtility().getClanByPlayer(event.getPlayer()).getName(); @@ -90,6 +90,9 @@ public class RunedPickaxe extends RareItem if (event.getBlock().getType() == Material.BEDROCK) return; + if (ClansManager.getInstance().getNetherManager().getNetherWorld().equals(event.getBlock().getWorld())) + return; + if (!UtilTime.elapsed(pick._instamineEnabled, 12000)) { event.getBlock().breakNaturally(); From 61eca3ced0adcee735bbbc3db5e7ae12cf159a83 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Tue, 26 Jul 2016 00:54:31 -0400 Subject: [PATCH 49/90] Removed auto disguising from clans hub and removed clans tnt protection --- .../mineplex/game/clans/clans/ClanInfo.java | 22 ------------------- .../mineplex/game/clans/clans/ClansGame.java | 5 +---- .../clans/clans/gui/page/ClanWhoPage.java | 1 - .../src/mineplex/clanshub/HubManager.java | 1 - 4 files changed, 1 insertion(+), 28 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java index f7df176ea..a07074f98 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java @@ -363,9 +363,6 @@ public class ClanInfo } stringList.add(F.value("Members", members)); - // Protected - stringList.add(F.value("TNT Protection", getProtected())); - return stringList; } @@ -506,25 +503,6 @@ public class ClanInfo return isOnlineNow(); } - public String getProtected() - { - for (ClansPlayer cur : getMembers().values()) - if (cur.isOnline()) - return C.cRed + "No - Clan Members are Online"; - - if (UtilTime.elapsed(_lastOnline.getTime(), Clans.getOnlineTime())) - return C.cGreen + "Yes - Clan Members are Offline"; - - return C.cGold - + "No, " - + UtilTime.convertString(Clans.getOnlineTime() - (System.currentTimeMillis() - _lastOnline.getTime()), 1, - TimeUnit.FIT) + " to Protection"; - } - - public boolean isProtected() { - return getProtected().startsWith(C.cGreen + "Yes"); - } - public TntGenerator getGenerator() { return _generator; 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 8784ee3f3..9c3d21437 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 @@ -553,10 +553,7 @@ public class ClansGame extends MiniPlugin ClanInfo clan = _clans.getClanUtility().getOwner(event.getEntity().getLocation()); if (clan == null) return; - if (!clan.isProtected()) - event.setCancelled(true); - else - clan.inform(C.cRed + "Your Territory is under attack!", null); + clan.inform(C.cRed + "Your Territory is under attack!", null); } @EventHandler diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/page/ClanWhoPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/page/ClanWhoPage.java index 5550d370a..e38ed4b1b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/page/ClanWhoPage.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/page/ClanWhoPage.java @@ -65,7 +65,6 @@ public class ClanWhoPage extends ClanPageBase lore.add(C.Reset + C.cYellow + "Formed " + C.cWhite + UtilTime.convertString(System.currentTimeMillis() - _lookupClan.getDateCreated().getTime(), 1, UtilTime.TimeUnit.FIT) + " ago on " + UtilTime.when(_lookupClan.getDateCreated().getTime())); lore.add(C.Reset + C.cYellow + "Members " + C.cWhite + _lookupClan.getOnlinePlayerCount() + "/" + _lookupClan.getMembers().size()); lore.add(C.Reset + C.cYellow + "Territory " + C.cWhite + _lookupClan.getClaims() + "/" + _lookupClan.getClaimsMax()); - lore.add(C.Reset + C.cYellow + "TNT Protection " + C.cWhite + _lookupClan.getProtected()); if (clanInfo != null) { lore.add(C.Reset + C.cYellow + "Your War Points " + C.cWhite + clanInfo.getFormattedWarPoints(_lookupClan)); diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java index 347b81551..b5a5d12a3 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java @@ -242,7 +242,6 @@ public class HubManager extends MiniPlugin ((CraftWorld)Bukkit.getWorlds().get(0)).getHandle().pvpMode = true; - new PlayerDisguiseManager(plugin, _clientManager); new ValentinesGiftManager(plugin, clientManager, _bonusManager.getRewardManager(), inventoryManager, _gadgetManager, statsManager); _playerCountManager = new PlayerCountManager(plugin); From bf5e9f1d76fff057c242cc3e7a197203f2b4a0ea Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Tue, 26 Jul 2016 05:50:43 -0400 Subject: [PATCH 50/90] ADD JAVADOCS TO CLANS --- .../mineplex/game/clans/clans/ClanTips.java | 4 +- .../mineplex/game/clans/clans/ClansAdmin.java | 70 ++++++++++++++++--- .../mineplex/game/clans/clans/ClansGame.java | 64 +++++++++-------- .../game/clans/clans/ClansManager.java | 5 -- .../clans/clans/amplifiers/Amplifier.java | 15 ++++ .../clans/amplifiers/AmplifierCommand.java | 3 + .../clans/clans/amplifiers/AmplifierGUI.java | 28 ++++++++ .../clans/amplifiers/AmplifierManager.java | 34 +++++++++ .../game/clans/clans/ban/ClansBanManager.java | 15 ++++ .../clans/ban/commands/FreezeCommand.java | 3 + .../clans/ban/commands/UnfreezeCommand.java | 3 + .../clans/clans/banners/BannerManager.java | 32 +++++++++ .../clans/banners/BannerPacketManager.java | 12 ++++ .../clans/clans/banners/BannerPattern.java | 23 ++++++ .../clans/clans/banners/BannerRepository.java | 16 +++++ .../game/clans/clans/banners/ClanBanner.java | 30 ++++++++ .../clans/banners/command/BannerCommand.java | 3 + .../clans/clans/banners/gui/BannerGUI.java | 25 +++++++ .../gui/creation/BaseColorSelectionGUI.java | 3 + .../creation/PatternColorSelectionGUI.java | 3 + .../gui/creation/PatternTypeSelectionGUI.java | 3 + .../gui/nonedit/NonEditOverviewGUI.java | 4 +- .../banners/gui/overview/OverviewGUI.java | 3 + .../clans/commands/ClanManagementCommand.java | 30 +------- .../clans/clans/nether/NetherManager.java | 59 +++++++++++++++- .../game/clans/clans/nether/NetherPortal.java | 26 +++++++ .../clans/clans/nether/PortalRepository.java | 18 ++++- .../nether/miniboss/MinibossFireball.java | 24 ++++++- .../clans/nether/miniboss/NetherMiniBoss.java | 21 ++++++ .../miniboss/NetherMinibossManager.java | 55 +++++++++++++++ .../nether/miniboss/NetherMinibossType.java | 13 +++- .../miniboss/bosses/ArcherMiniboss.java | 6 +- .../nether/miniboss/bosses/GhastMiniboss.java | 9 ++- .../miniboss/bosses/PigmanMiniboss.java | 28 +++++++- .../miniboss/bosses/WarriorMiniboss.java | 19 +++-- .../elements/ScoreboardElementPlayer.java | 9 ++- .../clans/worldevent/EventTerrainFinder.java | 14 ++++ .../clans/worldevent/WorldEventManager.java | 1 - .../game/clans/items/runes/RuneManager.java | 50 +++++++++++++ 39 files changed, 681 insertions(+), 102 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanTips.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanTips.java index 0520548b8..117d5d648 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanTips.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanTips.java @@ -227,7 +227,7 @@ public class ClanTips extends MiniPlugin ENTER_NETHER( new String[] { C.cDRedB + "The Nether", - C.cRed + "The Nether is the home of all that is evil and monstrous, the true origin of demonic power. While here you can slay terrible creatures to find amazing loot, but remember that its darkness will slowly poison your body and kill you after 20 minutes!" + C.cRed + "The Nether is a dangerous place full of powerful mobs and hazardous terrain! However, the mobs here drop powerful Ancient Runes, which can be used to strengthen your gear, making your clan even more fearsome than before!" }), ; @@ -242,7 +242,7 @@ public class ClanTips extends MiniPlugin TipType(String[] messages, boolean ignorePreferences) { - _messages = new LinkedList(); + _messages = new LinkedList<>(); for (String message : messages) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAdmin.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAdmin.java index 4f0017ea9..65aad970a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAdmin.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAdmin.java @@ -1,12 +1,7 @@ package mineplex.game.clans.clans; -import java.sql.ResultSet; -import java.sql.SQLException; import java.util.ArrayList; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - import mineplex.core.common.Rank; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; @@ -17,7 +12,9 @@ import mineplex.core.common.util.UtilWorld; import mineplex.game.clans.core.repository.ClanTerritory; import mineplex.game.clans.core.repository.tokens.ClanToken; import mineplex.game.clans.core.war.ClanWarData; -import mineplex.serverdata.database.ResultSetCallable; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; public class ClansAdmin { @@ -341,19 +338,70 @@ public class ClansAdmin { ClanWarData war = clan.getWarData(clanAgainst); -// war.set -// -// Clans.getClanDataAccess().updateWar(clan, clanAgainst, war, success -> { -// UtilPlayer.message(caller, F.main("Clans Admin", "Updated war points against " + F.elem(war.getClanB()))); -// }); + if (war != null) + { + war.set(clan.getName(), war.getClanAPoints() - value); + + Clans.getClanDataAccess().updateWar(clan, clanAgainst, war, success -> + { + UtilPlayer.message(caller, F.main("Clans Admin", "Updated war points against " + F.elem(war.getClanB()))); + }); + } + else + { + UtilPlayer.message(caller, F.main("Clans Admin", "There is no war between those two clans!")); + return; + } } else if (operation.equalsIgnoreCase("set")) { + ClanWarData war = clan.getWarData(clanAgainst); + if (war != null) + { + war.set(clanAgainst.getName(), value); + + Clans.getClanDataAccess().updateWar(clan, clanAgainst, war, success -> + { + UtilPlayer.message(caller, F.main("Clans Admin", "Updated war points against " + F.elem(war.getClanB()))); + }); + } + else + { + Clans.getClanDataAccess().war(clan, clanAgainst, value, new Callback() + { + @Override + public void run(ClanWarData data) + { + UtilPlayer.message(caller, F.main("Clans Admin", "Updated war points against " + F.elem(data.getClanB()))); + } + }); + } } else if (operation.equalsIgnoreCase("add")) { + ClanWarData war = clan.getWarData(clanAgainst); + if (war != null) + { + war.set(clanAgainst.getName(), war.getClanAPoints() + value); + + Clans.getClanDataAccess().updateWar(clan, clanAgainst, war, success -> + { + UtilPlayer.message(caller, F.main("Clans Admin", "Updated war points against " + F.elem(war.getClanB()))); + }); + } + else + { + Clans.getClanDataAccess().war(clan, clanAgainst, value, new Callback() + { + @Override + public void run(ClanWarData data) + { + UtilPlayer.message(caller, F.main("Clans Admin", "Updated war points against " + F.elem(data.getClanB()))); + } + }); + } } else { 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 9c3d21437..f59db05d6 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 @@ -1,36 +1,6 @@ package mineplex.game.clans.clans; import java.sql.Timestamp; -import java.util.Arrays; -import java.util.Iterator; - -import org.bukkit.Bukkit; -import org.bukkit.Effect; -import org.bukkit.GameMode; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.World.Environment; -import org.bukkit.block.Block; -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.block.BlockBreakEvent; -import org.bukkit.event.block.BlockBurnEvent; -import org.bukkit.event.block.BlockIgniteEvent; -import org.bukkit.event.block.BlockIgniteEvent.IgniteCause; -import org.bukkit.event.block.BlockPistonExtendEvent; -import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.event.entity.EntityExplodeEvent; -import org.bukkit.event.entity.FoodLevelChangeEvent; -import org.bukkit.event.player.PlayerBucketEmptyEvent; -import org.bukkit.event.player.PlayerFishEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.event.player.PlayerRespawnEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.blockrestore.BlockRestoreData; @@ -52,6 +22,35 @@ import mineplex.game.clans.clans.ClansUtility.ClanRelation; import mineplex.game.clans.core.repository.ClanTerritory; import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import org.bukkit.Bukkit; +import org.bukkit.Effect; +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.World.Environment; +import org.bukkit.block.Block; +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.block.BlockBreakEvent; +import org.bukkit.event.block.BlockBurnEvent; +import org.bukkit.event.block.BlockIgniteEvent; +import org.bukkit.event.block.BlockIgniteEvent.IgniteCause; +import org.bukkit.event.block.BlockPistonExtendEvent; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.enchantment.EnchantItemEvent; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.entity.FoodLevelChangeEvent; +import org.bukkit.event.player.PlayerBucketEmptyEvent; +import org.bukkit.event.player.PlayerFishEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerRespawnEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.java.JavaPlugin; + public class ClansGame extends MiniPlugin { private ClansManager _clans; @@ -78,6 +77,11 @@ public class ClansGame extends MiniPlugin } } + @EventHandler + public void onEnchant(EnchantItemEvent event) + { + event.setCancelled(true); + } @EventHandler(priority = EventPriority.LOW) public void BlockBurn(BlockBurnEvent event) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index a7c10a0df..7c7af2e44 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -50,7 +50,6 @@ import mineplex.core.task.TaskManager; import mineplex.core.teleport.Teleport; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import mineplex.game.clans.Clans; import mineplex.game.clans.clans.ClanTips.TipType; import mineplex.game.clans.clans.ClansUtility.ClanRelation; import mineplex.game.clans.clans.amplifiers.AmplifierManager; @@ -237,8 +236,6 @@ public class ClansManager extends MiniClientPluginimplements IRelati public String UserDataDir = UtilServer.getServer().getWorlds().get(0).getWorldFolder().getPath() + File.separator + ".." + File.separator + "CLANS_USER_DATA" + File.separator; - private ClansBanManager _clansBans; - private PacketHandler _packetHandler; public ClanTips ClanTips; @@ -250,8 +247,6 @@ public class ClansManager extends MiniClientPluginimplements IRelati super("Clans Manager", plugin); _instance = this; - - _clansBans = clansBans; _punish = punish; _packetHandler = packetHandler; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/Amplifier.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/Amplifier.java index b07268b6f..4623bbe65 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/Amplifier.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/Amplifier.java @@ -4,6 +4,9 @@ import mineplex.game.clans.clans.amplifiers.AmplifierManager.AmplifierType; import org.bukkit.entity.Player; +/** + * Data class for active amplifiers + */ public class Amplifier { private Player _owner; @@ -15,16 +18,28 @@ public class Amplifier _end = System.currentTimeMillis() + type.getDuration(); } + /** + * Gets the owner of the amplifier + * @return This amplifier's owner + */ public Player getOwner() { return _owner; } + /** + * Gets the remaining duration of this amplifier + * @return How much time is left before this amplifier expires + */ public long getRemainingTime() { return Math.max(0, _end - System.currentTimeMillis()); } + /** + * Checks whether this amplifier has run out of time + * @return Whether this amplifier has run out of time + */ public boolean isEnded() { return System.currentTimeMillis() >= _end; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierCommand.java index 9c593a3b3..a50ff3366 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierCommand.java @@ -5,6 +5,9 @@ import mineplex.core.common.Rank; import org.bukkit.entity.Player; +/** + * Main amplifier command + */ public class AmplifierCommand extends CommandBase { public AmplifierCommand(AmplifierManager plugin) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierGUI.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierGUI.java index 33962d83d..b62061957 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierGUI.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierGUI.java @@ -20,6 +20,9 @@ import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; +/** + * GUI manager for amplifiers + */ public class AmplifierGUI implements Listener { private Player _viewer; @@ -40,16 +43,27 @@ public class AmplifierGUI implements Listener open(); } + /** + * Gets the owner of this specific inventory + * @return The owner of this inventory + */ public Player getViewer() { return _viewer; } + /** + * Fetches all the items registered as buttons in this inventory gui + * @return A list of the items registered as buttons in this inventory gui + */ public HashMap getItems() { return _items; } + /** + * Fills the gui with buttons + */ public void propagate() { getItems().clear(); @@ -65,6 +79,9 @@ public class AmplifierGUI implements Listener refresh(); } + /** + * Fils the confirmation menu with buttons + */ public void propagateConfirmation() { getItems().clear(); @@ -74,6 +91,11 @@ public class AmplifierGUI implements Listener refresh(); } + /** + * Handles players clicking on buttons + * @param slot The slot clicked on + * @param type The type of click + */ public void onClick(Integer slot, ClickType type) { if (_boundSlots.containsKey(slot)) @@ -116,11 +138,17 @@ public class AmplifierGUI implements Listener } } + /** + * Opens this inventory to its viewer + */ public void open() { _viewer.openInventory(_inventory); } + /** + * Updates the GUI's visuals to match registered button items + */ public void refresh() { _inventory.clear(); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierManager.java index 8995f38c5..6183a0dcb 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierManager.java @@ -17,8 +17,12 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.plugin.java.JavaPlugin; +/** + * Manager for using amplifiers in clans + */ public class AmplifierManager extends MiniPlugin { + public static final double AMPLIFIER_RUNE_DROP_MULTIPLIER = 2; private static final String AMPLIFIER_NAME = "Rune Amplifier"; private Amplifier _active; @@ -29,16 +33,31 @@ public class AmplifierManager extends MiniPlugin addCommand(new AmplifierCommand(this)); } + /** + * Checks whether there is an amplifier active on this server + * @return Whether there is an amplifier active on this server + */ public boolean hasActiveAmplifier() { return _active != null; } + /** + * Checks how many of a certain amplifier type a player owns + * @param player The player to check + * @param type The type of amplifier to check for + * @return The amount of amplifiers of that type owned + */ public int getAmountOwned(Player player, AmplifierType type) { return ClansManager.getInstance().getInventoryManager().Get(player).getItemCount(type.getFullItemName()); } + /** + * Makes a player use an amplifier + * @param user The player to use the amplifier + * @param type The type of amplifier to use + */ public void useAmplifier(Player user, AmplifierType type) { if (getAmountOwned(user, type) < 1) @@ -88,6 +107,9 @@ public class AmplifierManager extends MiniPlugin } } + /** + * Enum containing different types of amplifiers recognized by code + */ public static enum AmplifierType { TWENTY("20", "Twenty Minute Amplifier", UtilTime.convert(20, TimeUnit.MINUTES, TimeUnit.MILLISECONDS)), @@ -103,16 +125,28 @@ public class AmplifierManager extends MiniPlugin _duration = duration; } + /** + * Gets the full name of this amplifier as recognized by the inventory database + * @return The full name of this amplifier as recognized by the inventory database + */ public String getFullItemName() { return AMPLIFIER_NAME + " " + _extension; } + /** + * Gets the display name for this amplifier in this GUI + * @return The display name for this amplifier in this GUI + */ public String getDisplayName() { return _display; } + /** + * Gets the total duration for this type of amplifier + * @return The total duration for this type of amplifier + */ public long getDuration() { return _duration; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java index 157c84755..b519c1448 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java @@ -246,11 +246,21 @@ public class ClansBanManager extends MiniPlugin } } + /** + * Checks if a player is frozen + * @param player The player to check + * @return Whether the player is frozen + */ public boolean isFrozen(Player player) { return _frozen.containsKey(player.getUniqueId()); } + /** + * Freezes a player + * @param player The player to freeze + * @param staff The staff member who froze them + */ public void freeze(Player player, Player staff) { _frozen.put(player.getUniqueId(), player.getWalkSpeed()); @@ -265,6 +275,11 @@ public class ClansBanManager extends MiniPlugin } } + /** + * Unfreezes a player + * @param player The player to unfreeze + * @param staff The staff member who unfroze them + */ public void unfreeze(Player player, Player staff) { Float walkSpeed = _frozen.remove(player.getUniqueId()); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/FreezeCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/FreezeCommand.java index 5b6ee7158..fedad6275 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/FreezeCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/FreezeCommand.java @@ -9,6 +9,9 @@ import mineplex.game.clans.clans.ban.ClansBanManager; import org.bukkit.entity.Player; +/** + * Command to freeze players + */ public class FreezeCommand extends CommandBase { public FreezeCommand(ClansBanManager plugin) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/UnfreezeCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/UnfreezeCommand.java index 3494ee20c..7114d0e79 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/UnfreezeCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/UnfreezeCommand.java @@ -9,6 +9,9 @@ import mineplex.game.clans.clans.ban.ClansBanManager; import org.bukkit.entity.Player; +/** + * Command to unfreeze players + */ public class UnfreezeCommand extends CommandBase { public UnfreezeCommand(ClansBanManager plugin) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerManager.java index c5b168900..ec022d057 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerManager.java @@ -29,6 +29,9 @@ import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.inventory.meta.BannerMeta; import org.bukkit.plugin.java.JavaPlugin; +/** + * Manager class for cosmetic clans banners + */ public class BannerManager extends MiniPlugin { private static final long BANNER_PLACE_DURATION = UtilTime.convert(30, TimeUnit.MINUTES, TimeUnit.MILLISECONDS); @@ -45,6 +48,9 @@ public class BannerManager extends MiniPlugin addCommand(new BannerCommand(this)); } + /** + * Resets all placed banners to air + */ @Override public void disable() { @@ -54,6 +60,11 @@ public class BannerManager extends MiniPlugin } } + /** + * Checks what type of banner unlock a player has + * @param player The player to check + * @return The type of banner unlock a player has + */ public int getBannerUnlockLevel(Player player) { int level = 0; @@ -72,27 +83,48 @@ public class BannerManager extends MiniPlugin return level; } + /** + * Loads a banner for a clan + * @param clan The clan whose banner to load + */ public void loadBanner(ClanInfo clan) { _repo.loadBanner(LoadedBanners, clan); } + /** + * Saves a banner to the database + * @param banner The banner to save + */ public void saveBanner(ClanBanner banner) { _repo.saveBanner(banner); } + /** + * Deletes a clan's banner + * @param clan The clan whose banner to delete + */ public void deleteBanner(ClanInfo clan) { _repo.deleteBanner(clan); LoadedBanners.remove(clan.getName()); } + /** + * Deletes a clan banner + * @param banner The banner to delete + */ public void deleteBanner(ClanBanner banner) { deleteBanner(banner.getClan()); } + /** + * Places a clans banner for a player + * @param placing The player who placed the banner + * @param banner The banner to place + */ public void placeBanner(Player placing, ClanBanner banner) { if (!Recharge.Instance.use(placing, "Place Banner", 30000, true, false)) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerPacketManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerPacketManager.java index 9c7c76007..43121fea0 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerPacketManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerPacketManager.java @@ -19,6 +19,9 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.inventory.ItemStack; +/** + * Handler for banner wearing packets + */ public class BannerPacketManager implements Listener { private Field _itemField; @@ -42,11 +45,20 @@ public class BannerPacketManager implements Listener Instance = this; } + /** + * Fetches the registered loaded instance of this class + * @return The loaded instance of this class + */ public static BannerPacketManager getInstance() { return Instance; } + /** + * Toggles a player wearing their clan's banner + * @param player The player to toggle for + * @param banner The banner to toggle + */ public void toggleBanner(Player player, ItemStack banner) { if (_wearing.containsKey(player)) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerPattern.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerPattern.java index a3ea8ad8a..62cc5ec3f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerPattern.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerPattern.java @@ -4,6 +4,9 @@ import org.bukkit.DyeColor; import org.bukkit.block.banner.Pattern; import org.bukkit.block.banner.PatternType; +/** + * Data class for clans banner patterns + */ public class BannerPattern { private int _layer; @@ -24,11 +27,19 @@ public class BannerPattern _type = null; } + /** + * Gets the layer this pattern occupies on the clan's banner + * @return The layer this pattern occupies on the clan's banner + */ public int getLayer() { return _layer; } + /** + * Gets the Bukkit version of this banner pattern + * @return The Bukkit version of this banner pattern, or null if this is not a fully configured pattern + */ public Pattern getBukkitPattern() { if (_color == null || _type == null) @@ -39,6 +50,10 @@ public class BannerPattern return new Pattern(_color, _type); } + /** + * Gets the form this banner pattern will take in the database + * @return The form this banner pattern will take in the database + */ public String getDatabaseForm() { if (_color == null || _type == null) @@ -49,11 +64,19 @@ public class BannerPattern return _color.toString() + "," + _type.toString(); } + /** + * Sets the color of this banner pattern + * @param color The color to set this pattern to + */ public void setColor(DyeColor color) { _color = color; } + /** + * Sets the design of this banner pattern + * @param color The design to set this pattern to + */ public void setPatternType(PatternType type) { _type = type; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerRepository.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerRepository.java index d0c6ac27f..f9c2b41aa 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerRepository.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerRepository.java @@ -15,6 +15,9 @@ import org.bukkit.DyeColor; import org.bukkit.block.banner.PatternType; import org.bukkit.plugin.java.JavaPlugin; +/** + * Database repository class for banners + */ public class BannerRepository extends MinecraftRepository { private static final String CREATE = "CREATE TABLE IF NOT EXISTS clanBanners (clanId INT NOT NULL," @@ -34,6 +37,11 @@ public class BannerRepository extends MinecraftRepository _bannerManager = bannerManager; } + /** + * Loads a banner for a certain clan into a given hashmap + * @param map The hashmap to load the banner into + * @param clan The clan whose banner to fetch + */ public void loadBanner(final HashMap map, ClanInfo clan) { _bannerManager.runAsync(() -> @@ -74,6 +82,10 @@ public class BannerRepository extends MinecraftRepository }); } + /** + * Saves a banner into the database + * @param banner The banner to save + */ public void saveBanner(ClanBanner banner) { _bannerManager.runAsync(() -> @@ -91,6 +103,10 @@ public class BannerRepository extends MinecraftRepository }); } + /** + * Deletes a banner from the database + * @param clan The clan whose banner to delete + */ public void deleteBanner(ClanInfo clan) { _bannerManager.runAsync(() -> diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/ClanBanner.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/ClanBanner.java index e5531df42..5a12ab688 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/ClanBanner.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/ClanBanner.java @@ -15,6 +15,9 @@ import org.bukkit.inventory.meta.BannerMeta; import com.google.common.collect.Lists; +/** + * Data class for clan banners + */ public class ClanBanner { private BannerManager _manager; @@ -30,21 +33,37 @@ public class ClanBanner _patterns = patterns; } + /** + * Gets the clan that owns this banner + * @return The clan that owns this banner + */ public ClanInfo getClan() { return _clan; } + /** + * Gets the base color for this banner + * @return The base color for this banner + */ public DyeColor getBaseColor() { return _baseColor; } + /** + * Gets this banner's patterns + * @return This banner's patterns + */ public LinkedList getPatterns() { return _patterns; } + /** + * Gets the ItemStack representation of this banner + * @return The ItemStack representation of this banner + */ public ItemStack getBanner() { ItemStack banner = new ItemStack(Material.BANNER); @@ -66,16 +85,27 @@ public class ClanBanner return banner; } + /** + * Sets the base color of this banner + * @param color The color to set + */ public void setBaseColor(DyeColor color) { _baseColor = color; } + /** + * Saves this banner to the database + */ public void save() { _manager.saveBanner(this); } + /** + * Places this banner on the ground + * @param player The player to place the banner for + */ public void place(Player player) { _manager.placeBanner(player, this); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/command/BannerCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/command/BannerCommand.java index 1f93b5e94..dab08ae35 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/command/BannerCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/command/BannerCommand.java @@ -17,6 +17,9 @@ import mineplex.game.clans.clans.banners.gui.nonedit.NonEditOverviewGUI; import org.bukkit.DyeColor; import org.bukkit.entity.Player; +/** + * Main banner usage command + */ public class BannerCommand extends CommandBase { public BannerCommand(BannerManager plugin) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/BannerGUI.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/BannerGUI.java index 20753905a..0c6b5e684 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/BannerGUI.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/BannerGUI.java @@ -18,6 +18,9 @@ import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; +/** + * Base class to manage banner guis + */ public abstract class BannerGUI implements Listener { private Player _viewer; @@ -31,25 +34,47 @@ public abstract class BannerGUI implements Listener Bukkit.getPluginManager().registerEvents(this, ClansManager.getInstance().getPlugin()); } + /** + * Gets the owner of this specific inventory + * @return The owner of this inventory + */ public Player getViewer() { return _viewer; } + /** + * Fetches all the items registered as buttons in this inventory gui + * @return A list of the items registered as buttons in this inventory gui + */ public HashMap getItems() { return _items; } + /** + * Fills the gui with buttons + */ public abstract void propagate(); + /** + * Handles players clicking on buttons + * @param slot The slot clicked on + * @param type The type of click + */ public abstract void onClick(Integer slot, ClickType type); + /** + * Opens this inventory to its viewer + */ public void open() { _viewer.openInventory(_inventory); } + /** + * Updates the GUI's visuals to match registered button items + */ public void refresh() { _inventory.clear(); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/creation/BaseColorSelectionGUI.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/creation/BaseColorSelectionGUI.java index daf486024..cc3a93bff 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/creation/BaseColorSelectionGUI.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/creation/BaseColorSelectionGUI.java @@ -12,6 +12,9 @@ import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; +/** + * GUI manager for selecting a banner's base color + */ public class BaseColorSelectionGUI extends BannerGUI { private ClanBanner _banner; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/creation/PatternColorSelectionGUI.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/creation/PatternColorSelectionGUI.java index 73f823fd4..3daef4b68 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/creation/PatternColorSelectionGUI.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/creation/PatternColorSelectionGUI.java @@ -12,6 +12,9 @@ import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; +/** + * GUI manager for selecting a banner pattern's base color + */ public class PatternColorSelectionGUI extends BannerGUI { private ClanBanner _banner; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/creation/PatternTypeSelectionGUI.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/creation/PatternTypeSelectionGUI.java index 11a88dc31..587d0deab 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/creation/PatternTypeSelectionGUI.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/creation/PatternTypeSelectionGUI.java @@ -18,6 +18,9 @@ import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.BannerMeta; +/** + * GUI manager for selecting a banner pattern's design + */ public class PatternTypeSelectionGUI extends BannerGUI { private ClanBanner _banner; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/nonedit/NonEditOverviewGUI.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/nonedit/NonEditOverviewGUI.java index 474007915..b7862d8ee 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/nonedit/NonEditOverviewGUI.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/nonedit/NonEditOverviewGUI.java @@ -19,7 +19,9 @@ import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; - +/** + * GUI manager for viewing a banner usage overview + */ public class NonEditOverviewGUI extends BannerGUI { private ClanBanner _banner; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/overview/OverviewGUI.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/overview/OverviewGUI.java index 59553930d..a60ba1886 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/overview/OverviewGUI.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/gui/overview/OverviewGUI.java @@ -19,6 +19,9 @@ import org.bukkit.inventory.meta.BannerMeta; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.material.MaterialData; +/** + * GUI manager for overviewing a banner's design + */ public class OverviewGUI extends BannerGUI { private static final int MAX_BANNER_LAYERS = 12; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClanManagementCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClanManagementCommand.java index cda7ab480..baf413b43 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClanManagementCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClanManagementCommand.java @@ -1,40 +1,14 @@ package mineplex.game.clans.clans.commands; -import java.util.ArrayList; -import java.util.List; - -import org.bukkit.Chunk; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.util.Vector; - import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; -import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilInput; -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.common.util.UtilWorld; -import mineplex.core.recharge.Recharge; import mineplex.game.clans.clans.ClanInfo; -import mineplex.game.clans.clans.ClanRole; import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.clans.ClansUtility.ClanRelation; -import mineplex.game.clans.clans.ClientClan; -import mineplex.game.clans.items.CustomItem; -import mineplex.game.clans.items.GearManager; -import mineplex.game.clans.items.attributes.weapon.FlamingAttribute; -import mineplex.game.clans.items.attributes.weapon.FrostedAttribute; -import mineplex.game.clans.items.attributes.weapon.SharpAttribute; -import mineplex.game.clans.items.legendaries.LegendaryItem; -import mineplex.game.clans.items.legendaries.WindBlade; + +import org.bukkit.entity.Player; public class ClanManagementCommand extends CommandBase { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java index 50b4c210b..b50fb56b7 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java @@ -57,6 +57,9 @@ import org.bukkit.potion.PotionEffectType; import com.google.common.collect.Lists; +/** + * Manager for all nether features + */ public class NetherManager extends MiniPlugin { private static final long PORTAL_OPEN_DURATION = UtilTime.convert(10, TimeUnit.MINUTES, TimeUnit.MILLISECONDS); @@ -116,26 +119,49 @@ public class NetherManager extends MiniPlugin InNether.clear(); } + /** + * Get the manager for nether miniboss + * @return The loaded Nether Miniboss manager + */ public NetherMinibossManager getMinibossManager() { return _miniboss; } + /** + * Gets the Nether world + * @return The Nether world + */ public World getNetherWorld() { return _netherWorld; } - + + /** + * Checks if a player is in the nether + * @param player The player to check + * @return Whether the player is in the nether + */ public boolean isInNether(Player player) { return player.getWorld().equals(_netherWorld); } + /** + * Gets the place a player will exit the nether + * @param player The player to check + * @return The place the player will exit the nether + */ public Location getReturnLocation(Player player) { return OverworldOrigins.getOrDefault(player, Spawn.getNorthSpawn()); } + /** + * Fetches the nether portal with the given id + * @param id The id of the portal + * @return The nether portal with the given id + */ public NetherPortal getPortal(int id) { for (NetherPortal portal : _portals) @@ -149,6 +175,10 @@ public class NetherManager extends MiniPlugin return null; } + /** + * Loads a nether portal into the manager + * @param portal The portal to load + */ public void addPortal(NetherPortal portal) { _portals.add(portal); @@ -169,6 +199,10 @@ public class NetherManager extends MiniPlugin }); } + /** + * Deletes a nether portal and removes it from the database + * @param portal The portal to remove + */ public void deletePortal(NetherPortal portal) { portal.close(); @@ -177,6 +211,10 @@ public class NetherManager extends MiniPlugin _repo.deletePortal(portal.getId()); } + /** + * Spawns a nether portal for a given duration + * @param duration The duration to maintain the portal for + */ public void spawnPortal(long duration) { if (_portals.isEmpty() || _returnPortals.isEmpty()) @@ -203,11 +241,19 @@ public class NetherManager extends MiniPlugin Bukkit.broadcastMessage(F.main(getName(), "A " + F.clansNether("Nether Portal") + " has opened at " + F.elem(UtilWorld.locToStrClean(portal.getLocation())) + " for " + F.elem(UtilTime.MakeStr(duration)) + "!")); } + /** + * Spawns a portal for the default remain duration + */ public void spawnPortal() { spawnPortal(PORTAL_OPEN_DURATION); } + /** + * Creates a portal with the player's stored corners + * @param creator The creator of the portal + * @param returnPortal Whether the portal is a return portal + */ public void createPortal(Player creator, boolean returnPortal) { if (Claiming.getOrDefault(creator, new ClaimData()).getTotalSelected() < 2) @@ -221,6 +267,9 @@ public class NetherManager extends MiniPlugin UtilPlayer.message(creator, F.main(getName(), "Portal successfully created!")); } + /** + * Closes all portals and clears away their blocks + */ public void closePortals() { for (NetherPortal portal : _portals) @@ -229,6 +278,10 @@ public class NetherManager extends MiniPlugin } } + /** + * Displays a list of all portals to a player + * @param player The player to display the list to + */ public void showPortalList(Player player) { UtilPlayer.message(player, F.main(getName(), "Portal List:")); @@ -238,6 +291,10 @@ public class NetherManager extends MiniPlugin } } + /** + * Gives a player a portal claim wand + * @param player The player to give the wand to + */ public void giveWand(Player player) { player.getInventory().addItem(CLAIM_WAND.clone()); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java index d1def8de8..e1ba574c0 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java @@ -28,6 +28,9 @@ import org.bukkit.potion.PotionEffectType; import com.google.common.collect.Lists; +/** + * Data and listener class for individual nether portals + */ public class NetherPortal implements Listener { private static final int SECONDS_UNTIL_PORTAL = 5; @@ -103,26 +106,46 @@ public class NetherPortal implements Listener return _frame.contains(block) || _portal.contains(block); } + /** + * Gets the id of this portal + * @return This portal's id + */ public int getId() { return _id; } + /** + * Gets the center location of this portal + * @return The center location of this portal + */ public Location getLocation() { return _loc; } + /** + * Gets the corners of this portal + * @return An array of the corners of this portal + */ public Location[] getCorners() { return _corners; } + /** + * Checks if this portal is a return portal + * @return Whether this portal is a return portal + */ public boolean isReturnPortal() { return _returnPortal; } + /** + * Opens this portal for a given duration + * @param duration The duration to hold the portal open for + */ @SuppressWarnings("deprecation") public void open(long duration) { @@ -153,6 +176,9 @@ public class NetherPortal implements Listener } } + /** + * Closes this portal and clears away its blocks + */ public void close() { Open = false; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/PortalRepository.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/PortalRepository.java index 7a57e144a..6074de105 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/PortalRepository.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/PortalRepository.java @@ -9,6 +9,9 @@ import mineplex.serverdata.database.column.ColumnVarChar; import org.bukkit.plugin.java.JavaPlugin; +/** + * Database repository class for nether portals + */ public class PortalRepository extends MinecraftRepository { private static final String CREATE = "CREATE TABLE IF NOT EXISTS clansNetherPortals (id INT NOT NULL AUTO_INCREMENT," @@ -30,6 +33,9 @@ public class PortalRepository extends MinecraftRepository _nether = portalManager; } + /** + * Loads all stored portals + */ public void loadPortals() { _nether.runAsync(() -> @@ -53,6 +59,12 @@ public class PortalRepository extends MinecraftRepository }); } + /** + * Adds a portal into the database and loaded portals + * @param cornerOne The serialized first corner of the portal + * @param cornerTwo The serialized second corner of the portal + * @param returnPortal Whether the portal is a return portal + */ public void addPortal(final String cornerOne, final String cornerTwo, final boolean returnPortal) { _nether.runAsync(() -> @@ -71,7 +83,11 @@ public class PortalRepository extends MinecraftRepository }, new ColumnVarChar("cornerOne", 30, cornerOne), new ColumnVarChar("cornerTwo", 30, cornerTwo), new ColumnBoolean("returnPortal", returnPortal)); }); } - + + /** + * Deletes the portal with the given id from the database + * @param id The id of the portal to delete + */ public void deletePortal(final int id) { _nether.runAsync(() -> diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/MinibossFireball.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/MinibossFireball.java index e085b326b..d33ad0de6 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/MinibossFireball.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/MinibossFireball.java @@ -18,8 +18,17 @@ import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.util.Vector; +/** + * Manager class for managing boss fireballs + */ public class MinibossFireball implements Listener { + private static final double FIREBALL_EXPLOSION_RANGE = 5; + private static final float SOUND_VOLUME = 1f; + private static final float SOUND_PITCH = 0.8f; + private static final double STRENGTH_MULTIPLIER = 1.6; + private static final double VERT_MULTIPLIER = 0.8; + public MinibossFireball() { Bukkit.getPluginManager().registerEvents(this, ClansManager.getInstance().getPlugin()); @@ -39,7 +48,7 @@ public class MinibossFireball implements Listener return; } - HashMap hitMap = UtilEnt.getInRadius(proj.getLocation(), 5); + HashMap hitMap = UtilEnt.getInRadius(proj.getLocation(), FIREBALL_EXPLOSION_RANGE); for (LivingEntity cur : hitMap.keySet()) { double range = hitMap.get(cur); @@ -47,15 +56,24 @@ public class MinibossFireball implements Listener ClansManager.getInstance().getCondition().Factory().Ignite("Fireball", cur, ((LivingEntity)proj.getMetadata("MINIBOSS_FIREBALL").get(0).value()), 7 * range, false, false); ClansManager.getInstance().getCondition().Factory().Falling("Fireball", cur, ((LivingEntity)proj.getMetadata("MINIBOSS_FIREBALL").get(0).value()), 10, false, true); UtilAction.velocity(cur, UtilAlg.getTrajectory(proj.getLocation().add(0, -0.5, 0), cur.getEyeLocation()), - 1.6 * range, false, 0, 0.8 * range, 1.2, true); + STRENGTH_MULTIPLIER * range, false, 0, VERT_MULTIPLIER * range, 1.2, true); } } + /** + * Checks if the given projectile is a boss fireball + * @param entity The projectile to check + * @return Whether the given projectile is a boss fireball + */ public static boolean isFireball(Projectile entity) { return entity.hasMetadata("MINIBOSS_FIREBALL"); } + /** + * Makes an entity shoot a fireball + * @param shooter The entity to shoot from + */ public static void launchFireball(LivingEntity shooter) { LargeFireball ball = shooter.launchProjectile(LargeFireball.class); @@ -66,6 +84,6 @@ public class MinibossFireball implements Listener ball.teleport(shooter.getEyeLocation().add(shooter.getLocation().getDirection().multiply(1))); ball.setVelocity(new Vector(0,0,0)); ball.setMetadata("MINIBOSS_FIREBALL", new FixedMetadataValue(ClansManager.getInstance().getPlugin(), shooter)); - shooter.getWorld().playSound(shooter.getLocation(), Sound.GHAST_FIREBALL, 1f, 0.8f); + shooter.getWorld().playSound(shooter.getLocation(), Sound.GHAST_FIREBALL, SOUND_VOLUME, SOUND_PITCH); } } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMiniBoss.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMiniBoss.java index dad0324d5..870f9b03d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMiniBoss.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMiniBoss.java @@ -13,6 +13,10 @@ import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityDeathEvent; +/** + * Base class for nether minibosses + * @param The type of entity this boss will use + */ public abstract class NetherMiniBoss implements Listener { private Mob _entity; @@ -44,17 +48,34 @@ public abstract class NetherMiniBoss implements Listen Bukkit.getPluginManager().registerEvents(this, ClansManager.getInstance().getPlugin()); } + /** + * Fetches the entity for this boss + * @return The entity for this boss + */ public Mob getEntity() { return _entity; } + /** + * Method called after the entity spawns + */ public void customSpawn() {}; + /** + * Method called when the entity dies + * @param deathLocation The location where the entity died + */ public void customDeath(Location deathLocation) {}; + /** + * Method called when the entity despawns for non-death reasons + */ public void customDespawn() {}; + /** + * Method called for updating every 10 ticks + */ public void update() {}; @EventHandler diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossManager.java index 3d4da1f7e..ef48ff386 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossManager.java @@ -8,20 +8,29 @@ import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilTime; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.nether.NetherManager; import org.bukkit.Bukkit; +import org.bukkit.GameMode; import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.BlockFace; import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntitySpawnEvent; import com.google.common.collect.Lists; +/** + * Manager to handle miniboss spawning in the nether + */ public class NetherMinibossManager implements Listener { private static final long MINIBOSS_SPAWN_RATE = 10000; + private static final int[] PIGMAN_SPAWN_OFFSET = {6, 12}; private NetherManager _manager; private HashMap _spawns = new HashMap<>(); private long _lastSpawned; @@ -105,6 +114,52 @@ public class NetherMinibossManager implements Listener { spawnAttacker(spawn); } + List nether = Lists.newArrayList(); + nether.addAll(_manager.InNether.keySet()); + + for (Player player : nether) + { + if (player.getGameMode() != GameMode.SURVIVAL || ClansManager.getInstance().getIncognitoManager().Get(player).Hidden) + { + continue; + } + Location spawn = player.getLocation().clone().add(UtilMath.rRange(PIGMAN_SPAWN_OFFSET[0], PIGMAN_SPAWN_OFFSET[1]), 0, UtilMath.rRange(PIGMAN_SPAWN_OFFSET[0], PIGMAN_SPAWN_OFFSET[1])); + if (spawn.getBlock().getType() != Material.AIR || spawn.getBlock().getRelative(BlockFace.UP).getType() != Material.AIR || spawn.getBlock().getRelative(BlockFace.DOWN).getType() == Material.AIR) + { + boolean down = spawn.getBlock().getRelative(BlockFace.DOWN).getType() == Material.AIR; + for (int tries = 0; tries < 10; tries++) + { + if (down) + { + spawn.subtract(0, 1, 0); + if (spawn.getBlock().getRelative(BlockFace.DOWN).getType() != Material.AIR) + { + _allowSpawn = true; + NetherMinibossType.PIGMAN.getNewInstance(spawn); + _allowSpawn = false; + break; + } + } + else + { + spawn.add(0, 1, 0); + if (spawn.getBlock().getType() == Material.AIR && spawn.getBlock().getRelative(BlockFace.UP).getType() == Material.AIR) + { + _allowSpawn = true; + NetherMinibossType.PIGMAN.getNewInstance(spawn); + _allowSpawn = false; + break; + } + } + } + } + else + { + _allowSpawn = true; + NetherMinibossType.PIGMAN.getNewInstance(spawn); + _allowSpawn = false; + } + } } } } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossType.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossType.java index 36d2e79f0..8658ca2b2 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossType.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossType.java @@ -2,17 +2,21 @@ package mineplex.game.clans.clans.nether.miniboss; import mineplex.game.clans.clans.nether.miniboss.bosses.ArcherMiniboss; import mineplex.game.clans.clans.nether.miniboss.bosses.GhastMiniboss; +import mineplex.game.clans.clans.nether.miniboss.bosses.PigmanMiniboss; import mineplex.game.clans.clans.nether.miniboss.bosses.WarriorMiniboss; import org.bukkit.Location; import org.bukkit.entity.EntityType; +/** + * Enum with all types of nether minibosses + */ public enum NetherMinibossType { GHAST("Ghast", 25D, EntityType.GHAST, GhastMiniboss.class), WARRIOR("Undead Warrior", 30D, EntityType.ZOMBIE, WarriorMiniboss.class), - ARCHER("Undead Archer", 25D, EntityType.SKELETON, ArcherMiniboss.class) - //PIGMAN("Zombie Pigman", 30D, EntityType.PIG_ZOMBIE, PigmanMiniboss.class) + ARCHER("Undead Archer", 25D, EntityType.SKELETON, ArcherMiniboss.class), + PIGMAN("Zombie Pigman", 30D, EntityType.PIG_ZOMBIE, PigmanMiniboss.class) ; private Class _code; @@ -28,6 +32,11 @@ public enum NetherMinibossType _code = code; } + /** + * Creates a new instance of this miniboss at a given location + * @param spawn The location to spawn the boss in + * @return The instance of the miniboss + */ public NetherMiniBoss getNewInstance(Location spawn) { try diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/ArcherMiniboss.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/ArcherMiniboss.java index 8248772bb..72ce7c439 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/ArcherMiniboss.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/ArcherMiniboss.java @@ -4,6 +4,7 @@ import java.util.Random; import mineplex.core.common.util.UtilMath; import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.amplifiers.AmplifierManager; import mineplex.game.clans.clans.nether.miniboss.NetherMiniBoss; import mineplex.game.clans.items.runes.RuneManager.RuneAttribute; import mineplex.minecraft.game.core.damage.CustomDamageEvent; @@ -34,6 +35,7 @@ public class ArcherMiniboss extends NetherMiniBoss { private static final int BARBED_LEVEL = 1; private static final double RUNE_DROP_CHANCE = .1; + private static final int MAX_DIAMOND_DROPS = 5; public ArcherMiniboss(String displayName, Double maxHealth, Location spawn, EntityType type) { @@ -61,11 +63,11 @@ public class ArcherMiniboss extends NetherMiniBoss @Override public void customDeath(Location deathLocation) { - deathLocation.getWorld().dropItemNaturally(deathLocation, new ItemStack(Material.DIAMOND, UtilMath.r(5) + 1)); + deathLocation.getWorld().dropItemNaturally(deathLocation, new ItemStack(Material.DIAMOND, UtilMath.r(MAX_DIAMOND_DROPS) + 1)); double runeDropChance = RUNE_DROP_CHANCE; if (ClansManager.getInstance().getAmplifierManager().hasActiveAmplifier()) { - runeDropChance *= 2; + runeDropChance *= AmplifierManager.AMPLIFIER_RUNE_DROP_MULTIPLIER; } if (new Random().nextDouble() <= runeDropChance) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/GhastMiniboss.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/GhastMiniboss.java index 150814f82..5c2f35532 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/GhastMiniboss.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/GhastMiniboss.java @@ -7,6 +7,7 @@ import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.amplifiers.AmplifierManager; import mineplex.game.clans.clans.nether.miniboss.MinibossFireball; import mineplex.game.clans.clans.nether.miniboss.NetherMiniBoss; import mineplex.game.clans.items.runes.RuneManager.RuneAttribute; @@ -30,6 +31,8 @@ public class GhastMiniboss extends NetherMiniBoss private static final long FIREBALL_LAUNCH_RATE = 500; private static final int FIREBALLS_PER_USE = 5; private static final double RUNE_DROP_CHANCE = .1; + private static final int MAX_DIAMOND_DROPS = 5; + private static final double MAX_TARGET_RANGE = 25; private long _lastFireballUse; private int _fireballsRemaining; @@ -68,11 +71,11 @@ public class GhastMiniboss extends NetherMiniBoss @Override public void customDeath(Location deathLocation) { - deathLocation.getWorld().dropItemNaturally(deathLocation, new ItemStack(Material.DIAMOND, UtilMath.r(5) + 1)); + deathLocation.getWorld().dropItemNaturally(deathLocation, new ItemStack(Material.DIAMOND, UtilMath.r(MAX_DIAMOND_DROPS) + 1)); double runeDropChance = RUNE_DROP_CHANCE; if (ClansManager.getInstance().getAmplifierManager().hasActiveAmplifier()) { - runeDropChance *= 2; + runeDropChance *= AmplifierManager.AMPLIFIER_RUNE_DROP_MULTIPLIER; } if (new Random().nextDouble() <= runeDropChance) { @@ -85,7 +88,7 @@ public class GhastMiniboss extends NetherMiniBoss public void update() { Player target = null; - for (Player test : UtilPlayer.getInRadius(getEntity().getLocation(), 25).keySet()) + for (Player test : UtilPlayer.getInRadius(getEntity().getLocation(), MAX_TARGET_RANGE).keySet()) { if (test.getGameMode() == GameMode.SURVIVAL && !ClansManager.getInstance().getIncognitoManager().Get(test).Hidden) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/PigmanMiniboss.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/PigmanMiniboss.java index 1e15f0758..0fc4574fc 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/PigmanMiniboss.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/PigmanMiniboss.java @@ -2,14 +2,20 @@ package mineplex.game.clans.clans.nether.miniboss.bosses; import java.util.Random; +import mineplex.core.common.util.UtilMath; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.amplifiers.AmplifierManager; import mineplex.game.clans.clans.nether.miniboss.NetherMiniBoss; +import mineplex.game.clans.items.runes.RuneManager.RuneAttribute; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.EntityType; import org.bukkit.entity.PigZombie; import org.bukkit.event.EventHandler; +import org.bukkit.inventory.ItemStack; /** * Class for running an individual Pigman miniboss @@ -17,12 +23,32 @@ import org.bukkit.event.EventHandler; public class PigmanMiniboss extends NetherMiniBoss { private static final double IRON_SKIN_CHANCE = .33; + private static final float SOUND_VOLUME = 0.5f; + private static final float SOUND_PITCH = 1.6f; + private static final double RUNE_DROP_CHANCE = .1; + private static final int MAX_DIAMOND_DROPS = 5; public PigmanMiniboss(String displayName, Double maxHealth, Location spawn, EntityType type) { super(displayName, maxHealth, spawn, type); } + @Override + public void customDeath(Location deathLocation) + { + deathLocation.getWorld().dropItemNaturally(deathLocation, new ItemStack(Material.DIAMOND, UtilMath.r(MAX_DIAMOND_DROPS) + 1)); + double runeDropChance = RUNE_DROP_CHANCE; + if (ClansManager.getInstance().getAmplifierManager().hasActiveAmplifier()) + { + runeDropChance *= AmplifierManager.AMPLIFIER_RUNE_DROP_MULTIPLIER; + } + if (new Random().nextDouble() <= runeDropChance) + { + RuneAttribute runeType = RuneAttribute.values()[UtilMath.r(RuneAttribute.values().length)]; + deathLocation.getWorld().dropItemNaturally(deathLocation, ClansManager.getInstance().getGearManager().getRuneManager().getRune(runeType)); + } + } + @EventHandler public void onDamage(CustomDamageEvent event) { @@ -31,7 +57,7 @@ public class PigmanMiniboss extends NetherMiniBoss if (new Random().nextDouble() <= IRON_SKIN_CHANCE) { event.SetCancelled("Iron Skin Deflection"); - event.GetDamageeEntity().getWorld().playSound(event.GetDamageeEntity().getLocation(), Sound.ZOMBIE_METAL, 0.5f, 1.6f); + event.GetDamageeEntity().getWorld().playSound(event.GetDamageeEntity().getLocation(), Sound.ZOMBIE_METAL, SOUND_VOLUME, SOUND_PITCH); } } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/WarriorMiniboss.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/WarriorMiniboss.java index b0f0c98b3..df682506a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/WarriorMiniboss.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/WarriorMiniboss.java @@ -6,6 +6,7 @@ import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilMath; import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.amplifiers.AmplifierManager; import mineplex.game.clans.clans.nether.miniboss.NetherMiniBoss; import mineplex.game.clans.items.runes.RuneManager.RuneAttribute; import mineplex.minecraft.game.core.damage.CustomDamageEvent; @@ -32,6 +33,12 @@ import org.bukkit.potion.PotionEffectType; public class WarriorMiniboss extends NetherMiniBoss { private static final double RUNE_DROP_CHANCE = .1; + private static final int MAX_DIAMOND_DROPS = 5; + private static final double LEAP_CHANCE = .9; + private static final double LEAP_MIN_DIST = 3; + private static final double LEAP_MAX_DIST = 16; + private static final float SOUND_VOLUME = 1f; + private static final float SOUND_PITCH = 2f; public WarriorMiniboss(String displayName, Double maxHealth, Location spawn, EntityType type) { @@ -59,11 +66,11 @@ public class WarriorMiniboss extends NetherMiniBoss @Override public void customDeath(Location deathLocation) { - deathLocation.getWorld().dropItemNaturally(deathLocation, new ItemStack(Material.DIAMOND, UtilMath.r(5) + 1)); + deathLocation.getWorld().dropItemNaturally(deathLocation, new ItemStack(Material.DIAMOND, UtilMath.r(MAX_DIAMOND_DROPS) + 1)); double runeDropChance = RUNE_DROP_CHANCE; if (ClansManager.getInstance().getAmplifierManager().hasActiveAmplifier()) { - runeDropChance *= 2; + runeDropChance *= AmplifierManager.AMPLIFIER_RUNE_DROP_MULTIPLIER; } if (new Random().nextDouble() <= runeDropChance) { @@ -75,7 +82,7 @@ public class WarriorMiniboss extends NetherMiniBoss @Override public void update() { - if (Math.random() < 0.9) + if (Math.random() < LEAP_CHANCE) return; Zombie zombie = getEntity(); @@ -85,18 +92,18 @@ public class WarriorMiniboss extends NetherMiniBoss double dist = UtilMath.offset(zombie.getTarget(), zombie); - if (dist <= 3 || dist > 16) + if (dist <= LEAP_MIN_DIST || dist > LEAP_MAX_DIST) return; - double power = 0.8 + (1.2 * ((dist-3)/13d)); + double power = 0.8 + (1.2 * ((dist-3)/13d)); //Im sorry connor but i have no idea what those numbers are for <3 //Leap UtilAction.velocity(zombie, UtilAlg.getTrajectory(zombie, zombie.getTarget()), power, false, 0, 0.2, 1, true); //Effect - zombie.getWorld().playSound(zombie.getLocation(), Sound.ZOMBIE_HURT, 1f, 2f); + zombie.getWorld().playSound(zombie.getLocation(), Sound.ZOMBIE_HURT, SOUND_VOLUME, SOUND_PITCH); } @EventHandler diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java index c514a2119..d86ecc0ac 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java @@ -1,12 +1,7 @@ package mineplex.game.clans.clans.scoreboard.elements; -import java.util.ArrayList; import java.util.List; -import org.bukkit.entity.Player; - -import com.google.common.collect.Lists; - import mineplex.core.common.CurrencyType; import mineplex.core.common.util.C; import mineplex.core.scoreboard.ScoreboardManager; @@ -15,6 +10,10 @@ import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansUtility; import mineplex.game.clans.core.repository.ClanTerritory; +import org.bukkit.entity.Player; + +import com.google.common.collect.Lists; + public class ScoreboardElementPlayer implements ScoreboardElement { private ClansManager _clansManager; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/EventTerrainFinder.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/EventTerrainFinder.java index 6e4f8dcb2..54ffef2d8 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/EventTerrainFinder.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/EventTerrainFinder.java @@ -130,6 +130,9 @@ public class EventTerrainFinder return null; } + /** + * Enum with locations around the map for world events to spawn + */ private static enum EventLocation { NORTH_1("world", -495, 73, -1028), @@ -157,16 +160,27 @@ public class EventTerrainFinder _z = z; } + /** + * Returns the Bukkit center location for this event space + * @return The Bukkit center location for this event space + */ public Location getLocation() { return new Location(UtilWorld.getWorld(_world), _x, _y, _z); } + /** + * Gets the last time this event space has been used + * @return The last time this event space has been used + */ public Long getLastUsed() { return _last; } + /** + * Updates this event space's last used time to now + */ public void use() { _last = System.currentTimeMillis(); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java index c8b82fea9..2270b7ef0 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java @@ -28,7 +28,6 @@ import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature; import mineplex.minecraft.game.core.boss.skeletonking.SkeletonCreature; import mineplex.minecraft.game.core.damage.DamageManager; -import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/runes/RuneManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/runes/RuneManager.java index d4c349ded..1fa2eeff7 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/runes/RuneManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/runes/RuneManager.java @@ -43,6 +43,9 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.plugin.java.JavaPlugin; +/** + * Manager class for runes + */ public class RuneManager implements Listener { private static final String RUNE_NAME = C.cGold + "Ancient Rune"; @@ -54,6 +57,11 @@ public class RuneManager implements Listener Bukkit.getPluginManager().registerEvents(this, plugin); } + /** + * Checks if an item is a rune + * @param item The item to check + * @return Whether the item is a rune + */ public boolean isRune(ItemStack item) { if (item == null || item.getType() == Material.AIR) @@ -64,6 +72,11 @@ public class RuneManager implements Listener return im.hasDisplayName() && im.getDisplayName().equals(RUNE_NAME) && im.hasLore() && im.getLore().size() > 0; } + /** + * Converts a rune item to a rune attribute + * @param rune The rune to convert + * @return The attribute of the rune + */ public RuneAttribute decodeRune(ItemStack rune) { if (!isRune(rune)) @@ -75,6 +88,11 @@ public class RuneManager implements Listener return attribute; } + /** + * Gets the item representation of a rune attribute + * @param attribute The rune attribute to generate the rune from + * @return The item representation of the rune attribute + */ public ItemStack getRune(RuneAttribute attribute) { ItemStack rune = new ItemStack(Material.NETHER_STAR); @@ -87,6 +105,12 @@ public class RuneManager implements Listener return rune; } + /** + * Applies a rune to an item + * @param rune The rune to apply to the item + * @param to The item to apply the rune to + * @return The item after having the rune applied + */ public ItemStack applyToItem(RuneAttribute rune, ItemStack to) { if (!rune.canApplyTo(to.getType())) @@ -231,6 +255,9 @@ public class RuneManager implements Listener player.updateInventory(); } + /** + * Enum of all rune attributes + */ public static enum RuneAttribute { FROSTED(FrostedAttribute.class, "Frosted", true, false, false), @@ -279,16 +306,29 @@ public class RuneManager implements Listener } } + /** + * Gets the lore display of this rune type + * @return The lore display of this rune type + */ public String getDisplay() { return _display; } + /** + * Gets the class for this rune type + * @return The class for this rune type + */ public Class getAttributeClass() { return _class; } + /** + * Checks whether this rune type can be applied to an item type + * @param type The item type to check + * @return Whether this rune type can be applied to that item type + */ public boolean canApplyTo(Material type) { if (_weapon) @@ -314,6 +354,11 @@ public class RuneManager implements Listener return false; } + /** + * Gets the rune attribute from a given lore display + * @param display The lore display to check + * @return The rune attribute associated with that lore display + */ public static RuneAttribute getFromDisplay(String display) { for (RuneAttribute rune : RuneAttribute.values()) @@ -327,6 +372,11 @@ public class RuneManager implements Listener return null; } + /** + * Gets the rune attribute that resolves to the given string + * @param string The string to get the rune attribute based on + * @return The rune attribute that resolves to that string + */ public static RuneAttribute getFromString(String string) { for (RuneAttribute rune : RuneAttribute.values()) From 4df8de58a640a96c35a74b03ac3d48f0f48b89e2 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Tue, 26 Jul 2016 05:51:42 -0400 Subject: [PATCH 51/90] More javadocs --- .../src/mineplex/game/clans/items/commands/RuneCommand.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/commands/RuneCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/commands/RuneCommand.java index 6ae4cc5ed..b3cc4272a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/commands/RuneCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/commands/RuneCommand.java @@ -12,6 +12,9 @@ import mineplex.game.clans.items.runes.RuneManager.RuneAttribute; import org.bukkit.entity.Player; +/** + * Command to give yourself a rune + */ public class RuneCommand extends CommandBase { private RuneManager _rune; From e396acc69c7790c3636cbdf7a0c4dfbe66060d7e Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Tue, 26 Jul 2016 07:15:09 -0400 Subject: [PATCH 52/90] Fix clans ips being added to the bungee rotator --- .../bungee/playerCount/PlayerCount.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerCount/PlayerCount.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerCount/PlayerCount.java index 61767b81d..9c6cdfbc5 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerCount/PlayerCount.java +++ b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerCount/PlayerCount.java @@ -1,7 +1,6 @@ package mineplex.bungee.playerCount; import java.io.File; -import java.util.UUID; import java.util.concurrent.TimeUnit; import mineplex.bungee.status.InternetStatus; @@ -12,7 +11,6 @@ import mineplex.serverdata.redis.RedisDataRepository; import mineplex.serverdata.servers.ConnectionData; import mineplex.serverdata.servers.ConnectionData.ConnectionType; import mineplex.serverdata.servers.ServerManager; -import mineplex.serverdata.servers.ServerRepository; import net.md_5.bungee.api.ServerPing.Players; import net.md_5.bungee.api.config.ListenerInfo; import net.md_5.bungee.api.event.ProxyPingEvent; @@ -39,7 +37,13 @@ public class PlayerCount implements Listener, Runnable _plugin.getProxy().getScheduler().schedule(_plugin, this, 4L, 4L, TimeUnit.SECONDS); _plugin.getProxy().getPluginManager().registerListener(_plugin, this); - _listenerInfo = _plugin.getProxy().getConfigurationAdapter().getListeners().iterator().next(); + for (ListenerInfo info : _plugin.getProxy().getConfigurationAdapter().getListeners()) + { + if (info.getDefaultServer().equalsIgnoreCase("Lobby")) + { + _listenerInfo = info; + } + } _repository = new RedisDataRepository(ServerManager.getConnection(true, ServerManager.SERVER_STATUS_LABEL), ServerManager.getConnection(false, ServerManager.SERVER_STATUS_LABEL), Region.ALL, BungeeServer.class, "bungeeServers"); @@ -55,7 +59,10 @@ public class PlayerCount implements Listener, Runnable public void run() { BungeeServer snapshot = generateSnapshot(); - _repository.addElement(snapshot, 15); // Update with a 15 second expiry on session + if (snapshot != null) + { + _repository.addElement(snapshot, 15); // Update with a 15 second expiry on session + } _totalPlayers = fetchPlayerCount(); } @@ -84,6 +91,10 @@ public class PlayerCount implements Listener, Runnable */ private BungeeServer generateSnapshot() { + if (_listenerInfo == null) + { + return null; + } String name = _listenerInfo.getHost().getAddress().getHostAddress(); String host = _listenerInfo.getHost().getAddress().getHostAddress(); int port = _listenerInfo.getHost().getPort(); From 34d5fb5e24702ee58fb6d366d17231f573f38bb6 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Tue, 26 Jul 2016 07:15:40 -0400 Subject: [PATCH 53/90] Fix craters getting glitched in wilderness --- .../game/clans/clans/siege/weapon/projectile/Crater.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/Crater.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/Crater.java index 883211b4f..7f35a1850 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/Crater.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/Crater.java @@ -27,10 +27,13 @@ public class Crater { return; } - ClanInfo clan = ClansManager.getInstance().getClanUtility().getOwner(terr); - if (clan != null && !ClansManager.getInstance().getWarManager().isBeingBesiegedBy(clan, _weapon.getOwner())) + if (terr != null) { - return; + ClanInfo clan = ClansManager.getInstance().getClanUtility().getOwner(terr); + if (clan != null && !ClansManager.getInstance().getWarManager().isBeingBesiegedBy(clan, _weapon.getOwner())) + { + return; + } } _origin.getWorld().createExplosion(_origin, 2.6f); From bb5d766ba620d9cf62feed976693496472cbc9df Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Tue, 26 Jul 2016 07:35:11 -0400 Subject: [PATCH 54/90] Patch war point evasion by committing suicide in safezones --- .../game/clans/clans/commands/KillCommand.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/KillCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/KillCommand.java index 611838bd7..7f9b6f85a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/KillCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/KillCommand.java @@ -1,15 +1,14 @@ package mineplex.game.clans.clans.commands; -import mineplex.game.clans.clans.ClansManager; -import mineplex.minecraft.game.classcombat.Skill.Global.Recharge; -import org.bukkit.entity.Player; - import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; +import mineplex.game.clans.clans.ClansManager; import mineplex.minecraft.game.core.damage.DamageManager; +import org.bukkit.entity.Player; + public class KillCommand extends CommandBase { public KillCommand(DamageManager plugin) @@ -35,9 +34,14 @@ public class KillCommand extends CommandBase UtilPlayer.message(caller, F.main("Clans", "Please wait a bit before suiciding")); return; } + if (ClansManager.getInstance().getClanUtility().isSafe(caller.getLocation()) || (ClansManager.getInstance().getClanUtility().getClaim(caller.getLocation()) != null && ClansManager.getInstance().getClanUtility().getClaim(caller.getLocation()).Owner.equalsIgnoreCase("Spawn"))) + { + UtilPlayer.message(caller, F.main("Clans", "You cannot use this command whilst in a safezone!")); + return; + } UtilPlayer.message(caller, F.main("Clans", "You have imploded.")); caller.setHealth(0D); } -} +} \ No newline at end of file From d98ca0ab3c36d71bc692c18af637fae81daba034 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Tue, 26 Jul 2016 09:00:37 -0400 Subject: [PATCH 55/90] Remove unused miniboss --- .../miniboss/NetherMinibossManager.java | 52 --------------- .../nether/miniboss/NetherMinibossType.java | 4 +- .../miniboss/bosses/PigmanMiniboss.java | 64 ------------------- 3 files changed, 1 insertion(+), 119 deletions(-) delete mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/PigmanMiniboss.java diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossManager.java index ef48ff386..1b688d330 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossManager.java @@ -8,16 +8,11 @@ import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilTime; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.nether.NetherManager; import org.bukkit.Bukkit; -import org.bukkit.GameMode; import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.BlockFace; import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntitySpawnEvent; @@ -30,7 +25,6 @@ import com.google.common.collect.Lists; public class NetherMinibossManager implements Listener { private static final long MINIBOSS_SPAWN_RATE = 10000; - private static final int[] PIGMAN_SPAWN_OFFSET = {6, 12}; private NetherManager _manager; private HashMap _spawns = new HashMap<>(); private long _lastSpawned; @@ -114,52 +108,6 @@ public class NetherMinibossManager implements Listener { spawnAttacker(spawn); } - List nether = Lists.newArrayList(); - nether.addAll(_manager.InNether.keySet()); - - for (Player player : nether) - { - if (player.getGameMode() != GameMode.SURVIVAL || ClansManager.getInstance().getIncognitoManager().Get(player).Hidden) - { - continue; - } - Location spawn = player.getLocation().clone().add(UtilMath.rRange(PIGMAN_SPAWN_OFFSET[0], PIGMAN_SPAWN_OFFSET[1]), 0, UtilMath.rRange(PIGMAN_SPAWN_OFFSET[0], PIGMAN_SPAWN_OFFSET[1])); - if (spawn.getBlock().getType() != Material.AIR || spawn.getBlock().getRelative(BlockFace.UP).getType() != Material.AIR || spawn.getBlock().getRelative(BlockFace.DOWN).getType() == Material.AIR) - { - boolean down = spawn.getBlock().getRelative(BlockFace.DOWN).getType() == Material.AIR; - for (int tries = 0; tries < 10; tries++) - { - if (down) - { - spawn.subtract(0, 1, 0); - if (spawn.getBlock().getRelative(BlockFace.DOWN).getType() != Material.AIR) - { - _allowSpawn = true; - NetherMinibossType.PIGMAN.getNewInstance(spawn); - _allowSpawn = false; - break; - } - } - else - { - spawn.add(0, 1, 0); - if (spawn.getBlock().getType() == Material.AIR && spawn.getBlock().getRelative(BlockFace.UP).getType() == Material.AIR) - { - _allowSpawn = true; - NetherMinibossType.PIGMAN.getNewInstance(spawn); - _allowSpawn = false; - break; - } - } - } - } - else - { - _allowSpawn = true; - NetherMinibossType.PIGMAN.getNewInstance(spawn); - _allowSpawn = false; - } - } } } } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossType.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossType.java index 8658ca2b2..938810015 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossType.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossType.java @@ -2,7 +2,6 @@ package mineplex.game.clans.clans.nether.miniboss; import mineplex.game.clans.clans.nether.miniboss.bosses.ArcherMiniboss; import mineplex.game.clans.clans.nether.miniboss.bosses.GhastMiniboss; -import mineplex.game.clans.clans.nether.miniboss.bosses.PigmanMiniboss; import mineplex.game.clans.clans.nether.miniboss.bosses.WarriorMiniboss; import org.bukkit.Location; @@ -15,8 +14,7 @@ public enum NetherMinibossType { GHAST("Ghast", 25D, EntityType.GHAST, GhastMiniboss.class), WARRIOR("Undead Warrior", 30D, EntityType.ZOMBIE, WarriorMiniboss.class), - ARCHER("Undead Archer", 25D, EntityType.SKELETON, ArcherMiniboss.class), - PIGMAN("Zombie Pigman", 30D, EntityType.PIG_ZOMBIE, PigmanMiniboss.class) + ARCHER("Undead Archer", 25D, EntityType.SKELETON, ArcherMiniboss.class) ; private Class _code; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/PigmanMiniboss.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/PigmanMiniboss.java deleted file mode 100644 index 0fc4574fc..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/PigmanMiniboss.java +++ /dev/null @@ -1,64 +0,0 @@ -package mineplex.game.clans.clans.nether.miniboss.bosses; - -import java.util.Random; - -import mineplex.core.common.util.UtilMath; -import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.clans.amplifiers.AmplifierManager; -import mineplex.game.clans.clans.nether.miniboss.NetherMiniBoss; -import mineplex.game.clans.items.runes.RuneManager.RuneAttribute; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; - -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.PigZombie; -import org.bukkit.event.EventHandler; -import org.bukkit.inventory.ItemStack; - -/** - * Class for running an individual Pigman miniboss - */ -public class PigmanMiniboss extends NetherMiniBoss -{ - private static final double IRON_SKIN_CHANCE = .33; - private static final float SOUND_VOLUME = 0.5f; - private static final float SOUND_PITCH = 1.6f; - private static final double RUNE_DROP_CHANCE = .1; - private static final int MAX_DIAMOND_DROPS = 5; - - public PigmanMiniboss(String displayName, Double maxHealth, Location spawn, EntityType type) - { - super(displayName, maxHealth, spawn, type); - } - - @Override - public void customDeath(Location deathLocation) - { - deathLocation.getWorld().dropItemNaturally(deathLocation, new ItemStack(Material.DIAMOND, UtilMath.r(MAX_DIAMOND_DROPS) + 1)); - double runeDropChance = RUNE_DROP_CHANCE; - if (ClansManager.getInstance().getAmplifierManager().hasActiveAmplifier()) - { - runeDropChance *= AmplifierManager.AMPLIFIER_RUNE_DROP_MULTIPLIER; - } - if (new Random().nextDouble() <= runeDropChance) - { - RuneAttribute runeType = RuneAttribute.values()[UtilMath.r(RuneAttribute.values().length)]; - deathLocation.getWorld().dropItemNaturally(deathLocation, ClansManager.getInstance().getGearManager().getRuneManager().getRune(runeType)); - } - } - - @EventHandler - public void onDamage(CustomDamageEvent event) - { - if (event.GetDamageeEntity() != null && event.GetDamageeEntity().equals(getEntity())) - { - if (new Random().nextDouble() <= IRON_SKIN_CHANCE) - { - event.SetCancelled("Iron Skin Deflection"); - event.GetDamageeEntity().getWorld().playSound(event.GetDamageeEntity().getLocation(), Sound.ZOMBIE_METAL, SOUND_VOLUME, SOUND_PITCH); - } - } - } -} \ No newline at end of file From 9c700425fdac9e33bb40bf689af892b610191525 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Tue, 26 Jul 2016 22:32:46 -0400 Subject: [PATCH 56/90] More javadocs --- .../src/mineplex/clanshub/ClansHub.java | 3 + .../mineplex/clanshub/ClansServerPage.java | 6 + .../mineplex/clanshub/ClansServerShop.java | 3 + .../clanshub/ClansTransferManager.java | 26 ++- .../mineplex/clanshub/ForcefieldManager.java | 10 +- .../src/mineplex/clanshub/HubManager.java | 148 +++++++++++++++--- .../clanshub/HubVisibilityManager.java | 15 +- .../mineplex/clanshub/JoinServerButton.java | 10 +- .../src/mineplex/clanshub/ServerInfo.java | 7 + .../src/mineplex/clanshub/WorldManager.java | 3 + .../clanshub/commands/ForcefieldRadius.java | 3 + .../clanshub/commands/GadgetToggle.java | 3 + .../clanshub/commands/GameModeCommand.java | 3 + .../clanshub/profile/buttons/ButtonPrefs.java | 3 + .../clanshub/profile/buttons/ButtonStats.java | 3 + .../clanshub/profile/gui/GUIProfile.java | 3 + 16 files changed, 220 insertions(+), 29 deletions(-) diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java index 9360191e5..3b40034b0 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java @@ -56,6 +56,9 @@ import mineplex.minecraft.game.core.damage.DamageManager; import org.bukkit.Bukkit; import org.bukkit.plugin.java.JavaPlugin; +/** + * Main class for clans hub + */ public class ClansHub extends JavaPlugin { private String WEB_CONFIG = "webServer"; diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansServerPage.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansServerPage.java index 9d1f26115..a561d15fc 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansServerPage.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansServerPage.java @@ -15,6 +15,9 @@ import mineplex.game.clans.core.repository.tokens.SimpleClanToken; import org.bukkit.Material; import org.bukkit.entity.Player; +/** + * GUI page for clans servers + */ public class ClansServerPage extends ShopPageBase { public ClansServerPage(ClansTransferManager plugin, ClansServerShop shop, CoreClientManager clientManager, @@ -136,6 +139,9 @@ public class ClansServerPage extends ShopPageBase { public ClansServerShop(ClansTransferManager plugin, CoreClientManager clientManager, DonationManager donationManager) diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansTransferManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansTransferManager.java index fb16e0e0b..522b83199 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansTransferManager.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansTransferManager.java @@ -35,6 +35,9 @@ import org.bukkit.plugin.java.JavaPlugin; import com.google.common.collect.Lists; +/** + * Server selection controller for clans + */ public class ClansTransferManager extends MiniDbClientPlugin { private static final long SERVER_RELOAD_INTERVAL = 5000; @@ -58,11 +61,19 @@ public class ClansTransferManager extends MiniDbClientPlugin _serverShop = new ClansServerShop(this, client, donation); } + /** + * Gets the stored party manager + * @return The stored party manager + */ public PartyManager getPartyManager() { return _party; } + /** + * Gets a list of all loaded servers + * @return A list of all loaded servers + */ public List getServers() { List servers = Lists.newArrayList(); @@ -70,6 +81,11 @@ public class ClansTransferManager extends MiniDbClientPlugin return servers; } + /** + * Gets the loaded ServerInfo with the given name + * @param name The name to check + * @return The loaded ServerInfo, or null if it is not stored + */ public ServerInfo getServer(String name) { for (ServerInfo server : _servers.values()) @@ -82,7 +98,10 @@ public class ClansTransferManager extends MiniDbClientPlugin return null; } - + + /** + * Pulls all the clans servers from redis and loads them. SHOULD BE RUN ASYNC + */ public void reload() { _servers.clear(); @@ -96,6 +115,11 @@ public class ClansTransferManager extends MiniDbClientPlugin } } + /** + * Selects a server to send a player to + * @param player The player to send + * @param serverInfo The server to send the player to + */ public void selectServer(Player player, ServerInfo serverInfo) { Party party = _party.getParty(player); diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ForcefieldManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ForcefieldManager.java index 20f1752d3..78146700a 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ForcefieldManager.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ForcefieldManager.java @@ -20,6 +20,9 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerQuitEvent; +/** + * Manager for player forcefields + */ public class ForcefieldManager extends MiniPlugin { public HubManager Manager; @@ -71,7 +74,12 @@ public class ForcefieldManager extends MiniPlugin } } } - + + /** + * Handles the radius from a command and sets a player's forcefield to it + * @param caller The caller of the command + * @param args The args of the command + */ public void ForcefieldRadius(Player caller, String[] args) { try diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java index b5a5d12a3..26f7065f6 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java @@ -31,7 +31,6 @@ import mineplex.core.common.util.UtilWorld; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.customdata.CustomDataManager; import mineplex.core.disguise.DisguiseManager; -import mineplex.core.disguise.PlayerDisguiseManager; import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguiseWither; import mineplex.core.donation.DonationManager; @@ -114,6 +113,9 @@ import org.bukkit.scoreboard.DisplaySlot; import org.bukkit.scoreboard.Objective; import org.bukkit.scoreboard.Scoreboard; +/** + * Main manager for clans hub + */ public class HubManager extends MiniPlugin { private BlockRestore _blockRestore; @@ -260,7 +262,7 @@ public class HubManager extends MiniPlugin addCommand(new GadgetToggle(this)); addCommand(new GameModeCommand(this)); } - + @EventHandler(priority = EventPriority.HIGHEST) public void reflectMotd(ServerListPingEvent event) { @@ -269,7 +271,12 @@ public class HubManager extends MiniPlugin event.setMotd("Restarting soon"); } } - + + /** + * Checks if an entity can be bumped + * @param ent The entity to check + * @return Whether the entity can be bumped + */ public boolean BumpDisabled(Entity ent) { if (ent == null) @@ -333,7 +340,7 @@ public class HubManager extends MiniPlugin { public void run() { - _portal.sendPlayerToServer(event.getPlayer(), "Lobby"); + _portal.sendPlayerToServer(event.getPlayer(), "ClansHub"); } }); @@ -654,87 +661,155 @@ public class HubManager extends MiniPlugin UtilTextBottom.display(C.cGray + "Visit " + F.elem("http://www.mineplex.com/shop") + " for exclusive perks!", player); }); } - + + /** + * Gets the loaded BlockRestore manager + * @return The loaded BlockRestore manager + */ public BlockRestore GetBlockRestore() { return _blockRestore; } - + + /** + * Gets the loaded CoreClient manager + * @return The loaded CoreClient manager + */ public CoreClientManager GetClients() { return _clientManager; } - + + /** + * Gets the loaded Condition manager + * @return The loaded Condition manager + */ public ConditionManager GetCondition() { return _conditionManager; } - + + /** + * Gets the loaded Donation manager + * @return The loaded Donation manager + */ public DonationManager GetDonation() { return _donationManager; } - + + /** + * Gets the loaded Disguise manager + * @return The loaded Disguise manager + */ public DisguiseManager GetDisguise() { return _disguiseManager; } - + + /** + * Gets the loaded Gadget manager + * @return The loaded Gadget manager + */ public GadgetManager GetGadget() { return _gadgetManager; } - + + /** + * Gets the loaded Treasure manager + * @return The loaded Treasure manager + */ public TreasureManager GetTreasure() { return _treasureManager; } - + + /** + * Gets the loaded Mount manager + * @return The loaded Mount manager + */ public MountManager GetMount() { return _mountManager; } - + + /** + * Gets the loaded Preferences manager + * @return The loaded Preferences manager + */ public PreferencesManager getPreferences() { return _preferences; } - + + /** + * Gets the lobby's spawn + * @return The lobby's spawn + */ public Location GetSpawn() { return _spawn.clone(); } - + + /** + * Gets the loaded Pet manager + * @return The loaded Pet manager + */ public PetManager getPetManager() { return _petManager; } + /** + * Gets the loaded Bonus manager + * @return The loaded Bonus manager + */ public BonusManager getBonusManager() { return _bonusManager; } - + + /** + * Gets the loaded Stats manager + * @return The loaded Stats manager + */ public StatsManager GetStats() { return _statsManager; } - + + /** + * Gets the loaded HubVisibility manager + * @return The loaded HubVisibility manager + */ public HubVisibilityManager GetVisibility() { return _visibilityManager; } - + + /** + * Gets the loaded CustomData manager + * @return The loaded CustomData manager + */ public CustomDataManager getCustomDataManager() { return _customDataManager; } + /** + * Gets the loaded Punishment manager + * @return The loaded Punishment manager + */ public Punish getPunishments() { return _punishManager; } + /** + * Gets the loaded Incognito manager + * @return The loaded Incognito manager + */ public IncognitoManager getIncognitoManager() { return _incognito; @@ -748,7 +823,11 @@ public class HubManager extends MiniPlugin SetPortalDelay(event.getOther()); } } - + + /** + * Updates a player's portal delay start to be now + * @param ent The player to set delay for + */ public void SetPortalDelay(Entity ent) { if (ent instanceof Player) @@ -756,7 +835,12 @@ public class HubManager extends MiniPlugin _portalTime.put(((Player)ent).getName(), System.currentTimeMillis()); } } - + + /** + * Checks if a player can portal yet + * @param The player to check + * @return Whether a player can portal yet + */ public boolean CanPortal(Player player) { //Riding @@ -778,12 +862,19 @@ public class HubManager extends MiniPlugin event.setCancelled(true); } } - + + /** + * Toggles all gadgets on or off via command + * @param caller The player who issued the command + */ public void ToggleGadget(Player caller) { toggleGadget(); } - + + /** + * Toggles gadget access on or off in this lobby + */ public void toggleGadget() { GetGadget().toggleGadgetEnabled(); @@ -791,7 +882,12 @@ public class HubManager extends MiniPlugin for (Player player : UtilServer.getPlayers()) player.sendMessage(C.cWhite + C.Bold + "Gadgets/Mounts are now " + F.elem(GetGadget().isGadgetEnabled() ? C.cGreen + C.Bold + "Enabled" : C.cRed + C.Bold + "Disabled")); } - + + /** + * Sets a player's gamemode via command + * @param caller The issuer of the command + * @param target The player whose gamemode should be set + */ public void addGameMode(Player caller, Player target) { if (!_creativeAdmin.containsKey(caller.getName())) @@ -847,7 +943,11 @@ public class HubManager extends MiniPlugin UtilPlayer.message(player, F.main("Game Mode", event.getPlayer().getName() + " left the game. Creative Mode: " + F.tf(false))); } } - + + /** + * Gets the loaded PacketHandler + * @return The loaded PacketHandler + */ public PacketHandler getPacketHandler() { return _packetHandler; diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubVisibilityManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubVisibilityManager.java index 4e2088aa8..d38ca5d11 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubVisibilityManager.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubVisibilityManager.java @@ -14,6 +14,9 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerQuitEvent; +/** + * Manager for Hub Visibility of players + */ public class HubVisibilityManager extends MiniPlugin { public HubManager Manager; @@ -26,13 +29,21 @@ public class HubVisibilityManager extends MiniPlugin Manager = manager; } - + + /** + * Force sets a player as hidden + * @param player The player to set + */ public void addHiddenPlayer(Player player) { _hiddenPlayers.add(player); } - + + /** + * Force unsets a player as hidden + * @param player The player to unset + */ public void removeHiddenPlayer(Player player) { _hiddenPlayers.remove(player); diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/JoinServerButton.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/JoinServerButton.java index c28510a35..658accdf4 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/JoinServerButton.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/JoinServerButton.java @@ -7,6 +7,9 @@ import mineplex.core.shop.page.ShopPageBase; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; +/** + * GUI button to select a server from a display + */ public class JoinServerButton implements IButton { private ShopPageBase _page; @@ -26,6 +29,11 @@ public class JoinServerButton implements IButton selectServer(player, _serverInfo); } + /** + * Selects a server to send a player to + * @param player The player to send + * @param serverInfo The server to send the player to + */ public void selectServer(Player player, ServerInfo serverInfo) { if (serverInfo != null) @@ -47,4 +55,4 @@ public class JoinServerButton implements IButton _page.playDenySound(player); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ServerInfo.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ServerInfo.java index 9624ee5b8..1bb5643db 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ServerInfo.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ServerInfo.java @@ -1,11 +1,18 @@ package mineplex.clanshub; +/** + * Data class for loaded servers + */ public class ServerInfo { public String Name; public int CurrentPlayers = 0; public int MaxPlayers = 0; + /** + * Checks how many slots are left on this server + * @return The amount of slots that are left on this server + */ public int getAvailableSlots() { return MaxPlayers - CurrentPlayers; diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/WorldManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/WorldManager.java index e91694063..577bbb7e1 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/WorldManager.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/WorldManager.java @@ -34,6 +34,9 @@ import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.event.weather.WeatherChangeEvent; +/** + * Manager for the hub world + */ public class WorldManager extends MiniPlugin { public HubManager Manager; diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/ForcefieldRadius.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/ForcefieldRadius.java index 2b6c166ed..113cfacf3 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/ForcefieldRadius.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/ForcefieldRadius.java @@ -6,6 +6,9 @@ import mineplex.core.common.Rank; import org.bukkit.entity.Player; +/** + * Command for controlling forcefield radius + */ public class ForcefieldRadius extends CommandBase { public ForcefieldRadius(ForcefieldManager plugin) diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/GadgetToggle.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/GadgetToggle.java index 974b73f2f..c30b61fae 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/GadgetToggle.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/GadgetToggle.java @@ -6,6 +6,9 @@ import mineplex.core.common.Rank; import org.bukkit.entity.Player; +/** + * Command for toggling gadgets + */ public class GadgetToggle extends CommandBase { public GadgetToggle(HubManager plugin) diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/GameModeCommand.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/GameModeCommand.java index aaf978085..f79e55f38 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/GameModeCommand.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/GameModeCommand.java @@ -9,6 +9,9 @@ import mineplex.core.common.util.UtilPlayer; import org.bukkit.GameMode; import org.bukkit.entity.Player; +/** + * Command for setting gamemode + */ public class GameModeCommand extends CommandBase { public GameModeCommand(HubManager plugin) diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/profile/buttons/ButtonPrefs.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/profile/buttons/ButtonPrefs.java index 39f535112..39c16f1c6 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/profile/buttons/ButtonPrefs.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/profile/buttons/ButtonPrefs.java @@ -10,6 +10,9 @@ import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; +/** + * Button to open preferences menu + */ public class ButtonPrefs implements GuiItem { private GUIProfile _profile; diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/profile/buttons/ButtonStats.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/profile/buttons/ButtonStats.java index b53c707bb..4b3833618 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/profile/buttons/ButtonStats.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/profile/buttons/ButtonStats.java @@ -12,6 +12,9 @@ import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.SkullMeta; +/** + * Button to open stats menu + */ public class ButtonStats implements GuiItem { private GUIProfile _profile; diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/profile/gui/GUIProfile.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/profile/gui/GUIProfile.java index 2f243c289..e14ab7fc4 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/profile/gui/GUIProfile.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/profile/gui/GUIProfile.java @@ -9,6 +9,9 @@ import mineplex.core.preferences.PreferencesManager; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; +/** + * Profile GUI + */ public class GUIProfile extends SimpleGui { private PreferencesManager _preferencesManager; From 85cf005ebab54b27b6fc6fa72c9f7fd1c609d396 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Tue, 26 Jul 2016 22:33:19 -0400 Subject: [PATCH 57/90] Small clans economy changes --- .../src/mineplex/game/clans/clans/ClansAdmin.java | 10 ++++++++++ .../src/mineplex/game/clans/shop/ClansShopItem.java | 6 +++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAdmin.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAdmin.java index 65aad970a..1c11b514b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAdmin.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAdmin.java @@ -345,6 +345,8 @@ public class ClansAdmin Clans.getClanDataAccess().updateWar(clan, clanAgainst, war, success -> { UtilPlayer.message(caller, F.main("Clans Admin", "Updated war points against " + F.elem(war.getClanB()))); + Clans.messageClan(clan, F.main("Clans", "Your war points with " + F.elem(clanAgainst.getName()) + " have been edited by " + F.elem(caller.getName()) + "!")); + Clans.messageClan(clanAgainst, F.main("Clans", "Your war points with " + F.elem(clan.getName()) + " have been edited by " + F.elem(caller.getName()) + "!")); }); } else @@ -364,6 +366,8 @@ public class ClansAdmin Clans.getClanDataAccess().updateWar(clan, clanAgainst, war, success -> { UtilPlayer.message(caller, F.main("Clans Admin", "Updated war points against " + F.elem(war.getClanB()))); + Clans.messageClan(clan, F.main("Clans", "Your war points with " + F.elem(clanAgainst.getName()) + " have been edited by " + F.elem(caller.getName()) + "!")); + Clans.messageClan(clanAgainst, F.main("Clans", "Your war points with " + F.elem(clan.getName()) + " have been edited by " + F.elem(caller.getName()) + "!")); }); } else @@ -374,6 +378,8 @@ public class ClansAdmin public void run(ClanWarData data) { UtilPlayer.message(caller, F.main("Clans Admin", "Updated war points against " + F.elem(data.getClanB()))); + Clans.messageClan(clan, F.main("Clans", "Your war points with " + F.elem(clanAgainst.getName()) + " have been edited by " + F.elem(caller.getName()) + "!")); + Clans.messageClan(clanAgainst, F.main("Clans", "Your war points with " + F.elem(clan.getName()) + " have been edited by " + F.elem(caller.getName()) + "!")); } }); } @@ -389,6 +395,8 @@ public class ClansAdmin Clans.getClanDataAccess().updateWar(clan, clanAgainst, war, success -> { UtilPlayer.message(caller, F.main("Clans Admin", "Updated war points against " + F.elem(war.getClanB()))); + Clans.messageClan(clan, F.main("Clans", "Your war points with " + F.elem(clanAgainst.getName()) + " have been edited by " + F.elem(caller.getName()) + "!")); + Clans.messageClan(clanAgainst, F.main("Clans", "Your war points with " + F.elem(clan.getName()) + " have been edited by " + F.elem(caller.getName()) + "!")); }); } else @@ -399,6 +407,8 @@ public class ClansAdmin public void run(ClanWarData data) { UtilPlayer.message(caller, F.main("Clans Admin", "Updated war points against " + F.elem(data.getClanB()))); + Clans.messageClan(clan, F.main("Clans", "Your war points with " + F.elem(clanAgainst.getName()) + " have been edited by " + F.elem(caller.getName()) + "!")); + Clans.messageClan(clanAgainst, F.main("Clans", "Your war points with " + F.elem(clan.getName()) + " have been edited by " + F.elem(caller.getName()) + "!")); } }); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ClansShopItem.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ClansShopItem.java index 3ba9eaff8..636854481 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ClansShopItem.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ClansShopItem.java @@ -37,7 +37,7 @@ public enum ClansShopItem BOW(175, 35, Material.BOW, 1), ARROW(10, 2, Material.ARROW, 1), ENCHANTMENT_TABLE(30000, 0, Material.ENCHANTMENT_TABLE, 1), - TNT(30000, 0, Material.TNT, 1), + TNT(20000, 0, Material.TNT, 1), TNT_GENERATOR(300000, 0, Material.BREWING_STAND_ITEM, 1), // Mining Shop IRON_INGOT(500, 100, Material.IRON_INGOT, 1), @@ -78,8 +78,8 @@ public enum ClansShopItem QUARTZ_BLOCK(75, 15, Material.QUARTZ_BLOCK, 1), CLAY(30, 6, Material.CLAY, 1), GOLD_TOKEN(50000, 50000, Material.GOLD_RECORD, 1, (byte) 0, "Gold Token"), - OUTPOST(100000, 0, Material.BEACON, 1, (byte) 0, C.cBlue + "Outpost"), - CANNON(50000, 0, Material.SPONGE, 1, (byte) 1, C.cBlue + "Cannon"); + OUTPOST(30000, 0, Material.BEACON, 1, (byte) 0, C.cBlue + "Outpost"), + CANNON(25000, 0, Material.SPONGE, 1, (byte) 1, C.cBlue + "Cannon"); private int _buyPrice; private int _sellPrice; From ea3cb36d3ab56b6f52b956eb65079a903b870c8b Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Wed, 27 Jul 2016 04:43:00 -0400 Subject: [PATCH 58/90] Clean up miniboss mobs after their chunk unloads --- .../clans/nether/miniboss/NetherMiniBoss.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMiniBoss.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMiniBoss.java index 870f9b03d..4cebeeb60 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMiniBoss.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMiniBoss.java @@ -1,5 +1,7 @@ package mineplex.game.clans.clans.nether.miniboss; +import java.util.Arrays; + import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClansManager; @@ -12,6 +14,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.event.world.ChunkUnloadEvent; /** * Base class for nether minibosses @@ -90,6 +93,18 @@ public abstract class NetherMiniBoss implements Listen } } + @EventHandler + public void onUnload(ChunkUnloadEvent event) + { + if (Arrays.asList(event.getChunk().getEntities()).contains(_entity)) + { + HandlerList.unregisterAll(this); + _entity.remove(); + customDespawn(); + return; + } + } + @EventHandler public void onUpdate(UpdateEvent event) { From d162750aec86675acf632c7db01d5300228092cc Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Wed, 27 Jul 2016 04:47:03 -0400 Subject: [PATCH 59/90] Keep nether loaded if its not empty --- .../nether/miniboss/NetherMinibossManager.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossManager.java index 1b688d330..5f28115a4 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossManager.java @@ -14,8 +14,10 @@ import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntitySpawnEvent; +import org.bukkit.event.world.ChunkUnloadEvent; import com.google.common.collect.Lists; @@ -93,6 +95,18 @@ public class NetherMinibossManager implements Listener } } + @EventHandler(priority = EventPriority.LOW) + public void onUnload(ChunkUnloadEvent event) + { + if (_manager.getNetherWorld().equals(event.getWorld())) + { + if (!_manager.InNether.isEmpty()) + { + event.setCancelled(true); + } + } + } + @EventHandler public void onSpawnThreat(UpdateEvent event) { From 157c969e8dbd5ef2346d0c93f4007cec9acfbd58 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Wed, 27 Jul 2016 05:51:49 -0400 Subject: [PATCH 60/90] Completely prevent players in parties from joining Clans servers --- .../src/mineplex/core/portal/Portal.java | 20 ++++++++++++------- .../clanshub/ClansTransferManager.java | 8 ++++++++ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java b/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java index b4ae83137..1b02de296 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java @@ -98,12 +98,18 @@ public class Portal extends MiniPlugin final boolean override = serverName.equalsIgnoreCase("Lobby") || serverName.equalsIgnoreCase("ClansHub"); final Rank playerRank = _clientManager.Get(player).GetRank(); - if(event.getParty() != null && override) + if (event.getParty() != null && override) { Party party = event.getParty(); sendParty(party); return; } + + if (event.getParty() != null && serverName.toUpperCase().startsWith("CLANS-")) + { + event.getParty().sendMessage(F.main(getName(), "You cannot join Clans while in a party!")); + return; + } if (override) { @@ -111,7 +117,7 @@ public class Portal extends MiniPlugin return; } - if(event.isCancel()) + if (event.isCancel()) { return; } @@ -139,23 +145,23 @@ public class Portal extends MiniPlugin MinecraftServer best = null; List serverList = Lists.newArrayList(repository.getServersByGroup("Lobby")); int lowest = Integer.MAX_VALUE; - for(MinecraftServer server : serverList) + for (MinecraftServer server : serverList) { int playercount = server.getPlayerCount(); - if(playercount < 20) + if (playercount < 20) { continue; } - if(playercount < lowest) + if (playercount < lowest) { lowest = playercount; - if(best == null) + if (best == null) { best = server; } } } - if(best == null) + if (best == null) { //Well, fuck. best = serverList.get(new Random().nextInt(serverList.size())); diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansTransferManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansTransferManager.java index 522b83199..15d8c24fb 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansTransferManager.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansTransferManager.java @@ -28,6 +28,7 @@ import mineplex.serverdata.Region; import mineplex.serverdata.data.MinecraftServer; import mineplex.serverdata.servers.ServerManager; +import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityPortalEnterEvent; @@ -193,6 +194,13 @@ public class ClansTransferManager extends MiniDbClientPlugin UtilAction.velocity(player, UtilAlg.getTrajectory(player.getLocation(), _hub.GetSpawn()), 1, true, 0.5, 0, 1.0, true); return; } + if (_party.getParty(player) != null) + { + player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1, .6f); + player.sendMessage(F.main("Party", "You cannot join Clans while in a party.")); + UtilAction.velocity(player, UtilAlg.getTrajectory(player.getLocation(), _hub.GetSpawn()), 1, true, 0.5, 0, 1.0, true); + return; + } if (!Recharge.Instance.use(player, "Transfer Portal", 5000, false, false)) { From 3d0cc2a5fd4e03417ed3055e16d5e0f62cc5fd0b Mon Sep 17 00:00:00 2001 From: cnr Date: Mon, 25 Jul 2016 19:57:07 -0500 Subject: [PATCH 61/90] Refactor Clans gold dependency out of core --- .../mineplex/core/common/CurrencyType.java | 41 --- .../core/common/currency/Currency.java | 41 +++ .../core/common/currency/GlobalCurrency.java | 17 ++ .../src/mineplex/core/common/util/F.java | 7 +- .../mineplex/core/common/util/UtilText.java | 13 +- .../bonuses/gui/buttons/ClaimTipsButton.java | 26 +- .../core/boosters/command/ThankCommand.java | 6 +- .../fountain/GemFountainSalesPackage.java | 11 +- .../brawl/fountain/command/AddCommand.java | 4 +- .../core/brawl/fountain/gui/FountainPage.java | 4 +- .../gui/button/FountainAddButton.java | 4 +- .../core/cosmetic/ui/CosmeticShop.java | 16 +- .../core/cosmetic/ui/button/MountButton.java | 13 +- .../core/cosmetic/ui/page/CostumePage.java | 13 +- .../core/cosmetic/ui/page/GadgetPage.java | 91 ++++--- .../mineplex/core/cosmetic/ui/page/Menu.java | 30 +-- .../core/cosmetic/ui/page/MountPage.java | 49 ++-- .../core/cosmetic/ui/page/PetPage.java | 61 ++--- .../core/cosmetic/ui/page/PetTagPage.java | 5 +- .../core/donation/DonationManager.java | 233 +++--------------- .../src/mineplex/core/donation/Donor.java | 91 ++----- .../repository/DonationRepository.java | 73 +----- .../mineplex/core/gadget/gadgets/Ammo.java | 10 +- .../core/gadget/gadgets/morph/MorphBunny.java | 49 ++-- .../gadget/gadgets/morph/MorphVillager.java | 39 ++- .../mineplex/core/gadget/types/Gadget.java | 14 +- .../src/mineplex/core/mount/Mount.java | 22 +- .../src/mineplex/core/pet/Pet.java | 12 +- .../src/mineplex/core/pet/PetExtra.java | 11 +- .../reward/rewards/UnknownPackageReward.java | 9 +- .../core/scoreboard/ScoreboardData.java | 10 +- .../elements/ScoreboardElementCoinCount.java | 11 +- .../elements/ScoreboardElementGemCount.java | 11 +- .../elements/ScoreboardElementGoldCount.java | 20 -- .../src/mineplex/core/shop/ShopBase.java | 36 +-- .../core/shop/item/ICurrencyPackage.java | 4 +- .../core/shop/item/SalesPackageBase.java | 19 +- .../core/shop/page/ConfirmationPage.java | 34 ++- .../mineplex/core/shop/page/ShopPageBase.java | 50 +--- .../core/tournament/ui/TournamentShop.java | 6 +- .../mineplex/core/treasure/ChestPackage.java | 11 +- .../mineplex/core/treasure/TreasureKey.java | 11 +- .../core/treasure/gui/BuyChestButton.java | 13 +- .../core/treasure/gui/TreasurePage.java | 30 +-- .../src/mineplex/enjinTranslator/Enjin.java | 31 ++- .../game/clans/clans/ClansManager.java | 5 + .../elements/ScoreboardElementPlayer.java | 12 +- .../ScoreboardElementPlayerCount.java | 12 +- .../game/clans/economy/ClansCurrency.java | 9 + .../game/clans/economy}/GoldCommand.java | 12 +- .../mineplex/game/clans/economy/GoldData.java | 18 ++ .../game/clans/economy/GoldManager.java | 182 ++++++++++---- .../game/clans/economy/GoldRepository.java | 52 ++++ .../game/clans/economy}/SetGoldCommand.java | 6 +- .../game/clans/shop/energy/EnergyPackage.java | 14 +- .../clans/shop/energy/EnergyShopButton.java | 9 +- .../game/clans/shop/pvp/tnt/TNTGenPage.java | 22 +- .../src/mineplex/hub/HubManager.java | 6 +- .../hub/modules/ValentinesManager.java | 20 +- .../classcombat/shop/ClassCombatShop.java | 30 ++- .../game/classcombat/shop/page/SkillPage.java | 19 +- .../shop/salespackage/ItemSalesPackage.java | 14 +- .../shop/salespackage/SkillSalesPackage.java | 14 +- .../customerSupport/CustomerSupport.java | 20 +- .../command/GemHunterCommand.java | 7 +- .../salespackage/command/ItemCommand.java | 11 +- .../arcade/booster/GameBoosterManager.java | 9 +- .../arcade/game/games/event/EventGame.java | 40 +-- .../game/games/halloween/Halloween.java | 43 +--- .../games/searchanddestroy/KitEvolveShop.java | 10 +- .../games/wizards/WizardSpellMenuShop.java | 6 +- .../gui/spectatorMenu/SpectatorShop.java | 8 +- .../game/arcade/kit/ProgressingKit.java | 8 +- .../arcade/managers/GameLobbyManager.java | 5 +- .../arcade/managers/GameRewardManager.java | 36 ++- .../nautilus/game/arcade/shop/ArcadeShop.java | 8 +- .../nautilus/game/arcade/shop/KitPackage.java | 14 +- 77 files changed, 771 insertions(+), 1222 deletions(-) delete mode 100644 Plugins/Mineplex.Core.Common/src/mineplex/core/common/CurrencyType.java create mode 100644 Plugins/Mineplex.Core.Common/src/mineplex/core/common/currency/Currency.java create mode 100644 Plugins/Mineplex.Core.Common/src/mineplex/core/common/currency/GlobalCurrency.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElementGoldCount.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/ClansCurrency.java rename Plugins/{Mineplex.Core/src/mineplex/core/donation/command => Mineplex.Game.Clans/src/mineplex/game/clans/economy}/GoldCommand.java (88%) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldData.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldRepository.java rename Plugins/{Mineplex.Core/src/mineplex/core/donation/command => Mineplex.Game.Clans/src/mineplex/game/clans/economy}/SetGoldCommand.java (92%) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/CurrencyType.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/CurrencyType.java deleted file mode 100644 index 550a761a7..000000000 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/CurrencyType.java +++ /dev/null @@ -1,41 +0,0 @@ -package mineplex.core.common; - -import mineplex.core.common.util.C; -import org.bukkit.Material; - -public enum CurrencyType -{ - TOKEN("Tokens", "Token", C.cWhite, Material.EMERALD), - TREASURE_SHARD("Treasure Shards", "Treasure Shard", C.cAqua, Material.PRISMARINE_SHARD), - GEM("Gems", "Gem", C.cGreen, Material.EMERALD), - GOLD("Gold", "Gold", C.cGold, Material.GOLD_NUGGET); - - private String _plural; - private String _single; - private String _color; - private Material _displayMaterial; - - CurrencyType(String plural, String single, String color, Material displayMaterial) - { - _plural = plural; - _single = single; - _color = color; - _displayMaterial = displayMaterial; - } - - @Deprecated - public String getPrefix() - { - return _plural; - } - - public String getString(int amount) - { - return _color + amount + " " + (amount == 1 ? _single : _plural); - } - - public Material getDisplayMaterial() - { - return _displayMaterial; - } -} diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/currency/Currency.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/currency/Currency.java new file mode 100644 index 000000000..f82182bb6 --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/currency/Currency.java @@ -0,0 +1,41 @@ +package mineplex.core.common.currency; + +import org.bukkit.Material; + +/** + * Currency is the base class for all currency types in mineplex: + * - Global currencies, found in {@link GlobalCurrency}, e.g., treasure shards + * - Clans gold, found in the Mineplex.Game.Clans project + */ +public class Currency +{ + private final String _plural; + private final String _singular; + private final String _color; + private final Material _displayMaterial; + + public Currency(String plural, String singular, String color, Material displayMaterial) + { + this._plural = plural; + this._singular = singular; + this._color = color; + this._displayMaterial = displayMaterial; + } + + @Deprecated + public String getPrefix() + { + return _plural; + } + + public String getString(int amount) + { + return _color + amount + " " + (amount == 1 ? _singular : _plural); + } + + public Material getDisplayMaterial() + { + return _displayMaterial; + } +} + diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/currency/GlobalCurrency.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/currency/GlobalCurrency.java new file mode 100644 index 000000000..1e6b6bc03 --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/currency/GlobalCurrency.java @@ -0,0 +1,17 @@ +package mineplex.core.common.currency; + +import mineplex.core.common.util.C; +import org.bukkit.Material; + +/** + * A GlobalCurrency is one whose state is shared between all Mineplex servers. + * GlobalCurrencies can be retrieved and modified through DonationManager/Donor in Mineplex.Core + */ +public class GlobalCurrency extends Currency { + public static final GlobalCurrency TREASURE_SHARD = new GlobalCurrency("Treasure Shards", "Treasure Shard", C.cAqua, Material.PRISMARINE_SHARD); + public static final GlobalCurrency GEM = new GlobalCurrency("Gems", "Gem", C.cGreen, Material.EMERALD); + + public GlobalCurrency(String plural, String singular, String color, Material displayMaterial) { + super(plural, singular, color, displayMaterial); + } +} diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/F.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/F.java index 8c58e0ef8..03bbec0a3 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/F.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/F.java @@ -1,10 +1,7 @@ package mineplex.core.common.util; -import mineplex.core.common.CurrencyType; import mineplex.core.common.Rank; - -import java.util.LinkedList; - +import mineplex.core.common.currency.Currency; import org.bukkit.ChatColor; public class F @@ -201,7 +198,7 @@ public class F return out; } - public static String currency(CurrencyType type, int amount) + public static String currency(Currency type, int amount) { return type.getString(amount) + ChatColor.RESET + C.mBody; } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java index d0825126d..0867db6d4 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java @@ -1,5 +1,9 @@ package mineplex.core.common.util; +import org.apache.commons.lang.WordUtils; +import org.bukkit.ChatColor; + +import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import java.io.IOException; import java.io.InputStream; @@ -7,13 +11,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; -import javax.imageio.ImageIO; - -import org.apache.commons.lang.WordUtils; -import org.bukkit.ChatColor; - -import mineplex.core.common.CurrencyType; - public class UtilText { private static HashMap _characters = new HashMap<>(); @@ -25,7 +22,7 @@ public class UtilText { try { - InputStream inputStream = CurrencyType.class.getResourceAsStream("/ascii.png"); + InputStream inputStream = UtilText.class.getResourceAsStream("/ascii.png"); BufferedImage image = ImageIO.read(inputStream); char[] text = new char[] diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/ClaimTipsButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/ClaimTipsButton.java index a0d53216e..e8a3d062d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/ClaimTipsButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/ClaimTipsButton.java @@ -1,41 +1,27 @@ package mineplex.core.bonuses.gui.buttons; -import java.util.ArrayList; - +import mineplex.core.bonuses.BonusManager; import mineplex.core.boosters.BoosterManager; -import mineplex.core.common.CurrencyType; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; -import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; 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.gui.pages.LoadingWindow; import mineplex.core.gui.pages.TimedMessageWindow; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.shop.item.ShopItem; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.core.bonuses.BonusAmount; -import mineplex.core.bonuses.BonusClientData; -import mineplex.core.bonuses.BonusManager; -import mineplex.core.bonuses.StreakRecord; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.DyeColor; -import org.bukkit.Material; -import org.bukkit.Sound; +import org.bukkit.*; import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; 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; +import java.util.ArrayList; + public class ClaimTipsButton implements GuiItem, Listener { private ItemStack _item; @@ -87,7 +73,7 @@ public class ClaimTipsButton implements GuiItem, Listener new TimedMessageWindow(getPlugin(), getPlayer(), ItemStackFactory.Instance.CreateStack(Material.STAINED_GLASS_PANE, DyeColor.LIME.getData(), 1, ChatColor.GREEN + "Amplifier Thanks Collected"), "Thanks Collected", 6*9, 20*3, getGui()).openInventory(); } - UtilPlayer.message(getPlayer(), F.main("Carl", "You collected " + F.currency(CurrencyType.TREASURE_SHARD, claimed) + " from Amplifiers!")); + UtilPlayer.message(getPlayer(), F.main("Carl", "You collected " + F.currency(GlobalCurrency.TREASURE_SHARD, claimed) + " from Amplifiers!")); // Pending explosions are strange.. Not sure why we are using strings. Either way, lets display a rank reward effect _bonusManager.addPendingExplosion(getPlayer(), "RANK"); getPlayer().playSound(getPlayer().getLocation(), Sound.NOTE_PLING, 1, 1.6f); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/ThankCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/ThankCommand.java index 686fd9c58..0670ce643 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/ThankCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/ThankCommand.java @@ -5,8 +5,8 @@ import mineplex.core.boosters.BoosterManager; import mineplex.core.boosters.tips.BoosterTipManager; import mineplex.core.boosters.tips.TipAddResult; import mineplex.core.command.CommandBase; -import mineplex.core.common.CurrencyType; import mineplex.core.common.Rank; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import org.apache.commons.lang3.StringUtils; @@ -60,8 +60,8 @@ public class ThankCommand extends CommandBase { if (result == TipAddResult.SUCCESS) { - UtilPlayer.message(caller, F.main("Tip", "You thanked " + F.name(booster.getPlayerName()) + ". They earned " + F.currency(CurrencyType.TREASURE_SHARD, BoosterTipManager.TIP_FOR_SPONSOR) + " and you got " - + F.currency(CurrencyType.TREASURE_SHARD, BoosterTipManager.TIP_FOR_TIPPER)) + " in return!"); + UtilPlayer.message(caller, F.main("Tip", "You thanked " + F.name(booster.getPlayerName()) + ". They earned " + F.currency(GlobalCurrency.TREASURE_SHARD, BoosterTipManager.TIP_FOR_SPONSOR) + " and you got " + + F.currency(GlobalCurrency.TREASURE_SHARD, BoosterTipManager.TIP_FOR_TIPPER)) + " in return!"); caller.playSound(caller.getLocation(), Sound.LEVEL_UP, 1f, 1f); } else if (result.getFriendlyMessage() != null) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/GemFountainSalesPackage.java b/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/GemFountainSalesPackage.java index 6018772f0..d0ba3e882 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/GemFountainSalesPackage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/GemFountainSalesPackage.java @@ -1,9 +1,8 @@ package mineplex.core.brawl.fountain; -import mineplex.core.common.CurrencyType; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.shop.item.SalesPackageBase; import org.bukkit.Material; -import org.bukkit.entity.Player; /** * @author Shaun Bennett @@ -14,14 +13,8 @@ public class GemFountainSalesPackage extends SalesPackageBase { super("Add " + gems + " Gems", Material.EMERALD, (byte) 0, new String[] {}, gems, 1); - CurrencyCostMap.put(CurrencyType.GEM, gems); + CurrencyCostMap.put(GlobalCurrency.GEM, gems); KnownPackage = false; OneTimePurchaseOnly = false; } - - @Override - public void sold(Player player, CurrencyType currencyType) - { - - } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/command/AddCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/command/AddCommand.java index cd1bf65a5..8e108093c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/command/AddCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/command/AddCommand.java @@ -2,8 +2,8 @@ package mineplex.core.brawl.fountain.command; import mineplex.core.brawl.fountain.FountainManager; import mineplex.core.command.CommandBase; -import mineplex.core.common.CurrencyType; import mineplex.core.common.Rank; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -53,7 +53,7 @@ public class AddCommand extends CommandBase UtilPlayer.message(caller, F.main("Fountain", "There was an error processing your request!")); } } - }, caller, "GemFountain.Add", CurrencyType.GEM, amount, false); + }, caller, "GemFountain.Add", GlobalCurrency.GEM, amount, false); } catch (NumberFormatException ex) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/gui/FountainPage.java b/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/gui/FountainPage.java index 61d5d8427..dc3fb9c64 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/gui/FountainPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/gui/FountainPage.java @@ -4,8 +4,8 @@ import mineplex.core.account.CoreClientManager; import mineplex.core.brawl.fountain.Fountain; import mineplex.core.brawl.fountain.FountainManager; import mineplex.core.brawl.fountain.gui.button.FountainAddButton; -import mineplex.core.common.CurrencyType; import mineplex.core.common.MaterialData; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; import mineplex.core.donation.DonationManager; import mineplex.core.shop.item.ShopItem; @@ -77,7 +77,7 @@ public class FountainPage extends ShopPageBase if (canAdd) { - int playerGems = getDonationManager().Get(getPlayer()).GetGems(); + int playerGems = getDonationManager().Get(getPlayer()).getBalance(GlobalCurrency.GEM); ShopItem add1 = new ShopItem(Material.EMERALD, "Add 100 Gems", new String[]{}, 1, playerGems < 100, false); ShopItem add2 = new ShopItem(Material.EMERALD, "Add 1,000 Gems", new String[]{}, 64, playerGems < 1000, false); ShopItem add3 = new ShopItem(Material.EMERALD_BLOCK, "Add 10,000 Gems", new String[]{}, 1, playerGems < 10000, false); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/gui/button/FountainAddButton.java b/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/gui/button/FountainAddButton.java index c37c8c551..622b44add 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/gui/button/FountainAddButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/gui/button/FountainAddButton.java @@ -4,7 +4,7 @@ import mineplex.core.brawl.fountain.FountainManager; import mineplex.core.brawl.fountain.GemFountainSalesPackage; import mineplex.core.brawl.fountain.gui.FountainPage; import mineplex.core.brawl.fountain.gui.FountainShop; -import mineplex.core.common.CurrencyType; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.SalesPackageBase; import mineplex.core.shop.page.ConfirmationPage; @@ -37,6 +37,6 @@ public class FountainAddButton implements IButton _page.getPlugin().getGemFountain().increment(player, _gems, null); _page.refresh(); } - }, _page, _salesPackage, CurrencyType.GEM, player)); + }, _page, _salesPackage, GlobalCurrency.GEM, player)); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/CosmeticShop.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/CosmeticShop.java index 271dbe895..94ec614e7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/CosmeticShop.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/CosmeticShop.java @@ -1,25 +1,23 @@ package mineplex.core.cosmetic.ui; -import mineplex.core.cosmetic.ui.page.*; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.plugin.messaging.PluginMessageListener; - import mineplex.core.account.CoreClientManager; -import mineplex.core.common.CurrencyType; import mineplex.core.cosmetic.CosmeticManager; +import mineplex.core.cosmetic.ui.page.GadgetPage; +import mineplex.core.cosmetic.ui.page.Menu; +import mineplex.core.cosmetic.ui.page.PetTagPage; import mineplex.core.donation.DonationManager; import mineplex.core.gadget.event.ItemGadgetOutOfAmmoEvent; import mineplex.core.shop.ShopBase; import mineplex.core.shop.page.ShopPageBase; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.plugin.messaging.PluginMessageListener; public class CosmeticShop extends ShopBase implements PluginMessageListener { public CosmeticShop(CosmeticManager plugin, CoreClientManager clientManager, DonationManager donationManager, String name) { - super(plugin, clientManager, donationManager, name, CurrencyType.GEM, CurrencyType.TREASURE_SHARD); + super(plugin, clientManager, donationManager, name); plugin.getPlugin().getServer().getMessenger().registerIncomingPluginChannel(plugin.getPlugin(), "MC|ItemName", this); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/MountButton.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/MountButton.java index c41b9915a..e60b042f5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/MountButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/MountButton.java @@ -1,15 +1,14 @@ package mineplex.core.cosmetic.ui.button; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; - -import mineplex.core.shop.item.IButton; -import mineplex.core.shop.page.ConfirmationPage; -import mineplex.core.common.CurrencyType; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.cosmetic.ui.CosmeticShop; import mineplex.core.cosmetic.ui.page.MountPage; import mineplex.core.mount.Mount; +import mineplex.core.shop.item.IButton; +import mineplex.core.shop.page.ConfirmationPage; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; public class MountButton implements IButton { @@ -32,6 +31,6 @@ public class MountButton implements IButton _page.getPlugin().getInventoryManager().addItemToInventory(null, player, _mount.getName(), 1); _page.refresh(); } - }, _page, _mount, CurrencyType.TREASURE_SHARD, player)); + }, _page, _mount, GlobalCurrency.TREASURE_SHARD, player)); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/CostumePage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/CostumePage.java index 525594815..218390e2c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/CostumePage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/CostumePage.java @@ -1,12 +1,7 @@ package mineplex.core.cosmetic.ui.page; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; - import mineplex.core.account.CoreClientManager; -import mineplex.core.common.CurrencyType; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.cosmetic.ui.CosmeticShop; @@ -19,6 +14,10 @@ import mineplex.core.gadget.types.ItemGadget; import mineplex.core.gadget.types.OutfitGadget; import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.ShopItem; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; /** * Created by shaun on 14-09-15. @@ -38,7 +37,7 @@ public class CostumePage extends GadgetPage for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.COSTUME)) { - if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -1) + if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -1) continue; OutfitGadget outfitGadget = ((OutfitGadget) gadget); 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 b56d4cf8e..19c2f2a8c 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,30 +1,19 @@ package mineplex.core.cosmetic.ui.page; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.banner.CountryFlag; -import mineplex.core.gadget.event.GadgetChangeEvent; -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.CurrencyType; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.banner.CountryFlag; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.cosmetic.ui.CosmeticShop; +import mineplex.core.cosmetic.ui.button.GadgetButton; import mineplex.core.cosmetic.ui.button.activate.ActivateGadgetButton; import mineplex.core.cosmetic.ui.button.deactivate.DeactivateGadgetButton; -import mineplex.core.cosmetic.ui.button.GadgetButton; import mineplex.core.donation.DonationManager; +import mineplex.core.gadget.event.GadgetChangeEvent; import mineplex.core.gadget.gadgets.morph.MorphBlock; import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetType; @@ -34,6 +23,16 @@ import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.ShopItem; import mineplex.core.shop.page.ConfirmationPage; 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; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; public class GadgetPage extends ShopPageBase { @@ -50,7 +49,7 @@ public class GadgetPage extends ShopPageBase for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.ITEM)) { - if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -3) + if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -3) continue; addGadget(gadget, slot); @@ -105,64 +104,64 @@ public class GadgetPage extends ShopPageBase if (!gadget.ownsGadget(getPlayer())) { - if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -1) + if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -1) { //Nothing } //Chest Unlocks - else if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -2 || gadget.getCost(CurrencyType.TREASURE_SHARD) > 0) + else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -2 || gadget.getCost(GlobalCurrency.TREASURE_SHARD) > 0) { itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Treasure Chests"); } - else if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -3) + else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -3) { itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Winter Holiday Treasure"); } - else if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -4) + else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -4) { itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Halloween Pumpkin Treasure"); } - else if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -5) + else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -5) { itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Easter Holiday Treasure"); } - else if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -6) + else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -6) { itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Valentines Gifts"); } - else if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -7) + else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -7) { itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Purchased from shop.mineplex.com"); } - else if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -8) + else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -8) { itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Freedom Chests"); } //Rank Unlocks - else if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -10) + else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -10) { itemLore.add(C.cBlack); itemLore.add(C.cAqua + "Unlocked with Ultra Rank"); } - else if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -11) + else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -11) { itemLore.add(C.cBlack); itemLore.add(C.cPurple + "Unlocked with Hero Rank"); } - else if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -12) + else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -12) { itemLore.add(C.cBlack); itemLore.add(C.cGreen + "Unlocked with Legend Rank"); } - else if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -13) + else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -13) { itemLore.add(C.cBlack); itemLore.add(C.cRed + "Unlocked with Titan Rank"); @@ -178,12 +177,12 @@ public class GadgetPage extends ShopPageBase itemLore.add(C.cWhite + "You own " + C.cGreen + getPlugin().getInventoryManager().Get(getPlayer()).getItemCount(gadget.getName())); // boolean canAffordAmmo = true; -// if (itemGadget.getAmmo().getCost(CurrencyType.Coins) > 0) +// if (itemGadget.getAmmo().getCost(GlobalCurrency.Coins) > 0) // { // itemLore.add(C.cBlack); -// itemLore.add(C.cWhite + ((ItemGadget)gadget).getAmmo().getDisplayName() + " for " + C.cYellow + ((ItemGadget)gadget).getAmmo().getCost(CurrencyType.Coins) + " Coins"); +// itemLore.add(C.cWhite + ((ItemGadget)gadget).getAmmo().getDisplayName() + " for " + C.cYellow + ((ItemGadget)gadget).getAmmo().getCost(GlobalCurrency.Coins) + " Coins"); // -// if (getDonationManager().Get(getPlayer().getName()).GetBalance(CurrencyType.Coins) >= itemGadget.getAmmo().getCost(CurrencyType.Coins)) +// if (getDonationManager().Get(getPlayer().getName()).getBalance(GlobalCurrency.Coins) >= itemGadget.getAmmo().getCost(GlobalCurrency.Coins)) // { // itemLore.add(C.cGreen + "Right-Click To Purchase"); // } @@ -239,26 +238,26 @@ public class GadgetPage extends ShopPageBase } else { - if (gadget.getCost(CurrencyType.TREASURE_SHARD) > 0) + if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) > 0) { itemLore.add(C.cBlack); - itemLore.add(C.cWhiteB + "Cost: " + C.cAqua + gadget.getCost(CurrencyType.TREASURE_SHARD) + " Treasure Shards"); + itemLore.add(C.cWhiteB + "Cost: " + C.cAqua + gadget.getCost(GlobalCurrency.TREASURE_SHARD) + " Treasure Shards"); } - if (gadget.getCost(CurrencyType.TREASURE_SHARD) > 0 && getDonationManager().Get(getPlayer().getName()).GetBalance(CurrencyType.TREASURE_SHARD) >= gadget.getCost(CurrencyType.TREASURE_SHARD)) + if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) > 0 && getDonationManager().Get(getPlayer().getName()).getBalance(GlobalCurrency.TREASURE_SHARD) >= gadget.getCost(GlobalCurrency.TREASURE_SHARD)) { itemLore.add(C.cBlack); - itemLore.add(C.cWhiteB + "Cost: " + C.cAqua + gadget.getCost(CurrencyType.TREASURE_SHARD) + " Treasure Shards"); + itemLore.add(C.cWhiteB + "Cost: " + C.cAqua + gadget.getCost(GlobalCurrency.TREASURE_SHARD) + " Treasure Shards"); } - if (gadget.getCost(CurrencyType.TREASURE_SHARD) > 0 && getDonationManager().Get(getPlayer().getName()).GetBalance(CurrencyType.TREASURE_SHARD) >= gadget.getCost(CurrencyType.TREASURE_SHARD)) + if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) > 0 && getDonationManager().Get(getPlayer().getName()).getBalance(GlobalCurrency.TREASURE_SHARD) >= gadget.getCost(GlobalCurrency.TREASURE_SHARD)) { itemLore.add(C.cBlack); itemLore.add(C.cGreen + "Click to Purchase"); addButton(slot, new ShopItem(Material.INK_SACK, (byte) 8, gadget.getName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false).hideInfo(), new GadgetButton(gadget, this)); } - else if (gadget.getCost(CurrencyType.TREASURE_SHARD) > 0) + else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) > 0) { itemLore.add(C.cBlack); itemLore.add(C.cRed + "Not enough Treasure Shards."); @@ -291,7 +290,7 @@ public class GadgetPage extends ShopPageBase if (gadget.getGadgetType() == GadgetType.ARROW_TRAIL || gadget.getGadgetType() == GadgetType.DEATH || gadget.getGadgetType() == GadgetType.PARTICLE || gadget.getGadgetType() == GadgetType.DOUBLE_JUMP) { - if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -8) + if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -8) { gadgetItemStack = CountryFlag.USA.getBanner(); BannerMeta bannerMeta = (BannerMeta) gadgetItemStack.getItemMeta(); @@ -314,7 +313,7 @@ public class GadgetPage extends ShopPageBase if (gadget.getGadgetType() == GadgetType.ARROW_TRAIL || gadget.getGadgetType() == GadgetType.DEATH || gadget.getGadgetType() == GadgetType.PARTICLE || gadget.getGadgetType() == GadgetType.DOUBLE_JUMP) { - if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -8) + if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -8) { gadgetItemStack = CountryFlag.USA.getBanner(); BannerMeta bannerMeta = (BannerMeta) gadgetItemStack.getItemMeta(); @@ -329,20 +328,20 @@ public class GadgetPage extends ShopPageBase } else { - if (gadget.getCost(CurrencyType.TREASURE_SHARD) > 0) + if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) > 0) { itemLore.add(C.cBlack); - itemLore.add(C.cWhiteB + "Cost: " + C.cAqua + gadget.getCost(CurrencyType.TREASURE_SHARD) + " Treasure Shards"); + itemLore.add(C.cWhiteB + "Cost: " + C.cAqua + gadget.getCost(GlobalCurrency.TREASURE_SHARD) + " Treasure Shards"); } - if (gadget.getCost(CurrencyType.TREASURE_SHARD) > 0 && getDonationManager().Get(getPlayer().getName()).GetBalance(CurrencyType.TREASURE_SHARD) >= gadget.getCost(CurrencyType.TREASURE_SHARD)) + if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) > 0 && getDonationManager().Get(getPlayer().getName()).getBalance(GlobalCurrency.TREASURE_SHARD) >= gadget.getCost(GlobalCurrency.TREASURE_SHARD)) { itemLore.add(C.cBlack); itemLore.add(C.cGreen + "Click to Purchase"); addButton(slot, new ShopItem(Material.INK_SACK, (byte) 8, gadget.getName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false).hideInfo(), new GadgetButton(gadget, this)); } - else if (gadget.getCost(CurrencyType.TREASURE_SHARD) > 0) + else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) > 0) { itemLore.add(C.cBlack); itemLore.add(C.cRed + "Not enough Treasure Shards."); @@ -363,7 +362,7 @@ public class GadgetPage extends ShopPageBase { ItemGadget itemGadget = (ItemGadget)gadget; - if (itemGadget.getAmmo().getCost(CurrencyType.TREASURE_SHARD) < 0) + if (itemGadget.getAmmo().getCost(GlobalCurrency.TREASURE_SHARD) < 0) return; } @@ -379,7 +378,7 @@ public class GadgetPage extends ShopPageBase getPlugin().getInventoryManager().addItemToInventory(getPlayer(), gadget.getName(), (gadget instanceof ItemGadget ? ((ItemGadget) gadget).getAmmo().getQuantity() : gadget.getQuantity())); refresh(); } - }, this, (gadget instanceof ItemGadget ? ((ItemGadget) gadget).getAmmo() : gadget), CurrencyType.TREASURE_SHARD, getPlayer())); + }, this, (gadget instanceof ItemGadget ? ((ItemGadget) gadget).getAmmo() : gadget), GlobalCurrency.TREASURE_SHARD, getPlayer())); } public void activateGadget(Player player, Gadget gadget) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java index 51ed4dd84..314fd5879 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java @@ -1,24 +1,11 @@ package mineplex.core.cosmetic.ui.page; -import java.util.ArrayList; -import java.util.EnumMap; -import java.util.List; - -import mineplex.core.cosmetic.ui.button.open.*; -import org.bukkit.Material; -import org.bukkit.entity.Creature; -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.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.LineFormat; -import mineplex.core.common.util.NautHashMap; -import mineplex.core.common.util.UtilText; +import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.common.util.*; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.cosmetic.ui.CosmeticShop; +import mineplex.core.cosmetic.ui.button.open.*; import mineplex.core.donation.DonationManager; import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetType; @@ -27,6 +14,15 @@ import mineplex.core.pet.Pet; 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.Creature; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +import java.util.ArrayList; +import java.util.EnumMap; +import java.util.List; public class Menu extends ShopPageBase { @@ -41,7 +37,7 @@ public class Menu extends ShopPageBase protected void buildPage() { // Treasure Shards - int treasureShards = getDonationManager().Get(getPlayer()).getCoins(); + int treasureShards = getDonationManager().Get(getPlayer()).getBalance(GlobalCurrency.TREASURE_SHARD); List shardLore = new ArrayList(); shardLore.add(" "); 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 bc84607ea..29964074a 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,26 +1,25 @@ package mineplex.core.cosmetic.ui.page; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; - import mineplex.core.account.CoreClientManager; -import mineplex.core.common.CurrencyType; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.cosmetic.ui.CosmeticShop; +import mineplex.core.cosmetic.ui.button.MountButton; import mineplex.core.cosmetic.ui.button.activate.ActivateMountButton; import mineplex.core.cosmetic.ui.button.deactivate.DeactivateMountButton; -import mineplex.core.cosmetic.ui.button.MountButton; import mineplex.core.donation.DonationManager; 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; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; public class MountPage extends ShopPageBase { @@ -62,58 +61,58 @@ public class MountPage extends ShopPageBase if (!getDonationManager().Get(getPlayer().getName()).OwnsUnknownPackage(mount.getName())) { - if (mount.getCost(CurrencyType.TREASURE_SHARD) == -1) + if (mount.getCost(GlobalCurrency.TREASURE_SHARD) == -1) { //Nothing } //Chest Unlocks - else if (mount.getCost(CurrencyType.TREASURE_SHARD) == -2 || mount.getCost(CurrencyType.TREASURE_SHARD) > 0) + else if (mount.getCost(GlobalCurrency.TREASURE_SHARD) == -2 || mount.getCost(GlobalCurrency.TREASURE_SHARD) > 0) { itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Treasure Chests"); } - else if (mount.getCost(CurrencyType.TREASURE_SHARD) == -3) + else if (mount.getCost(GlobalCurrency.TREASURE_SHARD) == -3) { itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Winter Holiday Treasure"); } - else if (mount.getCost(CurrencyType.TREASURE_SHARD) == -4) + else if (mount.getCost(GlobalCurrency.TREASURE_SHARD) == -4) { itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Halloween Pumpkin Treasure"); } - else if (mount.getCost(CurrencyType.TREASURE_SHARD) == -5) + else if (mount.getCost(GlobalCurrency.TREASURE_SHARD) == -5) { itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Easter Holiday Treasure"); } - else if (mount.getCost(CurrencyType.TREASURE_SHARD) == -6) + else if (mount.getCost(GlobalCurrency.TREASURE_SHARD) == -6) { itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Valentines Holiday Treasure"); } - else if (mount.getCost(CurrencyType.TREASURE_SHARD) == -7) + else if (mount.getCost(GlobalCurrency.TREASURE_SHARD) == -7) { itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Freedom Chests"); } //Rank Unlocks - else if (mount.getCost(CurrencyType.TREASURE_SHARD) == -10) + else if (mount.getCost(GlobalCurrency.TREASURE_SHARD) == -10) { itemLore.add(C.cBlack); itemLore.add(C.cAqua + "Unlocked with Ultra Rank"); } - else if (mount.getCost(CurrencyType.TREASURE_SHARD) == -11) + else if (mount.getCost(GlobalCurrency.TREASURE_SHARD) == -11) { itemLore.add(C.cBlack); itemLore.add(C.cPurple + "Unlocked with Hero Rank"); } - else if (mount.getCost(CurrencyType.TREASURE_SHARD) == -12) + else if (mount.getCost(GlobalCurrency.TREASURE_SHARD) == -12) { itemLore.add(C.cBlack); itemLore.add(C.cGreen + "Unlocked with Legend Rank"); } - else if (mount.getCost(CurrencyType.TREASURE_SHARD) == -13) + else if (mount.getCost(GlobalCurrency.TREASURE_SHARD) == -13) { itemLore.add(C.cBlack); itemLore.add(C.cRed + "Unlocked with Titan Rank"); @@ -139,20 +138,20 @@ public class MountPage extends ShopPageBase } else { - if (mount.getCost(CurrencyType.TREASURE_SHARD) > 0) + if (mount.getCost(GlobalCurrency.TREASURE_SHARD) > 0) { itemLore.add(C.cBlack); - itemLore.add(C.cWhiteB + "Cost: " + C.cAqua + mount.getCost(CurrencyType.TREASURE_SHARD) + " Treasure Shards"); + itemLore.add(C.cWhiteB + "Cost: " + C.cAqua + mount.getCost(GlobalCurrency.TREASURE_SHARD) + " Treasure Shards"); } - if (mount.getCost(CurrencyType.TREASURE_SHARD) > 0 && getDonationManager().Get(getPlayer().getName()).GetBalance(CurrencyType.TREASURE_SHARD) >= mount.getCost(CurrencyType.TREASURE_SHARD)) + if (mount.getCost(GlobalCurrency.TREASURE_SHARD) > 0 && getDonationManager().Get(getPlayer().getName()).getBalance(GlobalCurrency.TREASURE_SHARD) >= mount.getCost(GlobalCurrency.TREASURE_SHARD)) { itemLore.add(C.cBlack); itemLore.add(C.cGreen + "Click to Purchase"); addButton(slot, new ShopItem(Material.INK_SACK, (byte) 8, mount.getName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false), new MountButton(mount, this)); } - else if (mount.getCost(CurrencyType.TREASURE_SHARD) > 0) + else if (mount.getCost(GlobalCurrency.TREASURE_SHARD) > 0) { itemLore.add(C.cBlack); itemLore.add(C.cRed + "Not enough Treasure Shards."); 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 8ecd60944..a99e9135c 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 @@ -1,33 +1,16 @@ package mineplex.core.cosmetic.ui.page; -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.CurrencyType; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilPlayer; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.cosmetic.ui.CosmeticShop; import mineplex.core.cosmetic.ui.PetSorter; -import mineplex.core.cosmetic.ui.button.activate.ActivatePetButton; -import mineplex.core.cosmetic.ui.button.deactivate.DeactivatePetButton; import mineplex.core.cosmetic.ui.button.PetButton; import mineplex.core.cosmetic.ui.button.RenamePetButton; +import mineplex.core.cosmetic.ui.button.activate.ActivatePetButton; +import mineplex.core.cosmetic.ui.button.deactivate.DeactivatePetButton; import mineplex.core.donation.DonationManager; import mineplex.core.pet.Pet; import mineplex.core.pet.PetExtra; @@ -35,6 +18,16 @@ 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; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; public class PetPage extends ShopPageBase { @@ -63,49 +56,49 @@ public class PetPage extends ShopPageBase //Chest Unlocks if (!getPlugin().getPetManager().Get(getPlayer()).getPets().containsKey(pet.getPetType())) { - if (pet.getCost(CurrencyType.TREASURE_SHARD) == -1) + if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -1) { //Nothing } - else if (pet.getCost(CurrencyType.TREASURE_SHARD) == -2 || pet.getCost(CurrencyType.TREASURE_SHARD) > 0) + else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -2 || pet.getCost(GlobalCurrency.TREASURE_SHARD) > 0) { itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Treasure Chests"); } - else if (pet.getCost(CurrencyType.TREASURE_SHARD) == -3) + else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -3) { itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Winter Holiday Treasure"); } - else if (pet.getCost(CurrencyType.TREASURE_SHARD) == -4) + else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -4) { itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Halloween Pumpkin Treasure"); } - else if (pet.getCost(CurrencyType.TREASURE_SHARD) == -5) + else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -5) { itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Easter Holiday Treasure"); } //Rank Unlocks - else if (pet.getCost(CurrencyType.TREASURE_SHARD) == -10) + else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -10) { itemLore.add(C.cBlack); itemLore.add(C.cAqua + "Unlocked with Ultra Rank"); } - else if (pet.getCost(CurrencyType.TREASURE_SHARD) == -11) + else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -11) { itemLore.add(C.cBlack); itemLore.add(C.cPurple + "Unlocked with Hero Rank"); } - else if (pet.getCost(CurrencyType.TREASURE_SHARD) == -12) + else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -12) { itemLore.add(C.cBlack); itemLore.add(C.cGreen + "Unlocked with Legend Rank"); } - else if (pet.getCost(CurrencyType.TREASURE_SHARD) == -13) + else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -13) { itemLore.add(C.cBlack); itemLore.add(C.cRed + "Unlocked with Titan Rank"); @@ -145,20 +138,20 @@ public class PetPage extends ShopPageBase //Not Owned else { - if (pet.getCost(CurrencyType.TREASURE_SHARD) > 0) + if (pet.getCost(GlobalCurrency.TREASURE_SHARD) > 0) { itemLore.add(C.cBlack); - itemLore.add(C.cWhiteB + "Cost: " + C.cAqua + pet.getCost(CurrencyType.TREASURE_SHARD) + " Treasure Shards"); + itemLore.add(C.cWhiteB + "Cost: " + C.cAqua + pet.getCost(GlobalCurrency.TREASURE_SHARD) + " Treasure Shards"); } - if (pet.getCost(CurrencyType.TREASURE_SHARD) > 0 && getDonationManager().Get(getPlayer().getName()).GetBalance(CurrencyType.TREASURE_SHARD) >= pet.getCost(CurrencyType.TREASURE_SHARD)) + if (pet.getCost(GlobalCurrency.TREASURE_SHARD) > 0 && getDonationManager().Get(getPlayer().getName()).getBalance(GlobalCurrency.TREASURE_SHARD) >= pet.getCost(GlobalCurrency.TREASURE_SHARD)) { itemLore.add(C.cBlack); itemLore.add(C.cGreen + "Click to Purchase"); addButton(slot, new ShopItem(Material.INK_SACK, (byte) 8, pet.getPetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false), new PetButton(pet, this)); } - else if (pet.getCost(CurrencyType.TREASURE_SHARD) > 0) + else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) > 0) { itemLore.add(C.cBlack); itemLore.add(C.cRed + "Not enough Treasure Shards."); @@ -194,7 +187,7 @@ public class PetPage extends ShopPageBase || getPlugin().getPetManager().getActivePet(getPlayer().getName()).getType() != EntityType.VILLAGER || getPlugin().getPetManager().getActivePet(getPlayer().getName()).getType() != EntityType.ZOMBIE) { - addButton(slot, new ShopItem(petExtra.GetMaterial(), (byte) 0, "Rename " + getPlugin().getPetManager().getActivePet(getPlayer().getName()).getCustomName() + " for " + C.cYellow + petExtra.getCost(CurrencyType.TREASURE_SHARD) + C.cGreen + " Shards", itemLore.toArray(new String[itemLore.size()]), 1, false, false), new RenamePetButton(this)); + addButton(slot, new ShopItem(petExtra.GetMaterial(), (byte) 0, "Rename " + getPlugin().getPetManager().getActivePet(getPlayer().getName()).getCustomName() + " for " + C.cYellow + petExtra.getCost(GlobalCurrency.TREASURE_SHARD) + C.cGreen + " Shards", itemLore.toArray(new String[itemLore.size()]), 1, false, false), new RenamePetButton(this)); } slot++; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetTagPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetTagPage.java index 27997f3a8..63079412e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetTagPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetTagPage.java @@ -2,7 +2,7 @@ package mineplex.core.cosmetic.ui.page; import mineplex.cache.player.PlayerCache; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.CurrencyType; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -19,7 +19,6 @@ import mineplex.core.shop.page.ConfirmationPage; import mineplex.core.shop.page.ShopPageBase; import net.minecraft.server.v1_8_R3.ItemStack; import net.minecraft.server.v1_8_R3.Items; - import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -130,7 +129,7 @@ public class PetTagPage extends ShopPageBase getShop().openPageForPlayer(getPlayer(), new Menu(getPlugin(), getShop(), getClientManager(), getDonationManager(), getPlayer())); } - }, null, _petPurchase ? _pet : tag, CurrencyType.TREASURE_SHARD, getPlayer())); + }, null, _petPurchase ? _pet : tag, GlobalCurrency.TREASURE_SHARD, getPlayer())); } public void SetTagName(String tagName) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java index fd0862c9d..4cbab4787 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java @@ -1,36 +1,30 @@ package mineplex.core.donation; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.LinkedList; -import java.util.Queue; -import java.util.UUID; - -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.plugin.java.JavaPlugin; - import com.google.gson.Gson; - import mineplex.cache.player.PlayerCache; -import mineplex.core.MiniDbClientPlugin; +import mineplex.core.MiniClientPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.event.ClientWebResponseEvent; -import mineplex.core.common.CurrencyType; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.Callback; import mineplex.core.common.util.NautHashMap; -import mineplex.core.donation.command.ShardCommand; import mineplex.core.donation.command.GemCommand; -import mineplex.core.donation.command.GoldCommand; -import mineplex.core.donation.command.SetGoldCommand; +import mineplex.core.donation.command.ShardCommand; import mineplex.core.donation.repository.DonationRepository; import mineplex.core.donation.repository.token.DonorTokenWrapper; import mineplex.core.server.util.TransactionResponse; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.plugin.java.JavaPlugin; -public class DonationManager extends MiniDbClientPlugin +import java.util.LinkedList; +import java.util.Queue; +import java.util.UUID; + +public class DonationManager extends MiniClientPlugin { private final int MAX_GIVE_ATTEMPTS = 10; @@ -38,17 +32,24 @@ public class DonationManager extends MiniDbClientPlugin private NautHashMap> _gemQueue = new NautHashMap>(); private NautHashMap> _coinQueue = new NautHashMap>(); - private NautHashMap> _goldQueue = new NautHashMap>(); private Queue _coinAttemptQueue; + private final CoreClientManager _clientManager; public DonationManager(JavaPlugin plugin, CoreClientManager clientManager, String webAddress) { - super("Donation", plugin, clientManager); + super("Donation", plugin); _repository = new DonationRepository(plugin, webAddress); _coinAttemptQueue = new LinkedList<>(); + + _clientManager = clientManager; + } + + public CoreClientManager getClientManager() + { + return _clientManager; } @Override @@ -57,8 +58,6 @@ public class DonationManager extends MiniDbClientPlugin // TODO: Re-add commands? Where are command implementations, seen as missing at the moment. addCommand(new GemCommand(this)); addCommand(new ShardCommand(this)); - addCommand(new GoldCommand(this)); - addCommand(new SetGoldCommand(this)); } @EventHandler @@ -74,12 +73,12 @@ public class DonationManager extends MiniDbClientPlugin //_repository.updateGemsAndCoins(uuid, Get(token.Name).GetGems(), Get(token.Name).getCoins()); } - public void purchaseUnknownSalesPackage(Callback callback, Player player, String packageName, CurrencyType currencyType, int cost, boolean oneTimePurchase) + public void purchaseUnknownSalesPackage(Callback callback, Player player, String packageName, GlobalCurrency currencyType, int cost, boolean oneTimePurchase) { - PurchaseUnknownSalesPackage(callback, player.getName(), getClientManager().getAccountId(player), packageName, currencyType, cost, oneTimePurchase); + PurchaseUnknownSalesPackage(callback, player.getName(), _clientManager.getAccountId(player), packageName, currencyType, cost, oneTimePurchase); } - public void PurchaseUnknownSalesPackage(final Callback callback, final String name, final int accountId, final String packageName, final CurrencyType currencyType, final int cost, boolean oneTimePurchase) + public void PurchaseUnknownSalesPackage(final Callback callback, final String name, final int accountId, final String packageName, final GlobalCurrency currencyType, final int cost, boolean oneTimePurchase) { final Donor donor = Bukkit.getPlayerExact(name) != null ? Get(name) : null; @@ -112,29 +111,7 @@ public class DonationManager extends MiniDbClientPlugin } }, name, accountId, packageName, currencyType, cost); } - - public void PurchaseKnownSalesPackage(final Callback callback, final String name, final UUID uuid, final int cost, final int salesPackageId) - { - _repository.PurchaseKnownSalesPackage(new Callback() - { - public void run(TransactionResponse response) - { - if (response == TransactionResponse.Success) - { - Donor donor = Get(name); - if (donor != null) - { - donor.AddSalesPackagesOwned(salesPackageId); - } - } - - if (callback != null) - callback.run(response); - } - }, name, uuid.toString(), cost, salesPackageId); - } - public void RewardGems(Callback callback, String caller, String name, UUID uuid, int amount) { RewardGems(callback, caller, name, uuid, amount, true); @@ -154,7 +131,7 @@ public class DonationManager extends MiniDbClientPlugin if (donor != null) { - donor.AddGems(amount); + donor.addBalance(GlobalCurrency.GEM, amount); } } } @@ -181,7 +158,7 @@ public class DonationManager extends MiniDbClientPlugin Donor donor = Get(player.getName()); if (donor != null) - donor.AddGems(amount); + donor.addBalance(GlobalCurrency.GEM, amount); } @EventHandler @@ -241,7 +218,7 @@ public class DonationManager extends MiniDbClientPlugin if (donor != null) { - donor.addCoins(amount); + donor.addBalance(GlobalCurrency.TREASURE_SHARD, amount); } } } @@ -268,7 +245,7 @@ public class DonationManager extends MiniDbClientPlugin Donor donor = Get(player.getName()); if (donor != null) - donor.addCoins(amount); + donor.addBalance(GlobalCurrency.TREASURE_SHARD, amount); } @EventHandler @@ -295,7 +272,7 @@ public class DonationManager extends MiniDbClientPlugin continue; if (player.isOnline() && player.isValid()) - RewardCoins(null, caller, player.getName(), ClientManager.Get(player).getAccountId(), total, false); + RewardCoins(null, caller, player.getName(), _clientManager.Get(player).getAccountId(), total, false); else { Bukkit.getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable() @@ -338,7 +315,7 @@ public class DonationManager extends MiniDbClientPlugin if (donor != null) { - donor.addCoins(data.getGiveAmount()); + donor.addBalance(GlobalCurrency.TREASURE_SHARD, data.getGiveAmount()); } if (data.getCallback() != null) data.getCallback().run(true); @@ -367,165 +344,15 @@ public class DonationManager extends MiniDbClientPlugin } } - - public void rewardGold(Callback callback, String caller, Player player, int amount) - { - rewardGold(callback, caller, player.getName(), ClientManager.Get(player).getAccountId(), amount); - } - - public void rewardGold(Callback callback, String caller, String name, int accountId, int amount) - { - rewardGold(callback, caller, name, accountId, amount, true); - } - - public void rewardGold(final Callback callback, final String caller, final String name, final int accountId, final int amount, final boolean updateTotal) - { - _repository.rewardGold(new Callback() - { - public void run(Boolean success) - { - if (success) - { - if (updateTotal) - { - Donor donor = Get(name); - - if (donor != null) - { - donor.addGold(amount); - } - } - } - else - { - System.out.println("REWARD GOLD FAILED..."); - } - - if (callback != null) - callback.run(success); - } - }, caller, name, accountId, amount); - } - - public void setGold(final Callback callback, final String caller, final String name, final int accountId, final int amount, final boolean updateTotal) - { - _repository.setGold(new Callback() - { - public void run(Boolean success) - { - if (success) - { - if (updateTotal) - { - Donor donor = Get(name); - - if (donor != null) - { - donor.setGold(amount); - } - } - } - else - { - System.out.println("SET GOLD FAILED..."); - } - - if (callback != null) - callback.run(success); - } - }, caller, name, accountId, amount); - } - - public void RewardGoldLater(final String caller, final Player player, final int amount) - { - if (!_goldQueue.containsKey(player)) - _goldQueue.put(player, new NautHashMap()); - - int totalAmount = amount; - - if (_goldQueue.get(player).containsKey(caller)) - totalAmount += _goldQueue.get(player).get(caller); - - _goldQueue.get(player).put(caller, totalAmount); - - //Do Temp Change - Donor donor = Get(player.getName()); - - if (donor != null) - donor.addGold(amount); - } - - @EventHandler - public void updateGoldQueue(UpdateEvent event) - { - if (event.getType() != UpdateType.SLOWER) - return; - - for (Player player : _goldQueue.keySet()) - { - updateGoldQueue(null, player); - } - - //Clean - _goldQueue.clear(); - } - - public void updateGoldQueue(final Callback callback, final Player player) - { - String tempCaller = null; - int tempTotal = 0; - - for (String curCaller : _goldQueue.get(player).keySet()) - { - tempCaller = curCaller; - tempTotal += _goldQueue.get(player).get(curCaller); - } - - final String caller = tempCaller; - final int total = tempTotal; - - if (caller == null) - return; - - if (player.isOnline() && player.isValid()) - rewardGold(callback, caller, player.getName(), ClientManager.Get(player).getAccountId(), total, false); - else - { - Bukkit.getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable() - { - public void run() - { - rewardGold(callback, caller, player.getName(), PlayerCache.getInstance().getPlayer(player.getUniqueId()).getAccountId(), total, false); - } - }); - } - - System.out.println("Queue Added [" + player + "] with Gold [" + total + "] for [" + caller + "]"); - - //Clean - _goldQueue.get(player).clear(); - } public void applyKits(String playerName) { _repository.applyKits(playerName); } - - @Override - public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException - { - Get(playerName).setGold(_repository.retrieveDonorInfo(resultSet).getGold()); - } @Override protected Donor addPlayer(String player) { return new Donor(); } - - @Override - public String getQuery(int accountId, String uuid, String name) - { - return "SELECT gold FROM accounts WHERE id = '" + accountId + "';"; - } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/Donor.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/Donor.java index 692b9cdb5..c2282a3b4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/Donor.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/Donor.java @@ -1,18 +1,18 @@ package mineplex.core.donation; -import java.util.ArrayList; -import java.util.List; - -import mineplex.core.common.CurrencyType; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.donation.repository.token.CoinTransactionToken; import mineplex.core.donation.repository.token.DonorToken; import mineplex.core.donation.repository.token.TransactionToken; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + public class Donor { - private int _gems; - private int _coins; - private int _gold; + private final Map _balances = new HashMap<>(); private boolean _donated; private List _salesPackagesOwned = new ArrayList(); private List _unknownSalesPackagesOwned = new ArrayList(); @@ -25,8 +25,8 @@ public class Donor public void loadToken(DonorToken token) { - _gems = token.Gems; - _coins = token.Coins; + _balances.put(GlobalCurrency.GEM, token.Gems); + _balances.put(GlobalCurrency.TREASURE_SHARD, token.Coins); _donated = token.Donated; _salesPackagesOwned = token.SalesPackages; @@ -34,12 +34,7 @@ public class Donor _transactions = token.Transactions; _coinTransactions = token.CoinRewards; } - - public int GetGems() - { - return _gems; - } - + public List GetSalesPackagesOwned() { return _salesPackagesOwned; @@ -65,49 +60,21 @@ public class Donor return _donated; } - public void DeductCost(int cost, CurrencyType currencyType) + public void DeductCost(int cost, GlobalCurrency currencyType) { - switch (currencyType) - { - case GEM: - _gems -= cost; - _update = true; - break; - case TREASURE_SHARD: - _coins -= cost; - _update = true; - break; - case GOLD: - _gold -= cost; - _update = true; - break; - default: - break; - } + addBalance(currencyType, -cost); } - public int GetBalance(CurrencyType currencyType) + public int getBalance(GlobalCurrency currencyType) { - switch (currencyType) - { - case GEM: - return _gems; - case TREASURE_SHARD: - return _coins; - case GOLD: - return _gold; - case TOKEN: - return 0; - default: - return 0; - } + return _balances.getOrDefault(currencyType, 0); } - public void AddGems(int gems) + public void addBalance(GlobalCurrency currencyType, int amount) { - _gems += gems; + _balances.merge(currencyType, amount, Integer::sum); } - + public boolean OwnsUnknownPackage(String packageName) { return _unknownSalesPackagesOwned.contains(packageName); @@ -144,33 +111,9 @@ public class Donor return false; } - public int getCoins() - { - return _coins; - } - - public void addCoins(int amount) - { - _coins += amount; - } - - public void addGold(int amount) - { - _gold = Math.max(0, _gold + amount); - } - - public void setGold(int amount) - { - _gold = Math.max(0, amount); - } - public List getCoinTransactions() { return _coinTransactions; } - public int getGold() - { - return _gold; - } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java index 414e23118..a73791657 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java @@ -1,24 +1,20 @@ package mineplex.core.donation.repository; -import java.sql.ResultSet; -import java.sql.SQLException; - -import mineplex.core.database.MinecraftRepository; -import org.bukkit.Bukkit; -import org.bukkit.plugin.java.JavaPlugin; - -import mineplex.core.common.CurrencyType; +import mineplex.core.common.currency.Currency; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.Callback; -import mineplex.serverdata.database.DBPool; -import mineplex.serverdata.database.DatabaseRunnable; -import mineplex.serverdata.database.column.ColumnInt; -import mineplex.core.donation.Donor; +import mineplex.core.database.MinecraftRepository; import mineplex.core.donation.repository.token.GemRewardToken; import mineplex.core.donation.repository.token.PurchaseToken; import mineplex.core.donation.repository.token.UnknownPurchaseToken; import mineplex.core.server.remotecall.AsyncJsonWebCall; import mineplex.core.server.remotecall.JsonWebCall; import mineplex.core.server.util.TransactionResponse; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.DatabaseRunnable; +import mineplex.serverdata.database.column.ColumnInt; +import org.bukkit.Bukkit; +import org.bukkit.plugin.java.JavaPlugin; public class DonationRepository extends MinecraftRepository { @@ -26,8 +22,6 @@ public class DonationRepository extends MinecraftRepository private static String CREATE_GEM_TRANSACTION_TABLE = "CREATE TABLE IF NOT EXISTS accountGemTransactions (id INT NOT NULL AUTO_INCREMENT, accountId INT, reason VARCHAR(100), gems INT, PRIMARY KEY (id), FOREIGN KEY (accountId) REFERENCES accounts(id));"; private static String INSERT_COIN_TRANSACTION = "INSERT INTO accountCoinTransactions(accountId, reason, coins) VALUES(?, ?, ?);"; private static String UPDATE_ACCOUNT_COINS = "UPDATE accounts SET coins = coins + ? WHERE id = ?;"; - private static String UPDATE_ACCOUNT_GOLD = "UPDATE accounts SET gold = gold + ? WHERE id = ? && gold >= ?;"; - private static String SET_ACCOUNT_GOLD = "UPDATE accounts SET gold = ? WHERE id = ?;"; private static String UPDATE_NULL_ACCOUNT_GEMS_AND_COINS_ = "UPDATE accounts SET gems = ?, coins = ? WHERE id = ? AND gems IS NULL AND coins IS NULL;"; private String _webAddress; @@ -70,12 +64,12 @@ public class DonationRepository extends MinecraftRepository }), "Error purchasing known sales package in DonationRepository : "); } - public void PurchaseUnknownSalesPackage(final Callback callback, final String name, final int accountId, final String packageName, final CurrencyType currencyType, final int cost) + public void PurchaseUnknownSalesPackage(final Callback callback, final String name, final int accountId, final String packageName, final Currency currencyType, final int cost) { final UnknownPurchaseToken token = new UnknownPurchaseToken(); token.AccountName = name; token.SalesPackageName = packageName; - token.CoinPurchase = currencyType == CurrencyType.TREASURE_SHARD; + token.CoinPurchase = currencyType == GlobalCurrency.TREASURE_SHARD; token.Cost = cost; token.Premium = false; @@ -85,15 +79,11 @@ public class DonationRepository extends MinecraftRepository { if (response == TransactionResponse.Success) { - if (currencyType == CurrencyType.TREASURE_SHARD) + if (currencyType == GlobalCurrency.TREASURE_SHARD) { executeUpdate(UPDATE_ACCOUNT_COINS, new ColumnInt("coins", -cost), new ColumnInt("id", accountId)); //executeUpdate(INSERT_COIN_TRANSACTION, new ColumnInt("id", accountId), new ColumnVarChar("reason", 100, "Purchased " + packageName), new ColumnInt("coins", -cost)); } - else if (currencyType == CurrencyType.GOLD) - { - executeUpdate(UPDATE_ACCOUNT_GOLD, new ColumnInt("gold", -cost), new ColumnInt("id", accountId)); - } } Bukkit.getServer().getScheduler().runTask(getPlugin(), new Runnable() @@ -184,35 +174,6 @@ public class DonationRepository extends MinecraftRepository }), "Error updating player coin amount in DonationRepository : "); } - public void rewardGold(final Callback callback, final String giver, final String name, final int accountId, final int gold) - { - handleDatabaseCall(new DatabaseRunnable(new Runnable() - { - public void run() - { - ColumnInt min = new ColumnInt("gold", gold < 0 ? -gold : 0); - boolean success = executeUpdate(UPDATE_ACCOUNT_GOLD, new ColumnInt("gold", gold), new ColumnInt("id", accountId), min) > 0; - callback.run(success); - } - }), "Error updating player gold amount in DonationRepository : "); - } - - public void setGold(final Callback callback, final String giver, final String name, final int accountId, final int gold) - { - if (gold < 0) - { - throw new IllegalArgumentException("gold cannot be negative"); - } - handleDatabaseCall(new DatabaseRunnable(new Runnable() - { - public void run() - { - boolean success = executeUpdate(SET_ACCOUNT_GOLD, new ColumnInt("gold", gold), new ColumnInt("id", accountId)) > 0; - callback.run(success); - } - }), "Error updating player gold amount in DonationRepository : "); - } - @Override protected void initialize() { @@ -240,16 +201,4 @@ public class DonationRepository extends MinecraftRepository { new AsyncJsonWebCall(_webAddress + "PlayerAccount/ApplyKits").Execute(playerName); } - - public Donor retrieveDonorInfo(ResultSet resultSet) throws SQLException - { - Donor donor = new Donor(); - - while (resultSet.next()) - { - donor.setGold(resultSet.getInt(1)); - } - - return donor; - } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/Ammo.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/Ammo.java index 71d36ba62..4f6f3b421 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/Ammo.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/Ammo.java @@ -1,10 +1,7 @@ package mineplex.core.gadget.gadgets; -import org.bukkit.Material; -import org.bukkit.entity.Player; - -import mineplex.core.common.CurrencyType; import mineplex.core.shop.item.SalesPackageBase; +import org.bukkit.Material; public class Ammo extends SalesPackageBase { @@ -16,9 +13,4 @@ public class Ammo extends SalesPackageBase KnownPackage = false; OneTimePurchaseOnly = false; } - - @Override - public void sold(Player player, CurrencyType currencyType) - { - } } 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 762dc9a7c..55abae373 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 @@ -1,14 +1,18 @@ package mineplex.core.gadget.gadgets.morph; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Color; -import org.bukkit.Material; -import org.bukkit.Sound; +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.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.FireworkEffect.Type; import org.bukkit.entity.Item; import org.bukkit.entity.Player; @@ -21,28 +25,9 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; -import mineplex.core.common.CurrencyType; -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.UtilFirework; -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.UtilEvent.ActionType; -import mineplex.core.common.util.UtilServer; -import mineplex.core.disguise.disguises.DisguiseRabbit; -import mineplex.core.gadget.GadgetManager; -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 java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; public class MorphBunny extends MorphGadget { @@ -151,7 +136,7 @@ public class MorphBunny extends MorphGadget if (!UtilEvent.isAction(event, ActionType.L)) return; - if (Manager.getDonationManager().Get(player.getName()).GetBalance(CurrencyType.TREASURE_SHARD) < 500) + if (Manager.getDonationManager().Get(player.getName()).getBalance(GlobalCurrency.TREASURE_SHARD) < 500) { UtilPlayer.message(player, F.main("Gadget", "You do not have enough Shards.")); return; 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 3480504e3..794fba99d 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 @@ -1,8 +1,16 @@ 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.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; @@ -12,27 +20,12 @@ import org.bukkit.entity.Item; import org.bukkit.entity.LivingEntity; 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.PlayerPickupItemEvent; import org.bukkit.inventory.ItemStack; -import mineplex.core.common.CurrencyType; -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.UtilPlayer; -import mineplex.core.common.util.UtilText; -import mineplex.core.common.util.UtilEvent.ActionType; -import mineplex.core.disguise.disguises.DisguiseVillager; -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 java.util.HashSet; +import java.util.Iterator; public class MorphVillager extends MorphGadget implements IThrown { @@ -81,7 +74,7 @@ public class MorphVillager extends MorphGadget implements IThrown if (!UtilEvent.isAction(event, ActionType.L)) return; - if (Manager.getDonationManager().Get(player.getName()).GetBalance(CurrencyType.GEM) < 20) + if (Manager.getDonationManager().Get(player.getName()).getBalance(GlobalCurrency.GEM) < 20) { UtilPlayer.message(player, F.main("Gadget", "You do not have enough Gems.")); return; 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 20742f4f3..ed341aa82 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/Gadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/Gadget.java @@ -1,17 +1,13 @@ package mineplex.core.gadget.types; -import java.util.HashSet; - -import mineplex.core.common.CurrencyType; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.event.GadgetAppliedEvent; -import mineplex.core.gadget.event.GadgetEnableEvent; import mineplex.core.gadget.event.GadgetDisableEvent; +import mineplex.core.gadget.event.GadgetEnableEvent; import mineplex.core.shop.item.SalesPackageBase; - import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -19,6 +15,8 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerQuitEvent; +import java.util.HashSet; + public abstract class Gadget extends SalesPackageBase implements Listener { public GadgetManager Manager; @@ -152,12 +150,6 @@ public abstract class Gadget extends SalesPackageBase implements Listener UtilPlayer.message(player, F.main("Gadget", "You disabled " + F.elem(getName()) + ".")); } - @Override - public void sold(Player player, CurrencyType currencyType) - { - - } - public boolean ownsGadget(Player player) { if(isFree() || _free) return true; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/Mount.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/Mount.java index b63bea8d9..9735c3a20 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/Mount.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/Mount.java @@ -1,8 +1,10 @@ package mineplex.core.mount; -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; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Entity; @@ -12,12 +14,8 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; -import mineplex.core.common.CurrencyType; -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.util.HashMap; +import java.util.HashSet; public abstract class Mount extends SalesPackageBase implements Listener { @@ -35,12 +33,6 @@ public abstract class Mount extends SalesPackageBase implem Manager.getPlugin().getServer().getPluginManager().registerEvents(this, Manager.getPlugin()); } - @Override - public void sold(Player player, CurrencyType currencyType) - { - - } - public final void enable(Player player) { MountActivateEvent gadgetEvent = new MountActivateEvent(player, this); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/Pet.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/Pet.java index 0ae459e78..e6f918520 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/Pet.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/Pet.java @@ -1,12 +1,10 @@ package mineplex.core.pet; -import mineplex.core.common.CurrencyType; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.pet.repository.token.PetSalesToken; import mineplex.core.shop.item.SalesPackageBase; - import org.bukkit.Material; import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; public class Pet extends SalesPackageBase { @@ -19,7 +17,7 @@ public class Pet extends SalesPackageBase _name = name; _petType = petType; - CurrencyCostMap.put(CurrencyType.TREASURE_SHARD, cost); + CurrencyCostMap.put(GlobalCurrency.TREASURE_SHARD, cost); KnownPackage = false; } @@ -38,10 +36,4 @@ public class Pet extends SalesPackageBase { return _name; } - - @Override - public void sold(Player player, CurrencyType currencyType) - { - - } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetExtra.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetExtra.java index 162b53a01..ca38ba1a9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetExtra.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetExtra.java @@ -1,11 +1,9 @@ package mineplex.core.pet; -import mineplex.core.common.CurrencyType; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.pet.repository.token.PetExtraToken; import mineplex.core.shop.item.SalesPackageBase; - import org.bukkit.Material; -import org.bukkit.entity.Player; public class PetExtra extends SalesPackageBase { @@ -18,7 +16,7 @@ public class PetExtra extends SalesPackageBase _name = name; _material = material; - CurrencyCostMap.put(CurrencyType.TREASURE_SHARD, cost); + CurrencyCostMap.put(GlobalCurrency.TREASURE_SHARD, cost); KnownPackage = false; OneTimePurchaseOnly = false; @@ -38,9 +36,4 @@ public class PetExtra extends SalesPackageBase { return _material; } - - @Override - public void sold(Player player, CurrencyType currencyType) - { - } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/UnknownPackageReward.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/UnknownPackageReward.java index 51a54d3ea..aeb5b3550 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/UnknownPackageReward.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/UnknownPackageReward.java @@ -1,14 +1,13 @@ package mineplex.core.reward.rewards; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -import mineplex.core.common.CurrencyType; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.donation.DonationManager; import mineplex.core.reward.Reward; import mineplex.core.reward.RewardData; import mineplex.core.reward.RewardRarity; import mineplex.core.reward.RewardType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; /** * Created by shaun on 14-09-12. @@ -34,7 +33,7 @@ public class UnknownPackageReward extends Reward @Override protected RewardData giveRewardCustom(Player player, RewardType type) { - _donationManager.PurchaseUnknownSalesPackage(null, player.getName(), _donationManager.getClientManager().Get(player).getAccountId(), _packageName, CurrencyType.TREASURE_SHARD, 0, true); + _donationManager.PurchaseUnknownSalesPackage(null, player.getName(), _donationManager.getClientManager().Get(player).getAccountId(), _packageName, GlobalCurrency.TREASURE_SHARD, 0, true); return new RewardData(getRarity().getDarkColor() + _header, getRarity().getColor() + _name, _itemStack, getRarity()); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/ScoreboardData.java b/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/ScoreboardData.java index 1881d7357..58eaab05c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/ScoreboardData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/ScoreboardData.java @@ -1,12 +1,11 @@ package mineplex.core.scoreboard; -import java.util.ArrayList; - import mineplex.core.scoreboard.elements.*; - import org.bukkit.ChatColor; import org.bukkit.entity.Player; +import java.util.ArrayList; + public class ScoreboardData { private ArrayList _elements = new ArrayList(); @@ -96,11 +95,6 @@ public class ScoreboardData _elements.add(new ScoreboardElementText(" ")); } - public void writePlayerGold() - { - _elements.add(new ScoreboardElementGoldCount()); - } - public void writePlayerGems() { _elements.add(new ScoreboardElementGemCount()); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElementCoinCount.java b/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElementCoinCount.java index a11dd46fc..2c7937411 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElementCoinCount.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElementCoinCount.java @@ -1,20 +1,19 @@ package mineplex.core.scoreboard.elements; +import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.scoreboard.ScoreboardManager; +import org.bukkit.entity.Player; + import java.util.ArrayList; import java.util.List; -import org.bukkit.entity.Player; - -import mineplex.core.common.CurrencyType; -import mineplex.core.scoreboard.ScoreboardManager; - public class ScoreboardElementCoinCount implements ScoreboardElement { @Override public List getLines(ScoreboardManager manager, Player player, List out) { List output = new ArrayList(); - output.add(manager.getDonation().Get(player).GetBalance(CurrencyType.TREASURE_SHARD) + ""); + output.add(manager.getDonation().Get(player).getBalance(GlobalCurrency.TREASURE_SHARD) + ""); return output; } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElementGemCount.java b/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElementGemCount.java index c4566a6c3..8caae6533 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElementGemCount.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElementGemCount.java @@ -1,20 +1,19 @@ package mineplex.core.scoreboard.elements; +import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.scoreboard.ScoreboardManager; +import org.bukkit.entity.Player; + import java.util.ArrayList; import java.util.List; -import org.bukkit.entity.Player; - -import mineplex.core.common.CurrencyType; -import mineplex.core.scoreboard.ScoreboardManager; - public class ScoreboardElementGemCount implements ScoreboardElement { @Override public List getLines(ScoreboardManager manager, Player player, List out) { List output = new ArrayList(); - output.add(manager.getDonation().Get(player).GetBalance(CurrencyType.GEM) + ""); + output.add(manager.getDonation().Get(player).getBalance(GlobalCurrency.GEM) + ""); return output; } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElementGoldCount.java b/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElementGoldCount.java deleted file mode 100644 index 5f97e8798..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/elements/ScoreboardElementGoldCount.java +++ /dev/null @@ -1,20 +0,0 @@ -package mineplex.core.scoreboard.elements; - -import java.util.ArrayList; -import java.util.List; - -import org.bukkit.entity.Player; - -import mineplex.core.common.CurrencyType; -import mineplex.core.scoreboard.ScoreboardManager; - -public class ScoreboardElementGoldCount implements ScoreboardElement -{ - @Override - public List getLines(ScoreboardManager manager, Player player, List out) - { - List output = new ArrayList(); - output.add(manager.getDonation().Get(player).GetBalance(CurrencyType.GOLD) + ""); - return output; - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/shop/ShopBase.java b/Plugins/Mineplex.Core/src/mineplex/core/shop/ShopBase.java index 31a6065c9..a20567c0b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/shop/ShopBase.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/shop/ShopBase.java @@ -1,12 +1,13 @@ package mineplex.core.shop; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; - +import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.donation.DonationManager; +import mineplex.core.npc.event.NpcDamageByEntityEvent; +import mineplex.core.npc.event.NpcInteractEntityEvent; +import mineplex.core.shop.page.ShopPageBase; import net.minecraft.server.v1_8_R3.EntityPlayer; - import org.bukkit.ChatColor; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_8_R3.event.CraftEventFactory; @@ -22,22 +23,13 @@ import org.bukkit.event.inventory.InventoryDragEvent; import org.bukkit.event.inventory.InventoryOpenEvent; import org.bukkit.event.player.PlayerQuitEvent; -import mineplex.core.MiniPlugin; -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.CurrencyType; -import mineplex.core.common.util.NautHashMap; -import mineplex.core.donation.DonationManager; -import mineplex.core.npc.event.NpcDamageByEntityEvent; -import mineplex.core.npc.event.NpcInteractEntityEvent; -import mineplex.core.shop.page.ShopPageBase; +import java.util.HashSet; public abstract class ShopBase implements Listener { private NautHashMap _errorThrottling; private NautHashMap _purchaseBlock; - private List _availableCurrencyTypes = new ArrayList(); - private PluginType _plugin; private CoreClientManager _clientManager; private DonationManager _donationManager; @@ -46,7 +38,7 @@ public abstract class ShopBase implements Listene private HashSet _openedShop = new HashSet(); - public ShopBase(PluginType plugin, CoreClientManager clientManager, DonationManager donationManager, String name, CurrencyType...currencyTypes) + public ShopBase(PluginType plugin, CoreClientManager clientManager, DonationManager donationManager, String name) { _plugin = plugin; _clientManager = clientManager; @@ -56,18 +48,10 @@ public abstract class ShopBase implements Listene _playerPageMap = new NautHashMap>>(); _errorThrottling = new NautHashMap(); _purchaseBlock = new NautHashMap(); - - if (currencyTypes != null && currencyTypes.length > 0) - _availableCurrencyTypes.addAll(Arrays.asList(currencyTypes)); - + _plugin.registerEvents(this); } - public List getAvailableCurrencyTypes() - { - return _availableCurrencyTypes; - } - @EventHandler(priority = EventPriority.LOWEST) public void onPlayerDamageEntity(NpcDamageByEntityEvent event) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/shop/item/ICurrencyPackage.java b/Plugins/Mineplex.Core/src/mineplex/core/shop/item/ICurrencyPackage.java index 3cd7b949f..93fc1b154 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/shop/item/ICurrencyPackage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/shop/item/ICurrencyPackage.java @@ -1,12 +1,12 @@ package mineplex.core.shop.item; -import mineplex.core.common.CurrencyType; +import mineplex.core.common.currency.Currency; import mineplex.core.donation.repository.GameSalesPackageToken; public interface ICurrencyPackage { int getSalesPackageId(); - int getCost(CurrencyType currencytype); + int getCost(Currency currencytype); boolean isFree(); void update(GameSalesPackageToken token); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/shop/item/SalesPackageBase.java b/Plugins/Mineplex.Core/src/mineplex/core/shop/item/SalesPackageBase.java index 51dee3397..e22387f1b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/shop/item/SalesPackageBase.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/shop/item/SalesPackageBase.java @@ -1,12 +1,11 @@ package mineplex.core.shop.item; -import org.bukkit.Material; -import org.bukkit.entity.Player; - -import mineplex.core.common.CurrencyType; +import mineplex.core.common.currency.Currency; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.NautHashMap; import mineplex.core.donation.repository.GameSalesPackageToken; +import org.bukkit.Material; public abstract class SalesPackageBase implements ICurrencyPackage, IDisplayPackage { @@ -20,7 +19,7 @@ public abstract class SalesPackageBase implements ICurrencyPackage, IDisplayPack protected int SalesPackageId; protected boolean Free; - protected NautHashMap CurrencyCostMap; + protected NautHashMap CurrencyCostMap; protected boolean KnownPackage = true; protected boolean OneTimePurchaseOnly = true; @@ -41,7 +40,7 @@ public abstract class SalesPackageBase implements ICurrencyPackage, IDisplayPack public SalesPackageBase(String name, Material material, byte displayData, String[] description, int coins, int quantity) { - CurrencyCostMap = new NautHashMap(); + CurrencyCostMap = new NautHashMap<>(); Name = name; DisplayName = name; @@ -49,12 +48,10 @@ public abstract class SalesPackageBase implements ICurrencyPackage, IDisplayPack _displayMaterial = material; _displayData = displayData; - CurrencyCostMap.put(CurrencyType.TREASURE_SHARD, coins); + CurrencyCostMap.put(GlobalCurrency.TREASURE_SHARD, coins); Quantity = quantity; } - public abstract void sold(Player player, CurrencyType currencyType); - @Override public String getName() { @@ -68,7 +65,7 @@ public abstract class SalesPackageBase implements ICurrencyPackage, IDisplayPack } @Override - public int getCost(CurrencyType currencyType) + public int getCost(Currency currencyType) { return CurrencyCostMap.containsKey(currencyType) ? CurrencyCostMap.get(currencyType) : 0; } @@ -105,7 +102,7 @@ public abstract class SalesPackageBase implements ICurrencyPackage, IDisplayPack if (token.Gems > 0) { - CurrencyCostMap.put(CurrencyType.GEM, token.Gems); + CurrencyCostMap.put(GlobalCurrency.GEM, token.Gems); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ConfirmationPage.java b/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ConfirmationPage.java index 75102a07b..f388caf9c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ConfirmationPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ConfirmationPage.java @@ -1,19 +1,15 @@ package mineplex.core.shop.page; import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.currency.Currency; +import mineplex.core.common.util.C; import mineplex.core.donation.DonationManager; import mineplex.core.server.util.TransactionResponse; import mineplex.core.shop.ShopBase; import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.SalesPackageBase; import mineplex.core.shop.item.ShopItem; -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.CurrencyType; -import mineplex.core.common.util.C; -import mineplex.core.common.util.Callback; - - - import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -31,17 +27,18 @@ public class ConfirmationPage returnPage, SalesPackageBase salesItem, CurrencyType currencyType, Player player) + public ConfirmationPage(PluginType plugin, ShopType shop, CoreClientManager clientManager, DonationManager donationManager, Runnable runnable, ShopPageBase returnPage, SalesPackageBase salesItem, Currency currencyType, Player player) { super(plugin, shop, clientManager, donationManager, " Confirmation", player); _runnable = runnable; _returnPage = returnPage; _salesItem = salesItem; - setCurrencyType(currencyType); _progressItem = new ShopItem(Material.LAPIS_BLOCK, (byte)11, ChatColor.BLUE + "Processing", null, 1, false, true); _okSquareSlotStart = 27; + _currencyType = currencyType; if (getShop().canPlayerAttemptPurchase(player)) { @@ -79,7 +76,7 @@ public class ConfirmationPage goldCount) showResultsPage(TransactionResponse.InsufficientFunds); @@ -168,7 +165,7 @@ public class ConfirmationPage> extends CraftInventoryCustom implements Listener { protected PluginType _plugin; @@ -29,7 +27,6 @@ public abstract class ShopPageBase _buttonMap; protected boolean _showCurrency = false; @@ -52,27 +49,6 @@ public abstract class ShopPageBase(); _client = _clientManager.Get(player); - - if (shop.getAvailableCurrencyTypes().size() > 0) - { - _currencyType = shop.getAvailableCurrencyTypes().get(0); - } - } - - protected void changeCurrency(Player player) - { - playAcceptSound(player); - - int currentIndex = _shop.getAvailableCurrencyTypes().indexOf(_currencyType); - - if (currentIndex + 1 < _shop.getAvailableCurrencyTypes().size()) - { - _currencyType = _shop.getAvailableCurrencyTypes().get(currentIndex + 1); - } - else - { - _currencyType = _shop.getAvailableCurrencyTypes().get(0); - } } protected abstract void buildPage(); @@ -237,16 +213,6 @@ public abstract class ShopPageBase getButtonMap() { return _buttonMap; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/tournament/ui/TournamentShop.java b/Plugins/Mineplex.Core/src/mineplex/core/tournament/ui/TournamentShop.java index 07db4d582..1967124d4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/tournament/ui/TournamentShop.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/tournament/ui/TournamentShop.java @@ -1,20 +1,18 @@ package mineplex.core.tournament.ui; -import org.bukkit.entity.Player; - import mineplex.core.account.CoreClientManager; -import mineplex.core.common.CurrencyType; import mineplex.core.donation.DonationManager; import mineplex.core.shop.ShopBase; import mineplex.core.shop.page.ShopPageBase; import mineplex.core.tournament.TournamentManager; import mineplex.core.tournament.ui.page.MainMenu; +import org.bukkit.entity.Player; public class TournamentShop extends ShopBase { public TournamentShop(TournamentManager plugin, CoreClientManager clientManager, DonationManager donationManager) { - super(plugin, clientManager, donationManager, "Tournaments", CurrencyType.GEM); + super(plugin, clientManager, donationManager, "Tournaments"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/ChestPackage.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/ChestPackage.java index 8ab2aa019..bd4162932 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/ChestPackage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/ChestPackage.java @@ -1,10 +1,7 @@ package mineplex.core.treasure; -import org.bukkit.Material; -import org.bukkit.entity.Player; - -import mineplex.core.common.CurrencyType; import mineplex.core.shop.item.SalesPackageBase; +import org.bukkit.Material; public class ChestPackage extends SalesPackageBase { @@ -15,10 +12,4 @@ public class ChestPackage extends SalesPackageBase KnownPackage = false; OneTimePurchaseOnly = false; } - - @Override - public void sold(Player player, CurrencyType currencyType) - { - - } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureKey.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureKey.java index 06ecab631..30ef863f6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureKey.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureKey.java @@ -1,11 +1,8 @@ package mineplex.core.treasure; +import mineplex.core.shop.item.SalesPackageBase; import org.bukkit.ChatColor; import org.bukkit.Material; -import org.bukkit.entity.Player; - -import mineplex.core.common.CurrencyType; -import mineplex.core.shop.item.SalesPackageBase; /** * Created by shaun on 14-09-18. @@ -19,10 +16,4 @@ public class TreasureKey extends SalesPackageBase KnownPackage = false; OneTimePurchaseOnly = false; } - - @Override - public void sold(Player player, CurrencyType currencyType) - { - - } } 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 f62bd83cc..4dbb912a9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java @@ -1,17 +1,16 @@ package mineplex.core.treasure.gui; -import mineplex.core.treasure.TreasureType; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; - -import mineplex.core.common.CurrencyType; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.inventory.InventoryManager; import mineplex.core.shop.item.IButton; import mineplex.core.shop.page.ConfirmationPage; 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 { @@ -68,6 +67,6 @@ public class BuyChestButton implements IButton _page.getPlugin(), _page.getShop(), _page.getClientManager(), _page.getDonationManager(), () -> { _inventoryManager.addItemToInventory(player, _chestName, 1); _page.refresh(); - }, _page, new ChestPackage(_chestName, _chestMat, _chestCost), CurrencyType.TREASURE_SHARD, player)); + }, _page, new ChestPackage(_chestName, _chestMat, _chestCost), GlobalCurrency.TREASURE_SHARD, 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 c05c9a774..e1648228c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java @@ -1,8 +1,11 @@ package mineplex.core.treasure.gui; -import java.util.ArrayList; -import java.util.List; - +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.common.skin.SkinData; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.donation.DonationManager; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.arrowtrail.freedom.ArrowTrailFreedom; import mineplex.core.gadget.gadgets.death.freedom.DeathFreedom; @@ -11,24 +14,21 @@ import mineplex.core.gadget.gadgets.morph.MorphUncleSam; import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedom; import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetType; +import mineplex.core.inventory.InventoryManager; import mineplex.core.mount.Mount; +import mineplex.core.shop.item.ShopItem; +import mineplex.core.shop.page.ShopPageBase; +import mineplex.core.treasure.TreasureLocation; +import mineplex.core.treasure.TreasureManager; +import mineplex.core.treasure.TreasureType; import org.bukkit.ChatColor; import org.bukkit.DyeColor; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.skin.SkinData; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.donation.DonationManager; -import mineplex.core.inventory.InventoryManager; -import mineplex.core.shop.item.ShopItem; -import mineplex.core.shop.page.ShopPageBase; -import mineplex.core.treasure.TreasureLocation; -import mineplex.core.treasure.TreasureManager; -import mineplex.core.treasure.TreasureType; +import java.util.ArrayList; +import java.util.List; public class TreasurePage extends ShopPageBase { @@ -50,7 +50,7 @@ public class TreasurePage extends ShopPageBase @Override protected void buildPage() { - int treasureShards = getDonationManager().Get(getPlayer()).getCoins(); + int treasureShards = getDonationManager().Get(getPlayer()).getBalance(GlobalCurrency.TREASURE_SHARD); int basicCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.OLD.getItemName()); int heroicCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.ANCIENT.getItemName()); diff --git a/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java b/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java index 3c569acb1..f22a421f3 100644 --- a/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java +++ b/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java @@ -1,24 +1,10 @@ package mineplex.enjinTranslator; -import java.text.SimpleDateFormat; -import java.util.AbstractMap; -import java.util.Date; -import java.util.Iterator; -import java.util.Map.Entry; -import java.util.UUID; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.plugin.java.JavaPlugin; - import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.CurrencyType; import mineplex.core.common.Rank; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.Callback; import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UUIDFetcher; @@ -28,6 +14,19 @@ import mineplex.core.server.util.TransactionResponse; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.enjinTranslator.purchase.PurchaseManager; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.plugin.java.JavaPlugin; + +import java.text.SimpleDateFormat; +import java.util.AbstractMap; +import java.util.Date; +import java.util.Iterator; +import java.util.Map.Entry; +import java.util.UUID; public class Enjin extends MiniPlugin implements CommandExecutor { @@ -243,7 +242,7 @@ public class Enjin extends MiniPlugin implements CommandExecutor _purchaseManager.addAccountPurchaseToQueue(client.getAccountId(), packageName, amount, data == TransactionResponse.Success); } } - }, name, client.getAccountId(), amount == 1 ? packageName : packageName + " " + amount, CurrencyType.GEM, 0, false); + }, name, client.getAccountId(), amount == 1 ? packageName : packageName + " " + amount, GlobalCurrency.GEM, 0, false); return true; } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index 08157bd5d..e3460fbf4 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -481,6 +481,11 @@ public class ClansManager extends MiniClientPluginimplements IRelati { return _donationManager; } + + public GoldManager getGoldManager() + { + return _goldManager; + } public ItemMapManager getItemMapManager() { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java index 5b6cb24f4..c72d597ca 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java @@ -1,17 +1,15 @@ package mineplex.game.clans.clans.scoreboard.elements; -import java.util.ArrayList; -import java.util.List; - -import org.bukkit.entity.Player; - -import mineplex.core.common.CurrencyType; import mineplex.core.common.util.C; import mineplex.core.scoreboard.ScoreboardManager; import mineplex.core.scoreboard.elements.ScoreboardElement; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansUtility; import mineplex.game.clans.core.repository.ClanTerritory; +import org.bukkit.entity.Player; + +import java.util.ArrayList; +import java.util.List; public class ScoreboardElementPlayer implements ScoreboardElement { @@ -26,7 +24,7 @@ public class ScoreboardElementPlayer implements ScoreboardElement public List getLines(ScoreboardManager manager, Player player, List out) { List output = new ArrayList(); - output.add(C.cYellow + "Gold " + C.cWhite + manager.getDonation().Get(player).GetBalance(CurrencyType.GOLD) + ""); + output.add(C.cYellow + "Gold " + C.cWhite + _clansManager.getGoldManager().Get(player).getBalance()); String regionString = C.xWilderness + "Wilderness"; output.add(" "); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayerCount.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayerCount.java index 0c6fb35d5..9b2f8c152 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayerCount.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayerCount.java @@ -1,18 +1,14 @@ package mineplex.game.clans.clans.scoreboard.elements; -import java.util.ArrayList; -import java.util.List; - -import org.bukkit.entity.Player; - -import mineplex.core.common.CurrencyType; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilServer; import mineplex.core.scoreboard.ScoreboardManager; import mineplex.core.scoreboard.elements.ScoreboardElement; import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.clans.ClansUtility; -import mineplex.game.clans.core.repository.ClanTerritory; +import org.bukkit.entity.Player; + +import java.util.ArrayList; +import java.util.List; public class ScoreboardElementPlayerCount implements ScoreboardElement { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/ClansCurrency.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/ClansCurrency.java new file mode 100644 index 000000000..ee0947382 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/ClansCurrency.java @@ -0,0 +1,9 @@ +package mineplex.game.clans.economy; + +import mineplex.core.common.currency.Currency; +import mineplex.core.common.util.C; +import org.bukkit.Material; + +public class ClansCurrency { + public static final Currency GOLD = new Currency("Gold", "Gold", C.cGold, Material.GOLD_NUGGET); +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/command/GoldCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldCommand.java similarity index 88% rename from Plugins/Mineplex.Core/src/mineplex/core/donation/command/GoldCommand.java rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldCommand.java index 953b2c840..108265536 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/command/GoldCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldCommand.java @@ -1,4 +1,4 @@ -package mineplex.core.donation.command; +package mineplex.game.clans.economy; import mineplex.core.account.CoreClient; import mineplex.core.command.CommandBase; @@ -6,13 +6,11 @@ import mineplex.core.common.Rank; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; -import mineplex.core.donation.DonationManager; - import org.bukkit.entity.Player; -public class GoldCommand extends CommandBase +public class GoldCommand extends CommandBase { - public GoldCommand(DonationManager plugin) + public GoldCommand(GoldManager plugin) { super(plugin, Rank.ADMIN, "givegold"); } @@ -22,7 +20,7 @@ public class GoldCommand extends CommandBase { if (args == null || args.length == 0) { - UtilPlayer.message(caller, F.main("Gold", "Your Gold: " + F.elem("" + Plugin.Get(caller).getGold()))); + UtilPlayer.message(caller, F.main("Gold", "Your Gold: " + F.elem("" + Plugin.Get(caller).getBalance()))); return; } else if (args.length < 2) @@ -84,6 +82,6 @@ public class GoldCommand extends CommandBase UtilPlayer.message(target, F.main("Gold", F.name(caller.getName()) + " gave you " + F.elem(gold + " Gold") + ".")); } } - }, caller.getName(), targetName, accountId, gold); + }, accountId, targetName, gold, true); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldData.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldData.java new file mode 100644 index 000000000..9de4d3d9d --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldData.java @@ -0,0 +1,18 @@ +package mineplex.game.clans.economy; + +public class GoldData +{ + private int balance; + + public void addBalance(int amount) { + balance += amount; + } + + public void setBalance(int amount) { + balance = amount; + } + + public int getBalance() { + return balance; + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java index a86f41fd2..fcfc0a347 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java @@ -1,14 +1,16 @@ package mineplex.game.clans.economy; -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.Bukkit; +import mineplex.core.MiniDbClientPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.common.util.*; +import mineplex.core.donation.DonationManager; +import mineplex.core.donation.Donor; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.items.economy.GoldToken; +import mineplex.game.clans.shop.bank.BankShop; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; @@ -24,22 +26,11 @@ import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.metadata.MetadataValue; import org.bukkit.util.Vector; -import mineplex.core.MiniPlugin; -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.UtilPlayer; -import mineplex.core.donation.DonationManager; -import mineplex.core.donation.Donor; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.items.economy.GoldToken; -import mineplex.game.clans.shop.bank.BankShop; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.*; -public class GoldManager extends MiniPlugin +public class GoldManager extends MiniDbClientPlugin { public static final double GEM_CONVERSION_RATE = 16; // The number of gold coins when converted from a single gem @@ -54,10 +45,12 @@ public class GoldManager extends MiniPlugin private Set _itemSet; private Map _playerPickupMap; private BankShop _bankShop; + + private final GoldRepository _repository; public GoldManager(ClansManager plugin, CoreClientManager clientManager, DonationManager donationManager) { - super("Clans Gold", plugin.getPlugin()); + super("Clans Gold", plugin.getPlugin(), clientManager); _instance = this; _donationManager = donationManager; @@ -65,6 +58,14 @@ public class GoldManager extends MiniPlugin _itemSet = new HashSet(); _playerPickupMap = new HashMap(); _bankShop = new BankShop(plugin, clientManager, donationManager); + _repository = new GoldRepository(plugin.getPlugin()); + } + + @Override + public void addCommands() + { + addCommand(new GoldCommand(this)); + addCommand(new SetGoldCommand(this)); } @EventHandler @@ -177,12 +178,12 @@ public class GoldManager extends MiniPlugin public int getGold(Player player) { - return getDonor(player).getGold(); + return Get(player).getBalance(); } public int getGems(Player player) { - return getDonor(player).GetGems(); + return getDonor(player).getBalance(GlobalCurrency.GEM); } public void transferGemsToCoins(Player player, int gemAmount) @@ -192,7 +193,7 @@ public class GoldManager extends MiniPlugin if (gemCount >= gemAmount) { - deductGems(player, gemAmount); + _donationManager.RewardGemsLater("GoldManager", player, -gemAmount); addGold(player, goldCount); notify(player, String.format("You have transferred %d gems into %d gold coins!", gemAmount, goldCount)); _transferTracker.insertTransfer(player); @@ -208,20 +209,6 @@ public class GoldManager extends MiniPlugin { return !_transferTracker.hasTransferredToday(player); } - - public void addGold(Player player, int amount) - { - if (amount >= 0) - _donationManager.rewardGold(null, "GoldManager", player, amount); - } - - public void deductGold(Callback resultCallback, Player player, int amount) - { - if (amount == 0) - resultCallback.run(true); - if (amount > 0) - _donationManager.rewardGold(resultCallback, "GoldManager", player, -amount); - } public void cashIn(Player player, GoldToken token) { @@ -302,16 +289,7 @@ public class GoldManager extends MiniPlugin }, player, tokenValue); } - public void addGems(Player player, int amount) - { - _donationManager.RewardGemsLater("GoldManager", player, amount); - } - - public void deductGems(Player player, int amount) - { - addGems(player, -amount); - } - + private Donor getDonor(Player player) { return _donationManager.Get(player.getName()); @@ -330,4 +308,104 @@ public class GoldManager extends MiniPlugin item.remove(); } } + + public void setGold(final Callback callback, final String caller, final String name, final int accountId, final int amount, final boolean updateTotal) + { + _repository.setGold(new Callback() + { + public void run(Boolean success) + { + if (success) + { + if (updateTotal) + { + GoldData data = Get(name); + + if (data != null) + { + data.setBalance(amount); + } + } + } + else + { + System.out.println("SET GOLD FAILED..."); + } + + if (callback != null) + callback.run(success); + } + }, accountId, amount); + } + + public void addGold(Player player, int amount) + { + if (amount >= 0) + rewardGold(null, player, amount, true); + } + + public void deductGold(Callback resultCallback, Player player, int amount) + { + if (amount > 0) + rewardGold(resultCallback, player, -amount, true); + } + + public void rewardGold(final Callback callback, final Player player, final int amount, final boolean updateTotal) + { + rewardGold(callback, getClientManager().Get(player).getAccountId(), player.getName(), amount, updateTotal); + } + + public void rewardGold(final Callback callback, int accountId, String name, final int amount, final boolean updateTotal) + { + if (amount == 0) + { + if (callback != null) + { + callback.run(true); + } + return; + } + + _repository.rewardGold(new Callback() + { + public void run(Boolean success) + { + if (success) + { + if (updateTotal) + { + GoldData data = Get(name); + + if (data != null) + { + data.addBalance(amount); + } + } + } + else + { + System.out.println("REWARD GOLD FAILED..."); + } + + if (callback != null) + callback.run(success); + } + }, accountId, amount); + } + + + @Override + public String getQuery(int accountId, String uuid, String name) { + return "SELECT gold FROM accounts WHERE id = '" + accountId + "';"; + } + + @Override + public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException { + Get(playerName).setBalance(resultSet.getInt(1)); + } + + @Override + protected GoldData addPlayer(String player) { + return new GoldData(); + } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldRepository.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldRepository.java new file mode 100644 index 000000000..7afab5019 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldRepository.java @@ -0,0 +1,52 @@ +package mineplex.game.clans.economy; + +import mineplex.core.common.util.Callback; +import mineplex.core.database.MinecraftRepository; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.DatabaseRunnable; +import mineplex.serverdata.database.column.ColumnInt; +import org.bukkit.plugin.java.JavaPlugin; + +public class GoldRepository extends MinecraftRepository { + private static final String UPDATE_ACCOUNT_GOLD = "UPDATE accounts SET gold = gold + ? WHERE id = ? && gold >= ?;"; + private static final String SET_ACCOUNT_GOLD = "UPDATE accounts SET gold = ? WHERE id = ?;"; + + public GoldRepository(JavaPlugin plugin) { + super(plugin, DBPool.getAccount()); + } + + public void rewardGold(final Callback callback, final int accountId, final int gold) + { + handleDatabaseCall(new DatabaseRunnable(new Runnable() + { + public void run() + { + ColumnInt min = new ColumnInt("gold", gold < 0 ? -gold : 0); + boolean success = executeUpdate(UPDATE_ACCOUNT_GOLD, new ColumnInt("gold", gold), new ColumnInt("id", accountId), min) > 0; + callback.run(success); + } + }), "Error updating player gold amount in DonationRepository : "); + } + + public void setGold(final Callback callback, final int accountId, final int gold) + { + if (gold < 0) + { + throw new IllegalArgumentException("gold cannot be negative"); + } + handleDatabaseCall(new DatabaseRunnable(new Runnable() + { + public void run() + { + boolean success = executeUpdate(SET_ACCOUNT_GOLD, new ColumnInt("gold", gold), new ColumnInt("id", accountId)) > 0; + callback.run(success); + } + }), "Error updating player gold amount in DonationRepository : "); + } + + @Override + protected void initialize() {} + + @Override + protected void update() {} +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/command/SetGoldCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/SetGoldCommand.java similarity index 92% rename from Plugins/Mineplex.Core/src/mineplex/core/donation/command/SetGoldCommand.java rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/SetGoldCommand.java index d477f5b8f..bd1a249d1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/command/SetGoldCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/SetGoldCommand.java @@ -1,4 +1,4 @@ -package mineplex.core.donation.command; +package mineplex.game.clans.economy; import mineplex.core.account.CoreClient; import mineplex.core.command.CommandBase; @@ -10,9 +10,9 @@ import mineplex.core.donation.DonationManager; import org.bukkit.entity.Player; -public class SetGoldCommand extends CommandBase +public class SetGoldCommand extends CommandBase { - public SetGoldCommand(DonationManager plugin) + public SetGoldCommand(GoldManager plugin) { super(plugin, Rank.ADMIN, "setgold"); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyPackage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyPackage.java index 5cbea79d1..ba5a9ded0 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyPackage.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyPackage.java @@ -1,25 +1,17 @@ package mineplex.game.clans.shop.energy; +import mineplex.core.shop.item.SalesPackageBase; +import mineplex.game.clans.economy.ClansCurrency; import org.bukkit.ChatColor; import org.bukkit.Material; -import org.bukkit.entity.Player; - -import mineplex.core.common.CurrencyType; -import mineplex.core.shop.item.SalesPackageBase; public class EnergyPackage extends SalesPackageBase { public EnergyPackage(String name, int cost) { super(name, Material.REDSTONE, " ", ChatColor.RESET + "Clan Energy"); - CurrencyCostMap.put(CurrencyType.GOLD, cost); + CurrencyCostMap.put(ClansCurrency.GOLD, cost); KnownPackage = false; OneTimePurchaseOnly = false; } - - @Override - public void sold(Player player, CurrencyType currencyType) - { - - } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyShopButton.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyShopButton.java index d84a9877a..35e4c5979 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyShopButton.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyShopButton.java @@ -1,9 +1,5 @@ package mineplex.game.clans.shop.energy; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; - -import mineplex.core.common.CurrencyType; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilServer; import mineplex.core.shop.item.IButton; @@ -11,6 +7,9 @@ import mineplex.core.shop.page.ConfirmationPage; import mineplex.game.clans.clans.ClanEnergyManager; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.event.PreEnergyShopBuyEvent; +import mineplex.game.clans.economy.ClansCurrency; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; public class EnergyShopButton implements IButton { @@ -57,7 +56,7 @@ public class EnergyShopButton implements IButton // Notify _energyManager.getClansManager().messageClan(_clanInfo, F.main("Energy", F.name(player.getName()) + " purchased " + F.elem(_energyToPurchase + " Energy") + " for the clan")); } - }, _page, new EnergyPackage(_energyToPurchase + " Energy", _cost), CurrencyType.GOLD, player)); + }, _page, new EnergyPackage(_energyToPurchase + " Energy", _cost), ClansCurrency.GOLD, player)); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/pvp/tnt/TNTGenPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/pvp/tnt/TNTGenPage.java index eaed63bc0..367cc8464 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/pvp/tnt/TNTGenPage.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/pvp/tnt/TNTGenPage.java @@ -1,31 +1,19 @@ package mineplex.game.clans.shop.pvp.tnt; -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.event.EventHandler; -import org.bukkit.inventory.ItemStack; -import org.bukkit.scheduler.BukkitRunnable; - import mineplex.core.account.CoreClientManager; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilInv; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilUI; +import mineplex.core.common.util.*; import mineplex.core.donation.DonationManager; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.shop.page.ShopPageBase; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.tntGenerator.TntGenerator; import mineplex.game.clans.clans.tntGenerator.TntGeneratorManager; import mineplex.game.clans.economy.GoldManager; import mineplex.game.clans.shop.ClansShopItem; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.inventory.ItemStack; public class TNTGenPage extends ShopPageBase { @@ -64,7 +52,7 @@ public class TNTGenPage extends ShopPageBase return; } - if (_donationManager.Get(player).getGold() >= ClansShopItem.TNT_GENERATOR.getBuyPrice()) + if (getPlugin().getGoldManager().Get(player).getBalance() >= ClansShopItem.TNT_GENERATOR.getBuyPrice()) { GoldManager.getInstance().deductGold(success -> { UtilPlayer.message(player, F.main("Clans", "You purchased a " + F.elem("TNT Generator") + " for your Clan. You can now access it from the " + F.elem("PvP Shop") + ".")); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index 21752eafe..c983c9cbb 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -1,4 +1,5 @@ package mineplex.hub; + import mineplex.core.MiniClientPlugin; import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; @@ -10,6 +11,7 @@ import mineplex.core.bonuses.BonusManager; import mineplex.core.boosters.BoosterManager; import mineplex.core.botspam.BotSpamManager; import mineplex.core.common.Rank; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.*; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.customdata.CustomDataManager; @@ -736,8 +738,8 @@ public class HubManager extends MiniClientPlugin obj.getScore(C.cGreen + C.Bold + "Gems").setScore(line--); // Remove Old/Add New player.getScoreboard().resetScores(Get(player.getName()).GetLastGemCount() + ""); - obj.getScore(GetDonation().Get(player.getName()).GetGems() + "").setScore(line--); - Get(player.getName()).SetLastGemCount(GetDonation().Get(player.getName()).GetGems()); + obj.getScore(GetDonation().Get(player.getName()).getBalance(GlobalCurrency.GEM) + "").setScore(line--); + Get(player.getName()).SetLastGemCount(GetDonation().Get(player.getName()).getBalance(GlobalCurrency.GEM)); //Space obj.getScore(" ").setScore(line--); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ValentinesManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ValentinesManager.java index cce5c3625..d0ce99b44 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ValentinesManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ValentinesManager.java @@ -1,19 +1,9 @@ package mineplex.hub.modules; -import org.bukkit.entity.Player; -import org.bukkit.entity.Sheep; -import org.bukkit.event.EventHandler; -import org.bukkit.plugin.java.JavaPlugin; - import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.CurrencyType; -import mineplex.core.common.util.C; -import mineplex.core.common.util.Callback; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilTime; +import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.common.util.*; import mineplex.core.donation.DonationManager; import mineplex.core.gadget.event.GadgetCollideEntityEvent; import mineplex.core.gadget.gadgets.item.ItemLovePotion; @@ -21,6 +11,10 @@ import mineplex.core.server.util.TransactionResponse; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.hub.modules.valentines.Courtship; +import org.bukkit.entity.Player; +import org.bukkit.entity.Sheep; +import org.bukkit.event.EventHandler; +import org.bukkit.plugin.java.JavaPlugin; public class ValentinesManager extends MiniPlugin { @@ -128,6 +122,6 @@ public class ValentinesManager extends MiniPlugin UtilPlayer.message(player, F.main("Reward", "You recieved " + F.elem(_reward + " Mount") + " from " + F.elem(_prefix) + "!")); } } - }, player.getName(), _client.getAccountId(player), _reward, CurrencyType.TREASURE_SHARD, 0, true); + }, player.getName(), _client.getAccountId(player), _reward, GlobalCurrency.TREASURE_SHARD, 0, true); } } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/ClassCombatShop.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/ClassCombatShop.java index 211e1d6de..d29892b44 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/ClassCombatShop.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/ClassCombatShop.java @@ -1,5 +1,17 @@ package mineplex.minecraft.game.classcombat.shop; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.F; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.donation.DonationManager; +import mineplex.core.shop.ShopBase; +import mineplex.core.shop.page.ShopPageBase; +import mineplex.minecraft.game.classcombat.Class.ClientClass; +import mineplex.minecraft.game.classcombat.Class.IPvpClass; +import mineplex.minecraft.game.classcombat.Class.repository.token.CustomBuildToken; +import mineplex.minecraft.game.classcombat.shop.event.OpenClassShopEvent; +import mineplex.minecraft.game.classcombat.shop.page.CustomBuildPage; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Sound; @@ -9,20 +21,6 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.inventory.ItemStack; -import mineplex.core.account.CoreClientManager; -import mineplex.core.donation.DonationManager; -import mineplex.core.shop.ShopBase; -import mineplex.core.shop.page.ShopPageBase; -import mineplex.core.common.CurrencyType; -import mineplex.core.common.util.F; -import mineplex.core.common.util.NautHashMap; -import mineplex.core.common.util.UtilPlayer; -import mineplex.minecraft.game.classcombat.Class.ClientClass; -import mineplex.minecraft.game.classcombat.Class.IPvpClass; -import mineplex.minecraft.game.classcombat.Class.repository.token.CustomBuildToken; -import mineplex.minecraft.game.classcombat.shop.event.OpenClassShopEvent; -import mineplex.minecraft.game.classcombat.shop.page.CustomBuildPage; - public class ClassCombatShop extends ShopBase { private NautHashMap _playerInventoryMap = new NautHashMap(); @@ -34,14 +32,14 @@ public class ClassCombatShop extends ShopBase public ClassCombatShop(ClassShopManager plugin, CoreClientManager clientManager, DonationManager donationManager, boolean skillsOnly, String name) { - super(plugin, clientManager, donationManager, name, CurrencyType.GEM); + super(plugin, clientManager, donationManager, name); _skillsOnly = skillsOnly; } public ClassCombatShop(ClassShopManager plugin, CoreClientManager clientManager, DonationManager donationManager, boolean skillsOnly, String name, IPvpClass iPvpClass, boolean hub) { - super(plugin, clientManager, donationManager, name, CurrencyType.GEM); + super(plugin, clientManager, donationManager, name); _gameClass = iPvpClass; _takeAwayStuff = true; _skillsOnly = skillsOnly; diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/page/SkillPage.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/page/SkillPage.java index 60025020b..08dd9397e 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/page/SkillPage.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/page/SkillPage.java @@ -1,11 +1,8 @@ package mineplex.minecraft.game.classcombat.shop.page; -import java.util.ArrayList; -import java.util.List; - import mineplex.core.account.CoreClientManager; -import mineplex.core.common.CurrencyType; import mineplex.core.common.Rank; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; import mineplex.core.donation.DonationManager; import mineplex.core.itemstack.ItemStackFactory; @@ -20,20 +17,18 @@ import mineplex.minecraft.game.classcombat.Skill.ISkill; import mineplex.minecraft.game.classcombat.item.Item; import mineplex.minecraft.game.classcombat.shop.ClassCombatShop; import mineplex.minecraft.game.classcombat.shop.ClassShopManager; -import mineplex.minecraft.game.classcombat.shop.button.DeselectItemButton; -import mineplex.minecraft.game.classcombat.shop.button.PurchaseItemButton; -import mineplex.minecraft.game.classcombat.shop.button.PurchaseSkillButton; -import mineplex.minecraft.game.classcombat.shop.button.SelectItemButton; -import mineplex.minecraft.game.classcombat.shop.button.SelectSkillButton; +import mineplex.minecraft.game.classcombat.shop.button.*; import mineplex.minecraft.game.classcombat.shop.salespackage.ItemSalesPackage; import mineplex.minecraft.game.classcombat.shop.salespackage.SkillSalesPackage; - import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import java.util.ArrayList; +import java.util.List; + public class SkillPage extends ShopPageBase { private IPvpClass _pvpClass; @@ -398,7 +393,7 @@ public class SkillPage extends ShopPageBase { buildPage(); } - }, this, new SkillSalesPackage(skill), CurrencyType.GEM, player)); + }, this, new SkillSalesPackage(skill), GlobalCurrency.GEM, player)); } private boolean isSkillLocked(ISkill skill) @@ -425,7 +420,7 @@ public class SkillPage extends ShopPageBase { buildPage(); } - }, this, new ItemSalesPackage(item), CurrencyType.GEM, player)); + }, this, new ItemSalesPackage(item), GlobalCurrency.GEM, player)); } public void SelectItem(Player player, Item item) diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/salespackage/ItemSalesPackage.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/salespackage/ItemSalesPackage.java index d30d81984..3ce30af02 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/salespackage/ItemSalesPackage.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/salespackage/ItemSalesPackage.java @@ -1,11 +1,9 @@ package mineplex.minecraft.game.classcombat.shop.salespackage; -import org.bukkit.Material; -import org.bukkit.entity.Player; - -import mineplex.core.common.CurrencyType; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.shop.item.SalesPackageBase; import mineplex.minecraft.game.classcombat.item.Item; +import org.bukkit.Material; public class ItemSalesPackage extends SalesPackageBase { @@ -14,12 +12,6 @@ public class ItemSalesPackage extends SalesPackageBase super("Champions " + item.GetName(), Material.BOOK, (byte)0, item.GetDesc(), item.GetGemCost()); Free = item.isFree(); KnownPackage = false; - CurrencyCostMap.put(CurrencyType.GEM, item.GetGemCost()); - } - - @Override - public void sold(Player player, CurrencyType currencyType) - { - + CurrencyCostMap.put(GlobalCurrency.GEM, item.GetGemCost()); } } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/salespackage/SkillSalesPackage.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/salespackage/SkillSalesPackage.java index fe3873a3d..420427e31 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/salespackage/SkillSalesPackage.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/salespackage/SkillSalesPackage.java @@ -1,11 +1,9 @@ package mineplex.minecraft.game.classcombat.shop.salespackage; -import org.bukkit.Material; -import org.bukkit.entity.Player; - -import mineplex.core.common.CurrencyType; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.shop.item.SalesPackageBase; import mineplex.minecraft.game.classcombat.Skill.ISkill; +import org.bukkit.Material; public class SkillSalesPackage extends SalesPackageBase { @@ -14,12 +12,6 @@ public class SkillSalesPackage extends SalesPackageBase super("Champions " + skill.GetName(), Material.BOOK, (byte)0, skill.GetDesc(0), skill.GetGemCost()); Free = skill.IsFree(); KnownPackage = false; - CurrencyCostMap.put(CurrencyType.GEM, skill.GetGemCost()); - } - - @Override - public void sold(Player player, CurrencyType currencyType) - { - + CurrencyCostMap.put(GlobalCurrency.GEM, skill.GetGemCost()); } } diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java index c91f53c0e..157226516 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java @@ -1,15 +1,10 @@ package mineplex.staffServer.customerSupport; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; - import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; import mineplex.core.common.Rank; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; @@ -17,11 +12,8 @@ import mineplex.core.donation.DonationManager; import mineplex.core.donation.Donor; import mineplex.core.donation.repository.token.CoinTransactionToken; import mineplex.core.donation.repository.token.TransactionToken; -import mineplex.core.gadget.types.Gadget; -import mineplex.core.mount.Mount; import mineplex.serverdata.database.ResultSetCallable; import mineplex.staffServer.salespackage.SalesPackageManager; - import org.bukkit.GameMode; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -34,6 +26,12 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.java.JavaPlugin; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; + public class CustomerSupport extends MiniPlugin implements ResultSetCallable { private CoreClientManager _clientManager; @@ -119,8 +117,8 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable caller.sendMessage(C.cDGreen + C.Strike + "============================================="); caller.sendMessage(C.cBlue + "Name: " + C.cYellow + playerName); caller.sendMessage(C.cBlue + "Rank: " + C.cYellow + (client.GetRank() == null ? C.cRed + "Error rank null!" : (client.GetRank().Name.isEmpty() ? "Regular" : client.GetRank().Name))); - caller.sendMessage(C.cBlue + "Shards: " + C.cYellow + donor.getCoins()); - caller.sendMessage(C.cBlue + "Gems: " + C.cYellow + donor.GetGems()); + caller.sendMessage(C.cBlue + "Shards: " + C.cYellow + donor.getBalance(GlobalCurrency.TREASURE_SHARD)); + caller.sendMessage(C.cBlue + "Gems: " + C.cYellow + donor.getBalance(GlobalCurrency.GEM)); int enjinCoinsReceived = 0; int oldChestsReceived = 0; diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/GemHunterCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/GemHunterCommand.java index 62258e3af..42d53f513 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/GemHunterCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/GemHunterCommand.java @@ -1,13 +1,12 @@ package mineplex.staffServer.salespackage.command; -import org.bukkit.entity.Player; - import mineplex.core.account.CoreClient; import mineplex.core.command.CommandBase; -import mineplex.core.common.CurrencyType; import mineplex.core.common.Rank; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.F; import mineplex.staffServer.salespackage.SalesPackageManager; +import org.bukkit.entity.Player; public class GemHunterCommand extends CommandBase { @@ -41,7 +40,7 @@ public class GemHunterCommand extends CommandBase if (client != null) { - Plugin.getDonationManager().PurchaseUnknownSalesPackage(null, playerName, client.getAccountId(), "Gem Hunter Level " + amount, CurrencyType.GEM, 0, false); + Plugin.getDonationManager().PurchaseUnknownSalesPackage(null, playerName, client.getAccountId(), "Gem Hunter Level " + amount, GlobalCurrency.GEM, 0, false); Plugin.getStatsManager().incrementStat(client.getAccountId(), "Global.GemsEarned", experience); caller.sendMessage(F.main(Plugin.getName(), "Added Level " + amount + " Gem Hunter to " + playerName + "'s account!")); } diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/ItemCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/ItemCommand.java index 0e30045b5..7f834cf3e 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/ItemCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/ItemCommand.java @@ -1,18 +1,17 @@ package mineplex.staffServer.salespackage.command; -import java.util.UUID; - -import org.bukkit.entity.Player; - import mineplex.core.account.CoreClient; import mineplex.core.command.CommandBase; -import mineplex.core.common.CurrencyType; import mineplex.core.common.Rank; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.server.util.TransactionResponse; import mineplex.staffServer.salespackage.SalesPackageManager; +import org.bukkit.entity.Player; + +import java.util.UUID; public class ItemCommand extends CommandBase { @@ -72,7 +71,7 @@ public class ItemCommand extends CommandBase } }, uuid, itemName, amount); } - }, playerName, client.getAccountId(), (amount == 1 ? itemName : itemName + " " + amount), CurrencyType.GEM, 0, false); + }, playerName, client.getAccountId(), (amount == 1 ? itemName : itemName + " " + amount), GlobalCurrency.GEM, 0, false); } else caller.sendMessage(F.main(Plugin.getName(), "Couldn't find " + playerName + "'s account!")); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/booster/GameBoosterManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/booster/GameBoosterManager.java index 7c88911ff..01f2172df 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/booster/GameBoosterManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/booster/GameBoosterManager.java @@ -4,10 +4,9 @@ import mineplex.core.MiniPlugin; import mineplex.core.boosters.Booster; import mineplex.core.boosters.BoosterManager; import mineplex.core.boosters.event.BoosterActivateEvent; -import mineplex.core.boosters.event.BoosterExpireEvent; import mineplex.core.boosters.tips.BoosterTipManager; import mineplex.core.boosters.tips.TipAddResult; -import mineplex.core.common.CurrencyType; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.jsonchat.ClickEvent; import mineplex.core.common.jsonchat.HoverEvent; import mineplex.core.common.jsonchat.JsonMessage; @@ -63,8 +62,8 @@ public class GameBoosterManager extends MiniPlugin _boosterManager.getTipManager().addTip(player, active, result -> { if (result == TipAddResult.SUCCESS) { - UtilPlayer.message(player, F.main("Tip", "You thanked " + F.name(active.getPlayerName()) + ". They earned " + F.currency(CurrencyType.TREASURE_SHARD, BoosterTipManager.TIP_FOR_SPONSOR) + " and you got " - + F.currency(CurrencyType.TREASURE_SHARD, BoosterTipManager.TIP_FOR_TIPPER)) + " in return!"); + UtilPlayer.message(player, F.main("Tip", "You thanked " + F.name(active.getPlayerName()) + ". They earned " + F.currency(GlobalCurrency.TREASURE_SHARD, BoosterTipManager.TIP_FOR_SPONSOR) + " and you got " + + F.currency(GlobalCurrency.TREASURE_SHARD, BoosterTipManager.TIP_FOR_TIPPER)) + " in return!"); player.playSound(player.getLocation(), Sound.LEVEL_UP, 1f, 1f); } else { @@ -88,7 +87,7 @@ public class GameBoosterManager extends MiniPlugin Bukkit.broadcastMessage(F.main("Amplifier", F.name(booster.getPlayerName()) + " has activated a Game Amplifier on " + F.elem(event.getBoosterGroup().replaceAll("_", " ")) + "!")); } - JsonMessage message = new JsonMessage(F.main("Amplifier", F.elem("Click here") + " to thank them and receive " + F.currency(CurrencyType.TREASURE_SHARD, BoosterTipManager.TIP_FOR_TIPPER) + "!")); + JsonMessage message = new JsonMessage(F.main("Amplifier", F.elem("Click here") + " to thank them and receive " + F.currency(GlobalCurrency.TREASURE_SHARD, BoosterTipManager.TIP_FOR_TIPPER) + "!")); message.click(ClickEvent.RUN_COMMAND, "/amplifier thank " + _boosterGroup); message.hover(HoverEvent.SHOW_TEXT, C.cGreen + "Click to Thank"); message.send(JsonMessage.MessageType.CHAT_BOX, UtilServer.getPlayers()); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventGame.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventGame.java index 9543fa0b7..315e8c117 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventGame.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventGame.java @@ -1,29 +1,8 @@ package nautilus.game.arcade.game.games.event; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; - -import mineplex.core.common.util.Callback; -import mineplex.core.common.util.F; -import mineplex.core.common.util.NautHashMap; -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.UtilInv; -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.disguise.disguises.DisguiseBase; -import mineplex.core.disguise.disguises.DisguiseBat; -import mineplex.core.disguise.disguises.DisguiseChicken; -import mineplex.core.disguise.disguises.DisguiseEnderman; -import mineplex.core.disguise.disguises.DisguiseWither; +import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.common.util.*; +import mineplex.core.disguise.disguises.*; import mineplex.core.gadget.event.GadgetEnableEvent; import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetType; @@ -42,14 +21,7 @@ import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.games.event.kits.KitPlayer; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.managers.GameHostManager; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Effect; -import org.bukkit.GameMode; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; +import org.bukkit.*; import org.bukkit.block.BlockFace; import org.bukkit.block.Sign; import org.bukkit.entity.Entity; @@ -72,6 +44,8 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; +import java.util.*; + public class EventGame extends Game { private GameHostManager _mps; @@ -1242,7 +1216,7 @@ public class EventGame extends Game return; } - if(Manager.GetDonation().Get(event.getPlayer()).GetGems() < price) + if(Manager.GetDonation().Get(event.getPlayer()).getBalance(GlobalCurrency.GEM) < price) { UtilPlayer.message(event.getPlayer(), F.main("Event", "You dont have enough Gems.")); return; 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 19d8cfa40..29f27d376 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,19 +1,7 @@ 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 mineplex.core.common.CurrencyType; -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.currency.GlobalCurrency; +import mineplex.core.common.util.*; import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; @@ -29,37 +17,22 @@ 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.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.game.games.halloween.waves.*; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.managers.chat.ChatStatData; - import net.minecraft.server.v1_8_R3.PacketPlayOutNamedSoundEffect; - -import org.bukkit.ChatColor; -import org.bukkit.Difficulty; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; +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.EntityDamageByEntityEvent; +import org.bukkit.event.entity.*; 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 java.util.*; + public class Halloween extends SoloGame { //Wave Data @@ -436,7 +409,7 @@ public class Halloween extends SoloGame if (!player.isOnline()) continue; - Manager.GetDonation().PurchaseUnknownSalesPackage(null, player.getName(), Manager.GetClients().Get(player).getAccountId(), "Decrepit Warhorse", CurrencyType.TREASURE_SHARD, 0, true); + Manager.GetDonation().PurchaseUnknownSalesPackage(null, player.getName(), Manager.GetClients().Get(player).getAccountId(), "Decrepit Warhorse", GlobalCurrency.TREASURE_SHARD, 0, true); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/KitEvolveShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/KitEvolveShop.java index 40ccaf0d7..b6d739c57 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/KitEvolveShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/KitEvolveShop.java @@ -1,16 +1,14 @@ package nautilus.game.arcade.game.games.searchanddestroy; -import java.util.ArrayList; - import mineplex.core.account.CoreClientManager; -import mineplex.core.common.CurrencyType; import mineplex.core.donation.DonationManager; import mineplex.core.shop.ShopBase; import mineplex.core.shop.page.ShopPageBase; import nautilus.game.arcade.game.games.searchanddestroy.KitManager.UpgradeKit; - import org.bukkit.entity.Player; +import java.util.ArrayList; + public class KitEvolveShop extends ShopBase { @@ -18,9 +16,9 @@ public class KitEvolveShop extends ShopBase private ArrayList _kits; public KitEvolveShop(KitEvolve plugin, SearchAndDestroy arcadeManager, CoreClientManager clientManager, - DonationManager donationManager, ArrayList kits, CurrencyType... currencyTypes) + DonationManager donationManager, ArrayList kits) { - super(plugin, clientManager, donationManager, "Kit Evolve Menu", currencyTypes); + super(plugin, clientManager, donationManager, "Kit Evolve Menu"); _arcadeManager = arcadeManager; _kits = kits; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/WizardSpellMenuShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/WizardSpellMenuShop.java index 4c7cb0154..cda8ebd37 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/WizardSpellMenuShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/WizardSpellMenuShop.java @@ -1,11 +1,9 @@ package nautilus.game.arcade.game.games.wizards; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.CurrencyType; import mineplex.core.donation.DonationManager; import mineplex.core.shop.ShopBase; import mineplex.core.shop.page.ShopPageBase; - import org.bukkit.entity.Player; public class WizardSpellMenuShop extends ShopBase @@ -13,9 +11,9 @@ public class WizardSpellMenuShop extends ShopBase private Wizards _wizards; public WizardSpellMenuShop(WizardSpellMenu plugin, CoreClientManager clientManager, DonationManager donationManager, - Wizards wizard, CurrencyType... currencyTypes) + Wizards wizard) { - super(plugin, clientManager, donationManager, "Kit Evolve Menu", currencyTypes); + super(plugin, clientManager, donationManager, "Kit Evolve Menu"); _wizards = wizard; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/spectatorMenu/SpectatorShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/spectatorMenu/SpectatorShop.java index 26b0de8c3..f7dad01e5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/spectatorMenu/SpectatorShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/spectatorMenu/SpectatorShop.java @@ -1,15 +1,13 @@ package nautilus.game.arcade.gui.spectatorMenu; -import org.bukkit.entity.Player; - import mineplex.core.account.CoreClientManager; -import mineplex.core.common.CurrencyType; import mineplex.core.donation.DonationManager; import mineplex.core.shop.ShopBase; import mineplex.core.shop.page.ShopPageBase; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.addons.compass.CompassAddon; import nautilus.game.arcade.gui.spectatorMenu.page.SpectatorPage; +import org.bukkit.entity.Player; /** * Created by shaun on 14-09-24. @@ -19,9 +17,9 @@ public class SpectatorShop extends ShopBase private ArcadeManager _arcadeManager; - public SpectatorShop(CompassAddon plugin, ArcadeManager arcadeManager, CoreClientManager clientManager, DonationManager donationManager, CurrencyType... currencyTypes) + public SpectatorShop(CompassAddon plugin, ArcadeManager arcadeManager, CoreClientManager clientManager, DonationManager donationManager) { - super(plugin, clientManager, donationManager, "Spectate Menu", currencyTypes); + super(plugin, clientManager, donationManager, "Spectate Menu"); _arcadeManager = arcadeManager; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/ProgressingKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/ProgressingKit.java index 9d8679a34..9ab3d48ab 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/ProgressingKit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/ProgressingKit.java @@ -1,8 +1,8 @@ package nautilus.game.arcade.kit; import com.google.common.collect.Lists; -import mineplex.core.common.CurrencyType; import mineplex.core.common.Rank; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -242,7 +242,7 @@ public abstract class ProgressingKit extends Kit implements ProgressiveKit { PlayerKit playerKit = _dataManager.get(player); Donor donor = Manager.GetDonation().Get(Bukkit.getPlayer(player)); - return Calculations.canUpgrade(playerKit.getLevel(getInternalName()), donor.GetGems()); + return Calculations.canUpgrade(playerKit.getLevel(getInternalName()), donor.getBalance(GlobalCurrency.GEM)); } @Override @@ -298,7 +298,7 @@ public abstract class ProgressingKit extends Kit implements ProgressiveKit { return true; } - else if (this.GetAvailability() == KitAvailability.Gem && donor.GetBalance(CurrencyType.GEM) >= this.GetCost()) + else if (this.GetAvailability() == KitAvailability.Gem && donor.getBalance(GlobalCurrency.GEM) >= this.GetCost()) { Manager.GetShop().openPageForPlayer(player, new ConfirmationPage<>( Manager, Manager.GetShop(), Manager.GetClients(), Manager.GetDonation(), () -> { @@ -306,7 +306,7 @@ public abstract class ProgressingKit extends Kit implements ProgressiveKit { Manager.GetGame().SetKit(player, this, true); } - }, null, new KitPackage(Manager.GetGame().GetType().GetKitGameName(Manager.GetGame()), this), CurrencyType.GEM, player)); + }, null, new KitPackage(Manager.GetGame().GetType().GetKitGameName(Manager.GetGame()), this), GlobalCurrency.GEM, player)); } else if (this.GetAvailability() == KitAvailability.Achievement) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java index 87c345881..b8450e200 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java @@ -2,6 +2,7 @@ package nautilus.game.arcade.managers; import mineplex.core.account.CoreClient; import mineplex.core.common.Rank; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.*; import mineplex.core.common.util.UtilBlockText.TextAlign; import mineplex.core.donation.Donor; @@ -1115,9 +1116,9 @@ public class GameLobbyManager implements Listener // Remove old entry.getValue().resetScores(_gemMap.get(entry.getKey()) + " "); // Set new - objective.getScore(Manager.GetDonation().Get(entry.getKey().getName()).GetGems() + " ").setScore(line--); + objective.getScore(Manager.GetDonation().Get(entry.getKey().getName()).getBalance(GlobalCurrency.GEM) + " ").setScore(line--); - _gemMap.put(entry.getKey(), Manager.GetDonation().Get(entry.getKey().getName()).GetGems()); + _gemMap.put(entry.getKey(), Manager.GetDonation().Get(entry.getKey().getName()).getBalance(GlobalCurrency.GEM)); //Server objective.getScore(" ").setScore(line--); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameRewardManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameRewardManager.java index c39b46247..5aa9b23c5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameRewardManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameRewardManager.java @@ -1,28 +1,11 @@ package nautilus.game.arcade.managers; -import java.lang.reflect.Field; -import java.util.HashMap; - -import org.bukkit.Bukkit; -import org.bukkit.Sound; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftHumanEntity; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerQuitEvent; - import com.mojang.authlib.GameProfile; - import mineplex.core.achievement.Achievement; import mineplex.core.boosters.Booster; import mineplex.core.common.Rank; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTime; +import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.common.util.*; import mineplex.minecraft.game.core.combat.CombatComponent; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import mineplex.serverdata.Utility; @@ -37,6 +20,17 @@ import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.game.GemData; import net.minecraft.server.v1_8_R3.EntityHuman; +import org.bukkit.Sound; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftHumanEntity; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerQuitEvent; + +import java.lang.reflect.Field; +import java.util.HashMap; /** * This class is used to reward gems and shards at the end of a game, or when players leave the server. @@ -405,8 +399,8 @@ public class GameRewardManager implements Listener if (give) { UtilPlayer.message(player, F.elem(C.cWhite + "§lYou now have " + - C.cGreen + C.Bold + (Manager.GetDonation().Get(player.getName()).GetGems() + totalGems) + " Gems") + C.cWhite + C.Bold + " and " + - F.elem(C.cAqua + C.Bold + (Manager.GetDonation().Get(player.getName()).getCoins() + shards) + " Treasure Shards")); + C.cGreen + C.Bold + (Manager.GetDonation().Get(player.getName()).getBalance(GlobalCurrency.GEM) + totalGems) + " Gems") + C.cWhite + C.Bold + " and " + + F.elem(C.cAqua + C.Bold + (Manager.GetDonation().Get(player.getName()).getBalance(GlobalCurrency.TREASURE_SHARD) + shards) + " Treasure Shards")); } else { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/shop/ArcadeShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/shop/ArcadeShop.java index 82919530d..eea1cfa52 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/shop/ArcadeShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/shop/ArcadeShop.java @@ -1,19 +1,17 @@ package nautilus.game.arcade.shop; -import org.bukkit.entity.Player; - -import nautilus.game.arcade.ArcadeManager; import mineplex.core.account.CoreClientManager; import mineplex.core.donation.DonationManager; -import mineplex.core.common.CurrencyType; import mineplex.core.shop.ShopBase; import mineplex.core.shop.page.ShopPageBase; +import nautilus.game.arcade.ArcadeManager; +import org.bukkit.entity.Player; public class ArcadeShop extends ShopBase { public ArcadeShop(ArcadeManager plugin, CoreClientManager clientManager, DonationManager donationManager) { - super(plugin, clientManager, donationManager, "Shop", CurrencyType.GEM); + super(plugin, clientManager, donationManager, "Shop"); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/shop/KitPackage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/shop/KitPackage.java index 7ff7bdae3..6fbea37dc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/shop/KitPackage.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/shop/KitPackage.java @@ -1,10 +1,8 @@ package nautilus.game.arcade.shop; -import org.bukkit.entity.Player; - -import nautilus.game.arcade.kit.Kit; -import mineplex.core.common.CurrencyType; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.shop.item.SalesPackageBase; +import nautilus.game.arcade.kit.Kit; public class KitPackage extends SalesPackageBase { @@ -12,12 +10,6 @@ public class KitPackage extends SalesPackageBase { super(gameName + " " + kit.GetName(), kit.getDisplayMaterial(), kit.GetDesc()); KnownPackage = false; - CurrencyCostMap.put(CurrencyType.GEM, kit.GetCost()); - } - - @Override - public void sold(Player player, CurrencyType currencyType) - { - + CurrencyCostMap.put(GlobalCurrency.GEM, kit.GetCost()); } } From 3cddf35d1222f53e8e6fac385d4e095e0bc22c5a Mon Sep 17 00:00:00 2001 From: cnr Date: Mon, 25 Jul 2016 21:57:24 -0500 Subject: [PATCH 62/90] Refactor out legacy ConfirmationPage --- .../core/boosters/BoosterProcessor.java | 4 + .../core/boosters/gui/BoosterPage.java | 4 +- .../gui/button/FountainAddButton.java | 16 +- .../core/cosmetic/ui/button/MountButton.java | 16 +- .../core/cosmetic/ui/page/GadgetPage.java | 14 +- .../core/cosmetic/ui/page/PetTagPage.java | 68 ++-- .../core/donation/DonationManager.java | 22 ++ .../shop/confirmation/ConfirmationPage.java | 16 +- .../confirmation/ConfirmationProcessor.java | 3 + .../core/shop/item/ICurrencyPackage.java | 4 +- .../core/shop/item/SalesPackageBase.java | 12 +- .../core/shop/item/SalesPackageProcessor.java | 97 ++++++ .../core/shop/page/ConfirmationPage.java | 324 ------------------ .../core/treasure/gui/BuyChestButton.java | 15 +- .../game/clans/shop/energy/EnergyPackage.java | 17 - .../clans/shop/energy/EnergyShopButton.java | 10 +- .../game/classcombat/shop/page/SkillPage.java | 21 +- .../game/arcade/kit/ProgressingKit.java | 10 +- 18 files changed, 229 insertions(+), 444 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/shop/item/SalesPackageProcessor.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/shop/page/ConfirmationPage.java delete mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyPackage.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/boosters/BoosterProcessor.java b/Plugins/Mineplex.Core/src/mineplex/core/boosters/BoosterProcessor.java index 0cc567715..23ae2e6eb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/boosters/BoosterProcessor.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/boosters/BoosterProcessor.java @@ -6,6 +6,7 @@ import mineplex.core.common.util.UtilTime; import mineplex.core.shop.confirmation.ConfirmationCallback; import mineplex.core.shop.confirmation.ConfirmationProcessor; import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; /** * @author Shaun Bennett @@ -21,6 +22,9 @@ public class BoosterProcessor implements ConfirmationProcessor _player = player; } + @Override + public void init(Inventory inventory) {} + @Override public void process(ConfirmationCallback callback) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/boosters/gui/BoosterPage.java b/Plugins/Mineplex.Core/src/mineplex/core/boosters/gui/BoosterPage.java index 3a6315ec9..9e4ae655f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/boosters/gui/BoosterPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/boosters/gui/BoosterPage.java @@ -4,7 +4,6 @@ import mineplex.core.account.CoreClientManager; import mineplex.core.boosters.Booster; import mineplex.core.boosters.BoosterManager; import mineplex.core.boosters.BoosterProcessor; -import mineplex.core.common.Pair; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilTime; import mineplex.core.donation.DonationManager; @@ -115,8 +114,7 @@ public class BoosterPage extends ShopPageBase ShopItem booster = new ShopItem(Material.SUGAR, "Game Amplifier", lore.toArray(new String[0]), 0, false, false); BoosterProcessor processor = new BoosterProcessor(getPlugin(), getPlayer()); - ConfirmationPage page = new ConfirmationPage<>(getPlugin(), getShop(), - getClientManager(), getDonationManager(), getPlayer(), this, processor, booster); + ConfirmationPage page = new ConfirmationPage<>(getPlayer(), this, processor, booster); getShop().openPageForPlayer(getPlayer(), page); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/gui/button/FountainAddButton.java b/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/gui/button/FountainAddButton.java index 622b44add..3dcc6ebd7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/gui/button/FountainAddButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/gui/button/FountainAddButton.java @@ -1,13 +1,12 @@ package mineplex.core.brawl.fountain.gui.button; -import mineplex.core.brawl.fountain.FountainManager; import mineplex.core.brawl.fountain.GemFountainSalesPackage; import mineplex.core.brawl.fountain.gui.FountainPage; -import mineplex.core.brawl.fountain.gui.FountainShop; import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.shop.confirmation.ConfirmationPage; import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.SalesPackageBase; -import mineplex.core.shop.page.ConfirmationPage; +import mineplex.core.shop.item.SalesPackageProcessor; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -30,13 +29,10 @@ public class FountainAddButton implements IButton @Override public void onClick(Player player, ClickType clickType) { - _page.getShop().openPageForPlayer(player, new ConfirmationPage(_page.getPlugin(), _page.getShop(), _page.getClientManager(), _page.getDonationManager(), new Runnable() + _page.getShop().openPageForPlayer(player, new ConfirmationPage<>(player, _page, new SalesPackageProcessor(player, GlobalCurrency.GEM, _salesPackage, _page.getDonationManager(), () -> { - public void run() - { - _page.getPlugin().getGemFountain().increment(player, _gems, null); - _page.refresh(); - } - }, _page, _salesPackage, GlobalCurrency.GEM, player)); + _page.getPlugin().getGemFountain().increment(player, _gems, null); + _page.refresh(); + }), _salesPackage.buildIcon())); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/MountButton.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/MountButton.java index e60b042f5..3d1039572 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/MountButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/MountButton.java @@ -1,12 +1,11 @@ package mineplex.core.cosmetic.ui.button; import mineplex.core.common.currency.GlobalCurrency; -import mineplex.core.cosmetic.CosmeticManager; -import mineplex.core.cosmetic.ui.CosmeticShop; import mineplex.core.cosmetic.ui.page.MountPage; import mineplex.core.mount.Mount; +import mineplex.core.shop.confirmation.ConfirmationPage; import mineplex.core.shop.item.IButton; -import mineplex.core.shop.page.ConfirmationPage; +import mineplex.core.shop.item.SalesPackageProcessor; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -24,13 +23,10 @@ public class MountButton implements IButton @Override public void onClick(final Player player, ClickType clickType) { - _page.getShop().openPageForPlayer(player, new ConfirmationPage(_page.getPlugin(), _page.getShop(), _page.getClientManager(), _page.getDonationManager(), new Runnable() + _page.getShop().openPageForPlayer(player, new ConfirmationPage<>(player, _page, new SalesPackageProcessor(player, GlobalCurrency.TREASURE_SHARD, _mount, _page.getDonationManager(), () -> { - public void run() - { - _page.getPlugin().getInventoryManager().addItemToInventory(null, player, _mount.getName(), 1); - _page.refresh(); - } - }, _page, _mount, GlobalCurrency.TREASURE_SHARD, player)); + _page.getPlugin().getInventoryManager().addItemToInventory(null, player, _mount.getName(), 1); + _page.refresh(); + }), _mount.buildIcon())); } } 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 19c2f2a8c..cd40f9b06 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 @@ -19,9 +19,10 @@ import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetType; import mineplex.core.gadget.types.HatGadget; import mineplex.core.gadget.types.ItemGadget; +import mineplex.core.shop.confirmation.ConfirmationPage; import mineplex.core.shop.item.IButton; +import mineplex.core.shop.item.SalesPackageProcessor; import mineplex.core.shop.item.ShopItem; -import mineplex.core.shop.page.ConfirmationPage; import mineplex.core.shop.page.ShopPageBase; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -371,14 +372,11 @@ public class GadgetPage extends ShopPageBase UtilPlayer.message(player, F.main("Disguise", "You cant buy things while you are disguised!")); return; } - getShop().openPageForPlayer(getPlayer(), new ConfirmationPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), new Runnable() + getShop().openPageForPlayer(getPlayer(), new ConfirmationPage<>(player, this, new SalesPackageProcessor(player, GlobalCurrency.TREASURE_SHARD, gadget, getDonationManager(), () -> { - public void run() - { - getPlugin().getInventoryManager().addItemToInventory(getPlayer(), gadget.getName(), (gadget instanceof ItemGadget ? ((ItemGadget) gadget).getAmmo().getQuantity() : gadget.getQuantity())); - refresh(); - } - }, this, (gadget instanceof ItemGadget ? ((ItemGadget) gadget).getAmmo() : gadget), GlobalCurrency.TREASURE_SHARD, getPlayer())); + getPlugin().getInventoryManager().addItemToInventory(getPlayer(), gadget.getName(), (gadget instanceof ItemGadget ? ((ItemGadget) gadget).getAmmo().getQuantity() : gadget.getQuantity())); + refresh(); + }), gadget.buildIcon())); } public void activateGadget(Player player, Gadget gadget) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetTagPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetTagPage.java index 63079412e..0a5c568fa 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetTagPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetTagPage.java @@ -15,7 +15,9 @@ import mineplex.core.pet.Pet; import mineplex.core.pet.PetExtra; import mineplex.core.pet.repository.token.PetChangeToken; import mineplex.core.pet.repository.token.PetToken; -import mineplex.core.shop.page.ConfirmationPage; +import mineplex.core.shop.confirmation.ConfirmationPage; +import mineplex.core.shop.item.SalesPackageBase; +import mineplex.core.shop.item.SalesPackageProcessor; import mineplex.core.shop.page.ShopPageBase; import net.minecraft.server.v1_8_R3.ItemStack; import net.minecraft.server.v1_8_R3.Items; @@ -92,44 +94,42 @@ public class PetTagPage extends ShopPageBase } PetExtra tag = new PetExtra("Rename " + _pet.getName() + " to " + _tagName, Material.NAME_TAG, 100); + final SalesPackageBase salesPackage = _petPurchase ? _pet : tag; _pet.setDisplayName(C.cGreen + "Purchase " + _tagName); - - getShop().openPageForPlayer(getPlayer(), new ConfirmationPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), new Runnable() + + getShop().openPageForPlayer(getPlayer(), new ConfirmationPage<>(_player, this, new SalesPackageProcessor(_player, GlobalCurrency.TREASURE_SHARD, salesPackage, _donationManager, () -> { - public void run() + PetChangeToken token = new PetChangeToken(); + + if (getClientManager().Get(getPlayer()) != null) + token.AccountId = getClientManager().Get(getPlayer()).getAccountId(); + else + token.AccountId = PlayerCache.getInstance().getPlayer(getPlayer().getUniqueId()).getAccountId(); + + token.Name = getPlayer().getName(); + token.PetType = _pet.getPetType().toString(); + token.PetId = _pet.getPetType().ordinal(); + token.PetName = _tagName; + + PetToken petToken = new PetToken(); + petToken.PetType = token.PetType; + + if (_petPurchase) { - PetChangeToken token = new PetChangeToken(); - - if (getClientManager().Get(getPlayer()) != null) - token.AccountId = getClientManager().Get(getPlayer()).getAccountId(); - else - token.AccountId = PlayerCache.getInstance().getPlayer(getPlayer().getUniqueId()).getAccountId(); - - token.Name = getPlayer().getName(); - token.PetType = _pet.getPetType().toString(); - token.PetId = _pet.getPetType().ordinal(); - token.PetName = _tagName; - - PetToken petToken = new PetToken(); - petToken.PetType = token.PetType; - - if (_petPurchase) - { - getPlugin().getPetManager().getRepository().AddPet(token); - getPlugin().getPetManager().addPetOwnerToQueue(getPlayer().getName(), _pet.getPetType()); - } - else - { - getPlugin().getPetManager().getRepository().UpdatePet(token); - getPlugin().getPetManager().addRenamePetToQueue(getPlayer().getName(), token.PetName); - } - - getPlugin().getPetManager().Get(getPlayer()).getPets().put(_pet.getPetType(), token.PetName); - - getShop().openPageForPlayer(getPlayer(), new Menu(getPlugin(), getShop(), getClientManager(), getDonationManager(), getPlayer())); + getPlugin().getPetManager().getRepository().AddPet(token); + getPlugin().getPetManager().addPetOwnerToQueue(getPlayer().getName(), _pet.getPetType()); } - }, null, _petPurchase ? _pet : tag, GlobalCurrency.TREASURE_SHARD, getPlayer())); + else + { + getPlugin().getPetManager().getRepository().UpdatePet(token); + getPlugin().getPetManager().addRenamePetToQueue(getPlayer().getName(), token.PetName); + } + + getPlugin().getPetManager().Get(getPlayer()).getPets().put(_pet.getPetType(), token.PetName); + + getShop().openPageForPlayer(getPlayer(), new Menu(getPlugin(), getShop(), getClientManager(), getDonationManager(), getPlayer())); + }), salesPackage.buildIcon())); } public void SetTagName(String tagName) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java index 4cbab4787..206d245be 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java @@ -112,6 +112,28 @@ public class DonationManager extends MiniClientPlugin }, name, accountId, packageName, currencyType, cost); } + public void PurchaseKnownSalesPackage(final Callback callback, final String name, final UUID uuid, final int cost, final int salesPackageId) + { + _repository.PurchaseKnownSalesPackage(new Callback() + { + public void run(TransactionResponse response) + { + if (response == TransactionResponse.Success) + { + Donor donor = Get(name); + + if (donor != null) + { + donor.AddSalesPackagesOwned(salesPackageId); + } + } + + if (callback != null) + callback.run(response); + } + }, name, uuid.toString(), cost, salesPackageId); + } + public void RewardGems(Callback callback, String caller, String name, UUID uuid, int amount) { RewardGems(callback, caller, name, uuid, amount, true); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/shop/confirmation/ConfirmationPage.java b/Plugins/Mineplex.Core/src/mineplex/core/shop/confirmation/ConfirmationPage.java index 5bcdcfb82..67a43b2e8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/shop/confirmation/ConfirmationPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/shop/confirmation/ConfirmationPage.java @@ -31,11 +31,21 @@ public class ConfirmationPage returnPage, ConfirmationProcessor processor, ItemStack displayItem) + public ConfirmationPage(Player player, ShopPageBase returnPage, ConfirmationProcessor processor, ItemStack displayItem) + { + super(returnPage.getPlugin(), returnPage.getShop(), returnPage.getClientManager(), returnPage.getDonationManager(), "Confirmation", player); + + _returnPage = returnPage; + _displayItem = displayItem; + _processor = processor; + + buildPage(); + } + + public ConfirmationPage(Player player, PluginType plugin, ShopType shop, CoreClientManager clientManager, DonationManager donationManager, ConfirmationProcessor processor, ItemStack displayItem) { super(plugin, shop, clientManager, donationManager, "Confirmation", player); - _returnPage = returnPage; _displayItem = displayItem; _processor = processor; @@ -49,6 +59,8 @@ public class ConfirmationPage CurrencyCostMap; + protected NautHashMap CurrencyCostMap; protected boolean KnownPackage = true; protected boolean OneTimePurchaseOnly = true; @@ -65,7 +66,7 @@ public abstract class SalesPackageBase implements ICurrencyPackage, IDisplayPack } @Override - public int getCost(Currency currencyType) + public int getCost(GlobalCurrency currencyType) { return CurrencyCostMap.containsKey(currencyType) ? CurrencyCostMap.get(currencyType) : 0; } @@ -130,4 +131,9 @@ public abstract class SalesPackageBase implements ICurrencyPackage, IDisplayPack { DisplayName = name; } + + public ItemStack buildIcon() + { + return new ItemBuilder(_displayMaterial).setData(_displayData).setTitle(DisplayName).addLore(Description).build(); + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/shop/item/SalesPackageProcessor.java b/Plugins/Mineplex.Core/src/mineplex/core/shop/item/SalesPackageProcessor.java new file mode 100644 index 000000000..d7c75985f --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/shop/item/SalesPackageProcessor.java @@ -0,0 +1,97 @@ +package mineplex.core.shop.item; + +import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.common.util.C; +import mineplex.core.donation.DonationManager; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.server.util.TransactionResponse; +import mineplex.core.shop.confirmation.ConfirmationCallback; +import mineplex.core.shop.confirmation.ConfirmationProcessor; +import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; + +public class SalesPackageProcessor implements ConfirmationProcessor { + /* + int goldCount = _donationManager.Get(_player).getGold(); + int cost = _salesItem.getCost(_currencyType); + + if (cost > goldCount) + showResultsPage(TransactionResponse.InsufficientFunds); + else + { + _donationManager.rewardGold(new Callback() + { + @Override + public void run(Boolean data) + { + if (data) + { + showResultsPage(TransactionResponse.Success); + _player.playSound(_player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f); + } + else + { + showResultsPage(TransactionResponse.Failed); + } + } + }, "Energy Purchase", _player.getName(), getClientManager().Get(_player).getAccountId(), -cost); + + } + */ + private final GlobalCurrency _currencyType; + private final SalesPackageBase _salesItem; + private final DonationManager _donationManager; + private final Player _player; + private final Runnable _runAfterPurchase; + + public SalesPackageProcessor(Player player, GlobalCurrency currencyType, SalesPackageBase salesItem, DonationManager donationManager, Runnable runAfterPurchase) + { + _currencyType = currencyType; + _salesItem = salesItem; + _donationManager = donationManager; + _player = player; + _runAfterPurchase = runAfterPurchase; + } + + @Override + public void init(Inventory inventory) + { + inventory.setItem(4, new ItemBuilder(_currencyType.getDisplayMaterial()).setTitle(_currencyType.getPrefix()).addLore(C.cGray + _salesItem.getCost(_currencyType) + " " + _currencyType.getPrefix() + " will be", C.cGray + "deducted from your account balance").build()); + } + + @Override + public void process(ConfirmationCallback callback) + { + if (_salesItem.isKnown()) + { + _donationManager.PurchaseKnownSalesPackage(response -> showResults(callback, response), _player.getName(), _player.getUniqueId(), _salesItem.getCost(_currencyType), _salesItem.getSalesPackageId()); + } + else + { + _donationManager.PurchaseUnknownSalesPackage(response -> showResults(callback, response), _player.getName(), _donationManager.getClientManager().Get(_player).getAccountId(), _salesItem.getName(), _currencyType, _salesItem.getCost(_currencyType), _salesItem.oneTimePurchase()); + } + } + + private void showResults(ConfirmationCallback callback, TransactionResponse response) + { + switch (response) + { + case Failed: + callback.reject("There was an error processing your request."); + break; + case AlreadyOwns: + callback.reject("You already own this package."); + break; + case InsufficientFunds: + callback.reject("Your account has insufficient funds."); + break; + case Success: + callback.resolve("Your purchase was successful."); + + if (_runAfterPurchase != null) + _runAfterPurchase.run(); + + break; + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ConfirmationPage.java b/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ConfirmationPage.java deleted file mode 100644 index f388caf9c..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ConfirmationPage.java +++ /dev/null @@ -1,324 +0,0 @@ -package mineplex.core.shop.page; - -import mineplex.core.MiniPlugin; -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.currency.Currency; -import mineplex.core.common.util.C; -import mineplex.core.donation.DonationManager; -import mineplex.core.server.util.TransactionResponse; -import mineplex.core.shop.ShopBase; -import mineplex.core.shop.item.IButton; -import mineplex.core.shop.item.SalesPackageBase; -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.inventory.ClickType; - -public class ConfirmationPage> extends ShopPageBase implements Runnable -{ - private Runnable _runnable; - private ShopPageBase _returnPage; - private SalesPackageBase _salesItem; - private int _okSquareSlotStart; - private boolean _processing; - private int _progressCount; - private ShopItem _progressItem; - private int _taskId; - private final Currency _currencyType; - - public ConfirmationPage(PluginType plugin, ShopType shop, CoreClientManager clientManager, DonationManager donationManager, Runnable runnable, ShopPageBase returnPage, SalesPackageBase salesItem, Currency currencyType, Player player) - { - super(plugin, shop, clientManager, donationManager, " Confirmation", player); - - _runnable = runnable; - _returnPage = returnPage; - _salesItem = salesItem; - _progressItem = new ShopItem(Material.LAPIS_BLOCK, (byte)11, ChatColor.BLUE + "Processing", null, 1, false, true); - _okSquareSlotStart = 27; - _currencyType = currencyType; - - if (getShop().canPlayerAttemptPurchase(player)) - { - buildPage(); - } - else - { - buildErrorPage(new String[]{ChatColor.RED + "You have attempted too many invalid transactions.", ChatColor.RED + "Please wait 10 seconds before retrying."}); - _taskId = plugin.getScheduler().scheduleSyncRepeatingTask(plugin.getPlugin(), this, 2L, 2L); - } - } - - protected void buildPage() - { - this.getInventory().setItem(22, new ShopItem(_salesItem.getDisplayMaterial(), (byte)0, _salesItem.getDisplayName(), _salesItem.getDescription(), 1, false, true).getHandle()); - - IButton okClicked = new IButton() - { - @Override - public void onClick(Player player, ClickType clickType) - { - okClicked(player); - } - }; - - IButton cancelClicked = new IButton() - { - @Override - public void onClick(Player player, ClickType clickType) - { - cancelClicked(player); - } - }; - - buildSquareAt(_okSquareSlotStart, new ShopItem(Material.EMERALD_BLOCK, (byte) 0, ChatColor.GREEN + "OK", null, 1, false, true), okClicked); - buildSquareAt(_okSquareSlotStart + 6, new ShopItem(Material.REDSTONE_BLOCK, (byte) 0, ChatColor.RED + "CANCEL", null, 1, false, true), cancelClicked); - - this.getInventory().setItem(4, new ShopItem(_currencyType.getDisplayMaterial(), (byte)0, _currencyType.getPrefix(), new String[] { C.cGray + _salesItem.getCost(_currencyType) + " " + _currencyType.getPrefix() + " will be", C.cGray + "deducted from your account balance." }, 1, false, true).getHandle()); - } - - protected void okClicked(Player player) - { - processTransaction(); - } - - protected void cancelClicked(Player player) - { - getPlugin().getScheduler().cancelTask(_taskId); - - if (_returnPage != null) - getShop().openPageForPlayer(player, _returnPage); - else - { - player.closeInventory(); - } - - } - - private void buildSquareAt(int slot, ShopItem item, IButton button) - { - addButton(slot, item, button); - addButton(slot + 1, item, button); - addButton(slot + 2, item, button); - - slot += 9; - - addButton(slot, item, button); - addButton(slot + 1, item, button); - addButton(slot + 2, item, button); - - slot += 9; - - addButton(slot, item, button); - addButton(slot + 1, item, button); - addButton(slot + 2, item, button); - } - - private void processTransaction() - { - for (int i=_okSquareSlotStart; i < 54; i++) - { - getButtonMap().remove(i); - clear(i); - } - - /*_processing = true; - - if (_currencyType == GlobalCurrency.GOLD) - { - int goldCount = getDonationManager().Get(getPlayer()).getGold(); - int cost = _salesItem.getCost(_currencyType); - - if (cost > goldCount) - showResultsPage(TransactionResponse.InsufficientFunds); - else - { - getDonationManager().rewardGold(new Callback() - { - @Override - public void run(Boolean data) - { - if (data) - { - showResultsPage(TransactionResponse.Success); - getPlayer().playSound(getPlayer().getLocation(), Sound.LEVEL_UP, 2f, 1.5f); - } - else - { - showResultsPage(TransactionResponse.Failed); - } - } - }, "Energy Purchase", getPlayer().getName(), getClientManager().Get(getPlayer()).getAccountId(), -cost); - - } - - } - else - { - if (_salesItem.isKnown()) - { - getDonationManager().PurchaseKnownSalesPackage(new Callback() - { - public void run(TransactionResponse response) - { - showResultsPage(response); - } - }, getPlayer().getName(), getPlayer().getUniqueId(), _salesItem.getCost(_currencyType), _salesItem.getSalesPackageId()); - } - else - { - getDonationManager().PurchaseUnknownSalesPackage(new Callback() - { - public void run(TransactionResponse response) - { - showResultsPage(response); - } - }, getPlayer().getName(), getClientManager().Get(getPlayer()).getAccountId(), _salesItem.getName(), _currencyType, _salesItem.getCost(_currencyType), _salesItem.oneTimePurchase()); - } - } - - _taskId = getPlugin().getScheduler().scheduleSyncRepeatingTask(getPlugin().getPlugin(), this, 2L, 2L);*/ - // TODO - } - - private void showResultsPage(TransactionResponse response) - { - _processing = false; - - switch (response) - { - case Failed: - buildErrorPage(ChatColor.RED + "There was an error processing your request."); - getShop().addPlayerProcessError(getPlayer()); - break; - case AlreadyOwns: - buildErrorPage(ChatColor.RED + "You already own this package."); - getShop().addPlayerProcessError(getPlayer()); - break; - case InsufficientFunds: - buildErrorPage(ChatColor.RED + "Your account has insufficient funds."); - getShop().addPlayerProcessError(getPlayer()); - break; - case Success: - buildSuccessPage("Your purchase was successful."); - - if (_runnable != null) - _runnable.run(); - - break; - default: - break; - } - - _progressCount = 0; - } - - private void buildErrorPage(String... message) - { - IButton returnButton = new IButton() - { - @Override - public void onClick(Player player, ClickType clickType) - { - cancelClicked(player); - } - }; - - ShopItem item = new ShopItem(Material.REDSTONE_BLOCK, (byte)0, ChatColor.RED + "" + ChatColor.UNDERLINE + "ERROR", message, 1, false, true); - for (int i = 0; i < this.getSize(); i++) - { - addButton(i, item, returnButton); - } - - getPlayer().playSound(getPlayer().getLocation(), Sound.BLAZE_DEATH, 1, .1f); - } - - private void buildSuccessPage(String message) - { - IButton returnButton = new IButton() - { - @Override - public void onClick(Player player, ClickType clickType) - { - cancelClicked(player); - } - }; - - ShopItem item = new ShopItem(Material.EMERALD_BLOCK, (byte)0, ChatColor.GREEN + message, null, 1, false, true); - for (int i = 0; i < this.getSize(); i++) - { - addButton(i, item, returnButton); - } - - getPlayer().playSound(getPlayer().getLocation(), Sound.NOTE_PLING, 1, .9f); - } - - @Override - public void playerClosed() - { - super.playerClosed(); - - Bukkit.getScheduler().cancelTask(_taskId); - - if (_returnPage != null && getShop() != null) - getShop().setCurrentPageForPlayer(getPlayer(), _returnPage); - } - - @Override - public void run() - { - if (_processing) - { - if (_progressCount == 9) - { - for (int i=45; i < 54; i++) - { - clear(i); - } - - _progressCount = 0; - } - - setItem(45 + _progressCount, _progressItem); - } - else - { - if (_progressCount >= 20) - { - try - { - Bukkit.getScheduler().cancelTask(_taskId); - - if (_returnPage != null && getShop() != null) - { - getShop().openPageForPlayer(getPlayer(), _returnPage); - } - else if (getPlayer() != null) - { - getPlayer().closeInventory(); - } - } - catch (Exception exception) - { - exception.printStackTrace(); - } - finally - { - dispose(); - } - } - } - - _progressCount++; - } - - @Override - public void dispose() - { - super.dispose(); - - Bukkit.getScheduler().cancelTask(_taskId); - } -} 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 4dbb912a9..2d7203f06 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java @@ -4,8 +4,10 @@ import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.inventory.InventoryManager; +import mineplex.core.shop.confirmation.ConfirmationPage; import mineplex.core.shop.item.IButton; -import mineplex.core.shop.page.ConfirmationPage; +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; @@ -63,10 +65,11 @@ public class BuyChestButton implements IButton UtilPlayer.message(player, F.main("Disguise", "You cant buy things while you are disguised!")); return; } - _page.getShop().openPageForPlayer(player, new ConfirmationPage<>( - _page.getPlugin(), _page.getShop(), _page.getClientManager(), _page.getDonationManager(), () -> { - _inventoryManager.addItemToInventory(player, _chestName, 1); - _page.refresh(); - }, _page, new ChestPackage(_chestName, _chestMat, _chestCost), GlobalCurrency.TREASURE_SHARD, player)); + SalesPackageBase salesPackage = new ChestPackage(_chestName, _chestMat, _chestCost); + _page.getShop().openPageForPlayer(player, new ConfirmationPage<>(player, _page, new SalesPackageProcessor(player, GlobalCurrency.TREASURE_SHARD, salesPackage, _page.getDonationManager(), () -> + { + _inventoryManager.addItemToInventory(player, _chestName, 1); + _page.refresh(); + }), salesPackage.buildIcon())); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyPackage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyPackage.java deleted file mode 100644 index ba5a9ded0..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyPackage.java +++ /dev/null @@ -1,17 +0,0 @@ -package mineplex.game.clans.shop.energy; - -import mineplex.core.shop.item.SalesPackageBase; -import mineplex.game.clans.economy.ClansCurrency; -import org.bukkit.ChatColor; -import org.bukkit.Material; - -public class EnergyPackage extends SalesPackageBase -{ - public EnergyPackage(String name, int cost) - { - super(name, Material.REDSTONE, " ", ChatColor.RESET + "Clan Energy"); - CurrencyCostMap.put(ClansCurrency.GOLD, cost); - KnownPackage = false; - OneTimePurchaseOnly = false; - } -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyShopButton.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyShopButton.java index 35e4c5979..cea8d672a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyShopButton.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyShopButton.java @@ -1,13 +1,10 @@ package mineplex.game.clans.shop.energy; -import mineplex.core.common.util.F; import mineplex.core.common.util.UtilServer; import mineplex.core.shop.item.IButton; -import mineplex.core.shop.page.ConfirmationPage; import mineplex.game.clans.clans.ClanEnergyManager; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.event.PreEnergyShopBuyEvent; -import mineplex.game.clans.economy.ClansCurrency; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -35,8 +32,8 @@ public class EnergyShopButton implements IButton { return; } - - _page.getShop().openPageForPlayer(player, new ConfirmationPage( + + /*_page.getShop().openPageForPlayer(player, new ConfirmationPage( _page.getPlugin(), _page.getShop(), _page.getClientManager(), _page.getDonationManager(), new Runnable() { public void run() @@ -56,7 +53,8 @@ public class EnergyShopButton implements IButton // Notify _energyManager.getClansManager().messageClan(_clanInfo, F.main("Energy", F.name(player.getName()) + " purchased " + F.elem(_energyToPurchase + " Energy") + " for the clan")); } - }, _page, new EnergyPackage(_energyToPurchase + " Energy", _cost), ClansCurrency.GOLD, player)); + }, _page, new EnergyPackage(_energyToPurchase + " Energy", _cost), ClansCurrency.GOLD, player));*/ + // TODO } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/page/SkillPage.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/page/SkillPage.java index 08dd9397e..90eac4190 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/page/SkillPage.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/page/SkillPage.java @@ -6,8 +6,9 @@ import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; import mineplex.core.donation.DonationManager; import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.shop.item.SalesPackageBase; +import mineplex.core.shop.item.SalesPackageProcessor; import mineplex.core.shop.item.ShopItem; -import mineplex.core.shop.page.ConfirmationPage; import mineplex.core.shop.page.ShopPageBase; import mineplex.minecraft.game.classcombat.Class.ClientClass; import mineplex.minecraft.game.classcombat.Class.IPvpClass; @@ -387,13 +388,8 @@ public class SkillPage extends ShopPageBase public void PurchaseSkill(Player player, ISkill skill) { - getShop().openPageForPlayer(player, new ConfirmationPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), new Runnable() - { - public void run() - { - buildPage(); - } - }, this, new SkillSalesPackage(skill), GlobalCurrency.GEM, player)); + SalesPackageBase salesPackage = new SkillSalesPackage(skill); + getShop().openPageForPlayer(player, new mineplex.core.shop.confirmation.ConfirmationPage<>(player, this, new SalesPackageProcessor(player, GlobalCurrency.GEM, salesPackage, getDonationManager(), this::buildPage), salesPackage.buildIcon())); } private boolean isSkillLocked(ISkill skill) @@ -414,13 +410,8 @@ public class SkillPage extends ShopPageBase public void PurchaseItem(Player player, Item item) { - getShop().openPageForPlayer(player, new ConfirmationPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), new Runnable() - { - public void run() - { - buildPage(); - } - }, this, new ItemSalesPackage(item), GlobalCurrency.GEM, player)); + SalesPackageBase salesPackage = new ItemSalesPackage(item); + getShop().openPageForPlayer(player, new mineplex.core.shop.confirmation.ConfirmationPage<>(player, this, new SalesPackageProcessor(player, GlobalCurrency.GEM, salesPackage, getDonationManager(), this::buildPage), salesPackage.buildIcon())); } public void SelectItem(Player player, Item item) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/ProgressingKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/ProgressingKit.java index 9ab3d48ab..12395f010 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/ProgressingKit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/ProgressingKit.java @@ -14,7 +14,8 @@ import mineplex.core.progression.data.PlayerKit; import mineplex.core.progression.data.PlayerKitDataManager; import mineplex.core.progression.gui.Menu; import mineplex.core.progression.math.Calculations; -import mineplex.core.shop.page.ConfirmationPage; +import mineplex.core.shop.item.SalesPackageBase; +import mineplex.core.shop.item.SalesPackageProcessor; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.game.games.evolution.Evolution; @@ -300,13 +301,14 @@ public abstract class ProgressingKit extends Kit implements ProgressiveKit } else if (this.GetAvailability() == KitAvailability.Gem && donor.getBalance(GlobalCurrency.GEM) >= this.GetCost()) { - Manager.GetShop().openPageForPlayer(player, new ConfirmationPage<>( - Manager, Manager.GetShop(), Manager.GetClients(), Manager.GetDonation(), () -> { + SalesPackageBase salesPackage = new KitPackage(Manager.GetGame().GetType().GetKitGameName(Manager.GetGame()), this); + Manager.GetShop().openPageForPlayer(player, new mineplex.core.shop.confirmation.ConfirmationPage<>(player, Manager, Manager.GetShop(), Manager.GetClients(), Manager.GetDonation(), new SalesPackageProcessor(player, GlobalCurrency.GEM, salesPackage, Manager.GetDonation(), () -> + { if (player.isOnline()) { Manager.GetGame().SetKit(player, this, true); } - }, null, new KitPackage(Manager.GetGame().GetType().GetKitGameName(Manager.GetGame()), this), GlobalCurrency.GEM, player)); + }), salesPackage.buildIcon())); } else if (this.GetAvailability() == KitAvailability.Achievement) { From 167c0f2b5e0c183068c9998e64871b74034bbfb9 Mon Sep 17 00:00:00 2001 From: cnr Date: Mon, 25 Jul 2016 22:10:58 -0500 Subject: [PATCH 63/90] Reimplement EnergyShopButton with new machinery --- .../core/shop/item/SalesPackageProcessor.java | 27 ------- .../clans/economy/GoldPurchaseProcessor.java | 74 +++++++++++++++++++ .../clans/shop/energy/EnergyShopButton.java | 37 ++++------ 3 files changed, 90 insertions(+), 48 deletions(-) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldPurchaseProcessor.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/shop/item/SalesPackageProcessor.java b/Plugins/Mineplex.Core/src/mineplex/core/shop/item/SalesPackageProcessor.java index d7c75985f..8fd1e6fd2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/shop/item/SalesPackageProcessor.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/shop/item/SalesPackageProcessor.java @@ -11,33 +11,6 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; public class SalesPackageProcessor implements ConfirmationProcessor { - /* - int goldCount = _donationManager.Get(_player).getGold(); - int cost = _salesItem.getCost(_currencyType); - - if (cost > goldCount) - showResultsPage(TransactionResponse.InsufficientFunds); - else - { - _donationManager.rewardGold(new Callback() - { - @Override - public void run(Boolean data) - { - if (data) - { - showResultsPage(TransactionResponse.Success); - _player.playSound(_player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f); - } - else - { - showResultsPage(TransactionResponse.Failed); - } - } - }, "Energy Purchase", _player.getName(), getClientManager().Get(_player).getAccountId(), -cost); - - } - */ private final GlobalCurrency _currencyType; private final SalesPackageBase _salesItem; private final DonationManager _donationManager; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldPurchaseProcessor.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldPurchaseProcessor.java new file mode 100644 index 000000000..43df9ade0 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldPurchaseProcessor.java @@ -0,0 +1,74 @@ +package mineplex.game.clans.economy; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.server.util.TransactionResponse; +import mineplex.core.shop.confirmation.ConfirmationCallback; +import mineplex.core.shop.confirmation.ConfirmationProcessor; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; + +public class GoldPurchaseProcessor implements ConfirmationProcessor { + private final Player _player; + private final int _price; + private final GoldManager _goldManager; + private final Runnable _runAfterPurchase; + + public GoldPurchaseProcessor(Player player, int price, GoldManager goldManager, Runnable runAfterPurchase) + { + _player = player; + _price = price; + _goldManager = goldManager; + _runAfterPurchase = runAfterPurchase; + } + + @Override + public void init(Inventory inventory) { + inventory.setItem(4, new ItemBuilder(ClansCurrency.GOLD.getDisplayMaterial()).setTitle(ClansCurrency.GOLD.getPrefix()).addLore(C.cGray + _price + " " + ClansCurrency.GOLD.getPrefix() + " will be", C.cGray + "deducted from your account balance").build()); + } + + @Override + public void process(ConfirmationCallback callback) { + int goldCount = _goldManager.Get(_player).getBalance(); + + if (_price > goldCount) + showResults(callback, TransactionResponse.InsufficientFunds); + else + { + _goldManager.rewardGold(data -> + { + if (data) + { + showResults(callback, TransactionResponse.Success); + _player.playSound(_player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f); + } + else + { + showResults(callback, TransactionResponse.Failed); + } + }, _player, -_price, true); + + } + } + + private void showResults(ConfirmationCallback callback, TransactionResponse response) + { + switch (response) + { + case Failed: + callback.reject("There was an error processing your request."); + break; + case AlreadyOwns: + callback.reject("You already own this package."); + break; + case InsufficientFunds: + callback.reject("Your account has insufficient funds."); + break; + case Success: + callback.resolve("Your purchase was successful."); + _runAfterPurchase.run(); + break; + } + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyShopButton.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyShopButton.java index cea8d672a..b28c2558f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyShopButton.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyShopButton.java @@ -1,15 +1,24 @@ package mineplex.game.clans.shop.energy; +import mineplex.core.common.util.F; import mineplex.core.common.util.UtilServer; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.shop.confirmation.ConfirmationPage; import mineplex.core.shop.item.IButton; import mineplex.game.clans.clans.ClanEnergyManager; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.event.PreEnergyShopBuyEvent; +import mineplex.game.clans.economy.GoldPurchaseProcessor; +import org.bukkit.ChatColor; +import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; public class EnergyShopButton implements IButton { + private static final ItemStack ICON = new ItemBuilder(Material.REDSTONE).setTitle(ChatColor.RESET + "Clan Energy").build(); + private ClanEnergyManager _energyManager; private EnergyPage _page; private int _energyToPurchase; @@ -33,30 +42,16 @@ public class EnergyShopButton implements IButton return; } - /*_page.getShop().openPageForPlayer(player, new ConfirmationPage( - _page.getPlugin(), _page.getShop(), _page.getClientManager(), _page.getDonationManager(), new Runnable() + _page.getShop().openPageForPlayer(player, new ConfirmationPage<>(player, _page, new GoldPurchaseProcessor(player, _cost, _energyManager.getClansManager().getGoldManager(), () -> { - public void run() - { - _clanInfo.adjustEnergy(_energyToPurchase); - _page.refresh(); - - _energyManager.runAsync(new Runnable() - { - @Override - public void run() - { - _energyManager.getClansManager().getClanDataAccess().updateEnergy(_clanInfo); - } - }); - - // Notify - _energyManager.getClansManager().messageClan(_clanInfo, F.main("Energy", F.name(player.getName()) + " purchased " + F.elem(_energyToPurchase + " Energy") + " for the clan")); - } - }, _page, new EnergyPackage(_energyToPurchase + " Energy", _cost), ClansCurrency.GOLD, player));*/ - // TODO + _clanInfo.adjustEnergy(_energyToPurchase); + _page.refresh(); + _energyManager.runAsync(() -> _energyManager.getClansManager().getClanDataAccess().updateEnergy(_clanInfo)); + // Notify + _energyManager.getClansManager().messageClan(_clanInfo, F.main("Energy", F.name(player.getName()) + " purchased " + F.elem(_energyToPurchase + " Energy") + " for the clan")); + }), ICON)); } } From 43c45f409454b5ebbd37ade941ed065c0261c25c Mon Sep 17 00:00:00 2001 From: xXVevzZXx Date: Sun, 24 Jul 2016 13:24:17 +0200 Subject: [PATCH 64/90] add timer to dragon escape --- .../game/games/dragonescape/DragonEscape.java | 59 +++++++++++++++++-- 1 file changed, 55 insertions(+), 4 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java index c6cead608..cc43ec8b1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java @@ -9,10 +9,10 @@ import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Color; import org.bukkit.Effect; +import org.bukkit.FireworkEffect.Type; 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.EnderDragon; @@ -30,18 +30,21 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.scoreboard.Team; import org.bukkit.util.Vector; +import mineplex.core.common.block.BlockData; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilServer; 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.UtilTextBottom; +import mineplex.core.common.util.UtilTextTop; import mineplex.core.common.util.UtilTime; -import mineplex.core.common.block.BlockData; +import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -50,7 +53,10 @@ import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.PlayerKitGiveEvent; import nautilus.game.arcade.game.SoloGame; -import nautilus.game.arcade.game.games.dragonescape.kits.*; +import nautilus.game.arcade.game.games.dragonescape.kits.KitDigger; +import nautilus.game.arcade.game.games.dragonescape.kits.KitDisruptor; +import nautilus.game.arcade.game.games.dragonescape.kits.KitLeaper; +import nautilus.game.arcade.game.games.dragonescape.kits.KitWarper; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.stats.DistanceTraveledStatTracker; @@ -94,6 +100,9 @@ public class DragonEscape extends SoloGame private double _speedMult = 1; private HashMap _tunneled = new HashMap(); + + private long _started; + private long _ended; public DragonEscape(ArcadeManager manager) { @@ -644,4 +653,46 @@ public class DragonEscape extends SoloGame // Stops players using trap doors in game. event.setCancelled(true); } + + @EventHandler + public void setTimes(GameStateChangeEvent event) + { + if (event.GetState() == GameState.Live) + { + _started = System.currentTimeMillis(); + } + else if (event.GetState() == GameState.End) + { + _ended = System.currentTimeMillis(); + } + } + + @EventHandler + public void updateTimer(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTEST) + return; + + if (GetState() == GameState.Prepare) + { + UtilTextTop.display(F.game("Game time: ") + F.time("0.0 Seconds"), UtilServer.getPlayers()); + } + else if (GetState() == GameState.Live) + { + if (_started == 0) + return; + + UtilTextTop.display(F.game("Game time: ") + F.time(UtilTime.convertString(System.currentTimeMillis() - _started, 6, TimeUnit.SECONDS)), UtilServer.getPlayers()); + } + else if (GetState() == GameState.End) + { + if (_started == 0) + return; + + if (_ended == 0) + return; + + UtilTextBottom.display(F.game("Game time: ") + F.time(UtilTime.convertString(_ended - _started, 6, TimeUnit.SECONDS)), UtilServer.getPlayers()); + } + } } From 6180bea5cc909fb490afa0b6c1b7a837604fac3a Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Wed, 27 Jul 2016 15:07:11 -0400 Subject: [PATCH 65/90] Update clans drop aesthetics and spawn/shop locations --- .../game/clans/clans/loot/GearLoot.java | 2 +- .../game/clans/clans/loot/GoldTokenLoot.java | 6 ++- .../clans/clans/regions/ClansRegions.java | 33 ++++------------ .../game/clans/items/GearManager.java | 11 ++++++ .../src/mineplex/game/clans/spawn/Spawn.java | 39 +++++++++---------- 5 files changed, 43 insertions(+), 48 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/GearLoot.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/GearLoot.java index c65d2cd33..343871074 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/GearLoot.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/GearLoot.java @@ -17,7 +17,7 @@ public class GearLoot implements ILoot @Override public void dropLoot(Location location) { - _gearManager.spawnItem(location); + _gearManager.spawnItem(location.clone().add(0, 3, 0)); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/GoldTokenLoot.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/GoldTokenLoot.java index 03707ad93..82875cea8 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/GoldTokenLoot.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/GoldTokenLoot.java @@ -1,8 +1,11 @@ package mineplex.game.clans.clans.loot; +import org.bukkit.Color; import org.bukkit.Location; +import org.bukkit.FireworkEffect.Type; import org.bukkit.inventory.ItemStack; +import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilMath; import mineplex.game.clans.items.economy.GoldToken; @@ -23,7 +26,8 @@ public class GoldTokenLoot implements ILoot int gold = _minGold + UtilMath.r(_maxGold - _minGold); GoldToken token = new GoldToken(gold); - location.getWorld().dropItemNaturally(location, token.toItemStack()); + UtilFirework.playFirework(location.clone().add(0, 3, 0), Type.BALL, Color.YELLOW, true, false); + location.getWorld().dropItemNaturally(location.clone().add(0, 3, 0), token.toItemStack()); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/regions/ClansRegions.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/regions/ClansRegions.java index 6c9424634..b60c27ae8 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/regions/ClansRegions.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/regions/ClansRegions.java @@ -1,41 +1,22 @@ package mineplex.game.clans.clans.regions; -import java.util.ArrayList; import java.util.HashSet; -import java.util.Iterator; -import java.util.List; import java.util.Set; -import org.bukkit.Bukkit; -import org.bukkit.Chunk; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.WorldBorder; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerMoveEvent; -import org.bukkit.event.player.PlayerTeleportEvent; -import org.bukkit.plugin.java.JavaPlugin; - -import net.minecraft.server.v1_8_R3.PacketPlayOutWorldBorder; - import mineplex.core.MiniPlugin; 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.UtilEnt; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilWorld; import mineplex.game.clans.clans.ClanInfo; -import mineplex.game.clans.clans.ClansDataAccessLayer; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.spawn.Spawn; import mineplex.minecraft.game.classcombat.Skill.event.SkillTeleportEvent; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.WorldBorder; +import org.bukkit.event.EventHandler; +import org.bukkit.plugin.java.JavaPlugin; + public class ClansRegions extends MiniPlugin { public final static String DEFAULT_WORLD_NAME = "world"; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java index 27b8900b0..b25959a72 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java @@ -13,6 +13,7 @@ import java.util.UUID; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilServer; import mineplex.core.common.weight.Weight; @@ -67,6 +68,8 @@ import net.minecraft.server.v1_8_R3.PacketPlayOutSetSlot; import net.minecraft.server.v1_8_R3.PacketPlayOutWindowItems; import org.bukkit.Bukkit; +import org.bukkit.Color; +import org.bukkit.FireworkEffect.Type; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; @@ -385,6 +388,14 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable public void spawnItem(Location location) { CustomItem item = generateItem(); + if (item.getMaterial() == Material.RECORD_4 || item.getMaterial() == Material.GOLD_RECORD || item.getMaterial() == Material.RECORD_3 || item.getMaterial() == Material.RECORD_5 || item.getMaterial() == Material.RECORD_6 || item.getMaterial() == Material.GREEN_RECORD) + { + UtilFirework.playFirework(location, Type.BALL, Color.RED, true, false); + } + else + { + UtilFirework.playFirework(location, Type.BALL, Color.AQUA, true, false); + } location.getWorld().dropItem(location, item.toItemStack()); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java index 92f29b3bf..5c57ef602 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java @@ -2,6 +2,23 @@ package mineplex.game.clans.spawn; import java.util.Set; +import mineplex.core.MiniPlugin; +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.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.common.weight.WeightSet; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClansManager; +import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; +import mineplex.minecraft.game.classcombat.item.event.WebTossEvent; +import mineplex.minecraft.game.core.condition.Condition.ConditionType; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Effect; @@ -26,28 +43,10 @@ import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.hanging.HangingBreakByEntityEvent; -import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.event.player.PlayerVelocityEvent; import org.bukkit.plugin.java.JavaPlugin; -import mineplex.core.MiniPlugin; -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.UtilTextMiddle; -import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilTime.TimeUnit; -import mineplex.core.common.weight.WeightSet; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.game.clans.clans.ClansManager; -import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; -import mineplex.minecraft.game.classcombat.item.event.WebTossEvent; -import mineplex.minecraft.game.core.condition.Condition.ConditionType; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; - public class Spawn extends MiniPlugin { public static final int SPAWN_RADIUS = 32; @@ -457,7 +456,7 @@ public class Spawn extends MiniPlugin public static Location getWestTown() { - return new Location(getSpawnWorld(), -440.91, 63, 23.08); + return new Location(getSpawnWorld(), -440.91, 65, 23.08); } public static Location getWestTownCenter() @@ -467,7 +466,7 @@ public class Spawn extends MiniPlugin public static Location getEastTown() { - return new Location(getSpawnWorld(), 440.91, 63, -23.08); + return new Location(getSpawnWorld(), 440.91, 65, -23.08); } public static Location getEastTownCenter() From dfbebe11f481b7b72ae288214ed1ca5f9d8ba39b Mon Sep 17 00:00:00 2001 From: cnr Date: Wed, 27 Jul 2016 15:46:26 -0500 Subject: [PATCH 66/90] Use separate gold balances for each clans server --- .../game/clans/clans/ClansManager.java | 7 +- .../game/clans/economy/GoldManager.java | 13 ++-- .../game/clans/economy/GoldRepository.java | 76 ++++++++++++------- 3 files changed, 62 insertions(+), 34 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index 91678a98f..03a19b238 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -267,7 +267,6 @@ public class ClansManager extends MiniClientPluginimplements IRelati _blacklist = new ClansBlacklist(plugin); - _goldManager = new GoldManager(this, _clientManager, donationManager); _gearManager = gearManager; _lootManager = new LootManager(gearManager, _goldManager); _disguiseManager = new DisguiseManager(plugin, packetHandler); @@ -384,13 +383,15 @@ public class ClansManager extends MiniClientPluginimplements IRelati _playTracker = new Playtime(this, statsManager); - _legacyTutorial = new mineplex.game.clans.legacytutorial.TutorialManager(plugin, _playTracker, _goldManager, _taskManager, donationManager, preferencesManager, this, packetHandler); - _scoreboard = new ClansScoreboardManager(plugin, this, _warManager, _worldEvent, _tutorial, clientManager, donationManager); _clanDataAccess = new ClansDataAccessLayer(this, _scoreboard); _bannerManager = new BannerManager(plugin); + _goldManager = new GoldManager(this, _clientManager, donationManager, _clanDataAccess); + + _legacyTutorial = new mineplex.game.clans.legacytutorial.TutorialManager(plugin, _playTracker, _goldManager, _taskManager, donationManager, preferencesManager, this, packetHandler); + for (ClanToken token : _clanDataAccess.getRepository().retrieveClans()) { loadClan(token); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java index fcfc0a347..0fe863038 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java @@ -8,6 +8,7 @@ import mineplex.core.donation.DonationManager; import mineplex.core.donation.Donor; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClansDataAccessLayer; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.items.economy.GoldToken; import mineplex.game.clans.shop.bank.BankShop; @@ -41,24 +42,26 @@ public class GoldManager extends MiniDbClientPlugin public static GoldManager getInstance() { return _instance; } private DonationManager _donationManager; + private final int _serverId; private TransferTracker _transferTracker; private Set _itemSet; private Map _playerPickupMap; private BankShop _bankShop; private final GoldRepository _repository; - - public GoldManager(ClansManager plugin, CoreClientManager clientManager, DonationManager donationManager) + + public GoldManager(ClansManager plugin, CoreClientManager clientManager, DonationManager donationManager, ClansDataAccessLayer dataAccessLayer) { super("Clans Gold", plugin.getPlugin(), clientManager); - + _instance = this; _donationManager = donationManager; + _serverId = dataAccessLayer.getRepository().getServerId(); _transferTracker = new TransferTracker(); _itemSet = new HashSet(); _playerPickupMap = new HashMap(); _bankShop = new BankShop(plugin, clientManager, donationManager); - _repository = new GoldRepository(plugin.getPlugin()); + _repository = new GoldRepository(_serverId); } @Override @@ -396,7 +399,7 @@ public class GoldManager extends MiniDbClientPlugin @Override public String getQuery(int accountId, String uuid, String name) { - return "SELECT gold FROM accounts WHERE id = '" + accountId + "';"; + return "SELECT gold FROM clansGold WHERE id = '" + accountId + "' AND serverId=" + _serverId + ";"; } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldRepository.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldRepository.java index 7afab5019..ad08ef462 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldRepository.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldRepository.java @@ -1,31 +1,47 @@ package mineplex.game.clans.economy; import mineplex.core.common.util.Callback; -import mineplex.core.database.MinecraftRepository; import mineplex.serverdata.database.DBPool; -import mineplex.serverdata.database.DatabaseRunnable; -import mineplex.serverdata.database.column.ColumnInt; -import org.bukkit.plugin.java.JavaPlugin; -public class GoldRepository extends MinecraftRepository { - private static final String UPDATE_ACCOUNT_GOLD = "UPDATE accounts SET gold = gold + ? WHERE id = ? && gold >= ?;"; - private static final String SET_ACCOUNT_GOLD = "UPDATE accounts SET gold = ? WHERE id = ?;"; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; - public GoldRepository(JavaPlugin plugin) { - super(plugin, DBPool.getAccount()); +public class GoldRepository { + private static final String CREATE_TABLE = "CREATE TABLE clansGold (serverId int(11) not null, id int(11) not null, gold int not null, primary key (serverId, id), foreign key (serverId) references clanServer(id), foreign key (id) references accounts(id))"; + private static final String UPDATE_ACCOUNT_GOLD = "INSERT INTO clansGold (serverId, id, gold) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE gold=gold+?"; + private static final String SET_ACCOUNT_GOLD = "INSERT INTO clansGold (serverId, id, gold) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE gold=?"; + + private final int _serverId; + + public GoldRepository(int serverId) { + _serverId = serverId; } public void rewardGold(final Callback callback, final int accountId, final int gold) { - handleDatabaseCall(new DatabaseRunnable(new Runnable() + try (Connection connection = DBPool.getAccount().getConnection()) { - public void run() + PreparedStatement statement = connection.prepareStatement(UPDATE_ACCOUNT_GOLD); + statement.setInt(1, _serverId); + statement.setInt(2, accountId); + statement.setInt(3, gold); + statement.setInt(4, gold); + statement.executeUpdate(); + + if (callback != null) { - ColumnInt min = new ColumnInt("gold", gold < 0 ? -gold : 0); - boolean success = executeUpdate(UPDATE_ACCOUNT_GOLD, new ColumnInt("gold", gold), new ColumnInt("id", accountId), min) > 0; - callback.run(success); + callback.run(true); } - }), "Error updating player gold amount in DonationRepository : "); + + } catch (SQLException e) { + e.printStackTrace(); + + if (callback != null) + { + callback.run(false); + } + } } public void setGold(final Callback callback, final int accountId, final int gold) @@ -34,19 +50,27 @@ public class GoldRepository extends MinecraftRepository { { throw new IllegalArgumentException("gold cannot be negative"); } - handleDatabaseCall(new DatabaseRunnable(new Runnable() + + try (Connection connection = DBPool.getAccount().getConnection()) { - public void run() + PreparedStatement statement = connection.prepareStatement(SET_ACCOUNT_GOLD); + statement.setInt(1, _serverId); + statement.setInt(2, accountId); + statement.setInt(3, gold); + statement.setInt(4, gold); + statement.executeUpdate(); + if (callback != null) { - boolean success = executeUpdate(SET_ACCOUNT_GOLD, new ColumnInt("gold", gold), new ColumnInt("id", accountId)) > 0; - callback.run(success); + callback.run(true); } - }), "Error updating player gold amount in DonationRepository : "); + + } catch (SQLException e) { + e.printStackTrace(); + + if (callback != null) + { + callback.run(false); + } + } } - - @Override - protected void initialize() {} - - @Override - protected void update() {} } From 62871686b0997729ed974aba0a6def642d1173f2 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Wed, 27 Jul 2016 16:57:07 -0400 Subject: [PATCH 67/90] Update clans store items to currency changes --- .../src/mineplex/enjinTranslator/Enjin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java b/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java index b792d884c..8591bbfb4 100644 --- a/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java +++ b/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java @@ -336,7 +336,7 @@ public class Enjin extends MiniPlugin implements CommandExecutor _purchaseManager.addAccountPurchaseToQueue(client.getAccountId(), packageName, 1, data == TransactionResponse.Success); } } - }, name, client.getAccountId(), packageName, CurrencyType.GEM, 0, false); + }, name, client.getAccountId(), packageName, GlobalCurrency.GEM, 0, false); //enjin_mineplex clansBanner AlexTheCoder true return true; } From 646ce96250d0a35cdd7f9eef93fe82caa1a0198c Mon Sep 17 00:00:00 2001 From: cnr Date: Wed, 27 Jul 2016 16:14:45 -0500 Subject: [PATCH 68/90] Ensure gold balance row is present --- .../src/mineplex/game/clans/economy/GoldManager.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java index 0fe863038..fdd40a847 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java @@ -404,7 +404,10 @@ public class GoldManager extends MiniDbClientPlugin @Override public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException { - Get(playerName).setBalance(resultSet.getInt(1)); + if (resultSet.next()) + { + Get(playerName).setBalance(resultSet.getInt(1)); + } } @Override From 749fa36a5ad9d959d38590e4c1b0c5ede4da25a0 Mon Sep 17 00:00:00 2001 From: xXVevzZXx Date: Wed, 27 Jul 2016 23:42:01 +0200 Subject: [PATCH 69/90] remove debug and check for Integer class --- .../game/games/bridge/modes/OverpoweredBridge.java | 3 --- .../game/arcade/managers/GameCreationManager.java | 12 ++++++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/modes/OverpoweredBridge.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/modes/OverpoweredBridge.java index 7fcf95f0e..17b6b5ce5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/modes/OverpoweredBridge.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/modes/OverpoweredBridge.java @@ -233,16 +233,13 @@ public class OverpoweredBridge extends Bridge { for (Player player : _starterChests.keySet()) { - System.out.println("test4"); if (player == clicker) continue; - System.out.println("test2"); Location chest = _starterChests.get(player); if (chest.getBlock().getLocation().equals(block.getLocation())) { - System.out.println("test1"); return true; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameCreationManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameCreationManager.java index 181d5efc8..896bfc317 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameCreationManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameCreationManager.java @@ -508,27 +508,27 @@ public class GameCreationManager implements Listener { return value; } - else if (clazz == int.class) + else if (clazz == int.class || clazz == Integer.class) { return Integer.parseInt(value); } - else if (clazz == float.class) + else if (clazz == float.class || clazz == Float.class) { return Float.parseFloat(value); } - else if (clazz == double.class) + else if (clazz == double.class || clazz == Double.class) { return Double.parseDouble(value); } - else if (clazz == long.class) + else if (clazz == long.class || clazz == Long.class) { return Long.parseLong(value); } - else if (clazz == byte.class) + else if (clazz == byte.class || clazz == Byte.class) { return Byte.parseByte(value); } - else if (clazz == short.class) + else if (clazz == short.class || clazz == Short.class) { return Short.parseShort(value); } From 05e59ae9cc7113b62e70b4851832d61ed1c8e086 Mon Sep 17 00:00:00 2001 From: cnr Date: Wed, 27 Jul 2016 19:03:04 -0500 Subject: [PATCH 70/90] Revert "Revert "Merge branch 'develop' of github.com:Mineplex-LLC/Minecraft-PC into ben/champions-gi-balancing"" This reverts commit 917b83250dfeeb94c5f9486d27a6a0107e1301fc. --- .../mineplex/core/common/util/UtilBlock.java | 31 ++++++++ .../core/projectile/ProjectileManager.java | 19 +++-- .../core/projectile/ProjectileUser.java | 49 +++++++++++++ .../classcombat/Skill/Assassin/Blink.java | 5 +- .../classcombat/Skill/Assassin/Evade.java | 4 +- .../classcombat/Skill/Assassin/Recall.java | 8 +- .../Skill/Assassin/ViperStrikes.java | 15 ++-- .../classcombat/Skill/Brute/BlockToss.java | 43 +++++++---- .../Skill/Brute/CripplingBlow.java | 4 +- .../classcombat/Skill/Brute/DwarfToss.java | 13 +++- .../classcombat/Skill/Brute/FleshHook.java | 12 +-- .../classcombat/Skill/Brute/Intimidation.java | 4 +- .../classcombat/Skill/Knight/AxeThrow.java | 4 +- .../classcombat/Skill/Knight/HiltSmash.java | 4 +- .../Skill/Knight/Swordsmanship.java | 4 +- .../game/classcombat/Skill/Mage/Blizzard.java | 4 +- .../classcombat/Skill/Mage/IcePrison.java | 4 +- .../game/classcombat/Skill/Mage/Immolate.java | 6 ++ .../game/classcombat/Skill/Mage/Inferno.java | 6 +- .../classcombat/Skill/Mage/LifeBonds.java | 21 ++---- .../classcombat/Skill/Mage/MagmaBlade.java | 4 +- .../Skill/Ranger/Sharpshooter.java | 56 +++++++++++++- .../Skill/Ranger/VitalitySpores.java | 73 ++++++++++--------- .../classcombat/Skill/Ranger/WolfsPounce.java | 4 +- .../game/classcombat/Skill/SkillFactory.java | 14 ++-- .../game/core/condition/Condition.java | 38 +++++++++- .../game/core/condition/ConditionFactory.java | 8 +- .../src/nautilus/game/arcade/game/Game.java | 15 ++++ .../game/games/champions/ChampionsCTF.java | 3 - .../games/champions/ChampionsDominate.java | 1 - .../game/games/champions/ChampionsTDM.java | 1 - .../arcade/game/games/hideseek/HideSeek.java | 14 +++- .../arcade/game/games/wizards/Wizards.java | 7 +- .../game/arcade/managers/GameFlagManager.java | 2 +- 34 files changed, 367 insertions(+), 133 deletions(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java index a710ccb1b..a3df8747f 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java @@ -1617,4 +1617,35 @@ public class UtilBlock } } + + public static boolean water(Material type) + { + return type == Material.WATER || type == Material.STATIONARY_WATER; + } + + public static boolean lava(Material type) + { + return type == Material.LAVA || type == Material.STATIONARY_LAVA; + } + + public static boolean liquid(Material type) + { + return water(type) || lava(type); + } + + public static boolean water(Block block) + { + return water(block.getType()); + } + + public static boolean lava(Block block) + { + return lava(block.getType()); + } + + public static boolean liquid(Block block) + { + return liquid(block.getType()); + } + } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileManager.java b/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileManager.java index 12dbee6b4..07b4e54e9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileManager.java @@ -88,6 +88,15 @@ public class ProjectileManager extends MiniPlugin sound, soundVolume, soundPitch, null, 0, effectRate, particle, 0F, 0F, 0F, 0F, 1, hitboxMult)); } + public void AddThrow(Entity thrown, LivingEntity thrower, IThrown callback, + long expireTime, boolean hitPlayer, boolean hitNonPlayerEntity, boolean hitBlock, boolean idle, + Sound sound, float soundVolume, float soundPitch, ParticleType particle, UpdateType effectRate, float hitboxMult, double charge) + { + _thrown.put(thrown, new ProjectileUser(this, thrown, thrower, callback, + expireTime, hitPlayer, hitNonPlayerEntity, hitBlock, idle, false, + sound, soundVolume, soundPitch, null, 0, effectRate, particle, 0F, 0F, 0F, 0F, 1, hitboxMult, charge)); + } + public void AddThrow(Entity thrown, LivingEntity thrower, IThrown callback, long expireTime, boolean hitPlayer, boolean hitNonPlayerEntity, boolean hitBlock, boolean idle, Sound sound, float soundVolume, float soundPitch, ParticleType particle, float pX, float pY, float pZ, float pS, int pC, UpdateType effectRate, float hitboxMult) @@ -133,14 +142,14 @@ public class ProjectileManager extends MiniPlugin } public void AddThrow(Entity thrown, LivingEntity thrower, IThrown callback, - long expireTime, boolean hitPlayer, boolean hitNonPlayerEntity, boolean hitBlock, boolean idle, - Sound sound, float soundVolume, float soundPitch, ParticleType particle, UpdateType effectRate, float hitboxMult, List canHit) + long expireTime, boolean hitPlayer, boolean hitNonPlayerEntity, boolean hitBlock, boolean idle, + Sound sound, float soundVolume, float soundPitch, ParticleType particle, UpdateType effectRate, float hitboxMult, List canHit) { _thrown.put(thrown, new ProjectileUser(this, thrown, thrower, callback, - expireTime, hitPlayer, hitNonPlayerEntity, hitBlock, idle, false, - sound, soundVolume, soundPitch, null, 0, effectRate, particle, 0F, 0F, 0F, 0F, 1, hitboxMult, canHit)); + expireTime, hitPlayer, hitNonPlayerEntity, hitBlock, idle, false, + sound, soundVolume, soundPitch, null, 0, effectRate, particle, 0F, 0F, 0F, 0F, 1, hitboxMult, canHit)); } - + public void AddThrow(Entity thrown, LivingEntity thrower, IThrown callback, long expireTime, boolean hitPlayer, boolean hitNonPlayerEntity, boolean hitBlock, boolean idle, Sound sound, float soundVolume, float soundPitch, ParticleType particle, float pX, float pY, float pZ, float pS, int pC, UpdateType effectRate, float hitboxMult, List canHit) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileUser.java b/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileUser.java index 31aee43b1..16213685f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileUser.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileUser.java @@ -62,6 +62,8 @@ public class ProjectileUser private UpdateType _effectRate = UpdateType.TICK; private double _hitboxGrow; + + private double _charge; private List _canHit; @@ -104,6 +106,47 @@ public class ProjectileUser _canHit = null; } + public ProjectileUser(ProjectileManager throwInput, Entity thrown, LivingEntity thrower, IThrown callback, + long expireTime, boolean hitPlayer, boolean hitNonPlayerEntity, boolean hitBlock, boolean idle, boolean pickup, + Sound sound, float soundVolume, float soundPitch, + Effect effect, int effectData, UpdateType effectRate, + ParticleType particle, float particleX, float particleY, + float particleZ, float particleS, int particleC, double hitboxMult, double charge) + { + Throw = throwInput; + + _thrown = thrown; + _thrower = thrower; + _callback = callback; + + _expireTime = expireTime; + _startTime = System.currentTimeMillis(); + + _hitPlayer = hitPlayer; + _hitNonPlayerEntity = hitNonPlayerEntity; + _hitBlock = hitBlock; + _idle = idle; + _pickup = pickup; + + _sound = sound; + _soundVolume = soundVolume; + _soundPitch = soundPitch; + _particle = particle; + _particleX = particleX; + _particleY = particleY; + _particleZ = particleZ; + _particleS = particleS; + _particleC = particleC; + _effect = effect; + _effectData = effectData; + _effectRate = effectRate; + + _hitboxGrow = hitboxMult; + _canHit = null; + + _charge = charge; + } + public ProjectileUser(ProjectileManager throwInput, Entity thrown, LivingEntity thrower, IThrown callback, long expireTime, boolean hitPlayer, boolean hitNonPlayerEntity, boolean hitBlock, boolean idle, boolean pickup, Sound sound, float soundVolume, float soundPitch, @@ -142,6 +185,7 @@ public class ProjectileUser _hitboxGrow = hitboxMult; _canHit = canHit; } + public void effect(UpdateEvent event) { @@ -311,6 +355,11 @@ public class ProjectileUser return false; } + + public double getCharge() + { + return _charge; + } public IThrown getIThrown() { diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Blink.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Blink.java index 7aecaade1..2a87b1c30 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Blink.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Blink.java @@ -33,7 +33,7 @@ public class Blink extends SkillActive { private HashMap _loc = new HashMap(); private HashMap _blinkTime = new HashMap(); - + public Blink(SkillFactory skills, String name, ClassType classType, SkillType skillType, int cost, int levels, int energy, int energyMod, @@ -206,6 +206,9 @@ public class Blink extends SkillActive done = true; } + target.setYaw(player.getLocation().getYaw()); + target.setPitch(player.getLocation().getPitch()); + player.teleport(target); player.setFallDistance(0); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Evade.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Evade.java index c00d10c69..128ee2a11 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Evade.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Evade.java @@ -29,6 +29,7 @@ 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.minecraft.game.classcombat.Skill.SkillActive; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; @@ -213,10 +214,11 @@ public class Evade extends SkillActive { Player player = activeIter.next(); - if (!player.isOnline() || !player.isBlocking() || UtilTime.elapsed(_active.get(player), 750)) + if (!player.isOnline() || !player.isBlocking() || UtilTime.elapsed(_active.get(player), 1000)) { activeIter.remove(); UtilPlayer.message(player, F.main(GetClassType().name(), "You failed to " + F.skill(GetName()) + ".")); + Recharge.Instance.useForce(player, GetName(), 10000l, true); } } } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Recall.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Recall.java index 1918c5cf4..16b032c06 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Recall.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Recall.java @@ -14,6 +14,7 @@ import org.bukkit.event.player.PlayerDropItemEvent; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; @@ -28,7 +29,6 @@ import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; import mineplex.minecraft.game.classcombat.Skill.Skill; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; -import net.minecraft.server.v1_8_R3.Material; public class Recall extends Skill { @@ -69,6 +69,12 @@ public class Recall extends Skill event.setCancelled(true); + if (UtilBlock.water(player.getLocation().getBlock())) + { + UtilPlayer.message(player, F.main("Skill", "You cannot use " + F.skill(GetName()) + " in water.")); + return; + } + //Check Allowed SkillTriggerEvent trigger = new SkillTriggerEvent(player, GetName(), GetClassType()); Bukkit.getServer().getPluginManager().callEvent(trigger); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/ViperStrikes.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/ViperStrikes.java index 7cac7e593..6aaaba4a2 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/ViperStrikes.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/ViperStrikes.java @@ -6,12 +6,14 @@ 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.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; import mineplex.core.common.util.UtilGear; import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.classcombat.Skill.Skill; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; public class ViperStrikes extends Skill { @@ -21,8 +23,8 @@ public class ViperStrikes extends Skill SetDesc(new String[] { - "Your attacks give enemies", - "Shock, Slow 1 and Poison 1", + "Your attacks give", + "enemies Poison 1", "for #0#1 seconds." }); } @@ -47,10 +49,9 @@ public class ViperStrikes extends Skill LivingEntity damagee = event.GetDamageeEntity(); if (damagee == null) return; - - //Confuse - Factory.Condition().Factory().PoisonShock(GetName(), damagee, damager, level, false); - Factory.Condition().Factory().Slow(GetName(), damagee, damager, level, 0, false, false, true, false); + + Factory.Damage().NewDamageEvent(damagee, damager, null, DamageCause.POISON, 0, false, true, true, damager.getName(), GetName()); + damagee.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 20 * (2 + level), 0)); //Sound damager.getWorld().playSound(damager.getLocation(), Sound.SPIDER_IDLE, 1f, 2f); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/BlockToss.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/BlockToss.java index 800547f8b..3422b690b 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/BlockToss.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/BlockToss.java @@ -9,32 +9,34 @@ import org.bukkit.Effect; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.entity.Entity; import org.bukkit.entity.FallingBlock; 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.EntityChangeBlockEvent; -import org.bukkit.event.entity.ItemSpawnEvent; +import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.player.PlayerInteractEvent; -import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; import mineplex.core.common.util.F; -import mineplex.core.projectile.IThrown; -import mineplex.core.projectile.ProjectileUser; -import mineplex.core.recharge.Recharge; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.core.updater.UpdateType; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilGear; -import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilMath; 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.classcombat.Class.IPvpClass.ClassType; import mineplex.minecraft.game.classcombat.Skill.SkillCharge; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; import mineplex.minecraft.game.classcombat.Skill.event.BlockTossExpireEvent; @@ -90,7 +92,7 @@ public class BlockToss extends SkillCharge implements IThrown @Override public String GetRechargeString() { - return "Recharge: " + "#4#-0.5 Seconds"; + return "Recharge: " + "#5.5#-0.5 Seconds"; } @EventHandler @@ -193,7 +195,22 @@ public class BlockToss extends SkillCharge implements IThrown //Effect player.getWorld().playEffect(event.getClickedBlock().getLocation(), Effect.STEP_SOUND, block.getMaterial().getId()); } - + + @EventHandler + public void Damage(EntityDamageByEntityEvent event) + { + Entity vehicle = event.getEntity().getVehicle(); + + if (_holding.containsKey(vehicle)) + { + Player attacker = (Player) event.getDamager(); + + //Forward Damage + Factory.Damage().NewDamageEvent((Player) vehicle, attacker, Factory.Damage().GetProjectile(event), + event.getCause(), event.getDamage(), true, false, false, null, null, event.isCancelled()); + } + } + @EventHandler public void Throw(UpdateEvent event) { @@ -224,7 +241,7 @@ public class BlockToss extends SkillCharge implements IThrown } //Throw - if (!cur.isBlocking()) + if (!cur.isBlocking() || (_charge.containsKey(cur) && _charge.get(cur) >= 1)) throwSet.add(cur); //Charged Tick @@ -241,7 +258,7 @@ public class BlockToss extends SkillCharge implements IThrown for (Player cur : throwSet) { Recharge.Instance.recharge(cur, GetName()); - Recharge.Instance.use(cur, GetName(), 4000 - (500 * getLevel(cur)), false, true); + Recharge.Instance.use(cur, GetName(), 5500 - (500 * getLevel(cur)), false, true); FallingBlock block = _holding.remove(cur); float charge = _charge.remove(cur); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/CripplingBlow.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/CripplingBlow.java index 3e384a64c..1ae7b8f6e 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/CripplingBlow.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/CripplingBlow.java @@ -24,7 +24,7 @@ public class CripplingBlow extends Skill { "Your powerful axe attacks give", "targets Slow 2 for 1.5 second,", - "as well as 50% less knockback." + "as well as 25% less knockback." }); } @@ -57,7 +57,7 @@ public class CripplingBlow extends Skill //Damage event.AddMod(damager.getName(), GetName(), 0, true); - event.AddKnockback(GetName(), 0.5); + event.AddKnockback(GetName(), 0.75); //Event UtilServer.getServer().getPluginManager().callEvent(new SkillEvent(damager, GetName(), ClassType.Brute, damagee)); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/DwarfToss.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/DwarfToss.java index 915c78b7a..1ce818b5f 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/DwarfToss.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/DwarfToss.java @@ -73,7 +73,7 @@ public class DwarfToss extends SkillActive { if (_used.contains(player)) return false; - + return true; } @@ -96,7 +96,13 @@ public class DwarfToss extends SkillActive { int level = getLevel(player); if (level == 0) return false; - + + if (player.getLocation().getBlock().getTypeId() == 8 || player.getLocation().getBlock().getTypeId() == 9) + { + UtilPlayer.message(player, F.main("Skill", "You cannot use " + F.skill(GetName()) + " in water.")); + return false; + } + //Check Material if (player.getItemInHand() != null) if (!_itemSet.contains(player.getItemInHand().getType())) @@ -337,6 +343,9 @@ public class DwarfToss extends SkillActive target.leaveVehicle(); final double mult = (1.8) * timeScale; + //Protection + Factory.Condition().Factory().Invulnerable(GetName(), target, target, 1.25, false, false); + //Delay Bukkit.getScheduler().scheduleSyncDelayedTask(Factory.getPlugin(), new Runnable() { diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/FleshHook.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/FleshHook.java index 373caea1f..588571fdc 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/FleshHook.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/FleshHook.java @@ -101,16 +101,16 @@ public class FleshHook extends SkillActiveCharge implements IThrown //Release Charge else if (_charge.containsKey(cur)) { - float charge = _charge.remove(cur); + double charge = _charge.remove(cur); //Action Item item = cur.getWorld().dropItem(cur.getEyeLocation().add(cur.getLocation().getDirection()), ItemStackFactory.Instance.CreateStack(131)); UtilAction.velocity(item, cur.getLocation().getDirection(), - 1 + charge , false, 0, 0.2, 20, false); + 1 + charge, false, 0, 0.2, 20, false); Factory.Projectile().AddThrow(item, cur, this, -1, true, true, true, true, - Sound.FIRE_IGNITE, 1.4f, 0.8f, ParticleType.CRIT, UpdateType.TICK, 0.6f); - + Sound.FIRE_IGNITE, 1.4f, 0.8f, ParticleType.CRIT, UpdateType.TICK, 0.6f, charge); + //Inform UtilPlayer.message(cur, F.main(GetClassType().name(), "You used " + F.skill(GetName(level)) + ".")); @@ -148,14 +148,14 @@ public class FleshHook extends SkillActiveCharge implements IThrown //Pull UtilAction.velocity(target, UtilAlg.getTrajectory(target.getLocation(), player.getLocation()), - 1.2 + (0.3 * level), false, 0, 0.7, 1.2, true); + velocity, false, 0, 0.7, 1.2, true); //Condition Factory.Condition().Factory().Falling(GetName(), target, player, 10, false, true); //Damage Event Factory.Damage().NewDamageEvent(target, player, null, - DamageCause.CUSTOM, 5 + level, false, true, false, + DamageCause.CUSTOM, (5 + level) * data.getCharge(), false, true, false, player.getName(), GetName()); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/Intimidation.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/Intimidation.java index cab4d77fa..1f5d560b9 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/Intimidation.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/Intimidation.java @@ -21,7 +21,7 @@ public class Intimidation extends Skill SetDesc(new String[] { "You intimidate nearby enemies;", - "Enemies within #3#3 blocks receive Slow 1.", + "Enemies within #4#2 blocks receive Slow 1.", }); } @@ -36,7 +36,7 @@ public class Intimidation extends Skill int level = getLevel(cur); if (level == 0) continue; - HashMap targets = UtilPlayer.getInRadius(cur.getLocation(), 3 + (level * 3)); + HashMap targets = UtilPlayer.getInRadius(cur.getLocation(), 3 + (level * 2)); for (Player other : targets.keySet()) if (!other.equals(cur)) if (Factory.Relation().canHurt(cur, other)) diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/AxeThrow.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/AxeThrow.java index bf2d6aa75..14ae0fcf1 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/AxeThrow.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/AxeThrow.java @@ -52,7 +52,7 @@ public class AxeThrow extends SkillActive implements IThrown SetDesc(new String[] { "Throw your axe with #0.7#0.1 velocity, ", - "dealing #5.5#0.5 damage.", + "dealing #4.5#0.5 damage.", "", "You pull your axe back to you when it", "collides with anything.", @@ -107,7 +107,7 @@ public class AxeThrow extends SkillActive implements IThrown if (level <= 0) return; - double damage = 5.5 + 0.5 * level; + double damage = 4.5 + 0.5 * level; //Damage Event Factory.Damage().NewDamageEvent(target, data.getThrower(), null, diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/HiltSmash.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/HiltSmash.java index 9e743cea2..cf9845e03 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/HiltSmash.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/HiltSmash.java @@ -46,7 +46,7 @@ public class HiltSmash extends SkillActive SetDesc(new String[] { "Smash the hilt of your sword into", - "your opponent, dealing #2#1 damage", + "your opponent, dealing #1#1 damage", "and Slow 3 for #0.5#0.5 seconds." }); } @@ -153,7 +153,7 @@ public class HiltSmash extends SkillActive //Damage Event Factory.Damage().NewDamageEvent((LivingEntity)ent, player, null, - DamageCause.CUSTOM, 2 + level, false, true, false, + DamageCause.CUSTOM, 1 + level, false, true, false, player.getName(), GetName()); //Sound diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/Swordsmanship.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/Swordsmanship.java index 1e29be118..5d62eac5f 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/Swordsmanship.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/Swordsmanship.java @@ -30,7 +30,7 @@ public class Swordsmanship extends Skill { "Prepare a powerful sword attack;", "You gain 1 Charge every #5#-1 seconds.", - "You can store a maximum of #0#1 Charges.", + "You can store a maximum of #1#1 Charges.", "", "When you next attack, your damage is", "increased by the number of your Charges,", @@ -79,7 +79,7 @@ public class Swordsmanship extends Skill if (!Recharge.Instance.use(cur, GetName(), 5000 - (1000 * level), false, false)) continue; - int max = level; + int max = 1 + level; int charge = 1; if (_charges.containsKey(cur)) diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Blizzard.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Blizzard.java index 57bf77854..e27680712 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Blizzard.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Blizzard.java @@ -67,7 +67,7 @@ public class Blizzard extends SkillActive @Override public String GetEnergyString() { - return "Energy: #34#-2 per Second"; + return "Energy: #42#-2 per Second"; } @Override @@ -114,7 +114,7 @@ public class Blizzard extends SkillActive } //Energy - if (!Factory.Energy().Use(cur, GetName(), 1.7 - (0.1 * level), true, true)) + if (!Factory.Energy().Use(cur, GetName(), 2.1 - (0.1 * level), true, true)) { _active.remove(cur); continue; diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/IcePrison.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/IcePrison.java index 2c2c0f118..a04b31ebc 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/IcePrison.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/IcePrison.java @@ -48,7 +48,7 @@ public class IcePrison extends SkillActive implements IThrown { "Launch an icy orb. When it collides,", "it creates a hollow sphere of ice", - "thats lasts for #3#1.5 seconds.", + "thats lasts for #3#1 seconds.", }); } @@ -171,7 +171,7 @@ public class IcePrison extends SkillActive implements IThrown if (!UtilBlock.airFoliage(freeze)) return; - long time = 3500 + (1500 * level); + long time = 3500 + (1000 * level); int yDiff = freeze.getY() - mid.getY(); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Immolate.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Immolate.java index 043333409..d0f884988 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Immolate.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Immolate.java @@ -152,6 +152,12 @@ public class Immolate extends Skill Remove(cur); continue; } + + if (cur.getLocation().getBlock().getType() == Material.WATER || cur.getLocation().getBlock().getType() == Material.STATIONARY_WATER) + { + Remove(cur); + continue; + } //Energy if (!Factory.Energy().Use(cur, GetName(), 0.65 - (level * 0.05), true, true)) diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Inferno.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Inferno.java index 9ef227c18..2c07078cb 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Inferno.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Inferno.java @@ -53,7 +53,7 @@ public class Inferno extends SkillActive @Override public String GetEnergyString() { - return "Energy: #34#-2 per Second"; + return "Energy: #42#-2 per Second"; } @Override @@ -100,7 +100,7 @@ public class Inferno extends SkillActive } //Energy - if (!Factory.Energy().Use(cur, GetName(), 1.7 - (0.1 * level), true, false)) + if (!Factory.Energy().Use(cur, GetName(), 2.1 - (0.1 * level), true, false)) { _active.remove(cur); continue; @@ -113,7 +113,7 @@ public class Inferno extends SkillActive itemStack.setItemMeta(meta); Item fire = cur.getWorld().dropItem(cur.getEyeLocation().add(cur.getLocation().getDirection()), itemStack); - Factory.Fire().Add(fire, cur, 0.7, 0, 0.3 + (0.1 * level), 1, GetName(), false); + Factory.Fire().Add(fire, cur, 0.7, 0, 0.3 + (0.1 * level), .25, GetName(), false); fire.teleport(cur.getEyeLocation()); double x = 0.07 - (UtilMath.r(14)/100d); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/LifeBonds.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/LifeBonds.java index 837fb8ada..4ad73365d 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/LifeBonds.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/LifeBonds.java @@ -42,8 +42,8 @@ public class LifeBonds extends Skill { "Drop Axe/Sword to Toggle.", "", - "Transfers life from healthy allies", - "to nearby allies with less health.", + "Transfers life from yourself to", + "nearby allies with less health.", "", "Transfers #0.5#0.5 health every second.", "Maximum range of #3#3 Blocks from user." @@ -188,9 +188,6 @@ public class LifeBonds extends Skill int level = getLevel(cur); //Bonds - Player highest = null; - double highestHp = 0; - Player lowest = null; double lowestHp = 20; @@ -199,12 +196,6 @@ public class LifeBonds extends Skill if (Factory.Relation().canHurt(cur, other) && !other.equals(cur)) continue; - if (highest == null || other.getHealth() > highestHp) - { - highest = other; - highestHp = other.getHealth(); - } - if (lowest == null || other.getHealth() < lowestHp) { lowest = other; @@ -213,18 +204,18 @@ public class LifeBonds extends Skill } //Nothing to Transfer - if (highest == null || lowest == null || highest.equals(lowest) || highestHp - lowestHp < 2) + if (cur.equals(lowest) || cur.getHealth() - lowestHp < 2) continue; double amount = 0.5 + (0.5 * level); - amount = Math.min((double)(highestHp - lowestHp) / 2d, amount); + amount = Math.min((double)(cur.getHealth() - lowestHp) / 2d, amount); //Steal - UtilPlayer.health(highest, -amount); + UtilPlayer.health(cur, -amount); //Hearts - _hearts.add(new LifeBondsData(highest.getLocation().add(0, 0.8, 0), lowest, amount)); + _hearts.add(new LifeBondsData(cur.getLocation().add(0, 0.8, 0), lowest, amount)); //Effect //highest.getWorld().playEffect(highest.getLocation(), Effect.STEP_SOUND, 18); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/MagmaBlade.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/MagmaBlade.java index 4ad21a66b..e107aca50 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/MagmaBlade.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/MagmaBlade.java @@ -22,7 +22,7 @@ public class MagmaBlade extends Skill SetDesc(new String[] { "Your sword deals an additional,", - "#0.5#0.5 damage to burning opponents,", + "#0.25#0.25 damage to burning opponents,", "but also extinguishes them.", }); } @@ -54,7 +54,7 @@ public class MagmaBlade extends Skill if (level == 0) return; //Damage - event.AddMod(damager.getName(), GetName(), 0.5 + 0.5 * level, true); + event.AddMod(damager.getName(), GetName(), 0.25 + 0.25 * level, true); //Effect damager.getWorld().playSound(damager.getLocation(), Sound.FIZZ, 0.8f, 0f); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/Sharpshooter.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/Sharpshooter.java index 77218628b..4a0f2ede7 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/Sharpshooter.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/Sharpshooter.java @@ -18,18 +18,24 @@ import mineplex.minecraft.game.classcombat.Skill.Skill; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; import org.bukkit.Sound; +import org.bukkit.World; +import org.bukkit.block.Block; +import org.bukkit.entity.Arrow; import org.bukkit.entity.Entity; 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.EntityShootBowEvent; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.util.BlockIterator; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; public class Sharpshooter extends Skill { + private WeakHashMap _missedCount = new WeakHashMap(); private WeakHashMap _hitCount = new WeakHashMap(); - private HashMap _arrows = new HashMap(); + private HashMap _arrows = new HashMap(); public Sharpshooter(SkillFactory skills, String name, ClassType classType, SkillType skillType, int cost, int levels) { @@ -53,9 +59,15 @@ public class Sharpshooter extends Skill int level = getLevel((Player)event.getEntity()); if (level == 0) return; - + + if (!(event.getProjectile() instanceof Arrow)) + { + System.out.println(GetName() + " : " + event.getEntity().getName() + " shot bow but resulting projectile was now Arrow?!?!?!?"); + return; + } + //Store - _arrows.put(event.getProjectile(), (Player)event.getEntity()); + _arrows.put((Arrow) event.getProjectile(), (Player)event.getEntity()); } @EventHandler(priority = EventPriority.HIGH) @@ -98,9 +110,46 @@ public class Sharpshooter extends Skill projectile.remove(); + _missedCount.remove(player); + Recharge.Instance.useForce(player, GetName() + " Timer", 5000); } + @EventHandler + public void missReset(ProjectileHitEvent event) + { + final Projectile projectile = event.getEntity(); + Factory.runSyncLater(() -> { + if (!projectile.isDead() && _arrows.containsKey(projectile)) + { + Player shooter = (Player) projectile.getShooter(); + + if (!_hitCount.containsKey(shooter)) + { + return; + } + + if (!_missedCount.containsKey(shooter)) + { + _missedCount.put(shooter, Integer.valueOf(1)); + } + else + { + _missedCount.put(shooter, Integer.valueOf(_missedCount.get(shooter).intValue() + 1)); + + // Reset + if (_missedCount.get(shooter).intValue() >= 2) + { + _hitCount.remove(shooter); + _missedCount.remove(shooter); + UtilPlayer.message(shooter, F.main(GetClassType().name(), GetName() + " : " + F.elem("Damage Bonus Reset"))); + shooter.playSound(shooter.getLocation(), Sound.NOTE_PLING, 1f, 0.75f); + } + } + } + }, 3l); + } + @EventHandler public void resetViaTime(UpdateEvent event) { @@ -148,5 +197,6 @@ public class Sharpshooter extends Skill public void Reset(Player player) { _hitCount.remove(player); + _missedCount.remove(player); } } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/VitalitySpores.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/VitalitySpores.java index db7e4e34c..310146f5a 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/VitalitySpores.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/VitalitySpores.java @@ -1,28 +1,26 @@ package mineplex.minecraft.game.classcombat.Skill.Ranger; import java.util.HashMap; +import java.util.Iterator; +import java.util.Map.Entry; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; -import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.core.updater.UpdateType; -import mineplex.core.common.util.UtilAlg; -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.F; import mineplex.core.common.util.UtilTime; -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.classcombat.Class.IPvpClass.ClassType; import mineplex.minecraft.game.classcombat.Skill.Skill; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; public class VitalitySpores extends Skill { - private HashMap _lastMove = new HashMap(); + private HashMap _lastDamage = new HashMap<>(); public VitalitySpores(SkillFactory skills, String name, ClassType classType, SkillType skillType, int cost, int levels) { @@ -30,47 +28,52 @@ public class VitalitySpores extends Skill SetDesc(new String[] { - "While standing still, forest spores", - "heal you for #0#0.5 health per 2 seconds." + "After getting hit, if no damage is taken", + "for 10 Seconds then you will receive", + "Regeneration #2#0 for #5#1 Seconds", }); } @EventHandler - public void playerMove(PlayerMoveEvent event) + public void damage(CustomDamageEvent event) { - if (doesUserHaveSkill(event.getPlayer()) && UtilMath.offset(event.getFrom(), event.getTo()) > 0) - _lastMove.put(event.getPlayer(), System.currentTimeMillis()); + if (doesUserHaveSkill(event.GetDamageePlayer())) + { + if (event.GetDamageePlayer().hasPotionEffect(PotionEffectType.REGENERATION)) + { + event.GetDamageePlayer().removePotionEffect(PotionEffectType.REGENERATION); + } + else + { + _lastDamage.put(event.GetDamageePlayer(), Long.valueOf(System.currentTimeMillis())); + } + } } @EventHandler public void update(UpdateEvent event) { if (event.getType() != UpdateType.TICK) + { return; - - for (Player cur : GetUsers()) - { - int level = getLevel(cur); - if (level == 0) continue; - - if (!_lastMove.containsKey(cur)) - continue; - - if (UtilTime.elapsed(_lastMove.get(cur), 2000)) + } + + Iterator> iterator = _lastDamage.entrySet().iterator(); + while (iterator.hasNext()) + { + Entry entry = iterator.next(); + + if (UtilTime.elapsed(entry.getValue().longValue(), 10000)) { - UtilPlayer.health(cur, 0.5 * level); - - UtilParticle.PlayParticle(ParticleType.HEART, cur.getEyeLocation().add(UtilAlg.getBehind(cur.getLocation().getDirection().multiply(0.5))), 0, 0.2f, 0, 0, 1, - ViewDist.LONG, UtilServer.getPlayers()); - - _lastMove.put(cur, System.currentTimeMillis()); - } + iterator.remove(); + entry.getKey().addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, (20 * (5 + getLevel(entry.getKey()))), 1)); + } } } @Override public void Reset(Player player) { - _lastMove.remove(player); + _lastDamage.remove(player); } } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/WolfsPounce.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/WolfsPounce.java index 51e412beb..195ff7a27 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/WolfsPounce.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/WolfsPounce.java @@ -45,7 +45,7 @@ public class WolfsPounce extends SkillChargeSword "Taking damage cancels charge.", "", "Colliding with another player", - "mid-air deals up to #4#1 damage", + "mid-air deals up to #2#1 damage", "and Slow 2 for 3 seconds." }); @@ -128,7 +128,7 @@ public class WolfsPounce extends SkillChargeSword if (_chargeStore.containsKey(damager)) charge = _chargeStore.remove(damager); - int damage = (int)((4 + getLevel(damager)) * charge); + int damage = (int)((2 + getLevel(damager)) * charge); //Damage Event Factory.Damage().NewDamageEvent(damagee, damager, null, diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/SkillFactory.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/SkillFactory.java index 7fd52db63..8bc9f565b 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/SkillFactory.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/SkillFactory.java @@ -221,10 +221,6 @@ public class SkillFactory extends MiniPlugin implements ISkillFactory AddSkill(new Fitness(this, "Mana Pool", ClassType.Mage, SkillType.GlobalPassive, 1, 3)); AddSkill(new Recharge(this, "Mana Regeneration", ClassType.Mage, SkillType.GlobalPassive, 1, 3)); - AddSkill(new Fitness(this, "Fitness", ClassType.Assassin, SkillType.GlobalPassive, 1, 3)); - AddSkill(new Recharge(this, "Rest", ClassType.Assassin, SkillType.GlobalPassive, 1, 3)); - - //AddSkill(new Stamina(this, "Stamina", ClassType.Global, SkillType.GlobalPassive, 1, 1)); //AddSkill(new Swim(this, "Swim", ClassType.Global, SkillType.GlobalPassive, 1, 1)); } @@ -235,9 +231,9 @@ public class SkillFactory extends MiniPlugin implements ISkillFactory //Sword AddSkill(new Evade(this, "Evade", ClassType.Assassin, SkillType.Sword, - 1, 4, + 2, 1, 0, 0, - 6500, -500, true, + 2500, -500, true, new Material[] {Material.IRON_SWORD, Material.GOLD_SWORD, Material.DIAMOND_SWORD}, new Action[] {Action.RIGHT_CLICK_AIR, Action.RIGHT_CLICK_BLOCK})); @@ -337,7 +333,7 @@ public class SkillFactory extends MiniPlugin implements ISkillFactory AddSkill(new Takedown(this, "Takedown", ClassType.Brute, SkillType.Axe, 1, 5, 0, 0, - 21000, -1000, true, + 17000, -1000, true, new Material[] {Material.IRON_AXE, Material.GOLD_AXE, Material.DIAMOND_AXE}, new Action[] {Action.RIGHT_CLICK_AIR, Action.RIGHT_CLICK_BLOCK})); @@ -374,7 +370,7 @@ public class SkillFactory extends MiniPlugin implements ISkillFactory AddSkill(new Riposte(this, "Riposte", ClassType.Knight, SkillType.Sword, 1, 5, 0, 0, - 11000, -1000, false, + 15000, -1000, false, new Material[] {Material.IRON_SWORD, Material.GOLD_SWORD, Material.DIAMOND_SWORD}, new Action[] {Action.RIGHT_CLICK_AIR, Action.RIGHT_CLICK_BLOCK})); @@ -411,7 +407,7 @@ public class SkillFactory extends MiniPlugin implements ISkillFactory AddSkill(new AxeThrow(this, "Roped Axe Throw", ClassType.Knight, SkillType.Axe, 1, 5, 0, 0, - 3300, -300, true, + 4300, -300, true, new Material[] {Material.IRON_AXE, Material.GOLD_AXE, Material.DIAMOND_AXE}, new Action[] {Action.RIGHT_CLICK_AIR, Action.RIGHT_CLICK_BLOCK})); diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/Condition.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/Condition.java index b84ac5cd0..8109e3ef2 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/Condition.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/Condition.java @@ -72,7 +72,9 @@ public class Condition protected boolean _add = false; protected boolean _live = false; - + + protected boolean _cancelPotion; + protected boolean _showIndicator = true; public Condition(ConditionManager manager, String reason, LivingEntity ent, LivingEntity source, @@ -101,6 +103,35 @@ public class Condition //Live if NOT Additive _live = !add; } + + public Condition(ConditionManager manager, String reason, LivingEntity ent, LivingEntity source, + ConditionType type, int mult, int ticks, boolean add, Material visualType, byte visualData, boolean showIndicator, boolean ambient, boolean cancelPotion) + { + Manager = manager; + _time = System.currentTimeMillis(); + + _reason = reason; + + _ent = ent; + _source = source; + + _type = type; + _mult = mult; + _ticks = ticks; + _ticksTotal = ticks; + _ambient = ambient; + + _indicatorType = visualType; + _indicatorData = visualData; + _showIndicator = showIndicator; + + _cancelPotion = cancelPotion; + + _add = add; + + //Live if NOT Additive + _live = !add; + } public boolean Tick() { @@ -124,6 +155,11 @@ public class Condition public void Add() { + if (_cancelPotion) + { + return; + } + try { PotionEffectType type = PotionEffectType.getByName(_type.toString()); diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/ConditionFactory.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/ConditionFactory.java index e6fac9836..fcfa571e1 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/ConditionFactory.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/ConditionFactory.java @@ -239,10 +239,16 @@ public class ConditionFactory public Condition Poison(String reason, LivingEntity ent, LivingEntity source, double duration, int mult, boolean extend, boolean showIndicator, boolean ambient) + { + return Poison(reason, ent, source, duration, mult, extend, showIndicator, ambient, false); + } + + public Condition Poison(String reason, LivingEntity ent, LivingEntity source, + double duration, int mult, boolean extend, boolean showIndicator, boolean ambient, boolean cancelPotion) { return Manager.AddCondition(new Condition(Manager, reason, ent, source, ConditionType.POISON, mult, (int)(20 * duration), extend, - Material.SLIME_BALL, (byte)14, showIndicator, ambient)); + Material.SLIME_BALL, (byte)14, showIndicator, ambient, cancelPotion)); } public Condition PoisonShock(String reason, LivingEntity ent, LivingEntity source, diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index bcd04629c..8d5435b32 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -2,10 +2,12 @@ package nautilus.game.arcade.game; import com.google.common.collect.Lists; import com.mojang.authlib.GameProfile; + import mineplex.core.common.util.*; import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.elo.EloPlayer; import mineplex.core.elo.EloTeam; +import mineplex.core.gadget.types.GadgetType; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.packethandler.IPacketHandler; import mineplex.core.packethandler.PacketInfo; @@ -34,6 +36,7 @@ import nautilus.game.arcade.world.WorldData; import net.minecraft.server.v1_8_R3.EntityItem; import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity; import net.minecraft.server.v1_8_R3.WorldServer; + import org.bukkit.*; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -1649,6 +1652,18 @@ public abstract class Game implements Listener // End SetState(GameState.End); } + + @EventHandler + public void disableParticles(GameStateChangeEvent event) + { + if (event.GetState() == GameState.Prepare && Manager.getCosmeticManager().getGadgetManager().hideParticles()) + { + for (Player player : GetPlayers(false)) + { + getArcadeManager().getCosmeticManager().getGadgetManager().removeGadgetType(player, GadgetType.PARTICLE); + } + } + } @EventHandler public void onGameStart(GameStateChangeEvent event) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsCTF.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsCTF.java index fbe9a5428..32855df7d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsCTF.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsCTF.java @@ -1,9 +1,7 @@ package nautilus.game.arcade.game.games.champions; import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilPlayer; -import mineplex.core.inventory.data.Item; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.combat.DeathMessageType; @@ -28,7 +26,6 @@ import nautilus.game.arcade.stats.SpecialWinStatTracker; import nautilus.game.arcade.stats.TheLongestShotStatTracker; import org.bukkit.Location; -import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsDominate.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsDominate.java index f8583deec..52763c8a3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsDominate.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsDominate.java @@ -16,7 +16,6 @@ import nautilus.game.arcade.game.games.champions.kits.KitMage; import nautilus.game.arcade.game.games.champions.kits.KitRanger; import nautilus.game.arcade.game.games.common.Domination; import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.stats.ElectrocutionStatTracker; import nautilus.game.arcade.stats.KillReasonStatTracker; import nautilus.game.arcade.stats.SeismicSlamStatTracker; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsTDM.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsTDM.java index 3f6441659..8baa4a01c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsTDM.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsTDM.java @@ -16,7 +16,6 @@ import nautilus.game.arcade.game.games.champions.kits.KitMage; import nautilus.game.arcade.game.games.champions.kits.KitRanger; import nautilus.game.arcade.game.games.common.TeamDeathmatch; import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.stats.ElectrocutionStatTracker; import nautilus.game.arcade.stats.KillAllOpposingStatTracker; import nautilus.game.arcade.stats.KillReasonStatTracker; 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 55535e846..c21d4e824 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 @@ -4,6 +4,15 @@ 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.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilFirework; +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.itemstack.ItemStackFactory; import mineplex.core.packethandler.IPacketHandler; import mineplex.core.packethandler.PacketInfo; @@ -311,13 +320,14 @@ public class HideSeek extends TeamGame { if (event.GetState() == GameState.Prepare) { + System.out.println("prep"); this.getArcadeManager().getPacketHandler().addPacketHandler(_blockDisguise, PacketPlayOutSpawnEntityLiving.class, PacketPlayOutEntityDestroy.class); this.getArcadeManager().getPacketHandler().addPacketHandler(_useEntity, true, PacketPlayInUseEntity.class); } else if (event.GetState() == GameState.Dead) { - this.getArcadeManager().getPacketHandler().removePacketHandler(_blockDisguise); - this.getArcadeManager().getPacketHandler().removePacketHandler(_useEntity); + this.getArcadeManager().getPacketHandler().removePacketHandler(_blockDisguise); + this.getArcadeManager().getPacketHandler().removePacketHandler(_useEntity); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java index 6ab2f5018..18a6494aa 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java @@ -1,6 +1,5 @@ package nautilus.game.arcade.game.games.wizards; -import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -51,11 +50,11 @@ import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick; import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClickBlock; import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClickEntity; import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.managers.chat.ChatStatData; import net.minecraft.server.v1_8_R3.EntityFireball; import net.minecraft.server.v1_8_R3.PacketPlayOutSetSlot; import net.minecraft.server.v1_8_R3.PacketPlayOutWindowItems; -import nautilus.game.arcade.managers.chat.ChatStatData; import org.apache.commons.lang.IllegalClassException; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -736,7 +735,7 @@ public class Wizards extends SoloGame done++; } } - + private void displayProgress(String progressColor, String prefix, double amount, String suffix, Player... players) { // Generate Bar @@ -863,7 +862,7 @@ public class Wizards extends SoloGame return items; } - + private void dropSpells(Player player) { HashSet spells = new HashSet(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java index c00b8f81d..c4ef3eaf9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java @@ -720,7 +720,7 @@ public class GameFlagManager implements Listener player.removePotionEffect(potion.getType()); //Visual - Manager.GetCondition().Factory().Blind("Ghost", player, player, 2.5, 0, false, false, false); +// Manager.GetCondition().Factory().Blind("Ghost", player, player, 2.5, 0, false, false, false); player.setFireTicks(0); player.setFallDistance(0); From d5a1312c48d20813aa195d67f323341607a7c529 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Wed, 27 Jul 2016 20:46:40 -0400 Subject: [PATCH 71/90] Update border size to match new map --- .../src/mineplex/game/clans/clans/regions/ClansRegions.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/regions/ClansRegions.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/regions/ClansRegions.java index b60c27ae8..640a27c72 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/regions/ClansRegions.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/regions/ClansRegions.java @@ -24,7 +24,7 @@ public class ClansRegions extends MiniPlugin public final static int SHOP_RADIUS = 5; // Radius of shop claim area (measured in chunks) public final static int FIELDS_RADIUS = 7; // Radius of fields claim area (measured in chunks) public final static int BORDERLANDS_RADIUS = 85; // Radius of borderlands claim area (measured in chunks) - public static final int BORDER_RADIUS = 1319; + public static final int BORDER_RADIUS = 1250; private ClansManager _manager; private World _world; From b718a723664bc70e6bf3d124c8be366c807e709f Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 28 Jul 2016 02:59:03 -0400 Subject: [PATCH 72/90] Fix shop chunk size being too small for map --- .../src/mineplex/game/clans/clans/regions/ClansRegions.java | 2 +- .../clans/scoreboard/elements/ScoreboardElementPlayer.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/regions/ClansRegions.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/regions/ClansRegions.java index 640a27c72..55debe953 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/regions/ClansRegions.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/regions/ClansRegions.java @@ -21,7 +21,7 @@ public class ClansRegions extends MiniPlugin { public final static String DEFAULT_WORLD_NAME = "world"; public final static int SPAWN_RADIUS = 3; // Radius of spawn claim area (measured in chunks) - public final static int SHOP_RADIUS = 5; // Radius of shop claim area (measured in chunks) + public final static int SHOP_RADIUS = 6; // Radius of shop claim area (measured in chunks) public final static int FIELDS_RADIUS = 7; // Radius of fields claim area (measured in chunks) public final static int BORDERLANDS_RADIUS = 85; // Radius of borderlands claim area (measured in chunks) public static final int BORDER_RADIUS = 1250; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java index c035b812b..33c24cfff 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java @@ -27,7 +27,7 @@ public class ScoreboardElementPlayer implements ScoreboardElement { List output = Lists.newArrayList(); output.add(C.cYellowB + "Gold"); - output.add(C.cGold + "Gold " + _clansManager.getGoldManager().Get(player).getBalance()); + output.add(C.cGold + _clansManager.getGoldManager().Get(player).getBalance()); output.add(" "); From aef94e13a8f3ab9168cbba0750b7512ca5d5bb39 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 28 Jul 2016 04:18:29 -0400 Subject: [PATCH 73/90] Fix message not being sent --- .../mineplex/staffServer/salespackage/SalesPackageManager.java | 1 + 1 file changed, 1 insertion(+) diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java index 97bc832c7..e93d43c34 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java @@ -126,6 +126,7 @@ public class SalesPackageManager extends MiniPlugin coinBuilder.sendToPlayer(caller); chestBuilder.sendToPlayer(caller); packageBuilder.sendToPlayer(caller); + clanBuilder.sendToPlayer(caller); } public StatsManager getStatsManager() From 639e089901bd0e3c7c8300c09382504fad4e6736 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 28 Jul 2016 04:28:34 -0400 Subject: [PATCH 74/90] Disable clans tutorial --- .../src/mineplex/game/clans/tutorial/TutorialManager.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/TutorialManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/TutorialManager.java index 826fbccc1..4f9da06f8 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/TutorialManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/TutorialManager.java @@ -23,7 +23,6 @@ import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.message.ClansMessageManager; import mineplex.game.clans.tutorial.command.TutorialCommand; import mineplex.game.clans.tutorial.gui.TutorialShop; -import mineplex.game.clans.tutorial.tutorials.clans.ClansMainTutorial; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -49,7 +48,7 @@ public class TutorialManager extends MiniPlugin implements ScoreboardElement _tutorialMap = new EnumMap(TutorialType.class); _shopMap = new EnumMap(TutorialType.class); - addTutorial(TutorialType.MAIN, new ClansMainTutorial(plugin, clansManager, _clansMessageManager, hologram, npcManager, taskManager)); + //addTutorial(TutorialType.MAIN, new ClansMainTutorial(plugin, clansManager, _clansMessageManager, hologram, npcManager, taskManager)); chat.AddFilter(event -> { if (inTutorial(event.getPlayer())) From ab9bf2f405dced16206e49c394aee857cee1c750 Mon Sep 17 00:00:00 2001 From: TadahTech Date: Thu, 28 Jul 2016 03:40:24 -0500 Subject: [PATCH 75/90] Fixes possible bug with party leaders not seeing chat. Adds pling when you received an invite. --- .../party/manager/PartyInviteManager.java | 2 + .../core/party/manager/PartyRedisManager.java | 37 +++++++++---------- .../src/mineplex/core/portal/Portal.java | 6 +++ .../src/mineplex/hub/HubManager.java | 10 +---- .../arcade/managers/chat/GameChatManager.java | 16 +++----- 5 files changed, 34 insertions(+), 37 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyInviteManager.java b/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyInviteManager.java index b05477683..bfff39b40 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyInviteManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyInviteManager.java @@ -17,6 +17,7 @@ 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 org.bukkit.Bukkit; +import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitTask; @@ -124,6 +125,7 @@ public class PartyInviteManager inviteTo(player.getUniqueId(), sender, sender, serverFrom); Lang.INVITE_RECEIVED.send(player, sender); sendAcceptOrDeny(player, sender); + player.playSound(player.getLocation(), Sound.NOTE_PLING, 1.0F, 1.0F); } /** diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyRedisManager.java b/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyRedisManager.java index 4f1d01473..993fe1a5f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyRedisManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyRedisManager.java @@ -139,12 +139,7 @@ public class PartyRedisManager case PLAYER_FIND_RESPONSE: UUID uuid = UUID.fromString(third); - BukkitTask task = TASKS.remove(second); - - if (task != null) - { - task.cancel(); - } + cancelTask(second); Player inviter = Bukkit.getPlayerExact(contents[3]); if (_plugin.getInviteManager().isInvitedTo(uuid, inviter.getName())) @@ -177,12 +172,7 @@ public class PartyRedisManager private void handleNotAccepting(String second, String[] contents) { - BukkitTask task = TASKS.remove(second); - - if (task != null) - { - task.cancel(); - } + cancelTask(second); Player inviter = Bukkit.getPlayerExact(contents[3]); inviter.sendMessage(F.main("Party", F.name(second) + " is not accepting invites at this time.")); @@ -190,13 +180,7 @@ public class PartyRedisManager private void handleAlreadyIn(String second, String[] contents) { - BukkitTask task = TASKS.remove(second); - - if (task != null) - { - task.cancel(); - } - + cancelTask(second); Player inviter = Bukkit.getPlayerExact(contents[3]); Lang.ALREADY_IN.send(inviter, second); } @@ -215,6 +199,11 @@ public class PartyRedisManager @Override public void run() { + if(!TASKS.containsKey(player)) + { + cancel(); + return; + } TASKS.remove(player); Player senderPlayer = Bukkit.getPlayerExact(sender); if (senderPlayer == null) @@ -293,4 +282,14 @@ public class PartyRedisManager { return FIND_PLAYERS_CHANNEL; } + + public void cancelTask(String player) + { + BukkitTask task = TASKS.remove(player); + + if (task != null) + { + task.cancel(); + } + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java b/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java index 1b02de296..0e872a0c4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java @@ -9,6 +9,7 @@ import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTabTitle; +import mineplex.core.party.Lang; import mineplex.core.party.Party; import mineplex.core.party.event.PartySendToServerEvent; import mineplex.core.portal.Commands.SendCommand; @@ -101,6 +102,11 @@ public class Portal extends MiniPlugin if (event.getParty() != null && override) { Party party = event.getParty(); + if(!party.getOwner().equalsIgnoreCase(player.getName())) + { + Lang.NOT_OWNER_SERVER.send(player); + return; + } sendParty(party); return; } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index c983c9cbb..88fc33b11 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -102,6 +102,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.Random; +import java.util.stream.Collectors; public class HubManager extends MiniClientPlugin { @@ -601,14 +602,7 @@ public class HubManager extends MiniClientPlugin event.setMessage(event.getMessage().substring(1, event.getMessage().length())); event.setFormat(levelStr + C.cDPurple + C.Bold + "Party " + C.cWhite + C.Bold + playerName + " " + C.cPurple + "%2$s"); - - for (String name : party.getMembers()) - { - Player other = UtilPlayer.searchExact(name); - - if (other != null) - event.getRecipients().add(other); - } + event.getRecipients().addAll(party.getMembersByUUID().stream().map(Bukkit::getPlayer).collect(Collectors.toList())); } else { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java index 368746c24..00beb0a37 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java @@ -11,6 +11,7 @@ import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.GameTeam; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -25,6 +26,7 @@ import java.util.Collection; import java.util.Iterator; import java.util.LinkedList; import java.util.Map; +import java.util.stream.Collectors; public class GameChatManager implements Listener { @@ -131,20 +133,14 @@ public class GameChatManager implements Listener event.setMessage(event.getMessage().substring(1, event.getMessage().length())); event.setFormat(levelStr + C.cDPurple + C.Bold + "Party " + C.cWhite + C.Bold + event.getPlayer().getName() + " " + C.cPurple + "%2$s"); - - for (String member : party.getMembers()) - { - Player other = UtilPlayer.searchExact(member); - - if (other != null) - event.getRecipients().add(other); - } + event.getRecipients().addAll(party.getMembersByUUID().stream().map(Bukkit::getPlayer).collect(Collectors.toList())); } else { - UtilPlayer.message(sender, F.main("Party", "You are not in a Party.")); + UtilPlayer.message(event.getPlayer(), F.main("Party", "You are not in a Party.")); event.setCancelled(true); } + return; } @@ -156,7 +152,7 @@ public class GameChatManager implements Listener format = event.getFormat().split(rankStr)[0]; name = _manager.GetColor(sender) + sender.getName() + C.Reset; - if (event.getMessage().charAt(0) == '@') + if (event.getMessage().charAt(0) == '#') message = event.getFormat().split(sender.getName())[1].replace("%2$s", "") + _manager.GetChat().getFilteredMessage(sender, event.getMessage().substring(1, event.getMessage().length())); else message = event.getFormat().split(sender.getName())[1].replace("%2$s", "") + _manager.GetChat().getFilteredMessage(sender, event.getMessage()); From c30d30b2e78c2647485b702a878527b7fbfce24a Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 28 Jul 2016 05:33:37 -0400 Subject: [PATCH 76/90] Fixes event mobs getting stuck outside --- .../game/core/boss/EventCreature.java | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventCreature.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventCreature.java index 7f1f2bdfa..5093b0370 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventCreature.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventCreature.java @@ -37,6 +37,7 @@ public abstract class EventCreature implements Listener private double _health; private double _maxHealth; private boolean _showHealthName; + private long _teleportHome; // Fight Data private long _lastDamaged; @@ -55,6 +56,7 @@ public abstract class EventCreature implements Listener _health = health; _maxHealth = health; _showHealthName = true; + _teleportHome = -1L; } public double getDifficulty() @@ -282,7 +284,26 @@ public abstract class EventCreature implements Listener if (UtilMath.offset2d(_entity.getLocation(), _spawnLocation) > 34) { - _entity.setVelocity(UtilAlg.getTrajectory(_entity.getLocation(), _spawnLocation).normalize().multiply(2)); + if (_teleportHome != -1 && System.currentTimeMillis() >= _teleportHome) + { + _entity.teleport(_spawnLocation); + _teleportHome = -1; + } + else + { + _entity.setVelocity(UtilAlg.getTrajectory(_entity.getLocation(), _spawnLocation).normalize().multiply(2)); + if (_teleportHome == -1) + { + _teleportHome = System.currentTimeMillis() + 5000; + } + } + } + else + { + if (_teleportHome != -1) + { + _teleportHome = -1; + } } _lastLocation = _entity.getLocation(); From 4efe1fe76d3063e8ac9edf4e49a2f2a40606b118 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 28 Jul 2016 05:46:26 -0400 Subject: [PATCH 77/90] Make boss portals open where the boss spawned --- .../clans/clans/nether/BossNetherPortal.java | 279 ++++++++++++++++++ .../clans/clans/nether/NetherManager.java | 28 +- 2 files changed, 306 insertions(+), 1 deletion(-) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/BossNetherPortal.java diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/BossNetherPortal.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/BossNetherPortal.java new file mode 100644 index 000000000..d09407609 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/BossNetherPortal.java @@ -0,0 +1,279 @@ +package mineplex.game.clans.clans.nether; + +import java.util.List; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClanTips.TipType; +import mineplex.game.clans.clans.ClansManager; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockDamageEvent; +import org.bukkit.event.block.BlockPhysicsEvent; +import org.bukkit.event.entity.EntityPortalEnterEvent; +import org.bukkit.event.entity.EntityPortalEvent; +import org.bukkit.event.player.PlayerPortalEvent; +import org.bukkit.event.world.ChunkUnloadEvent; +import org.bukkit.potion.PotionEffectType; + +import com.google.common.collect.Lists; + +/** + * Data and listener class for individual nether portals opened by bosses + */ +public class BossNetherPortal implements Listener +{ + private static final int SECONDS_UNTIL_PORTAL = 5; + private List _frame = Lists.newArrayList(); + private List _portal = Lists.newArrayList(); + private Location _loc; + private Location[] _corners; + private boolean _returnPortal; + private byte _portalFacing; + + public boolean Open = false; + public long Expire = -1; + + public BossNetherPortal(Location firstCorner, Location secondCorner, boolean returnPortal) + { + int maxX = Math.max(firstCorner.getBlockX(), secondCorner.getBlockX()); + int minX = Math.min(firstCorner.getBlockX(), secondCorner.getBlockX()); + int maxY = Math.max(firstCorner.getBlockY(), secondCorner.getBlockY()); + int minY = Math.min(firstCorner.getBlockY(), secondCorner.getBlockY()); + int maxZ = Math.max(firstCorner.getBlockZ(), secondCorner.getBlockZ()); + int minZ = Math.min(firstCorner.getBlockZ(), secondCorner.getBlockZ()); + + for (int x = minX; x <= maxX; x++) + { + for (int y = minY; y <= maxY; y++) + { + for (int z = minZ; z <= maxZ; z++) + { + if (minX == maxX) + { + if ((y != minY && y != maxY) && (z != minZ && z != maxZ)) + { + _portal.add(firstCorner.getWorld().getBlockAt(x, y, z)); + } + else + { + _frame.add(firstCorner.getWorld().getBlockAt(x, y, z)); + } + } + else + { + if ((x != minX && x != maxX) && (y != minY && y != maxY)) + { + _portal.add(firstCorner.getWorld().getBlockAt(x, y, z)); + } + else + { + _frame.add(firstCorner.getWorld().getBlockAt(x, y, z)); + } + } + } + } + } + + _loc = new Location(firstCorner.getWorld(), minX + ((maxX - minX) / 2), maxY, minZ + ((maxZ - minZ) / 2)); + _corners = new Location[] {firstCorner, secondCorner}; + _returnPortal = returnPortal; + + if (maxX == minX) + { + _portalFacing = (byte)2; + } + else + { + _portalFacing = (byte)0; + } + } + + private boolean isInPortal(Block block) + { + return _frame.contains(block) || _portal.contains(block); + } + + /** + * Gets the center location of this portal + * @return The center location of this portal + */ + public Location getLocation() + { + return _loc; + } + + /** + * Gets the corners of this portal + * @return An array of the corners of this portal + */ + public Location[] getCorners() + { + return _corners; + } + + /** + * Checks if this portal is a return portal + * @return Whether this portal is a return portal + */ + public boolean isReturnPortal() + { + return _returnPortal; + } + + /** + * Opens this portal for a given duration + * @param duration The duration to hold the portal open for + */ + @SuppressWarnings("deprecation") + public void open(long duration) + { + if (Open) + { + if (Expire != -1) + { + Expire = Expire + duration; + } + } + else + { + if (!_returnPortal) + { + Expire = System.currentTimeMillis() + duration; + } + Open = true; + Bukkit.getPluginManager().registerEvents(this, ClansManager.getInstance().getPlugin()); + for (Block block : _frame) + { + block.setType(Material.OBSIDIAN); + } + for (Block block : _portal) + { + block.setType(Material.PORTAL); + block.setData(_portalFacing); + } + } + } + + /** + * Closes this portal and clears away its blocks + */ + public void close() + { + Open = false; + Expire = -1; + for (Block block : _portal) + { + block.setType(Material.AIR); + } + for (Block block : _frame) + { + block.setType(Material.AIR); + } + HandlerList.unregisterAll(this); + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onBreak(BlockDamageEvent event) + { + if (isInPortal(event.getBlock())) + { + event.setInstaBreak(false); + event.setCancelled(true); + UtilPlayer.message(event.getPlayer(), F.main("Clans", "You cannot destroy a " + F.clansNether("Nether Portal"))); + } + } + + @EventHandler(priority = EventPriority.LOW) + public void playerPortalEvent(PlayerPortalEvent event) + { + if (isInPortal(event.getFrom().getBlock())) + { + event.setCancelled(true); + } + } + + @EventHandler(priority = EventPriority.LOW) + public void entityPortalEvent(EntityPortalEvent event) + { + if (isInPortal(event.getFrom().getBlock())) + { + event.setCancelled(true); + } + } + + @EventHandler + public void onEnterPortal(EntityPortalEnterEvent event) + { + if (event.getEntity() instanceof Player) + { + if (isInPortal(event.getLocation().getBlock())) + { + Bukkit.getScheduler().runTaskLater(ClansManager.getInstance().getPlugin(), () -> + { + if (isInPortal(event.getEntity().getLocation().getBlock())) + { + if (isReturnPortal()) + { + ClansManager.getInstance().getNetherManager().InNether.remove((Player)event.getEntity()); + event.getEntity().teleport(ClansManager.getInstance().getNetherManager().getReturnLocation((Player)event.getEntity())); + ClansManager.getInstance().getNetherManager().OverworldOrigins.remove((Player)event.getEntity()); + ((Player)event.getEntity()).removePotionEffect(PotionEffectType.NIGHT_VISION); + UtilPlayer.message(event.getEntity(), F.main(ClansManager.getInstance().getNetherManager().getName(), "You have escaped " + F.clansNether("The Nether") + "!")); + } + else + { + ClansManager.getInstance().getNetherManager().InNether.put((Player)event.getEntity(), Expire); + Location from = event.getEntity().getLocation(); + ClansManager.getInstance().getNetherManager().OverworldOrigins.put((Player)event.getEntity(), from); + event.getEntity().teleport(ClansManager.getInstance().getNetherManager().getNetherWorld().getSpawnLocation()); + ClansManager.getInstance().ClanTips.displayTip(TipType.ENTER_NETHER, (Player)event.getEntity()); + } + } + }, SECONDS_UNTIL_PORTAL * 20); + } + } + } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onBlockPhysics(BlockPhysicsEvent event) + { + if (isInPortal(event.getBlock())) + { + event.setCancelled(true); + } + } + + @EventHandler + public void handleExpiration(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + if (Open && Expire != -1 && System.currentTimeMillis() >= Expire) + { + close(); + ClansManager.getInstance().getNetherManager().BossPortals.remove(this); + } + } + + @EventHandler + public void onUnload(ChunkUnloadEvent event) + { + if (event.getChunk().getX() == _loc.getChunk().getX() && event.getChunk().getZ() == _loc.getChunk().getZ()) + { + event.setCancelled(true); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java index b50fb56b7..b872f9984 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java @@ -70,6 +70,7 @@ public class NetherManager extends MiniPlugin private NetherMinibossManager _miniboss; private World _netherWorld; private List _portals = Lists.newArrayList(); + public List BossPortals = Lists.newArrayList(); private List _returnPortals = Lists.newArrayList(); public HashMap InNether = new HashMap<>(); public HashMap OverworldOrigins = new HashMap<>(); @@ -249,6 +250,26 @@ public class NetherManager extends MiniPlugin spawnPortal(PORTAL_OPEN_DURATION); } + /** + * Spawns a nether portal when a boss dies + * @param bossSpawn The location where the boss spawned in + */ + public void spawnBossPortal(Location bossSpawn) + { + if (_returnPortals.isEmpty()) + { + return; + } + BossNetherPortal portal = new BossNetherPortal(bossSpawn.clone().add(-2, 5, 0), bossSpawn.clone().add(0, 0, 2), false); + portal.open(PORTAL_OPEN_DURATION); + for (NetherPortal returnPortal : _returnPortals) + { + returnPortal.open(-1); + } + UtilTextMiddle.display(F.clansNether("Nether Portal"), "Has opened at " + F.elem(UtilWorld.locToStrClean(portal.getLocation()))); + Bukkit.broadcastMessage(F.main(getName(), "A " + F.clansNether("Nether Portal") + " has opened at " + F.elem(UtilWorld.locToStrClean(portal.getLocation())) + " for " + F.elem(UtilTime.MakeStr(PORTAL_OPEN_DURATION)) + "!")); + } + /** * Creates a portal with the player's stored corners * @param creator The creator of the portal @@ -276,6 +297,11 @@ public class NetherManager extends MiniPlugin { portal.close(); } + for (BossNetherPortal portal : BossPortals) + { + portal.close(); + } + BossPortals.clear(); } /** @@ -495,7 +521,7 @@ public class NetherManager extends MiniPlugin { if (event.getCreature() instanceof GolemCreature || event.getCreature() instanceof SkeletonCreature || event.getCreature() instanceof SpiderCreature) { - spawnPortal(); + spawnBossPortal(event.getCreature().getSpawnLocation()); } } } \ No newline at end of file From f0be7794f5a3c9f132d8163f4a703153db291e3f Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 28 Jul 2016 06:16:20 -0400 Subject: [PATCH 78/90] Lower skeleton king passive rate --- .../game/core/boss/skeletonking/abilities/SkeletonPassive.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/abilities/SkeletonPassive.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/abilities/SkeletonPassive.java index 28577f521..b8ce6b1c2 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/abilities/SkeletonPassive.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/abilities/SkeletonPassive.java @@ -26,7 +26,7 @@ public class SkeletonPassive extends BossPassive { private static final int MAX_ARCHERS = 10; private static final int MAX_WARRIORS = 8; - private static final long SPAWN_RATE = 1000; + private static final long SPAWN_RATE = 5000; private List _queuedArchers = Lists.newArrayList(); private List _queuedWarriors = Lists.newArrayList(); private long _lastASpawned; From 9c42f4c1470abf3e2a6dd8237c64b2b24ed26764 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Thu, 28 Jul 2016 13:27:48 -0500 Subject: [PATCH 79/90] Use the proper boostergroup for amplifier thanks --- .../src/nautilus/game/arcade/booster/GameBoosterManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/booster/GameBoosterManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/booster/GameBoosterManager.java index 01f2172df..ae823e9fa 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/booster/GameBoosterManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/booster/GameBoosterManager.java @@ -88,7 +88,7 @@ public class GameBoosterManager extends MiniPlugin } JsonMessage message = new JsonMessage(F.main("Amplifier", F.elem("Click here") + " to thank them and receive " + F.currency(GlobalCurrency.TREASURE_SHARD, BoosterTipManager.TIP_FOR_TIPPER) + "!")); - message.click(ClickEvent.RUN_COMMAND, "/amplifier thank " + _boosterGroup); + message.click(ClickEvent.RUN_COMMAND, "/amplifier thank " + event.getBoosterGroup()); message.hover(HoverEvent.SHOW_TEXT, C.cGreen + "Click to Thank"); message.send(JsonMessage.MessageType.CHAT_BOX, UtilServer.getPlayers()); } From a498bc13dbc0261074fc0a72c69d9cc367db0369 Mon Sep 17 00:00:00 2001 From: cnr Date: Thu, 28 Jul 2016 14:59:12 -0500 Subject: [PATCH 80/90] Reinstate async wrappers for clans gold access --- .../game/clans/economy/GoldRepository.java | 73 +++++++++++-------- 1 file changed, 41 insertions(+), 32 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldRepository.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldRepository.java index ad08ef462..10fdd5270 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldRepository.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldRepository.java @@ -1,7 +1,9 @@ package mineplex.game.clans.economy; import mineplex.core.common.util.Callback; +import mineplex.core.common.util.UtilServer; import mineplex.serverdata.database.DBPool; +import org.bukkit.Bukkit; import java.sql.Connection; import java.sql.PreparedStatement; @@ -20,28 +22,32 @@ public class GoldRepository { public void rewardGold(final Callback callback, final int accountId, final int gold) { - try (Connection connection = DBPool.getAccount().getConnection()) + Bukkit.getScheduler().runTaskAsynchronously(UtilServer.getPlugin(), () -> { - PreparedStatement statement = connection.prepareStatement(UPDATE_ACCOUNT_GOLD); - statement.setInt(1, _serverId); - statement.setInt(2, accountId); - statement.setInt(3, gold); - statement.setInt(4, gold); - statement.executeUpdate(); - - if (callback != null) + try (Connection connection = DBPool.getAccount().getConnection()) { - callback.run(true); - } + PreparedStatement statement = connection.prepareStatement(UPDATE_ACCOUNT_GOLD); + statement.setInt(1, _serverId); + statement.setInt(2, accountId); + statement.setInt(3, gold); + statement.setInt(4, gold); + statement.executeUpdate(); - } catch (SQLException e) { - e.printStackTrace(); + if (callback != null) + { + callback.run(true); + } - if (callback != null) + } catch (SQLException e) { - callback.run(false); + e.printStackTrace(); + + if (callback != null) + { + callback.run(false); + } } - } + }); } public void setGold(final Callback callback, final int accountId, final int gold) @@ -51,26 +57,29 @@ public class GoldRepository { throw new IllegalArgumentException("gold cannot be negative"); } - try (Connection connection = DBPool.getAccount().getConnection()) + Bukkit.getScheduler().runTaskAsynchronously(UtilServer.getPlugin(), () -> { - PreparedStatement statement = connection.prepareStatement(SET_ACCOUNT_GOLD); - statement.setInt(1, _serverId); - statement.setInt(2, accountId); - statement.setInt(3, gold); - statement.setInt(4, gold); - statement.executeUpdate(); - if (callback != null) + try (Connection connection = DBPool.getAccount().getConnection()) { - callback.run(true); - } + PreparedStatement statement = connection.prepareStatement(SET_ACCOUNT_GOLD); + statement.setInt(1, _serverId); + statement.setInt(2, accountId); + statement.setInt(3, gold); + statement.setInt(4, gold); + statement.executeUpdate(); + if (callback != null) { + callback.run(true); + } - } catch (SQLException e) { - e.printStackTrace(); - - if (callback != null) + } catch (SQLException e) { - callback.run(false); + e.printStackTrace(); + + if (callback != null) + { + callback.run(false); + } } - } + }); } } From f3944527f8a85619e97a1ca7996b5608f093ef73 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 28 Jul 2016 19:08:24 -0400 Subject: [PATCH 81/90] Display clans purchases properly in support server --- .../customerSupport/CustomerSupport.java | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java index 157226516..afbaea2d9 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java @@ -129,6 +129,8 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable int valentinesGiftsReceived = 0; int boostersReceived = 0; int freedomChestsReceived = 0; + int runeAmplifier20 = 0; + int runeAmplifier60 = 0; for (CoinTransactionToken transaction : donor.getCoinTransactions()) { @@ -227,7 +229,26 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable else if (transaction.SalesPackageName.split(" ").length == 2) boostersReceived += 1; } - + } + if (transaction.SalesPackageName.startsWith("Rune Amplifier 20")) + { + if (transaction.Coins == 0 && transaction.Gems == 0) + { + if (transaction.SalesPackageName.split(" ").length == 4) + runeAmplifier20 += Integer.parseInt(transaction.SalesPackageName.split(" ")[3]); + else if (transaction.SalesPackageName.split(" ").length == 3) + runeAmplifier20 += 1; + } + } + if (transaction.SalesPackageName.startsWith("Rune Amplifier 60")) + { + if (transaction.Coins == 0 && transaction.Gems == 0) + { + if (transaction.SalesPackageName.split(" ").length == 4) + runeAmplifier60 += Integer.parseInt(transaction.SalesPackageName.split(" ")[3]); + else if (transaction.SalesPackageName.split(" ").length == 3) + runeAmplifier60 += 1; + } } } @@ -238,6 +259,8 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable caller.sendMessage(C.cBlue + "Mythical Chests Received: " + C.cYellow + mythicalChestsReceived); caller.sendMessage(C.cBlue + "Illuminated Chests Received: " + C.cYellow + illuminatedChestsReceived); 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); caller.sendMessage(C.cBlue + "Freedom Chests Received: " + C.cYellow + freedomChestsReceived); caller.sendMessage(C.cBlue + "Monthly Bonus Log (Last 6 entries):"); @@ -260,6 +283,9 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable caller.sendMessage(C.cBlue + "Price of Freedom: " + getLockedFreedomStr(playerName, "Price of Freedom")); caller.sendMessage(C.cBlue + "Uncle Sam Hat: " + getLockedFreedomStr(playerName, "Uncle Sam Hat")); caller.sendMessage(C.cDGreen + C.Strike + "============================================="); + caller.sendMessage(C.cBlue + "Clan Banner Usage: " + getLockedFreedomStr(playerName, "Clan Banner Usage")); + caller.sendMessage(C.cBlue + "Uncle Sam Morph: " + getLockedFreedomStr(playerName, "Clan Banner Editor")); + caller.sendMessage(C.cDGreen + C.Strike + "============================================="); _accountBonusLog.remove(client.getAccountId()); } From 47d79bbad5f9527252825748be84e440d7db703f Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 28 Jul 2016 19:08:47 -0400 Subject: [PATCH 82/90] Fix bugs arising during clans release --- .../core/scoreboard/PlayerScoreboard.java | 55 ++++++++++--------- .../clans/clans/nether/BossNetherPortal.java | 32 +++++++++++ .../clans/clans/nether/NetherManager.java | 2 +- .../game/clans/clans/nether/NetherPortal.java | 32 +++++++++++ .../game/core/boss/EventCreature.java | 2 +- .../skeletonking/minion/WraithCreature.java | 2 +- 6 files changed, 96 insertions(+), 29 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/PlayerScoreboard.java b/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/PlayerScoreboard.java index 6a63bf257..272f24733 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/PlayerScoreboard.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/PlayerScoreboard.java @@ -96,36 +96,39 @@ public class PlayerScoreboard for (int i=0 ; i i) + if ((15-i) >= 0) { - String oldLine = _currentLines.get(i); + //Get New Line + String newLine = lines.get(i); - if (oldLine.equals(newLine)) + //Check if Unchanged + if (_currentLines.size() > i) + { + String oldLine = _currentLines.get(i); + + if (oldLine.equals(newLine)) + continue; + } + + // Ignore extra lines + if (i >= _teamNames.length) continue; + + //Update + Team team = _scoreboard.getTeam(_teamNames[i]); + if (team == null) + { + System.out.println("Scoreboard Error: Line Team Not Found!"); + return; + } + + //Set Line Prefix/Suffix + team.setPrefix(newLine.substring(0, Math.min(newLine.length(), 16))); + team.setSuffix(ChatColor.getLastColors(team.getPrefix()) + newLine.substring(team.getPrefix().length(), Math.min(newLine.length(), 32))); + + //Line + _sideObjective.getScore(_teamNames[i]).setScore(15-i); } - - // Ignore extra lines - if (i >= _teamNames.length) - continue; - - //Update - Team team = _scoreboard.getTeam(_teamNames[i]); - if (team == null) - { - System.out.println("Scoreboard Error: Line Team Not Found!"); - return; - } - - //Set Line Prefix/Suffix - team.setPrefix(newLine.substring(0, Math.min(newLine.length(), 16))); - team.setSuffix(ChatColor.getLastColors(team.getPrefix()) + newLine.substring(team.getPrefix().length(), Math.min(newLine.length(), 32))); - - //Line - _sideObjective.getScore(_teamNames[i]).setScore(15-i); } //Hide Old Unused diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/BossNetherPortal.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/BossNetherPortal.java index d09407609..63f6045c5 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/BossNetherPortal.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/BossNetherPortal.java @@ -1,9 +1,13 @@ package mineplex.game.clans.clans.nether; +import java.util.LinkedList; import java.util.List; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilWorld; +import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClanTips.TipType; @@ -40,6 +44,7 @@ public class BossNetherPortal implements Listener private Location[] _corners; private boolean _returnPortal; private byte _portalFacing; + private LinkedList _closeWarnings = new LinkedList<>(); public boolean Open = false; public long Expire = -1; @@ -97,6 +102,16 @@ public class BossNetherPortal implements Listener { _portalFacing = (byte)0; } + + _closeWarnings.add(UtilTime.convert(5, TimeUnit.MINUTES, TimeUnit.MILLISECONDS)); + _closeWarnings.add(UtilTime.convert(1, TimeUnit.MINUTES, TimeUnit.MILLISECONDS)); + _closeWarnings.add(30000L); + _closeWarnings.add(10000L); + _closeWarnings.add(5000L); + _closeWarnings.add(4000L); + _closeWarnings.add(3000L); + _closeWarnings.add(2000L); + _closeWarnings.add(1000L); } private boolean isInPortal(Block block) @@ -261,6 +276,23 @@ public class BossNetherPortal implements Listener { return; } + if (Open && Expire != -1) + { + Long warning = -1L; + for (Long test : _closeWarnings) + { + if ((Expire - System.currentTimeMillis()) < warning) + { + warning = test; + break; + } + } + if (warning != -1) + { + _closeWarnings.remove(warning); + Bukkit.broadcastMessage(F.main(ClansManager.getInstance().getNetherManager().getName(), "The " + F.clansNether("Nether Portal") + " at " + F.elem(UtilWorld.locToStrClean(getLocation())) + " will close in " + F.elem(UtilTime.MakeStr(warning)) + "!")); + } + } if (Open && Expire != -1 && System.currentTimeMillis() >= Expire) { close(); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java index b872f9984..0c5c39fa7 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java @@ -260,7 +260,7 @@ public class NetherManager extends MiniPlugin { return; } - BossNetherPortal portal = new BossNetherPortal(bossSpawn.clone().add(-2, 5, 0), bossSpawn.clone().add(0, 0, 2), false); + BossNetherPortal portal = new BossNetherPortal(bossSpawn.clone().add(-2, 5, 0), bossSpawn.clone().add(2, 0, 0), false); portal.open(PORTAL_OPEN_DURATION); for (NetherPortal returnPortal : _returnPortals) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java index e1ba574c0..ff220fc7a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java @@ -1,9 +1,13 @@ package mineplex.game.clans.clans.nether; +import java.util.LinkedList; import java.util.List; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilWorld; +import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClanTips.TipType; @@ -41,6 +45,7 @@ public class NetherPortal implements Listener private Location[] _corners; private boolean _returnPortal; private byte _portalFacing; + private LinkedList _closeWarnings = new LinkedList<>(); public boolean Open = false; public long Expire = -1; @@ -99,6 +104,16 @@ public class NetherPortal implements Listener { _portalFacing = (byte)0; } + + _closeWarnings.add(UtilTime.convert(5, TimeUnit.MINUTES, TimeUnit.MILLISECONDS)); + _closeWarnings.add(UtilTime.convert(1, TimeUnit.MINUTES, TimeUnit.MILLISECONDS)); + _closeWarnings.add(30000L); + _closeWarnings.add(10000L); + _closeWarnings.add(5000L); + _closeWarnings.add(4000L); + _closeWarnings.add(3000L); + _closeWarnings.add(2000L); + _closeWarnings.add(1000L); } private boolean isInPortal(Block block) @@ -272,6 +287,23 @@ public class NetherPortal implements Listener { return; } + if (Open && Expire != -1) + { + Long warning = -1L; + for (Long test : _closeWarnings) + { + if ((Expire - System.currentTimeMillis()) < warning) + { + warning = test; + break; + } + } + if (warning != -1) + { + _closeWarnings.remove(warning); + Bukkit.broadcastMessage(F.main(ClansManager.getInstance().getNetherManager().getName(), "The " + F.clansNether("Nether Portal") + " at " + F.elem(UtilWorld.locToStrClean(getLocation())) + " will close in " + F.elem(UtilTime.MakeStr(warning)) + "!")); + } + } if (Open && Expire != -1 && System.currentTimeMillis() >= Expire) { close(); diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventCreature.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventCreature.java index 5093b0370..6746f9187 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventCreature.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventCreature.java @@ -282,7 +282,7 @@ public abstract class EventCreature implements Listener spawnEntity(); } - if (UtilMath.offset2d(_entity.getLocation(), _spawnLocation) > 34) + if (UtilMath.offset2d(_entity.getLocation(), _spawnLocation) > 30) { if (_teleportHome != -1 && System.currentTimeMillis() >= _teleportHome) { diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/minion/WraithCreature.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/minion/WraithCreature.java index c8bc96291..6a71d40f6 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/minion/WraithCreature.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/skeletonking/minion/WraithCreature.java @@ -135,7 +135,7 @@ public class WraithCreature extends EventCreature return; Location teleport = zombie.getTarget().getLocation().add(Math.random() + 1, 0, Math.random() + 1); - if (UtilMath.offset(getSpawnLocation(), teleport) > 34) + if (UtilMath.offset(getSpawnLocation(), teleport) > 30) { return; } From 3aad06cc8a6c342dc941cb4430db12195491dbac Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 28 Jul 2016 19:11:14 -0400 Subject: [PATCH 83/90] Make Clans displayed as FULL instead of BETA in server compass --- .../Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java index a176467a8..711602e2d 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java @@ -190,7 +190,7 @@ public class ServerGameMenu extends ShopPageBase add(40, Material.IRON_DOOR, C.cYellowB + "Mineplex Clans " + C.cGray + "Factions PvP", new String[] { - (_extraValue ? C.cAquaB : C.cWhiteB) + "BETA RELEASE", + (_extraValue ? C.cAquaB : C.cWhiteB) + "FULL RELEASE", C.Reset + "", C.Reset + "Equip custom skills and builds", C.Reset + "and join your clan to destroy", From 97d5d21a55e65de5e3e1499e2d925780116de80f Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 28 Jul 2016 19:43:43 -0400 Subject: [PATCH 84/90] Fix lightning orb duping --- .../classcombat/Skill/Mage/LightningOrb.java | 41 +++++++++++-------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/LightningOrb.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/LightningOrb.java index 027fee62a..79cbdc825 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/LightningOrb.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/LightningOrb.java @@ -1,31 +1,36 @@ package mineplex.minecraft.game.classcombat.Skill.Mage; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; -import org.bukkit.*; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.projectile.IThrown; +import mineplex.core.projectile.ProjectileUser; +import mineplex.core.updater.UpdateType; +import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; +import mineplex.minecraft.game.classcombat.Skill.SkillActive; +import mineplex.minecraft.game.classcombat.Skill.SkillFactory; + +import org.bukkit.Bukkit; +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.*; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockIgniteEvent; import org.bukkit.event.block.BlockIgniteEvent.IgniteCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; - -import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; -import mineplex.core.common.util.F; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.projectile.IThrown; -import mineplex.core.projectile.ProjectileUser; -import mineplex.core.updater.UpdateType; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.minecraft.game.classcombat.Skill.SkillActive; -import mineplex.minecraft.game.classcombat.Skill.SkillFactory; - -import org.bukkit.event.player.*; +import org.bukkit.event.player.PlayerEvent; public class LightningOrb extends SkillActive implements IThrown { @@ -99,7 +104,7 @@ public class LightningOrb extends SkillActive implements IThrown public void Skill(Player player, int level) { //Action - Item item = player.getWorld().dropItem(player.getEyeLocation().add(player.getLocation().getDirection()), ItemStackFactory.Instance.CreateStack(57)); + Item item = player.getWorld().dropItem(player.getEyeLocation().add(player.getLocation().getDirection()),new ItemBuilder(Material.DIAMOND_BLOCK).setTitle(UtilMath.random.nextDouble() + "").build()); item.setVelocity(player.getLocation().getDirection()); Factory.Projectile().AddThrow(item, player, this, 5000 - (400 * level), true, true, false, false, Sound.FIZZ, 0.6f, 1.6f, ParticleType.FIREWORKS_SPARK, UpdateType.TICK, 0.4f); From 16804a860ca92a2fc2f0394cd6456f072b93d4ab Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 28 Jul 2016 20:22:30 -0400 Subject: [PATCH 85/90] Made duping usage for class shop impossible --- .../mineplex/game/clans/clans/ClansGame.java | 41 +++++++++++++++++++ .../game/clans/clans/siege/weapon/Cannon.java | 20 ++++++++- 2 files changed, 60 insertions(+), 1 deletion(-) 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 f59db05d6..8156714a2 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 @@ -4,6 +4,7 @@ import java.sql.Timestamp; import mineplex.core.MiniPlugin; import mineplex.core.blockrestore.BlockRestoreData; +import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilBlock; @@ -23,6 +24,7 @@ import mineplex.game.clans.core.repository.ClanTerritory; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import org.bukkit.Bukkit; +import org.bukkit.ChatColor; import org.bukkit.Effect; import org.bukkit.GameMode; import org.bukkit.Location; @@ -62,6 +64,25 @@ public class ClansGame extends MiniPlugin _clans = clans; } + public static boolean isDupedFromClassShop(ItemStack item) + { + if (item == null || item.getType() == Material.AIR) + { + return false; + } + if (!item.hasItemMeta() || !item.getItemMeta().hasDisplayName()) + { + return false; + } + String name = ChatColor.stripColor(item.getItemMeta().getDisplayName()).toUpperCase(); + if (name.contains("APPLY DEFAULT BUILD") || name.contains("APPLY BUILD") || name.contains("EDIT BUILD") || name.contains("DELETE BUILD")) + { + return true; + } + + return false; + } + @EventHandler(ignoreCancelled = true) public void openClanShop(PlayerInteractEvent event) { @@ -102,6 +123,26 @@ public class ClansGame extends MiniPlugin if (event.getBlock().getType() != Material.LADDER) return; + if (isDupedFromClassShop(event.getItemInHand())) + { + event.setCancelled(true); + for (Player p : Bukkit.getOnlinePlayers()) + { + if (ClansManager.getInstance().getClientManager().hasRank(p, Rank.HELPER)) + { + UtilPlayer.message(p, F.elem("[" + C.cRedB + "!" + C.cGray + "] ") + event.getPlayer().getName() + " just tried to use a duped item/block!"); + } + } + final int slot = event.getPlayer().getInventory().getHeldItemSlot(); + ClansManager.getInstance().runSyncLater(() -> + { + event.getPlayer().getInventory().setItem(slot, new ItemStack(Material.AIR)); + event.getPlayer().updateInventory(); + }, 1L); + + return; + } + if (_clans.getClanUtility().getAccess(event.getPlayer(), event.getBlock().getLocation()) == ClanRelation.SELF) return; final Block block = event.getBlock(); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/Cannon.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/Cannon.java index 0dc3b7a9a..fce9ea9d2 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/Cannon.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/Cannon.java @@ -4,6 +4,7 @@ import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; @@ -22,6 +23,7 @@ import org.bukkit.util.Vector; import com.google.common.collect.Lists; +import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; @@ -36,6 +38,8 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.itemstack.ItemBuilder; import mineplex.game.clans.clans.ClanInfo; +import mineplex.game.clans.clans.ClansGame; +import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.siege.SiegeManager; import mineplex.game.clans.clans.siege.events.SiegeWeaponExplodeEvent; import mineplex.game.clans.clans.siege.repository.tokens.SiegeWeaponToken; @@ -216,6 +220,7 @@ public class Cannon extends SiegeWeapon })); } + @SuppressWarnings("deprecation") @EventHandler protected void InventoryClick(InventoryClickEvent event) { @@ -224,7 +229,7 @@ public class Cannon extends SiegeWeapon return; } - if (event.getClick() == ClickType.SHIFT_RIGHT || event.getClick() == ClickType.SHIFT_RIGHT) + if (event.getClick() == ClickType.SHIFT_RIGHT || event.getClick() == ClickType.SHIFT_LEFT) { if(_inventory.getViewers().contains(event.getWhoClicked())) { @@ -282,6 +287,19 @@ public class Cannon extends SiegeWeapon { event.setCancelled(true); } + else if (event.getSlot() == _ammunitionSlot && ClansGame.isDupedFromClassShop(event.getCursor())) + { + event.setCancelled(true); + for (Player p : Bukkit.getOnlinePlayers()) + { + if (ClansManager.getInstance().getClientManager().hasRank(p, Rank.HELPER)) + { + UtilPlayer.message(p, F.elem("[" + C.cRedB + "!" + C.cGray + "] ") + event.getWhoClicked().getName() + " just tried to use a duped item/block!"); + } + } + event.setCursor(new ItemStack(Material.AIR)); + ((Player)event.getWhoClicked()).updateInventory(); + } } private void updateInventory() From 841a44b8a63d3c5f95f8cf3f64ba72c4bbb3b377 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 28 Jul 2016 21:02:04 -0400 Subject: [PATCH 86/90] Make clan create button functional --- .../clans/gui/button/ClanCreateButton.java | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/button/ClanCreateButton.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/button/ClanCreateButton.java index 39815a0f8..3b917b2e1 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/button/ClanCreateButton.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/button/ClanCreateButton.java @@ -1,15 +1,15 @@ package mineplex.game.clans.clans.gui.button; import mineplex.core.common.util.UtilServer; +import mineplex.core.shop.item.IButton; import mineplex.game.clans.clans.gui.events.ClansButtonClickEvent; +import net.md_5.bungee.api.ChatColor; +import net.md_5.bungee.api.chat.ClickEvent; +import net.md_5.bungee.api.chat.TextComponent; + import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; -import mineplex.core.common.jsonchat.ClickEvent; -import mineplex.core.common.jsonchat.JsonMessage; -import mineplex.core.common.util.C; -import mineplex.core.shop.item.IButton; - public class ClanCreateButton implements IButton { public ClanCreateButton() @@ -20,6 +20,14 @@ public class ClanCreateButton implements IButton @Override public void onClick(Player player, ClickType clickType) { - UtilServer.CallEvent(new ClansButtonClickEvent(player, ClansButtonClickEvent.ButtonType.Create)); + if (!UtilServer.CallEvent(new ClansButtonClickEvent(player, ClansButtonClickEvent.ButtonType.Create)).isCancelled()) + { + return; + } + + TextComponent message = new TextComponent("Click Here to create a Clan!"); + message.setColor(ChatColor.AQUA); + message.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/c create ")); + player.spigot().sendMessage(message); } } From dddfb4420cac4a82cb40b5948ff78fdcaffff2a9 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 28 Jul 2016 21:05:25 -0400 Subject: [PATCH 87/90] Fix players being allowed to recall through worlds --- .../minecraft/game/classcombat/Skill/Assassin/Recall.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Recall.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Recall.java index 16b032c06..98e8cddaa 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Recall.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Recall.java @@ -92,6 +92,9 @@ public class Recall extends Skill LinkedList health = _healthMap.remove(player); if (health == null) return; + + if (!player.getWorld().equals(locs.getLast().getWorld())) + return; Factory.runSync(() -> { if (player.isDead()) From f53503f16a900b3a74358c30b535e7237479dd61 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 28 Jul 2016 21:07:29 -0400 Subject: [PATCH 88/90] Move code in sync runnable --- .../minecraft/game/classcombat/Skill/Assassin/Recall.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Recall.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Recall.java index 98e8cddaa..f293f5c7f 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Recall.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Recall.java @@ -92,15 +92,16 @@ public class Recall extends Skill LinkedList health = _healthMap.remove(player); if (health == null) return; - - if (!player.getWorld().equals(locs.getLast().getWorld())) - return; Factory.runSync(() -> { if (player.isDead()) { return; } + if (!player.getWorld().equals(locs.getLast().getWorld())) + { + return; + } //Heal double newHealth = Math.min(health.getLast(), player.getHealth() + 3 + level); player.setHealth(newHealth); From 62e0a39ee8a28a29463a48365287eb7001315d7f Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 28 Jul 2016 23:28:47 -0400 Subject: [PATCH 89/90] Fix some medium graphics issues --- .../src/mineplex/game/clans/clans/ClanTips.java | 4 ++-- .../src/mineplex/game/clans/tutorial/TutorialManager.java | 3 ++- .../clans/tutorial/tutorials/clans/ClansMainTutorial.java | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanTips.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanTips.java index 117d5d648..b50aa8601 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanTips.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanTips.java @@ -191,14 +191,14 @@ public class ClanTips extends MiniPlugin new String[] { C.cDAquaB + "Lost War Point", C.cAqua + "You were killed by another Clan and they have gained 1 War Point against you.", - C.cAqua + "If your War Points with them reaches -20, they will get to invade your Territory, giving them full access for 15 minutes." + C.cAqua + "If your War Points with them reaches -25, they will get to besiege your Territory, giving them access to cannon it for 30 minutes." }), DOMINANCE_NOOICE( new String[] { C.cDAquaB + "Gained War Point", C.cAqua + "You killed someone in another Clan and you have gained 1 War Point against them.", - C.cAqua + "If your War Points with them reaches +20, you will get to invade their Territory, giving you full access for 15 minutes." + C.cAqua + "If your War Points with them reaches +25, you will get to besiege their Territory, giving you access to cannon it for 30 minutes." }), ENERGY( diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/TutorialManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/TutorialManager.java index 4f9da06f8..826fbccc1 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/TutorialManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/TutorialManager.java @@ -23,6 +23,7 @@ import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.message.ClansMessageManager; import mineplex.game.clans.tutorial.command.TutorialCommand; import mineplex.game.clans.tutorial.gui.TutorialShop; +import mineplex.game.clans.tutorial.tutorials.clans.ClansMainTutorial; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -48,7 +49,7 @@ public class TutorialManager extends MiniPlugin implements ScoreboardElement _tutorialMap = new EnumMap(TutorialType.class); _shopMap = new EnumMap(TutorialType.class); - //addTutorial(TutorialType.MAIN, new ClansMainTutorial(plugin, clansManager, _clansMessageManager, hologram, npcManager, taskManager)); + addTutorial(TutorialType.MAIN, new ClansMainTutorial(plugin, clansManager, _clansMessageManager, hologram, npcManager, taskManager)); chat.AddFilter(event -> { if (inTutorial(event.getPlayer())) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/ClansMainTutorial.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/ClansMainTutorial.java index f9d21b850..804966bb3 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/ClansMainTutorial.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/ClansMainTutorial.java @@ -469,7 +469,7 @@ public class ClansMainTutorial extends Tutorial // } // }); - if (!_taskManager.hasCompletedTask(event.getPlayer(), getTaskIdentifier())) + /*if (!_taskManager.hasCompletedTask(event.getPlayer(), getTaskIdentifier())) { ClanInfo clan = ClansManager.getInstance().getClan(event.getPlayer()); if (clan == null) @@ -481,7 +481,7 @@ public class ClansMainTutorial extends Tutorial UtilPlayer.message(event.getPlayer(), F.main("Clans", "It seems you already have a clan here, so we can skip the tutorial")); } } - else if (!event.getPlayer().hasPlayedBefore() || !event.getPlayer().getLocation().getWorld().equals(Spawn.getSpawnWorld())) + else */if (!event.getPlayer().hasPlayedBefore() || !event.getPlayer().getLocation().getWorld().equals(Spawn.getSpawnWorld())) { Spawn.getInstance().teleport(event.getPlayer(), Spawn.getInstance().getSpawnLocation(), 2); } From 952978915976d24371f6fdea7b7e57e64796b204 Mon Sep 17 00:00:00 2001 From: TadahTech Date: Sun, 24 Jul 2016 22:20:55 -0500 Subject: [PATCH 90/90] Remove 3 second chat delay. --- .../src/mineplex/core/chat/Chat.java | 83 ++++++++----------- 1 file changed, 33 insertions(+), 50 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java index effa0f484..c27c6a00a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java @@ -1,40 +1,5 @@ package mineplex.core.chat; -import java.io.BufferedReader; -import java.io.DataOutputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.net.URL; -import java.nio.charset.Charset; -import java.security.cert.X509Certificate; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.UUID; -import java.util.function.Function; - -import javax.net.ssl.HostnameVerifier; -import javax.net.ssl.HttpsURLConnection; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLSession; -import javax.net.ssl.TrustManager; -import javax.net.ssl.X509TrustManager; - -import org.apache.commons.lang3.Validate; -import org.bukkit.block.Sign; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.block.SignChangeEvent; -import org.bukkit.event.player.AsyncPlayerChatEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.plugin.java.JavaPlugin; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; -import org.json.simple.JSONValue; - import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; @@ -53,6 +18,39 @@ import mineplex.core.preferences.PreferencesManager; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import org.apache.commons.lang3.Validate; +import org.bukkit.block.Sign; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.SignChangeEvent; +import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.plugin.java.JavaPlugin; +import org.json.simple.JSONArray; +import org.json.simple.JSONObject; +import org.json.simple.JSONValue; + +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSession; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; +import java.io.BufferedReader; +import java.io.DataOutputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.URL; +import java.nio.charset.Charset; +import java.security.cert.X509Certificate; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.UUID; +import java.util.function.Function; public class Chat extends MiniPlugin { @@ -69,7 +67,6 @@ public class Chat extends MiniPlugin private int _chatSlow = 0; private long _silenced = 0; - private boolean _threeSecondDelay = true; private List> _highPriorityFilters = new ArrayList<>(); private List> _lowPriorityFilters = new ArrayList<>(); @@ -349,15 +346,6 @@ public class Chat extends MiniPlugin event.setCancelled(true); return; } - else if (_threeSecondDelay && - _clientManager.Get(sender).GetRank() == Rank.ALL && - _achievements.getMineplexLevelNumber(sender, Rank.ALL) < 25 && - !Recharge.Instance.use(sender, "All Chat Message", 3000, false, false)) - { - UtilPlayer.message(sender, C.cYellow + "You can only chat once every 3 seconds to prevent spam."); - UtilPlayer.message(sender, C.cYellow + "Buy a Rank at " + C.cGreen + "www.mineplex.com/shop" + C.cYellow + " to remove this limit!"); - event.setCancelled(true); - } else if (!_clientManager.Get(sender).GetRank().has(Rank.MODERATOR) && !Recharge.Instance.use(sender, "Chat Message", 400, false, false)) { @@ -645,11 +633,6 @@ public class Chat extends MiniPlugin _playerLastMessage.remove(event.getPlayer().getUniqueId()); } - public void setThreeSecondDelay(boolean b) - { - _threeSecondDelay = b; - } - /** * If the function returns Boolean.TRUE then the message will be CANCELLED. */