From 195c990e29785ca3cb6bbbab1e1e777894bab481 Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 25 Mar 2016 04:01:57 +0000 Subject: [PATCH] further tutorial progress --- .../core/common/util/EnclosedObject.java | 81 ------------------- .../game/clans/clans/ClanEnergyTracker.java | 2 +- .../game/clans/clans/map/ItemMapManager.java | 6 +- .../clans/clans/siege/outpost/Outpost.java | 2 +- .../game/clans/clans/siege/weapon/Cannon.java | 2 +- .../clans/clans/siege/weapon/SiegeWeapon.java | 8 ++ .../tutorials/clans/ClansMainTutorial.java | 4 +- .../clans/objective/ClanObjective.java | 6 +- .../BlowUpWallGoal.java} | 20 +---- .../StealEnemyPotatoesGoal.java | 2 +- 10 files changed, 23 insertions(+), 110 deletions(-) rename Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/{clan/AttackEnemyGoal.java => attackenemy/BlowUpWallGoal.java} (82%) rename Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/{clan => attackenemy}/StealEnemyPotatoesGoal.java (99%) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/EnclosedObject.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/EnclosedObject.java index 37038f8ca..50f548a46 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/EnclosedObject.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/EnclosedObject.java @@ -28,85 +28,4 @@ public class EnclosedObject { return _value.toString(); } - - // Arithmetic operations, will only work if T is an instance of Number - public long Add(Number number) - { - if (!(_value instanceof Number)) - { - throw new RuntimeException("Type of T must be an instance of Number to perform arithmetic."); - } - - return ((Number) _value).longValue() + number.longValue(); - } - - public long Subtract(Number number) - { - if (!(_value instanceof Number)) - { - throw new RuntimeException("Type of T must be an instance of Number to perform arithmetic."); - } - - return ((Number) _value).longValue() - number.longValue(); - } - - public long Multiply(Number number) - { - if (!(_value instanceof Number)) - { - throw new RuntimeException("Type of T must be an instance of Number to perform arithmetic."); - } - - return ((Number) _value).longValue() * number.longValue(); - } - - public long Divide(Number number) - { - if (!(_value instanceof Number)) - { - throw new RuntimeException("Type of T must be an instance of Number to perform arithmetic."); - } - - return ((Number) _value).longValue() / number.longValue(); - } - - public double PreciseAdd(Number number) - { - if (!(_value instanceof Number)) - { - throw new RuntimeException("Type of T must be an instance of Number to perform arithmetic."); - } - - return ((Number) _value).doubleValue() + number.doubleValue(); - } - - public double PreciseSubtract(Number number) - { - if (!(_value instanceof Number)) - { - throw new RuntimeException("Type of T must be an instance of Number to perform arithmetic."); - } - - return ((Number) _value).doubleValue() - number.doubleValue(); - } - - public double PreciseMultiply(Number number) - { - if (!(_value instanceof Number)) - { - throw new RuntimeException("Type of T must be an instance of Number to perform arithmetic."); - } - - return ((Number) _value).doubleValue() * number.doubleValue(); - } - - public double PreciseDivide(Number number) - { - if (!(_value instanceof Number)) - { - throw new RuntimeException("Type of T must be an instance of Number to perform arithmetic."); - } - - return ((Number) _value).doubleValue() / number.doubleValue(); - } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanEnergyTracker.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanEnergyTracker.java index 307768c84..e7a2a998a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanEnergyTracker.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanEnergyTracker.java @@ -61,7 +61,7 @@ public class ClanEnergyTracker extends MiniPlugin Triple energyBounds = _updateMap.get(type); - if (energyBounds != null && energyRemaining > energyBounds.getLeft() && energyRemaining < energyBounds.getMiddle()) + if (energyBounds != null && energyRemaining > energyBounds.getLeft().longValue() && energyRemaining < energyBounds.getMiddle().longValue()) { _clans.middleTextClan(clan, energyBounds.getRight()[0], energyBounds.getRight()[1], 20, 200, 80); _clans.sendTipToClan(clan, TipType.ENERGY); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/map/ItemMapManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/map/ItemMapManager.java index ad18709cb..2e462300a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/map/ItemMapManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/map/ItemMapManager.java @@ -10,8 +10,6 @@ import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.Iterator; -import java.util.List; -import java.util.Map; import java.util.Map.Entry; import org.apache.commons.io.FileUtils; @@ -55,11 +53,11 @@ import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.portal.ServerTransferEvent; -import mineplex.core.timing.TimingManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansUtility; +import mineplex.game.clans.clans.map.events.PlayerGetMapEvent; import mineplex.game.clans.clans.worldevent.WorldEventManager; import net.minecraft.server.v1_8_R3.Block; import net.minecraft.server.v1_8_R3.BlockPosition; @@ -866,6 +864,8 @@ public class ItemMapManager extends MiniPlugin public void setMap(Player player) { + UtilServer.CallEvent(new PlayerGetMapEvent(player)); + for (ItemStack item : UtilInv.getItems(player)) { if (item.getType() == Material.MAP && (item.getDurability() >= _mapId && item.getDurability() <= _mapId + 100)) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java index 8b6bddc05..5a010009e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java @@ -523,7 +523,7 @@ public class Outpost implements Listener _outpostManager.runSyncLater(() -> { UtilParticle.PlayParticleToAll(ParticleType.HUGE_EXPLOSION, block.getLocation(), new Vector(0,0,0), 1f, 1, ViewDist.MAX); _origin.getWorld().playSound(block.getLocation(), Sound.EXPLODE, 1.0f, 1.0f); - }, wait.Add(Integer.valueOf(4 + UtilMath.random.nextInt(4)))) + }, wait.Set(Integer.valueOf(wait.Get().intValue() + 4 + UtilMath.random.nextInt(4))).longValue()) ); _outpostManager.runSyncLater(() -> { 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 0f9de76f6..c739c1bb3 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 @@ -266,7 +266,7 @@ public class Cannon extends SiegeWeapon private void updateInventory() { _inventory.setItem(0, new ItemBuilder(Material.LEVER).setTitle(C.cRed + "-1 Firepower").build()); - _inventory.setItem(1, new ItemBuilder(Material.SULPHUR).setTitle(C.cWhiteB + "Firepower: " + C.cYellow + _firepower).build()); + _inventory.setItem(1, new ItemBuilder(Material.SULPHUR).setTitle(C.cWhiteB + "Firepower: " + C.cYellow + _firepower).setAmount(_firepower).build()); _inventory.setItem(2, new ItemBuilder(Material.LEVER).setTitle(C.cGreen + "+1 Firepower").build()); for (int slot : UtilCollections.newList(Integer.valueOf(3), Integer.valueOf(5), Integer.valueOf(6), Integer.valueOf(7), Integer.valueOf(8))) 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 5fbd2d890..bf75e0325 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 @@ -48,6 +48,8 @@ import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.siege.SiegeManager; +import mineplex.game.clans.clans.siege.events.LoadSiegeWeaponEvent; +import mineplex.game.clans.clans.siege.events.MountSiegeWeaponEvent; import mineplex.game.clans.clans.siege.events.SiegeWeaponExplodeEvent; import mineplex.game.clans.clans.siege.repository.tokens.SiegeWeaponToken; import mineplex.game.clans.clans.siege.weapon.projectile.ProjectileAttributes; @@ -401,6 +403,8 @@ public abstract class SiegeWeapon implements Listener private void handleMount(Player player) { + UtilServer.CallEvent(new MountSiegeWeaponEvent(player, this)); + if (!CustomMount(player)) { getEntity("PLAYERMOUNT").setPassenger(player); @@ -634,6 +638,10 @@ public abstract class SiegeWeapon implements Listener _inventory.setItem(slot, new ItemStack(_ammunitionType, _maxAmmunition)); } + else + { + UtilServer.CallEvent(new LoadSiegeWeaponEvent(getRider(), this)); + } } } else if (_firepowerSlots.contains(Integer.valueOf(slot))) 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 93ce9923e..7faee1ff1 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 @@ -2,8 +2,6 @@ package mineplex.game.clans.tutorial.tutorials.clans; import java.io.IOException; import java.util.List; -import java.util.function.Supplier; -import java.util.stream.Stream; import org.bukkit.DyeColor; import org.bukkit.GameMode; @@ -29,6 +27,7 @@ import mineplex.game.clans.tutorial.Tutorial; import mineplex.game.clans.tutorial.TutorialRegion; import mineplex.game.clans.tutorial.TutorialWorldManager; import mineplex.game.clans.tutorial.map.TutorialMapManager; +import mineplex.game.clans.tutorial.tutorials.clans.objective.AttackEnemyObjective; import mineplex.game.clans.tutorial.tutorials.clans.objective.ClanObjective; import mineplex.game.clans.tutorial.tutorials.clans.objective.ClassesObjective; import mineplex.game.clans.tutorial.tutorials.clans.objective.FieldsObjective; @@ -57,6 +56,7 @@ public class ClansMainTutorial extends Tutorial addObjective(new LeaveSpawnObjective(this, plugin)); addObjective(new ClanObjective(this, plugin)); + addObjective(new AttackEnemyObjective(this, plugin)); addObjective(new ShopsObjective(this, plugin)); addObjective(new ClassesObjective(this, plugin)); addObjective(new FieldsObjective(this, plugin)); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/ClanObjective.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/ClanObjective.java index 65f996834..885fd7397 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/ClanObjective.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/ClanObjective.java @@ -5,13 +5,13 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.game.clans.tutorial.objective.OrderedObjective; import mineplex.game.clans.tutorial.tutorials.clans.ClansMainTutorial; -import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan.AttackEnemyGoal; +import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.attackenemy.BlowUpWallGoal; +import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.attackenemy.StealEnemyPotatoesGoal; import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan.BuildHouseGoal; import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan.ClaimLandGoal; import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan.ClanDetailsGoal; import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan.CreateClanGoal; import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan.SetHomeGoal; -import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan.StealEnemyPotatoesGoal; public class ClanObjective extends OrderedObjective { @@ -24,8 +24,6 @@ public class ClanObjective extends OrderedObjective addGoal(new ClaimLandGoal(this)); addGoal(new BuildHouseGoal(this)); addGoal(new SetHomeGoal(this)); - addGoal(new AttackEnemyGoal(this)); - addGoal(new StealEnemyPotatoesGoal(this)); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/clan/AttackEnemyGoal.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/attackenemy/BlowUpWallGoal.java similarity index 82% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/clan/AttackEnemyGoal.java rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/attackenemy/BlowUpWallGoal.java index be4b82aa9..121432b63 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/clan/AttackEnemyGoal.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/attackenemy/BlowUpWallGoal.java @@ -1,4 +1,4 @@ -package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan; +package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.attackenemy; import java.util.HashMap; import java.util.Map; @@ -14,7 +14,6 @@ import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.fallingblock.FallingBlocks; -import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.siege.SiegeManager; import mineplex.game.clans.clans.siege.events.SiegeWeaponExplodeEvent; import mineplex.game.clans.clans.siege.weapon.Cannon; @@ -22,13 +21,11 @@ import mineplex.game.clans.tutorial.TutorialRegion; import mineplex.game.clans.tutorial.objective.ObjectiveGoal; import mineplex.game.clans.tutorial.tutorials.clans.ClansMainTutorial; import mineplex.game.clans.tutorial.tutorials.clans.ClansMainTutorial.Point; -import mineplex.game.clans.tutorial.tutorials.clans.objective.ClanObjective; +import mineplex.game.clans.tutorial.tutorials.clans.objective.AttackEnemyObjective; -public class AttackEnemyGoal extends ObjectiveGoal +public class BlowUpWallGoal extends ObjectiveGoal { - private Map _cannon = new HashMap<>(); - - public AttackEnemyGoal(ClanObjective objective) + public BlowUpWallGoal(AttackEnemyObjective objective) { super(objective, "Attack Enemy", "Attack enemy clan! Blow a hole in their base with a Cannon."); } @@ -37,15 +34,6 @@ public class AttackEnemyGoal extends ObjectiveGoal protected void customStart(Player player) { UtilInv.give(player, Material.TNT); - - _cannon.put(player.getName(), SiegeManager.Instance.spawnCannon(player, getObjective().getPlugin().getPoint(getObjective().getPlugin().getRegion(player), Point.CANNON), false)); - _cannon.get(player.getName()).SetForcedVelocity(0.4, 2.45); - } - - @Override - protected void clean(Player player, TutorialRegion region) - { - _cannon.remove(player.getName()).kill(); } @EventHandler diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/clan/StealEnemyPotatoesGoal.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/attackenemy/StealEnemyPotatoesGoal.java similarity index 99% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/clan/StealEnemyPotatoesGoal.java rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/attackenemy/StealEnemyPotatoesGoal.java index 381277e46..934abd67e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/clan/StealEnemyPotatoesGoal.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/attackenemy/StealEnemyPotatoesGoal.java @@ -1,4 +1,4 @@ -package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan; +package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.attackenemy; import java.util.HashMap; import java.util.UUID;