npcs = new ArrayList<>();
+
+ // While there are more entries
+ while (resultSet.next())
+ {
+ int id = resultSet.getInt("id");
+ EntityType entityType = EntityType.valueOf(resultSet.getString("entity_type"));
+ String name = resultSet.getString("name");
+ String worldName = resultSet.getString("world");
+ double x = resultSet.getDouble("x");
+ double y = resultSet.getDouble("y");
+ double z = resultSet.getDouble("z");
+ int yaw = resultSet.getInt("yaw");
+ int pitch = resultSet.getInt("pitch");
+ Material inHand = parseMaterial(resultSet.getString("in_hand"));
+ byte inHandData = resultSet.getByte("in_hand_data");
+ Material helmet = parseMaterial(resultSet.getString("helmet"));
+ Material chestplate = parseMaterial(resultSet.getString("chestplate"));
+ Material leggings = parseMaterial(resultSet.getString("leggings"));
+ Material boots = parseMaterial(resultSet.getString("boots"));
+ String metadata = resultSet.getString("metadata");
+ String skinValue = resultSet.getString("skinValue");
+ String skinSignature = resultSet.getString("skinSignature");
+
+ NPC npc;
+ World world = Bukkit.getWorld(worldName);
+
+ // If the world is not loaded on the server then don't add it to the list
+ if (world == null)
+ {
+ continue;
+ }
+
+ // If the entity type is of player then the NPC must be specified as a PlayerNPC
+ if (entityType == EntityType.PLAYER)
+ {
+ npc = new PlayerNPC(id, name, new Location(world, x, y, z, yaw, pitch), inHand, inHandData, helmet, chestplate, leggings, boots, metadata, skinValue, skinSignature);
+ }
+ else
+ {
+ npc = new NPC(id, entityType, name, new Location(world, x, y, z, yaw, pitch), inHand, inHandData, helmet, chestplate, leggings, boots, metadata);
+ }
+
+ npcs.add(npc);
+ }
+
+ response.accept(npcs);
+ });
+ }
+
+ // Simply calls Material.valueOf, if invalid null
+ private Material parseMaterial(String material)
+ {
+ try
+ {
+ return Material.valueOf(material);
+ }
+ catch (IllegalArgumentException e)
+ {
+ return null;
+ }
+ }
+
+ /**
+ * Executes the SQL insert:
+ *
+ * {@value INSERT_NPC}
+ *
+ * If the NPC does not have an id of -1, the insert will not be run.
+ *
+ * @param npc The NPC you want to insert into the database.
+ */
+ void insertNPCIfNotExists(NPC npc)
+ {
+ // If the id isn't -1 then it has already been inserted
+ if (npc.getId() != -1)
+ {
+ return;
+ }
+
+ Column>[] columns = npc.toDatabaseQuery().toArray(new Column[0]);
+ executeInsert(INSERT_NPC, resultSet ->
+ {
+ // If successful
+ if (resultSet.next())
+ {
+ // Set the NPC's id with that generated by the database
+ npc.setId(resultSet.getInt(1));
+ }
+ }, columns);
+ }
+
+ /**
+ * Executes the SQL insert:
+ *
+ * {@value DELETE_NPC}
+ *
+ *
+ * @param npc The NPC you want to delete.
+ */
+ void deleteNPC(NPC npc)
+ {
+ executeUpdate(DELETE_NPC, new ColumnInt("id", npc.getId()));
+ }
+
+ /**
+ * Executes the SQL insert:
+ *
+ * {@value CLEAR_NPCS}
+ *
+ */
+ void clearNPCs()
+ {
+ executeUpdate(CLEAR_NPCS);
+ }
+
+ /**
+ * Executes the SQL insert:
+ *
+ * {@value MOVE_NPC}
+ *
+ *
+ * @param npc The NPC you want to teleport.
+ * @param location The Location that you want to the npc to teleport to.
+ */
+ void teleportNPC(NPC npc, Location location)
+ {
+ executeUpdate(MOVE_NPC,
+ new ColumnVarChar("world", 32, location.getWorld().getName()),
+ new ColumnDouble("x", location.getBlockX() + 0.5),
+ new ColumnDouble("y", location.getY()),
+ new ColumnDouble("z", location.getBlockZ() + 0.5),
+ new ColumnInt("yaw", (int) location.getYaw()),
+ new ColumnInt("pitch", (int) location.getPitch()),
+ new ColumnInt("id", npc.getId())
+ );
+ }
+}
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/newnpc/PlayerNPC.java b/Plugins/Mineplex.Core/src/mineplex/core/newnpc/PlayerNPC.java
new file mode 100644
index 000000000..24a16c9f1
--- /dev/null
+++ b/Plugins/Mineplex.Core/src/mineplex/core/newnpc/PlayerNPC.java
@@ -0,0 +1,96 @@
+package mineplex.core.newnpc;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+
+import org.bukkit.Location;
+import org.bukkit.Material;
+import org.bukkit.entity.EntityType;
+import org.bukkit.entity.LivingEntity;
+import org.bukkit.inventory.EntityEquipment;
+
+import com.mojang.authlib.GameProfile;
+
+import mineplex.core.Managers;
+import mineplex.core.common.skin.SkinData;
+import mineplex.core.disguise.DisguiseManager;
+import mineplex.core.disguise.disguises.DisguisePlayer;
+import mineplex.core.hologram.Hologram;
+import mineplex.serverdata.database.column.Column;
+import mineplex.serverdata.database.column.ColumnVarChar;
+
+public class PlayerNPC extends NPC
+{
+
+ private static final DisguiseManager MANAGER = Managers.require(DisguiseManager.class);
+
+ private final SkinData _skinData;
+
+ private DisguisePlayer _disguise;
+
+ public PlayerNPC(int id, String name, Location spawn, Material inHand, byte inHandData, Material helmet, Material chestplate, Material leggings, Material boots, String metadata, String skinValue, String skinSignature)
+ {
+ super(id, EntityType.ARMOR_STAND, name, spawn, inHand, inHandData, helmet, chestplate, leggings, boots, metadata);
+
+ _skinData = new SkinData(skinValue, skinSignature);
+ }
+
+ @Override
+ public LivingEntity spawnEntity()
+ {
+ LivingEntity entity = super.spawnEntity();
+
+ if (entity == null)
+ {
+ return null;
+ }
+
+ GameProfile profile = new GameProfile(UUID.randomUUID(), SkinData.getUnusedSkullName());
+ profile.getProperties().clear();
+ profile.getProperties().put("textures", _skinData.getProperty());
+
+ DisguisePlayer player = new DisguisePlayer(entity, profile);
+
+ EntityEquipment equipment = entity.getEquipment();
+ player.setHeldItem(equipment.getItemInHand());
+ player.setHelmet(equipment.getHelmet());
+ player.setChestplate(equipment.getChestplate());
+ player.setLeggings(equipment.getLeggings());
+ player.setBoots(equipment.getBoots());
+
+ _disguise = player;
+
+ // Ensure the entity is loaded before disguising
+ MANAGER.runSyncLater(() -> MANAGER.disguise(player), 20);
+ return entity;
+ }
+
+ @Override
+ public Hologram getNameTag()
+ {
+ if (!_disguise.hasHologram())
+ {
+ _disguise.getHologram().setText(getEntity().getCustomName());
+ }
+
+ return _disguise.getHologram();
+ }
+
+ @Override
+ public List> toDatabaseQuery()
+ {
+ List> columns = new ArrayList<>(super.toDatabaseQuery());
+
+ columns.set(0, new ColumnVarChar("entity_type", 32, EntityType.PLAYER.name()));
+ columns.set(15, new ColumnVarChar("skinValue", 400, _skinData.getProperty().getValue()));
+ columns.set(16, new ColumnVarChar("skinSignature", 700, _skinData.getProperty().getSignature()));
+
+ return columns;
+ }
+
+ public DisguisePlayer getDisguise()
+ {
+ return _disguise;
+ }
+}
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/newnpc/command/NPCBuildCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/newnpc/command/NPCBuildCommand.java
new file mode 100644
index 000000000..783fd1def
--- /dev/null
+++ b/Plugins/Mineplex.Core/src/mineplex/core/newnpc/command/NPCBuildCommand.java
@@ -0,0 +1,22 @@
+package mineplex.core.newnpc.command;
+
+import org.bukkit.entity.Player;
+
+import mineplex.core.command.CommandBase;
+import mineplex.core.newnpc.NewNPCManager;
+import mineplex.core.newnpc.NewNPCManager.Perm;
+
+public class NPCBuildCommand extends CommandBase
+{
+
+ NPCBuildCommand(NewNPCManager plugin)
+ {
+ super(plugin, Perm.BUILD_NPC_COMMAND, "builder");
+ }
+
+ @Override
+ public void Execute(Player caller, String[] args)
+ {
+ Plugin.createBuilder(caller);
+ }
+}
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/newnpc/command/NPCClearCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/newnpc/command/NPCClearCommand.java
new file mode 100644
index 000000000..a9718c000
--- /dev/null
+++ b/Plugins/Mineplex.Core/src/mineplex/core/newnpc/command/NPCClearCommand.java
@@ -0,0 +1,39 @@
+package mineplex.core.newnpc.command;
+
+import java.util.concurrent.TimeUnit;
+
+import org.bukkit.entity.Player;
+
+import mineplex.core.command.CommandBase;
+import mineplex.core.common.util.F;
+import mineplex.core.newnpc.NewNPCManager;
+import mineplex.core.newnpc.NewNPCManager.Perm;
+import mineplex.core.recharge.Recharge;
+
+public class NPCClearCommand extends CommandBase
+{
+
+ private static final String RECHARGE_KEY = "Clear NPCS";
+
+ NPCClearCommand(NewNPCManager plugin)
+ {
+ super(plugin, Perm.CLEAR_NPC_COMMAND, "clear");
+ }
+
+ @Override
+ public void Execute(Player caller, String[] args)
+ {
+ if (Recharge.Instance.usable(caller, RECHARGE_KEY))
+ {
+ caller.sendMessage(F.main(Plugin.getName(), "Are you really sure you want to delete ALL NPCs? This will remove every one off every server."));
+ caller.sendMessage(F.main(Plugin.getName(), "If you are sure then run " + F.elem("/npc clear") + " again within " + F.time("10 seconds")) + ".");
+ Recharge.Instance.useForce(caller, RECHARGE_KEY, TimeUnit.SECONDS.toMillis(10));
+ return;
+ }
+
+ caller.sendMessage(F.main(Plugin.getName(), "Deleting all NPCs..."));
+ Plugin.clearNPCS(true);
+ caller.sendMessage(F.main(Plugin.getName(), "Deleted all NPCs."));
+ Recharge.Instance.recharge(caller, RECHARGE_KEY);
+ }
+}
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/newnpc/command/NPCCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/newnpc/command/NPCCommand.java
new file mode 100644
index 000000000..6a595e9ca
--- /dev/null
+++ b/Plugins/Mineplex.Core/src/mineplex/core/newnpc/command/NPCCommand.java
@@ -0,0 +1,35 @@
+package mineplex.core.newnpc.command;
+
+import org.bukkit.ChatColor;
+import org.bukkit.entity.Player;
+
+import mineplex.core.command.MultiCommandBase;
+import mineplex.core.common.util.F;
+import mineplex.core.newnpc.NewNPCManager;
+import mineplex.core.newnpc.NewNPCManager.Perm;
+
+public class NPCCommand extends MultiCommandBase
+{
+
+ public NPCCommand(NewNPCManager plugin)
+ {
+ super(plugin, Perm.NPC_COMMAND, "newnpc");
+
+ AddCommand(new NPCBuildCommand(plugin));
+ AddCommand(new NPCDeleteCommand(plugin));
+ AddCommand(new NPCClearCommand(plugin));
+ AddCommand(new NPCRefreshCommand(plugin));
+ AddCommand(new NPCMoveCommand(plugin));
+ }
+
+ @Override
+ protected void Help(Player caller, String[] args)
+ {
+ caller.sendMessage(F.main(Plugin.getName(), "Command List:"));
+ caller.sendMessage(F.help("/" + _aliasUsed + " builder", "Creates a new NPC using the builder.", ChatColor.DARK_RED));
+ caller.sendMessage(F.help("/" + _aliasUsed + " delete", "Deletes an NPC.", ChatColor.DARK_RED));
+ caller.sendMessage(F.help("/" + _aliasUsed + " clear", "Removes all NPCs permanently.", ChatColor.DARK_RED));
+ caller.sendMessage(F.help("/" + _aliasUsed + " refresh", "Reloads all NPCs.", ChatColor.DARK_RED));
+ caller.sendMessage(F.help("/" + _aliasUsed + " move", "Moves an NPC.", ChatColor.DARK_RED));
+ }
+}
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/newnpc/command/NPCDeleteCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/newnpc/command/NPCDeleteCommand.java
new file mode 100644
index 000000000..658006bf1
--- /dev/null
+++ b/Plugins/Mineplex.Core/src/mineplex/core/newnpc/command/NPCDeleteCommand.java
@@ -0,0 +1,29 @@
+package mineplex.core.newnpc.command;
+
+import java.util.concurrent.TimeUnit;
+
+import org.bukkit.entity.Player;
+
+import mineplex.core.command.CommandBase;
+import mineplex.core.common.util.F;
+import mineplex.core.newnpc.NewNPCManager;
+import mineplex.core.newnpc.NewNPCManager.Perm;
+import mineplex.core.recharge.Recharge;
+
+public class NPCDeleteCommand extends CommandBase
+{
+
+ public static final String RECHARGE_KEY = "Delete NPC";
+
+ NPCDeleteCommand(NewNPCManager plugin)
+ {
+ super(plugin, Perm.DELETE_NPC_COMMAND, "delete");
+ }
+
+ @Override
+ public void Execute(Player caller, String[] args)
+ {
+ caller.sendMessage(F.main(Plugin.getName(), "Punch the NPC you wish to remove. You will have " + F.time("10 seconds") + " to do so."));
+ Recharge.Instance.useForce(caller, RECHARGE_KEY, TimeUnit.SECONDS.toMillis(10));
+ }
+}
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/newnpc/command/NPCMoveCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/newnpc/command/NPCMoveCommand.java
new file mode 100644
index 000000000..51d98ea18
--- /dev/null
+++ b/Plugins/Mineplex.Core/src/mineplex/core/newnpc/command/NPCMoveCommand.java
@@ -0,0 +1,30 @@
+package mineplex.core.newnpc.command;
+
+import java.util.concurrent.TimeUnit;
+
+import org.bukkit.entity.Player;
+
+import mineplex.core.command.CommandBase;
+import mineplex.core.common.util.F;
+import mineplex.core.newnpc.NewNPCManager;
+import mineplex.core.newnpc.NewNPCManager.Perm;
+import mineplex.core.recharge.Recharge;
+
+public class NPCMoveCommand extends CommandBase
+{
+
+ public static final String RECHARGE_KEY = "Move NPC";
+
+ NPCMoveCommand(NewNPCManager plugin)
+ {
+ super(plugin, Perm.DELETE_NPC_COMMAND, "move");
+ }
+
+ @Override
+ public void Execute(Player caller, String[] args)
+ {
+ caller.sendMessage(F.main(Plugin.getName(), "Punch the NPC you wish to move to this location. You will have " + F.time("30 seconds") + " to do so."));
+ Plugin.setPlayerTeleport(caller);
+ Recharge.Instance.useForce(caller, RECHARGE_KEY, TimeUnit.SECONDS.toMillis(30));
+ }
+}
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/newnpc/command/NPCRefreshCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/newnpc/command/NPCRefreshCommand.java
new file mode 100644
index 000000000..3d953bf76
--- /dev/null
+++ b/Plugins/Mineplex.Core/src/mineplex/core/newnpc/command/NPCRefreshCommand.java
@@ -0,0 +1,25 @@
+package mineplex.core.newnpc.command;
+
+import org.bukkit.entity.Player;
+
+import mineplex.core.command.CommandBase;
+import mineplex.core.common.util.F;
+import mineplex.core.newnpc.NewNPCManager;
+import mineplex.core.newnpc.NewNPCManager.Perm;
+
+public class NPCRefreshCommand extends CommandBase
+{
+
+ NPCRefreshCommand(NewNPCManager plugin)
+ {
+ super(plugin, Perm.REFRESH_NPC_COMMAND, "refresh");
+ }
+
+ @Override
+ public void Execute(Player caller, String[] args)
+ {
+ caller.sendMessage(F.main(Plugin.getName(), "Refreshing NPCs..."));
+ Plugin.runAsync(() -> Plugin.refreshNPCS());
+ caller.sendMessage(F.main(Plugin.getName(), "Refreshed NPCs"));
+ }
+}
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/newnpc/event/NPCInteractEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/newnpc/event/NPCInteractEvent.java
new file mode 100644
index 000000000..310c3e319
--- /dev/null
+++ b/Plugins/Mineplex.Core/src/mineplex/core/newnpc/event/NPCInteractEvent.java
@@ -0,0 +1,64 @@
+package mineplex.core.newnpc.event;
+
+import org.bukkit.entity.Player;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.player.PlayerEvent;
+
+import mineplex.core.newnpc.NPC;
+
+public class NPCInteractEvent extends PlayerEvent implements Cancellable
+{
+
+ private static final HandlerList _handlers = new HandlerList();
+
+ private final NPC _npc;
+ private final boolean _leftClick;
+
+ private boolean _cancel;
+
+ public NPCInteractEvent(Player who, NPC npc, boolean leftClick)
+ {
+ super(who);
+
+ _npc = npc;
+ _leftClick = leftClick;
+ }
+
+ public NPC getNpc()
+ {
+ return _npc;
+ }
+
+ public boolean isLeftClick()
+ {
+ return _leftClick;
+ }
+
+ public boolean isRightClick()
+ {
+ return !isLeftClick();
+ }
+
+ public void setCancelled(boolean cancel)
+ {
+ _cancel = cancel;
+ }
+
+ public boolean isCancelled()
+ {
+ return _cancel;
+ }
+
+ public static HandlerList getHandlerList()
+ {
+ return _handlers;
+ }
+
+ @Override
+ public HandlerList getHandlers()
+ {
+ return getHandlerList();
+ }
+
+}
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/newnpc/event/NPCRefreshEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/newnpc/event/NPCRefreshEvent.java
new file mode 100644
index 000000000..a44937d4b
--- /dev/null
+++ b/Plugins/Mineplex.Core/src/mineplex/core/newnpc/event/NPCRefreshEvent.java
@@ -0,0 +1,22 @@
+package mineplex.core.newnpc.event;
+
+import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList;
+
+public class NPCRefreshEvent extends Event
+{
+
+ private static final HandlerList _handlers = new HandlerList();
+
+ public static HandlerList getHandlerList()
+ {
+ return _handlers;
+ }
+
+ @Override
+ public HandlerList getHandlers()
+ {
+ return getHandlerList();
+ }
+
+}
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java b/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java
index 591235d34..9522eaaca 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java
@@ -114,7 +114,7 @@ public class NpcManager extends MiniPlugin
NPC_COMMAND,
REFRESH_NPCS_COMMAND,
}
-
+
private final Creature _creature;
private final List _npcs = new ArrayList<>();
private final Queue _queuedNpcs = new LinkedList<>();
@@ -140,17 +140,17 @@ public class NpcManager extends MiniPlugin
require(DisguiseManager.class);
try
- {
+ {
loadNpcs();
}
catch (SQLException e)
{
e.printStackTrace();
}
-
+
generatePermissions();
}
-
+
private void generatePermissions()
{
PermissionGroup.ADMIN.setPermission(Perm.ADD_NPC_COMMAND, true, true);
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/BabyFireworkEffect.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/BabyFireworkEffect.java
index fc85c203f..32c9ba6de 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/BabyFireworkEffect.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/BabyFireworkEffect.java
@@ -1,10 +1,9 @@
package mineplex.core.particleeffects;
-import java.awt.Color;
+import java.awt.*;
import java.util.Random;
import org.bukkit.Location;
-import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.particles.ColoredParticle;
@@ -23,14 +22,14 @@ public class BabyFireworkEffect extends Effect
private Color[] _colors;
private boolean _trail = true;
- public BabyFireworkEffect(Location location, JavaPlugin javaPlugin, Color color)
+ public BabyFireworkEffect(Location location, Color color)
{
- this(location, javaPlugin, color, -1);
+ this(location, color, -1);
}
- public BabyFireworkEffect(Location location, JavaPlugin javaPlugin, Color color, int maxCount)
+ public BabyFireworkEffect(Location location, Color color, int maxCount)
{
- super(10, new EffectLocation(location), javaPlugin, 2);
+ super(10, new EffectLocation(location), 2);
_fireworkColor = color;
_fireworkLocation = location.clone();
if (color == null)
@@ -43,9 +42,9 @@ public class BabyFireworkEffect extends Effect
_maxCount = maxCount;
}
- public BabyFireworkEffect(Location location, JavaPlugin javaPlugin, Color... colors)
+ public BabyFireworkEffect(Location location, Color... colors)
{
- super(10, new EffectLocation(location), javaPlugin, 2);
+ super(10, new EffectLocation(location), 2);
_fireworkLocation = location.clone();
_colors = colors;
_fireworkColor = _colors[0];
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/BlowAKissEffect.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/BlowAKissEffect.java
index 066521459..35345f4ff 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/BlowAKissEffect.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/BlowAKissEffect.java
@@ -9,22 +9,18 @@ import org.bukkit.util.Vector;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
-import mineplex.core.gadget.types.Gadget;
public class BlowAKissEffect extends Effect
{
- private int _particles = 100;
private int _count = 0;
private Vector _vector;
private Location _fixedLoc;
- private Gadget _gadget;
private Player _player;
- public BlowAKissEffect(Player player, Location target, Gadget gadget)
+ public BlowAKissEffect(Player player, Location target)
{
- super(-1, new EffectLocation(player), gadget.Manager.getPlugin());
- _gadget = gadget;
+ super(-1, new EffectLocation(player));
_player = player;
setTargetLocation(new EffectLocation(target));
}
@@ -45,7 +41,8 @@ public class BlowAKissEffect extends Effect
Vector link = targetLoc.toVector().subtract(location.toVector());
float length = (float) link.length();
link.normalize();
- _vector = link.multiply(length / _particles);
+ int particles = 100;
+ _vector = link.multiply(length / particles);
_fixedLoc = location.clone().subtract(_vector);
}
for (int i = 0; i < 5; i++){
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/ChristmasTreeEffect.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/ChristmasTreeEffect.java
index bc2da7ac4..8e7840481 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/ChristmasTreeEffect.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/ChristmasTreeEffect.java
@@ -1,12 +1,11 @@
package mineplex.core.particleeffects;
-import java.awt.Color;
+import java.awt.*;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
-import mineplex.core.common.util.Callback;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.particles.ColoredParticle;
import mineplex.core.common.util.particles.DustSpellColor;
@@ -17,20 +16,17 @@ public class ChristmasTreeEffect extends Effect
private Player _player;
private JavaPlugin _plugin;
- private int _count = 0;
private double _currentRadius = 0;
private double _currentY = 0;
- private BabyFireworkEffect _babyFireworkEffect = null;
private GadgetManager _manager;
private static final double MAX_RADIUS = 1.;
private static final double MAX_Y = 2.5;
- public ChristmasTreeEffect(JavaPlugin plugin, Player player, GadgetManager manager)
+ public ChristmasTreeEffect(Player player, GadgetManager manager)
{
- super(-1, new EffectLocation(player), plugin, 5);
+ super(-1, new EffectLocation(player), 5);
_player = player;
- _plugin = plugin;
_manager = manager;
}
@@ -50,7 +46,7 @@ public class ChristmasTreeEffect extends Effect
{
double radius = MAX_RADIUS - _currentRadius;
_currentRadius += 0.1;
- CircleEffect circleEffect = new CircleEffect(_plugin, _player.getLocation().clone().add(0, _currentY, 0), radius, Color.GREEN);
+ CircleEffect circleEffect = new CircleEffect(_player.getLocation().clone().add(0, _currentY, 0), radius, Color.GREEN);
circleEffect.addRandomColor(Color.RED);
circleEffect.addRandomColor(Color.YELLOW);
circleEffect.start();
@@ -58,18 +54,13 @@ public class ChristmasTreeEffect extends Effect
}
else
{
- BabyFireworkEffect babyFireworkEffect = new BabyFireworkEffect(_player.getLocation().clone().add(0, MAX_Y + .5, 0), _plugin, Color.YELLOW, 1);
+ BabyFireworkEffect babyFireworkEffect = new BabyFireworkEffect(_player.getLocation().clone().add(0, MAX_Y + .5, 0), Color.YELLOW, 1);
babyFireworkEffect.setTrail(false);
babyFireworkEffect.start();
- _babyFireworkEffect = babyFireworkEffect;
- _babyFireworkEffect.setCallback(new Callback()
+ babyFireworkEffect.setCallback(data ->
{
- @Override
- public void run(Effect data)
- {
- _currentY = 0;
- _currentRadius = 0;
- }
+ _currentY = 0;
+ _currentRadius = 0;
});
}
}
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/CircleEffect.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/CircleEffect.java
index 60d83be21..0d8afbf29 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/CircleEffect.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/CircleEffect.java
@@ -1,12 +1,11 @@
package mineplex.core.particleeffects;
-import java.awt.Color;
+import java.awt.*;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
-import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
import mineplex.core.common.util.UtilMath;
@@ -30,36 +29,36 @@ public class CircleEffect extends Effect
private static final double RANDOM_COLOR_CHANCE = 0.5;
- public CircleEffect(JavaPlugin plugin, Location location, double radius, Color color)
+ public CircleEffect(Location location, double radius, Color color)
{
- super(-1, new EffectLocation(location), plugin);
+ super(-1, new EffectLocation(location));
_radius = radius;
_color = color;
}
- public CircleEffect(JavaPlugin plugin, Location location, double radius, Color color, boolean instantly)
+ public CircleEffect(Location location, double radius, Color color, boolean instantly)
{
- this(plugin, location, radius, color);
+ this(location, radius, color);
_instantly = instantly;
}
- public CircleEffect(JavaPlugin plugin, Entity entity, double radius, Color color, boolean instantly)
+ public CircleEffect(Entity entity, double radius, Color color, boolean instantly)
{
- super(-1, new EffectLocation(entity), plugin);
+ super(-1, new EffectLocation(entity));
_radius = radius;
_color = color;
_instantly = instantly;
}
- public CircleEffect(JavaPlugin plugin, Location location, double radius, Color color, boolean instantly, int particles)
+ public CircleEffect(Location location, double radius, Color color, boolean instantly, int particles)
{
- this(plugin, location, radius, color, instantly);
+ this(location, radius, color, instantly);
_particles = particles;
}
- public CircleEffect(JavaPlugin plugin, Entity entity, double radius, Color color, boolean instantly, int particles)
+ public CircleEffect(Entity entity, double radius, Color color, boolean instantly, int particles)
{
- this(plugin, entity, radius, color, instantly);
+ this(entity, radius, color, instantly);
_particles = particles;
}
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/CloverEffect.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/CloverEffect.java
deleted file mode 100644
index 7f62e7100..000000000
--- a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/CloverEffect.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package mineplex.core.particleeffects;
-
-import java.awt.Color;
-
-import org.bukkit.Location;
-import org.bukkit.plugin.java.JavaPlugin;
-import org.bukkit.util.Vector;
-
-import mineplex.core.common.shape.ShapeWings;
-import mineplex.core.common.util.UtilParticle;
-
-public class CloverEffect extends Effect
-{
-
- private ShapeWings _cloverBlack = new ShapeWings(UtilParticle.ParticleType.RED_DUST.particleName, new Vector(1, 1, 1), 1, 0, '#', ShapeWings.DEFAULT_ROTATION, ShapeWings.FOUR_LEAF_CLOVER);
- private ShapeWings _cloverDarkGreen = new ShapeWings(UtilParticle.ParticleType.RED_DUST.particleName, new Vector(1, 1, 1), 1, 0, '%', ShapeWings.DEFAULT_ROTATION, ShapeWings.FOUR_LEAF_CLOVER);
- private ShapeWings _cloverGreen = new ShapeWings(UtilParticle.ParticleType.RED_DUST.particleName, new Vector(1, 1, 1), 1, 0, '*', ShapeWings.DEFAULT_ROTATION, ShapeWings.FOUR_LEAF_CLOVER);
-
- public CloverEffect(JavaPlugin plugin, Location location)
- {
- super(-1, new EffectLocation(location), plugin, 1);
- }
-
- @Override
- public void runEffect()
- {
- Location location = getEffectLocation().getLocation();
- _cloverBlack.displayColored(location, Color.BLACK);
- _cloverDarkGreen.displayColored(location, new Color(0, 100, 0));
- _cloverGreen.displayColored(location, Color.GREEN);
- }
-
-}
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/ColoredCircleEffect.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/ColoredCircleEffect.java
index 21a4b2681..433b85e1a 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/ColoredCircleEffect.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/ColoredCircleEffect.java
@@ -1,6 +1,6 @@
package mineplex.core.particleeffects;
-import java.awt.Color;
+import java.awt.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -8,7 +8,6 @@ import java.util.List;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
-import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
import mineplex.core.common.util.RGBData;
@@ -31,9 +30,9 @@ public class ColoredCircleEffect extends Effect
private static final int PARTICLES_PER_CIRCLE = 20;
- public ColoredCircleEffect(JavaPlugin plugin, Entity entity, double radius, boolean instantly, Color... colors)
+ public ColoredCircleEffect(Entity entity, double radius, boolean instantly, Color... colors)
{
- super(-1, new EffectLocation(entity), plugin);
+ super(-1, new EffectLocation(entity));
_radius = radius;
_colors = new ArrayList<>();
_instantly = instantly;
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/Effect.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/Effect.java
index f72a32fbf..9dd7397b2 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/Effect.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/Effect.java
@@ -1,72 +1,70 @@
package mineplex.core.particleeffects;
-import org.bukkit.Bukkit;
-import org.bukkit.plugin.java.JavaPlugin;
+import org.bukkit.scheduler.BukkitTask;
import mineplex.core.common.util.Callback;
-import mineplex.core.particleeffects.events.EffectStopEvent;
+import mineplex.core.common.util.UtilServer;
public abstract class Effect
{
- public int _ticksToRun = 20, _ticks = 0, _task;
- public long _delay = 1;
- public EffectLocation _effectLocation;
- public EffectLocation _targetLocation;
- protected JavaPlugin _javaPlugin;
+ private int _ticksToRun = 20, _ticks = 0;
+ private BukkitTask _task;
+ protected long _period = 1;
+ protected EffectLocation _effectLocation;
+ private EffectLocation _targetLocation;
private boolean _running = false;
private Callback _callback;
- public Effect(int ticks, EffectLocation effectLocation, JavaPlugin javaPlugin)
+ public Effect(int ticks, EffectLocation effectLocation)
{
_ticksToRun = ticks;
_effectLocation = effectLocation;
- _javaPlugin = javaPlugin;
}
- public Effect(int ticks, EffectLocation effectLocation, JavaPlugin javaPlugin, long delay)
+ public Effect(int ticks, EffectLocation effectLocation, long delay)
{
_ticksToRun = ticks;
_effectLocation = effectLocation;
- _javaPlugin = javaPlugin;
- _delay = delay;
+ _period = delay;
}
public void start()
{
onStart();
_running = true;
- _task = Bukkit.getScheduler().scheduleSyncRepeatingTask(_javaPlugin, new Runnable()
+ _task = UtilServer.runSyncTimer(() ->
{
- @Override
- public void run()
- {
- runEffect();
- update();
- }
- }, 1, _delay);
+ runEffect();
+ update();
+ }, 1, _period);
}
public void stop()
{
_running = false;
- Bukkit.getScheduler().cancelTask(_task);
- EffectStopEvent effectStopEvent = new EffectStopEvent(this);
- Bukkit.getPluginManager().callEvent(effectStopEvent);
+ _task.cancel();
+
if (_callback != null)
+ {
_callback.run(this);
+ }
+
onStop();
}
- public void onStart(){};
+ public void onStart(){}
- public void onStop(){};
+ public void onStop(){}
private void update()
{
_ticks++;
+
if (_ticks == _ticksToRun)
- Bukkit.getScheduler().cancelTask(_task);
+ {
+ _task.cancel();
+ }
}
public boolean isRunning()
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/FreedomFireworkEffect.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/FreedomFireworkEffect.java
index c89fd92cf..6854f7b85 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/FreedomFireworkEffect.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/FreedomFireworkEffect.java
@@ -10,13 +10,13 @@ public class FreedomFireworkEffect extends Effect
{
private Color _fireworkColor = Color.RED;
- private int _count = 0, _max = -1;
+ private int _count = 0;
private boolean _increaseY;
private Entity _playerEntity;
- public FreedomFireworkEffect(Entity entity, JavaPlugin javaPlugin, boolean increaseY)
+ public FreedomFireworkEffect(Entity entity, boolean increaseY)
{
- super(-1, new EffectLocation(entity), javaPlugin, 15);
+ super(-1, new EffectLocation(entity), 15);
_increaseY = increaseY;
_playerEntity = entity;
}
@@ -29,13 +29,13 @@ public class FreedomFireworkEffect extends Effect
this.stop();
return;
}
- if (_count == _max)
+ if (_count == -1)
{
this.stop();
return;
}
Location location = _effectLocation.getLocation().clone().add(0, (_increaseY) ? 1 : 0, 0);
- BabyFireworkEffect babyFireworkEffect = new BabyFireworkEffect(location, _javaPlugin, _fireworkColor);
+ BabyFireworkEffect babyFireworkEffect = new BabyFireworkEffect(location, _fireworkColor);
babyFireworkEffect.start();
_count++;
if (_fireworkColor == null)
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/FreedomTrailEffect.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/FreedomTrailEffect.java
index 373b6c570..9bedfd2d1 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/FreedomTrailEffect.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/FreedomTrailEffect.java
@@ -1,10 +1,9 @@
package mineplex.core.particleeffects;
-import java.awt.Color;
+import java.awt.*;
import org.bukkit.FireworkEffect;
import org.bukkit.entity.Entity;
-import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
import mineplex.core.common.util.UtilFirework;
@@ -20,9 +19,9 @@ public class FreedomTrailEffect extends Effect
private boolean _isJumping = false;
private Entity _entity;
- public FreedomTrailEffect(Entity entity, JavaPlugin javaPlugin)
+ public FreedomTrailEffect(Entity entity)
{
- super(-1, new EffectLocation(entity), javaPlugin);
+ super(-1, new EffectLocation(entity));
_entity = entity;
}
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/HalloweenSmashedEffect.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/HalloweenSmashedEffect.java
deleted file mode 100644
index f99fe1ad8..000000000
--- a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/HalloweenSmashedEffect.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package mineplex.core.particleeffects;
-
-import org.bukkit.FireworkEffect;
-import org.bukkit.Location;
-import org.bukkit.plugin.java.JavaPlugin;
-
-import mineplex.core.common.util.UtilFirework;
-
-public class HalloweenSmashedEffect extends Effect
-{
-
- private FireworkEffect _fireworkEffect;
-
- public HalloweenSmashedEffect(Location location, FireworkEffect fireworkEffect, JavaPlugin javaPlugin)
- {
- super(140, new EffectLocation(location), javaPlugin, 5);
- _fireworkEffect = fireworkEffect;
- }
-
- @Override
- public void runEffect()
- {
- UtilFirework.playFirework(_effectLocation.getLocation(), _fireworkEffect);
- }
-
-}
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/LineEffect.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/LineEffect.java
deleted file mode 100644
index 15a55f406..000000000
--- a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/LineEffect.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package mineplex.core.particleeffects;
-
-import java.awt.Color;
-
-import org.bukkit.Location;
-import org.bukkit.plugin.java.JavaPlugin;
-import org.bukkit.util.Vector;
-
-import mineplex.core.common.util.UtilParticle;
-import mineplex.core.common.util.particles.ColoredParticle;
-import mineplex.core.common.util.particles.DustSpellColor;
-
-public class LineEffect extends Effect
-{
-
- private int _particles = 100;
- private Color _color;
- private int _count = 0;
- private Vector _vector;
- private Location _fixedLoc;
-
- public LineEffect(JavaPlugin plugin, Location location, Location target, Color color)
- {
- super(-1, new EffectLocation(location), plugin);
- setTargetLocation(new EffectLocation(target));
- _color = color;
- }
-
- @Override
- public void runEffect()
- {
- Location location = _effectLocation.getFixedLocation().clone().add(0, 1, 0);
- if (_vector == null)
- {
- Location targetLoc = getTargetLocation().getFixedLocation().clone();
- Vector link = targetLoc.toVector().subtract(location.toVector());
- float length = (float) link.length();
- link.normalize();
- Vector vector = link.multiply(length / _particles);
- _vector = vector;
- _fixedLoc = location.clone().subtract(_vector);
- }
- ColoredParticle coloredParticle = new ColoredParticle(UtilParticle.ParticleType.RED_DUST,
- new DustSpellColor(_color), _effectLocation.getLocation().clone());
- _fixedLoc.add(_vector);
- if (_count == _particles)
- {
- stop();
- }
- }
-
-}
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/LoveDoctorEffect.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/LoveDoctorEffect.java
index 85c293e6f..fad8f33df 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/LoveDoctorEffect.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/LoveDoctorEffect.java
@@ -18,17 +18,15 @@ import mineplex.core.gadget.types.Gadget;
public class LoveDoctorEffect extends Effect
{
- private int _particles = 100;
private int _count = 0;
private Vector _vector;
private Location _fixedLoc;
private Gadget _gadget;
private Player _player;
- private boolean _forceStop = false;
public LoveDoctorEffect(Player player, Location target, Gadget gadget)
{
- super(-1, new EffectLocation(player), gadget.Manager.getPlugin());
+ super(-1, new EffectLocation(player));
_gadget = gadget;
_player = player;
setTargetLocation(new EffectLocation(target));
@@ -50,7 +48,8 @@ public class LoveDoctorEffect extends Effect
Vector link = targetLoc.toVector().subtract(location.toVector());
float length = (float) link.length();
link.normalize();
- _vector = link.multiply(length / _particles);
+ int particles = 100;
+ _vector = link.multiply(length / particles);
_fixedLoc = location.clone().subtract(_vector);
}
for (int i = 0; i < 5; i++){
@@ -63,7 +62,6 @@ public class LoveDoctorEffect extends Effect
}
else if (_count >= 1000)
{
- _forceStop = true;
stop();
}
_count += 5;
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/LoveDoctorHitEffect.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/LoveDoctorHitEffect.java
index 5b7678fa1..88a325855 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/LoveDoctorHitEffect.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/LoveDoctorHitEffect.java
@@ -11,7 +11,7 @@ public class LoveDoctorHitEffect extends Effect
public LoveDoctorHitEffect(Player player)
{
- super(200, new EffectLocation(player.getLocation()), UtilServer.getPlugin());
+ super(200, new EffectLocation(player.getLocation()));
}
@Override
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/MetalManEffect.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/MetalManEffect.java
index d9382e15e..c960e4969 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/MetalManEffect.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/MetalManEffect.java
@@ -22,7 +22,6 @@ import mineplex.core.gadget.types.Gadget;
public class MetalManEffect extends Effect
{
- private int _particles = 100;
private int _color;
private int _count = 0;
private Vector _vector;
@@ -34,7 +33,7 @@ public class MetalManEffect extends Effect
public MetalManEffect(Location location, Location target, int color, Gadget gadget, Player player)
{
- super(-1, new EffectLocation(player), gadget.Manager.getPlugin());
+ super(-1, new EffectLocation(player));
_color = color;
_gadget = gadget;
_player = player;
@@ -57,7 +56,8 @@ public class MetalManEffect extends Effect
Vector link = targetLoc.toVector().subtract(location.toVector());
float length = (float) link.length();
link.normalize();
- Vector vector = link.multiply(length / _particles);
+ int particles = 100;
+ Vector vector = link.multiply(length / particles);
_vector = vector;
_fixedLoc = location.clone().subtract(_vector);
}
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/NewYearEffect.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/NewYearEffect.java
deleted file mode 100644
index 114dd4c50..000000000
--- a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/NewYearEffect.java
+++ /dev/null
@@ -1,155 +0,0 @@
-package mineplex.core.particleeffects;
-
-public class NewYearEffect //extends Effect
-{
-
- /*private static final int SECONDS_IN_A_MINUTE = 60;
-
- private final Location _ballLocation, _clockLocation, _timerLocation, _timerLocationTen;
-
- private int _seconds = 90;
- private Collection