diff --git a/Plugins/Mineplex.ClansGenerator/src/mineplex/clansgenerator/ClansGenerator.java b/Plugins/Mineplex.ClansGenerator/src/mineplex/clansgenerator/ClansGenerator.java index fbab3adc7..2238167d5 100644 --- a/Plugins/Mineplex.ClansGenerator/src/mineplex/clansgenerator/ClansGenerator.java +++ b/Plugins/Mineplex.ClansGenerator/src/mineplex/clansgenerator/ClansGenerator.java @@ -99,6 +99,7 @@ public class ClansGenerator extends JavaPlugin implements Runnable, Listener getServer().getPluginManager().registerEvents(this, this); } + @SuppressWarnings("deprecation") @EventHandler public void onPopulate(ChunkPopulateEvent event) { @@ -117,6 +118,27 @@ public class ClansGenerator extends JavaPlugin implements Runnable, Listener { getLogger().info("Removing dungeon pieces"); } + continue; + } + if (block.getType() == Material.LAVA) + { + byte data = block.getData(); + block.setTypeIdAndData(Material.WATER.getId(), data, false); + if (_debug) + { + getLogger().info("Removing lava"); + } + continue; + } + if (block.getType() == Material.STATIONARY_LAVA) + { + byte data = block.getData(); + block.setTypeIdAndData(Material.STATIONARY_WATER.getId(), data, false); + if (_debug) + { + getLogger().info("Removing lava"); + } + continue; } } } diff --git a/Plugins/Mineplex.ClansQueue.Common/pom.xml b/Plugins/Mineplex.ClansQueue.Common/pom.xml new file mode 100644 index 000000000..d468c56ca --- /dev/null +++ b/Plugins/Mineplex.ClansQueue.Common/pom.xml @@ -0,0 +1,23 @@ + + + 4.0.0 + + + com.mineplex + mineplex-parent + dev-SNAPSHOT + ../plugin.xml + + + ClansQueue-Common + mineplex-clansqueue-common + + + + ${project.groupId} + mineplex-serverdata + ${project.version} + + + diff --git a/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/ClansQueueMessage.java b/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/ClansQueueMessage.java new file mode 100644 index 000000000..2bb7211c3 --- /dev/null +++ b/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/ClansQueueMessage.java @@ -0,0 +1,8 @@ +package com.mineplex.clansqueue.common; + +public class ClansQueueMessage +{ + protected String Origin; + protected String BodyClass; + protected String BodySerialized; +} \ No newline at end of file diff --git a/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/ClansQueueMessageBody.java b/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/ClansQueueMessageBody.java new file mode 100644 index 000000000..9a81b2c75 --- /dev/null +++ b/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/ClansQueueMessageBody.java @@ -0,0 +1,13 @@ +package com.mineplex.clansqueue.common; + +import mineplex.serverdata.Utility; + +public abstract class ClansQueueMessageBody +{ + @Override + public final String toString() + { + super.toString(); + return Utility.serialize(this); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/ClansQueueMessenger.java b/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/ClansQueueMessenger.java new file mode 100644 index 000000000..1de841e9f --- /dev/null +++ b/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/ClansQueueMessenger.java @@ -0,0 +1,115 @@ +package com.mineplex.clansqueue.common; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.function.BiConsumer; + +import mineplex.serverdata.Utility; +import mineplex.serverdata.servers.ServerManager; +import redis.clients.jedis.Jedis; +import redis.clients.jedis.JedisPool; +import redis.clients.jedis.JedisPubSub; + +public class ClansQueueMessenger +{ + private static final String CHANNEL_NAME_BASE = "ClansQueueMessageChannel:"; + + private static final Map _messengers = new ConcurrentHashMap<>(); + + private final String _identifier; + private final JedisPool _readPool; + private final JedisPool _writePool; + @SuppressWarnings("rawtypes") + private final Map _bodyTypes = Collections.synchronizedMap(new HashMap<>()); + @SuppressWarnings("rawtypes") + private final Map> _listeners = Collections.synchronizedMap(new HashMap<>()); + + private ClansQueueMessenger(String identifier) + { + _identifier = identifier; + + _writePool = Utility.generatePool(ServerManager.getMasterConnection()); + _readPool = Utility.generatePool(ServerManager.getSlaveConnection()); + + initialize(); + } + + private void initialize() + { + new Thread("Clans Queue Messenger: " + _identifier) + { + public void run() + { + try (Jedis jedis = _readPool.getResource()) + { + jedis.subscribe(new ClansQueueMessageListener(ClansQueueMessenger.this), CHANNEL_NAME_BASE + "ALL", CHANNEL_NAME_BASE + _identifier); + } + } + }.start(); + } + + public void registerListener(Class messageType, BiConsumer callback) + { + _bodyTypes.putIfAbsent(messageType.getName(), messageType); + _listeners.computeIfAbsent(messageType.getName(), (type) -> new ArrayList<>()).add(callback); + } + + public void transmitMessage(ClansQueueMessageBody message) + { + transmitMessage(message, "ALL"); + } + + public void transmitMessage(ClansQueueMessageBody message, String target) + { + ClansQueueMessage msg = new ClansQueueMessage(); + msg.Origin = _identifier; + msg.BodyClass = message.getClass().getName(); + msg.BodySerialized = message.toString(); + + final String toSend = Utility.serialize(msg); + + new Thread(() -> + { + try (Jedis jedis = _writePool.getResource()) + { + jedis.publish(CHANNEL_NAME_BASE + target, toSend); + } + }).start(); + } + + @SuppressWarnings("unchecked") + public void receiveMessage(ClansQueueMessage message) + { + if (_listeners.containsKey(message.BodyClass) && _bodyTypes.containsKey(message.BodyClass)) + { + T body = Utility.deserialize(message.BodySerialized, (Class)_bodyTypes.get(message.BodyClass)); + _listeners.get(message.BodyClass).forEach(listener -> listener.accept(body, message.Origin)); + } + } + + private static class ClansQueueMessageListener extends JedisPubSub + { + private final ClansQueueMessenger _manager; + + private ClansQueueMessageListener(ClansQueueMessenger manager) + { + _manager = manager; + } + + @Override + public void onMessage(String channelName, String message) + { + ClansQueueMessage msg = Utility.deserialize(message, ClansQueueMessage.class); + _manager.receiveMessage(msg); + } + } + + public static ClansQueueMessenger getMessenger(String identifier) + { + return _messengers.computeIfAbsent(identifier, (id) -> new ClansQueueMessenger(id)); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/QueueConstant.java b/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/QueueConstant.java new file mode 100644 index 000000000..241f40ea0 --- /dev/null +++ b/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/QueueConstant.java @@ -0,0 +1,8 @@ +package com.mineplex.clansqueue.common; + +public class QueueConstant +{ + public static final String SERVICE_MESSENGER_IDENTIFIER = "Queue System"; + public static final int BYPASS_QUEUE_WEIGHT = -1; + public static final int MAX_TRANSFERS_PER_UPDATE = 5; +} \ No newline at end of file diff --git a/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/SortableLinkedList.java b/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/SortableLinkedList.java new file mode 100644 index 000000000..1cffc506a --- /dev/null +++ b/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/SortableLinkedList.java @@ -0,0 +1,13 @@ +package com.mineplex.clansqueue.common; + +import java.util.LinkedList; + +public class SortableLinkedList> extends LinkedList +{ + private static final long serialVersionUID = -1751886037436467545L; + + public void sort() + { + sort((t1, t2) -> t1.compareTo(t2)); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/messages/ClansServerStatusMessage.java b/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/messages/ClansServerStatusMessage.java new file mode 100644 index 000000000..f8e0d7119 --- /dev/null +++ b/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/messages/ClansServerStatusMessage.java @@ -0,0 +1,10 @@ +package com.mineplex.clansqueue.common.messages; + +import com.mineplex.clansqueue.common.ClansQueueMessageBody; + +public class ClansServerStatusMessage extends ClansQueueMessageBody +{ + public String ServerName; + public int OpenSlots; + public boolean Online; +} \ No newline at end of file diff --git a/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/messages/PlayerJoinQueueCallbackMessage.java b/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/messages/PlayerJoinQueueCallbackMessage.java new file mode 100644 index 000000000..73fa93238 --- /dev/null +++ b/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/messages/PlayerJoinQueueCallbackMessage.java @@ -0,0 +1,12 @@ +package com.mineplex.clansqueue.common.messages; + +import java.util.UUID; + +import com.mineplex.clansqueue.common.ClansQueueMessageBody; + +public class PlayerJoinQueueCallbackMessage extends ClansQueueMessageBody +{ + public UUID PlayerUUID; + public String TargetServer; + public int Position; +} \ No newline at end of file diff --git a/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/messages/PlayerJoinQueueMessage.java b/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/messages/PlayerJoinQueueMessage.java new file mode 100644 index 000000000..c31946294 --- /dev/null +++ b/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/messages/PlayerJoinQueueMessage.java @@ -0,0 +1,12 @@ +package com.mineplex.clansqueue.common.messages; + +import java.util.UUID; + +import com.mineplex.clansqueue.common.ClansQueueMessageBody; + +public class PlayerJoinQueueMessage extends ClansQueueMessageBody +{ + public UUID PlayerUUID; + public String TargetServer; + public int PlayerPriority; +} \ No newline at end of file diff --git a/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/messages/PlayerLeaveQueueMessage.java b/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/messages/PlayerLeaveQueueMessage.java new file mode 100644 index 000000000..dc177c457 --- /dev/null +++ b/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/messages/PlayerLeaveQueueMessage.java @@ -0,0 +1,11 @@ +package com.mineplex.clansqueue.common.messages; + +import java.util.UUID; + +import com.mineplex.clansqueue.common.ClansQueueMessageBody; + +public class PlayerLeaveQueueMessage extends ClansQueueMessageBody +{ + public UUID PlayerUUID; + public String TargetServer; +} \ No newline at end of file diff --git a/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/messages/PlayerSendToServerMessage.java b/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/messages/PlayerSendToServerMessage.java new file mode 100644 index 000000000..b1fe5fff0 --- /dev/null +++ b/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/messages/PlayerSendToServerMessage.java @@ -0,0 +1,11 @@ +package com.mineplex.clansqueue.common.messages; + +import java.util.UUID; + +import com.mineplex.clansqueue.common.ClansQueueMessageBody; + +public class PlayerSendToServerMessage extends ClansQueueMessageBody +{ + public UUID PlayerUUID; + public String TargetServer; +} \ No newline at end of file diff --git a/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/messages/QueueDeleteMessage.java b/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/messages/QueueDeleteMessage.java new file mode 100644 index 000000000..d8594724b --- /dev/null +++ b/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/messages/QueueDeleteMessage.java @@ -0,0 +1,8 @@ +package com.mineplex.clansqueue.common.messages; + +import com.mineplex.clansqueue.common.ClansQueueMessageBody; + +public class QueueDeleteMessage extends ClansQueueMessageBody +{ + public String ServerName; +} \ No newline at end of file diff --git a/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/messages/QueuePauseBroadcastMessage.java b/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/messages/QueuePauseBroadcastMessage.java new file mode 100644 index 000000000..b871ee252 --- /dev/null +++ b/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/messages/QueuePauseBroadcastMessage.java @@ -0,0 +1,9 @@ +package com.mineplex.clansqueue.common.messages; + +import com.mineplex.clansqueue.common.ClansQueueMessageBody; + +public class QueuePauseBroadcastMessage extends ClansQueueMessageBody +{ + public String ServerName; + public boolean Paused; +} \ No newline at end of file diff --git a/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/messages/QueuePauseUpdateMessage.java b/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/messages/QueuePauseUpdateMessage.java new file mode 100644 index 000000000..c17064447 --- /dev/null +++ b/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/messages/QueuePauseUpdateMessage.java @@ -0,0 +1,9 @@ +package com.mineplex.clansqueue.common.messages; + +import com.mineplex.clansqueue.common.ClansQueueMessageBody; + +public class QueuePauseUpdateMessage extends ClansQueueMessageBody +{ + public String ServerName; + public boolean Paused; +} \ No newline at end of file diff --git a/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/messages/QueueStatusMessage.java b/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/messages/QueueStatusMessage.java new file mode 100644 index 000000000..135acb4cc --- /dev/null +++ b/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/messages/QueueStatusMessage.java @@ -0,0 +1,20 @@ +package com.mineplex.clansqueue.common.messages; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import com.mineplex.clansqueue.common.ClansQueueMessageBody; + +public class QueueStatusMessage extends ClansQueueMessageBody +{ + public final List Snapshots = new ArrayList<>(); + + public static class QueueSnapshot + { + public String ServerName; + public Map Queue; + public boolean Paused; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/messages/ServerOfflineMessage.java b/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/messages/ServerOfflineMessage.java new file mode 100644 index 000000000..51761ccb9 --- /dev/null +++ b/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/messages/ServerOfflineMessage.java @@ -0,0 +1,8 @@ +package com.mineplex.clansqueue.common.messages; + +import com.mineplex.clansqueue.common.ClansQueueMessageBody; + +public class ServerOfflineMessage extends ClansQueueMessageBody +{ + public String ServerName; +} \ No newline at end of file diff --git a/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/messages/ServerOnlineMessage.java b/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/messages/ServerOnlineMessage.java new file mode 100644 index 000000000..0d95cc1aa --- /dev/null +++ b/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/messages/ServerOnlineMessage.java @@ -0,0 +1,8 @@ +package com.mineplex.clansqueue.common.messages; + +import com.mineplex.clansqueue.common.ClansQueueMessageBody; + +public class ServerOnlineMessage extends ClansQueueMessageBody +{ + public String ServerName; +} \ No newline at end of file diff --git a/Plugins/Mineplex.ClansQueue/pom.xml b/Plugins/Mineplex.ClansQueue/pom.xml new file mode 100644 index 000000000..a202846c3 --- /dev/null +++ b/Plugins/Mineplex.ClansQueue/pom.xml @@ -0,0 +1,48 @@ + + + 4.0.0 + + + com.mineplex + mineplex-plugin + dev-SNAPSHOT + ../plugin.xml + + + ClansQueue + mineplex-clansqueue + + + + ${project.groupId} + mineplex-clansqueue-common + ${project.version} + + + + + + org.apache.maven.plugins + maven-shade-plugin + + false + + + com.mineplex.clansqueue.service.QueueService + + + + + + package + + shade + + + + + + + diff --git a/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/QueueService.java b/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/QueueService.java new file mode 100644 index 000000000..aea90d00d --- /dev/null +++ b/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/QueueService.java @@ -0,0 +1,95 @@ +package com.mineplex.clansqueue.service; + +import java.io.File; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.atomic.AtomicBoolean; + +import com.mineplex.clansqueue.common.ClansQueueMessenger; +import com.mineplex.clansqueue.common.QueueConstant; +import com.mineplex.clansqueue.common.messages.ClansServerStatusMessage; +import com.mineplex.clansqueue.common.messages.PlayerJoinQueueMessage; +import com.mineplex.clansqueue.common.messages.PlayerLeaveQueueMessage; +import com.mineplex.clansqueue.common.messages.QueuePauseUpdateMessage; +import com.mineplex.clansqueue.common.messages.ServerOfflineMessage; +import com.mineplex.clansqueue.common.messages.ServerOnlineMessage; +import com.mineplex.clansqueue.service.commands.CommandSystem; +import com.mineplex.clansqueue.service.commands.ConsoleCommand; +import com.mineplex.clansqueue.service.queue.ClansQueueManager; + +import mineplex.serverdata.Region; + +public class QueueService +{ + public static void main(String[] args) + { + QueueService service = new QueueService(new File("eu.dat").exists()); + service.start(); + while (service.isRunning()) {} + System.exit(0); + } + + private final Region _region; + private final AtomicBoolean _running; + private final Map _commandMap = Collections.synchronizedMap(new HashMap<>()); + private final CommandSystem _commandSystem; + private final ClansQueueManager _queueManager; + + private QueueService(boolean eu) + { + if (eu) + { + _region = Region.EU; + } + else + { + _region = Region.US; + } + _running = new AtomicBoolean(); + _commandSystem = new CommandSystem(this, _commandMap); + _queueManager = new ClansQueueManager(this); + } + + private void start() + { + System.out.println("[Queue Service] Enabling on region " + getRegion().name()); + _running.set(true); + _commandSystem.start(); + _queueManager.start(); + + ClansQueueMessenger messenger = ClansQueueMessenger.getMessenger(QueueConstant.SERVICE_MESSENGER_IDENTIFIER); + messenger.registerListener(ServerOnlineMessage.class, (online, origin) -> _queueManager.handleServerEnable(online.ServerName)); + messenger.registerListener(ServerOfflineMessage.class, (offline, origin) -> _queueManager.handleServerDisable(offline.ServerName)); + messenger.registerListener(QueuePauseUpdateMessage.class, (pause, origin) -> _queueManager.handleQueuePause(pause.ServerName, pause.Paused)); + messenger.registerListener(PlayerJoinQueueMessage.class, (join, origin) -> _queueManager.joinQueue(join.TargetServer, origin, join.PlayerUUID, join.PlayerPriority)); + messenger.registerListener(PlayerLeaveQueueMessage.class, (leave, origin) -> _queueManager.leaveQueue(leave.TargetServer, leave.PlayerUUID)); + messenger.registerListener(ClansServerStatusMessage.class, (status, origin) -> _queueManager.handleServerUpdate(status.ServerName, status.OpenSlots, status.Online)); + } + + public ClansQueueManager getQueueManager() + { + return _queueManager; + } + + public boolean isRunning() + { + return _running.get(); + } + + public Region getRegion() + { + return _region; + } + + public void registerCommand(ConsoleCommand command) + { + _commandMap.put(command.getCommand().toLowerCase(), command); + } + + public void shutdown() + { + System.out.println("[Queue Service] Shutting down..."); + _running.set(false); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/commands/CommandSystem.java b/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/commands/CommandSystem.java new file mode 100644 index 000000000..e02409633 --- /dev/null +++ b/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/commands/CommandSystem.java @@ -0,0 +1,65 @@ +package com.mineplex.clansqueue.service.commands; + +import java.util.Map; +import java.util.Optional; +import java.util.Scanner; + +import com.mineplex.clansqueue.service.QueueService; + +public class CommandSystem extends Thread +{ + private final QueueService _service; + private final Map _commands; + + public CommandSystem(QueueService service, Map commands) + { + super("Command System"); + _service = service; + _commands = commands; + + _service.registerCommand(new HelpCommand(_commands)); + _service.registerCommand(new StopCommand(_service)); + _service.registerCommand(new DeleteQueueCommand(_service)); + _service.registerCommand(new ListQueuesCommand(_service)); + _service.registerCommand(new PauseQueueCommand(_service)); + _service.registerCommand(new UnpauseQueueCommand(_service)); + } + + private boolean matches(String key, String input) + { + if (key.equalsIgnoreCase(input)) + { + return true; + } + if (input.toLowerCase().startsWith(key + " ")) + { + return true; + } + return false; + } + + @Override + public void run() + { + try (Scanner scanner = new Scanner(System.in)) + { + while (_service.isRunning()) + { + String input = scanner.nextLine(); + if (input.isEmpty()) + { + continue; + } + Optional opt = _commands.entrySet().stream().filter(entry -> matches(entry.getKey(), input)).map(Map.Entry::getValue).findAny(); + if (opt.isPresent()) + { + opt.get().call(input); + } + else + { + System.out.println("Command '" + input.split(" ")[0] + "' was not found. Run 'help' for a list of commands."); + } + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/commands/ConsoleCommand.java b/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/commands/ConsoleCommand.java new file mode 100644 index 000000000..f962d4dd6 --- /dev/null +++ b/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/commands/ConsoleCommand.java @@ -0,0 +1,59 @@ +package com.mineplex.clansqueue.service.commands; + +public abstract class ConsoleCommand +{ + private final String _command; + private final String _usageText; + private StringBuilder _outputBuilder; + + public ConsoleCommand(String command, String usageText) + { + _command = command; + _usageText = usageText; + } + + public String getCommand() + { + return _command; + } + + public String getUsageText() + { + return _usageText; + } + + protected final void addOutput(String text) + { + if (_outputBuilder == null) + { + _outputBuilder = new StringBuilder(); + } + else + { + _outputBuilder.append("\n"); + } + _outputBuilder.append(text); + } + + protected final void sendOutput() + { + System.out.println(_outputBuilder.toString()); + _outputBuilder = null; + } + + public final void call(String input) + { + String parsing = input.trim(); + if (parsing.length() > getCommand().length() + 2) + { + String[] args = parsing.substring(getCommand().length() + 1).split(" "); + use(args); + } + else + { + use(new String[] {}); + } + } + + protected abstract void use(String[] arguments); +} \ No newline at end of file diff --git a/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/commands/DeleteQueueCommand.java b/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/commands/DeleteQueueCommand.java new file mode 100644 index 000000000..fd169d08e --- /dev/null +++ b/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/commands/DeleteQueueCommand.java @@ -0,0 +1,38 @@ +package com.mineplex.clansqueue.service.commands; + +import com.mineplex.clansqueue.service.QueueService; +import com.mineplex.clansqueue.service.queue.ClansServer; + +public class DeleteQueueCommand extends ConsoleCommand +{ + private final QueueService _service; + + public DeleteQueueCommand(QueueService service) + { + super("delete", "Deletes an existing server and queue"); + + _service = service; + } + + @Override + protected void use(String[] arguments) + { + if (arguments.length < 1) + { + addOutput("Usage: delete "); + sendOutput(); + return; + } + ClansServer server = _service.getQueueManager().getLoadedServer(arguments[0]); + if (server == null) + { + addOutput("Server '" + arguments[0] + "' was not found. Run 'list' for a list of servers."); + sendOutput(); + return; + } + + _service.getQueueManager().deleteServer(server); + addOutput("Server and queue deleted."); + sendOutput(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/commands/HelpCommand.java b/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/commands/HelpCommand.java new file mode 100644 index 000000000..808c1ab2d --- /dev/null +++ b/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/commands/HelpCommand.java @@ -0,0 +1,41 @@ +package com.mineplex.clansqueue.service.commands; + +import java.util.Map; + +public class HelpCommand extends ConsoleCommand +{ + private final Map _commands; + + public HelpCommand(Map commands) + { + super("help", "Lists commands and their usage"); + + _commands = commands; + } + + @Override + protected void use(String[] arguments) + { + if (arguments.length < 1) + { + addOutput("Commands:"); + _commands.values().forEach(command -> + { + addOutput(command.getCommand() + " : " + command.getUsageText()); + }); + } + else + { + if (_commands.containsKey(arguments[0].toLowerCase())) + { + ConsoleCommand cmd = _commands.get(arguments[0].toLowerCase()); + addOutput(cmd.getCommand() + " : " + cmd.getUsageText()); + } + else + { + addOutput("Command '" + arguments[0] + "' was not found. Run 'help' for a list of commands."); + } + } + sendOutput(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/commands/ListQueuesCommand.java b/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/commands/ListQueuesCommand.java new file mode 100644 index 000000000..55de6784c --- /dev/null +++ b/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/commands/ListQueuesCommand.java @@ -0,0 +1,29 @@ +package com.mineplex.clansqueue.service.commands; + +import java.util.stream.Collectors; + +import com.mineplex.clansqueue.service.QueueService; +import com.mineplex.clansqueue.service.queue.ClansServer; + +public class ListQueuesCommand extends ConsoleCommand +{ + private final QueueService _service; + + public ListQueuesCommand(QueueService service) + { + super("list", "Lists existing servers"); + + _service = service; + } + + @Override + protected void use(String[] arguments) + { + StringBuilder servers = new StringBuilder("Servers: ["); + servers.append(_service.getQueueManager().getLoadedServers().stream().map(ClansServer::getName).collect(Collectors.joining(", "))); + servers.append(']'); + + addOutput(servers.toString()); + sendOutput(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/commands/PauseQueueCommand.java b/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/commands/PauseQueueCommand.java new file mode 100644 index 000000000..c417883e6 --- /dev/null +++ b/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/commands/PauseQueueCommand.java @@ -0,0 +1,38 @@ +package com.mineplex.clansqueue.service.commands; + +import com.mineplex.clansqueue.service.QueueService; +import com.mineplex.clansqueue.service.queue.ClansServer; + +public class PauseQueueCommand extends ConsoleCommand +{ + private final QueueService _service; + + public PauseQueueCommand(QueueService service) + { + super("pause", "Pauses an existing queue"); + + _service = service; + } + + @Override + protected void use(String[] arguments) + { + if (arguments.length < 1) + { + addOutput("Usage: pause "); + sendOutput(); + return; + } + ClansServer server = _service.getQueueManager().getLoadedServer(arguments[0]); + if (server == null) + { + addOutput("Server '" + arguments[0] + "' was not found. Run 'list' for a list of servers."); + sendOutput(); + return; + } + + _service.getQueueManager().handleQueuePause(server.getName(), true); + addOutput("Queue paused."); + sendOutput(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/commands/StopCommand.java b/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/commands/StopCommand.java new file mode 100644 index 000000000..a1c100d64 --- /dev/null +++ b/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/commands/StopCommand.java @@ -0,0 +1,21 @@ +package com.mineplex.clansqueue.service.commands; + +import com.mineplex.clansqueue.service.QueueService; + +public class StopCommand extends ConsoleCommand +{ + private final QueueService _service; + + public StopCommand(QueueService service) + { + super("stop", "Stops the Queue Service"); + + _service = service; + } + + @Override + protected void use(String[] arguments) + { + _service.shutdown(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/commands/UnpauseQueueCommand.java b/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/commands/UnpauseQueueCommand.java new file mode 100644 index 000000000..c047e6972 --- /dev/null +++ b/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/commands/UnpauseQueueCommand.java @@ -0,0 +1,38 @@ +package com.mineplex.clansqueue.service.commands; + +import com.mineplex.clansqueue.service.QueueService; +import com.mineplex.clansqueue.service.queue.ClansServer; + +public class UnpauseQueueCommand extends ConsoleCommand +{ + private final QueueService _service; + + public UnpauseQueueCommand(QueueService service) + { + super("unpause", "Resumes an existing queue"); + + _service = service; + } + + @Override + protected void use(String[] arguments) + { + if (arguments.length < 1) + { + addOutput("Usage: unpause "); + sendOutput(); + return; + } + ClansServer server = _service.getQueueManager().getLoadedServer(arguments[0]); + if (server == null) + { + addOutput("Server '" + arguments[0] + "' was not found. Run 'list' for a list of servers."); + sendOutput(); + return; + } + + _service.getQueueManager().handleQueuePause(server.getName(), false); + addOutput("Queue unpaused."); + sendOutput(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/queue/ClansQueueManager.java b/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/queue/ClansQueueManager.java new file mode 100644 index 000000000..bf08084a3 --- /dev/null +++ b/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/queue/ClansQueueManager.java @@ -0,0 +1,202 @@ +package com.mineplex.clansqueue.service.queue; + +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import com.mineplex.clansqueue.common.ClansQueueMessenger; +import com.mineplex.clansqueue.common.QueueConstant; +import com.mineplex.clansqueue.common.messages.PlayerJoinQueueCallbackMessage; +import com.mineplex.clansqueue.common.messages.PlayerSendToServerMessage; +import com.mineplex.clansqueue.common.messages.QueueDeleteMessage; +import com.mineplex.clansqueue.common.messages.QueuePauseBroadcastMessage; +import com.mineplex.clansqueue.common.messages.QueueStatusMessage; +import com.mineplex.clansqueue.common.messages.QueueStatusMessage.QueueSnapshot; +import com.mineplex.clansqueue.service.QueueService; + +public class ClansQueueManager +{ + private final Map _servers = new HashMap<>(); + private final Map _queues = new HashMap<>(); + private final Thread _updater; + + public ClansQueueManager(QueueService service) + { + _updater = new Thread(() -> + { + while (service.isRunning()) + { + try + { + updateQueues(); + Thread.sleep(5000); + } + catch (InterruptedException e) + { + e.printStackTrace(); + } + } + }, "Queue Update Thread"); + } + + private QueueStatusMessage buildStatusMessage(Collection queues) + { + QueueStatusMessage message = new QueueStatusMessage(); + + queues.forEach(queue -> + { + QueueSnapshot snapshot = new QueueSnapshot(); + snapshot.Paused = queue.isPaused(); + snapshot.ServerName = queue.getServer().getName(); + snapshot.Queue = new HashMap<>(); + queue.getPlayers().values().forEach(player -> snapshot.Queue.put(player.PlayerUUID, player.Position)); + + message.Snapshots.add(snapshot); + }); + + return message; + } + + private synchronized void updateQueues() + { + System.out.println("Updating queues"); + Collection queues = _queues.values(); + + queues.forEach(q -> + { + q.updatePositions(Math.min(q.getServer().getOpenSlots(), QueueConstant.MAX_TRANSFERS_PER_UPDATE)); + if (q.getServer().isOnline()) + { + q.getNextSend().entrySet().forEach(entry -> + { + PlayerSendToServerMessage message = new PlayerSendToServerMessage(); + message.PlayerUUID = entry.getKey(); + message.TargetServer = q.getServer().getName(); + ClansQueueMessenger.getMessenger(QueueConstant.SERVICE_MESSENGER_IDENTIFIER).transmitMessage(message, entry.getValue()); + }); + } + }); + + QueueStatusMessage message = buildStatusMessage(queues); + ClansQueueMessenger.getMessenger(QueueConstant.SERVICE_MESSENGER_IDENTIFIER).transmitMessage(message); + } + + public synchronized ClansServer getLoadedServer(String serverName) + { + return _servers.get(serverName); + } + + public synchronized Collection getLoadedServers() + { + return _servers.values(); + } + + public synchronized void deleteServer(ClansServer server) + { + _servers.remove(server.getName()); + _queues.remove(server); + QueueDeleteMessage message = new QueueDeleteMessage(); + ClansQueueMessenger.getMessenger(QueueConstant.SERVICE_MESSENGER_IDENTIFIER).transmitMessage(message); + } + + public synchronized void handleServerEnable(String serverName) + { + _servers.computeIfAbsent(serverName, (name) -> + { + ClansServer server = new ClansServer(name); + + _queues.put(server, new ServerQueue(server)); + + return server; + }).setOnline(true); + + System.out.println("Clans server " + serverName + " enabled."); + } + + public synchronized void handleServerDisable(String serverName) + { + _servers.computeIfAbsent(serverName, (name) -> + { + ClansServer server = new ClansServer(name); + + _queues.put(server, new ServerQueue(server)); + + return server; + }).setOnline(false); + } + + public synchronized void handleServerUpdate(String serverName, int openSlots, boolean online) + { + ClansServer server = _servers.computeIfAbsent(serverName, (name) -> + { + ClansServer s = new ClansServer(name); + + _queues.put(s, new ServerQueue(s)); + + return s; + }); + server.setOpenSlots(openSlots); + server.setOnline(online); + } + + public synchronized void handleQueuePause(String serverName, boolean pause) + { + ClansServer server = _servers.get(serverName); + if (server != null) + { + _queues.get(server).setPaused(pause); + System.out.println("Clans server " + serverName + " queue pause: " + pause); + QueuePauseBroadcastMessage message = new QueuePauseBroadcastMessage(); + message.ServerName = serverName; + message.Paused = pause; + ClansQueueMessenger.getMessenger(QueueConstant.SERVICE_MESSENGER_IDENTIFIER).transmitMessage(message); + } + } + + public synchronized void joinQueue(String serverName, String currentServer, UUID uuid, int weight) + { + ClansServer server = _servers.get(serverName); + if (server != null) + { + ServerQueue queue = _queues.get(server); + if (weight == QueueConstant.BYPASS_QUEUE_WEIGHT) + { + queue.addBypasser(uuid, currentServer); + } + else + { + queue.addPlayer(uuid, currentServer, weight, player -> + { + PlayerJoinQueueCallbackMessage message = new PlayerJoinQueueCallbackMessage(); + message.PlayerUUID = uuid; + message.TargetServer = serverName; + message.Position = player.Position; + ClansQueueMessenger.getMessenger(QueueConstant.SERVICE_MESSENGER_IDENTIFIER).transmitMessage(message, currentServer); + QueueStatusMessage update = buildStatusMessage(Arrays.asList(queue)); + ClansQueueMessenger.getMessenger(QueueConstant.SERVICE_MESSENGER_IDENTIFIER).transmitMessage(update); + }); + } + } + } + + public synchronized void leaveQueue(String serverName, UUID uuid) + { + ClansServer server = _servers.get(serverName); + if (server != null) + { + ServerQueue queue = _queues.get(server); + queue.removePlayer(uuid, () -> + { + QueueStatusMessage message = buildStatusMessage(Arrays.asList(queue)); + ClansQueueMessenger.getMessenger(QueueConstant.SERVICE_MESSENGER_IDENTIFIER).transmitMessage(message); + }); + } + } + + public void start() + { + _updater.start(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/queue/ClansServer.java b/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/queue/ClansServer.java new file mode 100644 index 000000000..375a7ebc6 --- /dev/null +++ b/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/queue/ClansServer.java @@ -0,0 +1,58 @@ +package com.mineplex.clansqueue.service.queue; + +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; + +public class ClansServer +{ + private final String _serverName; + private final AtomicBoolean _online = new AtomicBoolean(); + private final AtomicInteger _openSlots = new AtomicInteger(); + + public ClansServer(String serverName) + { + _serverName = serverName; + } + + public String getName() + { + return _serverName; + } + + public boolean isOnline() + { + return _online.get(); + } + + public void setOnline(boolean online) + { + _online.set(online); + } + + public int getOpenSlots() + { + return _openSlots.get(); + } + + public void setOpenSlots(int openSlots) + { + _openSlots.set(openSlots); + } + + @Override + public int hashCode() + { + return _serverName.hashCode(); + } + + @Override + public boolean equals(Object o) + { + if (o == null || !getClass().isInstance(o)) + { + return false; + } + + return ((ClansServer)o)._serverName.equals(_serverName); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/queue/QueuePlayer.java b/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/queue/QueuePlayer.java new file mode 100644 index 000000000..2c5048d8b --- /dev/null +++ b/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/queue/QueuePlayer.java @@ -0,0 +1,33 @@ +package com.mineplex.clansqueue.service.queue; + +import java.util.UUID; + +public class QueuePlayer +{ + public final UUID PlayerUUID; + public final String CurrentServer; + public int Position; + + public QueuePlayer(UUID uuid, String currentServer) + { + PlayerUUID = uuid; + CurrentServer = currentServer; + } + + @Override + public int hashCode() + { + return PlayerUUID.hashCode(); + } + + @Override + public boolean equals(Object o) + { + if (o == null || !getClass().isInstance(o)) + { + return false; + } + + return ((QueuePlayer)o).PlayerUUID.equals(PlayerUUID); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/queue/ServerQueue.java b/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/queue/ServerQueue.java new file mode 100644 index 000000000..e9e269efc --- /dev/null +++ b/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/queue/ServerQueue.java @@ -0,0 +1,222 @@ +package com.mineplex.clansqueue.service.queue; + +import java.util.LinkedHashMap; +import java.util.LinkedList; +import java.util.Map; +import java.util.Optional; +import java.util.Queue; +import java.util.UUID; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.function.Consumer; + +import com.mineplex.clansqueue.common.SortableLinkedList; + +public class ServerQueue +{ + private final ClansServer _server; + private final Map _sending = new LinkedHashMap<>(); + private final Map _bypassing = new LinkedHashMap<>(); + private final SortableLinkedList _queues = new SortableLinkedList<>(); + private final Object _bypassLock = new Object(); + private final Object _queueLock = new Object(); + private final Object _sendLock = new Object(); + private final AtomicBoolean _paused = new AtomicBoolean(); + + public ServerQueue(ClansServer server) + { + _server = server; + } + + public ClansServer getServer() + { + return _server; + } + + public boolean isPaused() + { + return _paused.get() || !_server.isOnline(); + } + + public Map getNextSend() + { + synchronized (_sendLock) + { + Map sending = new LinkedHashMap<>(); + sending.putAll(_sending); + _sending.clear(); + return sending; + } + } + + public Map getPlayers() + { + synchronized (_queueLock) + { + Map players = new LinkedHashMap<>(); + _queues.forEach(queue -> queue._players.forEach(qp -> players.put(qp.PlayerUUID, qp))); + + return players; + } + } + + public void addBypasser(UUID uuid, String currentServer) + { + synchronized (_bypassLock) + { + _bypassing.put(uuid, currentServer); + } + } + + public void addPlayer(UUID uuid, String currentServer, int weight, Consumer callback) + { + synchronized (_queueLock) + { + Optional queueOpt = _queues.stream().filter(q -> q._weight == weight).findFirst(); + PlayerQueue queue = queueOpt.orElseGet(() -> + { + PlayerQueue creating = new PlayerQueue(weight); + if (_queues.add(creating)) + { + _queues.sort(); + } + + return creating; + }); + + QueuePlayer player = new QueuePlayer(uuid, currentServer); + queue._players.add(player); + + AtomicInteger position = new AtomicInteger(1); + if (_queues.removeIf(q -> q._players.isEmpty())) + { + _queues.sort(); + } + _queues.forEach(q -> q._players.forEach(qp -> + { + qp.Position = position.getAndIncrement(); + })); + + if (callback != null) + { + callback.accept(player); + } + } + } + + public void removePlayer(UUID uuid, Runnable after) + { + synchronized (_queueLock) + { + _queues.forEach(queue -> queue._players.removeIf(player -> player.PlayerUUID.equals(uuid))); + + AtomicInteger position = new AtomicInteger(1); + if (_queues.removeIf(q -> q._players.isEmpty())) + { + _queues.sort(); + } + _queues.forEach(q -> q._players.forEach(qp -> + { + qp.Position = position.getAndIncrement(); + })); + + if (after != null) + { + after.run(); + } + } + } + + public void setPaused(boolean paused) + { + _paused.set(paused); + } + + public void updatePositions(int openPlayerSlots) + { + Map send = new LinkedHashMap<>(); + if (_server.isOnline()) + { + synchronized (_bypassLock) + { + send.putAll(_bypassing); + _bypassing.clear(); + } + } + synchronized (_queueLock) + { + if (!isPaused() && openPlayerSlots > 0) + { + while (send.size() < openPlayerSlots) + { + if (_queues.removeIf(queue -> queue._players.isEmpty())) + { + _queues.sort(); + } + PlayerQueue queue = _queues.peek(); + if (queue == null) + { + break; + } + QueuePlayer player = queue._players.poll(); + send.put(player.PlayerUUID, player.CurrentServer); + } + } + AtomicInteger position = new AtomicInteger(1); + if (_queues.removeIf(queue -> queue._players.isEmpty())) + { + _queues.sort(); + } + _queues.forEach(queue -> queue._players.forEach(qp -> + { + qp.Position = position.getAndIncrement(); + })); + } + if (send.isEmpty()) + { + return; + } + synchronized (_sendLock) + { + _sending.putAll(send); + } + } + + private static class PlayerQueue implements Comparable + { + private final int _weight; + private final Queue _players = new LinkedList<>(); + + private PlayerQueue(int weight) + { + _weight = weight; + } + + @Override + public int compareTo(PlayerQueue queue) + { + if (queue == null) + { + throw new NullPointerException(); + } + return Integer.compare(queue._weight, _weight); + } + + @Override + public int hashCode() + { + return Integer.hashCode(_weight); + } + + @Override + public boolean equals(Object o) + { + if (o == null || !getClass().isInstance(o)) + { + return false; + } + + return ((PlayerQueue)o)._weight == _weight; + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilCollections.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilCollections.java index 1c41ffe51..c0f41b86d 100644 --- a/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilCollections.java +++ b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilCollections.java @@ -78,7 +78,7 @@ public class UtilCollections { for (int i = 0; i < elements.length; i++) { - consumer.accept(Integer.valueOf(i), elements[i]); + consumer.accept(i, elements[i]); } } @@ -91,7 +91,7 @@ public class UtilCollections { for (int i = min; i < max; i++) { - consumer.accept(Integer.valueOf(i)); + consumer.accept(i); } } @@ -281,4 +281,4 @@ public class UtilCollections { return optionalList.stream().filter(Optional::isPresent).map(Optional::get).collect(Collectors.toList()); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/animation/AnimationPoint.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/animation/AnimationPoint.java index a02e78796..316e23b87 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/animation/AnimationPoint.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/animation/AnimationPoint.java @@ -54,5 +54,4 @@ public class AnimationPoint { return Objects.hash(_tick, _move); } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/lang/IntlString.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/lang/IntlString.java index fada15f15..ff4de1345 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/lang/IntlString.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/lang/IntlString.java @@ -6,6 +6,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Locale; +import java.util.Objects; import org.bukkit.ChatColor; import org.bukkit.entity.Entity; @@ -154,7 +155,7 @@ public class IntlString @Override public int hashCode() { - return toString().hashCode(); + return Objects.hash(getKey(), getArguments()); } @Override @@ -220,7 +221,7 @@ public class IntlString @Override public int hashCode() { - return toString().hashCode(); + return Objects.hash(getArgument(), getStyle()); } @Override diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java index 54204cd9e..0b301c04b 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java @@ -45,7 +45,8 @@ public class SkinData public final static SkinData STEVE = new SkinData("eyJ0aW1lc3RhbXAiOjE0NjY3MzgxOTAzNDYsInByb2ZpbGVJZCI6ImJiYjg3ZGJlNjkwZjQyMDViZGM1NzJmZmI4ZWJjMjlkIiwicHJvZmlsZU5hbWUiOiJkaXJld29sZjIwIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS82NmZlNTE3NjY1MTdmM2QwMWNmZGI3MjQyZWI1ZjM0YWVhOTYyOGExNjZlM2U0MGZhZjRjMTMyMTY5NiJ9fX0=", "xIDCRBS39ZhhROcYkYORDcWosWqR5xvrTTScNzpt8WtBq1cAoL1mXEi/PtBrEEvajcpR/nGhRlZV/IeavtmUx49ulY3bdX827Rex3504DnmolxVqnq8/p1W8ywxV9FBcMI4Cto3c5kmIXHTTAcLsUuCmsmprzuMS+/RvfJ//vjem+lUc+eQKBe3Hc3ocapfxf1dHqSrtzurW2fRTMZcJWEOr9eicRDzOOP2nbtfZGeCcwJPnYJMxJReBWLO/LiV6Bzm/8+ynRFzmJVw7zvXY9WCz/Yt95nK1lqpFZXR7djFYTsnLpLc71rUPhPwSZSVm0Ca+wZWI2RFnm3kbKRsIB89EqsVIxgw9SMKHJwGPc/GBMOZuO2J6HxGn5xXE5JnLTn8YzpBDft+3Hnb2EJTJ2OCPHaQtzMiYDG4+OkwP7ksxcwmMxRUWuE37dwXi/d4A94IKsLqrCxj+vGFPo13wc5L0DRRx7Plk2/nrC32UhKomkjGz2XbS1aJpKgLILbaM1nYnNGKx/VBLNNJdpwhwaoWgRPEB2MEFmxV+GQ/QgOJuaI7fj5KfLqCePX5V3tfdEUb5OmnC2rH1+ptE1RNOBvPPV/D04NzpvvT9QtCq3I6f1fqbcdWVaYkrRcyD/EjQv0Vod46GJPT4jEQ8f2K10dpDtaB/cWGpT16XCRNT0F8="); public final static SkinData MOOSHROOM = new SkinData("eyJ0aW1lc3RhbXAiOjE0NDk4NzI0OTU0MTcsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzIxOWJlYTU0Y2FkN2Q1OGFiNWRhNDA2YjBhOTJhYjNhODI0MjI1MjY2Nzc3ZTUzNGI3ZGI2YzM3MmRkZmY3ZiJ9fX0=", "UoSif81+UyvkcaanU8KAMYBpw9mefAmWehE2liDUFvk+y0X/9NovsxTYVpIDCltTSpLW3sNgamvbj4Ybs+s6DbudPiEkvh0ER7Bv2v29UJw7RzIdr6/1g548X12zcnh5iPGz/P75uNRnSfTFQx0ed8P/GNkPIjWpDuJFxEj6KcPzrCAGMx+BVw1VwryBIYf9cCDHky8z0bxR89rjiIvPTBFI6MRhqI3vgpEBTySHDS+Ki0Hwl5oa3PwS6+jgYx/4RSfFsb+BawcvDk2Xpkt5UimvqZ5BceYLIfCt4KbShYipgLXLfYUZrntjPemd3SxthjxUuA07i44UxRdiC8uqy1twLT/HUS28gpk68lA/id9tKFwu1CUzshgcmvQPt3ghtNViNziR/2t7D/+5D31Vzmhf6n7Pnpdirt/5frMi2BKMMs7pLa0EF8CrrDU7QCwPav+EZVGFvVZbxSkCDq+n3IQ3PUWSCzy6KPxpdOlUjD0pAfLoiNj0P8u4+puQtID76r/St8ExchYl2dodUImu1ZETWeFUClF3ZGat62evx8uRQEI2W4dsVwj40VUfjaAuvyDzuouaKTrCzJXLQZZjR1B8URvuK61fGX0nhW607mEi6DE+nxP2ZoBrROEX4e37Ap6+TQn9Q8tKDPdcxtwSOpPO4Qkncjn/mGtP9lZU/DQ="); - + public final static SkinData IRON_GOLEM = new SkinData("eyJ0aW1lc3RhbXAiOjE1MDU1OTUxNTQzMjQsInByb2ZpbGVJZCI6Ijc1N2Y5MGIyMjM0NDRiOGQ4ZGFjODI0MjMyZTJjZWNlIiwicHJvZmlsZU5hbWUiOiJNSEZfR29sZW0iLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzg5MDkxZDc5ZWEwZjU5ZWY3ZWY5NGQ3YmJhNmU1ZjE3ZjJmN2Q0NTcyYzQ0ZjkwZjc2YzQ4MTlhNzE0In19fQ==", "d8G2rURRt/rjAOhFo51lI2TD1eRll7uyvTfqKB6zybc7bLX/igADhdkTpHqFFGeAGL2Qt5q8HjhJjDwG8lBiYRGkAFZFmeHhdszhtxgQ6SEqExp3In/lAkXNUdiQqmvyK5Gv+sgBsD8H/+FaMGXiU0Whv5hk2xnSv9UctnshqYLshds9eI+2ufcI3xO9UF8nvJqZCNsEGbvBxI0I7TFr9J3MiLeJNGlCt1QcQQBUSmmQbJPJID/CRNCc1aHq+fh/3rb3ejdr1tCCXHY6OgFL74wCjfZ8MiW9dh1Yjbg+oYQwIoAM5d5013PZUFnBg82gwNHgSzURDdp+eENCZJthHxFG5ydTgN4Fm2AQNPKE6Xmru0lm3ybndINgOqmivSAi6weVzFJIyEkrfs6i5tMl379i7Kkbet6/gkkmR+sTlN/A0svA7vpAEGBSKf4E8qVgTgubW17xbUsyms2rmVVxxpznd7t0S3097K8PdtiTkiwxudKy8oNjEEyhAbAgZChsIlLGfeGA2J6mLdnZZ1MwnKw+Wo5skll3gmcOT/JJ+UQF4XILfs0sajXjo/dvfcFUKmPq/bwCE0ijiN9Z9I23SFxXcBpVavmqLoCn/SysZPtQvldDBEuW8wMEo6DmFaQ/m7sSvD38W95/EIhPtaXJk5Wq0C5r+MY7b0Cp4af/pU0="); + public final static SkinData COMPANION_CUBE = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTUxMDk5NjI0NjEsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2MyMTVkYmRhNTY1ZjVjYjhlYjEyZjU1NWY1ZTNkYTBlYTVmNTUxOTg5MWNjNWM1ZDY3NmZkODJjNjIifX19", "vaAQbhnhnTOs64ToFWLg7o4JmqkIl07HWJ6l7xibfISaOcU4BvYBxsfGvmoxlVdsUeCunAJ8/05qVLl5zZYd8Dt+To6JSY0RlqV8piRaaj3FztYWV2ZvG3YZxPxiD3HRJTAQnDobSuxHyPa1e3khjAFp9xJo4q1oqQ28oI2WDuoT+IHqxwkKVbGzO7UD5lzz5chjQC46E8SxddNKp9aqwbbccrkHYT4gteoonOXu4MFxZniJN12LqUCb6+G15rU8MijlBkWx0xE5NMUloeTGuJZItbHun9fysLk/+HE5xJOKYtpZNMuWX+DB/O5ds9dXrOoSAg+Vn0QU4CZbwcxzLii5ILOfEEBtePuEAgzROri+iCKp59CqlEMBrCsd3Um0MCdbuOfvkXGBHBz+bqX7VJY1ujlSdMefmbJtHAkDANnsaaVb+eli9Dk6139041sptsLytD+EfJzaitX6crBwKZ2WDx2P6LHo8B+iSOzOJxjf/08zlXqFw1vsk62IN6lisuZ89QyZw23RvOx3obLAGYs1GxAlMl9qQdpXcmuE1+lPR3g8gZ0BfnTeYwflC2wbR1tuwGG98lyUGCvGLyqNKAQTN87XV4IFQWR81mi1c5CcasoWhKf9D9nAik9aK7A915fEE5IvpeuUdZseDxDVVN5dBIs5q2PIHFAS0rDsDBc="); public final static SkinData THE_GRINCH = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTAwMTYxNDMwMDQsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzg4ZWRlOTI3ZDQzOWVmMzliMzFhYzFkYzJhODM5NGZlNzlhY2U4NDMyNzBjYmUxMjg2ZGM3NTE3ZjMxYTk2In19fQ==", "ELo594vTzPq9ZmPYOtVr4kim/k19gzmoxEIK1ehS87gwgag5HcgM+P1FMnHIyrmSvTVaMh0NxwXmNS+JETFL7OrmgRYNpkxkkO4VBA0pfSn3dA9ujnXpDnDiWEPxKdMgQspIOOI0Z3esNt3pj8qIj6dWPtGwtso48tjHl2o/kazfa82yvGORlFhGkeEJKQMno/Buc12C0foQw39XI8GjvlSkFN2eH4Fp16RLu8/hf7SqJQC3L1KacvzMW1d8BWEIgACCJDni29+YqxflSqSyYrV4Z+D66S0jYvUUL/vM4/q/p/YWX/vs/FtMtHQTj4PCpAmMNTgfkahuhb6rCvKHukbjA+WhUdwyxSqXU5YnpXCu1M2dzZgiXjIi+fnyn4CmXKindWCQtSwu+mCA2ILv/6vEHoYJgdlz+DXyRkFx+DH4Sl74HBCOXTOq5AGjq5h3LYfsre+UjCCUv8VgxbVprOyj35So7K0m+6faCFVSt35T3RgicDQfdiWUrW7kmHQVvJpvaq9Vu+63F/0X93cwqwaR0buMirxRx7qkFrRunSI4T+9fsN02t1fAieeu80lBSv83wr7BFneSsLsdVAND9xttTb6fClg7anr8/XVEVIkylB4B+ZcWQbH61XP1nn7oFP2VBg1h6XuuLp8FGSgYf/LW+54/KZci/MnanqQE6QQ="); public final static SkinData LOVESTRUCK = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTUxMTAyNDMyNjUsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzczMTY5YWQwZTUyYjM1N2NiZGYxZDU0NGVkNGNmOWJmOTI4YmI0ZWNlMDhlY2YyY2M0YmYyYTlmMjJhODI4MmQifX19", "LL4RiSKQoTZamRQ4QG6izpvhgFu5gAqW4eZxcWAihk7GkhyxifpJpBTOzKrj5hH9fCUfYkkijVWUYTEcVSVRWhocp2HXW59TbKfxOeMvHU5vTMwgpwm6PnUfwuTsRPSLC7WMnEreI3cjOxPVmXbTniOSd+o8j4oOIgwFS+VLPiYLh5Jl16i5I/9ekafl3/x41NISKWl62geqO2jPWehlk+r3soiRJsxaKw20T61GSNLu19iA96Rz2T2tUHB4opm8hbLgoiNL2g1affTjq3cZPLHH4JWF3vPhqLB5uw6xb55vFLM/PP0YiEMIi7YZOfRGeaPp7uXbXgHeew+7PG9UDVMfqbwANQY4ndECijZoei54+xX3MDXkMhQsc5S+FLnGH6e4d008v81eEOyzJUPkKbGxLCBgTUb1s4IHwomCr30twPlo1IuFBOY1qeVvZUfAfPJsREuj5q/oCAoYFgupmb3ClWECnwwaH/T4wdHjfSBHoZQdLzcgDOAl0b5EXxWmYBECqk/WA4TrYIDVGdwkqjI0RkPLUoxTj6135KO+F7P7PwhU9WBGeW8hHq918DBL0fjQVHjrzvolTqwmw6nySSePnPOxFX/iwtHWzpBa9V6kUNNN+V7OGTgRr0H/yUxB+oq1F8UBqyqT4YpqxXCSD36derF/Xt5IdpTbEbGBpm0="); @@ -91,6 +92,11 @@ public class SkinData public static final SkinData PINEAPPLE = new SkinData("eyJ0aW1lc3RhbXAiOjE1MDEzNjU5Mjc3OTMsInByb2ZpbGVJZCI6ImJiMDgwOTFhOTJlZDQzYWQ5NGYxZWRmZDc0NmIwYTJjIiwicHJvZmlsZU5hbWUiOiJJcDRuZHgiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzczMjVlYmI5NmE3YWYzZTg3ZThiNmNhOWE4YzE5ZTllOWVlZDgxYjU4Y2RhZWUzNTIyMTg2NTc0YzgyN2Y0In19fQ==", "wrrEvFHwXhSivSnSN1VbXwjfZ7JrdizB4kAGCpOgYu090M087cJUoWan5KfjMN4N9DjmxmWt6M/yE25+47iu3grzaxnsIAUY+b7HzYzk1nrII3R9LLRbOF6cr6ug2c9scQ1wTsWHpul8y5U/vNekTN8+rRBBurmzUR+50M/wXh+mVFhVFtI2QFwDOZZWz4Tz/mPqGiRAtfT1UcPmGS9d5qETqWQlOAbtdlhuYQADNKSf3pIizRvbJKrEtDI6+deqzzGj35L7LdnsOO+k0qFz5m75AdbOty0l11ID1XGXf604iOocvNk/mO4oO+C7Na2jdwazgd7TJ0H+7qAz2suXflco+ALGcRJob3ysBleHBY2l1IpCWH6SPQG+mQvyOfi356dS4HM/QnPBswLJZ+q7rpkAyW8nArLP49/s+ou0PRs75EiFM61xzFoQRt1fLhx7X+IP2QYy7KIMWw5oRJvLKedu2bDTilMq5lyj6o7I7mfKIou8+O4P30eOwBFTPpjPe3BLMws7/Muwqh4TeSdTIuEkTca8qxb8RUv136DJkmkMJTYiZg7kNHLRL0oP8Hz1o8sCX9w6MElyHeRv/h+sE6PHP3zApjr3+wAun6CFBnLvtVcOA5/zvYQcNbzN2sdwWf7V+djN5Eqq78FduhK1MqiYXpJq9pM/cM3beM1rXE4="); public static final SkinData GREEN_APPLE = new SkinData("eyJ0aW1lc3RhbXAiOjE1MDEzNjU4MTM1MzIsInByb2ZpbGVJZCI6ImE5MGI4MmIwNzE4NTQ0ZjU5YmE1MTZkMGY2Nzk2NDkwIiwicHJvZmlsZU5hbWUiOiJJbUZhdFRCSCIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjY3OGNmNjAzOTg2ZTM4NDcwNjkyZjgwYWJlNDE4ZjM5YTJjYWQ3N2Q4Nzc4YWY4NTc0NmU5MTkzMzdjZmQ2In19fQ==", "xAm3i+xi9OynV2uaqdF0VTws0qCsH3SP3zeEa5gUZejbhzXA7/i4JZC2+Ag9ULj4AaTbZhc1mFMB9+XAozmrWr+BEQjaD8/sbyQIirzUAk/X6ZTCKkp7Xk46mFlKjd4IVvoUSopCa/HCTRZTugjqJrPbdy232/UVC9JBShAcMq7pD7rmH5+O/vVtMcrtT8MjY95vnlhyXyNpDwYhCW9YlmZcG5fS5nPaq8k8mCaNe/fILVf2T/hQqqMTuZiqQk53L+5C8aiU4nySrGATB3UK1OwVTB7t3gen4MQtUT0ursOKoLLbxWboQWjsFYOxycfDeccOcB50iHfqCW8UmARt8mUT17RfWQvwIqlv1uThdnKsFZjx3LAodPAzcqyIoyR8EbCEeV82pDtYG5X7gT/pV/inYDgrLT7ZmONRk2x1TzTC3PicKNXu40OcOU63yaB/nvQY3FURNVCpvWXwPD1QyZBYfKtO4no1/TfPoZPcdGz9E1Xor74AlDAUJTlGQ5+OlQldJiwHvmPxTPJKdgOJLXRVUHcFLV32VtWnmrBRq9pm3qO3MTEVytB4XVaGmsf3zqcwrVur910CpPxDjyXqe1NvxN2I/43FAQInL3iX/NqOpwsx7alSIUe3ZhdqP6l8SSTDK0Sp+1GtvGrvRiX/8dStDfAsNCN0HxvxQQUVM2w="); public static final SkinData PLUM = new SkinData("eyJ0aW1lc3RhbXAiOjE1MDEzNjQyMzY0NjMsInByb2ZpbGVJZCI6IjBiZTU2MmUxNzIyODQ3YmQ5MDY3MWYxNzNjNjA5NmNhIiwicHJvZmlsZU5hbWUiOiJ4Y29vbHgzIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS9lZWIzZjU5NzlhNWVhMGI4MmM4NTUyNmZkYjg0ZjI2YTY4YmY1YTI1NDQ5YzRiNTk2NWU5Y2IxYzQ5NDM5YWY0In19fQ==", "jC6e7Cy7wGmvqSUjIYXwPXQZjAVxnOMoST+IKy/m/g4uklandxhBT9HJskBI+rtVjz67psyLmY941gAtqIbLkRxEhAeT/Qc3iRMV9MN7Ac7b3UaQsnO5gnY3IBZZxSTJhX8oxyTXD+c9k4lsjladzxXA3DcmEn0Cqp0t0oFQA5mEYpa1qGB6NCoXvi5deXNID3PQJjj+PLkohoLKhsDEqbYb3djwGTDKWYGFAwuF7KnA3cuPXa5KN6sPbM7qdjnF3Gke9bkinTn8F7cXVxEpcqAxiUyv8Wv/umHRaEBuDf9yxrDaberkRQu+YIqK6fw805QwcxQePiG/qMU9yZAOuPoolp/SUROHF69pjN9lI8O5Vs08f/K3rSIpgyU16K+lUmE1XIPukUBjNsK2mRTLfJgv8csilzS5jWmVzjr859l0Inr51tGtfQ3VEyUJtIowcOh9GfZWTvaYeDnyGhRUaEpPOmCo1QLIbedAbq51+gYykeQMTmRc+joxxN9SBlF252d7ncOcVAChHxmcFWbPbhV2lMfSTxGmKAx1T9dmw22Z0WTM0NkMG7EsG7wFz1U8f0OY4lyrtVUM7Oy8pc8RuRPhOgQGAvuhA58k6DLgmOpMOVBuEkoOFpZaJKWgVMQI+u9g6COC7WRTF/Z3EW//BFQ09L+uSAPaeyD8rzFqbCo="); + + public static final SkinData CLANS_DYE_BOX = new SkinData("eyJ0aW1lc3RhbXAiOjE1MDYxMTgyMDExNDYsInByb2ZpbGVJZCI6IjI2YTVmMDc5ZTNkOTRkZGY5YzdjMjc4NTcxNGIzZWU2IiwicHJvZmlsZU5hbWUiOiJFMDgiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2JmOTVkMzJhNDQ0ZTBlMjY2MTlhZDFmNTE3M2M0ODNhODNlNmNmMzhjNzRjMGExMjlmMjkzNTQ3ZTY4NCJ9fX0=", "bFpeydp6pwuXQRjw096d/KQoVB0ztXDAciNNjQZEOpZJn9zrUQD0sY6f54NzlH2Ky7m+lJgE2sdvQrxqGSNVntpU4lyi2eP8hxGaymZ1hCkrNzImXHCeqrXSaifNAltzDvDbI6+olwRyos/civQygkHClg5IK4ztCyxNM2av+ulBxdi323jNMSj92aXvqQtR0AiUNDSyrAZC5qwzXzecY+snlrVmfwBe0f0G3FTAEX6519FU7qbXn6jKHtJsrEaPSl9d3gExp7EfhWWILlO6e/lnLH9peptrDqqC/kZwV9M8PFEsYdHCs+/Wy9pgnAIB+fRJKjd1gjfDOKKhWa3HAaqwAPUpUejGgI/N0kdoapeZzSnLF+jmkhlJyRxkMnriVb/zdoFfOfrE1XGMLl+U7V3VgqDNrJKy8CsK5njD1/juC2Hs9515Mc0CZFt50mztrsZeFPdvvC3IBUBosl1qzWCB92i2N5u0qopZ2jpmIJZimODQOloYBee6DZylVnnnb8Jr5/tmfoky4Za4Si8ijk7BqAtholBgmHCmWjcbQtiO6yq9qd/R4eyn32wkk/c2Rxmv073CqXFgVgKhwrZIPBSIfPqH18eVsW3s1wfGiSsQTF5pWUTmkOGOj0uXaAKJZvBOhUC6GsSeVXG+wtH9BdlOhY6RPIehx+0CaCNP+FQ="); + public static final SkinData CLANS_BUILDERS_BOX = new SkinData("eyJ0aW1lc3RhbXAiOjE1MDYxMTgxNjEwNDcsInByb2ZpbGVJZCI6IjI2YTVmMDc5ZTNkOTRkZGY5YzdjMjc4NTcxNGIzZWU2IiwicHJvZmlsZU5hbWUiOiJFMDgiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzNiNWVkZDcyYjZkNzY3YmNlYjIzZTcxM2Q1MzEzZjFjYTkyNjMwNWQ1MjFkZWQ2ZDQ4NzBjODZhM2ZmMjIzNzMifX19", "qQmbe4vZpjyDhs4kgjnbanqMm0z7i8pareN+eBaZ9xQRJQyh5D36hOr9tZXyMYt7IaHXqAoE9A2VSQN3tNzgY9fBqy8wb8kThtYN4aYfx9PDlrqX460o2Wp3QZhNNroOs8sCyViq0zKvdbWCQQlBs3ryQpoCCR878XXNJsWx+3aqBdT5mP7XeJw8RxL5vSgOkZuGbdou2+daJeX1KI/Q1dZUoLMRglIKr0iXgoXDZJAq9C9feNH72WUKT7RpbKpUj4ZFvSKb7i2/orbyoxdiTYa6XXkV/QaP8Mpe1O5wQ/EsaZNuBynK45OXtUyoduThBcqZzzyOmbAhjO6db7VgxxJ/9C7mUWe2DEYVaouYLMSNcnMvD21n/3NjBRdrWAHZq5+XzpkcXxX/SiB8Y6S+4ae0NMQClfJcOMpWpM43WaTQNvmmXWyiZNi4i/Y6aFQi2uvCQVdmOya8FVYcyXX5bGIZ6kyVVnlN1vDgZg+2mEyZUpjW5aJ547RCb0LKR/S1lwHUy+McmEpUDZUVXdFgwoNSUDiz7Dsmp9Pr1E3wyRK4WwF241OzPIxv1EJWfuMWYenY1BmUFAGpEAETWpv0QZXdixmMNVcXi5TjlzGNeHfhw8ruYWojjI49JfU/ryvZA+Qqm3uJ6GNUXrtTzRFrUoDv2O23y2xJZSjHOU6p0CA="); + public static final SkinData CLANS_SUPPLY_DROP = new SkinData("eyJ0aW1lc3RhbXAiOjE1MDYxMTgyNDk1MjMsInByb2ZpbGVJZCI6IjI2YTVmMDc5ZTNkOTRkZGY5YzdjMjc4NTcxNGIzZWU2IiwicHJvZmlsZU5hbWUiOiJFMDgiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2E3N2I4ZTQ1ZDE1ODdmM2I4ZGU3YzcyYjEyMTU4YTNhZTYzMjJlZGMxYjk4N2M4ODRlYzU3MmRjNDZiMjg2MCJ9fX0=", "Q3jw0EY0HIfa4YBcOmKhC8X16uf1m2UnZRCJ2sta0fOmYddElx+Bmk48i+e59awX/RxYjdf/TQNAvB3rjSIA9rGQj6zw0VgJIVFObCO+Ol5NbdH6QUXzF4r4s1S/Y24CBH3KAfp8rdhcUxuYrjgA+YR8Z9kXN9HMybaYFkZlMKoSvGuB2gcdyyvmrUApciBPF7n2IZvzcOU96wUZ0rPrpfiWkEMV+vslno24P4UWfp0w4+uUza2wG+YzrG34FWIdgO/rxYqYXGVsas2ZQGSXxZnt6BMtKHY/VR16MIlDHDGQ5uP6DLO+JfunxXGvDSRoYvH1hXyeFPnAAucixcl90B8hif7mKsUyV42L+qfgwdgrHa7YrvUEuGH30WZO0T9uvzFi1dRek/G4ltfIq2x109nhpje36sB3mDkjeXpYeBfi5cHvgeEkK0sExIXdiV3/+UzHeU4PB9bK6A3iI/jZ9kb/ElJCVuWbU8l4s4kEbaHXISTvNDGpm8QNaHtpuDGLTnsqsQKNgYgz6bigNDx2a5k+NMKV3+PTFuUM0es1G3Hghtdc1/m4UrLnF1NuCPO1zH0nDqQnTQ9EMFvx4Laq85NzNhStY2VqlNC1RAiQo9QXTd20ERvAZzpVpcsj/RDWJRPEnvzRbIyZFVsT/g29b7hyXlMlsJRgeLKgiSxPb5U="); + public static final SkinData CLANS_GILDED_SUPPLY_DROP = new SkinData("eyJ0aW1lc3RhbXAiOjE1MDYxMTgyODc4ODksInByb2ZpbGVJZCI6IjI2YTVmMDc5ZTNkOTRkZGY5YzdjMjc4NTcxNGIzZWU2IiwicHJvZmlsZU5hbWUiOiJFMDgiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzJkODc1ZGY4NzM3MDk1YjczZDQ5YmJkZTE5YjM5NDg0MzIxMjY5Y2MyNTU5YTlkMzQ2NWU1OGRiYTJkOWFiNSJ9fX0=", "Z07wjY/5re7JBLSK2Wo475mezAX9AkGf3agoYoDn5Sz92tyybyRk5OpqyIw+w/9RgsurpSbJWwKp3HWG2N67q+RUDdDV2goxBeywEfsemjZIIS/pHHvX8QVCG+owyVrE2t4LRn+Bps6ZaTMCH5xS9wiPUpuuSN2t6KG+OR29sobhlv/Vr4U0NLJ6S/RKdhDIqsVqGLA4T0XwCaMn7vtFLpedR1flF4V9qAHFoxjaSGVy12h9AzJHybNfTJWPy7dsI7aTPemO6joT+chUoJwOIGonzStUkk/kq+Y6GmQYeQcudRfQ/sH1rSt2hZ0LOuJ6DGz4eILhNiCMgAjSUEEkoC0hyTbRadWF6pBhkTiDJWOBraGnE1Jh7KiqbzALwh5UQ4U1ZSgergi1oICL8RC8ZzqNpOFBod/CKkQvCVa9rMgwuZ7HkS3pdp/NBeM/k6HvQC+peUawqGvKzOMdGGRmt1waQnrCQ+p7pB3VwWL6kMLFwDJOuReqJgxo5kIwpET5cKisO9iiCrFL9B++c0M2gcf4g785MpJnUmSc1ABXw2FdZXy7UQugK+HtYDN1vmmu+aGClKQ/GXTecnPeLLnl6X7XyJKAvPQ0NnKhunCxMuRtb1kdwQh+Mxn8cOihGimxCvIBzqonojeUr7SlIcBQ6DguzYDJ+mJoRX7skYnYECE="); // Comments this out for now, so it doesn't load the player profile diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/PlayerMap.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/PlayerMap.java index 5cb6e7758..bd110173c 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/PlayerMap.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/PlayerMap.java @@ -1,15 +1,7 @@ package mineplex.core.common.util; -import com.google.common.collect.Sets; -import org.apache.commons.lang3.Validate; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerQuitEvent; - -import javax.annotation.Nonnull; import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.Set; @@ -17,12 +9,21 @@ import java.util.UUID; import java.util.WeakHashMap; import java.util.concurrent.ConcurrentHashMap; +import javax.annotation.Nonnull; + +import org.apache.commons.lang3.Validate; +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; + public class PlayerMap implements Map { private static final Object LOCK = new Object(); private static final RemovalListener REMOVAL_LISTENER = new RemovalListener(); - private static final Set> ALL_PLAYER_MAPS = Sets.newSetFromMap(new WeakHashMap<>()); + private static final Set> ALL_PLAYER_MAPS = Collections.newSetFromMap(new WeakHashMap<>()); static { @@ -231,4 +232,4 @@ public class PlayerMap implements Map } } } -} +} \ No newline at end of file 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 1a8c443da..341de3aa3 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 @@ -9,16 +9,6 @@ import java.util.List; import java.util.Set; import java.util.UUID; -import net.minecraft.server.v1_8_R3.BlockPosition; -import net.minecraft.server.v1_8_R3.Blocks; -import net.minecraft.server.v1_8_R3.IBlockData; -import net.minecraft.server.v1_8_R3.Item; -import net.minecraft.server.v1_8_R3.MathHelper; -import net.minecraft.server.v1_8_R3.MinecraftKey; -import net.minecraft.server.v1_8_R3.NBTTagCompound; -import net.minecraft.server.v1_8_R3.TileEntityFlowerPot; -import net.minecraft.server.v1_8_R3.WorldServer; - import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.SkullType; @@ -47,6 +37,16 @@ import com.mojang.authlib.GameProfile; import mineplex.core.common.Pair; import mineplex.core.common.block.MultiBlockUpdaterAgent; import mineplex.core.common.skin.SkinData; +import net.minecraft.server.v1_8_R3.AxisAlignedBB; +import net.minecraft.server.v1_8_R3.BlockPosition; +import net.minecraft.server.v1_8_R3.Blocks; +import net.minecraft.server.v1_8_R3.IBlockData; +import net.minecraft.server.v1_8_R3.Item; +import net.minecraft.server.v1_8_R3.MathHelper; +import net.minecraft.server.v1_8_R3.MinecraftKey; +import net.minecraft.server.v1_8_R3.NBTTagCompound; +import net.minecraft.server.v1_8_R3.TileEntityFlowerPot; +import net.minecraft.server.v1_8_R3.WorldServer; public class UtilBlock { @@ -109,6 +109,7 @@ public class UtilBlock blockAirFoliageSet.add((byte) Material.AIR.getId()); blockAirFoliageSet.add((byte) Material.SAPLING.getId()); blockAirFoliageSet.add((byte) Material.LONG_GRASS.getId()); + blockAirFoliageSet.add((byte) Material.DOUBLE_PLANT.getId()); blockAirFoliageSet.add((byte) Material.DEAD_BUSH.getId()); blockAirFoliageSet.add((byte) Material.YELLOW_FLOWER.getId()); blockAirFoliageSet.add((byte) Material.RED_ROSE.getId()); @@ -628,6 +629,14 @@ public class UtilBlock return false; } + public static List getInBoundingBox(World world, AxisAlignedBB box) + { + Location l1 = new Location(world, box.a, box.b, box.c); + Location l2 = new Location(world, box.d, box.e, box.f); + + return getInBoundingBox(l1, l2); + } + public static ArrayList getInBoundingBox(Location a, Location b) { return getInBoundingBox(a, b, true); diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java index 07a2058c5..3dabf341d 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java @@ -947,21 +947,22 @@ public class UtilEnt **/ public static int getNewEntityId(boolean modifynumber) { - try - { - Field field = net.minecraft.server.v1_8_R3.Entity.class.getDeclaredField("entityCount"); - field.setAccessible(true); - int entityId = field.getInt(null); - if (modifynumber) { - field.set(null, Integer.valueOf(entityId + 1)); - } - return entityId; - } - catch (Exception ex) - { - ex.printStackTrace(); - } - return -1; + try + { + Field field = net.minecraft.server.v1_8_R3.Entity.class.getDeclaredField("entityCount"); + field.setAccessible(true); + int entityId = field.getInt(null); + if (modifynumber) + { + field.set(null, entityId + 1); + } + return entityId; + } + catch (Exception ex) + { + ex.printStackTrace(); + } + return -1; } public static Entity getEntityById(int entityId) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java index 47fd7594c..e9f182af0 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java @@ -670,7 +670,7 @@ public class UtilItem public static boolean isBoundless(Material material) { - return (_materials.get(material).contains(ItemCategory.BOUNDLESS)); + return material == null ? false : contains(material, ItemCategory.BOUNDLESS); } public static boolean isBoundless(ItemStack stack) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java index 5295e759a..550c36094 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java @@ -133,38 +133,6 @@ public class UtilPlayer return entry.trackedPlayers.contains(ep); } - - public static void hideFrom(Player player, Collection players) { - players.stream().forEach(p->p.hidePlayer(player)); - } - - public static void showFor(Player player, Collection players) { - players.stream().forEach(p->p.hidePlayer(player)); - } - - public static void hideFromAll(Player player, Collection except) { - UtilServer.getPlayersCollection().stream().filter(p->!except.contains(p)).forEach(p->p.hidePlayer(player)); - } - - public static void showForAll(Player player, Collection except) { - UtilServer.getPlayersCollection().stream().filter(p->!except.contains(p)).forEach(p->p.showPlayer(player)); - } - - public static void hideFrom(Player player, Player...players) { - hideFrom(player, Arrays.asList(players)); - } - - public static void showFor(Player player, Player...players) { - showFor(player, Arrays.asList(players)); - } - - public static void hideFromAll(Player player, Player...players) { - hideFromAll(player, Arrays.asList(players)); - } - - public static void showForAll(Player player, Player...players) { - showForAll(player, Arrays.asList(players)); - } public static boolean is1_9(Player player) { diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTextTop.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTextTop.java index bef877efd..a71666592 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTextTop.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTextTop.java @@ -1,8 +1,18 @@ package mineplex.core.common.util; import java.util.HashMap; +import java.util.Map; import java.util.UUID; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.scheduler.BukkitRunnable; + import mineplex.core.common.DummyEntity; import net.minecraft.server.v1_8_R3.DataWatcher; import net.minecraft.server.v1_8_R3.Entity; @@ -13,17 +23,6 @@ import net.minecraft.server.v1_8_R3.PacketPlayOutBossBar; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy; import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.scheduler.BukkitRunnable; - public class UtilTextTop { // Base Commands @@ -42,7 +41,7 @@ public class UtilTextTop public static final int EntityDragonId = 777777; public static final int EntityWitherId = 777778; public static final UUID BossUUID = UUID.fromString("178f5cde-2fb0-3e73-8296-967ec7e46748"); - private static HashMap _lastUpdated = new HashMap(); + private static Map _lastUpdated = new HashMap<>(); // Display public static void displayTextBar(final Player player, double healthPercent, String text) @@ -68,7 +67,7 @@ public class UtilTextTop } }; - runnable.runTaskLater(Bukkit.getPluginManager().getPlugins()[0], 20); + runnable.runTaskLater(UtilServer.getPlugin(), 20); if (UtilPlayer.is1_9(player)) { diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/particles/ColoredParticle.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/particles/ColoredParticle.java index 03cb5e95e..510da7011 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/particles/ColoredParticle.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/particles/ColoredParticle.java @@ -1,13 +1,12 @@ package mineplex.core.common.util.particles; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilServer; import org.bukkit.Location; import org.bukkit.entity.Player; +import mineplex.core.common.util.UtilParticle; + public class ColoredParticle extends ParticleData { - private ParticleColor _color; public ColoredParticle(UtilParticle.ParticleType particleType, ParticleColor color, Location location) @@ -45,21 +44,8 @@ public class ColoredParticle extends ParticleData } } - @Override - public void display(UtilParticle.ViewDist viewDist) - { - display(viewDist, UtilServer.getPlayers()); - } - - @Override - public void display() - { - display(UtilParticle.ViewDist.NORMAL); - } - public void setColor(ParticleColor color) { _color = color; } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/particles/ParticleData.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/particles/ParticleData.java index b0eaa5b80..2df994067 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/particles/ParticleData.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/particles/ParticleData.java @@ -7,7 +7,6 @@ import org.bukkit.entity.Player; public class ParticleData { - protected UtilParticle.ParticleType _particleType; protected Location _location; @@ -18,8 +17,8 @@ public class ParticleData } /** - * Displays the particles for all the players with a different ammount - * @param count the ammount of particles + * Displays the particles for all the players with a different amount + * @param count the amount of particles */ public void display(int count) { @@ -73,5 +72,4 @@ public class ParticleData { return _location; } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/weight/WeightSet.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/weight/WeightSet.java index 17ee9245f..9744e51b3 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/weight/WeightSet.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/weight/WeightSet.java @@ -9,10 +9,9 @@ import java.util.stream.Collectors; public class WeightSet { - private static Random random = new Random(); - private Set> _weights = new HashSet>(); + private Set> _weights = new HashSet<>(); private volatile transient Set _keyset; @@ -50,10 +49,18 @@ public class WeightSet computeKeyset(); } - public void add(int weight, T element) + public Weight add(int weight, T element) { - _weights.add(new Weight(weight, element)); + Weight w = new Weight<>(weight, element); + _weights.add(w); computeKeyset(); + + return w; + } + + public void remove(Weight weight) + { + _weights.remove(weight); } private int getTotalWeight() @@ -89,11 +96,11 @@ public class WeightSet public Set elements() { - return this._keyset; + return _keyset; } private void computeKeyset() { _keyset = Collections.unmodifiableSet(_weights.stream().map(Weight::getValue).collect(Collectors.toSet())); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java index 0c6a0e75e..8089ec178 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java @@ -617,7 +617,6 @@ public class CoreClientManager extends MiniPlugin if (client.hasPermission(Perm.JOIN_FULL)) { event.allow(); - event.setResult(PlayerLoginEvent.Result.ALLOWED); return; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/permissions/PermissionGroup.java b/Plugins/Mineplex.Core/src/mineplex/core/account/permissions/PermissionGroup.java index d5aea51eb..5bcc454f1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/permissions/PermissionGroup.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/permissions/PermissionGroup.java @@ -50,7 +50,7 @@ public enum PermissionGroup //SUB-GROUPS QA("qa", "", "Members of the Quality Assurance team.", ChatColor.WHITE, 50, false), QAM("qam", "", "Managers of the Quality Assurance team.", ChatColor.WHITE, 50, false, PermissionGroup.QA), - CMOD("cmod", "", "Members of the Clans Management team.", ChatColor.WHITE, 32, false), + CMOD("cmod", "", "Members of the Clans Management team.", ChatColor.WHITE, 46, false), TM("tm", "", "Members of the Trainee Management team.", ChatColor.WHITE, 52, false), MC("mc", "", "Members of the Moderator Coordination team.", ChatColor.WHITE, 49, false), EVENTMOD("eventmod", "", "Members of the Event Management team.", ChatColor.WHITE, -1, false), diff --git a/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestore.java b/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestore.java index c2859d691..1befc2493 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestore.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestore.java @@ -5,6 +5,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; +import java.util.Map; import java.util.Map.Entry; import org.bukkit.Effect; @@ -15,6 +16,7 @@ import org.bukkit.block.BlockFace; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockPhysicsEvent; import org.bukkit.event.block.BlockPistonExtendEvent; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.world.ChunkUnloadEvent; @@ -29,7 +31,7 @@ import mineplex.core.updater.event.UpdateEvent; @ReflectivelyCreateMiniPlugin public class BlockRestore extends MiniPlugin { - private HashMap _blocks = new HashMap(); + private Map _blocks = new HashMap<>(); private LinkedList _restoreMaps; private BlockRestore() @@ -266,7 +268,7 @@ public class BlockRestore extends MiniPlugin return null; } - public HashMap getBlocks() + public Map getBlocks() { return _blocks; } @@ -282,6 +284,15 @@ public class BlockRestore extends MiniPlugin { _restoreMaps.remove(blockRestore); } + + @EventHandler + public void onBlockPhysics(BlockPhysicsEvent event) + { + if (_blocks.containsKey(event.getBlock())) + { + event.setCancelled(true); + } + } @Override public void disable() @@ -294,4 +305,4 @@ public class BlockRestore extends MiniPlugin restoreAll(); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java index dc466f5b8..0c7d5fcdc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java @@ -365,7 +365,7 @@ public class Chat extends MiniPlugin for (Function filter : _highPriorityFilters) { - if (filter.apply(event).booleanValue()) + if (filter.apply(event)) { event.setCancelled(true); return; @@ -433,7 +433,7 @@ public class Chat extends MiniPlugin for (Function filter : _lowPriorityFilters) { - if (filter.apply(event).booleanValue()) + if (filter.apply(event)) { event.setCancelled(true); return; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/community/CommunityJoinRequestsPage.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/community/CommunityJoinRequestsPage.java index 1c5c69c92..e1f82de22 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/community/CommunityJoinRequestsPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/community/CommunityJoinRequestsPage.java @@ -137,7 +137,7 @@ public class CommunityJoinRequestsPage extends CommunitiesGUIPage @EventHandler public void onMembershipUpdate(CommunityMembershipUpdateEvent event) { - if (event.getCommunity().getId().intValue() != _community.getId().intValue()) + if (event.getCommunity().getId() != _community.getId()) { return; } @@ -155,7 +155,7 @@ public class CommunityJoinRequestsPage extends CommunitiesGUIPage @EventHandler public void onRequestsUpdate(CommunityJoinRequestsUpdateEvent event) { - if (event.getCommunity().getId().intValue() != _community.getId().intValue()) + if (event.getCommunity().getId() != _community.getId()) { return; } @@ -165,7 +165,7 @@ public class CommunityJoinRequestsPage extends CommunitiesGUIPage @EventHandler public void onCommunityDisband(CommunityDisbandEvent event) { - if (_community.getId().intValue() == event.getCommunity().getId().intValue()) + if (_community.getId() == event.getCommunity().getId()) { Viewer.closeInventory(); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/community/CommunityMembersPage.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/community/CommunityMembersPage.java index 720d5a41c..2513f0e69 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/community/CommunityMembersPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/community/CommunityMembersPage.java @@ -158,7 +158,7 @@ public class CommunityMembersPage extends CommunitiesGUIPage @EventHandler public void onRequestsUpdate(CommunityJoinRequestsUpdateEvent event) { - if (event.getCommunity().getId().intValue() != _community.getId().intValue()) + if (event.getCommunity().getId() != _community.getId()) { return; } @@ -171,7 +171,7 @@ public class CommunityMembersPage extends CommunitiesGUIPage @EventHandler public void onMembershipUpdate(CommunityMembershipUpdateEvent event) { - if (event.getCommunity().getId().intValue() != _community.getId().intValue()) + if (event.getCommunity().getId() != _community.getId()) { return; } @@ -182,7 +182,7 @@ public class CommunityMembersPage extends CommunitiesGUIPage @EventHandler public void onCommunityDisband(CommunityDisbandEvent event) { - if (_community.getId().intValue() == event.getCommunity().getId().intValue()) + if (_community.getId() == event.getCommunity().getId()) { Viewer.closeInventory(); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/community/CommunitySettingsPage.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/community/CommunitySettingsPage.java index 56e1d0ba4..44031723a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/community/CommunitySettingsPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/community/CommunitySettingsPage.java @@ -109,7 +109,7 @@ public class CommunitySettingsPage extends CommunitiesGUIPage @EventHandler public void onRequestsUpdate(CommunityJoinRequestsUpdateEvent event) { - if (event.getCommunity().getId().intValue() != _community.getId().intValue()) + if (event.getCommunity().getId() != _community.getId()) { return; } @@ -122,7 +122,7 @@ public class CommunitySettingsPage extends CommunitiesGUIPage @EventHandler public void onMembershipUpdate(CommunityMembershipUpdateEvent event) { - if (event.getCommunity().getId().intValue() != _community.getId().intValue()) + if (event.getCommunity().getId() != _community.getId()) { return; } @@ -136,7 +136,7 @@ public class CommunitySettingsPage extends CommunitiesGUIPage @EventHandler public void onSettingsUpdate(CommunitySettingUpdateEvent event) { - if (event.getCommunity().getId().intValue() != _community.getId().intValue()) + if (event.getCommunity().getId() != _community.getId()) { return; } @@ -146,7 +146,7 @@ public class CommunitySettingsPage extends CommunitiesGUIPage @EventHandler public void onCommunityDisband(CommunityDisbandEvent event) { - if (_community.getId().intValue() == event.getCommunity().getId().intValue()) + if (_community.getId() == event.getCommunity().getId()) { Viewer.closeInventory(); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePlayer.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePlayer.java index a4eb5dc4a..8951f526a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePlayer.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePlayer.java @@ -72,7 +72,7 @@ public class DisguisePlayer extends DisguiseHuman private DisguisePlayer(Entity entity) { super(EntityType.PLAYER, entity); - this._originalProfile = entity instanceof Player ? UtilGameProfile.getGameProfile((Player) entity) : null; + _originalProfile = entity instanceof Player ? UtilGameProfile.getGameProfile((Player) entity) : null; } /** @@ -82,7 +82,7 @@ public class DisguisePlayer extends DisguiseHuman { this(entity); - this._profile = UtilGameProfile.clone(gameProfile); + _profile = UtilGameProfile.clone(gameProfile); } /** @@ -101,16 +101,16 @@ public class DisguisePlayer extends DisguiseHuman { this(entity); - this._requestedUsername = username; - this._requestedSkin = skin; + _requestedUsername = username; + _requestedSkin = skin; } public DisguisePlayer(Entity entity, String username, SkinData skinData) { this(entity); - this._requestedUsername = username; - this._requestedSkinData = skinData; + _requestedUsername = username; + _requestedSkinData = skinData; } /** @@ -121,7 +121,7 @@ public class DisguisePlayer extends DisguiseHuman */ public Future initialize(Runnable onComplete) { - if (this._profile != null && this._profile.isComplete()) + if (_profile != null && _profile.isComplete()) { onComplete.run(); return CompletableFuture.completedFuture(null); @@ -139,8 +139,8 @@ public class DisguisePlayer extends DisguiseHuman _requestedSkinData = SkinData.constructFromGameProfile(profileOfSkin, true, true); } - this._profile = new GameProfile(profileOfUsername.getId(), profileOfUsername.getName()); - this._profile.getProperties().put("textures", _requestedSkinData.getProperty()); + _profile = new GameProfile(profileOfUsername.getId(), profileOfUsername.getName()); + _profile.getProperties().put("textures", _requestedSkinData.getProperty()); } catch (Exception e) { @@ -171,8 +171,8 @@ public class DisguisePlayer extends DisguiseHuman public void showInTabList(boolean show, int delay) { - this._showInTabList = show; - this._showInTabListDelay = delay; + _showInTabList = show; + _showInTabListDelay = delay; } public BlockFace getSleepingDirection() @@ -446,12 +446,12 @@ public class DisguisePlayer extends DisguiseHuman public boolean showInTabList() { - return this._showInTabList; + return _showInTabList; } public int getShowInTabListDelay() { - return this._showInTabListDelay; + return _showInTabListDelay; } private WorldSettings.EnumGamemode getAppropriateGamemode() @@ -465,25 +465,25 @@ public class DisguisePlayer extends DisguiseHuman private GameProfile getSelfProfile() { - GameProfile selfProfile = new GameProfile(getOriginalUUID(), this._profile.getName()); - selfProfile.getProperties().putAll(this._profile.getProperties()); + GameProfile selfProfile = new GameProfile(getOriginalUUID(), _profile.getName()); + selfProfile.getProperties().putAll(_profile.getProperties()); return selfProfile; } public boolean replaceOriginalName() { - return this._replaceOriginalName; + return _replaceOriginalName; } public int replaceOriginalNameDelay() { - return this._replaceOriginalNameDelay; + return _replaceOriginalNameDelay; } public void setReplaceOriginalName(boolean b, int delay) { - this._replaceOriginalName = b; - this._replaceOriginalNameDelay = delay; + _replaceOriginalName = b; + _replaceOriginalNameDelay = delay; } public Hologram getHologram() @@ -504,16 +504,14 @@ public class DisguisePlayer extends DisguiseHuman private UUID getOriginalUUID() { - if (this._originalProfile.getProperties().containsKey(PlayerDisguiseManager.ORIGINAL_UUID_KEY)) + if (_originalProfile.getProperties().containsKey(PlayerDisguiseManager.ORIGINAL_UUID_KEY)) { try { - return UUID.fromString(this._originalProfile.getProperties().get(PlayerDisguiseManager.ORIGINAL_UUID_KEY).iterator().next().getValue()); - } - catch (IllegalArgumentException ignored) - { + return UUID.fromString(_originalProfile.getProperties().get(PlayerDisguiseManager.ORIGINAL_UUID_KEY).iterator().next().getValue()); } + catch (IllegalArgumentException ignored) {} } - return this._originalProfile.getId(); + return _originalProfile.getId(); } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/gold/GoldRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/gold/GoldRepository.java index 649257494..97291953c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/gold/GoldRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/gold/GoldRepository.java @@ -1,19 +1,22 @@ package mineplex.core.donation.gold; -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; import java.sql.SQLException; +import org.bukkit.Bukkit; + +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.UtilServer; +import mineplex.serverdata.database.DBPool; + 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 static final int DUPLICATE_PRIMARY_KEY_ERROR_CODE = 1062; + private static final String CREATE_TABLE = "CREATE TABLE clansGold (serverId int(11) not null, accountId int(11) not null, gold int not null, primary key (serverId, accountId), index valueIndex (serverId, accountId, gold), index goldIndex (serverId, gold), foreign key (serverId) references clanServer(id), foreign key (accountId) references accounts(id))"; + private static final String INSERT_ACCOUNT_GOLD = "INSERT INTO clansGold (serverId, accountId, gold) VALUES (?, ?, ?);"; + private static final String UPDATE_ACCOUNT_GOLD = "UPDATE clansGold SET gold=gold+? WHERE serverId=? AND accountId=? AND (gold+? > 0 OR gold+? = 0);"; + private static final String SET_ACCOUNT_GOLD = "INSERT INTO clansGold (serverId, accountId, gold) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE gold=VALUES(gold);"; public GoldRepository() {} @@ -23,16 +26,48 @@ public class GoldRepository { try (Connection connection = DBPool.getAccount().getConnection()) { - 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 (PreparedStatement statement = connection.prepareStatement(INSERT_ACCOUNT_GOLD)) { - Bukkit.getScheduler().runTask(UtilServer.getPlugin(), () -> callback.run(true)); + statement.setInt(1, serverId); + statement.setInt(2, accountId); + statement.setInt(3, Math.max(gold, 0)); + statement.executeUpdate(); + + final boolean success = gold >= 0; + if (callback != null) + { + Bukkit.getScheduler().runTask(UtilServer.getPlugin(), () -> callback.run(success)); + } + } + catch (SQLException ex) + { + if (ex.getErrorCode() == DUPLICATE_PRIMARY_KEY_ERROR_CODE) + { + try (PreparedStatement statement = connection.prepareStatement(UPDATE_ACCOUNT_GOLD)) + { + statement.setInt(1, gold); + statement.setInt(2, serverId); + statement.setInt(3, accountId); + statement.setInt(4, gold); + statement.setInt(5, gold); + int updateCount = statement.executeUpdate(); + + final boolean success = updateCount > 0; + + if (callback != null) + { + Bukkit.getScheduler().runTask(UtilServer.getPlugin(), () -> callback.run(success)); + } + } + } + else + { + ex.printStackTrace(); + if (callback != null) + { + Bukkit.getScheduler().runTask(UtilServer.getPlugin(), () -> callback.run(false)); + } + } } } catch (SQLException e) @@ -51,7 +86,7 @@ public class GoldRepository { if (gold < 0) { - throw new IllegalArgumentException("gold cannot be negative"); + throw new IllegalArgumentException("Gold cannot be negative"); } Bukkit.getScheduler().runTaskAsynchronously(UtilServer.getPlugin(), () -> @@ -62,7 +97,6 @@ public class GoldRepository statement.setInt(1, serverId); statement.setInt(2, accountId); statement.setInt(3, gold); - statement.setInt(4, gold); statement.executeUpdate(); if (callback != null) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemFleshHook.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemFleshHook.java index 82004ff2b..e15b66832 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemFleshHook.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemFleshHook.java @@ -99,4 +99,10 @@ public class ItemFleshHook extends ItemGadget implements IThrown { data.getThrown().remove(); } -} + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemFreezeCannon.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemFreezeCannon.java index ce3e899d1..68a45639d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemFreezeCannon.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemFreezeCannon.java @@ -182,6 +182,12 @@ public class ItemFreezeCannon extends ItemGadget implements IThrown smash(data.getThrown()); } + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } + public void smash(Entity ent) { //Effect @@ -190,5 +196,4 @@ public class ItemFreezeCannon extends ItemGadget implements IThrown //Remove ent.remove(); } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemMelonLauncher.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemMelonLauncher.java index 30c732740..6418d54bc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemMelonLauncher.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemMelonLauncher.java @@ -101,6 +101,12 @@ public class ItemMelonLauncher extends ItemGadget implements IThrown smash(data.getThrown()); } + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } + public void smash(Entity ent) { //Effect @@ -160,4 +166,4 @@ public class ItemMelonLauncher extends ItemGadget implements IThrown item.remove(); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemPartyPopper.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemPartyPopper.java index 0554acfe2..a4702fea0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemPartyPopper.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemPartyPopper.java @@ -108,6 +108,12 @@ public class ItemPartyPopper extends ItemGadget implements IThrown Explode(data); } + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } + @EventHandler public void particleTrail(UpdateEvent event) { @@ -140,4 +146,4 @@ public class ItemPartyPopper extends ItemGadget implements IThrown data.getThrown().remove(); */ } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBat.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBat.java index 4225b2c6b..c2b3300e0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBat.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBat.java @@ -152,6 +152,12 @@ public class MorphBat extends MorphGadget implements IThrown { data.getThrown().remove(); } + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } @EventHandler public void Flap(PlayerToggleFlightEvent event) @@ -201,4 +207,4 @@ public class MorphBat extends MorphGadget implements IThrown } } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphChristmasKing.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphChristmasKing.java index 24803972f..934ef1238 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphChristmasKing.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphChristmasKing.java @@ -25,7 +25,6 @@ import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilText; import mineplex.core.disguise.disguises.DisguiseSkeleton; import mineplex.core.gadget.GadgetManager; @@ -35,11 +34,10 @@ import mineplex.core.recharge.Recharge; import mineplex.core.recharge.RechargeData; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import mineplex.core.visibility.VisibilityManager; public class MorphChristmasKing extends MorphGadget { - private Map _snowball = new WeakHashMap(); + private Map _snowball = new WeakHashMap<>(); public MorphChristmasKing(GadgetManager manager) { @@ -69,9 +67,6 @@ public class MorphChristmasKing extends MorphGadget UtilMorph.disguise(player, disguise, Manager); player.getInventory().setHelmet(new ItemStack(Material.JACK_O_LANTERN)); - - VisibilityManager.Instance.setVisibility(player, false, UtilServer.getPlayers()); - VisibilityManager.Instance.setVisibility(player, true, UtilServer.getPlayers()); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPumpkinKing.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPumpkinKing.java index c309fb7a4..c161f84ee 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPumpkinKing.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPumpkinKing.java @@ -1,11 +1,10 @@ package mineplex.core.gadget.gadgets.morph; +import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Random; -import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity; - import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Item; @@ -15,8 +14,6 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerToggleSneakEvent; import org.bukkit.inventory.ItemStack; -import com.google.common.collect.Lists; - import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.LineFormat; @@ -26,7 +23,6 @@ import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilText; import mineplex.core.disguise.disguises.DisguiseBlock; import mineplex.core.disguise.disguises.DisguiseSkeleton; @@ -39,13 +35,13 @@ import mineplex.core.packethandler.PacketInfo; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import mineplex.core.visibility.VisibilityManager; +import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity; public class MorphPumpkinKing extends MorphGadget implements IPacketHandler { private static final int CROWN_POINTS = 12; - private List _bombs = Lists.newArrayList(); + private List _bombs = new ArrayList<>(); public MorphPumpkinKing(GadgetManager manager) { @@ -75,9 +71,6 @@ public class MorphPumpkinKing extends MorphGadget implements IPacketHandler UtilMorph.disguise(player, disguise, Manager); player.getInventory().setHelmet(new ItemStack(Material.JACK_O_LANTERN)); - - VisibilityManager.Instance.setVisibility(player, false, UtilServer.getPlayers()); - VisibilityManager.Instance.setVisibility(player, true, UtilServer.getPlayers()); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSquid.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSquid.java index 34bd79a73..1cb807f6e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSquid.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSquid.java @@ -155,5 +155,10 @@ public class MorphSquid extends MorphGadget implements IThrown { data.getThrown().remove(); } - -} + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } +} \ No newline at end of file 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 f4cf0f975..e5406a120 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 @@ -141,6 +141,12 @@ public class MorphVillager extends MorphGadget implements IThrown { } + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } @EventHandler public void Pickup(PlayerPickupItemEvent event) @@ -175,4 +181,4 @@ public class MorphVillager extends MorphGadget implements IThrown } } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCandyCane.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCandyCane.java index e9e572f19..ed29b8663 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCandyCane.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCandyCane.java @@ -81,7 +81,6 @@ public class ParticleCandyCane extends ParticleGadget { Double y = _map.get(p.getUniqueId()); if (y == null) return 3; - return y.doubleValue(); + return y; } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectBabyChicken.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectBabyChicken.java index d7d20aa75..ddab0433d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectBabyChicken.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectBabyChicken.java @@ -3,6 +3,7 @@ package mineplex.core.gadget.gadgets.wineffect; import java.util.*; import java.util.Map.Entry; +import mineplex.core.Managers; import mineplex.core.common.util.*; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; @@ -12,9 +13,12 @@ import mineplex.core.gadget.types.WinEffectGadget; import mineplex.core.hologram.Hologram; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.visibility.VisibilityManager; import net.minecraft.server.v1_8_R3.EntityCreature; import net.minecraft.server.v1_8_R3.PacketPlayOutEntity.PacketPlayOutRelEntityMove; import net.minecraft.server.v1_8_R3.PathfinderGoal; + +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; @@ -52,7 +56,7 @@ public class WinEffectBabyChicken extends WinEffectGadget _tick = 0; List circle = UtilShapes.getPointsInCircle(getBaseLocation(), _team.size(), 3); - for(int i = 0; i < _team.size(); i++) + for (int i = 0; i < _team.size(); i++) { Player p = _team.get(i); Location l = circle.get(i); @@ -72,8 +76,9 @@ public class WinEffectBabyChicken extends WinEffectGadget chicken.setCustomNameVisible(true); UtilEnt.removeGoalSelectors(chicken); - - UtilPlayer.hideFromAll(player); + + VisibilityManager vm = Managers.require(VisibilityManager.class); + Bukkit.getOnlinePlayers().forEach(pl -> vm.hidePlayer(pl, player, "Baby Chicken Win Effect")); return chicken; } @@ -87,11 +92,11 @@ public class WinEffectBabyChicken extends WinEffectGadget _tick++; - if(_tick < 20*2) + if (_tick < 20*2) { return; } - else if(_tick == 20*2) + else if (_tick == 20*2) { Location loc = _npc.getEntity().getBukkitEntity().getLocation(); @@ -100,7 +105,7 @@ public class WinEffectBabyChicken extends WinEffectGadget UtilParticle.PlayParticleToAll(ParticleType.EXPLODE, loc.clone().add(0, 1, 0), 0.3f, 0.6f, 0.3f, 0.07f, 200, ViewDist.NORMAL); UtilParticle.PlayParticleToAll(ParticleType.EXPLODE, loc.clone().add(0, 0.3, 0), 0.7f, 0.1f, 0.7f, 0.07f, 200, ViewDist.NORMAL); - for(int i = 0; i < 10; i++) + for (int i = 0; i < 10; i++) { Vector v = Vector.getRandom().subtract(Vector.getRandom()).multiply(0.25).setY(0.5); UtilItem.dropItem(new ItemStack(Material.EGG), loc, false, false, 8*20, false).setVelocity(v); @@ -142,24 +147,30 @@ public class WinEffectBabyChicken extends WinEffectGadget e.getKey().setLocation(e.getKey().getLocation().add(e.getValue())); } - for(Chicken c : _teamChickens) + for (Chicken c : _teamChickens) { UtilEnt.CreatureLook(c, _chicken); } - } @Override public void finish() { - UtilPlayer.showForAll(_player); + VisibilityManager vm = Managers.require(VisibilityManager.class); + Bukkit.getOnlinePlayers().forEach(pl -> + { + vm.showPlayer(pl, _player, "Baby Chicken Win Effect"); + _team.forEach(p -> + { + vm.showPlayer(pl, p, "Baby Chicken Win Effect"); + }); + }); _text.keySet().forEach(h -> h.stop()); _text.clear(); _chicken.remove(); UtilParticle.PlayParticleToAll(ParticleType.EXPLODE, _chicken.getLocation().add(0, 0.15, 0), 0.3f, 0.3f, 0.3f, 0.1f, 50, ViewDist.NORMAL); _chicken = null; _teamChickens.forEach(c -> c.remove()); - _team.forEach(p -> UtilPlayer.showForAll(p)); } @Override @@ -205,5 +216,4 @@ public class WinEffectBabyChicken extends WinEffectGadget _ent.getNavigation().a(loc.getX(), loc.getY(), loc.getZ(), _speed); } } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectHalloween.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectHalloween.java index d977a7301..ff479cf61 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectHalloween.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectHalloween.java @@ -4,6 +4,7 @@ import java.awt.Color; import java.util.ArrayList; import java.util.List; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; @@ -12,6 +13,7 @@ import org.bukkit.entity.Skeleton; import org.bukkit.event.EventHandler; import org.bukkit.inventory.ItemStack; +import mineplex.core.Managers; import mineplex.core.common.skin.SkinData; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; @@ -31,6 +33,7 @@ import mineplex.core.particleeffects.BabyFireworkEffect; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.core.utils.UtilVariant; +import mineplex.core.visibility.VisibilityManager; public class WinEffectHalloween extends WinEffectGadget { @@ -72,9 +75,13 @@ public class WinEffectHalloween extends WinEffectGadget @Override public void finish() { - UtilPlayer.showForAll(_player); - _team.forEach(p -> UtilPlayer.showForAll(p)); - _nonTeam.forEach(p -> UtilPlayer.showForAll(p)); + VisibilityManager vm = Managers.require(VisibilityManager.class); + Bukkit.getOnlinePlayers().forEach(pl -> + { + vm.showPlayer(pl, _player, "Halloween Win Effect"); + _team.forEach(p -> vm.showPlayer(pl, p, "Halloween Win Effect")); + _nonTeam.forEach(p -> vm.showPlayer(pl, p, "Halloween Win Effect")); + }); _disguisePlayers.forEach(d -> d.getEntity().getBukkitEntity().remove()); _disguisePlayers.clear(); } @@ -123,7 +130,8 @@ public class WinEffectHalloween extends WinEffectGadget _npc.getEntity().getBukkitEntity().remove(); spawnSkeleton(); spawnGhosts(); - UtilPlayer.hideFromAll(_player); + VisibilityManager vm = Managers.require(VisibilityManager.class); + Bukkit.getOnlinePlayers().forEach(pl -> vm.hidePlayer(pl, _player, "Halloween Win Effect")); _player.getWorld().playSound(getBaseLocation(), Sound.CAT_MEOW, .5f, .5f); } @@ -145,6 +153,7 @@ public class WinEffectHalloween extends WinEffectGadget { int i = 0; List circle = UtilShapes.getPointsInCircle(getBaseLocation(), _nonTeam.size(), 7); + VisibilityManager vm = Managers.require(VisibilityManager.class); for (Player player : _nonTeam) { ItemStack playerHead = UtilSkull.getPlayerHead(player.getName(), player.getName() + " skull", null); @@ -157,7 +166,7 @@ public class WinEffectHalloween extends WinEffectGadget DisguisePlayer disguisePlayer = getNPC(player, ghostLoc, SkinData.GHOST); disguisePlayer.setHelmet(playerHead); UtilEnt.CreatureLook(disguisePlayer.getEntity().getBukkitEntity(), getBaseLocation()); - UtilPlayer.hideFromAll(player); + Bukkit.getOnlinePlayers().forEach(pl -> vm.hidePlayer(pl, player, "Halloween Win Effect")); for (int j = 0; j < 5; j++) { playFirework(ghostLoc.clone().add(0, 1, 0), j, false); @@ -183,5 +192,4 @@ public class WinEffectHalloween extends WinEffectGadget babyFireworkEffect.setCount(6); babyFireworkEffect.start(); } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/WinEffectGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/WinEffectGadget.java index 046f74787..00bfdf3e7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/WinEffectGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/WinEffectGadget.java @@ -6,6 +6,7 @@ import java.util.ArrayList; import java.util.List; import java.util.UUID; +import org.bukkit.Bukkit; import org.bukkit.Color; import org.bukkit.FireworkEffect; import org.bukkit.GameMode; @@ -25,18 +26,19 @@ import org.bukkit.util.Vector; import com.mojang.authlib.GameProfile; import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.Managers; import mineplex.core.common.block.schematic.Schematic; import mineplex.core.common.block.schematic.UtilSchematic; import mineplex.core.common.skin.SkinData; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.gadget.GadgetManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.visibility.VisibilityManager; /** * A wrapper for different win effects @@ -111,7 +113,12 @@ public abstract class WinEffectGadget extends Gadget } finally { - UtilServer.getPlayersCollection().forEach(UtilPlayer::showForAll); + VisibilityManager vm = Managers.require(VisibilityManager.class); + + Bukkit.getOnlinePlayers().forEach(p -> + { + Bukkit.getOnlinePlayers().forEach(pl -> vm.showPlayer(p, pl, "Inside Win Effect")); + }); _player = null; _baseLocation = null; _team.clear(); @@ -229,11 +236,15 @@ public abstract class WinEffectGadget extends Gadget { createBarriers(loc); - BukkitRunnable bRunnable = new BukkitRunnable() { + BukkitRunnable bRunnable = new BukkitRunnable() + { @Override - public void run() { - for(Player p : UtilServer.getPlayers()) { - UtilPlayer.hideFromAll(p); + public void run() + { + VisibilityManager vm = Managers.require(VisibilityManager.class); + for (Player p : UtilServer.getPlayers()) + { + Bukkit.getOnlinePlayers().forEach(pl -> vm.hidePlayer(pl, p, "Inside Win Effect")); p.eject(); p.teleport(loc); p.setGameMode(GameMode.ADVENTURE); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/hologram/Hologram.java b/Plugins/Mineplex.Core/src/mineplex/core/hologram/Hologram.java index 6ad1eb63e..5d6e016f6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/hologram/Hologram.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/hologram/Hologram.java @@ -5,17 +5,9 @@ import java.util.Arrays; import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Set; import java.util.UUID; -import net.minecraft.server.v1_8_R3.DataWatcher; -import net.minecraft.server.v1_8_R3.EntityArmorStand; -import net.minecraft.server.v1_8_R3.Packet; -import net.minecraft.server.v1_8_R3.PacketPlayOutEntity; -import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy; -import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata; -import net.minecraft.server.v1_8_R3.PacketPlayOutEntityTeleport; -import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; - import org.bukkit.Location; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; @@ -23,6 +15,14 @@ import org.bukkit.util.Vector; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilPlayer; +import net.minecraft.server.v1_8_R3.DataWatcher; +import net.minecraft.server.v1_8_R3.EntityArmorStand; +import net.minecraft.server.v1_8_R3.Packet; +import net.minecraft.server.v1_8_R3.PacketPlayOutEntity; +import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy; +import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata; +import net.minecraft.server.v1_8_R3.PacketPlayOutEntityTeleport; +import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; /** * Floating text object with interaction and entity follow capabilities. @@ -34,7 +34,7 @@ public class Hologram { /** * 1.7 packets uses both EntityIDs while 1.8 uses only the first. */ - private ArrayList _entityIds = new ArrayList<>(); + private List _entityIds = new ArrayList<>(); private Entity _followEntity; private HologramManager _hologramManager; private String[] _hologramText = new String[0]; @@ -49,8 +49,8 @@ public class Hologram { private boolean _makeSpawnPackets = true; private Packet[] _packets1_8; private Packet[] _packets1_9; - private HashSet _playersInList = new HashSet<>(); - private ArrayList _playersTracking = new ArrayList<>(); + private Set _playersInList = new HashSet<>(); + private List _playersTracking = new ArrayList<>(); private boolean _removeEntityDeath; private HologramTarget _target = HologramTarget.BLACKLIST; private int _viewDistance = 70; @@ -223,7 +223,7 @@ public class Hologram { /** * @return The list of players that are in the holograms whitelist or blacklist. */ - protected ArrayList getPlayersTracking() + protected List getPlayersTracking() { return _playersTracking; } @@ -334,7 +334,7 @@ public class Hologram { for (int i = _entityIds.size(); i < _hologramText.length; i++) { - _entityIds.add(Integer.valueOf(UtilEnt.getNewEntityId())); + _entityIds.add(UtilEnt.getNewEntityId()); } } else diff --git a/Plugins/Mineplex.Core/src/mineplex/core/incognito/IncognitoManager.java b/Plugins/Mineplex.Core/src/mineplex/core/incognito/IncognitoManager.java index 0654c5361..e023cc0ea 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/incognito/IncognitoManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/incognito/IncognitoManager.java @@ -12,6 +12,7 @@ import org.bukkit.event.player.PlayerKickEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.java.JavaPlugin; +import mineplex.core.Managers; import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.Permission; @@ -28,6 +29,7 @@ import mineplex.core.packethandler.PacketHandler; import mineplex.core.preferences.PreferencesManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.visibility.VisibilityManager; public class IncognitoManager extends MiniDbClientPlugin { @@ -73,6 +75,8 @@ public class IncognitoManager extends MiniDbClientPlugin public boolean toggle(Player caller) { boolean enabled = !Get(caller).Status; + + VisibilityManager vm = Managers.require(VisibilityManager.class); IncognitoStatusChangeEvent event = UtilServer.CallEvent(new IncognitoStatusChangeEvent(caller, enabled)); @@ -89,7 +93,7 @@ public class IncognitoManager extends MiniDbClientPlugin { for (Player other : UtilServer.getPlayers()) { - other.showPlayer(caller); + vm.showPlayer(other, caller, "Incognito Mode"); } } } @@ -104,6 +108,8 @@ public class IncognitoManager extends MiniDbClientPlugin { Player player = event.getPlayer(); + VisibilityManager vm = Managers.require(VisibilityManager.class); + if (Get(event.getPlayer()).Status && !_clientManager.Get(event.getPlayer()).hasPermission(Perm.USE_INCOGNITO)) { Get(event.getPlayer()).Status = false; @@ -128,7 +134,7 @@ public class IncognitoManager extends MiniDbClientPlugin { if (customEvent != null && !customEvent.isCancelled() && !canSeeThroughIncognito(other, player)) { - other.hidePlayer(player); + vm.hidePlayer(other, player, "Incognito Mode"); } if (Get(other).Status) @@ -137,7 +143,7 @@ public class IncognitoManager extends MiniDbClientPlugin if (!customEvent2.isCancelled() && !canSeeThroughIncognito(player, other)) { - player.hidePlayer(other); + vm.hidePlayer(player, other, "Incognito Mode"); } } } @@ -151,6 +157,8 @@ public class IncognitoManager extends MiniDbClientPlugin return; } + VisibilityManager vm = Managers.require(VisibilityManager.class); + for (Player player : UtilServer.getPlayers()) { for (Player other : UtilServer.getPlayers()) @@ -161,7 +169,7 @@ public class IncognitoManager extends MiniDbClientPlugin if (!customEvent.isCancelled() && !canSeeThroughIncognito(other, player)) { - other.hidePlayer(player); + vm.hidePlayer(other, player, "Incognito Mode"); } Get(player).Hidden = !customEvent.isCancelled(); @@ -177,7 +185,7 @@ public class IncognitoManager extends MiniDbClientPlugin if (!customEvent.isCancelled() && !canSeeThroughIncognito(player, other)) { - player.hidePlayer(other); + vm.hidePlayer(player, other, "Incognito Mode"); } Get(other).Hidden = !customEvent.isCancelled(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/inventory/command/GiveItemCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/command/GiveItemCommand.java index 3cc4042d7..4638a9a97 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/inventory/command/GiveItemCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/command/GiveItemCommand.java @@ -71,7 +71,7 @@ public class GiveItemCommand extends CommandBase { Plugin.addItemToInventoryForOffline(success -> { - if (success.booleanValue()) + if (success) { UtilPlayer.message(caller, F.main("Item", "You gave " + F.elem(amount + " " + itemName) + " to offline player " + F.name(playerName))); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardManager.java b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardManager.java index 8ce00fde8..08094511b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardManager.java @@ -133,7 +133,7 @@ public class LeaderboardManager extends MiniPlugin final int index = i; Managers.get(StatsManager.class).loadStatId(board.getStatNames()[index], id -> { - board.setStatId(index, id.intValue()); + board.setStatId(index, id); }); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/loot/RandomItem.java b/Plugins/Mineplex.Core/src/mineplex/core/loot/RandomItem.java index 7e7eef062..7402b32f8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/loot/RandomItem.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/loot/RandomItem.java @@ -59,4 +59,10 @@ public class RandomItem return _item.getType() == item.getItemStack().getType(); } + + @Override + public int hashCode() + { + return _item.getType().hashCode(); + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/poll/Poll.java b/Plugins/Mineplex.Core/src/mineplex/core/poll/Poll.java index 191113142..ae600ee98 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/poll/Poll.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/poll/Poll.java @@ -70,4 +70,10 @@ public class Poll } return false; } + + @Override + public int hashCode() + { + return Integer.hashCode(getId()); + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/portal/Commands/SendCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/portal/Commands/SendCommand.java index 294e793f6..e7a4f9a4e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/portal/Commands/SendCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/portal/Commands/SendCommand.java @@ -38,7 +38,7 @@ public class SendCommand extends CommandBase Plugin.doesServerExist(serverTarget, serverExists -> { - if (!serverExists.booleanValue()) + if (!serverExists) { UtilPlayer.message(player, F.main(Plugin.getName(), C.cGray + "Server " + C.cGold + serverTarget + C.cGray + " does not exist!")); return; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/portal/Commands/ServerCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/portal/Commands/ServerCommand.java index fd97de43c..51a018400 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/portal/Commands/ServerCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/portal/Commands/ServerCommand.java @@ -39,7 +39,7 @@ public class ServerCommand extends CommandBase { Plugin.doesServerExist(args[0], serverExists -> { - if (!serverExists.booleanValue()) + if (!serverExists) { UtilPlayer.message( player, @@ -60,11 +60,8 @@ public class ServerCommand extends CommandBase } else if (servUp.startsWith("CLANS-")) { - if (!_commandCenter.GetClientManager().Get(player).hasPermission(Portal.Perm.SERVER_COMMAND_CLANS)) - { - UtilPlayer.message(player, F.main(Plugin.getName(), "Clans servers can only be joined via the Clans Hub!")); - return; - } + UtilPlayer.message(player, F.main(Plugin.getName(), "Clans servers can only be joined via the Clans Hub!")); + return; } if (deniedAccess) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/projectile/IThrown.java b/Plugins/Mineplex.Core/src/mineplex/core/projectile/IThrown.java index 92bb0ddd0..845a372d0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/projectile/IThrown.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/projectile/IThrown.java @@ -9,4 +9,5 @@ public interface IThrown public void Collide(LivingEntity target, Block block, ProjectileUser data); public void Idle(ProjectileUser data); public void Expire(ProjectileUser data); + public void ChunkUnload(ProjectileUser data); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileManager.java b/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileManager.java index 50ec01904..23057f873 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileManager.java @@ -5,11 +5,6 @@ import java.util.List; import java.util.Map.Entry; import java.util.WeakHashMap; -import mineplex.core.MiniPlugin; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; - import org.bukkit.Effect; import org.bukkit.Sound; import org.bukkit.entity.Entity; @@ -19,8 +14,14 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.inventory.InventoryPickupItemEvent; import org.bukkit.event.player.PlayerPickupItemEvent; +import org.bukkit.event.world.ChunkUnloadEvent; import org.bukkit.plugin.java.JavaPlugin; +import mineplex.core.MiniPlugin; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + public class ProjectileManager extends MiniPlugin { private WeakHashMap _thrown = new WeakHashMap(); @@ -212,4 +213,16 @@ public class ProjectileManager extends MiniPlugin if (_thrown.containsKey(event.getItem())) event.setCancelled(true); } -} + + @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) + public void chunkUnload(ChunkUnloadEvent event) + { + for (Entity e : event.getChunk().getEntities()) + { + if (_thrown.containsKey(e)) + { + _thrown.get(e).chunkUnload(); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileUser.java b/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileUser.java index 16213685f..1800fd3d5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileUser.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileUser.java @@ -2,6 +2,18 @@ package mineplex.core.projectile; import java.util.List; +import org.bukkit.Effect; +import org.bukkit.GameMode; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; + import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; @@ -16,19 +28,6 @@ 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.Bukkit; -import org.bukkit.Effect; -import org.bukkit.GameMode; -import org.bukkit.Sound; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity; -import org.bukkit.entity.Entity; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; - public class ProjectileUser { public ProjectileManager Throw; @@ -186,6 +185,10 @@ public class ProjectileUser _canHit = canHit; } + public void chunkUnload() + { + _callback.ChunkUnload(this); + } public void effect(UpdateEvent event) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBan.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBan.java index 1b1c092e4..600f41a2d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBan.java @@ -18,9 +18,11 @@ public class ClansBan private Timestamp _unbanTime; private boolean _permanent; private boolean _removed; + private String _removeAdmin; + private String _removeReason; private UUID _uuid; - public ClansBan(int id, UUID uuid, String admin, String reason, Timestamp banTime, Timestamp unbanTime, boolean permanent, boolean removed) + public ClansBan(int id, UUID uuid, String admin, String reason, Timestamp banTime, Timestamp unbanTime, boolean permanent, boolean removed, String removeAdmin, String removeReason) { _id = id; _uuid = uuid; @@ -30,6 +32,8 @@ public class ClansBan _unbanTime = unbanTime; _permanent = permanent; _removed = removed; + _removeAdmin = removeAdmin; + _removeReason = removeReason; } public int getId() @@ -93,9 +97,21 @@ public class ClansBan { return _uuid; } + + public String getRemoveAdmin() + { + return _removeAdmin; + } + + public String getRemoveReason() + { + return _removeReason; + } - public void remove() + public void remove(String admin, String reason) { _removed = true; + _removeAdmin = admin; + _removeReason = reason; } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanClient.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanClient.java index 6710f4dd0..7e38a4eed 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanClient.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanClient.java @@ -18,6 +18,7 @@ public class ClansBanClient { _uuid = uuid; _bans = bans; + sortBans(); } public boolean isBanned() @@ -87,4 +88,28 @@ public class ClansBanClient return longest; } + + public void sortBans() + { + _bans.sort((b1, b2) -> + { + if (b1.isActive() && !b2.isActive()) + { + return -1; + } + if (b2.isActive() && !b1.isActive()) + { + return 1; + } + if ((b1.isActive() && b1.isPermanent()) && !(b2.isActive() && b2.isPermanent())) + { + return -1; + } + if ((b2.isActive() && b2.isPermanent()) && !(b1.isActive() && b1.isPermanent())) + { + return 1; + } + return b1.getBanTime().compareTo(b2.getBanTime()); + }); + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanManager.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanManager.java index 80244ad9d..3d8edd8ec 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanManager.java @@ -65,14 +65,15 @@ public class ClansBanManager extends MiniPlugin private void generatePermissions() { - PermissionGroup.ADMIN.setPermission(Perm.ALERT_PUNISHMENT, true, true); PermissionGroup.CMOD.setPermission(Perm.ALERT_PUNISHMENT, false, true); PermissionGroup.CMA.setPermission(Perm.ALERT_PUNISHMENT, false, true); + PermissionGroup.QA.setPermission(Perm.ALERT_PUNISHMENT, true, true); PermissionGroup.ADMIN.setPermission(Perm.PUNISHMENT_COMMAND, true, true); PermissionGroup.CMOD.setPermission(Perm.PUNISHMENT_COMMAND, false, true); PermissionGroup.CMA.setPermission(Perm.PUNISHMENT_COMMAND, false, true); + PermissionGroup.QA.setPermission(Perm.PUNISHMENT_COMMAND, true, true); } @Override @@ -108,6 +109,7 @@ public class ClansBanManager extends MiniPlugin if (ban.isPresent()) { target._bans.add(ban.get()); + target.sortBans(); String banTimeFormatted = target.getBanTimeFormatted(); if (targetName != null) @@ -133,21 +135,30 @@ public class ClansBanManager extends MiniPlugin UtilPlayer.message(caller, F.main(getName(), C.cRed + "An issue occurred when trying to ban " + F.elem(targetName))); } } - callback.accept(ban); + if (callback != null) + { + callback.accept(ban); + } })); } - public void unban(ClansBanClient target, ClansBan ban, Runnable callback) + public void unban(ClansBanClient target, ClansBan ban, String admin, String reason, Runnable callback) { if (!target._uuid.equals(ban.getUUID())) { return; } - ban.remove(); - _repository.removeBan(ban); - - callback.run(); + _repository.removeBan(ban, admin, reason, () -> + { + ban.remove(admin, reason); + target.sortBans(); + + if (callback != null) + { + callback.run(); + } + }); } @EventHandler(priority = EventPriority.HIGHEST) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanRepository.java index 702968d98..5f8680bd8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanRepository.java @@ -15,14 +15,16 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.Managers; import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.UtilServer; import mineplex.serverdata.database.DBPool; import mineplex.serverdata.database.RepositoryBase; import mineplex.serverdata.database.column.ColumnInt; +import mineplex.serverdata.database.column.ColumnVarChar; public class ClansBanRepository extends RepositoryBase { - private static final String BAN_PLAYER = "INSERT INTO clanBans (uuid, admin, reason, banTime, unbanTime, permanent, removed) VALUES (?, ?, ?, ?, ?, ?, ?);"; - private static final String REMOVE_BAN = "UPDATE clanBans SET removed = 1 WHERE id = ?;"; + private static final String BAN_PLAYER = "INSERT INTO clanBans (uuid, admin, reason, banTime, unbanTime, permanent, removed, removeAdmin, removeReason) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);"; + private static final String REMOVE_BAN = "UPDATE clanBans SET removed = 1, removeAdmin = ?, removeReason = ? WHERE id = ?;"; private static final String GET_ALL_BANS = "SELECT * FROM clanBans WHERE uuid = ?;"; public ClansBanRepository(JavaPlugin plugin) @@ -47,13 +49,15 @@ public class ClansBanRepository extends RepositoryBase stmt.setTimestamp(5, unbanTime); stmt.setBoolean(6, time == -1); stmt.setBoolean(7, false); + stmt.setString(8, null); + stmt.setString(9, null); stmt.executeUpdate(); ResultSet resultSet = stmt.getGeneratedKeys(); if (resultSet.next()) { int id = resultSet.getInt(1); - return Optional.of(new ClansBan(id, uuid, admin, reason, banTime, unbanTime, time == -1, false)); + return Optional.of(new ClansBan(id, uuid, admin, reason, banTime, unbanTime, time == -1, false, null, null)); } else { @@ -90,8 +94,10 @@ public class ClansBanRepository extends RepositoryBase Timestamp unbanTime = resultSet.getTimestamp(6); boolean permanent = resultSet.getBoolean(7); boolean removed = resultSet.getBoolean(8); + String removeAdmin = resultSet.getString(9); + String removeReason = resultSet.getString(10); - bans.add(new ClansBan(id, UUID.fromString(ruuid), admin, reason, banTime, unbanTime, permanent, removed)); + bans.add(new ClansBan(id, UUID.fromString(ruuid), admin, reason, banTime, unbanTime, permanent, removed, removeAdmin, removeReason)); } return new ClansBanClient(uuid, bans); @@ -123,8 +129,16 @@ public class ClansBanRepository extends RepositoryBase }); } - public void removeBan(ClansBan ban) + public void removeBan(ClansBan ban, String admin, String reason, Runnable onComplete) { - executeUpdate(REMOVE_BAN, new ColumnInt("id", ban.getId())); + UtilServer.runAsync(() -> + { + executeUpdate(REMOVE_BAN, new ColumnVarChar("removeAdmin", admin.length(), admin), new ColumnVarChar("removeReason", reason.length(), reason), new ColumnInt("id", ban.getId())); + + if (onComplete != null) + { + UtilServer.runSync(onComplete); + } + }); } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/command/ClansBanCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/command/ClansBanCommand.java index ca52f4cad..17eeea976 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/command/ClansBanCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/command/ClansBanCommand.java @@ -26,14 +26,15 @@ public class ClansBanCommand extends CommandBase { final String playerName = args[0]; - String reason = args[1]; + StringBuilder reasonBuilder = new StringBuilder(args[1]); for (int i = 2; i < args.length; i++) { - reason += " " + args[i]; + reasonBuilder.append(' '); + reasonBuilder.append(args[i]); } - final String finalReason = reason; + final String finalReason = reasonBuilder.toString(); Plugin.loadClient(playerName, client -> { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ui/ClansBanPage.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ui/ClansBanPage.java index f26c4a0b2..c54ccaeee 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ui/ClansBanPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ui/ClansBanPage.java @@ -96,9 +96,11 @@ public class ClansBanPage extends ShopPageBase .addLore(C.cGray + "Admin: " + C.cYellow + ban.getAdmin()) .addLore(C.cGray + "Permanent: " + C.cYellow + (ban.isPermanent() ? "Yes" : "No")) .addLore(C.cGray + "Reason: " + C.cYellow + ban.getReason(), 16) - .addLore(C.cGray + "Disabled: " + C.cYellow + (ban.isRemoved() ? "Yes" : "No")) + .addLore(C.cGray + "Removed: " + C.cYellow + (ban.isRemoved() ? "Yes" : "No")) + .addLore(ban.getRemoveAdmin() != null ? C.cGray + "Removed By: " + C.cYellow + ban.getRemoveAdmin() : null) + .addLore(ban.getRemoveReason() != null ? C.cGray + "Remove Reason: " + C.cYellow + ban.getRemoveReason() : null) .addLore(ban.isActive() ? " " : null) - .addLore(ban.isActive() ? C.cDAqua + "Left-Click to disable ban" : null) + .addLore(ban.isActive() ? C.cDAqua + "Left-Click to Remove Ban" : null) .setGlow(ban.isActive()) .build(); } @@ -112,9 +114,11 @@ public class ClansBanPage extends ShopPageBase .addLore(C.cGray + "Time Left: " + C.cYellow + (ban.isActive() ? ban.getBanTimeFormatted(false) : "None")) .addLore(C.cGray + "Permanent: " + C.cYellow + (ban.isPermanent() ? "Yes" : "No")) .addLore(C.cGray + "Reason: " + C.cYellow + ban.getReason(), 16) - .addLore(C.cGray + "Disabled: " + C.cYellow + (ban.isRemoved() ? "Yes" : "No")) + .addLore(C.cGray + "Removed: " + C.cYellow + (ban.isRemoved() ? "Yes" : "No")) + .addLore(ban.getRemoveAdmin() != null ? C.cGray + "Removed By: " + C.cYellow + ban.getRemoveAdmin() : null) + .addLore(ban.getRemoveReason() != null ? C.cGray + "Remove Reason: " + C.cYellow + ban.getRemoveReason() : null) .addLore(ban.isActive() ? " " : null) - .addLore(ban.isActive() ? C.cDAqua + "Left-Click to disable ban" : null) + .addLore(ban.isActive() ? C.cDAqua + "Left-Click to Remove Ban" : null) .setGlow(ban.isActive()) .build(); } @@ -123,13 +127,10 @@ public class ClansBanPage extends ShopPageBase { if (ban.isActive()) { - getPlugin().runAsync(() -> + getPlugin().unban(_victimClient, ban, getPlayer().getName(), _reason, () -> { - getPlugin().unban(_victimClient, ban, () -> - { - refresh(); - playAcceptSound(player); - }); + refresh(); + playAcceptSound(player); }); } }); @@ -138,6 +139,11 @@ public class ClansBanPage extends ShopPageBase private void performBan() { + if (_time == 0 && !_permanent) + { + playDenySound(getPlayer()); + return; + } getPlugin().ban(_victimClient, _victimName, getPlayer().getName(), _permanent ? -1 : _time, _reason, getPlayer(), ban -> { if (ban.isPresent()) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/InventoryReward.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/InventoryReward.java index 9fcdfca6e..d4ef9fc37 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/InventoryReward.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/InventoryReward.java @@ -85,4 +85,10 @@ public class InventoryReward extends Reward { return obj instanceof InventoryReward && ((InventoryReward) obj).getPackageName().equals(_packageName); } -} + + @Override + public int hashCode() + { + return _packageName.hashCode(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/RuneAmplifierReward.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/RuneAmplifierReward.java index a3eba8c95..81cc9ff87 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/RuneAmplifierReward.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/RuneAmplifierReward.java @@ -48,4 +48,10 @@ public class RuneAmplifierReward extends InventoryReward { return obj instanceof RuneAmplifierReward && ((RuneAmplifierReward) obj)._minutes == _minutes; } + + @Override + public int hashCode() + { + return Integer.hashCode(_minutes); + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/SpinTicketReward.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/SpinTicketReward.java index a3cd6af81..c09ceae96 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/SpinTicketReward.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/SpinTicketReward.java @@ -96,4 +96,10 @@ public class SpinTicketReward extends Reward { return obj instanceof SpinTicketReward; } + + @Override + public int hashCode() + { + return getClass().hashCode(); + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/shop/item/ShopItem.java b/Plugins/Mineplex.Core/src/mineplex/core/shop/item/ShopItem.java index d05f7734c..bea7b3638 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/shop/item/ShopItem.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/shop/item/ShopItem.java @@ -129,12 +129,6 @@ public class ShopItem extends ItemStack return new ShopItem(super.clone(), _name, _deliveryName, _deliveryAmount, _locked, _displayItem); } - @Override - public boolean equals(Object obj) - { - return super.equals(obj); - } - protected void UpdateVisual(boolean clone) { ItemMeta meta = getItemMeta(); @@ -220,4 +214,4 @@ public class ShopItem extends ItemStack return this; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/slack/SlackAPI.java b/Plugins/Mineplex.Core/src/mineplex/core/slack/SlackAPI.java index b9155e39f..0e8a7d234 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/slack/SlackAPI.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/slack/SlackAPI.java @@ -128,4 +128,4 @@ public class SlackAPI return _instance; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/slack/SlackMessage.java b/Plugins/Mineplex.Core/src/mineplex/core/slack/SlackMessage.java index 22bb1f2c2..a2b2f918b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/slack/SlackMessage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/slack/SlackMessage.java @@ -157,4 +157,4 @@ public class SlackMessage { _content = content; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/slack/SlackTeam.java b/Plugins/Mineplex.Core/src/mineplex/core/slack/SlackTeam.java index 4dd60c9fa..b25f1913f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/slack/SlackTeam.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/slack/SlackTeam.java @@ -10,6 +10,10 @@ public enum SlackTeam // QA team - mineplexqa.slack.com QA("Mineplex QA", "todo", "todo", "todo"), // TODO: new details + + CLANS("Mineplex CM", "T2ADQ1G9L", "B6URH6CM9", "HoF2tRaspjMBaj63luJWnlJz"), + + SOCIAL_MEDIA("Mineplex SM", "T44BS70DB", "B6UCH5Y1X", "NciHvU15gbRMZ1PksCjXy3my"), ; @@ -76,4 +80,4 @@ public enum SlackTeam { return "https://hooks.slack.com/services/" + getId1() + "/" + getId2() + "/" + getToken(); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java index e88be1e36..ef89dd72a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java @@ -128,7 +128,7 @@ public class StatsManager extends MiniDbClientPlugin { final int statId = _stats.get(statName); - runSync(() -> idConsumer.accept(Integer.valueOf(statId))); + runSync(() -> idConsumer.accept(statId)); }); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/texttutorial/TextTutorialManager.java b/Plugins/Mineplex.Core/src/mineplex/core/texttutorial/TextTutorialManager.java index 5a76c4021..bd5f230b9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/texttutorial/TextTutorialManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/texttutorial/TextTutorialManager.java @@ -15,6 +15,7 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.java.JavaPlugin; +import mineplex.core.Managers; import mineplex.core.MiniPlugin; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; @@ -27,6 +28,7 @@ import mineplex.core.texttutorial.tutorial.Tutorial; import mineplex.core.texttutorial.tutorial.TutorialData; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.visibility.VisibilityManager; public class TextTutorialManager extends MiniPlugin { @@ -59,6 +61,7 @@ public class TextTutorialManager extends MiniPlugin if (!(event.getRightClicked() instanceof LivingEntity)) return; + VisibilityManager vm = Managers.require(VisibilityManager.class); LivingEntity ent = (LivingEntity)event.getRightClicked(); String name = ent.getCustomName(); @@ -74,7 +77,7 @@ public class TextTutorialManager extends MiniPlugin for (Player other : Bukkit.getOnlinePlayers()) { - other.hidePlayer(event.getPlayer()); + vm.hidePlayer(other, event.getPlayer(), "Core Text Tutorial"); } ((CraftPlayer) event.getPlayer()).getHandle().spectating = true; @@ -89,7 +92,9 @@ public class TextTutorialManager extends MiniPlugin { if (event.getType() != UpdateType.TICK) return; - + + VisibilityManager vm = Managers.require(VisibilityManager.class); + for (final Tutorial tut : _tutorials) { Iterator iterator = tut.getTutorialDatas().iterator(); @@ -117,7 +122,7 @@ public class TextTutorialManager extends MiniPlugin for (Player other : Bukkit.getOnlinePlayers()) { - other.showPlayer(player); + vm.showPlayer(other, player, "Core Text Tutorial"); } ((CraftPlayer) player).getHandle().spectating = false; @@ -155,12 +160,13 @@ public class TextTutorialManager extends MiniPlugin public void hidePlayer(PlayerJoinEvent event) { Player player = event.getPlayer(); + VisibilityManager vm = Managers.require(VisibilityManager.class); for (Player other : Bukkit.getOnlinePlayers()) { if (isInTutorial(other)) { - player.hidePlayer(other); + vm.hidePlayer(player, other, "Core Text Tutorial"); } } } @@ -169,14 +175,18 @@ public class TextTutorialManager extends MiniPlugin public void playerQuit(PlayerQuitEvent event) { for (Tutorial tut : _tutorials) + { tut.stopTutorial(event.getPlayer()); + } } @EventHandler public void cancelInteract(PlayerInteractEvent event) { if (isInTutorial(event.getPlayer())) + { event.setCancelled(true); + } } public boolean isInTutorial(Player player) @@ -184,9 +194,11 @@ public class TextTutorialManager extends MiniPlugin for (Tutorial tutorial : _tutorials) { if (tutorial.isInTutorial(player)) + { return true; + } } return false; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/TrackManager.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/TrackManager.java index 657b46601..5a1e40251 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/TrackManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/TrackManager.java @@ -25,6 +25,7 @@ import mineplex.core.titles.tracks.award.AprilFools2017Track; import mineplex.core.titles.tracks.award.Bridges2017Track; import mineplex.core.titles.tracks.award.CastleSiegeTesterTrack; import mineplex.core.titles.tracks.award.ClansRaidTrack; +import mineplex.core.titles.tracks.award.Minestrike2017Track; import mineplex.core.titles.tracks.custom.DongerTrack; import mineplex.core.titles.tracks.custom.EarlyBirdTrack; import mineplex.core.titles.tracks.custom.HappyGaryTrack; @@ -119,6 +120,7 @@ public class TrackManager extends MiniPlugin registerTrack(new AlienInvasionTrack()); registerTrack(new ClansRaidTrack()); registerTrack(new CastleSiegeTesterTrack()); + registerTrack(new Minestrike2017Track()); // Staff tracks registerTrack(new BuilderTrack()); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/award/Minestrike2017Track.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/award/Minestrike2017Track.java new file mode 100644 index 000000000..a381e6384 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/award/Minestrike2017Track.java @@ -0,0 +1,31 @@ +package mineplex.core.titles.tracks.award; + +import net.md_5.bungee.api.ChatColor; + +import mineplex.core.titles.tracks.ItemizedTrack; +import mineplex.core.titles.tracks.TrackFormat; +import mineplex.core.titles.tracks.TrackTier; + +public class Minestrike2017Track extends ItemizedTrack +{ + public Minestrike2017Track() + { + super( + "tournament-ms-2017", + ChatColor.GOLD, + "MS 2017", + "2017 Minestrike Champion", + "This track is awarded to the winners of the 2017 Minestrike Tournament", + true); + + special(); + + getRequirements() + .addTier(new TrackTier( + "2017 Minestrike Champion", + null, + this::owns, + new TrackFormat(ChatColor.GOLD, ChatColor.GOLD) + )); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/updater/FileUpdater.java b/Plugins/Mineplex.Core/src/mineplex/core/updater/FileUpdater.java index 90b9c8919..e72629d7b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/updater/FileUpdater.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/updater/FileUpdater.java @@ -22,12 +22,14 @@ import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilServer; import mineplex.core.portal.GenericServer; import mineplex.core.portal.Intent; import mineplex.core.portal.Portal; import mineplex.core.updater.command.BuildVersionCommand; import mineplex.core.updater.command.RestartServerCommand; import mineplex.core.updater.event.RestartServerEvent; +import mineplex.core.updater.event.RestartTriggerEvent; import mineplex.core.updater.event.UpdateEvent; import mineplex.serverdata.Region; import mineplex.serverdata.commands.RestartCommand; @@ -50,6 +52,7 @@ public class FileUpdater extends MiniPlugin private boolean _needUpdate; private boolean _enabled = true; + private boolean _restartTriggered = false; private Properties _buildProperties; @@ -77,7 +80,6 @@ public class FileUpdater extends MiniPlugin private void generatePermissions() { - PermissionGroup.MOD.setPermission(Perm.BVERSION_COMMAND, true, true); PermissionGroup.ADMIN.setPermission(Perm.RESTART_COMMAND, true, true); PermissionGroup.QAM.setPermission(Perm.RESTART_COMMAND, false, true); @@ -112,10 +114,17 @@ public class FileUpdater extends MiniPlugin if (event.getType() != UpdateType.SLOWER) return; - if (!_needUpdate || !_enabled) + if (!_needUpdate || !_enabled || _restartTriggered) return; - RestartServerEvent restartEvent = new RestartServerEvent(); + if (UtilServer.CallEvent(new RestartTriggerEvent(RestartTriggerEvent.RestartReason.UPDATE)).isCancelled()) + { + return; + } + + _restartTriggered = true; + + RestartServerEvent restartEvent = new RestartServerEvent(RestartServerEvent.RestartReason.UPDATE); getPluginManager().callEvent(restartEvent); @@ -126,20 +135,14 @@ public class FileUpdater extends MiniPlugin player.sendMessage(F.main("Updater", C.cGold + _serverName + C.cGray + " is restarting for an update.")); } - getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() + getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(getPlugin(), () -> { - public void run() - { - _portal.sendAllPlayersToGenericServer(_transferHub, Intent.KICK); - } + _portal.sendAllPlayersToGenericServer(_transferHub, Intent.KICK); }, 60L); - getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() + getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(getPlugin(), () -> { - public void run() - { - getPlugin().getServer().shutdown(); - } + getPlugin().getServer().shutdown(); }, 100L); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/updater/RestartHandler.java b/Plugins/Mineplex.Core/src/mineplex/core/updater/RestartHandler.java index e37961ef9..9001426f6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/updater/RestartHandler.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/updater/RestartHandler.java @@ -1,14 +1,5 @@ package mineplex.core.updater; -import mineplex.core.common.util.F; -import mineplex.core.portal.GenericServer; -import mineplex.core.portal.Intent; -import mineplex.core.portal.Portal; -import mineplex.serverdata.Region; -import mineplex.serverdata.commands.CommandCallback; -import mineplex.serverdata.commands.RestartCommand; -import mineplex.serverdata.commands.ServerCommand; - import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -17,6 +8,18 @@ import org.bukkit.event.Listener; import org.bukkit.event.server.ServerListPingEvent; import org.bukkit.plugin.java.JavaPlugin; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilServer; +import mineplex.core.portal.GenericServer; +import mineplex.core.portal.Intent; +import mineplex.core.portal.Portal; +import mineplex.core.updater.event.RestartServerEvent; +import mineplex.core.updater.event.RestartTriggerEvent; +import mineplex.serverdata.Region; +import mineplex.serverdata.commands.CommandCallback; +import mineplex.serverdata.commands.RestartCommand; +import mineplex.serverdata.commands.ServerCommand; + public class RestartHandler implements CommandCallback, Listener { private JavaPlugin _plugin; @@ -51,6 +54,16 @@ public class RestartHandler implements CommandCallback, Listener if (!serverName.equalsIgnoreCase(_serverName) || _region != region) return; + if (UtilServer.CallEvent(new RestartTriggerEvent(RestartTriggerEvent.RestartReason.COMMAND)).isCancelled()) + { + return; + } + + if (UtilServer.CallEvent(new RestartServerEvent(RestartServerEvent.RestartReason.COMMAND)).isCancelled()) + { + return; + } + _restarting = true; for (Player player : Bukkit.getOnlinePlayers()) @@ -58,21 +71,15 @@ public class RestartHandler implements CommandCallback, Listener player.sendMessage(F.main("Restart", "Server is restarting, you're being sent to a lobby.")); } - Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Bukkit.getPluginManager().getPlugins()[0], new Runnable() + Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(UtilServer.getPlugin(), () -> { - public void run() - { - Portal.getInstance().sendAllPlayersToGenericServer(GenericServer.HUB, Intent.KICK); - } + Portal.getInstance().sendAllPlayersToGenericServer(GenericServer.HUB, Intent.KICK); }, 60L); - Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Bukkit.getPluginManager().getPlugins()[0], new Runnable() + Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(UtilServer.getPlugin(), () -> { - public void run() - { - Bukkit.getServer().shutdown(); - } + Bukkit.getServer().shutdown(); }, 100L); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/updater/event/RestartServerEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/updater/event/RestartServerEvent.java index a2c7e4fe5..072b6ded6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/updater/event/RestartServerEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/updater/event/RestartServerEvent.java @@ -8,6 +8,12 @@ public class RestartServerEvent extends Event implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean _cancelled = false; + private final RestartReason _reason; + + public RestartServerEvent(RestartReason reason) + { + _reason = reason; + } public HandlerList getHandlers() { @@ -18,6 +24,11 @@ public class RestartServerEvent extends Event implements Cancellable { return handlers; } + + public RestartReason getReason() + { + return _reason; + } @Override public boolean isCancelled() @@ -30,4 +41,10 @@ public class RestartServerEvent extends Event implements Cancellable { _cancelled = cancel; } -} + + public enum RestartReason + { + COMMAND, + UPDATE + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/updater/event/RestartTriggerEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/updater/event/RestartTriggerEvent.java new file mode 100644 index 000000000..b897934e8 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/updater/event/RestartTriggerEvent.java @@ -0,0 +1,50 @@ +package mineplex.core.updater.event; + +import org.bukkit.event.Cancellable; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class RestartTriggerEvent extends Event implements Cancellable +{ + private static final HandlerList handlers = new HandlerList(); + private boolean _cancelled = false; + private final RestartReason _reason; + + public RestartTriggerEvent(RestartReason reason) + { + _reason = reason; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } + + public RestartReason getReason() + { + return _reason; + } + + @Override + public boolean isCancelled() + { + return _cancelled; + } + + @Override + public void setCancelled(boolean cancel) + { + _cancelled = cancel; + } + + public enum RestartReason + { + COMMAND, + UPDATE + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/visibility/VisibilityData.java b/Plugins/Mineplex.Core/src/mineplex/core/visibility/VisibilityData.java deleted file mode 100644 index 851a0b73c..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/visibility/VisibilityData.java +++ /dev/null @@ -1,110 +0,0 @@ -package mineplex.core.visibility; - -import java.util.Iterator; - -import mineplex.core.common.util.NautHashMap; -import mineplex.core.recharge.Recharge; -import mineplex.core.common.timing.TimingManager; - -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; -import org.bukkit.entity.Player; - -public class VisibilityData -{ - private NautHashMap _shouldHide = new NautHashMap(); - private NautHashMap _lastState = new NautHashMap(); - - public void updatePlayer(Player player, Player target, boolean hide) - { - TimingManager.stopTotal("VisData updatePlayer"); - - if (_lastState.containsKey(target) && _lastState.get(target) == hide) - { - //Already this state, do nothing - TimingManager.stopTotal("VisData updatePlayer"); - return; - } - - if (attemptToProcess(player, target, hide)) - { - //Clear old - _shouldHide.remove(target); - } - else - { - //Store - _shouldHide.put(target, hide); - } - - TimingManager.stopTotal("VisData updatePlayer"); - } - - //Process New - private boolean attemptToProcess(Player player, Player target, boolean hide) - { - TimingManager.startTotal("VisData attemptToProcess"); - - if (Recharge.Instance.use(player, "VIS " + target.getName(), 250, false, false)) - { - //Use craftplayer because i recall jon added something where - //it would still send the packet, even if the client thought it was already the state. - - if (hide) - { - TimingManager.startTotal("Hide Player"); - ((CraftPlayer)player).hidePlayer(target, true, true); - TimingManager.stopTotal("Hide Player"); - } - else - { - TimingManager.startTotal("Show Player"); - player.showPlayer(target); - TimingManager.stopTotal("Show Player"); - } - - _lastState.put(target, hide); - - TimingManager.stopTotal("VisData attemptToProcess"); - return true; - } - - TimingManager.stopTotal("VisData attemptToProcess"); - return false; - } - - //Process Update - public void attemptToProcessUpdate(Player player) - { - TimingManager.startTotal("VisData attemptToProcessUpdate shouldHide"); - if (!_shouldHide.isEmpty()) - { - for (Iterator targetIter = _shouldHide.keySet().iterator(); targetIter.hasNext();) - { - Player target = targetIter.next(); - boolean hide = _shouldHide.get(target); - - if (!target.isOnline() || !target.isValid() || attemptToProcess(player, target, hide)) - { - targetIter.remove(); - } - } - } - TimingManager.stopTotal("VisData attemptToProcessUpdate shouldHide"); - - - TimingManager.startTotal("VisData attemptToProcessUpdate lastState"); - if (!_lastState.isEmpty()) - { - for (Iterator targetIter = _lastState.keySet().iterator(); targetIter.hasNext();) - { - Player target = targetIter.next(); - - if (!target.isOnline() || !target.isValid()) - { - targetIter.remove(); - } - } - } - TimingManager.stopTotal("VisData attemptToProcessUpdate lastState"); - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/visibility/VisibilityManager.java b/Plugins/Mineplex.Core/src/mineplex/core/visibility/VisibilityManager.java index dfd21d10c..0f33e69b2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/visibility/VisibilityManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/visibility/VisibilityManager.java @@ -1,109 +1,193 @@ package mineplex.core.visibility; -import java.util.Iterator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; import mineplex.core.MiniPlugin; -import mineplex.core.common.util.NautHashMap; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.timing.TimingManager; +import mineplex.core.ReflectivelyCreateMiniPlugin; +import mineplex.core.account.permissions.Permission; +import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.command.CommandBase; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.plugin.java.JavaPlugin; - +@ReflectivelyCreateMiniPlugin public class VisibilityManager extends MiniPlugin { - public static VisibilityManager Instance; - - private NautHashMap _data = new NautHashMap(); - - protected VisibilityManager(JavaPlugin plugin) + public enum Perm implements Permission { - super("Visibility Manager", plugin); - } - - public static void Initialize(JavaPlugin plugin) - { - Instance = new VisibilityManager(plugin); + VIS_DEBUG, } - public VisibilityData getDataFor(Player player) + private static final int VIEW_DISTANCE = Bukkit.getViewDistance() * 16; + + private final Map>> _visibility = new HashMap<>(); + + private VisibilityManager() { - if (!_data.containsKey(player)) - _data.put(player, new VisibilityData()); + super("Visibility Manager"); - return _data.get(player); - } - - public void setVisibility(Player target, boolean isVisible, Player... viewers) - { - TimingManager.startTotal("VisMan SetVis"); - - for (Player player : viewers) + addCommand(new CommandBase(this, Perm.VIS_DEBUG, "visdebug") { - if (player.equals(target)) - continue; - - getDataFor(player).updatePlayer(player, target, !isVisible); - } - - TimingManager.stopTotal("VisMan SetVis"); - } - - public void refreshPlayerToAll(Player player) - { - setVisibility(player, false, UtilServer.getPlayers()); - setVisibility(player, true, UtilServer.getPlayers()); - } - - @EventHandler - public void update(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; - - TimingManager.startTotal("VisMan Update"); - - Iterator playerIter = _data.keySet().iterator(); - - while (playerIter.hasNext()) - { - Player player = playerIter.next(); - - if (!player.isOnline() || !player.isValid()) + @Override + public void Execute(Player caller, String[] args) { - playerIter.remove(); - continue; + Player target = caller; + if (args.length > 0) + { + if (Bukkit.getPlayer(args[0]) != null) + { + target = Bukkit.getPlayer(args[0]); + } + } + + caller.sendMessage(target.getName() + " (Bukkit):"); + caller.sendMessage(caller.getName() + " Observing " + target.getName() + ": " + caller.canSee(target)); + caller.sendMessage(target.getName() + " Observing " + caller.getName() + ": " + target.canSee(caller)); + caller.sendMessage(target.getName() + " (Mineplex):"); + caller.sendMessage(caller.getName() + " Observing " + target.getName() + ": " + canSee(caller, target)); + caller.sendMessage(target.getName() + " Observing " + caller.getName() + ": " + canSee(target, caller)); + caller.sendMessage(caller.getName() + " Data (Mineplex):"); + _visibility.get(caller).entrySet().forEach(entry -> + { + caller.sendMessage("- " + entry.getKey().getName() + ":"); + entry.getValue().forEach(reason -> + { + caller.sendMessage(" - " + reason); + }); + }); + if (caller.getEntityId() != target.getEntityId()) + { + caller.sendMessage(target.getName() + " Data (Mineplex):"); + _visibility.get(target).entrySet().forEach(entry -> + { + caller.sendMessage("- " + entry.getKey().getName() + ":"); + entry.getValue().forEach(reason -> + { + caller.sendMessage(" - " + reason); + }); + }); + } } - - _data.get(player).attemptToProcessUpdate(player); - } + }); - TimingManager.stopTotal("VisMan Update"); + generatePermissions(); } - @EventHandler - public void quit(PlayerQuitEvent event) + private void generatePermissions() { - _data.remove(event.getPlayer()); + PermissionGroup.ADMIN.setPermission(Perm.VIS_DEBUG, true, true); + PermissionGroup.QA.setPermission(Perm.VIS_DEBUG, true, true); } - - //@EventHandler DISABLED - public void updateDebug(UpdateEvent event) + + public boolean canSee(Player viewer, Player target) { - if (event.getType() != UpdateType.MIN_01) + return _visibility.get(viewer).getOrDefault(target, new HashSet<>()).isEmpty(); + } + + public void refreshVisibility(Player viewer, Player target) + { + if (viewer == null || target == null) + { return; - - TimingManager.endTotal("VisMan update", true); - TimingManager.endTotal("VisMan setVis", true); - TimingManager.endTotal("VisData attemptToProcess", true); - TimingManager.endTotal("VisData updatePlayer", true); - TimingManager.endTotal("VisData attemptToProcessUpdate shouldHide", true); - TimingManager.endTotal("VisData attemptToProcessUpdate lastState", true); - TimingManager.endTotal("Hide Player", true); - TimingManager.endTotal("Show Player", true); + } + if (viewer.getEntityId() == target.getEntityId()) + { + return; + } + if (canSee(viewer, target)) + { + viewer.showPlayer(target); + } + else + { + viewer.hidePlayer(target); + } } -} + + public void hidePlayer(Player viewer, Player target, String reason) + { + if (viewer == null || target == null || reason == null) + { + return; + } + if (viewer.getEntityId() == target.getEntityId()) + { + return; + } + Set reasons = _visibility.get(viewer).computeIfAbsent(target, (p) -> new HashSet<>()); + if (reasons.contains(reason)) + { + return; + } + reasons.add(reason); + refreshVisibility(viewer, target); + } + + public void showPlayer(Player viewer, Player target, String reason) + { + if (viewer == null || target == null || reason == null) + { + return; + } + if (viewer.getEntityId() == target.getEntityId()) + { + return; + } + Set reasons = _visibility.get(viewer).get(target); + if (reasons == null) + { + return; + } + boolean modified = reasons.remove(reason); + if (reasons.isEmpty()) + { + _visibility.get(viewer).remove(target); + } + if (modified) + { + refreshVisibility(viewer, target); + } + } + + @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) + public void onJoin(PlayerJoinEvent event) + { + _visibility.put(event.getPlayer(), new HashMap<>()); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onQuit(PlayerQuitEvent event) + { + _visibility.remove(event.getPlayer()); + _visibility.values().forEach(v -> v.remove(event.getPlayer())); + } + + /*@EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() == UpdateType.SEC_05) + { + return; + } + Bukkit.getOnlinePlayers().forEach(player -> + { + player.getNearbyEntities(VIEW_DISTANCE, VIEW_DISTANCE, VIEW_DISTANCE).forEach(entity -> + { + if (entity instanceof Player) + { + refreshVisibility(player, (Player)entity); + } + }); + }); + }*/ +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/website/WebsiteLinkManager.java b/Plugins/Mineplex.Core/src/mineplex/core/website/WebsiteLinkManager.java index f1aef1a3a..6f89f178e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/website/WebsiteLinkManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/website/WebsiteLinkManager.java @@ -546,7 +546,7 @@ public class WebsiteLinkManager extends MiniDbClientPlugin try (BufferedReader reader = new BufferedReader(new InputStreamReader(new URL(API_URL + "?hash=" + API_KEY + "&" + call).openStream()))) { - reader.lines().forEach(l -> input.append(l)); + reader.lines().forEachOrdered(input::append); } catch (IOException e) { diff --git a/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/ClaimLocation.java b/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/ClaimLocation.java index adfdfe9d3..ec3fb85e4 100644 --- a/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/ClaimLocation.java +++ b/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/ClaimLocation.java @@ -62,4 +62,4 @@ public class ClaimLocation ClaimLocation that = (ClaimLocation) other; return Objects.equals(_worldName, that._worldName) && Objects.equals(_chunkX, that._chunkX) && Objects.equals(_chunkZ, that._chunkZ); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/pom.xml b/Plugins/Mineplex.Game.Clans/pom.xml index 73a6d5ad9..02d16f542 100644 --- a/Plugins/Mineplex.Game.Clans/pom.xml +++ b/Plugins/Mineplex.Game.Clans/pom.xml @@ -23,6 +23,11 @@ ${project.groupId} mineplex-minecraft-game-classcombat ${project.version} + + + ${project.groupId} + mineplex-clansqueue-common + ${project.version} 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 b67c40b58..0ff1e5698 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java @@ -77,7 +77,7 @@ import net.minecraft.server.v1_8_R3.MinecraftServer; public class Clans extends JavaPlugin { - public static final String MAP = "Season 3"; + public static final String MAP = "Season 4"; public static boolean HARDCORE = false; @@ -116,7 +116,7 @@ public class Clans extends JavaPlugin DelayedTask.Initialize(this); Recharge.Initialize(this); - VisibilityManager.Initialize(this); + require(VisibilityManager.class); // new ProfileCacheManager(this); _donationManager = require(DonationManager.class); 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 e7a2a998a..3541d8129 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 @@ -9,7 +9,6 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.common.util.C; -import mineplex.core.common.util.F; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClanTips.TipType; @@ -61,7 +60,7 @@ public class ClanEnergyTracker extends MiniPlugin Triple energyBounds = _updateMap.get(type); - if (energyBounds != null && energyRemaining > energyBounds.getLeft().longValue() && energyRemaining < energyBounds.getMiddle().longValue()) + if (energyBounds != null && energyRemaining > energyBounds.getLeft() && energyRemaining < energyBounds.getMiddle()) { _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/ClanInfo.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java index fe1f9b517..1cbd22ecf 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 @@ -26,7 +26,7 @@ import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.common.util.UtilWorld; import mineplex.game.clans.clans.ClansUtility.ClanRelation; -import mineplex.game.clans.clans.tntGenerator.TntGenerator; +import mineplex.game.clans.clans.tntgenerator.TntGenerator; import mineplex.game.clans.core.ClaimLocation; import mineplex.game.clans.core.repository.tokens.ClanAllianceToken; import mineplex.game.clans.core.repository.tokens.ClanMemberToken; 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 961b2b368..930399ff2 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 @@ -260,8 +260,10 @@ public class ClansAdmin { public void run() { - if (nameExists.booleanValue()) + if (nameExists) + { UtilPlayer.message(caller, F.main("Clans Admin", "Clan name cannot be a Player name.")); + } else { Clans.getClanDataAccess().create(caller.getName(), args[2], true, new Callback() diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDataAccessLayer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDataAccessLayer.java index 81e0244f6..738620527 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDataAccessLayer.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDataAccessLayer.java @@ -22,7 +22,7 @@ import mineplex.game.clans.clans.event.ClanJoinEvent; import mineplex.game.clans.clans.event.ClanLeaveEvent; import mineplex.game.clans.clans.event.ClanSetHomeEvent; import mineplex.game.clans.clans.scoreboard.ClansScoreboardManager; -import mineplex.game.clans.clans.tntGenerator.TntGenerator; +import mineplex.game.clans.clans.tntgenerator.TntGenerator; import mineplex.game.clans.core.ClaimLocation; import mineplex.game.clans.core.repository.ClanRepository; import mineplex.game.clans.core.repository.ClanTerritory; @@ -507,13 +507,9 @@ public class ClansDataAccessLayer _manager.getClaimMap().put(chunk, claim); // Save - runAsync(new Runnable() + runAsync(() -> { - @Override - public void run() - { - _repository.addTerritoryClaim(clan.getId(), chunk, safe); - } + _repository.addTerritoryClaim(clan.getId(), chunk, safe); }); // Visual @@ -751,7 +747,7 @@ public class ClansDataAccessLayer { if (callback != null) { - callback.run(Boolean.valueOf(ran)); + callback.run(ran); } 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 e3171d54c..154791b34 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 @@ -142,7 +142,21 @@ public class ClansGame extends MiniPlugin { if (!event.getPlayer().isSneaking() || !hasItem) { - _clans.getClassShop().attemptShopOpen(event.getPlayer()); + if (Recharge.Instance.use(event.getPlayer(), "Open Skill Table GUI", 1000, false, false)) + { + runSyncLater(() -> + { + if (event.getPlayer().isDead() || !event.getPlayer().isOnline() || !event.getPlayer().isValid()) + { + return; + } + if (UtilMath.offsetSquared(event.getClickedBlock().getLocation(), event.getPlayer().getLocation()) > 36) + { + return; + } + _clans.getClassShop().attemptShopOpen(event.getPlayer()); + }, 10); + } 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 24963f615..d7083c460 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 @@ -29,7 +29,6 @@ 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.server.ServerListPingEvent; import org.bukkit.event.vehicle.VehicleEnterEvent; @@ -38,6 +37,11 @@ import org.bukkit.plugin.java.JavaPlugin; import com.google.common.io.ByteArrayDataOutput; import com.google.common.io.ByteStreams; +import com.mineplex.clansqueue.common.ClansQueueMessenger; +import com.mineplex.clansqueue.common.QueueConstant; +import com.mineplex.clansqueue.common.messages.ClansServerStatusMessage; +import com.mineplex.clansqueue.common.messages.ServerOfflineMessage; +import com.mineplex.clansqueue.common.messages.ServerOnlineMessage; import mineplex.core.Managers; import mineplex.core.MiniClientPlugin; @@ -91,8 +95,10 @@ 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.antiafk.AfkManager; import mineplex.game.clans.clans.banners.BannerManager; import mineplex.game.clans.clans.boxes.BoxManager; +import mineplex.game.clans.clans.cash.CashShopManager; import mineplex.game.clans.clans.commands.ClansAllyChatCommand; import mineplex.game.clans.clans.commands.ClansChatCommand; import mineplex.game.clans.clans.commands.ClansCommand; @@ -104,19 +110,21 @@ import mineplex.game.clans.clans.event.ClansPlayerDeathEvent; import mineplex.game.clans.clans.gui.ClanShop; import mineplex.game.clans.clans.invsee.InvseeManager; import mineplex.game.clans.clans.loot.LootManager; +import mineplex.game.clans.clans.moderation.antialt.AltManager; import mineplex.game.clans.clans.mounts.MountManager; import mineplex.game.clans.clans.nameblacklist.ClansBlacklist; import mineplex.game.clans.clans.nether.NetherManager; import mineplex.game.clans.clans.observer.ObserverManager; import mineplex.game.clans.clans.playtime.Playtime; import mineplex.game.clans.clans.potato.PotatoManager; +import mineplex.game.clans.clans.pvptimer.PvPTimerManager; import mineplex.game.clans.clans.redis.ClanDeleteCommandHandler; import mineplex.game.clans.clans.redis.ClanLoadCommandHandler; import mineplex.game.clans.clans.regions.ClansRegions; import mineplex.game.clans.clans.scoreboard.ClansScoreboardManager; import mineplex.game.clans.clans.siege.SiegeManager; -import mineplex.game.clans.clans.supplyDrop.SupplyDropManager; -import mineplex.game.clans.clans.tntGenerator.TntGeneratorManager; +import mineplex.game.clans.clans.supplydrop.SupplyDropManager; +import mineplex.game.clans.clans.tntgenerator.TntGeneratorManager; import mineplex.game.clans.clans.war.WarManager; import mineplex.game.clans.clans.warpoints.WarPointEvasion; import mineplex.game.clans.clans.worldevent.WorldEventManager; @@ -142,8 +150,10 @@ 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.Assassin.Blink; +import mineplex.minecraft.game.classcombat.Skill.Assassin.Flash; +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; @@ -241,6 +251,7 @@ public class ClansManager extends MiniClientPlugin implements IRelat private ObserverManager _observerManager; private Punish _punish; private TaskManager _taskManager; + private PvPTimerManager _timerManager = require(PvPTimerManager.class); private int _inviteExpire = 2; private int _nameMin = 3; @@ -266,6 +277,8 @@ public class ClansManager extends MiniClientPlugin implements IRelat public ClanTips ClanTips; + private boolean _disabling = false; + // Spawn area public ClansManager(JavaPlugin plugin, 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) @@ -301,7 +314,7 @@ public class ClansManager extends MiniClientPlugin implements IRelat _damageManager = new DamageManager(plugin, _combatManager, _npcManager, _disguiseManager, _condition); _condition.setDamageManager(_damageManager); - _worldEvent = new WorldEventManager(plugin, this, _damageManager, _lootManager, blockRestore, _clanRegions, null); + _worldEvent = new WorldEventManager(plugin, this, _damageManager, _lootManager, blockRestore, _clanRegions); _taskManager = new TaskManager(plugin, _clientManager); @@ -317,7 +330,7 @@ public class ClansManager extends MiniClientPlugin implements IRelat _tutorial = new TutorialManager(plugin, clientManager, donationManager, chat, hologramManager, this, _npcManager, _taskManager); // _itemMapManager = new ItemMapManager(this, _tutorial, _worldEvent); new TntGeneratorManager(plugin, this); - new SupplyDropManager(plugin, this); + new SupplyDropManager(plugin); new InvseeManager(this); new MenuManager(plugin); @@ -363,14 +376,29 @@ public class ClansManager extends MiniClientPlugin implements IRelat skillManager.removeSkill("Shield Smash"); skillManager.removeSkill("Illusion"); skillManager.removeSkill("Smoke Bomb"); - // Check if any Ice Prison blocks will be placed inside a safe zone + // Check if any Ice Prison blocks will be placed inside a safe zone or world event // fixme Is there any way of checking the destination beforehand? // Although if the user is trying to launch an Ice Prison into a safezone they should know better skillManager.GetSkill("Ice Prison").setLocationFilter(location -> { - ClanTerritory territory = _clanUtility.getClaim(location); - return territory == null || !territory.Safe; + { + ClanTerritory territory = _clanUtility.getClaim(location); + if (territory != null && territory.Safe) + { + return false; + } + } + { + if (_worldEvent.isInEvent(location, true)) + { + return false; + } + } + + return true; }); + ((Blink)skillManager.GetSkill("Blink")).setAllowTrapping(true); + ((Flash)skillManager.GetSkill("Flash")).setAllowTrapping(true); registerEvents(new Listener() { @EventHandler @@ -389,12 +417,13 @@ public class ClansManager extends MiniClientPlugin implements IRelat { Condition poisonShock = _condition.GetActiveCondition(event.GetDamageePlayer(), Condition.ConditionType.POISON_SHOCK); if (poisonShock != null) + { event.SetIgnoreArmor(true); + } } } }); - _worldEvent.setFactory(skillManager); _classManager = new ClassManager(plugin, _clientManager, donationManager, skillManager, itemFactory); // Register redis based server commands @@ -489,14 +518,23 @@ public class ClansManager extends MiniClientPlugin implements IRelat new BoxManager(plugin); + new AltManager(); + _restartManager = new RestartManager(plugin); + require(CashShopManager.class); + + require(AfkManager.class); + generatePermissions(); + + ServerOnlineMessage message = new ServerOnlineMessage(); + message.ServerName = UtilServer.getServerName(); + ClansQueueMessenger.getMessenger(UtilServer.getServerName()).transmitMessage(message, QueueConstant.SERVICE_MESSENGER_IDENTIFIER); } private void generatePermissions() { - PermissionGroup.MOD.revokePermission(Teleport.Perm.TELEPORT_COMMAND); PermissionGroup.ADMIN.setPermission(Teleport.Perm.TELEPORT_COMMAND, true, true); @@ -518,6 +556,7 @@ public class ClansManager extends MiniClientPlugin implements IRelat PermissionGroup.CONTENT.setPermission(Perm.JOIN_FULL, true, true); PermissionGroup.BUILDER.setPermission(Perm.PREFIX_SHOWN, true, true); PermissionGroup.TRAINEE.setPermission(Perm.JOIN_FULL, true, true); + PermissionGroup.PLAYER.setPermission(CoreClientManager.Perm.JOIN_FULL, true, true); } @Override @@ -722,7 +761,7 @@ public class ClansManager extends MiniClientPlugin implements IRelat // 0 is set aside for active build so we just dupe build to this row // whenever we update it. - activeBuild.CustomBuildNumber = Integer.valueOf(0); + activeBuild.CustomBuildNumber = 0; _classManager.GetRepository().SaveCustomBuild(activeBuild); } } @@ -869,7 +908,7 @@ public class ClansManager extends MiniClientPlugin implements IRelat if (client.IsGameClass(IPvpClass.ClassType.Mage) || client.IsGameClass(IPvpClass.ClassType.Knight) || client.IsGameClass(IPvpClass.ClassType.Brute)) { event.setCancelled(true); - UtilPlayer.message(player, F.main("Clans", "You cannot use " + F.elem("bow") + " as a " + F.elem(client.GetGameClass().GetName()))); + UtilPlayer.message(player, F.main("Clans", "You cannot use " + F.elem("Bow") + " as a " + F.elem(client.GetGameClass().GetName()))); } } } @@ -1284,6 +1323,7 @@ public class ClansManager extends MiniClientPlugin implements IRelat // disable event to WorldEventManager // This is so that we can prevent any permanent world changes with // events + _disabling = true; _blockRestore.onDisable(); _worldEvent.onDisable(); _goldManager.onDisable(); @@ -1293,16 +1333,19 @@ public class ClansManager extends MiniClientPlugin implements IRelat _restartManager.onDisable(); _observerManager.onDisable(); Managers.get(MountManager.class).onDisable(); + ServerOfflineMessage message = new ServerOfflineMessage(); + message.ServerName = UtilServer.getServerName(); + ClansQueueMessenger.getMessenger(UtilServer.getServerName()).transmitMessage(message, QueueConstant.SERVICE_MESSENGER_IDENTIFIER); } - @EventHandler(priority = EventPriority.HIGHEST) - public void onJoin(PlayerLoginEvent event) + @EventHandler + public void transmitQueueStatus(UpdateEvent event) { - if (_restartManager.isRestarting()) + if (event.getType() != UpdateType.FAST) { return; } - + int online = 0; for (Player player : UtilServer.getPlayers()) @@ -1315,15 +1358,11 @@ public class ClansManager extends MiniClientPlugin implements IRelat online++; } - if (online >= UtilServer.getServer().getMaxPlayers() && !_clientManager.Get(event.getPlayer()).hasPermission(Perm.JOIN_FULL) && !event.getPlayer().isWhitelisted() && !event.getPlayer().isOp()) - { - event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "This Clans server is full! Try again soon"); - } - else - { - event.allow(); - event.setResult(PlayerLoginEvent.Result.ALLOWED); - } + ClansServerStatusMessage message = new ClansServerStatusMessage(); + message.ServerName = UtilServer.getServerName(); + message.OpenSlots = Math.max(0, Bukkit.getMaxPlayers() - online); + message.Online = !_restartManager.isRestarting() && !_disabling; + ClansQueueMessenger.getMessenger(UtilServer.getServerName()).transmitMessage(message, QueueConstant.SERVICE_MESSENGER_IDENTIFIER); } @EventHandler @@ -1494,7 +1533,7 @@ public class ClansManager extends MiniClientPlugin implements IRelat public boolean hasTimer(Player player) { - return false; + return _timerManager.hasTimer(player); } public ClansBlacklist getBlacklist() diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java index f019fa1d5..247f6caa9 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java @@ -738,7 +738,7 @@ public class ClansUtility @Override public void run(Boolean data) { - if (!data.booleanValue()) + if (!data) { UtilPlayer.message(caller, F.main("Clans", "There was an error processing your request. Try again later")); } @@ -879,9 +879,9 @@ public class ClansUtility // Claim Timer if (_clansManager.getUnclaimMap().containsKey(chunk)) { - if (!UtilTime.elapsed(_clansManager.getUnclaimMap().get(chunk).longValue(), _clansManager.getReclaimTime())) + if (!UtilTime.elapsed(_clansManager.getUnclaimMap().get(chunk), _clansManager.getReclaimTime())) { - UtilPlayer.message(caller, F.main("Clans", "This Territory cannot be claimed for " + F.time(UtilTime.convertString(_clansManager.getReclaimTime() - (System.currentTimeMillis() - _clansManager.getUnclaimMap().get(chunk).longValue()), 1, UtilTime.TimeUnit.FIT)) + ".")); + UtilPlayer.message(caller, F.main("Clans", "This Territory cannot be claimed for " + F.time(UtilTime.convertString(_clansManager.getReclaimTime() - (System.currentTimeMillis() - _clansManager.getUnclaimMap().get(chunk)), 1, UtilTime.TimeUnit.FIT)) + ".")); return false; } @@ -1228,6 +1228,12 @@ public class ClansUtility UtilPlayer.message(caller, F.main("Clans", "You cannot invite more members until you remove some allies.")); return; } + + if (clan.isInvited(target.getName())) + { + UtilPlayer.message(caller, F.main("Clans", "Your Clan has already invited " + F.elem(target.getName()) + ".")); + return; + } // Inform clan.inform(F.name(caller.getName()) + " invited " + F.name(target.getName()) + " to join your Clan.", caller.getName()); 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 a5edc48de..54365b3a9 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 @@ -37,7 +37,7 @@ public class AmplifierGUI implements Listener { _viewer = viewer; _manager = manager; - _inventory = Bukkit.createInventory(viewer, 9, C.cClansNether + "Rune Amplifiers"); + _inventory = Bukkit.createInventory(viewer, 27, C.cClansNether + "Rune Amplifiers"); Bukkit.getPluginManager().registerEvents(this, manager.getPlugin()); propagate(); @@ -68,27 +68,38 @@ public class AmplifierGUI implements Listener public void propagate() { getItems().clear(); - Integer slot = 0; + _boundSlots.clear(); + int[] slots = {12, 14}; + int i = 0; for (AmplifierType type : AmplifierType.values()) { 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()); + int slot = slots[i++]; + getItems().put(slot, new ItemBuilder(Material.NETHER_STAR) + .setTitle(type.getDisplayName()) + .addLore(C.cYellow + "Summons a " + C.cClansNether + "Nether Portal" + C.cYellow + " in Shops") + .addLore(C.cYellow + "And doubles the chance of Rune drops.") + .addLore(C.cRed + " ") + .addLore(C.cGreen + ">Click to Activate<") + .addLore(C.cBlue + " ") + .addLore(C.cDAqua + "You own " + F.greenElem(String.valueOf(owned)) + C.cDAqua + " " + type.getCleanDisplayName() + "s") + .build() + ); _boundSlots.put(slot, type); - slot++; } refresh(); } /** - * Fils the confirmation menu with buttons + * Fills the confirmation menu with buttons */ 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()); + getItems().put(12, new ItemBuilder(Material.STAINED_GLASS_PANE).setData((short) 5).setTitle(C.cGreen + "Confirm").build()); + getItems().put(14, new ItemBuilder(Material.STAINED_GLASS_PANE).setData((short) 14).setTitle(C.cRed + "Cancel").build()); refresh(); } @@ -124,7 +135,7 @@ public class AmplifierGUI implements Listener return; } - if (slot == 3) + if (slot == 12) { _manager.runSyncLater(() -> { @@ -132,7 +143,7 @@ public class AmplifierGUI implements Listener getViewer().closeInventory(); }, 1L); } - if (slot == 5) + if (slot == 14) { _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 1f0bf8ee9..ea7e57796 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 @@ -135,7 +135,7 @@ public class AmplifierManager extends MiniPlugin private AmplifierType(String extension, String displayName, long duration) { _extension = extension; - _display = C.cClansNether + displayName; + _display = displayName; _duration = duration; } @@ -153,6 +153,11 @@ public class AmplifierManager extends MiniPlugin * @return The display name for this amplifier in this GUI */ public String getDisplayName() + { + return C.cClansNether + _display; + } + + public String getCleanDisplayName() { return _display; } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/antiafk/AfkManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/antiafk/AfkManager.java new file mode 100644 index 000000000..6425c7b4d --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/antiafk/AfkManager.java @@ -0,0 +1,108 @@ +package mineplex.game.clans.clans.antiafk; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerMoveEvent; + +import mineplex.core.MiniPlugin; +import mineplex.core.ReflectivelyCreateMiniPlugin; +import mineplex.core.account.permissions.Permission; +import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.portal.GenericServer; +import mineplex.core.portal.Intent; +import mineplex.core.portal.Portal; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClansManager; + +@ReflectivelyCreateMiniPlugin +public class AfkManager extends MiniPlugin +{ + public enum Perm implements Permission + { + BYPASS_AFK_KICK + } + + private static final long AFK_TIME_ALLOWED = UtilTime.convert(10, TimeUnit.MINUTES, TimeUnit.MILLISECONDS); + + private AfkManager() + { + super("AFK Manager"); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionGroup.ADMIN.setPermission(Perm.BYPASS_AFK_KICK, true, true); + PermissionGroup.YOUTUBE.setPermission(Perm.BYPASS_AFK_KICK, false, true); + PermissionGroup.TWITCH.setPermission(Perm.BYPASS_AFK_KICK, false, true); + } + + private boolean matchYawPitch(Location loc, Location loc2) + { + if (loc.getYaw() != loc2.getYaw()) + { + return false; + } + if (loc.getPitch() != loc2.getPitch()) + { + return false; + } + return true; + } + + @EventHandler + public void onMove(PlayerMoveEvent event) + { + if (UtilMath.offsetSquared(event.getFrom(), event.getTo()) > 0) + { + if (!matchYawPitch(event.getFrom(), event.getTo())) + { + UtilEnt.SetMetadata(event.getPlayer(), "AFK_MOVE", System.currentTimeMillis()); + } + } + } + + @EventHandler + public void onJoin(PlayerJoinEvent event) + { + UtilEnt.SetMetadata(event.getPlayer(), "AFK_MOVE", System.currentTimeMillis()); + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC_05) + { + return; + } + Bukkit.getOnlinePlayers().forEach(player -> + { + Long lastMove = UtilEnt.GetMetadata(player, "AFK_MOVE"); + if (lastMove != null) + { + if (UtilTime.elapsed(lastMove, AFK_TIME_ALLOWED) && !ClansManager.getInstance().getClientManager().Get(player).hasPermission(Perm.BYPASS_AFK_KICK)) + { + UtilPlayer.message(player, F.main(getName(), "You have been sent to the hub for idling too long!")); + Portal.getInstance().sendPlayerToGenericServer(player, GenericServer.CLANS_HUB, Intent.KICK); + } + } + }); + } + + @EventHandler + public void onDeath(PlayerDeathEvent event) + { + runSyncLater(() -> event.getEntity().spigot().respawn(), 10); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/bosstoken/BossTokenPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/bosstoken/BossTokenPage.java new file mode 100644 index 000000000..64a1c9665 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/bosstoken/BossTokenPage.java @@ -0,0 +1,113 @@ +package mineplex.game.clans.clans.bosstoken; + +import java.util.Arrays; +import java.util.List; +import java.util.function.BiFunction; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.skin.SkinData; +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.core.recharge.Recharge; +import mineplex.core.shop.page.ShopPageBase; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.worldevent.WorldEventManager; +import mineplex.game.clans.clans.worldevent.WorldEventType; + +public class BossTokenPage extends ShopPageBase +{ + public BossTokenPage(WorldEventManager plugin, BossTokenShop shop, String name, Player player) + { + super(plugin, shop, ClansManager.getInstance().getClientManager(), ClansManager.getInstance().getDonationManager(), name, player, 27); + + buildPage(); + } + + @Override + protected void buildPage() + { + int[] slots = {12, 14}; + int i = 0; + for (TokenType type : TokenType.values()) + { + int owned = ClansManager.getInstance().getInventoryManager().Get(_player).getItemCount(type.getItemName()); + int slot = slots[i++]; + addButton(slot, type.getButton(C.cRed + type.getDisplay() + " Summon Token", Arrays.asList( + C.cYellow + "Summon the powerful " + type.getDisplay(), + C.cYellow + "In the " + C.cRed + "Borderlands", + C.cRed + " ", + C.cGreen + ">Click to Activate<", + C.cBlue + " ", + C.cDAqua + "You own " + F.greenElem(String.valueOf(Math.max(owned, 0))) + C.cDAqua + " " + type.getDisplay() + " Summon Tokens" + ) + ), (player, clickType) -> + { + if (!Recharge.Instance.use(player, "Clans Box Click", 1000, false, false)) + { + return; + } + if (owned < 1) + { + playDenySound(player); + UtilPlayer.message(player, F.main(getPlugin().getName(), "You do not have enough of that token! Purchase some at http://www.mineplex.com/shop!")); + return; + } + if (!getPlugin().getEvents().isEmpty()) + { + playDenySound(player); + UtilPlayer.message(player, F.main(getPlugin().getName(), "There is already an ongoing event! Try again later!")); + return; + } + WorldEventManager manager = getPlugin(); + player.closeInventory(); + manager.startEventFromType(type.getType()); + ClansManager.getInstance().getInventoryManager().addItemToInventory(player, type.getItemName(), -1); + }); + } + } + + private enum TokenType + { + SKELETON("Skeleton", "Skeleton King", WorldEventType.SKELETON_KING, (name, lore) -> new ItemBuilder(Material.SKULL_ITEM).setData((short)1).setTitle(name).addLores(lore).build()), + WIZARD("Wizard", "Iron Wizard", WorldEventType.IRON_WIZARD, SkinData.IRON_GOLEM::getSkull) + ; + + private final String _itemEnding; + private final String _display; + private final WorldEventType _type; + private final BiFunction, ItemStack> _buttonCreator; + + private TokenType(String itemEnding, String display, WorldEventType type, BiFunction, ItemStack> buttonCreator) + { + _itemEnding = itemEnding; + _display = display; + _type = type; + _buttonCreator = buttonCreator; + } + + public String getItemName() + { + return "Clans Boss Token " + _itemEnding; + } + + public String getDisplay() + { + return _display; + } + + public WorldEventType getType() + { + return _type; + } + + public ItemStack getButton(String itemName, List lore) + { + return _buttonCreator.apply(itemName, lore); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/bosstoken/BossTokenShop.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/bosstoken/BossTokenShop.java new file mode 100644 index 000000000..9f4a51795 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/bosstoken/BossTokenShop.java @@ -0,0 +1,22 @@ +package mineplex.game.clans.clans.bosstoken; + +import org.bukkit.entity.Player; + +import mineplex.core.shop.ShopBase; +import mineplex.core.shop.page.ShopPageBase; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.worldevent.WorldEventManager; + +public class BossTokenShop extends ShopBase +{ + public BossTokenShop(WorldEventManager plugin) + { + super(plugin, ClansManager.getInstance().getClientManager(), ClansManager.getInstance().getDonationManager(), "Boss Token"); + } + + @Override + protected ShopPageBase> buildPagesFor(Player player) + { + return new BossTokenPage(getPlugin(), this, "Boss Tokens", player); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxManager.java index daa2f3a52..63e002e34 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxManager.java @@ -17,46 +17,27 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.Managers; import mineplex.core.MiniPlugin; -import mineplex.core.account.permissions.Permission; -import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.command.CommandBase; import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; import mineplex.game.clans.clans.boxes.extra.BuilderBoxInventory; -import mineplex.game.clans.clans.boxes.extra.DyeBoxSpinner; public class BoxManager extends MiniPlugin { - public enum Perm implements Permission - { - BOX_COMMAND, - } - - private BuilderBoxInventory _builderBox; + private final BuilderBoxInventory _builderBox; + private final BoxShop _shop; public BoxManager(JavaPlugin plugin) { super("Box Manager", plugin); - final BoxShop shop = new BoxShop(this); + _shop = new BoxShop(this); _builderBox = new BuilderBoxInventory(); - - addCommand(new CommandBase(this, Perm.BOX_COMMAND, "boxes", "box") - { - @Override - public void Execute(Player caller, String[] args) - { - shop.attemptShopOpen(caller); - } - }); - - generatePermissions(); } - private void generatePermissions() + public void openDyePage(Player player) { - PermissionGroup.PLAYER.setPermission(Perm.BOX_COMMAND, true, true); + _shop.attemptShopOpen(player); } @EventHandler(priority=EventPriority.HIGHEST) @@ -184,7 +165,7 @@ public class BoxManager extends MiniPlugin { BUILDER_BOX("Clans Builder Box", C.cGold + "Builder's Box", Material.GLOWSTONE, Managers.get(BoxManager.class)._builderBox::open), @SuppressWarnings("deprecation") - DYE_BOX("Clans Dye Box", C.cGreen + "Dye Box", Material.INK_SACK, DyeColor.RED.getDyeData(), DyeBoxSpinner::createSpinner), + DYE_BOX(null, C.cGreen + "Dye Box", Material.INK_SACK, DyeColor.RED.getDyeData(), Managers.get(BoxManager.class)::openDyePage), ; private String _itemName, _displayName; @@ -220,6 +201,10 @@ public class BoxManager extends MiniPlugin public ItemStack getDisplayItem(int owned) { ItemBuilder newBuilder = new ItemBuilder(_displayBuilder.build()); + if (owned == -1) + { + return newBuilder.build(); + } if (owned > 0) { newBuilder.setGlow(true); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxOverviewPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxOverviewPage.java deleted file mode 100644 index bd17da0de..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxOverviewPage.java +++ /dev/null @@ -1,49 +0,0 @@ -package mineplex.game.clans.clans.boxes; - -import org.bukkit.Sound; -import org.bukkit.entity.Player; - -import mineplex.core.recharge.Recharge; -import mineplex.core.shop.item.IButton; -import mineplex.core.shop.page.ShopPageBase; -import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.clans.boxes.BoxManager.BoxType; - -public class BoxOverviewPage extends ShopPageBase -{ - public BoxOverviewPage(BoxManager plugin, BoxShop shop, String name, Player player) - { - super(plugin, shop, ClansManager.getInstance().getClientManager(), ClansManager.getInstance().getDonationManager(), name, player, 9); - - buildPage(); - } - - @Override - protected void buildPage() - { - int[] slots = {3, 5}; - for (int i = 0; i < BoxType.values().length && i < slots.length; i++) - { - BoxType type = BoxType.values()[i]; - int slot = slots[i]; - final int owns = ClansManager.getInstance().getInventoryManager().Get(getPlayer()).getItemCount(type.getItemName()); - IButton button = (player, clickType) -> - { - if (owns < 1) - { - playDenySound(player); - } - else - { - player.closeInventory(); - player.playSound(player.getLocation(), Sound.CHEST_OPEN, 1f, 1f); - if (Recharge.Instance.use(player, "Clans Box Click", 1000, false, false)) - { - type.onUse(player); - } - } - }; - addButton(slot, type.getDisplayItem(owns), button); - } - } -} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxShop.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxShop.java index bc7e8a852..d91caafbd 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxShop.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxShop.java @@ -10,12 +10,12 @@ public class BoxShop extends ShopBase { public BoxShop(BoxManager plugin) { - super(plugin, ClansManager.getInstance().getClientManager(), ClansManager.getInstance().getDonationManager(), "Your Boxes"); + super(plugin, ClansManager.getInstance().getClientManager(), ClansManager.getInstance().getDonationManager(), "Boxes"); } @Override protected ShopPageBase> buildPagesFor(Player player) { - return new BoxOverviewPage(getPlugin(), this, "Your Boxes", player); + return new DyeBoxPage(getPlugin(), this, "Dye Boxes", player); } } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/DyeBoxPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/DyeBoxPage.java new file mode 100644 index 000000000..8d62274ec --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/DyeBoxPage.java @@ -0,0 +1,107 @@ +package mineplex.game.clans.clans.boxes; + +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.ThreadLocalRandom; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import org.bukkit.DyeColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; + +import mineplex.core.common.skin.SkinData; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.recharge.Recharge; +import mineplex.core.shop.page.ShopPageBase; +import mineplex.game.clans.clans.ClansManager; + +public class DyeBoxPage extends ShopPageBase +{ + private static final List COMMON_COLORS = Stream.of(DyeColor.values()).filter(c -> c != DyeColor.BLACK && c != DyeColor.WHITE).collect(Collectors.toList()); + private static final List RARE_COLORS = Arrays.asList(DyeColor.WHITE, DyeColor.BLACK); + + public DyeBoxPage(BoxManager plugin, BoxShop shop, String name, Player player) + { + super(plugin, shop, ClansManager.getInstance().getClientManager(), ClansManager.getInstance().getDonationManager(), name, player, 27); + + buildPage(); + } + + @SuppressWarnings("deprecation") + @Override + protected void buildPage() + { + int[] slots = {12, 14}; + int i = 0; + for (DyeType type : DyeType.values()) + { + int owned = ClansManager.getInstance().getInventoryManager().Get(_player).getItemCount(type.getItemName()); + int slot = slots[i++]; + addButton(slot, SkinData.CLANS_DYE_BOX.getSkull(C.cRed + (type.isGilded() ? "Gilded " : "") + "Dye Box", Arrays.asList( + C.cYellow + "Open a box containing " + F.greenElem(String.valueOf(type.getDyeCount())) + C.cYellow + " random dyes!", + C.cRed + " ", + C.cGreen + ">Click to Activate<", + C.cBlue + " ", + C.cDAqua + "You own " + F.greenElem(String.valueOf(Math.max(owned, 0))) + C.cDAqua + (type.isGilded() ? " Gilded" : "") + " Dye Boxes")), + (player, clickType) -> + { + if (!Recharge.Instance.use(player, "Clans Box Click", 1000, false, false)) + { + return; + } + if (owned < 1) + { + playDenySound(player); + UtilPlayer.message(player, F.main(getPlugin().getName(), "You do not have enough of that box! Purchase some at http://www.mineplex.com/shop!")); + return; + } + player.closeInventory(); + ClansManager.getInstance().getInventoryManager().addItemToInventory(player, type.getItemName(), -1); + for (int dye = 0; dye < type.getDyeCount(); dye++) + { + List options = ThreadLocalRandom.current().nextDouble() <= 0.05 ? RARE_COLORS : COMMON_COLORS; + DyeColor color = UtilMath.randomElement(options); + player.getInventory().addItem(new ItemBuilder(Material.INK_SACK).setData(color.getDyeData()).setTitle(C.cGold + "Dye").build()); + } + }); + } + } + + private enum DyeType + { + NORMAL("Clans Dye Box", false, 32), + GILDED("Clans Gilded Dye Box", true, 64) + ; + + private final String _itemName; + private final boolean _gilded; + private final int _dyeCount; + + private DyeType(String itemName, boolean gilded, int dyeCount) + { + _itemName = itemName; + _gilded = gilded; + _dyeCount = dyeCount; + } + + public String getItemName() + { + return _itemName; + } + + public boolean isGilded() + { + return _gilded; + } + + public int getDyeCount() + { + return _dyeCount; + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/extra/DyeBoxSpinner.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/extra/DyeBoxSpinner.java deleted file mode 100644 index 0186f6b56..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/extra/DyeBoxSpinner.java +++ /dev/null @@ -1,172 +0,0 @@ -package mineplex.game.clans.clans.boxes.extra; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - -import org.bukkit.Bukkit; -import org.bukkit.DyeColor; -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.InventoryClickEvent; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.ItemStack; - -import mineplex.core.common.util.C; -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.itemstack.ItemBuilder; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.clans.boxes.BoxManager.BoxType; - -public class DyeBoxSpinner implements Listener -{ - private Player _player; - private Inventory _inv; - private int _step; - private List _items; - - private boolean _givenRewards = false; - - private DyeBoxSpinner(Player player) - { - _player = player; - _inv = Bukkit.createInventory(player, 27, "Dye Box"); - _step = 0; - _items = new ArrayList<>(); - buildGUI(); - generateRewards(); - player.openInventory(_inv); - Bukkit.getPluginManager().registerEvents(this, UtilServer.getPlugin()); - } - - /** - * Upper and lower bounds are inclusive - */ - private int getRandom(int max, int min) - { - return UtilMath.r(max - min + 1) + min; - } - - @SuppressWarnings("deprecation") - private void buildGUI() - { - ItemStack border = new ItemBuilder(Material.STAINED_GLASS_PANE).setData((short)DyeColor.GRAY.getWoolData()).setTitle(C.cRed + " ").build(); - ItemStack fill = new ItemBuilder(Material.STAINED_GLASS_PANE).setData((short)DyeColor.BLACK.getWoolData()).setTitle(C.cRed + " ").build(); - for (int i = 0; i < 27; i++) - { - if (i < 9 || i > 17) - { - _inv.setItem(i, border); - } - else - { - _inv.setItem(i, fill); - } - } - } - - @SuppressWarnings("deprecation") - private void generateRewards() - { - List commonColors = Arrays.asList(DyeColor.values()).stream().filter(c -> c != DyeColor.BLACK && c != DyeColor.WHITE).collect(Collectors.toList()); - List rareColors = Arrays.asList(DyeColor.WHITE, DyeColor.BLACK); - for (int i = 1; i <= getRandom(9, 5); i++) - { - DyeColor color = null; - if (Math.random() <= 0.05) - { - color = UtilMath.randomElement(rareColors); - } - else - { - color = UtilMath.randomElement(commonColors); - } - - _items.add(new ItemBuilder(Material.INK_SACK).setData(color.getDyeData()).setTitle(C.cGold + "Dye").build()); - } - } - - private void giveRewards() - { - if (_givenRewards) - { - return; - } - _givenRewards = true; - _player.closeInventory(); - _items.forEach(_player.getInventory()::addItem); - UtilPlayer.message(_player, F.main("Dye Box", "You have redeemed your box contents!")); - } - - @SuppressWarnings("deprecation") - private void progress() - { - if (_step == 0) - { - _step++; - return; - } - if (_step < 10) - { - int slot = 18 - _step; - if (Math.max(18, slot) - Math.min(18, slot) <= _items.size()) - { - _inv.setItem(slot, new ItemBuilder(Material.STAINED_GLASS_PANE).setData((short)DyeColor.LIME.getWoolData()).setTitle(C.cRed + " ").build()); - } - _step++; - return; - } - if (_step == 10) - { - int slot = 17; - for (int i = 0; i < _items.size(); i++) - { - _inv.setItem(slot, _items.get(i)); - slot--; - } - _step++; - return; - } - } - - @EventHandler - public void onUpdate(UpdateEvent event) - { - if (event.getType() == UpdateType.FASTEST) - { - if (_player.getOpenInventory() == null || _player.getOpenInventory().getTopInventory() == null || !_player.getOpenInventory().getTopInventory().getName().equals("Dye Box")) - { - HandlerList.unregisterAll(this); - giveRewards(); - } - } - if (event.getType() == UpdateType.SEC) - { - progress(); - } - } - - @EventHandler - public void onClick(InventoryClickEvent event) - { - if (event.getWhoClicked().getEntityId() == _player.getEntityId()) - { - event.setCancelled(true); - } - } - - public static void createSpinner(Player player) - { - ClansManager.getInstance().getInventoryManager().addItemToInventory(player, BoxType.DYE_BOX.getItemName(), -1); - new DyeBoxSpinner(player); - } -} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/cash/CashOverviewPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/cash/CashOverviewPage.java new file mode 100644 index 000000000..73d3e3a65 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/cash/CashOverviewPage.java @@ -0,0 +1,143 @@ +package mineplex.game.clans.clans.cash; + +import java.util.Arrays; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; + +import mineplex.core.Managers; +import mineplex.core.common.skin.SkinData; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilServer; +import mineplex.core.inventory.ClientInventory; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.shop.page.ShopPageBase; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.amplifiers.AmplifierGUI; +import mineplex.game.clans.clans.boxes.BoxManager; +import mineplex.game.clans.clans.boxes.BoxManager.BoxType; +import mineplex.game.clans.clans.supplydrop.SupplyDropManager; + +public class CashOverviewPage extends ShopPageBase +{ + private static final int OVERVIEW_BUTTON_SLOT = 13; + private static final int RUNE_BUTTON_SLOT = 21; + private static final int BUILDERS_BUTTON_SLOT = 23; + private static final int SUPPLY_BUTTON_SLOT = 29; + private static final int DYE_BUTTON_SLOT = 31; + private static final int BOSS_BUTTON_SLOT = 33; + private static final int MOUNT_BUTTON_SLOT = 39; + private static final int BANNER_BUTTON_SLOT = 41; + + public CashOverviewPage(CashShopManager plugin, CashShop shop, String name, Player player) + { + super(plugin, shop, ClansManager.getInstance().getClientManager(), ClansManager.getInstance().getDonationManager(), name, player); + + buildPage(); + } + + @Override + protected void buildPage() + { + ClientInventory inv = ClansManager.getInstance().getInventoryManager().Get(getPlayer()); + int rune20 = inv.getItemCount("Rune Amplifier 20"); + int rune60 = inv.getItemCount("Rune Amplifier 60"); + int builders = inv.getItemCount(BoxType.BUILDER_BOX.getItemName()); + int supply = inv.getItemCount("Clans Supply Drop"); + int supplyGilded = inv.getItemCount("Clans Gilded Supply Drop"); + int dye = inv.getItemCount("Clans Dye Box"); + int dyeGilded = inv.getItemCount("Clans Gilded Dye Box"); + int skeleton = inv.getItemCount("Clans Boss Token Skeleton"); + int wizard = inv.getItemCount("Clans Boss Token Wizard"); + addButtonNoAction(OVERVIEW_BUTTON_SLOT, new ItemBuilder(Material.EMERALD) + .setTitle(C.cRed + C.Scramble + "1 " + C.cRed + "Mineplex Shop" + " " + C.Scramble + "1") + .addLore(C.cYellow + "Purchase powerful supply drops, boss summoning items,") + .addLore(C.cYellow + "and exclusive cosmetic items in our online store!") + .addLore(C.cRed + " ") + .addLore(C.cGreen + "http://www.mineplex.com/shop") + .build() + ); + addButton(RUNE_BUTTON_SLOT, new ItemBuilder(Material.NETHER_STAR) + .setTitle(C.cRed + "Rune Amplifier") + .addLore(C.cYellow + "Open a portal to the Nether in Shops") + .addLore(C.cYellow + "And double the chances for Rune drops!") + .addLore(C.cRed + " ") + .addLore(C.cDAqua + "You own " + F.greenElem(String.valueOf(rune20)) + C.cDAqua + " Twenty Minute Amplifiers") + .addLore(C.cDAqua + "You own " + F.greenElem(String.valueOf(rune60)) + C.cDAqua + " One Hour Amplifiers") + .build(), + (player, clickType) -> + { + player.closeInventory(); + new AmplifierGUI(player, ClansManager.getInstance().getAmplifierManager()); + }); + addButton(BUILDERS_BUTTON_SLOT, SkinData.CLANS_BUILDERS_BOX.getSkull(C.cRed + "Builder's Box", Arrays.asList( + C.cYellow + "Transform normal blocks into alternate forms", + C.cYellow + "Or otherwise unobtainable cosmetic blocks!", + C.cRed + " ", + C.cDAqua + "You own " + F.greenElem(String.valueOf(builders)) + C.cDAqua + " Builder's Boxes")), + (player, clickType) -> + { + if (builders < 1) + { + return; + } + player.closeInventory(); + BoxType.BUILDER_BOX.onUse(player); + }); + addButton(SUPPLY_BUTTON_SLOT, SkinData.CLANS_GILDED_SUPPLY_DROP.getSkull(C.cRed + "Supply Drop", Arrays.asList( + C.cYellow + "Call down Supply Drops to obtain", + C.cYellow + "Rare and valuable resources!", + C.cRed + " ", + C.cYellow + "Use " + C.cGreen + "/inventory" + C.cYellow + " to access Supply Drops", + C.cBlue + " ", + C.cDAqua + "You own " + F.greenElem(String.valueOf(supply)) + C.cDAqua + " Supply Drops", + C.cDAqua + "You own " + F.greenElem(String.valueOf(supplyGilded)) + C.cDAqua + " Gilded Supply Drops")), + (player, clickType) -> + { + player.closeInventory(); + Managers.get(SupplyDropManager.class).getShop().attemptShopOpen(player); + }); + addButton(DYE_BUTTON_SLOT, SkinData.CLANS_DYE_BOX.getSkull(C.cRed + "Dye Box", Arrays.asList( + C.cYellow + "Open a box containing a large amount", + C.cYellow + "Of different dyes to use!", + C.cRed + " ", + C.cDAqua + "You own " + F.greenElem(String.valueOf(dye)) + C.cDAqua + " Dye Boxes", + C.cDAqua + "You own " + F.greenElem(String.valueOf(dyeGilded)) + C.cDAqua + " Gilded Dye Boxes")), + (player, clickType) -> + { + player.closeInventory(); + Managers.get(BoxManager.class).openDyePage(player); + }); + addButton(BOSS_BUTTON_SLOT, new ItemBuilder(Material.GOLD_INGOT) + .setTitle(C.cRed + "Boss Summon Token") + .addLore(C.cYellow + "Summon powerful World Bosses to fight") + .addLore(C.cYellow + "Whenever you are most prepared!") + .addLore(C.cRed + " ") + .addLore(C.cYellow + "Use " + C.cGreen + "/inventory" + C.cYellow + " to access Boss Summon Tokens") + .addLore(C.cBlue + " ") + .addLore(C.cDAqua + "You own " + F.greenElem(String.valueOf(skeleton)) + C.cDAqua + " Skeleton King Tokens") + .addLore(C.cDAqua + "You own " + F.greenElem(String.valueOf(wizard)) + C.cDAqua + " Iron Wizard Tokens") + .build(), + (player, clickType) -> + { + player.closeInventory(); + ClansManager.getInstance().getWorldEvent().getShop().attemptShopOpen(player); + }); + addButtonNoAction(MOUNT_BUTTON_SLOT, new ItemBuilder(Material.DIAMOND_BARDING) + .setTitle(C.cRed + "Mount Skins") + .addLore(C.cYellow + "Stroll around the map in style!") + .build() + ); + addButton(BANNER_BUTTON_SLOT, new ItemBuilder(Material.BANNER) + .setTitle(C.cRed + "Clan Banner") + .addLore(C.cYellow + "Show off your Clan Pride!") + .build(), + (player, clickType) -> + { + player.closeInventory(); + UtilServer.CallEvent(new PlayerCommandPreprocessEvent(player, "/banner")); + }); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/cash/CashShop.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/cash/CashShop.java new file mode 100644 index 000000000..2d08ae96b --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/cash/CashShop.java @@ -0,0 +1,21 @@ +package mineplex.game.clans.clans.cash; + +import org.bukkit.entity.Player; + +import mineplex.core.shop.ShopBase; +import mineplex.core.shop.page.ShopPageBase; +import mineplex.game.clans.clans.ClansManager; + +public class CashShop extends ShopBase +{ + public CashShop(CashShopManager manager) + { + super(manager, ClansManager.getInstance().getClientManager(), ClansManager.getInstance().getDonationManager(), "Online Store"); + } + + @Override + protected ShopPageBase> buildPagesFor(Player player) + { + return new CashOverviewPage(getPlugin(), this, "Online Store", player); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/cash/CashShopManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/cash/CashShopManager.java new file mode 100644 index 000000000..8095713e3 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/cash/CashShopManager.java @@ -0,0 +1,42 @@ +package mineplex.game.clans.clans.cash; + +import org.bukkit.entity.Player; + +import mineplex.core.MiniPlugin; +import mineplex.core.ReflectivelyCreateMiniPlugin; +import mineplex.core.account.permissions.Permission; +import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.command.CommandBase; + +@ReflectivelyCreateMiniPlugin +public class CashShopManager extends MiniPlugin +{ + public enum Perm implements Permission + { + INVENTORY_COMMAND_PERMISSION, + } + + private final CashShop _shop; + + private CashShopManager() + { + super("Online Store"); + + _shop = new CashShop(this); + + addCommand(new CommandBase(this, Perm.INVENTORY_COMMAND_PERMISSION, "inventory") + { + public void Execute(Player caller, String[] args) + { + _shop.attemptShopOpen(caller); + } + }); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionGroup.PLAYER.setPermission(Perm.INVENTORY_COMMAND_PERMISSION, true, true); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/freeze/ClansFreezeManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/freeze/ClansFreezeManager.java index 4f91363ad..11857393a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/freeze/ClansFreezeManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/freeze/ClansFreezeManager.java @@ -2,9 +2,11 @@ package mineplex.game.clans.clans.freeze; import java.util.HashMap; import java.util.Map; +import java.util.Set; import java.util.UUID; import org.bukkit.Bukkit; +import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -12,12 +14,18 @@ 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.PlayerDropItemEvent; +import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerToggleFlightEvent; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; +import com.google.common.collect.Sets; + import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.Permission; @@ -28,10 +36,15 @@ 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.slack.SlackAPI; +import mineplex.core.slack.SlackMessage; +import mineplex.core.slack.SlackTeam; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.event.ClansCommandExecutedEvent; +import mineplex.game.clans.clans.event.IronDoorOpenEvent; import mineplex.game.clans.clans.freeze.commands.FreezeCommand; +import mineplex.game.clans.clans.freeze.commands.PanicCommand; import mineplex.game.clans.clans.freeze.commands.UnfreezeCommand; import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; @@ -42,12 +55,16 @@ public class ClansFreezeManager extends MiniPlugin { FREEZE_COMMAND, UNFREEZE_COMMAND, + PANIC_COMMAND, NOTIFY, } private static final long FREEZE_MESSAGE_INTERVAL = 10000; + private static final Set CONTAINERS = Sets.newHashSet(Material.CHEST, Material.TRAPPED_CHEST, Material.HOPPER, Material.FURNACE, Material.BURNING_FURNACE, Material.DISPENSER, Material.DROPPER, Material.WORKBENCH, Material.BREWING_STAND); + private final CoreClientManager _clientManager; private final Map _frozen = new HashMap<>(); + private final Map _panic = new HashMap<>(); public ClansFreezeManager(JavaPlugin plugin, CoreClientManager clientManager) { @@ -70,6 +87,8 @@ public class ClansFreezeManager extends MiniPlugin PermissionGroup.CMOD.setPermission(Perm.NOTIFY, false, true); PermissionGroup.CMA.setPermission(Perm.NOTIFY, false, true); PermissionGroup.ADMIN.setPermission(Perm.NOTIFY, true, true); + PermissionGroup.CONTENT.setPermission(Perm.PANIC_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.PANIC_COMMAND, true, true); } @Override @@ -77,6 +96,7 @@ public class ClansFreezeManager extends MiniPlugin { addCommand(new FreezeCommand(this)); addCommand(new UnfreezeCommand(this)); + addCommand(new PanicCommand(this)); } @EventHandler(priority = EventPriority.LOW) @@ -95,12 +115,19 @@ public class ClansFreezeManager extends MiniPlugin } } } + + walkSpeed = _panic.remove(event.getPlayer().getUniqueId()); + if (walkSpeed != null) + { + event.getPlayer().setWalkSpeed(walkSpeed); + event.getPlayer().removePotionEffect(PotionEffectType.JUMP); + } } @EventHandler public void onMove(PlayerMoveEvent event) { - if (isFrozen(event.getPlayer()) && UtilMath.offset2d(event.getFrom().getBlock().getLocation(), event.getTo().getBlock().getLocation()) >= 1) + if ((isFrozen(event.getPlayer()) || isPanicking(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, 0.5, 0)); @@ -148,7 +175,7 @@ public class ClansFreezeManager extends MiniPlugin if (event.getTarget() instanceof Player) { Player player = (Player) event.getTarget(); - if (isFrozen(player)) + if (isFrozen(player) || isPanicking(player)) { event.setCancelled(true); } @@ -161,12 +188,12 @@ public class ClansFreezeManager extends MiniPlugin Player damager = event.GetDamagerPlayer(event.GetCause() == DamageCause.PROJECTILE); Player damagee = event.GetDamageePlayer(); - if (damager != null && isFrozen(damager)) + if (damager != null && (isFrozen(damager) || isPanicking(damager))) { event.SetCancelled("Frozen Attacker"); UtilPlayer.message(damager, F.main(getName(), "You cannot attack others while frozen!")); } - if (damagee != null && isFrozen(damagee)) + if (damagee != null && (isFrozen(damagee) || isPanicking(damagee))) { event.SetCancelled("Frozen Damagee"); if (damager != null) @@ -179,7 +206,7 @@ public class ClansFreezeManager extends MiniPlugin @EventHandler public void onUseSkill(SkillTriggerEvent event) { - if (isFrozen(event.GetPlayer())) + if (isFrozen(event.GetPlayer()) || isPanicking(event.GetPlayer())) { event.SetCancelled(true); UtilPlayer.message(event.GetPlayer(), F.main(getName(), "You cannot use " + F.skill(event.GetSkillName()) + " while frozen!")); @@ -189,7 +216,7 @@ public class ClansFreezeManager extends MiniPlugin @EventHandler public void onBreak(BlockBreakEvent event) { - if (isFrozen(event.getPlayer())) + if (isFrozen(event.getPlayer()) || isPanicking(event.getPlayer())) { event.setCancelled(true); UtilPlayer.message(event.getPlayer(), F.main(getName(), "You cannot break blocks while frozen!")); @@ -199,7 +226,7 @@ public class ClansFreezeManager extends MiniPlugin @EventHandler public void onPlace(BlockPlaceEvent event) { - if (isFrozen(event.getPlayer())) + if (isFrozen(event.getPlayer()) || isPanicking(event.getPlayer())) { event.setCancelled(true); UtilPlayer.message(event.getPlayer(), F.main(getName(), "You cannot place blocks while frozen!")); @@ -209,13 +236,62 @@ public class ClansFreezeManager extends MiniPlugin @EventHandler public void onTpHome(ClansCommandExecutedEvent event) { - if (isFrozen(event.getPlayer())) + if (isFrozen(event.getPlayer()) || isPanicking(event.getPlayer())) { event.setCancelled(true); UtilPlayer.message(event.getPlayer(), F.main(getName(), "You cannot use that command while frozen!")); } } + @EventHandler + public void onDropItem(PlayerDropItemEvent event) + { + if (isFrozen(event.getPlayer()) || isPanicking(event.getPlayer())) + { + event.setCancelled(true); + UtilPlayer.message(event.getPlayer(), F.main(getName(), "You cannot drop items while frozen!")); + } + } + + @EventHandler + public void onPickupItem(PlayerPickupItemEvent event) + { + if (isFrozen(event.getPlayer()) || isPanicking(event.getPlayer())) + { + event.setCancelled(true); + UtilPlayer.message(event.getPlayer(), F.main(getName(), "You cannot pick up items while frozen!")); + } + } + + @EventHandler + public void onOpenContainer(PlayerInteractEvent event) + { + if ((isFrozen(event.getPlayer()) || isPanicking(event.getPlayer())) && event.getClickedBlock() != null && CONTAINERS.contains(event.getClickedBlock().getType())) + { + event.setCancelled(true); + UtilPlayer.message(event.getPlayer(), F.main(getName(), "You cannot open containers while frozen!")); + } + } + + @EventHandler + public void onOpenDoor(IronDoorOpenEvent event) + { + if (isFrozen(event.getPlayer()) || isPanicking(event.getPlayer())) + { + event.setCancelled(true); + UtilPlayer.message(event.getPlayer(), F.main(getName(), "You cannot use doors while frozen!")); + } + } + + @EventHandler + public void onToggleFlight(PlayerToggleFlightEvent event) + { + if ((isFrozen(event.getPlayer()) || isPanicking(event.getPlayer())) && event.isFlying()) + { + event.setCancelled(true); + } + } + /** * Checks if a player is frozen * @param player The player to check @@ -226,6 +302,81 @@ public class ClansFreezeManager extends MiniPlugin return _frozen.containsKey(player.getUniqueId()); } + /** + * Checks if a player is panicking + * @param player The player to check + * @return Whether the player is panicking + */ + public boolean isPanicking(Player player) + { + return _panic.containsKey(player.getUniqueId()); + } + + /** + * Enters a player into panic mode + * @param player The player who is panicking + */ + public void panic(Player player) + { + _panic.put(player.getUniqueId(), _frozen.getOrDefault(player.getUniqueId(), player.getWalkSpeed())); + player.setFlying(false); + player.setWalkSpeed(0); + player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 999999, -10)); + if (!UtilServer.isTestServer()) + { + SlackMessage message = new SlackMessage("Clans Panic System", "crossed_swords", player.getName() + " has entered panic mode on " + UtilServer.getServerName() + "!"); + SlackAPI.getInstance().sendMessage(SlackTeam.CLANS, "#urgent", message, true); + SlackAPI.getInstance().sendMessage(SlackTeam.DEVELOPER, "#clans-commandspy", message, true); + SlackAPI.getInstance().sendMessage(SlackTeam.SOCIAL_MEDIA, "#streams-announcements", message, true); + } + for (Player alert : UtilServer.GetPlayers()) + { + if (_clientManager.Get(alert).hasPermission(Perm.NOTIFY)) + { + UtilPlayer.message(alert, F.main(getName(), F.elem(player.getName()) + " has entered panic mode!")); + } + if (alert.getName().equals(player.getName())) + { + UtilPlayer.message(alert, F.main(getName(), "You have entered panic mode!")); + } + } + } + + /** + * Removes a player from panic mode + * @param player The player to unpanic + */ + public void unpanic(Player player) + { + Float walkSpeed = _panic.remove(player.getUniqueId()); + if (walkSpeed != null) + { + if (!_frozen.containsKey(player.getUniqueId())) + { + player.setWalkSpeed(walkSpeed); + player.removePotionEffect(PotionEffectType.JUMP); + } + if (!UtilServer.isTestServer()) + { + SlackMessage message = new SlackMessage("Clans Panic System", "crossed_swords", player.getName() + " has exited panic mode on " + UtilServer.getServerName() + "!"); + SlackAPI.getInstance().sendMessage(SlackTeam.CLANS, "#urgent", message, true); + SlackAPI.getInstance().sendMessage(SlackTeam.DEVELOPER, "#clans-commandspy", message, true); + SlackAPI.getInstance().sendMessage(SlackTeam.SOCIAL_MEDIA, "#streams-announcements", message, true); + } + for (Player alert : UtilServer.GetPlayers()) + { + if (_clientManager.Get(alert).hasPermission(Perm.NOTIFY)) + { + UtilPlayer.message(alert, F.main(getName(), F.elem(player.getName()) + " has exited panic mode!")); + } + if (alert.getName().equals(player.getName())) + { + UtilPlayer.message(alert, F.main(getName(), "You have exited panic mode!")); + } + } + } + } + /** * Freezes a player * @param player The player to freeze @@ -233,7 +384,8 @@ public class ClansFreezeManager extends MiniPlugin */ public void freeze(Player player, Player staff) { - _frozen.put(player.getUniqueId(), player.getWalkSpeed()); + _frozen.put(player.getUniqueId(), _panic.getOrDefault(player.getUniqueId(), player.getWalkSpeed())); + player.setFlying(false); player.setWalkSpeed(0); player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 999999, -10)); for (Player alert : UtilServer.GetPlayers()) @@ -255,8 +407,11 @@ public class ClansFreezeManager extends MiniPlugin Float walkSpeed = _frozen.remove(player.getUniqueId()); if (walkSpeed != null) { - player.setWalkSpeed(walkSpeed); - player.removePotionEffect(PotionEffectType.JUMP); + if (!_panic.containsKey(player.getUniqueId())) + { + player.setWalkSpeed(walkSpeed); + player.removePotionEffect(PotionEffectType.JUMP); + } for (Player alert : UtilServer.GetPlayers()) { if (_clientManager.Get(alert).hasPermission(Perm.NOTIFY)) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/freeze/commands/PanicCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/freeze/commands/PanicCommand.java new file mode 100644 index 000000000..1e60c10af --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/freeze/commands/PanicCommand.java @@ -0,0 +1,30 @@ +package mineplex.game.clans.clans.freeze.commands; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.game.clans.clans.freeze.ClansFreezeManager; + +/** + * Command to enter panic mode + */ +public class PanicCommand extends CommandBase +{ + public PanicCommand(ClansFreezeManager plugin) + { + super(plugin, ClansFreezeManager.Perm.PANIC_COMMAND, "panic"); + } + + @Override + public void Execute(Player caller, String[] args) + { + if (Plugin.isPanicking(caller)) + { + Plugin.unpanic(caller); + } + else + { + Plugin.panic(caller); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/invsee/InvseeModifyOnlineInventoryEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/invsee/InvseeModifyOnlineInventoryEvent.java new file mode 100644 index 000000000..bff902bd5 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/invsee/InvseeModifyOnlineInventoryEvent.java @@ -0,0 +1,47 @@ +package mineplex.game.clans.clans.invsee; + +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class InvseeModifyOnlineInventoryEvent extends Event implements Cancellable +{ + private static final HandlerList handlers = new HandlerList(); + + private Player _modified; + private boolean _cancelled; + + public InvseeModifyOnlineInventoryEvent(Player modified) + { + _modified = modified; + } + + public Player getModified() + { + return _modified; + } + + @Override + public boolean isCancelled() + { + return _cancelled; + } + + @Override + public void setCancelled(boolean cancelled) + { + _cancelled = cancelled; + } + + @Override + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/invsee/ui/InvseeInventory.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/invsee/ui/InvseeInventory.java index 3db074dae..9fd6e6618 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/invsee/ui/InvseeInventory.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/invsee/ui/InvseeInventory.java @@ -1,10 +1,14 @@ package mineplex.game.clans.clans.invsee.ui; -import mineplex.core.common.util.*; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.clans.invsee.InvseeManager; -import net.minecraft.server.v1_8_R3.*; +import java.io.File; +import java.io.FileOutputStream; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.UUID; + import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.OfflinePlayer; @@ -14,15 +18,34 @@ 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.*; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryCloseEvent; +import org.bukkit.event.inventory.InventoryDragEvent; +import org.bukkit.event.inventory.InventoryOpenEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.meta.ItemMeta; -import java.io.File; -import java.io.FileOutputStream; -import java.util.*; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilText; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.invsee.InvseeManager; +import mineplex.game.clans.clans.invsee.InvseeModifyOnlineInventoryEvent; +import net.minecraft.server.v1_8_R3.ContainerPlayer; +import net.minecraft.server.v1_8_R3.IInventory; +import net.minecraft.server.v1_8_R3.MinecraftServer; +import net.minecraft.server.v1_8_R3.NBTCompressedStreamTools; +import net.minecraft.server.v1_8_R3.NBTTagCompound; +import net.minecraft.server.v1_8_R3.NBTTagList; +import net.minecraft.server.v1_8_R3.PlayerInventory; +import net.minecraft.server.v1_8_R3.WorldNBTStorage; public class InvseeInventory implements Listener { @@ -123,7 +146,7 @@ public class InvseeInventory implements Listener { if (event.getPlayer().getUniqueId().equals(_uuid) && !_canOpenInventory) { - Bukkit.getScheduler().runTaskLater(UtilServer.getPlugin(), () -> {event.getPlayer().closeInventory();}, 20); + Bukkit.getScheduler().runTaskLater(UtilServer.getPlugin(), () -> event.getPlayer().closeInventory(), 20); } } @@ -337,6 +360,11 @@ public class InvseeInventory implements Listener } else { + if (_targetPlayer.isOnline()) + { + UtilServer.CallEvent(new InvseeModifyOnlineInventoryEvent((Player)_targetPlayer)); + } + // Update items on hotbar for (int otherSlot = 0; otherSlot < 9; otherSlot++) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/CustomItemLoot.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/CustomItemLoot.java index af4160255..af16d4166 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/CustomItemLoot.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/CustomItemLoot.java @@ -48,7 +48,7 @@ public class CustomItemLoot implements ILoot @Override public void dropLoot(Location location) { - location.getWorld().dropItemNaturally(location, getItemStack()); + location.getWorld().dropItemNaturally(location.clone().add(0, 3, 0), getItemStack()); } @Override @@ -80,5 +80,4 @@ public class CustomItemLoot implements ILoot return stack; } - -} +} \ No newline at end of file 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 343871074..53aa93b17 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 @@ -25,4 +25,4 @@ public class GearLoot implements ILoot { return _gearManager.generateItem().toItemStack(); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/GoldLoot.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/GoldLoot.java index cf9634736..1691be02e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/GoldLoot.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/GoldLoot.java @@ -23,7 +23,7 @@ public class GoldLoot implements ILoot public void dropLoot(Location location) { int count = _min + UtilMath.r(_max - _min); - _goldManager.dropGold(location, count); + _goldManager.dropGold(location.clone().add(0, 3, 0), count); } @Override @@ -31,4 +31,4 @@ public class GoldLoot implements ILoot { return null; } -} +} \ No newline at end of file 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 82875cea8..1257bb4cc 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 @@ -37,4 +37,4 @@ public class GoldTokenLoot implements ILoot GoldToken token = new GoldToken(gold); return token.toItemStack(); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/ItemLoot.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/ItemLoot.java index e7e6bb848..52677280f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/ItemLoot.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/ItemLoot.java @@ -36,7 +36,7 @@ public class ItemLoot implements ILoot { int count = UtilMath.rRange(_min, _max); ItemStack item = new ItemStack(_material, count, (short) 0, _data); - location.getWorld().dropItemNaturally(location, item); + location.getWorld().dropItemNaturally(location.clone().add(0, 3, 0), item); } @Override @@ -45,4 +45,4 @@ public class ItemLoot implements ILoot int count = UtilMath.rRange(_min, _max); return new ItemStack(_material, count, (short) 0, _data); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/LootManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/LootManager.java index 949723a3a..a1a9c641f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/LootManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/LootManager.java @@ -4,10 +4,10 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; +import mineplex.core.common.weight.WeightSet; import mineplex.game.clans.clans.mounts.Mount.MountType; import mineplex.game.clans.economy.GoldManager; import mineplex.game.clans.items.GearManager; -import mineplex.core.common.weight.WeightSet; public class LootManager { @@ -16,17 +16,29 @@ public class LootManager private WeightSet _commonSet; private WeightSet _rareSet; + private WeightSet _bossSet; + private WeightSet _undeadCitySet; + private WeightSet _raidSet; + private WeightSet _capturePointSet; public LootManager(GearManager gearManager, GoldManager goldManager) { _gearManager = gearManager; _goldManager = goldManager; - _commonSet = new WeightSet(); - _rareSet = new WeightSet(); + _commonSet = new WeightSet<>(); + _rareSet = new WeightSet<>(); + _bossSet = new WeightSet<>(); + _undeadCitySet = new WeightSet<>(); + _raidSet = new WeightSet<>(); + _capturePointSet = new WeightSet<>(); populateCommon(); populateRare(); + populateBoss(); + populateCity(); + populateRaid(); + populateCapturePoint(); } private void populateCommon() @@ -93,6 +105,125 @@ public class LootManager _rareSet.add(20, new MountLoot(1, 3, MountType.values())); } + private void populateBoss() + { + _bossSet.add(70, new GearLoot(_gearManager)); + _bossSet.add(10, new GoldTokenLoot(50000, 100000)); + _bossSet.add(20, new MountLoot(1, 3, MountType.values())); + } + + private void populateCity() + { + // Food + _undeadCitySet.add(5, new ItemLoot(Material.CARROT, 1, 5)); + _undeadCitySet.add(5, new ItemLoot(Material.APPLE, 1, 3)); + _undeadCitySet.add(5, new ItemLoot(Material.COOKED_BEEF, 1, 3)); + _undeadCitySet.add(5, new ItemLoot(Material.RAW_BEEF, 1, 4)); + _undeadCitySet.add(5, new ItemLoot(Material.POTATO_ITEM, 1, 5)); + + // Armor + _undeadCitySet.add(3, new ItemLoot(Material.IRON_HELMET, 1, 1)); + _undeadCitySet.add(3, new ItemLoot(Material.IRON_CHESTPLATE, 1, 1)); + _undeadCitySet.add(4, new ItemLoot(Material.IRON_LEGGINGS, 1, 1)); + _undeadCitySet.add(4, new ItemLoot(Material.IRON_BOOTS, 1, 1)); + + _undeadCitySet.add(4, new ItemLoot(Material.GOLD_HELMET, 1, 1)); + _undeadCitySet.add(4, new ItemLoot(Material.GOLD_CHESTPLATE, 1, 1)); + _undeadCitySet.add(4, new ItemLoot(Material.GOLD_LEGGINGS, 1, 1)); + _undeadCitySet.add(4, new ItemLoot(Material.GOLD_BOOTS, 1, 1)); + + _undeadCitySet.add(4, new ItemLoot(Material.LEATHER_HELMET, 1, 1)); + _undeadCitySet.add(4, new ItemLoot(Material.LEATHER_CHESTPLATE, 1, 1)); + _undeadCitySet.add(4, new ItemLoot(Material.LEATHER_LEGGINGS, 1, 1)); + _undeadCitySet.add(4, new ItemLoot(Material.LEATHER_BOOTS, 1, 1)); + + _undeadCitySet.add(4, new ItemLoot(Material.DIAMOND_HELMET, 1, 1)); + _undeadCitySet.add(4, new ItemLoot(Material.DIAMOND_CHESTPLATE, 1, 1)); + _undeadCitySet.add(4, new ItemLoot(Material.DIAMOND_LEGGINGS, 1, 1)); + _undeadCitySet.add(4, new ItemLoot(Material.DIAMOND_BOOTS, 1, 1)); + + _undeadCitySet.add(4, new ItemLoot(Material.CHAINMAIL_HELMET, 1, 1)); + _undeadCitySet.add(4, new ItemLoot(Material.CHAINMAIL_CHESTPLATE, 1, 1)); + _undeadCitySet.add(4, new ItemLoot(Material.CHAINMAIL_LEGGINGS, 1, 1)); + _undeadCitySet.add(4, new ItemLoot(Material.CHAINMAIL_BOOTS, 1, 1)); + + _undeadCitySet.add(4, new ItemLoot(Material.IRON_AXE, 1, 1)); + _undeadCitySet.add(4, new ItemLoot(Material.IRON_SWORD, 1, 1)); + + _undeadCitySet.add(3, new ItemLoot(Material.EMERALD, 10, 15)); + + _undeadCitySet.add(2, new CustomItemLoot(Material.GOLD_SWORD, 1, 1, "Booster Sword")); + _undeadCitySet.add(2, new CustomItemLoot(Material.GOLD_AXE, 1, 1, "Booster Axe")); + _undeadCitySet.add(2, new CustomItemLoot(Material.DIAMOND_SWORD, 1, 1, "Power Sword")); + _undeadCitySet.add(2, new CustomItemLoot(Material.DIAMOND_AXE, 1, 1, "Power Axe")); + + // Gear + _undeadCitySet.add(1, new GearLoot(_gearManager)); + + // Gold + _undeadCitySet.add(5, new GoldLoot(_goldManager, 100, 1000)); + _undeadCitySet.add(1, new GoldTokenLoot(5000, 10000)); + } + + private void populateRaid() + { + _raidSet.add(70, new GearLoot(_gearManager)); + _raidSet.add(10, new GoldTokenLoot(100000, 200000)); + _raidSet.add(20, new MountLoot(2, 3, MountType.values())); + } + + private void populateCapturePoint() + { + // Food + _capturePointSet.add(5, new ItemLoot(Material.CARROT, 1, 5)); + _capturePointSet.add(5, new ItemLoot(Material.APPLE, 1, 3)); + _capturePointSet.add(5, new ItemLoot(Material.COOKED_BEEF, 1, 3)); + _capturePointSet.add(5, new ItemLoot(Material.RAW_BEEF, 1, 4)); + _capturePointSet.add(5, new ItemLoot(Material.POTATO_ITEM, 1, 5)); + + // Armor + _capturePointSet.add(3, new ItemLoot(Material.IRON_HELMET, 1, 1)); + _capturePointSet.add(3, new ItemLoot(Material.IRON_CHESTPLATE, 1, 1)); + _capturePointSet.add(4, new ItemLoot(Material.IRON_LEGGINGS, 1, 1)); + _capturePointSet.add(4, new ItemLoot(Material.IRON_BOOTS, 1, 1)); + + _capturePointSet.add(4, new ItemLoot(Material.GOLD_HELMET, 1, 1)); + _capturePointSet.add(4, new ItemLoot(Material.GOLD_CHESTPLATE, 1, 1)); + _capturePointSet.add(4, new ItemLoot(Material.GOLD_LEGGINGS, 1, 1)); + _capturePointSet.add(4, new ItemLoot(Material.GOLD_BOOTS, 1, 1)); + + _capturePointSet.add(4, new ItemLoot(Material.LEATHER_HELMET, 1, 1)); + _capturePointSet.add(4, new ItemLoot(Material.LEATHER_CHESTPLATE, 1, 1)); + _capturePointSet.add(4, new ItemLoot(Material.LEATHER_LEGGINGS, 1, 1)); + _capturePointSet.add(4, new ItemLoot(Material.LEATHER_BOOTS, 1, 1)); + + _capturePointSet.add(4, new ItemLoot(Material.DIAMOND_HELMET, 1, 1)); + _capturePointSet.add(4, new ItemLoot(Material.DIAMOND_CHESTPLATE, 1, 1)); + _capturePointSet.add(4, new ItemLoot(Material.DIAMOND_LEGGINGS, 1, 1)); + _capturePointSet.add(4, new ItemLoot(Material.DIAMOND_BOOTS, 1, 1)); + + _capturePointSet.add(4, new ItemLoot(Material.CHAINMAIL_HELMET, 1, 1)); + _capturePointSet.add(4, new ItemLoot(Material.CHAINMAIL_CHESTPLATE, 1, 1)); + _capturePointSet.add(4, new ItemLoot(Material.CHAINMAIL_LEGGINGS, 1, 1)); + _capturePointSet.add(4, new ItemLoot(Material.CHAINMAIL_BOOTS, 1, 1)); + + _capturePointSet.add(4, new ItemLoot(Material.IRON_AXE, 1, 1)); + _capturePointSet.add(4, new ItemLoot(Material.IRON_SWORD, 1, 1)); + + _capturePointSet.add(3, new ItemLoot(Material.EMERALD, 10, 15)); + + _capturePointSet.add(2, new CustomItemLoot(Material.GOLD_SWORD, 1, 1, "Booster Sword")); + _capturePointSet.add(2, new CustomItemLoot(Material.GOLD_AXE, 1, 1, "Booster Axe")); + _capturePointSet.add(2, new CustomItemLoot(Material.DIAMOND_SWORD, 1, 1, "Power Sword")); + _capturePointSet.add(2, new CustomItemLoot(Material.DIAMOND_AXE, 1, 1, "Power Axe")); + + // Gold + _capturePointSet.add(1, new GoldTokenLoot(50000, 50000)); + + // Rune + _capturePointSet.add(1, new RuneLoot()); + } + public void dropCommon(Location location) { _commonSet.generateRandom().dropLoot(location); @@ -103,9 +234,28 @@ public class LootManager _rareSet.generateRandom().dropLoot(location); } + public void dropBoss(Location location) + { + _bossSet.generateRandom().dropLoot(location); + } + + public void dropUndeadCity(Location location) + { + _undeadCitySet.generateRandom().dropLoot(location); + } + + public void dropRaid(Location location) + { + _raidSet.generateRandom().dropLoot(location); + } + + public void dropCapturePoint(Location location) + { + _capturePointSet.generateRandom().dropLoot(location); + } + public ItemStack getRareItemStack() { return _rareSet.generateRandom().getItemStack(); - } - -} + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/MountLoot.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/MountLoot.java index 65fe0c074..df326d968 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/MountLoot.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/MountLoot.java @@ -42,4 +42,4 @@ public class MountLoot implements ILoot { return new MountClaimToken(UtilMath.rRange(_minStars, _maxStars), UtilMath.rRange(_minStars, _maxStars), UtilMath.rRange(_minStars, _maxStars), UtilMath.randomElement(_types)).toItem(); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/RuneLoot.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/RuneLoot.java new file mode 100644 index 000000000..542f1c0d7 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/RuneLoot.java @@ -0,0 +1,44 @@ +package mineplex.game.clans.clans.loot; + +import org.bukkit.Color; +import org.bukkit.FireworkEffect.Type; +import org.bukkit.Location; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilMath; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.items.runes.RuneManager.RuneAttribute; + +public class RuneLoot implements ILoot +{ + private RuneAttribute[] _types; + + public RuneLoot(RuneAttribute... types) + { + if (types.length == 0) + { + _types = RuneAttribute.values(); + } + else + { + _types = types; + } + } + + @Override + public void dropLoot(Location location) + { + RuneAttribute attribute = UtilMath.randomElement(_types); + ItemStack item = ClansManager.getInstance().getGearManager().getRuneManager().getRune(attribute); + UtilFirework.playFirework(location.clone().add(0, 3, 0), Type.BALL, Color.PURPLE, true, false); + location.getWorld().dropItemNaturally(location.clone().add(0, 3, 0), item); + } + + @Override + public ItemStack getItemStack() + { + RuneAttribute attribute = UtilMath.randomElement(_types); + return ClansManager.getInstance().getGearManager().getRuneManager().getRune(attribute); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/moderation/antialt/AltManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/moderation/antialt/AltManager.java new file mode 100644 index 000000000..8e1321aba --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/moderation/antialt/AltManager.java @@ -0,0 +1,495 @@ +package mineplex.game.clans.clans.moderation.antialt; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.URL; +import java.net.URLConnection; +import java.util.HashMap; +import java.util.Map; +import java.util.function.Consumer; + +import org.apache.commons.lang3.tuple.Triple; +import org.bukkit.Bukkit; +import org.bukkit.OfflinePlayer; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.AsyncPlayerPreLoginEvent; +import org.bukkit.event.player.AsyncPlayerPreLoginEvent.Result; +import org.bukkit.event.player.PlayerJoinEvent; + +import mineplex.core.Managers; +import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.Permission; +import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.command.CommandBase; +import mineplex.core.common.Pair; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.punish.clans.ClansBanManager; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.moderation.antialt.AltRepository.ChainedDatabaseAction; +import mineplex.game.clans.clans.moderation.antialt.AltRepository.IpUnbanResult; +import mineplex.game.clans.clans.moderation.antialt.AltRepository.IpUnwhitelistResult; +import mineplex.game.clans.clans.moderation.antialt.IpAPIData.ImmutableIpAPIData; +import mineplex.serverdata.Utility; +import mineplex.serverdata.commands.ServerCommandManager; +import net.md_5.bungee.api.ChatColor; + +public class AltManager extends MiniPlugin +{ + public enum Perm implements Permission + { + BAN_IP, + UNBAN_IP, + WHITELIST_IP, + UNWHITELIST_IP, + CHECK_IP, + ACCOUNT_HISTORY, + IP_HISTORY, + CHECK_ALTS, + BYPASS_ALT_CHECK, + } + + private final ClansBanManager _punish = Managers.require(ClansBanManager.class); + private final CoreClientManager _clientManager = Managers.require(CoreClientManager.class); + protected final AltRepository _repo; + private final int _serverId; + private final Map> _vpnCache = new HashMap<>(); + + public AltManager() + { + super("Alt Manager"); + + _serverId = ClansManager.getInstance().getServerId(); + _repo = new AltRepository(); + + addCommand(new CommandBase(this, Perm.BAN_IP, "banip") + { + @Override + public void Execute(Player caller, String[] args) + { + if (args.length < 1) + { + UtilPlayer.message(caller, F.main(getName(), "Usage: /banip ")); + return; + } + final String ip = args[0]; + _repo.banIp(ip, caller.getName(), success -> + { + if (success) + { + UtilPlayer.message(caller, F.main(getName(), "Ip successfully banned!")); + new IpBanNotification(ip).publish(); + } + else + { + UtilPlayer.message(caller, F.main(getName(), "An error occurred while attempting to ban that ip!")); + } + }); + } + }); + addCommand(new CommandBase(this, Perm.UNBAN_IP, "unbanip") + { + @Override + public void Execute(Player caller, String[] args) + { + if (args.length < 1) + { + UtilPlayer.message(caller, F.main(getName(), "Usage: /unbanip ")); + return; + } + final String ip = args[0]; + _repo.unbanIp(ip, result -> + { + if (result == IpUnbanResult.UNBANNED) + { + UtilPlayer.message(caller, F.main(getName(), "Ip successfully unbanned!")); + } + else if (result == IpUnbanResult.NOT_BANNED) + { + UtilPlayer.message(caller, F.main(getName(), "That ip was not banned!")); + } + else + { + UtilPlayer.message(caller, F.main(getName(), "An error occurred while attempting to unban that ip!")); + } + }); + } + }); + addCommand(new CommandBase(this, Perm.WHITELIST_IP, "whitelistip") + { + @Override + public void Execute(Player caller, String[] args) + { + if (args.length < 2) + { + UtilPlayer.message(caller, F.main(getName(), "Usage: /whitelistip ")); + return; + } + final String ip = args[0]; + final int additionalAccounts; + try + { + additionalAccounts = Integer.parseInt(args[1]); + } + catch (NumberFormatException ex) + { + UtilPlayer.message(caller, F.main(getName(), "That is not a valid number of additional accounts!")); + return; + } + _repo.whitelistIp(ip, caller.getName(), additionalAccounts, success -> + { + if (success) + { + UtilPlayer.message(caller, F.main(getName(), "Ip successfully whitelisted!")); + } + else + { + UtilPlayer.message(caller, F.main(getName(), "An error occurred while attempting to whitelist that ip!")); + } + }); + } + }); + addCommand(new CommandBase(this, Perm.UNWHITELIST_IP, "unwhitelistip") + { + @Override + public void Execute(Player caller, String[] args) + { + if (args.length < 1) + { + UtilPlayer.message(caller, F.main(getName(), "Usage: /unwhitelistip ")); + return; + } + final String ip = args[0]; + _repo.unwhitelistIp(ip, result -> + { + if (result == IpUnwhitelistResult.UNWHITELISTED) + { + UtilPlayer.message(caller, F.main(getName(), "Ip successfully unwhitelisted!")); + } + else if (result == IpUnwhitelistResult.NOT_WHITELISTED) + { + UtilPlayer.message(caller, F.main(getName(), "That ip was not whitelisted!")); + } + else + { + UtilPlayer.message(caller, F.main(getName(), "An error occurred while attempting to unwhitelist that ip!")); + } + }); + } + }); + addCommand(new CommandBase(this, Perm.CHECK_IP, "checkip") + { + @Override + public void Execute(Player caller, String[] args) + { + if (args.length < 1) + { + UtilPlayer.message(caller, F.main(getName(), "Usage: /checkip ")); + return; + } + final String ip = args[0]; + runAsync(() -> + { + Triple status = checkIpStatus(ip); + final boolean banned = status.getLeft(); + final boolean whitelisted = status.getMiddle(); + final int additionalAccounts = status.getRight(); + runSync(() -> + { + if (banned) + { + UtilPlayer.message(caller, F.main(getName(), "That ip is banned!")); + } + else + { + UtilPlayer.message(caller, F.main(getName(), "That ip is not banned!")); + } + if (whitelisted) + { + UtilPlayer.message(caller, F.main(getName(), "That ip is whitelisted with " + F.elem(String.valueOf(additionalAccounts)) + " additional accounts!")); + } + else + { + UtilPlayer.message(caller, F.main(getName(), "That ip is not whitelisted!")); + } + }); + }); + } + }); + addCommand(new CommandBase(this, Perm.ACCOUNT_HISTORY, "accounthistory") + { + @SuppressWarnings("deprecation") + @Override + public void Execute(Player caller, String[] args) + { + if (args.length < 2) + { + UtilPlayer.message(caller, F.main(getName(), "Usage: /accounthistory ")); + return; + } + final String ip = args[0]; + if (Boolean.valueOf(args[1])) + { + _repo.loadAccounts(ip, _serverId, accounts -> + { + UtilPlayer.message(caller, F.main(getName(), "Accounts logged in under that ip on this server:")); + for (String name : accounts) + { + Player player = Bukkit.getPlayer(name); + ChatColor cc = ChatColor.GRAY; + if (player != null) + { + cc = ChatColor.GREEN; + } + UtilPlayer.message(caller, C.cBlue + "- " + cc + name); + } + }); + } + else + { + _repo.loadAccounts(ip, accounts -> + { + UtilPlayer.message(caller, F.main(getName(), "Accounts logged in under that ip:")); + for (String name : accounts) + { + OfflinePlayer op = Bukkit.getOfflinePlayer(name); + ChatColor cc = ChatColor.GRAY; + if (op.hasPlayedBefore()) + { + cc = ChatColor.RED; + } + if (op.isOnline()) + { + cc = ChatColor.GREEN; + } + UtilPlayer.message(caller, C.cBlue + "- " + cc + name); + } + }); + } + } + }); + addCommand(new CommandBase(this, Perm.IP_HISTORY, "iphistory") + { + @Override + public void Execute(Player caller, String[] args) + { + if (args.length < 2) + { + UtilPlayer.message(caller, F.main(getName(), "Usage: /iphistory ")); + return; + } + final String name = args[0]; + final boolean local = Boolean.valueOf(args[1]); + _clientManager.loadClientByName(name, client -> + { + if (client == null) + { + UtilPlayer.message(caller, F.main(getName(), "That player was not found!")); + } + else + { + final int accountId = client.getAccountId(); + if (local) + { + _repo.loadIps(accountId, _serverId, ips -> + { + UtilPlayer.message(caller, F.main(getName(), "Ips used by " + F.elem(client.getName()) + " on this server:")); + for (String ip : ips) + { + UtilPlayer.message(caller, C.cBlue + "- " + C.cGray + ip); + } + }); + } + else + { + _repo.loadIps(accountId, ips -> + { + UtilPlayer.message(caller, F.main(getName(), "Ips used by " + F.elem(client.getName()) + ":")); + for (String ip : ips) + { + UtilPlayer.message(caller, C.cBlue + "- " + C.cGray + ip); + } + }); + } + } + }); + } + }); + addCommand(new CommandBase(this, Perm.CHECK_ALTS, "alts") + { + @Override + public void Execute(Player caller, String[] args) + { + if (args.length < 1) + { + UtilPlayer.message(caller, F.main(getName(), "Usage: /alts ")); + return; + } + final String name = args[0]; + _clientManager.loadClientByName(name, client -> + { + if (client == null) + { + UtilPlayer.message(caller, F.main(getName(), "That player was not found!")); + } + else + { + final int accountId = client.getAccountId(); + _repo.loadDuplicateAccounts(accountId, accounts -> + { + UtilPlayer.message(caller, F.main(getName(), "Accounts sharing an ip with " + F.elem(client.getName()) + ":")); + for (String account : accounts) + { + if (account.equals(client.getName())) + { + continue; + } + UtilPlayer.message(caller, C.cBlue + "- " + C.cGray + account); + } + }); + } + }); + } + }); + ServerCommandManager.getInstance().registerCommandType(IpBanNotification.class, notification -> + { + runSync(() -> + { + Bukkit.getOnlinePlayers().forEach(player -> + { + if (player.getAddress().getAddress().toString().substring(1).equals(notification.getIp())) + { + player.kickPlayer(C.cRedB + "Your IP has been suspended from Mineplex Clans.\n" + C.cGold + "Visit http://www.mineplex.com/appeals to appeal this ban."); + } + }); + }); + }); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionGroup.ADMIN.setPermission(Perm.BAN_IP, true, true); + PermissionGroup.ADMIN.setPermission(Perm.UNBAN_IP, true, true); + PermissionGroup.ADMIN.setPermission(Perm.WHITELIST_IP, true, true); + PermissionGroup.ADMIN.setPermission(Perm.UNWHITELIST_IP, true, true); + PermissionGroup.ADMIN.setPermission(Perm.CHECK_IP, true, true); + PermissionGroup.ADMIN.setPermission(Perm.ACCOUNT_HISTORY, true, true); + PermissionGroup.ADMIN.setPermission(Perm.IP_HISTORY, true, true); + PermissionGroup.ADMIN.setPermission(Perm.CHECK_ALTS, true, true); + PermissionGroup.CMOD.setPermission(Perm.CHECK_ALTS, false, true); + } + + private synchronized boolean checkForVPN(String ipAddress) + { + _vpnCache.entrySet().removeIf(entry -> UtilTime.elapsed(entry.getValue().getRight(), 120000)); //expire cache + Pair cacheValue = _vpnCache.computeIfAbsent(ipAddress, ip -> + { + try + { + StringBuilder response = new StringBuilder(); + URLConnection connection = new URL("http://api.vpnblocker.net/v2/json/" + ipAddress + "/1YimOXUxTgh34kNRZYF31y5YEw8Phs").openConnection(); + connection.setConnectTimeout(10000); + connection.setRequestProperty("User-Agent", "Mineplex Clans"); + try (BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) + { + reader.lines().forEachOrdered(response::append); + } + if (response.length() == 0) + { + return Pair.create(new IpAPIData().makeImmutable(), System.currentTimeMillis()); + } + IpAPIData data = Utility.deserialize(response.toString(), IpAPIData.class); + if (data == null) + { + return Pair.create(new IpAPIData().makeImmutable(), System.currentTimeMillis()); + } + return Pair.create(data.makeImmutable(), System.currentTimeMillis()); + } + catch (IOException e) + { + e.printStackTrace(); + return Pair.create(new IpAPIData().makeImmutable(), System.currentTimeMillis()); + } + }); + if (cacheValue.getLeft().host_ip) + { + return true; + } + return false; + } + + private Triple checkIpStatus(String ipAddress) + { + ChainedDatabaseAction action = _repo.checkIpBanned(ipAddress).chain(_repo.checkIpWhitelisted(ipAddress)); + action.execute(); + return Triple.of(action.getResult(AltRepository.BAN_STATUS_KEY), action.getResult(AltRepository.WHITELIST_STATUS_KEY), action.getResult(AltRepository.WHITELIST_ADDITIONAL_ACCOUNTS_KEY)); + } + + private void storeLogin(int accountId, String ipAddress) + { + _repo.login(ipAddress, accountId, _serverId).executeAsync(null); + } + + private void checkAltAndStore(int accountId, String ipAddress, Consumer callback) + { + ChainedDatabaseAction action = _repo.checkAltAccount(ipAddress, _serverId, accountId).chain(_repo.checkIpWhitelisted(ipAddress)).chain(_repo.login(ipAddress, accountId, _serverId)); + action.executeAsync(() -> + { + int alts = action.getResult(AltRepository.ALT_COUNT_KEY); + boolean isWhitelisted = action.getResult(AltRepository.WHITELIST_STATUS_KEY); + int additionalAccounts = action.getResult(AltRepository.WHITELIST_ADDITIONAL_ACCOUNTS_KEY); + callback.accept(alts > additionalAccounts && !isWhitelisted); + }); + } + + @EventHandler(priority = EventPriority.HIGH) + public void onLogin(AsyncPlayerPreLoginEvent event) + { + if (event.getLoginResult() != Result.ALLOWED) + { + return; + } + + final String ipAddress = event.getAddress().toString().substring(1); + Triple status = checkIpStatus(ipAddress); + if (!status.getMiddle() && checkForVPN(ipAddress)) + { + event.disallow(Result.KICK_BANNED, C.cRedB + "VPN/Proxy usage is not permitted on Mineplex Clans"); + return; + } + if (status.getLeft()) + { + event.disallow(Result.KICK_BANNED, C.cRedB + "Your IP has been suspended from Mineplex Clans.\n" + C.cGold + "Visit http://www.mineplex.com/appeals to appeal this ban."); + return; + } + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onJoin(PlayerJoinEvent event) + { + Player player = event.getPlayer(); + /*if (_clientManager.Get(player).hasPermission(Perm.BYPASS_ALT_CHECK)) + { + return; + }*/ + final int accountId = _clientManager.getAccountId(player); + final String ipAddress = player.getAddress().getAddress().toString().substring(1); + + /*checkAltAndStore(accountId, ipAddress, alt -> + { + if (alt) + { + player.kickPlayer(C.cRed + "You have been disconnected for Unauthorized Alting!"); + } + });*/ + storeLogin(accountId, ipAddress); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/moderation/antialt/AltRepository.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/moderation/antialt/AltRepository.java new file mode 100644 index 000000000..75367e7f9 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/moderation/antialt/AltRepository.java @@ -0,0 +1,435 @@ +package mineplex.game.clans.clans.moderation.antialt; + +import java.sql.Connection; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.function.BiConsumer; +import java.util.function.Consumer; + +import mineplex.core.Managers; +import mineplex.core.common.util.EnclosedObject; +import mineplex.core.common.util.UtilServer; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.RepositoryBase; +import mineplex.serverdata.database.column.ColumnInt; +import mineplex.serverdata.database.column.ColumnVarChar; + +public class AltRepository extends RepositoryBase +{ + public static final String ALT_COUNT_KEY = "ALT_ACCOUNTS"; + public static final String WHITELIST_STATUS_KEY = "WHITELISTED_IP"; + public static final String WHITELIST_ADDITIONAL_ACCOUNTS_KEY = "WHITELISTED_ADDITIONAL_ACCOUNTS"; + public static final String BAN_STATUS_KEY = "BANNED_IP"; + + private static final String CREATE_IP_BAN_TABLE = "CREATE TABLE IF NOT EXISTS clansIpBans (ipAddress VARCHAR(16), admin VARCHAR(40), PRIMARY KEY (ipAddress), INDEX adminIndex (admin));"; + private static final String FETCH_IP_BAN_INFO = "SELECT * FROM clansIpBans WHERE ipAddress=?;"; + private static final String BAN_IP = "INSERT INTO clansIpBans (ipAddress, admin) VALUES (?, ?) ON DUPLICATE KEY UPDATE admin=VALUES(admin);"; + private static final String UNBAN_IP = "DELETE FROM clansIpBans WHERE ipAddress=?;"; + + private static final String CREATE_IP_WHITELIST_TABLE = "CREATE TABLE IF NOT EXISTS clansIpWhitelists (ipAddress VARCHAR(16), admin VARCHAR(40), additionalAccounts INT, PRIMARY KEY (ipAddress), INDEX adminIndex (admin));"; + private static final String FETCH_IP_WHITELIST_INFO = "SELECT * FROM clansIpWhitelists WHERE ipAddress=?;"; + private static final String WHITELIST_IP = "INSERT INTO clansIpWhitelists (ipAddress, admin, additionalAccounts) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE admin=VALUES(admin), additionalAccounts=VALUES(additionalAccounts);"; + private static final String UNWHITELIST_IP = "DELETE FROM clansIpWhitelists WHERE ipAddress=?;"; + + private static final String CREATE_IP_HISTORY_TABLE = "CREATE TABLE IF NOT EXISTS clansIpHistory (ipAddress VARCHAR(16), accountId INT, serverId INT, PRIMARY KEY (ipAddress, accountId, serverId), INDEX ipIndex (ipAddress), INDEX accountIndex (accountId), INDEX accountServerIndex (accountId, serverId), INDEX ipServerIndex (ipAddress, serverId), FOREIGN KEY (serverId) REFERENCES clanServer(id), FOREIGN KEY (accountId) REFERENCES accounts(id));"; + private static final String FETCH_LOCAL_ACCOUNT_IPS = "SELECT ipAddress FROM clansIpHistory WHERE accountId=? AND serverId=?;"; + private static final String FETCH_ACCOUNT_IPS = "SELECT DISTINCT ipAddress FROM clansIpHistory WHERE accountId=?;"; + private static final String FETCH_IP_ACCOUNTS = "SELECT DISTINCT name FROM accounts WHERE id IN (SELECT accountId FROM clansIpHistory WHERE ipAddress=?);"; + private static final String FETCH_LOCAL_IP_ACCOUNTS = "SELECT DISTINCT name FROM accounts WHERE id IN (SELECT accountId FROM clansIpHistory WHERE ipAddress=? AND serverId=?);"; + private static final String FETCH_LOCAL_IP_ACCOUNT_IDS = "SELECT DISTINCT accountId FROM clansIpHistory WHERE ipAddress=? AND serverId=?;"; + private static final String FETCH_DUPLICATE_ACCOUNTS = "SELECT DISTINCT name FROM accounts WHERE id IN (SELECT DISTINCT accountId FROM clansIpHistory WHERE ipAddress IN (SELECT DISTINCT ipAddress FROM clansIpHistory WHERE accountId=?));"; + private static final String LOGIN_ACCOUNT = "INSERT INTO clansIpHistory (ipAddress, accountId, serverId) VALUES (?, ?, ?);"; + + public AltRepository() + { + super(DBPool.getAccount()); + } + + public ChainedDatabaseAction checkIpBanned(String ipAddress) + { + return new ChainedDatabaseAction((connection, resultMap) -> + { + EnclosedObject recordExists = new EnclosedObject<>(false); + + executeQuery(connection, FETCH_IP_BAN_INFO, resultSet -> + { + recordExists.Set(resultSet.next()); + }, new ColumnVarChar("ipAddress", ipAddress.length(), ipAddress)); + + resultMap.put(BAN_STATUS_KEY, recordExists.Get()); + }); + } + + public ChainedDatabaseAction checkIpWhitelisted(String ipAddress) + { + return new ChainedDatabaseAction((connection, resultMap) -> + { + EnclosedObject recordExists = new EnclosedObject<>(false); + EnclosedObject additionalAccounts = new EnclosedObject<>(0); + + executeQuery(connection, FETCH_IP_WHITELIST_INFO, resultSet -> + { + recordExists.Set(resultSet.next()); + if (recordExists.Get()) + { + additionalAccounts.Set(resultSet.getInt("additionalAccounts")); + } + }, new ColumnVarChar("ipAddress", ipAddress.length(), ipAddress)); + + resultMap.put(WHITELIST_STATUS_KEY, recordExists.Get()); + resultMap.put(WHITELIST_ADDITIONAL_ACCOUNTS_KEY, additionalAccounts.Get()); + }); + } + + public ChainedDatabaseAction login(String ipAddress, int accountId, int serverId) + { + return new ChainedDatabaseAction((connection, resultMap) -> + { + List accounts = new ArrayList<>(); + executeQuery(connection, FETCH_LOCAL_IP_ACCOUNT_IDS, rs -> + { + while (rs.next()) + { + accounts.add(rs.getInt(1)); + } + }, new ColumnVarChar("ipAddress", ipAddress.length(), ipAddress), new ColumnInt("serverId", serverId)); + + if (!accounts.contains(accountId)) + { + executeInsert(connection, LOGIN_ACCOUNT, null, null, new ColumnVarChar(ipAddress, ipAddress.length(), ipAddress), new ColumnInt("accountId", accountId), new ColumnInt("serverId", serverId)); + } + }); + } + + public ChainedDatabaseAction checkAltAccount(String ipAddress, int serverId, Integer... accountIgnore) + { + return new ChainedDatabaseAction((connection, resultMap) -> + { + List accounts = new ArrayList<>(); + List ignore = Arrays.asList(accountIgnore); + executeQuery(connection, FETCH_LOCAL_IP_ACCOUNT_IDS, rs -> + { + while (rs.next()) + { + if (!ignore.contains(rs.getInt(1))) + { + accounts.add(rs.getInt(1)); + } + } + }, new ColumnVarChar("ipAddress", ipAddress.length(), ipAddress), new ColumnInt("serverId", serverId)); + + resultMap.put(ALT_COUNT_KEY, accounts.size()); + }); + } + + public void banIp(String ipAddress, String admin, Consumer callback) + { + UtilServer.runAsync(() -> + { + Consumer passThrough = success -> + { + if (callback != null) + { + UtilServer.runSync(() -> callback.accept(success)); + } + }; + executeInsert(BAN_IP, rs -> passThrough.accept(true), () -> passThrough.accept(false), new ColumnVarChar("ipAddress", ipAddress.length(), ipAddress), new ColumnVarChar("admin", admin.length(), admin)); + }); + } + + public void unbanIp(String ipAddress, Consumer callback) + { + UtilServer.runAsync(() -> + { + Consumer passThrough = result -> + { + if (callback != null) + { + UtilServer.runSync(() -> callback.accept(result)); + } + }; + EnclosedObject errored = new EnclosedObject<>(false); + + int rows = executeUpdate(UNBAN_IP, () -> + { + errored.Set(true); + passThrough.accept(IpUnbanResult.ERROR); + }, new ColumnVarChar("ipAddress", ipAddress.length(), ipAddress)); + + if (!errored.Get()) + { + if (rows > 0) + { + passThrough.accept(IpUnbanResult.UNBANNED); + } + else + { + passThrough.accept(IpUnbanResult.NOT_BANNED); + } + } + }); + } + + public void whitelistIp(String ipAddress, String admin, int additionalAccounts, Consumer callback) + { + UtilServer.runAsync(() -> + { + Consumer passThrough = success -> + { + if (callback != null) + { + UtilServer.runSync(() -> callback.accept(success)); + } + }; + executeInsert(WHITELIST_IP, rs -> passThrough.accept(true), () -> passThrough.accept(false), new ColumnVarChar("ipAddress", ipAddress.length(), ipAddress), new ColumnVarChar("admin", admin.length(), admin), new ColumnInt("additionalAccounts", additionalAccounts)); + }); + } + + public void unwhitelistIp(String ipAddress, Consumer callback) + { + UtilServer.runAsync(() -> + { + Consumer passThrough = result -> + { + if (callback != null) + { + UtilServer.runSync(() -> callback.accept(result)); + } + }; + EnclosedObject errored = new EnclosedObject<>(false); + + int rows = executeUpdate(UNWHITELIST_IP, () -> + { + errored.Set(true); + passThrough.accept(IpUnwhitelistResult.ERROR); + }, new ColumnVarChar("ipAddress", ipAddress.length(), ipAddress)); + + if (!errored.Get()) + { + if (rows > 0) + { + passThrough.accept(IpUnwhitelistResult.UNWHITELISTED); + } + else + { + passThrough.accept(IpUnwhitelistResult.NOT_WHITELISTED); + } + } + }); + } + + public void loadAccounts(String ipAddress, Consumer> accountCallback) + { + UtilServer.runAsync(() -> + { + List accounts = new ArrayList<>(); + executeQuery(FETCH_IP_ACCOUNTS, rs -> + { + while (rs.next()) + { + accounts.add(rs.getString(1)); + } + }, new ColumnVarChar("ipAddress", ipAddress.length(), ipAddress)); + + UtilServer.runSync(() -> + { + accountCallback.accept(accounts); + }); + }); + } + + public void loadAccountIds(String ipAddress, int serverId, Consumer> accountCallback) + { + UtilServer.runAsync(() -> + { + List accounts = new ArrayList<>(); + executeQuery(FETCH_LOCAL_IP_ACCOUNT_IDS, rs -> + { + while (rs.next()) + { + accounts.add(rs.getInt(1)); + } + }, new ColumnVarChar("ipAddress", ipAddress.length(), ipAddress), new ColumnInt("serverId", serverId)); + + UtilServer.runSync(() -> + { + accountCallback.accept(accounts); + }); + }); + } + + public void loadAccounts(String ipAddress, int serverId, Consumer> accountCallback) + { + UtilServer.runAsync(() -> + { + List accounts = new ArrayList<>(); + executeQuery(FETCH_LOCAL_IP_ACCOUNTS, rs -> + { + while (rs.next()) + { + accounts.add(rs.getString(1)); + } + }, new ColumnVarChar("ipAddress", ipAddress.length(), ipAddress), new ColumnInt("serverId", serverId)); + + UtilServer.runSync(() -> + { + accountCallback.accept(accounts); + }); + }); + } + + public void loadIps(int accountId, Consumer> ipCallback) + { + UtilServer.runAsync(() -> + { + List ips = new ArrayList<>(); + executeQuery(FETCH_ACCOUNT_IPS, rs -> + { + while (rs.next()) + { + ips.add(rs.getString(1)); + } + }, new ColumnInt("accountId", accountId)); + + UtilServer.runSync(() -> + { + ipCallback.accept(ips); + }); + }); + } + + public void loadIps(int accountId, int serverId, Consumer> ipCallback) + { + UtilServer.runAsync(() -> + { + List ips = new ArrayList<>(); + executeQuery(FETCH_LOCAL_ACCOUNT_IPS, rs -> + { + while (rs.next()) + { + ips.add(rs.getString(1)); + } + }, new ColumnInt("accountId", accountId), new ColumnInt("serverId", serverId)); + + UtilServer.runSync(() -> + { + ipCallback.accept(ips); + }); + }); + } + + public void loadDuplicateAccounts(int accountId, Consumer> nameCallback) + { + UtilServer.runAsync(() -> + { + List accounts = new ArrayList<>(); + executeQuery(FETCH_DUPLICATE_ACCOUNTS, rs -> + { + while (rs.next()) + { + accounts.add(rs.getString(1)); + } + }, new ColumnVarChar("accountId", accountId)); + + UtilServer.runSync(() -> + { + nameCallback.accept(accounts); + }); + }); + } + + protected static enum IpUnbanResult + { + UNBANNED, + NOT_BANNED, + ERROR; + } + + protected static enum IpUnwhitelistResult + { + UNWHITELISTED, + NOT_WHITELISTED, + ERROR; + } + + protected static class ChainedDatabaseAction + { + private final BiConsumer> _action; + private final Map _results = new HashMap<>(); + private final Object _resultLock = new Object(); + + public ChainedDatabaseAction(BiConsumer> action) + { + _action = action; + } + + public ChainedDatabaseAction chain(ChainedDatabaseAction action) + { + return new ChainedDatabaseAction(_action.andThen(action._action)); + } + + @SuppressWarnings("unchecked") + public T getResult(String key) + { + synchronized (_resultLock) + { + Object result = _results.get(key); + if (result == null) + { + return null; + } + try + { + return (T) result; + } + catch (ClassCastException ex) + { + ex.printStackTrace(); + return null; + } + } + } + + public void execute() + { + synchronized (_resultLock) + { + try (Connection c = Managers.get(AltManager.class)._repo.getConnection()) + { + _action.accept(c, _results); + } + catch (SQLException e) + { + e.printStackTrace(); + } + } + } + + public void executeAsync(Runnable onComplete) + { + UtilServer.runAsync(() -> + { + synchronized (_resultLock) + { + try (Connection c = Managers.get(AltManager.class)._repo.getConnection()) + { + _action.accept(c, _results); + } + catch (SQLException e) + { + e.printStackTrace(); + } + } + if (onComplete == null) + { + return; + } + UtilServer.runSync(onComplete); + }); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/moderation/antialt/IpAPIData.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/moderation/antialt/IpAPIData.java new file mode 100644 index 000000000..6f7ec852f --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/moderation/antialt/IpAPIData.java @@ -0,0 +1,155 @@ +package mineplex.game.clans.clans.moderation.antialt; + +import com.google.gson.annotations.SerializedName; + +public class IpAPIData +{ + public String status; + + public String msg; + + @SerializedName("package") + public String accessPackage; + + public int remaining_requests; + + public String ipaddress; + + @SerializedName("host-ip") + public boolean host_ip; + + public String org; + + public RegionInfo country; + + public RegionInfo subdivision; + + public String city; + + public String postal; + + public LocationInfo location; + + public ImmutableIpAPIData makeImmutable() + { + return ImmutableIpAPIData.create(this); + } + + public static class ImmutableIpAPIData + { + public final String status; + + public final String msg; + + @SerializedName("package") + public final String accessPackage; + + public final int remaining_requests; + + public final String ipaddress; + + @SerializedName("host-ip") + public final boolean host_ip; + + public final String org; + + public final ImmutableRegionInfo country; + + public final ImmutableRegionInfo subdivision; + + public final String city; + + public final String postal; + + public final ImmutableLocationInfo location; + + private ImmutableIpAPIData(IpAPIData base) + { + status = base.status; + msg = base.msg; + accessPackage = base.accessPackage; + remaining_requests = base.remaining_requests; + ipaddress = base.ipaddress; + host_ip = base.host_ip; + org = base.org; + country = ImmutableRegionInfo.create(base.country); + subdivision = ImmutableRegionInfo.create(base.subdivision); + city = base.city; + postal = base.postal; + location = ImmutableLocationInfo.create(base.location); + } + + public static ImmutableIpAPIData create(IpAPIData base) + { + if (base == null) + { + return null; + } + return new ImmutableIpAPIData(base); + } + } + + public static class RegionInfo + { + public String name = ""; + + public String code = ""; + } + + public static class ImmutableRegionInfo + { + public final String name; + + public final String code; + + private ImmutableRegionInfo(RegionInfo base) + { + name = base.name; + code = base.code; + } + + public static ImmutableRegionInfo create(RegionInfo base) + { + if (base == null) + { + return null; + } + + return new ImmutableRegionInfo(base); + } + } + + public static class LocationInfo + { + @SerializedName("lat") + public double latitude = 0; + + @SerializedName("long") + public double longitude = 0; + } + + public static class ImmutableLocationInfo + { + @SerializedName("lat") + public final double latitude; + + @SerializedName("long") + public final double longitude; + + private ImmutableLocationInfo(LocationInfo base) + { + latitude = base.latitude; + longitude = base.longitude; + } + + public static ImmutableLocationInfo create(LocationInfo base) + { + if (base == null) + { + return null; + } + + return new ImmutableLocationInfo(base); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/moderation/antialt/IpBanNotification.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/moderation/antialt/IpBanNotification.java new file mode 100644 index 000000000..4ffa8c526 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/moderation/antialt/IpBanNotification.java @@ -0,0 +1,18 @@ +package mineplex.game.clans.clans.moderation.antialt; + +import mineplex.serverdata.commands.ServerCommand; + +public class IpBanNotification extends ServerCommand +{ + private final String _ip; + + public IpBanNotification(String ip) + { + _ip = ip; + } + + public String getIp() + { + return _ip; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/Mount.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/Mount.java index 093631e9b..1d03f2269 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/Mount.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/Mount.java @@ -6,6 +6,7 @@ import org.bukkit.ChatColor; import org.bukkit.DyeColor; import org.bukkit.Material; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftHorse; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.entity.EntityType; import org.bukkit.entity.Horse.Color; import org.bukkit.entity.Horse.Style; @@ -15,16 +16,21 @@ import org.bukkit.inventory.ItemStack; import mineplex.core.common.TriConsumer; import mineplex.core.common.util.C; +import mineplex.core.common.util.EnclosedObject; +import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.particles.ColoredParticle; +import mineplex.core.common.util.particles.DustSpellColor; import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguiseCow; import mineplex.core.disguise.disguises.DisguiseSheep; import mineplex.core.itemstack.ItemBuilder; import mineplex.game.clans.clans.ClansManager; +import net.minecraft.server.v1_8_R3.EntityPlayer; import net.minecraft.server.v1_8_R3.GenericAttributes; public class Mount @@ -63,6 +69,31 @@ public class Mount if (_skin != null) { _skin.onUpdate(_entity); + if (_skin.needsJumpAssist()) + { + EntityPlayer rider = null; + if (_entity.getPassenger() != null && _entity.getPassenger() instanceof Player) + { + rider = ((CraftPlayer)_entity.getPassenger()).getHandle(); + try + { + boolean jumping = MountManager.JumpBooleanField.getBoolean(rider); + + if (jumping) + { + rider.i(false); + if (UtilEnt.isGrounded(_entity)) + { + MountManager.JumpFloatField.setFloat(_entity.getHandle(), 1.0f); + } + } + } + catch (Exception ex) + { + ex.printStackTrace(); + } + } + } } if (UtilTime.elapsed(_lastHit, HIT_REGEN_COOLDOWN) && _hits > 0) { @@ -98,43 +129,74 @@ public class Mount public static enum SkinType { - INFERNAL_HORROR(1, "Clans Infernal Horror Mount Skin", C.cRed + "Infernal Horror", Material.BONE, Color.BLACK, Variant.SKELETON_HORSE, Style.BLACK_DOTS, horse -> {}, horse -> + INFERNAL_HORROR(1, "Clans Infernal Horror Mount Skin", C.cRed + "Infernal Horror", Material.BONE, Color.BLACK, Variant.SKELETON_HORSE, Style.BLACK_DOTS, false, horse -> {}, horse -> { UtilParticle.PlayParticleToAll(ParticleType.FLAME, horse.getLocation().add(0, 1, 0), 0.25f, 0.25f, 0.25f, 0, 2,ViewDist.NORMAL); }, MountType.HORSE), - GLACIAL_STEED(2, "Clans Glacial Steed Mount Skin", C.cGray + "Glacial Steed", Material.SNOW_BALL, Color.WHITE, Variant.HORSE, Style.WHITE, horse -> {}, horse -> + GLACIAL_STEED(2, "Clans Glacial Steed Mount Skin", C.cGray + "Glacial Steed", Material.SNOW_BALL, Color.WHITE, Variant.HORSE, Style.WHITE, false, horse -> {}, horse -> { UtilParticle.PlayParticleToAll(ParticleType.SNOW_SHOVEL, horse.getLocation().add(0, 1, 0), 0.25f, 0.25f, 0.25f, 0.1f, 4, ViewDist.NORMAL); }, MountType.HORSE), - ZOMBIE_HORSE(3, "Clans Zombie Horse Mount Skin", C.cDGray + "Zombie Horse", Material.ROTTEN_FLESH, Color.BLACK, Variant.UNDEAD_HORSE, Style.BLACK_DOTS, horse -> {}, horse -> + ZOMBIE_HORSE(3, "Clans Zombie Horse Mount Skin", C.cDGray + "Zombie Horse", Material.ROTTEN_FLESH, Color.BLACK, Variant.UNDEAD_HORSE, Style.BLACK_DOTS, false, horse -> {}, horse -> { UtilParticle.PlayParticleToAll(ParticleType.FOOTSTEP, horse.getLocation(), null, 0, 1, ViewDist.NORMAL); }, MountType.HORSE), @SuppressWarnings("deprecation") - RAINBOW_SHEEP(4, "Clans Rainbow Sheep Mount Skin", C.cGreen + "Rainbow " + C.cAqua + "Sheep", new ItemBuilder(Material.WOOL).setData(DyeColor.RED.getWoolData()).build(),Color.WHITE, Variant.HORSE, Style.NONE, horse -> + RAINBOW_SHEEP(4, "Clans Rainbow Sheep Mount Skin", C.cGreen + "Rainbow " + C.cAqua + "Sheep", new ItemBuilder(Material.WOOL).setData(DyeColor.RED.getWoolData()).build(),Color.WHITE, Variant.HORSE, Style.NONE, true, horse -> { DisguiseSheep disguise = new DisguiseSheep(horse); disguise.setName(horse.getCustomName()); ClansManager.getInstance().getDisguiseManager().disguise(disguise); + UtilEnt.SetMetadata(horse, "RainbowSheep.ActiveTicks", new EnclosedObject<>(0)); + UtilEnt.SetMetadata(horse, "RainbowSheep.DelayTicks", new EnclosedObject<>(0)); + UtilEnt.SetMetadata(horse, "RainbowSheep.ParticleColor", new EnclosedObject<>(java.awt.Color.RED)); }, horse -> { - DisguiseBase base = ClansManager.getInstance().getDisguiseManager().getActiveDisguise(horse); - if (base == null || !(base instanceof DisguiseSheep)) + EnclosedObject activeTicks = null; + EnclosedObject delayTicks = null; + EnclosedObject color = UtilEnt.GetMetadata(horse, "RainbowSheep.ParticleColor"); + if ((activeTicks = UtilEnt.GetMetadata(horse, "RainbowSheep.ActiveTicks")) != null && (delayTicks = UtilEnt.GetMetadata(horse, "RainbowSheep.DelayTicks")) != null) { - return; + DisguiseBase base = ClansManager.getInstance().getDisguiseManager().getActiveDisguise(horse); + if (base instanceof DisguiseSheep && (delayTicks.Get() % 10) == 0) + { + DisguiseSheep sheep = (DisguiseSheep) base; + int mod = activeTicks.Get() % 4; + activeTicks.Set(activeTicks.Get() + 1); + + if (mod == 0) + { + sheep.setColor(DyeColor.RED); + color.Set(java.awt.Color.RED); + } + else if (mod == 1) + { + sheep.setColor(DyeColor.YELLOW); + color.Set(java.awt.Color.YELLOW); + } + else if (mod == 2) + { + sheep.setColor(DyeColor.GREEN); + color.Set(java.awt.Color.GREEN); + } + else if (mod == 3) + { + sheep.setColor(DyeColor.BLUE); + color.Set(java.awt.Color.BLUE); + } + + ClansManager.getInstance().getDisguiseManager().updateDisguise(base); + } + delayTicks.Set(delayTicks.Get() + 1); } - - DisguiseSheep sheep = (DisguiseSheep)base; - - if (horse.getTicksLived() % 4 == 0) sheep.setColor(DyeColor.RED); - else if (horse.getTicksLived() % 4 == 1) sheep.setColor(DyeColor.YELLOW); - else if (horse.getTicksLived() % 4 == 2) sheep.setColor(DyeColor.GREEN); - else if (horse.getTicksLived() % 4 == 3) sheep.setColor(DyeColor.BLUE); + ColoredParticle particle = new ColoredParticle(UtilParticle.ParticleType.RED_DUST, + new DustSpellColor(color.Get()), horse.getLocation().add(0, 1, 0)); + particle.display(3); }, MountType.HORSE), - ROYAL_STEED(5, "Clans Royal Steed Mount Skin", C.cGold + "Royal Steed", Material.DIAMOND_BARDING, Color.WHITE, Variant.HORSE, Style.WHITE, horse -> + ROYAL_STEED(5, "Clans Royal Steed Mount Skin", C.cGold + "Royal Steed", Material.DIAMOND_BARDING, Color.WHITE, Variant.HORSE, Style.WHITE, false, horse -> { horse.getInventory().setArmor(new ItemBuilder(Material.DIAMOND_BARDING).setTitle(C.cGoldB + "Royal Armor").build()); }, horse -> @@ -142,7 +204,7 @@ public class Mount UtilParticle.PlayParticleToAll(ParticleType.BLOCK_DUST.getParticle(Material.GOLD_BLOCK, 0), horse.getLocation().add(0, 1, 0), 0.25f, 0.25f, 0.25f, 0, 3, ViewDist.NORMAL); }, MountType.HORSE), - ROYAL_GUARD_STEED(6, "Clans Royal Guard Steed Mount Skin", C.cGray + "Royal Guard's Steed", Material.GOLD_BARDING, Color.BLACK, Variant.HORSE, Style.NONE, horse -> + ROYAL_GUARD_STEED(6, "Clans Royal Guard Steed Mount Skin", C.cGray + "Royal Guard's Steed", Material.GOLD_BARDING, Color.BLACK, Variant.HORSE, Style.NONE, false, horse -> { horse.getInventory().setArmor(new ItemBuilder(Material.GOLD_BARDING).setTitle(C.cGoldB + "Guardian Armor").build()); }, horse -> @@ -150,7 +212,7 @@ public class Mount UtilParticle.PlayParticleToAll(ParticleType.BLOCK_DUST.getParticle(Material.IRON_BLOCK, 0), horse.getLocation().add(0, 1, 0), 0.25f, 0.25f, 0.25f, 0, 3, ViewDist.NORMAL); }, MountType.HORSE), - KNIGHT_STEED(7, "Clans Knight Steed Mount Skin", C.cDRed + "Knight's Steed", Material.IRON_BARDING, Color.GRAY, Variant.HORSE, Style.NONE, horse -> + KNIGHT_STEED(7, "Clans Knight Steed Mount Skin", C.cDRed + "Knight's Steed", Material.IRON_BARDING, Color.GRAY, Variant.HORSE, Style.NONE, false, horse -> { horse.getInventory().setArmor(new ItemBuilder(Material.IRON_BARDING).setTitle(C.cGoldB + "Knightly Armor").build()); }, horse -> @@ -158,19 +220,19 @@ public class Mount UtilParticle.PlayParticleToAll(ParticleType.ICON_CRACK.getParticle(Material.APPLE, 0), horse.getLocation().add(0, 1, 0), 0.25f, 0.25f, 0.25f, 0, 3, ViewDist.NORMAL); }, MountType.HORSE), - COW(8, "Clans Cow Mount Skin", C.cWhite + "Cow", Material.MILK_BUCKET, Color.WHITE, Variant.HORSE, Style.NONE, horse -> + COW(8, "Clans Cow Mount Skin", C.cWhite + "Cow", Material.MILK_BUCKET, Color.WHITE, Variant.HORSE, Style.NONE, true, horse -> { DisguiseCow disguise = new DisguiseCow(horse); disguise.setName(horse.getCustomName()); ClansManager.getInstance().getDisguiseManager().disguise(disguise); }, horse -> {}, MountType.HORSE), - SHEEP(9, "Clans Sheep Mount Skin", C.cWhite + "Sheep", Material.WOOL, Color.WHITE, Variant.HORSE, Style.NONE, horse -> + SHEEP(9, "Clans Sheep Mount Skin", C.cWhite + "Sheep", Material.WOOL, Color.WHITE, Variant.HORSE, Style.NONE, true, horse -> { DisguiseSheep disguise = new DisguiseSheep(horse); disguise.setName(horse.getCustomName()); ClansManager.getInstance().getDisguiseManager().disguise(disguise); }, horse -> {}, MountType.HORSE), - TRUSTY_MULE(10, "Clans Trusty Mule Mount Skin", C.cBlue + "Trusty Mule", Material.APPLE, Color.BROWN, Variant.MULE, Style.NONE, horse -> {}, horse -> {}, MountType.DONKEY) + TRUSTY_MULE(10, "Clans Trusty Mule Mount Skin", C.cBlue + "Trusty Mule", Material.APPLE, Color.BROWN, Variant.MULE, Style.NONE, false, horse -> {}, horse -> {}, MountType.DONKEY) ; private final int _id; @@ -180,15 +242,16 @@ public class Mount private final Color _color; private final Variant _variant; private final Style _style; + private final boolean _needsJumpAssist; private final Consumer _onSpawn, _onUpdate; private final MountType[] _possibleTypes; - private SkinType(int id, String packageName, String displayName, Material displayType, Color color, Variant variant, Style style, Consumer onSpawn, Consumer onUpdate, MountType... possibleTypes) + private SkinType(int id, String packageName, String displayName, Material displayType, Color color, Variant variant, Style style, boolean needsJumpAssist, Consumer onSpawn, Consumer onUpdate, MountType... possibleTypes) { - this(id, packageName, displayName, new ItemStack(displayType), color, variant, style, onSpawn, onUpdate, possibleTypes); + this(id, packageName, displayName, new ItemStack(displayType), color, variant, style, needsJumpAssist, onSpawn, onUpdate, possibleTypes); } - private SkinType(int id, String packageName, String displayName, ItemStack baseDisplayItem, Color color, Variant variant, Style style, Consumer onSpawn, Consumer onUpdate, MountType... possibleTypes) + private SkinType(int id, String packageName, String displayName, ItemStack baseDisplayItem, Color color, Variant variant, Style style, boolean needsJumpAssist, Consumer onSpawn, Consumer onUpdate, MountType... possibleTypes) { _id = id; _packageName = packageName; @@ -197,6 +260,7 @@ public class Mount _color = color; _variant = variant; _style = style; + _needsJumpAssist = needsJumpAssist; _onSpawn = onSpawn; _onUpdate = onUpdate; _possibleTypes = possibleTypes; @@ -237,6 +301,11 @@ public class Mount return _style; } + public boolean needsJumpAssist() + { + return _needsJumpAssist; + } + public void onSpawn(CraftHorse horse) { _onSpawn.accept(horse); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountClaimToken.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountClaimToken.java index 63c0b11d6..47a98ae5f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountClaimToken.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountClaimToken.java @@ -98,6 +98,6 @@ public class MountClaimToken return null; } - return new MountClaimToken(strength, speed, jump, type); + return new MountClaimToken(jump, speed, strength, type); } } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java index 11cada41b..03946bf39 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java @@ -1,5 +1,6 @@ package mineplex.game.clans.clans.mounts; +import java.lang.reflect.Field; import java.sql.ResultSet; import java.sql.SQLException; import java.util.HashMap; @@ -9,13 +10,17 @@ import java.util.Map.Entry; import java.util.UUID; import java.util.WeakHashMap; +import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftHorse; +import org.bukkit.entity.Entity; import org.bukkit.entity.Horse; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; @@ -23,6 +28,7 @@ import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.world.ChunkUnloadEvent; import org.bukkit.inventory.HorseInventory; import org.bukkit.plugin.java.JavaPlugin; +import org.spigotmc.event.entity.EntityDismountEvent; import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; @@ -41,13 +47,18 @@ 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.ClanInfo; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.mounts.Mount.MountType; import mineplex.game.clans.clans.mounts.Mount.SkinType; import mineplex.game.clans.clans.mounts.gui.MountShop; +import mineplex.game.clans.core.repository.ClanTerritory; import mineplex.game.clans.spawn.Spawn; +import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.serverdata.Utility; +import net.minecraft.server.v1_8_R3.EntityHorse; +import net.minecraft.server.v1_8_R3.EntityLiving; public class MountManager extends MiniDbClientPlugin { @@ -58,6 +69,9 @@ public class MountManager extends MiniDbClientPlugin MOUNT_SKIN_UNLOCK, } + protected static Field JumpBooleanField; + protected static Field JumpFloatField; + private static final double[] JUMP_STARS = {0.8, 1, 1.2}; private static final double[] SPEED_STARS = {0.2, 0.27, 0.33}; private static final int[] STRENGTH_STARS = {1, 2, 3}; @@ -74,11 +88,25 @@ public class MountManager extends MiniDbClientPlugin private final Map _spawnedMounts = new HashMap<>(); private final Map> _summoning = new WeakHashMap<>(); + private final int _serverId; + public MountManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager) { super("Clans Mount Manager", plugin, clientManager); - _repository = new MountRepository(plugin, this); + try + { + JumpBooleanField = EntityLiving.class.getDeclaredField("aY"); + JumpBooleanField.setAccessible(true); + JumpFloatField = EntityHorse.class.getDeclaredField("br"); + JumpFloatField.setAccessible(true); + } + catch (NoSuchFieldException e) + { + e.printStackTrace(); + } + _serverId = ClansManager.getInstance().getServerId(); + _repository = new MountRepository(plugin, this, _serverId); _donationManager = donationManager; final MountShop shop = new MountShop(this); @@ -203,6 +231,23 @@ public class MountManager extends MiniDbClientPlugin UtilPlayer.message(player, F.main(getName(), "You cannot summon a mount inside a raid!")); return false; } + for (double x = -2; x <= 2; x++) + { + for (double z = -2; z <= 2; z++) + { + Location loc = player.getLocation().add(x, 0, z); + ClanTerritory territory = ClansManager.getInstance().getClanUtility().getClaim(loc); + if (territory != null) + { + ClanInfo cInfo = ClansManager.getInstance().getClan(player); + if (cInfo != null && !cInfo.getName().equals(territory.Owner) && !ClansManager.getInstance().getClan(territory.Owner).isAdmin()) + { + UtilPlayer.message(player, F.main(getName(), "You cannot summon a mount that close to another Clan's territory!")); + return false; + } + } + } + } if (!Recharge.Instance.usable(player, "Mount Spawn Delay")) { UtilPlayer.message(player, F.main(getName(), "You cannot summon a mount so soon after your last one was forcibly despawned!")); @@ -230,7 +275,7 @@ public class MountManager extends MiniDbClientPlugin { getRepository().deleteMount(token, id -> { - Get(player).removeMount(id.intValue()); + Get(player).removeMount(id); Pair summonPair = _summoning.get(player); if (summonPair != null) { @@ -287,7 +332,7 @@ public class MountManager extends MiniDbClientPlugin if (UtilEnt.GetMetadata(entry.getKey(), "DISMOUNT_TIME") != null) { Long dismount = UtilEnt.GetMetadata(entry.getKey(), "DISMOUNT_TIME"); - if (UtilTime.elapsed(dismount.longValue(), MAX_TIME_DISMOUNTED)) + if (UtilTime.elapsed(dismount, MAX_TIME_DISMOUNTED)) { mountIterator.remove(); entry.getValue().despawn(false); @@ -513,11 +558,47 @@ public class MountManager extends MiniDbClientPlugin } }); } + + @EventHandler + public void onDismount(EntityDismountEvent event) + { + if (_spawnedMounts.containsKey(event.getDismounted()) && event.getEntity() instanceof Player) + { + runSyncLater(() -> + { + event.getEntity().teleport(event.getDismounted()); + }, 1L); + } + } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onShootBow(EntityShootBowEvent event) + { + LivingEntity entity = event.getEntity(); + Entity vehicle = entity.getVehicle(); + if (entity instanceof Player && vehicle != null && _spawnedMounts.containsKey(vehicle)) + { + UtilPlayer.message(entity, F.main(getName(), "You cannot shoot while mounted!")); + event.setCancelled(true); + } + } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onUseSkill(SkillTriggerEvent event) + { + Player rider = event.GetPlayer(); + Entity vehicle = rider.getVehicle(); + if (vehicle != null && _spawnedMounts.containsKey(vehicle)) + { + UtilPlayer.message(rider, F.main(getName(), "You cannot use skills while mounted!")); + event.SetCancelled(true); + } + } @Override public String getQuery(int accountId, String uuid, String name) { - return "SELECT am.id, am.mountTypeId, am.mountSkinId, ms.statToken FROM accountClansMounts AS am INNER JOIN clansMountStats AS ms ON ms.mountId = am.id WHERE am.accountId=" + accountId + ";"; + return "SELECT am.id, am.mountTypeId, am.mountSkinId, ms.statToken FROM accountClansMounts AS am INNER JOIN clansMountStats AS ms ON ms.mountId = am.id WHERE am.accountId=" + accountId + " AND am.serverId=" + _serverId + ";"; } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountRepository.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountRepository.java index 821c887d2..419572c81 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountRepository.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountRepository.java @@ -21,8 +21,12 @@ public class MountRepository extends RepositoryBase { private static final String CREATE_MOUNTS_TABLE = "CREATE TABLE IF NOT EXISTS accountClansMounts (id INT NOT NULL AUTO_INCREMENT," + "accountId INT NOT NULL," + + "serverId INT NOT NULL," + "mountTypeId INT NOT NULL," + "mountSkinId INT NOT NULL," + + "INDEX accountIndex (accountId)," + + "INDEX serverIndex (serverId)," + + "INDEX accountServerIndex(accountId, serverId)," + "INDEX typeIndex (mountTypeId)," + "INDEX skinIndex (mountSkinId)," + "PRIMARY KEY (id));"; @@ -31,18 +35,21 @@ public class MountRepository extends RepositoryBase + "statToken VARCHAR(20) NOT NULL," + "PRIMARY KEY (mountId));"; - private static final String INSERT_MOUNT = "INSERT INTO accountClansMounts (accountId, mountTypeId, mountSkinId) VALUES (?, ?, ?);"; + private static final String INSERT_MOUNT = "INSERT INTO accountClansMounts (accountId, serverId, mountTypeId, mountSkinId) VALUES (?, ?, ?, ?);"; private static final String SAVE_MOUNT = "UPDATE accountClansMounts SET mountSkinId=? WHERE id=?;"; private static final String SAVE_MOUNT_STATS = "INSERT INTO clansMountStats (mountId, statToken) VALUES (?, ?) ON DUPLICATE KEY UPDATE statToken=VALUES(statToken);"; private static final String DELETE_MOUNT = "DELETE FROM accountClansMounts WHERE id=?;"; private static final String DELETE_MOUNT_STATS = "DELETE FROM clansMountStats WHERE mountId=?;"; + private final int _serverId; private MountManager _mountManager; - public MountRepository(JavaPlugin plugin, MountManager mountManager) + public MountRepository(JavaPlugin plugin, MountManager mountManager, int serverId) { super(DBPool.getAccount()); + _mountManager = mountManager; + _serverId = serverId; } /** @@ -65,7 +72,7 @@ public class MountRepository extends RepositoryBase { token.Id = idResult.getInt(1); } - }, null, new ColumnInt("accountId", accountId), new ColumnInt("mountTypeId", token.Type.getId()), new ColumnInt("mountSkinId", token.Skin == null ? -1 : token.Skin.getId())); + }, null, new ColumnInt("accountId", accountId), new ColumnInt("serverId", _serverId), new ColumnInt("mountTypeId", token.Type.getId()), new ColumnInt("mountSkinId", token.Skin == null ? -1 : token.Skin.getId())); } else { @@ -108,7 +115,7 @@ public class MountRepository extends RepositoryBase { token.Id = idResult.getInt(1); } - }, null, new ColumnInt("accountId", accountId), new ColumnInt("mountTypeId", token.Type.getId()), new ColumnInt("mountSkinId", token.Skin == null ? -1 : token.Skin.getId())); + }, null, new ColumnInt("accountId", accountId), new ColumnInt("serverId", _serverId), new ColumnInt("mountTypeId", token.Type.getId()), new ColumnInt("mountSkinId", token.Skin == null ? -1 : token.Skin.getId())); } else { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/potato/PotatoManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/potato/PotatoManager.java index bc9be3fff..c977fc414 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/potato/PotatoManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/potato/PotatoManager.java @@ -135,4 +135,10 @@ public class PotatoManager extends MiniPlugin implements IThrown { } -} + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvPTimerManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvPTimerManager.java new file mode 100644 index 000000000..160b4d1b0 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvPTimerManager.java @@ -0,0 +1,262 @@ +package mineplex.game.clans.clans.pvptimer; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.Charset; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; +import java.util.WeakHashMap; + +import org.apache.commons.io.FileUtils; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.player.PlayerJoinEvent; + +import mineplex.core.MiniPlugin; +import mineplex.core.ReflectivelyCreateMiniPlugin; +import mineplex.core.account.permissions.Permission; +import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.command.CommandBase; +import mineplex.core.common.util.F; +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.classcombat.Skill.event.SkillTriggerEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +@ReflectivelyCreateMiniPlugin +public class PvPTimerManager extends MiniPlugin +{ + public enum Perm implements Permission + { + PVP_ENABLE_SELF, + PVP_ENABLE_OTHER, + } + + private final File _directory; + private final Map _timers = new WeakHashMap<>(); + + public PvPTimerManager() + { + super("PvP Timer"); + + _directory = new File("pvptimers"); + if (!_directory.exists()) + { + _directory.mkdir(); + } + if (!_directory.isDirectory()) + { + FileUtils.deleteQuietly(_directory); + _directory.mkdir(); + } + + addCommand(new CommandBase(this, Perm.PVP_ENABLE_SELF, "pvp") + { + public void Execute(Player caller, String[] args) + { + if (!hasTimer(caller)) + { + UtilPlayer.message(caller, F.main(getName(), "You do not have a PvP Timer!")); + return; + } + + disableTimer(caller, true, true); + } + }); + addCommand(new CommandBase(this, Perm.PVP_ENABLE_OTHER, "enablepvp") + { + public void Execute(Player caller, String[] args) + { + if (args.length < 1) + { + UtilPlayer.message(caller, F.main(getName(), "Usage: /enablepvp ")); + return; + } + Player target = Bukkit.getPlayer(args[0]); + if (target == null) + { + UtilPlayer.message(caller, F.main(getName(), F.elem(args[0]) + " was not found!")); + return; + } + + if (hasTimer(target)) + { + disableTimer(target, true, true); + UtilPlayer.message(caller, F.main(getName(), F.elem(target.getName()) + " no longer has a PvP Timer!")); + } + else + { + UtilPlayer.message(caller, F.main(getName(), F.elem(target.getName()) + " does not have a PvP Timer!")); + } + } + }); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionGroup.PLAYER.setPermission(Perm.PVP_ENABLE_SELF, true, true); + PermissionGroup.CMOD.setPermission(Perm.PVP_ENABLE_OTHER, false, true); + PermissionGroup.ADMIN.setPermission(Perm.PVP_ENABLE_OTHER, true, true); + } + + private String getPvPTimerFile(String fileName) throws IOException + { + return _directory.getCanonicalFile() + File.separator + fileName; + } + + private boolean addPvPTimer(Player player) + { + try + { + File file = new File(getPvPTimerFile(player.getUniqueId().toString() + ".pvp")); + boolean add = !FileUtils.directoryContains(_directory, file); + + if (add) + { + long start = System.currentTimeMillis(); + FileUtils.write(file, String.valueOf(start), Charset.defaultCharset(), false); + _timers.put(player, start); + } + else + { + String read = FileUtils.readFileToString(file, Charset.defaultCharset()); + long parsed = Long.parseLong(read); + if (parsed != -1 && !UtilTime.elapsed(parsed, 60 * 60 * 1000)) + { + _timers.put(player, parsed); + } + } + + return add; + } + catch (IOException | NumberFormatException e) + { + e.printStackTrace(); + return false; + } + } + + private void disableTimer(Player player, boolean removeFromMap, boolean inform) + { + try + { + File file = new File(getPvPTimerFile(player.getUniqueId().toString() + ".pvp")); + if (file.exists()) + { + FileUtils.write(file, String.valueOf(-1L), Charset.defaultCharset(), false); + if (removeFromMap) + { + _timers.remove(player); + } + if (inform) + { + UtilPlayer.message(player, F.main(getName(), "Your PvP Protection has been removed!")); + } + } + } + catch (IOException e) + { + e.printStackTrace(); + } + } + + public boolean hasTimer(Player player) + { + if (_timers.containsKey(player)) + { + if (UtilTime.elapsed(_timers.get(player), 60 * 60 * 1000)) + { + _timers.remove(player); + } + else + { + return true; + } + } + + return false; + } + + @EventHandler + public void onJoin(PlayerJoinEvent event) + { + if (addPvPTimer(event.getPlayer())) + { + runSyncLater(() -> UtilPlayer.message(event.getPlayer(), F.main(getName(), "You now have 1 hour of PvP Protection!")), 40L); + } + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + { + return; + } + + Iterator> timers = _timers.entrySet().iterator(); + while (timers.hasNext()) + { + Entry timer = timers.next(); + if (UtilTime.elapsed(timer.getValue(), 60 * 60 * 1000)) + { + UtilPlayer.message(timer.getKey(), F.main(getName(), "Your PvP Protection has expired!")); + disableTimer(timer.getKey(), false, false); + timers.remove(); + } + } + } + + @EventHandler + public void onSkill(SkillTriggerEvent event) + { + if (hasTimer(event.GetPlayer())) + { + UtilPlayer.message(event.GetPlayer(), F.main("Clans", "You cannot use skills whilst protected from PvP. Run " + F.elem("/pvp") + " to enable PvP!")); + event.SetCancelled(true); + } + } + + @EventHandler + public void onShoot(EntityShootBowEvent event) + { + if (event.getEntity() instanceof Player) + { + Player player = (Player) event.getEntity(); + + if (hasTimer(player)) + { + UtilPlayer.message(player, F.main("Clans", "You cannot shoot whilst protected from PvP. Run " + F.elem("/pvp") + " to enable PvP!")); + event.setCancelled(true); + } + } + } + + @EventHandler + public void onDamage(CustomDamageEvent event) + { + if (event.GetDamageePlayer() != null) + { + if (hasTimer(event.GetDamageePlayer())) + { + UtilPlayer.message(event.GetDamagerPlayer(true), F.main(getName(), "You cannot harm " + F.elem(event.GetDamageePlayer().getName()) + "!")); + event.SetCancelled("PvP Timer"); + } + if (event.GetDamagerPlayer(true) != null) + { + if (hasTimer(event.GetDamagerPlayer(true))) + { + UtilPlayer.message(event.GetDamagerPlayer(true), F.main(getName(), "You cannot harm " + F.elem(event.GetDamageePlayer().getName()) + " whilst protected from PvP. Run " + F.elem("/pvp") + " to enable PvP!")); + event.SetCancelled("PvP Timer"); + } + } + } + } +} \ 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 792f96cc2..d0da92ce6 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 @@ -90,7 +90,7 @@ public class SiegeManager extends MiniPlugin System.out.println("[WEAPONS] LOADED SIEGE WEAPON " + weapon.getClass().getSimpleName() + " [" + token.UniqueId + "]"); - LiveSiegeWeapons.put(Integer.valueOf(token.UniqueId), weapon); + LiveSiegeWeapons.put(token.UniqueId, weapon); }) ) ); @@ -216,7 +216,7 @@ public class SiegeManager extends MiniPlugin { final SiegeWeaponToken token = weapon.toToken(); - if (UnsyncedSiegeWeapons.containsKey(Integer.valueOf(token.UniqueId))) + if (UnsyncedSiegeWeapons.containsKey(token.UniqueId)) continue; queue.push(() -> _repository.updateWeapon(token)); @@ -291,7 +291,7 @@ public class SiegeManager extends MiniPlugin if (_clansManager.hasTimer(player)) { - UtilPlayer.message(player, F.main("Clans", "You cannot place a Cannon whilst protected from pvp.")); + UtilPlayer.message(player, F.main("Clans", "You cannot place a Cannon whilst protected from PvP. Run " + F.elem("/pvp") + " to enable PvP!")); return false; } @@ -331,7 +331,7 @@ public class SiegeManager extends MiniPlugin if (_clansManager.hasTimer(player)) { - UtilPlayer.message(player, F.main("Clans", "You cannot place a Cannon whilst protected from pvp.")); + UtilPlayer.message(player, F.main("Clans", "You cannot place a Cannon whilst protected from PvP. Run " + F.elem("/pvp") + " to enable PvP!")); return false; } @@ -357,15 +357,15 @@ public class SiegeManager extends MiniPlugin { Cannon cannon = new Cannon(location, _clansManager.getClan(player), this, syncWithDb); - UnsyncedSiegeWeapons.put(Integer.valueOf(cannon.getUniqueId()), cannon); + UnsyncedSiegeWeapons.put(cannon.getUniqueId(), cannon); return cannon; } public void dead(SiegeWeapon weapon) { - LiveSiegeWeapons.remove(Integer.valueOf(weapon.getUniqueId())); - SiegeWeapon unsynced = UnsyncedSiegeWeapons.remove(Integer.valueOf(weapon.getUniqueId())); + LiveSiegeWeapons.remove(weapon.getUniqueId()); + SiegeWeapon unsynced = UnsyncedSiegeWeapons.remove(weapon.getUniqueId()); if (unsynced == null) _repository.deleteWeapon(weapon.getUniqueId()); 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 c20834e30..5dfd1bbbc 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 @@ -151,7 +151,7 @@ public class Outpost implements Listener { if (_outpostManager.getClansManager().hasTimer(player)) { - UtilPlayer.message(player, F.main("Clans", "You cannot destroy an Outpost whilst protected from PvP.")); + UtilPlayer.message(player, F.main("Clans", "You cannot destroy an Outpost whilst protected from PvP. Run " + F.elem("/pvp") + " to enable PvP!")); return; } if (!UtilTime.elapsed(_lastDamage, 5000)) @@ -255,7 +255,7 @@ public class Outpost implements Listener { if (_outpostManager.getClansManager().hasTimer(player)) { - UtilPlayer.message(player, F.main("Clans", "You cannot destroy an Outpost whilst protected from PvP.")); + UtilPlayer.message(player, F.main("Clans", "You cannot destroy an Outpost whilst protected from PvP. Run " + F.elem("/pvp") + " to enable PvP!")); return; } if (!UtilTime.elapsed(_lastDamage, 5000)) @@ -339,9 +339,9 @@ public class Outpost implements Listener { if (event.getClickedBlock().getType().equals(Material.BEACON)) { - if(_outpostManager.getClansManager().hasTimer(event.getPlayer())) + if (_outpostManager.getClansManager().hasTimer(event.getPlayer())) { - UtilPlayer.message(event.getPlayer(), F.main("Clans", "You cannot activate an Outpost whilst protected from PvP.")); + UtilPlayer.message(event.getPlayer(), F.main("Clans", "You cannot activate an Outpost whilst protected from PvP. Run " + F.elem("/pvp") + " to enable PvP!")); return; } @@ -379,7 +379,7 @@ public class Outpost implements Listener event.setCancelled(true); if (_outpostManager.getClansManager().hasTimer(event.getPlayer())) { - UtilPlayer.message(event.getPlayer(), F.main("Clans", "You cannot destroy an Outpost whilst protected from PvP.")); + UtilPlayer.message(event.getPlayer(), F.main("Clans", "You cannot destroy an Outpost whilst protected from PvP. Run " + F.elem("/pvp") + " to enable PvP!")); return; } if (!UtilTime.elapsed(_lastDamage, 5000)) @@ -426,7 +426,7 @@ public class Outpost implements Listener event.setCancelled(true); if (_outpostManager.getClansManager().hasTimer(event.getPlayer())) { - UtilPlayer.message(event.getPlayer(), F.main("Clans", "You cannot destroy an Outpost whilst protected from PvP.")); + UtilPlayer.message(event.getPlayer(), F.main("Clans", "You cannot destroy an Outpost whilst protected from PvP. Run " + F.elem("/pvp") + " to enable PvP!")); return; } if (!UtilTime.elapsed(_lastDamage, 5000)) @@ -643,18 +643,22 @@ public class Outpost implements Listener EnclosedObject wait = new EnclosedObject<>(0); _blocks.values().stream().filter(block -> UtilMath.random.nextBoolean() && UtilMath.random.nextBoolean()).filter(block -> UtilMath.random.nextBoolean()).limit(13).forEach(block -> - _outpostManager.runSyncLater(() -> { + _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.Set(Integer.valueOf(wait.Get().intValue() + 4 + UtilMath.random.nextInt(4))).longValue()) + }, wait.Set(wait.Get() + 4 + UtilMath.random.nextInt(4))) ); - _outpostManager.runSyncLater(() -> { + _outpostManager.runSyncLater(() -> + { _blocks.values().stream().forEach(OutpostBlock::restore); - }, wait.Get().intValue() + 5L); + }, wait.Get() + 5L); - _outpostManager.runSyncLater(() -> { - _blocks.values().stream().forEach(block -> { + _outpostManager.runSyncLater(() -> + { + _blocks.values().stream().forEach(block -> + { Material mat = Material.getMaterial(block.getId()); if (UtilItem.isTranslucent(mat) || UtilMath.random.nextBoolean()) @@ -675,7 +679,7 @@ public class Outpost implements Listener }); cleanup(); - }, wait.Get().intValue() + 6L); + }, wait.Get() + 6L); if (_lifetimeLeft != null) _lifetimeLeft.stop(); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/OutpostManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/OutpostManager.java index c962a829d..e7e1b25a6 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/OutpostManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/OutpostManager.java @@ -95,7 +95,7 @@ public class OutpostManager extends MiniPlugin if (_clansManager.hasTimer(player)) { - UtilPlayer.message(player, F.main("Clans", "You can't place an Outpost whilst protected from PvP.")); + UtilPlayer.message(player, F.main("Clans", "You can't place an Outpost whilst protected from PvP. Run " + F.elem("/pvp") + " to enable PvP!")); return false; } @@ -201,7 +201,7 @@ public class OutpostManager extends MiniPlugin } _outposts.put(clan.getName(), new Outpost(this, clan, location, type)); - _idToOutpost.put(Integer.valueOf(_outposts.get(clan.getName()).getUniqueId()), _outposts.get(clan.getName())); + _idToOutpost.put(_outposts.get(clan.getName()).getUniqueId(), _outposts.get(clan.getName())); return true; } @@ -237,7 +237,7 @@ public class OutpostManager extends MiniPlugin if (event.getType() == UpdateType.FASTER) if (!_removalQueue.isEmpty()) - HandlerList.unregisterAll(_idToOutpost.remove(Integer.valueOf(_outposts.remove(_removalQueue.remove(0)).getUniqueId()))); + HandlerList.unregisterAll(_idToOutpost.remove(_outposts.remove(_removalQueue.remove(0)).getUniqueId())); if (event.getType() == UpdateType.TWOSEC) _outposts.values() @@ -268,7 +268,7 @@ public class OutpostManager extends MiniPlugin public Outpost Get(int outpostId) { - return _idToOutpost.get(Integer.valueOf(outpostId)); + return _idToOutpost.get(outpostId); } public ClansManager getClansManager() @@ -305,19 +305,23 @@ public class OutpostManager extends MiniPlugin { final Stack queue = new Stack<>(); - _outposts.values().forEach(outpost -> { + _outposts.values().forEach(outpost -> + { final OutpostToken token = outpost.toToken(); queue.push(() -> _repository.updateOutpost(token)); }); - runAsync(() -> { + runAsync(() -> + { while (!queue.isEmpty()) queue.pop().run(); - _repository.getOutpostsByServer(_clansManager.getServerId(), tokens -> { - tokens.forEach(token -> { - if (!_idToOutpost.containsKey(Integer.valueOf(token.UniqueId))) + _repository.getOutpostsByServer(_clansManager.getServerId(), tokens -> + { + tokens.forEach(token -> + { + if (!_idToOutpost.containsKey(token.UniqueId)) { System.out.println("[OUTPOSTS] OUTPOST [" + token.UniqueId + "] NO LONGER EXISTS, DELETING"); _repository.deleteOutpost(token.UniqueId); @@ -331,4 +335,4 @@ public class OutpostManager extends MiniPlugin { return _repository; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/repository/OutpostRepository.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/repository/OutpostRepository.java index e6b53a15d..6fe2d021e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/repository/OutpostRepository.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/repository/OutpostRepository.java @@ -119,7 +119,7 @@ public class OutpostRepository extends RepositoryBase public void updateOutpost(OutpostToken token) { executeUpdate(UPDATE_OUTPOST, - new ColumnByte("outpostState", Byte.valueOf(token.OutpostState.getId())), + new ColumnByte("outpostState", token.OutpostState.getId()), new ColumnInt("uniqueId", token.UniqueId)); } @@ -132,6 +132,6 @@ public class OutpostRepository extends RepositoryBase new ColumnInt("outpostType", token.Type.getId()), new ColumnInt("ownerClan", token.OwnerClan.getId()), new ColumnTimestamp("timeSpawned", new Timestamp(token.TimeSpawned)), - new ColumnByte("outpostState", Byte.valueOf(token.OutpostState.getId()))); + new ColumnByte("outpostState", token.OutpostState.getId())); } -} +} \ No newline at end of file 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 a864ffaf1..c36c4b5b9 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 @@ -72,7 +72,8 @@ public class Cannon extends SiegeWeapon _baseDamage = 650; - setFireRule(new AccessRule(AccessType.LCLICK_BB, player -> { + setFireRule(new AccessRule(AccessType.LCLICK_BB, player -> + { if (!isRiding(player)) { return false; @@ -84,9 +85,9 @@ public class Cannon extends SiegeWeapon // return false; // } - if(_clans.hasTimer(player)) + if (_clans.hasTimer(player)) { - UtilPlayer.message(player, F.main("Clans", "You cannot fire a cannon whilst on PvPTimer")); + UtilPlayer.message(player, F.main("Clans", "You cannot fire a cannon whilst protected from PvP. Run " + F.elem("/pvp") + " to enable PvP!")); return false; } @@ -107,7 +108,8 @@ public class Cannon extends SiegeWeapon enableInventory(UtilServer.getServer().createInventory(null, InventoryType.DISPENSER, C.cDAquaB + _name), new AccessRule(AccessType.RCLICK_BB, player -> player.equals(getRider()))); - setRideable(new AccessRule(AccessType.RCLICK_BB, player -> { + setRideable(new AccessRule(AccessType.RCLICK_BB, player -> + { if (!_ownerClan.isMember(player)) { UtilPlayer.message(player, F.main("Clans", "This Cannon is not owned by your Clan.")); @@ -120,9 +122,9 @@ public class Cannon extends SiegeWeapon return false; } - if(_clans.hasTimer(player)) + if (_clans.hasTimer(player)) { - UtilPlayer.message(player, F.main("Clans", "You cannot ride on a Cannon whilst on PvPTimer")); + UtilPlayer.message(player, F.main("Clans", "You cannot ride on a Cannon whilst protected from PvP. Run " + F.elem("/pvp") + " to enable PvP!")); return false; } @@ -146,7 +148,7 @@ public class Cannon extends SiegeWeapon setFirepowerType(Material.SULPHUR); setAmmunitionType(Material.TNT); - setFirepowerSlots(Integer.valueOf(1), Integer.valueOf(3), Integer.valueOf(5), Integer.valueOf(7)); + setFirepowerSlots(1, 3, 5, 7); setMaximumFirepowerPerSlot(3); setAmmunitionSlot(4); @@ -154,7 +156,8 @@ public class Cannon extends SiegeWeapon _baseDamage = 650; - setFireRule(new AccessRule(AccessType.LCLICK_BB, player -> { + setFireRule(new AccessRule(AccessType.LCLICK_BB, player -> + { if (!isRiding(player)) { return false; @@ -168,7 +171,7 @@ public class Cannon extends SiegeWeapon if (_clans.hasTimer(player)) { - UtilPlayer.message(player, F.main("Clans", "You cannot fire a Cannon whilst protected from pvp.")); + UtilPlayer.message(player, F.main("Clans", "You cannot fire a Cannon whilst protected from PvP. Run " + F.elem("/pvp") + " to enable PvP!")); return false; } @@ -189,7 +192,8 @@ public class Cannon extends SiegeWeapon enableInventory(UtilServer.getServer().createInventory(null, InventoryType.DISPENSER, C.cDAquaB + _name), new AccessRule(AccessType.RCLICK_BB, player -> player.equals(getRider()))); - setRideable(new AccessRule(AccessType.RCLICK_BB, player -> { + setRideable(new AccessRule(AccessType.RCLICK_BB, player -> + { if (!_ownerClan.isMember(player)) { UtilPlayer.message(player, F.main("Clans", "This Cannon is not owned by your Clan.")); @@ -202,9 +206,9 @@ public class Cannon extends SiegeWeapon return false; } - if(_clans.hasTimer(player)) + if (_clans.hasTimer(player)) { - UtilPlayer.message(player, F.main("Clans", "You cannot ride on a Cannon whilst protected from pvp.")); + UtilPlayer.message(player, F.main("Clans", "You cannot ride on a Cannon whilst protected from PvP. Run " + F.elem("/pvp") + " to enable PvP!")); return false; } @@ -300,7 +304,7 @@ public class Cannon extends SiegeWeapon _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))) + for (int slot : UtilCollections.newList(3, 5, 6, 7, 8)) { _inventory.setItem(slot, new ItemBuilder(Material.COBBLESTONE).setTitle(C.cGray + "Cannon Wall").build()); } @@ -457,4 +461,4 @@ public class Cannon extends SiegeWeapon false ); }*/ -} +} \ No newline at end of file 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 4f6602afa..5ed1191c5 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 @@ -63,6 +63,7 @@ import mineplex.game.clans.clans.siege.weapon.util.BarrierCollisionBox; import mineplex.game.clans.clans.siege.weapon.util.WeaponStateInfo; import mineplex.game.clans.items.PlayerGear; import mineplex.game.clans.items.legendaries.AlligatorsTooth; +import mineplex.game.clans.items.legendaries.DemonicScythe; import mineplex.game.clans.items.legendaries.GiantsBroadsword; import mineplex.game.clans.items.legendaries.HyperAxe; import mineplex.game.clans.items.legendaries.LegendaryItem; @@ -235,6 +236,8 @@ public abstract class SiegeWeapon implements Listener return 8; else if (gear.getWeapon() instanceof WindBlade) return 7; + else if (gear.getWeapon() instanceof DemonicScythe) + return 8; return (int) UtilItem.getAttackDamage(stack.getType()); } @@ -685,7 +688,7 @@ public abstract class SiegeWeapon implements Listener } } } - else if (_firepowerSlots.contains(Integer.valueOf(slot))) + else if (_firepowerSlots.contains(slot)) { if (item.getType() != _firepowerType) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/supplyDrop/SupplyDrop.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/supplyDrop/SupplyDrop.java index 9aa27baff..7b80117b2 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/supplyDrop/SupplyDrop.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/supplyDrop/SupplyDrop.java @@ -1,91 +1,180 @@ -package mineplex.game.clans.clans.supplyDrop; +package mineplex.game.clans.clans.supplydrop; import java.lang.reflect.Field; -import java.util.Random; import org.bukkit.Bukkit; +import org.bukkit.Chunk; import org.bukkit.Color; import org.bukkit.FireworkEffect; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.Chest; import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; +import org.bukkit.event.block.Action; +import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; +import org.bukkit.metadata.FixedMetadataValue; + +import mineplex.core.common.Pair; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilWorld; +import mineplex.core.hologram.Hologram; +import mineplex.core.hologram.HologramManager; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.supplydrop.SupplyDropManager.SupplyDropType; import net.minecraft.server.v1_8_R3.BlockPosition; import net.minecraft.server.v1_8_R3.TileEntity; import net.minecraft.server.v1_8_R3.TileEntityBeacon; -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilFirework; -import mineplex.core.common.util.UtilTime; -import mineplex.core.hologram.Hologram; -import mineplex.core.hologram.HologramManager; -import mineplex.game.clans.clans.ClansManager; - -public class SupplyDrop implements Listener +public class SupplyDrop { - private static int DROP_TICKS = 20 * 10; - private static int REMOVE_TICKS = DROP_TICKS + (20 * 120); // 2 Minutes - public static Material SUPPLY_DROP_MATERIAL = Material.BEACON; - - private ClansManager _clansManager; - - private Block _block; - private Player _owner; - private int _ticks; - private boolean _running; - private Hologram _hologram; - private Random _random; - - protected SupplyDrop(Player owner, Block block, ClansManager clansManager, HologramManager hologramManager) + private static Field BEACON_LEVEL; + private static Field BEACON_ENABLED; + + static { - _owner = owner; + try + { + BEACON_LEVEL = TileEntityBeacon.class.getDeclaredField("j"); + BEACON_LEVEL.setAccessible(true); + BEACON_ENABLED = TileEntityBeacon.class.getDeclaredField("i"); + BEACON_ENABLED.setAccessible(true); + } + catch (NoSuchFieldException | SecurityException e) + { + e.printStackTrace(); + } + } + + private static final int DROP_TICKS = 20 * 60 * 3; //3 Minutes + private static final int REMOVE_TICKS = DROP_TICKS + (20 * 120); // 2 Minutes + public static final Material SUPPLY_DROP_MATERIAL = Material.BEACON; + public static final String SUPPLY_DROP_FILLED_METADATA = "SUPPLY_DROP_FILLED"; + + private final SupplyDropType _type; + private final mineplex.game.clans.clans.supplydrop.SupplyDropManager.BlockPosition _position; + private final Block _block; + private final Block[] _below = new Block[9]; + @SuppressWarnings("unchecked") + private final Pair[] _oldBelow = new Pair[9]; + private int _ticks; + private boolean _ended; + private final Hologram _hologram; + + @SuppressWarnings("deprecation") + protected SupplyDrop(SupplyDropType type, Block block, HologramManager hologramManager) + { + _type = type; + _position = new mineplex.game.clans.clans.supplydrop.SupplyDropManager.BlockPosition(block); _block = block; _ticks = 0; - _running = true; + _ended = false; _hologram = new Hologram(hologramManager, _block.getLocation().add(0.5, 1.5, 0.5)); + _hologram.setInteraction((player, clickType) -> + { + UtilServer.CallEvent(new PlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, player.getItemInHand(), _block, _block.getFace(player.getLocation().getBlock()))); + }); _hologram.start(); - _random = new Random(); - _clansManager = clansManager; - - System.out.println("supply drop"); - + block.setType(SUPPLY_DROP_MATERIAL); - + + int index = 0; for (int x = -1; x <= 1; x++) { for (int z = -1; z <= 1; z++) { Block b = block.getRelative(x, -1, z); - clansManager.getBlockRestore().add(b, Material.DIAMOND_BLOCK.getId(), (byte) 0, 60000); + _below[index] = b; + _oldBelow[index] = Pair.create(b.getType(), b.getData()); + b.setType(Material.DIAMOND_BLOCK); + index++; } } } + + private String getChatColor(long millis) + { + if (millis > 30000) + { + return C.cAqua; + } + else if (millis > 10000) + { + return C.cYellow; + } + else + { + return C.cRed; + } + } + + private void placeChest() + { + _block.setType(Material.CHEST); + + ClansManager.getInstance().runSyncLater(() -> + { + Chest chest = (Chest) _block.getState(); + + Inventory inventory = chest.getBlockInventory(); + + int i = 0; + for (ItemStack item : _type.generateLootItems()) + { + inventory.setItem(i++, item); + } + _block.setMetadata(SUPPLY_DROP_FILLED_METADATA, new FixedMetadataValue(UtilServer.getPlugin(), true)); + }, 5); + } + + public boolean isDropping() + { + return _ticks < DROP_TICKS; + } + + public boolean isActive() + { + return _ticks < REMOVE_TICKS && !_ended; + } + + public Chunk getChunk() + { + return _block.getChunk(); + } + + public mineplex.game.clans.clans.supplydrop.SupplyDropManager.BlockPosition getPosition() + { + return _position; + } + + public int getTicks() + { + return _ticks; + } public void tick() { + if (_ended) + { + return; + } if (getTicks() < DROP_TICKS) { if (getTicks() == 10) { - /* try { TileEntity tileEntity = ((CraftWorld) _block.getWorld()).getHandle().getTileEntity(new BlockPosition(_block.getX(), _block.getY(), _block.getZ())); - Field k = TileEntityBeacon.class.getDeclaredField("k"); - k.setAccessible(true); - - Field l = TileEntityBeacon.class.getDeclaredField("l"); - l.setAccessible(true); if (tileEntity instanceof TileEntityBeacon) { - k.set(tileEntity, true); - l.set(tileEntity, 3); + BEACON_ENABLED.set(tileEntity, true); + BEACON_LEVEL.set(tileEntity, 3); tileEntity.update(); } } @@ -93,7 +182,6 @@ public class SupplyDrop implements Listener { e.printStackTrace(); } - */ } if (getTicks() > 15 && getTicks() % 10 == 0) @@ -105,13 +193,14 @@ public class SupplyDrop implements Listener if (getTicks() % 20 == 0) { long millis = (DROP_TICKS - getTicks()) * 50; // Multiply by 50 to convert ticks to ms - _hologram.setText(getChatColor(millis) + UtilTime.convertString(millis, 0, UtilTime.TimeUnit.SECONDS) + " Until Drop"); + _hologram.setText(getChatColor(millis) + UtilTime.MakeStr(millis) + " Until Drop"); } } else { if (getTicks() == DROP_TICKS) { + Bukkit.broadcastMessage(F.main("Supply Drop", "A supply drop has landed at " + F.elem(UtilWorld.locToStrClean(_block.getLocation())))); placeChest(); } @@ -119,7 +208,7 @@ public class SupplyDrop implements Listener if (getTicks() % 20 == 0) { long millis = (REMOVE_TICKS - getTicks()) * 50; // Multiply by 50 to convert ticks to ms - _hologram.setText(getChatColor(millis) + UtilTime.convertString(millis, 0, UtilTime.TimeUnit.SECONDS) + " Remaining"); + _hologram.setText(getChatColor(millis) + UtilTime.MakeStr(millis) + " Remaining"); } if (getTicks() >= REMOVE_TICKS) @@ -131,70 +220,15 @@ public class SupplyDrop implements Listener _ticks++; } - private void placeChest() + @SuppressWarnings("deprecation") + public void finish() { - getBlock().setType(Material.CHEST); - - _clansManager.runSyncLater(new Runnable() - { - @Override - public void run() - { - Chest chest = (Chest) getBlock().getState(); - - Inventory inventory = chest.getBlockInventory(); - int slots = inventory.getSize(); - int drops = 5 + _random.nextInt(11); // 5 -> 15 - - for (int i = 0; i < drops; i++) - { - int slot = _random.nextInt(slots); - ItemStack item = _clansManager.getLootManager().getRareItemStack(); - inventory.setItem(slot, item); - } - } - }, 5); - } - - private void finish() - { - _running = false; + _ended = true; _hologram.stop(); - getBlock().setType(Material.AIR); + for (int i = 0; i < 9; i++) + { + _below[i].setTypeIdAndData(_oldBelow[i].getLeft().getId(), _oldBelow[i].getRight(), false); + } + _block.breakNaturally(); } - - private String getChatColor(long millis) - { - if (millis > 30000) - return C.cAqua; - else if (millis > 10000) - return C.cYellow; - else - return C.cRed; - } - - public boolean isRunning() - { - return _running; - } - - public Block getBlock() - { - return _block; - } - - public Player getOwner() - { - return _owner; - } - - public int getTicks() - { - return _ticks; - } - - public boolean contains(Block block) - { - return _block.equals(block); - } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/supplyDrop/SupplyDropManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/supplyDrop/SupplyDropManager.java index 2a0c69166..8b3f9042e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/supplyDrop/SupplyDropManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/supplyDrop/SupplyDropManager.java @@ -1,99 +1,85 @@ -package mineplex.game.clans.clans.supplyDrop; +package mineplex.game.clans.clans.supplydrop; -import java.util.Iterator; -import java.util.LinkedList; +import java.util.ArrayList; import java.util.List; +import java.util.Objects; +import java.util.concurrent.ThreadLocalRandom; +import java.util.function.Function; +import java.util.function.Supplier; +import java.util.stream.Stream; import org.bukkit.Bukkit; +import org.bukkit.GameMode; 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.block.Action; -import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.world.ChunkUnloadEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; +import com.google.common.collect.Lists; + import mineplex.core.MiniPlugin; import mineplex.core.common.util.C; import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilItem; +import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilWorld; -import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.weight.Weight; +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.game.clans.core.repository.ClanTerritory; +import mineplex.game.clans.clans.loot.GoldTokenLoot; +import mineplex.game.clans.clans.loot.MountLoot; +import mineplex.game.clans.clans.loot.RuneLoot; +import mineplex.game.clans.items.GearManager; +import mineplex.game.clans.items.ItemType; +import mineplex.game.clans.items.RareItemFactory; +import mineplex.game.clans.items.attributes.AttributeContainer; +import mineplex.game.clans.items.legendaries.LegendaryItem; +import mineplex.game.clans.items.legendaries.MeridianScepter; +import mineplex.game.clans.items.rares.RunedPickaxe; public class SupplyDropManager extends MiniPlugin { - private ClansManager _clansManager; - private List _supplyDrops; + private SupplyDrop _active = null; + private final Block _dropBlock = Bukkit.getWorld("world").getBlockAt(-31, 55, -7); + private final SupplyDropShop _shop; - public SupplyDropManager(JavaPlugin plugin, ClansManager clansManager) + public SupplyDropManager(JavaPlugin plugin) { - super("Supply Drops", plugin); - - _clansManager = clansManager; - _supplyDrops = new LinkedList(); + super("Supply Drop", plugin); + + _shop = new SupplyDropShop(this); } - - @EventHandler - public void placeSupplyDrop(BlockPlaceEvent event) + + public SupplyDropShop getShop() { - ItemStack item = event.getItemInHand(); - - if (isSupplyDropItem(item)) - { - ClanTerritory claim = _clansManager.getClanUtility().getClaim(event.getBlock().getLocation()); - if (claim != null) - { - UtilPlayer.message(event.getPlayer(), F.main("Clans", "You can only place " + F.elem("Supply Drop") + " in the Wilderness")); - event.setCancelled(true); - return; - } - - event.getPlayer().setItemInHand(null); - placeSupplyDrop(event.getPlayer(), event.getBlock()); - - Bukkit.broadcastMessage(F.main("Clans", F.name(event.getPlayer().getName()) + " placed a supply drop at " + F.elem(UtilWorld.blockToStrClean(event.getBlock())))); - } + return _shop; } -// @EventHandler -// public void debug(PlayerCommandPreprocessEvent event) -// { -// if (event.getMessage().equalsIgnoreCase("/supplydrop")) -// { -// UtilPlayer.message(event.getPlayer(), F.main("Clans", "You received a " + F.elem("Supply Drop"))); -// giveSupplyDropItem(event.getPlayer()); -// } -// } - @EventHandler public void update(UpdateEvent event) { if (event.getType() != UpdateType.TICK) return; - - Iterator iterator = _supplyDrops.iterator(); - - while (iterator.hasNext()) + + if (_active != null) { - SupplyDrop supplyDrop = iterator.next(); - - if (supplyDrop.isRunning()) + if (_active.isActive()) { - supplyDrop.tick(); + _active.tick(); } else { -// supplyDrop.getBlock().setType(Material.AIR); - HandlerList.unregisterAll(supplyDrop); - iterator.remove(); + _active = null; } } } @@ -101,56 +87,332 @@ public class SupplyDropManager extends MiniPlugin @EventHandler public void cancelInteract(PlayerInteractEvent event) { - if (event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_BLOCK) + if (!event.hasBlock()) { - if (event.getClickedBlock() != null && event.getClickedBlock().getType() == SupplyDrop.SUPPLY_DROP_MATERIAL) + return; + } + if (!UtilEvent.isAction(event, ActionType.ANY)) + { + return; + } + if (_active == null) + { + return; + } + if (new BlockPosition(event.getClickedBlock()).equals(_active.getPosition())) + { + event.setCancelled(true); + if (!_active.isActive() || _active.isDropping()) { - event.setCancelled(true); + return; } + if (!event.getClickedBlock().hasMetadata(SupplyDrop.SUPPLY_DROP_FILLED_METADATA)) + { + return; + } + if (UtilPlayer.isSpectator(event.getPlayer()) || event.getPlayer().getGameMode() != GameMode.SURVIVAL) + { + return; + } + _active.finish(); + _active = null; } } - + @EventHandler - public void cancelBreak(BlockBreakEvent event) + public void onChunkUnload(ChunkUnloadEvent event) { - for (SupplyDrop supplyDrop : _supplyDrops) + if (_active != null && _active.getChunk().getX() == event.getChunk().getX() && _active.getChunk().getZ() == event.getChunk().getZ()) { - if (supplyDrop.contains(event.getBlock())) - { - event.setCancelled(true); - } + event.setCancelled(true); } } - - private void placeSupplyDrop(Player player, Block block) + + @EventHandler + public void onJoin(PlayerJoinEvent event) { - SupplyDrop supplyDrop = new SupplyDrop(player, block, _clansManager, _clansManager.getHologramManager()); - getPlugin().getServer().getPluginManager().registerEvents(supplyDrop, getPlugin()); - _supplyDrops.add(supplyDrop); + if (_active != null) + { + boolean landed = !_active.isDropping(); + runSyncLater(() -> + { + if (_active != null) + { + if (_active.isDropping()) + { + UtilPlayer.message(event.getPlayer(), F.main(getName(), "A supply drop is landing at " + F.elem("(" + _active.getPosition()._x + ", " + _active.getPosition()._z + ")") + "!")); + } + else if (landed) + { + UtilPlayer.message(event.getPlayer(), F.main(getName(), "A supply drop has landed at " + F.elem("(" + _active.getPosition()._x + ", " + _active.getPosition()._z + ")") + "!")); + } + } + }, 40L); + } } - - private void giveSupplyDropItem(Player player) + + /** + * Checks whether there is a supply drop active on this server + * @return Whether there is a supply drop active on this server + */ + public boolean hasActiveSupplyDrop() { - ItemStack item = ItemStackFactory.Instance.CreateStack(Material.BEACON, (byte) 0, 1, C.cGold + "Supply Drop"); - player.getInventory().addItem(item); + return _active != null; } - - private boolean isSupplyDropItem(ItemStack item) + + /** + * Checks how many of a certain supply drop type a player owns + * @param player The player to check + * @param type The type of supply drop to check for + * @return The amount of supply drops of that type owned + */ + public int getAmountOwned(Player player, SupplyDropType type) { - if (item == null) + return ClansManager.getInstance().getInventoryManager().Get(player).getItemCount(type.getItemName()); + } + + /** + * Makes a player use a supply drop + * @param user The player to use the supply drop + * @param type The type of supply drop to use + */ + public void useSupplyDrop(Player user, SupplyDropType type) + { + if (getAmountOwned(user, type) < 1) + { + return; + } + if (hasActiveSupplyDrop()) + { + return; + } + _dropBlock.getChunk().load(); + _active = new SupplyDrop(type, _dropBlock, ClansManager.getInstance().getHologramManager()); + ClansManager.getInstance().getInventoryManager().addItemToInventory(user, type.getItemName(), -1); + UtilTextMiddle.display(C.cRed + "Supply Drop", "(" + _active.getPosition()._x + ", " + _active.getPosition()._z + ")"); + Bukkit.broadcastMessage(F.main(getName(), "A supply drop has been summoned by " + F.elem(user.getName()) + " at " + F.elem("(" + _active.getPosition()._x + ", " + _active.getPosition()._z + ")") + "!")); + } + + protected static class BlockPosition + { + private final int _x, _y, _z; + + public BlockPosition(Block block) + { + _x = block.getX(); + _y = block.getY(); + _z = block.getZ(); + } + + @Override + public int hashCode() + { + return Objects.hash(_x, _y, _z); + } + + @Override + public boolean equals(Object o) + { + if (o instanceof BlockPosition) + { + BlockPosition pos = (BlockPosition) o; + return pos._x == _x && pos._y == _y && pos._z == _z; + } + return false; - - return item.getType() == SupplyDrop.SUPPLY_DROP_MATERIAL && item.getItemMeta().hasDisplayName() && item.getItemMeta().getDisplayName().contains("Supply"); - -// if (item.getType() == SUPPLY_DROP_MATERIAL) -// { -// CustomItem customItem = GearManager.parseItem(item); -// if (customItem != null && customItem instanceof SupplyDropItem) -// { -// return true; -// } -// } -// -// return false; + } } -} + + public static enum SupplyDropType + { + NORMAL("Clans Supply Drop", "Supply Drop", 5, 7, () -> + { + GearManager gear = ClansManager.getInstance().getGearManager(); + ItemType[] itemTypes = {ItemType.ARMOR, ItemType.BOW, ItemType.WEAPON}; + Material[] weaponTypes = {Material.IRON_AXE, Material.IRON_SWORD}; + Material[] armorTypes = Stream.of(Material.values()).filter(UtilItem::isArmor).toArray(size -> new Material[size]); + GoldTokenLoot goldLoot = new GoldTokenLoot(30000, 70000); + MountLoot mountLoot = new MountLoot(1, 2); + + return (amount) -> + { + WeightSet> set = new WeightSet<>(); + set.add(1, () -> + { + return RareItemFactory.begin(ItemType.RARE).setRare(RunedPickaxe.class).fabricate(); + }); + set.add(25, () -> + { + ItemType type = UtilMath.randomElement(itemTypes); + Material mat = UtilMath.randomElement((type == ItemType.ARMOR) ? armorTypes : (type == ItemType.BOW ? new Material[] {Material.BOW} : weaponTypes)); + AttributeContainer container = new AttributeContainer(); + + gear.generateAttributes(container, type, ThreadLocalRandom.current().nextInt(1, 3)); + return RareItemFactory.begin(type).setType(mat).setSuperPrefix(container.getSuperPrefix()).setPrefix(container.getPrefix()).setSuffix(container.getSuffix()).fabricate(); + }); + Weight> gold = set.add(4, () -> + { + return goldLoot.getItemStack(); + }); + Weight> mount = set.add(4, () -> + { + return mountLoot.getItemStack(); + }); + + List items = new ArrayList<>(); + for (int i = 0; i < amount; i++) + { + ItemStack item = set.generateRandom().get(); + items.add(set.generateRandom().get()); + if (item.getType() == Material.RECORD_12) + { + set.remove(gold); + } + if (item.getType() == Material.IRON_BARDING || item.getType() == Material.GOLD_BARDING) + { + set.remove(mount); + } + } + + return items; + }; + }), + GILDED("Clans Gilded Supply Drop", "Gilded Supply Drop", 8, 10, () -> + { + GearManager gear = ClansManager.getInstance().getGearManager(); + List> legendaryTypes = Lists.newArrayList(gear.getFindableLegendaries()); + List> runeableLegendaryTypes = Lists.newArrayList(gear.getFindableLegendaries()); + runeableLegendaryTypes.remove(MeridianScepter.class); + ItemType[] rareTypes = {ItemType.RARE, ItemType.LEGENDARY}; + ItemType[] itemTypes = {ItemType.ARMOR, ItemType.BOW, ItemType.WEAPON}; + Material[] weaponTypes = {Material.IRON_AXE, Material.IRON_SWORD}; + Material[] armorTypes = Stream.of(Material.values()).filter(UtilItem::isArmor).toArray(size -> new Material[size]); + GoldTokenLoot goldLoot = new GoldTokenLoot(30000, 70000); + MountLoot mountLoot = new MountLoot(1, 3); + RuneLoot runeLoot = new RuneLoot(); + + return (amount) -> + { + WeightSet> set = new WeightSet<>(); + set.add(1, () -> + { + ItemType type = UtilMath.randomElement(rareTypes); + RareItemFactory factory = RareItemFactory.begin(type); + if (type == ItemType.RARE) + { + return factory.setRare(RunedPickaxe.class).fabricate(); + } + boolean runed = false; + if (ThreadLocalRandom.current().nextDouble() < 0.02) + { + runed = true; + AttributeContainer container = new AttributeContainer(); + gear.generateAttributes(container, type, ThreadLocalRandom.current().nextInt(1, 4)); + factory.setSuperPrefix(container.getSuperPrefix()).setPrefix(container.getPrefix()).setSuffix(container.getSuffix()); + } + return factory.setLegendary(UtilMath.randomElement(runed ? runeableLegendaryTypes : legendaryTypes)).fabricate(); + }); + set.add(25, () -> + { + ItemType type = UtilMath.randomElement(itemTypes); + Material mat = UtilMath.randomElement((type == ItemType.ARMOR) ? armorTypes : (type == ItemType.BOW ? new Material[] {Material.BOW} : weaponTypes)); + AttributeContainer container = new AttributeContainer(); + + gear.generateAttributes(container, type, ThreadLocalRandom.current().nextInt(1, 4)); + return RareItemFactory.begin(type).setType(mat).setSuperPrefix(container.getSuperPrefix()).setPrefix(container.getPrefix()).setSuffix(container.getSuffix()).fabricate(); + }); + set.add(3, () -> + { + return runeLoot.getItemStack(); + }); + Weight> gold = set.add(4, () -> + { + return goldLoot.getItemStack(); + }); + Weight> mount = set.add(4, () -> + { + return mountLoot.getItemStack(); + }); + + List items = new ArrayList<>(); + int golds = 0; + int mounts = 0; + for (int i = 0; i < amount; i++) + { + ItemStack item = set.generateRandom().get(); + items.add(set.generateRandom().get()); + if (item.getType() == Material.RECORD_12) + { + if (++golds > 1) + { + set.remove(gold); + } + } + if (item.getType() == Material.IRON_BARDING || item.getType() == Material.GOLD_BARDING) + { + if (++mounts > 2) + { + set.remove(mount); + } + } + } + + return items; + }; + }); + + private final String _item, _display; + private final int _min, _max; + private final Function> _loot; + + private SupplyDropType(String itemName, String displayName, int minItems, int maxItems, Supplier>> loot) + { + _item = itemName; + _display = displayName; + _min = minItems; + _max = maxItems; + _loot = loot.get(); + } + + /** + * Gets the name of this supply drop as recognized by the inventory database + * @return The name of this supply drop as recognized by the inventory database + */ + public String getItemName() + { + return _item; + } + + /** + * Gets the display name for this supply drop + * @return The display name for this supply drop + */ + public String getDisplayName() + { + return _display; + } + + /** + * Gets the minimum items for this type of supply drop + * @return The minimum items for this type of supply drop + */ + public int getMinItems() + { + return _min; + } + + /** + * Gets the maximum items for this type of supply drop + * @return The maximum items for this type of supply drop + */ + public int getMaxItems() + { + return _max; + } + + public List generateLootItems() + { + return _loot.apply(ThreadLocalRandom.current().nextInt(_min, _max + 1)); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/supplydrop/SupplyDropPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/supplydrop/SupplyDropPage.java new file mode 100644 index 000000000..bacd67d68 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/supplydrop/SupplyDropPage.java @@ -0,0 +1,73 @@ +package mineplex.game.clans.clans.supplydrop; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.bukkit.entity.Player; + +import mineplex.core.common.skin.SkinData; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.recharge.Recharge; +import mineplex.core.shop.page.ShopPageBase; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.supplydrop.SupplyDropManager.SupplyDropType; + +public class SupplyDropPage extends ShopPageBase +{ + public SupplyDropPage(SupplyDropManager plugin, SupplyDropShop shop, String name, Player player) + { + super(plugin, shop, ClansManager.getInstance().getClientManager(), ClansManager.getInstance().getDonationManager(), name, player, 27); + + buildPage(); + } + + @Override + protected void buildPage() + { + int[] slots = {12, 14}; + int i = 0; + for (SupplyDropType type : SupplyDropType.values()) + { + int owned = getPlugin().getAmountOwned(getPlayer(), type); + int slot = slots[i++]; + SkinData buttonData = type == SupplyDropType.GILDED ? SkinData.CLANS_GILDED_SUPPLY_DROP : SkinData.CLANS_SUPPLY_DROP; + List buttonLore = new ArrayList<>(); + buttonLore.addAll(Arrays.asList(C.cYellow + "Open a Supply Drop containing powerful items!", + C.cRed + " ", + C.cGreen + ">Click to Activate<", + C.cBlue + " ", + C.cDAqua + "You own " + F.greenElem(String.valueOf(Math.max(owned, 0))) + C.cDAqua + " " + type.getDisplayName() + "s" + )); + if (type == SupplyDropType.GILDED) + { + buttonLore.add(C.cGreen + " "); + buttonLore.add(C.cYellow + "Gilded Supply Drops contain better items!"); + } + addButton(slot, buttonData.getSkull(C.cRed + type.getDisplayName(), buttonLore), (player, clickType) -> + { + if (!Recharge.Instance.use(player, "Clans Box Click", 1000, false, false)) + { + return; + } + if (owned < 1) + { + playDenySound(player); + UtilPlayer.message(player, F.main(getPlugin().getName(), "You do not have enough of that Supply Drop! Purchase some at http://www.mineplex.com/shop!")); + return; + } + if (getPlugin().hasActiveSupplyDrop()) + { + playDenySound(player); + UtilPlayer.message(player, F.main(getPlugin().getName(), "There is already a Supply Drop dropping! Try again later!")); + return; + } + SupplyDropManager manager = getPlugin(); + player.closeInventory(); + manager.useSupplyDrop(player, type); + }); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/supplydrop/SupplyDropShop.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/supplydrop/SupplyDropShop.java new file mode 100644 index 000000000..0a9d4bf28 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/supplydrop/SupplyDropShop.java @@ -0,0 +1,21 @@ +package mineplex.game.clans.clans.supplydrop; + +import org.bukkit.entity.Player; + +import mineplex.core.shop.ShopBase; +import mineplex.core.shop.page.ShopPageBase; +import mineplex.game.clans.clans.ClansManager; + +public class SupplyDropShop extends ShopBase +{ + public SupplyDropShop(SupplyDropManager plugin) + { + super(plugin, ClansManager.getInstance().getClientManager(), ClansManager.getInstance().getDonationManager(), "Supply Drop"); + } + + @Override + protected ShopPageBase> buildPagesFor(Player player) + { + return new SupplyDropPage(getPlugin(), this, "Supply Drops", player); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/tntGenerator/TntGenerator.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/tntGenerator/TntGenerator.java index c27697061..7dd234565 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/tntGenerator/TntGenerator.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/tntGenerator/TntGenerator.java @@ -1,4 +1,4 @@ -package mineplex.game.clans.clans.tntGenerator; +package mineplex.game.clans.clans.tntgenerator; import java.util.UUID; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/tntGenerator/TntGeneratorManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/tntGenerator/TntGeneratorManager.java index cf57f77d1..0a5d37793 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/tntGenerator/TntGeneratorManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/tntGenerator/TntGeneratorManager.java @@ -1,4 +1,4 @@ -package mineplex.game.clans.clans.tntGenerator; +package mineplex.game.clans.clans.tntgenerator; import org.bukkit.event.EventHandler; import org.bukkit.plugin.java.JavaPlugin; 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 3a2c44f2e..e171b03de 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 @@ -26,6 +26,7 @@ import mineplex.core.thereallyoldscoreboardapiweshouldremove.elements.Scoreboard import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.bosstoken.BossTokenShop; import mineplex.game.clans.clans.loot.LootManager; import mineplex.game.clans.clans.regions.ClansRegions; import mineplex.game.clans.clans.worldevent.api.EventState; @@ -33,8 +34,6 @@ import mineplex.game.clans.clans.worldevent.api.WorldEvent; import mineplex.game.clans.clans.worldevent.boss.BossArenaLocationFinder; import mineplex.game.clans.clans.worldevent.command.WorldEventCommand; import mineplex.game.clans.clans.worldevent.raid.RaidManager; -import mineplex.minecraft.game.classcombat.Skill.SkillFactory; -import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; import mineplex.minecraft.game.core.damage.DamageManager; public class WorldEventManager extends MiniPlugin implements ScoreboardElement @@ -56,13 +55,13 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement private LootManager _lootManager; private BlockRestore _blockRestore; - private SkillFactory _skillFactory; - private long _nextEventStart; private RaidManager _raidManager; - public WorldEventManager(JavaPlugin plugin, ClansManager clansManager, DamageManager damageManager, LootManager lootManager, BlockRestore blockRestore, ClansRegions clansRegions, SkillFactory skillFactory) + private BossTokenShop _shop; + + public WorldEventManager(JavaPlugin plugin, ClansManager clansManager, DamageManager damageManager, LootManager lootManager, BlockRestore blockRestore, ClansRegions clansRegions) { super("World Event", plugin); @@ -75,7 +74,7 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement _blockRestore = blockRestore; _runningEvents = new LinkedList<>(); - _skillFactory = skillFactory; + _shop = new BossTokenShop(this); new Blood(plugin); @@ -109,26 +108,25 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement _raidManager.onDisable(); } - public boolean isInEvent(Location location) + public boolean isInEvent(Location location, boolean icePrisonCheck) { for (WorldEvent event : _runningEvents) { - event.isInBounds(location, true); + if (event.isInBounds(location, true)) + { + if (!icePrisonCheck || !event.allowsIcePrison()) + { + return true; + } + } } return false; } - @EventHandler - public void onIcePrison(SkillTriggerEvent event) + public BossTokenShop getShop() { - if (event.GetSkillName().equalsIgnoreCase("Ice Prison")) - { - if (isInEvent(event.GetPlayer().getLocation())) - { - event.SetCancelled(true); - } - } + return _shop; } @EventHandler @@ -332,12 +330,6 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement return _runningEvents; } - /** I know this is a bad work around... sorry */ - public void setFactory(SkillFactory skillManager) - { - _skillFactory = skillManager; - } - public DisguiseManager getDisguiseManager() { return getClans().getDisguiseManager(); 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 2580c7a9e..d52337639 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 @@ -1,8 +1,12 @@ package mineplex.game.clans.clans.worldevent; +import java.util.function.Function; + import mineplex.game.clans.clans.worldevent.api.WorldEvent; import mineplex.game.clans.clans.worldevent.boss.ironwizard.GolemBoss; import mineplex.game.clans.clans.worldevent.boss.skeletonking.SkeletonBoss; +import mineplex.game.clans.clans.worldevent.capturepoint.CapturePointEvent; +import mineplex.game.clans.clans.worldevent.undead.UndeadCity; public enum WorldEventType { @@ -12,24 +16,30 @@ public enum WorldEventType //IRON_WIZARD("Iron Wizard", GolemBoss.class, 30), //BROOD_MOTHER("Brood Mother", SpiderBoss.class, 30), //SKELETON_KING("Skeleton King", SkeletonBoss.class, 30) - IRON_WIZARD("Iron Wizard", GolemBoss.class, (man) -> + IRON_WIZARD("Iron Wizard", (man) -> { return new GolemBoss(man); }), - SKELETON_KING("Skeleton King", SkeletonBoss.class, (man) -> + SKELETON_KING("Skeleton King", (man) -> { return new SkeletonBoss(man); + }), + CAPTURE_POINT("Capture Point", (man) -> + { + return new CapturePointEvent(man); + }), + UNDEAD_CITY("Undead City", (man) -> + { + return new UndeadCity(man); }) ; private String _name; - private Class _clazz; - private EventCreator _creator; + private Function _creator; - WorldEventType(String name, Class clazz, EventCreator creator) + private WorldEventType(String name, Function creator) { _name = name; - _clazz = clazz; _creator = creator; } @@ -39,7 +49,7 @@ public enum WorldEventType if (_creator != null) { - worldEvent = _creator.createEvent(eventManager); + worldEvent = _creator.apply(eventManager); } return worldEvent; @@ -49,9 +59,4 @@ public enum WorldEventType { return _name; } - - private static interface EventCreator - { - WorldEvent createEvent(WorldEventManager manager); - } } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/WorldEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/WorldEvent.java index 1790cc269..ff09d34b3 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/WorldEvent.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/WorldEvent.java @@ -108,6 +108,11 @@ public abstract class WorldEvent implements Listener, ScoreboardElement _difficulty = difficulty; } + public boolean allowsIcePrison() + { + return false; + } + public Location getCenterLocation() { return _arena.getCenterLocation(); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/BossWorldEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/BossWorldEvent.java index 817850ac7..7ffa2486d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/BossWorldEvent.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/BossWorldEvent.java @@ -26,6 +26,7 @@ import mineplex.game.clans.clans.worldevent.api.EventCreatureDeathEvent; import mineplex.game.clans.clans.worldevent.api.EventState; import mineplex.game.clans.clans.worldevent.api.WorldEvent; import mineplex.minecraft.game.classcombat.Skill.ISkill; +import mineplex.minecraft.game.classcombat.Skill.Assassin.Blink; import mineplex.minecraft.game.classcombat.Skill.Assassin.Recall; import mineplex.minecraft.game.core.condition.ConditionManager; import mineplex.minecraft.game.core.damage.DamageManager; @@ -85,6 +86,10 @@ public abstract class BossWorldEvent> extends WorldEv { ((Recall)skill).Reset(player); } + if (skill instanceof Blink) + { + ((Blink)skill).Reset(player); + } } sendMessage(player, "You have teleported inside the arena!"); } @@ -104,7 +109,7 @@ public abstract class BossWorldEvent> extends WorldEv UtilServer.CallEvent(new BossDeathEvent(this, drop)); ClansManager.getInstance().runSyncLater(() -> { - ClansManager.getInstance().getLootManager().dropRare(drop); + ClansManager.getInstance().getLootManager().dropBoss(drop); drop.getWorld().dropItem(drop, new ItemBuilder(Material.IRON_INGOT).setTitle(C.cDRedB + "Old Silver Token").setLore(C.cRed + "This token pulses with an evil aura.").setGlow(true).build()); }, DELAY_TILL_DROP_REWARD); Bukkit.broadcastMessage(getDeathMessage()); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/IronHook.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/IronHook.java index 73ddfce16..94785a425 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/IronHook.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/IronHook.java @@ -51,4 +51,10 @@ public class IronHook implements IThrown { data.getThrown().remove(); } + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/capturepoint/CapturePointEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/capturepoint/CapturePointEvent.java index 663bd3850..e68e82c1a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/capturepoint/CapturePointEvent.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/capturepoint/CapturePointEvent.java @@ -1,37 +1,152 @@ package mineplex.game.clans.clans.worldevent.capturepoint; +import java.util.Optional; + +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; + +import mineplex.core.common.Pair; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilTextTop; +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.ClansManager; import mineplex.game.clans.clans.worldevent.WorldEventManager; +import mineplex.game.clans.clans.worldevent.api.EventState; import mineplex.game.clans.clans.worldevent.api.WorldEvent; public class CapturePointEvent extends WorldEvent { + private static final long MAX_TICKS = UtilTime.convert(5, TimeUnit.MINUTES, TimeUnit.SECONDS) * 20; + private Player _capturing = null; + private Player _winner = null; + private Pair _resetData = null; + private PointBoundary _boundary = null; + private long _ticks = 0; + public CapturePointEvent(WorldEventManager manager) { super("Capture Point", CapturePointLocation.getRandomLocation().toLocation(UtilWorld.getWorld("world")), 5, true, manager.getDisguiseManager(), manager.getClans().getProjectile(), manager.getDamage(), manager.getBlockRestore(), manager.getClans().getCondition()); } + @SuppressWarnings("deprecation") @Override protected void customStart() { - + Block set = getCenterLocation().getBlock().getRelative(BlockFace.DOWN); + _resetData = Pair.create(set.getType(), set.getData()); + set.setType(Material.BEACON); + double minX = (getCenterLocation().getBlockX() + 0.5) - 4.5; + double maxX = (getCenterLocation().getBlockX() + 0.5) + 4.5; + double minZ = (getCenterLocation().getBlockZ() + 0.5) - 4.5; + double maxZ = (getCenterLocation().getBlockZ() + 0.5) + 4.5; + double minY = getCenterLocation().getBlockY() + 1; + double maxY = getCenterLocation().getBlockY() + 4; + _boundary = new PointBoundary(minX, maxX, minZ, maxZ, minY, maxY); } @Override protected void customTick() { - + if (getState() != EventState.LIVE) + { + return; + } + if (_capturing == null) + { + Optional opt = Bukkit.getOnlinePlayers().stream().filter(_boundary::isInBoundary).findAny(); + if (opt.isPresent()) + { + _capturing = opt.get(); + Recharge.Instance.useForce(_capturing, "Capture Point Alert", 30000); + announceMessage(F.name(_capturing.getName()) + " is capturing the point!"); + } + } + else + { + if (!_boundary.isInBoundary(_capturing) || _capturing.isDead() || !_capturing.isOnline() || !_capturing.isValid()) + { + announceMessage(F.name(_capturing.getName()) + " has lost the point!"); + _capturing = null; + _ticks = 0; + } + else + { + _ticks++; + updateLastActive(); + if (_ticks >= MAX_TICKS) + { + _winner = _capturing; + UtilTextTop.display(C.cGoldB + "Capturing Point: " + C.cWhite + "100%", _capturing); + stop(); + return; + } + else if (Recharge.Instance.use(_capturing, "Capture Point Alert", 30000, false, false)) + { + announceMessage(F.name(_capturing.getName()) + " is still capturing the point!"); + } + double percentage = ((double)_ticks) / ((double)MAX_TICKS); + percentage *= 100; + UtilTextTop.display(C.cGoldB + "Capturing Point: " + C.cWhite + (int)Math.floor(percentage) + "%", _capturing); + } + } } + @SuppressWarnings("deprecation") @Override public void customCleanup(boolean onDisable) { - + Block reset = getCenterLocation().getBlock().getRelative(BlockFace.DOWN); + reset.setTypeIdAndData(_resetData.getLeft().getId(), _resetData.getRight(), false); } @Override protected void customStop() { + if (_winner != null) + { + announceMessage(F.name(_winner.getName()) + " has captured the point!"); + for (int i = 0; i < 6; i++) + { + ClansManager.getInstance().getLootManager().dropCapturePoint(_winner.getLocation()); + } + } + else + { + announceMessage("Nobody was able to capture the point this time!"); + } + _winner = null; + _capturing = null; + _resetData = null; + } + + private class PointBoundary + { + private final double _minX, _maxX, _minZ, _maxZ, _minY, _maxY; + public PointBoundary(double minX, double maxX, double minZ, double maxZ, double minY, double maxY) + { + _minX = minX; + _maxX = maxX; + _minZ = minZ; + _maxZ = maxZ; + _minY = minY; + _maxY = maxY; + } + + public boolean isInBoundary(Player player) + { + double x = player.getLocation().getX(); + double z = player.getLocation().getZ(); + double y = player.getLocation().getY(); + + return (x <= _maxX && x >= _minX) && (z <= _maxZ && z >= _minZ) && (y <= _maxY && y >= _minY); + } } } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/capturepoint/CapturePointLocation.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/capturepoint/CapturePointLocation.java index cd205cb7f..7236e034a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/capturepoint/CapturePointLocation.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/capturepoint/CapturePointLocation.java @@ -7,6 +7,11 @@ import org.bukkit.World; public enum CapturePointLocation { + ONE(1075, 66, -456), + TWO(636, 65, 1102), + THREE(-1140, 57, -163), + FOUR(-636, 66, -948), + FIVE(-75, 51, -1004), ; private final double _x, _y, _z; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidAltar.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidAltar.java index 0bb876d79..62ec129a0 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidAltar.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidAltar.java @@ -70,7 +70,7 @@ public class RaidAltar } if (data != null) { - if (item.getData().getData() != data.byteValue()) + if (item.getData().getData() != data) { rejected = true; } @@ -84,7 +84,7 @@ public class RaidAltar if (amount != null) { - return count >= amount.intValue(); + return count >= amount; } else { @@ -143,7 +143,7 @@ public class RaidAltar } if (data != null) { - if (item.getData().getData() != data.byteValue()) + if (item.getData().getData() != data) { rejected = true; } @@ -154,7 +154,7 @@ public class RaidAltar if (item.getAmount() > (amount - removed)) { removed += (amount - removed); - item.setAmount(item.getAmount() - (amount - removed)); + item.setAmount(item.getAmount() - removed); } else { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidWorldEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidWorldEvent.java index 6903d35ab..a43d05e12 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidWorldEvent.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidWorldEvent.java @@ -263,10 +263,7 @@ public abstract class RaidWorldEvent extends WorldEvent { return; } - if (_players.remove(event.getEntity())) - { - Manager.runSyncLater(() -> event.getEntity().spigot().respawn(), 10); - } + _players.remove(event.getEntity()); } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @@ -313,4 +310,10 @@ public abstract class RaidWorldEvent extends WorldEvent return ((RaidWorldEvent)object).getId() == getId(); } + + @Override + public int hashCode() + { + return Integer.hashCode(getId()); + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/WorldData.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/WorldData.java index a647f268c..536bfcaba 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/WorldData.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/WorldData.java @@ -367,7 +367,7 @@ public class WorldData try { - return new Location(World, Integer.valueOf(coords[0])+0.5, Integer.valueOf(coords[1]), Integer.valueOf(coords[2])+0.5); + return new Location(World, Integer.valueOf(coords[0]) +0.5, Integer.valueOf(coords[1]), Integer.valueOf(coords[2]) + 0.5); } catch (Exception e) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/five/ChallengeFive.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/five/ChallengeFive.java index b77f231be..e5ee9975b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/five/ChallengeFive.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/five/ChallengeFive.java @@ -19,6 +19,7 @@ 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.game.clans.clans.ClansManager; import mineplex.game.clans.clans.worldevent.api.EventCreature; import mineplex.game.clans.clans.worldevent.api.EventCreatureDeathEvent; import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; @@ -98,8 +99,11 @@ public class ChallengeFive extends RaidChallenge UtilPlayer.message(player, F.main(getRaid().getName() + " Raid", "You made it!")); player.teleport(_altar); }); + ClansManager.getInstance().getBlockRestore().restore(getRaid().getWorldData().getCustomLocs("GATE_THREE").get(0).getBlock().getRelative(BlockFace.DOWN)); getRaid().getWorldData().getCustomLocs("GATE_THREE").get(0).getBlock().getRelative(BlockFace.DOWN).setType(Material.OBSIDIAN); Block gate = getRaid().getWorldData().getCustomLocs("GATE_FOUR").get(0).getBlock(); + ClansManager.getInstance().getBlockRestore().restore(gate); + ClansManager.getInstance().getBlockRestore().restore(gate.getRelative(BlockFace.DOWN)); gate.getRelative(BlockFace.DOWN).setType(Material.GLOWSTONE); gate.setType(Material.SKULL); gate.setData((byte)1); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/five/IronGate.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/five/IronGate.java index b0a0964d5..5b42168bf 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/five/IronGate.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/five/IronGate.java @@ -6,6 +6,7 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; +import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.worldevent.api.EventCreature; public class IronGate @@ -39,6 +40,7 @@ public class IronGate for (int z = minZ; z <= maxZ; z++) { Block block = _challenge.getRaid().getWorldData().World.getBlockAt(x, y, z); + ClansManager.getInstance().getBlockRestore().restore(block); if (block.getType() == Material.IRON_FENCE) { block.setType(Material.AIR); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/four/ChallengeFour.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/four/ChallengeFour.java index bfb9cb879..8a0459faa 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/four/ChallengeFour.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/four/ChallengeFour.java @@ -18,6 +18,7 @@ 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.game.clans.clans.ClansManager; import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; @@ -69,8 +70,11 @@ public class ChallengeFour extends RaidChallenge UtilPlayer.message(player, F.main(getRaid().getName() + " Raid", "Excellent jumping!")); player.teleport(_altar); }); + ClansManager.getInstance().getBlockRestore().restore(getRaid().getWorldData().getCustomLocs("GATE_TWO").get(0).getBlock().getRelative(BlockFace.DOWN)); getRaid().getWorldData().getCustomLocs("GATE_TWO").get(0).getBlock().getRelative(BlockFace.DOWN).setType(Material.OBSIDIAN); Block gate = getRaid().getWorldData().getCustomLocs("GATE_THREE").get(0).getBlock(); + ClansManager.getInstance().getBlockRestore().restore(gate); + ClansManager.getInstance().getBlockRestore().restore(gate.getRelative(BlockFace.DOWN)); gate.getRelative(BlockFace.DOWN).setType(Material.GLOWSTONE); gate.setType(Material.SKULL); gate.setData((byte)1); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/four/FakeBlock.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/four/FakeBlock.java index 55793d72d..a14a2abce 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/four/FakeBlock.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/four/FakeBlock.java @@ -5,6 +5,8 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; +import mineplex.game.clans.clans.ClansManager; + public class FakeBlock { private ChallengeFour _challenge; @@ -24,6 +26,7 @@ public class FakeBlock { if (player.getLocation().getBlock().getRelative(BlockFace.DOWN).equals(_block)) { + ClansManager.getInstance().getBlockRestore().restore(_block); _block.setType(Material.AIR); aired = true; break; @@ -32,6 +35,7 @@ public class FakeBlock if (!aired) { + ClansManager.getInstance().getBlockRestore().restore(_block); _block.setType(Material.NETHER_BRICK); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/one/ChallengeOne.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/one/ChallengeOne.java index 57c1fa0af..0447604d9 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/one/ChallengeOne.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/one/ChallengeOne.java @@ -12,6 +12,7 @@ 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.game.clans.clans.ClansManager; import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; @@ -45,6 +46,7 @@ public class ChallengeOne extends RaidChallenge for (int z = minZ; z <= maxZ; z++) { Block block = getRaid().getWorldData().World.getBlockAt(x, y, z); + ClansManager.getInstance().getBlockRestore().restore(block); block.setType(Material.NETHER_BRICK); } } @@ -56,7 +58,9 @@ public class ChallengeOne extends RaidChallenge for (Location loc : getRaid().getWorldData().getCustomLocs("C_ONE_SBT")) { Block b = loc.getBlock(); + ClansManager.getInstance().getBlockRestore().restore(b); b.setType(Material.SMOOTH_BRICK); + ClansManager.getInstance().getBlockRestore().restore(b.getRelative(BlockFace.UP)); b.getRelative(BlockFace.UP).setType(Material.SMOOTH_BRICK); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/seven/ChallengeSeven.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/seven/ChallengeSeven.java index 193a2fb37..5b58dcd6d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/seven/ChallengeSeven.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/seven/ChallengeSeven.java @@ -94,17 +94,21 @@ public class ChallengeSeven extends RaidChallenge int emeralds = UtilMath.rRange((int)Math.ceil(45 / anim.size()), (int)Math.ceil(80 / anim.size())); for (Location drop : anim) { - ClansManager.getInstance().getLootManager().dropRare(drop); + ClansManager.getInstance().getLootManager().dropRaid(drop); drop.getWorld().dropItem(drop, new ItemStack(Material.EMERALD, emeralds)); } - RareItemFactory mainFactory = RareItemFactory.begin(ItemType.LEGENDARY).setLegendary(DemonicScythe.class); - if (Math.random() < 0.1) + if (Math.random() <= 0.03) { - mainFactory.setSuperPrefix(FlamingAttribute.class); - mainFactory.setPrefix(SharpAttribute.class); - mainFactory.setSuffix(ConqueringAttribute.class); + RareItemFactory mainFactory = RareItemFactory.begin(ItemType.LEGENDARY).setLegendary(DemonicScythe.class); + if (Math.random() < 0.1) + { + mainFactory.setSuperPrefix(FlamingAttribute.class); + mainFactory.setPrefix(SharpAttribute.class); + mainFactory.setSuffix(ConqueringAttribute.class); + } + _altar.getWorld().dropItem(_altar.clone().add(0, 2, 0), mainFactory.fabricate()); } - _altar.getWorld().dropItem(_altar.clone().add(0, 2, 0), mainFactory.fabricate()); + ClansManager.getInstance().getBlockRestore().restore(getRaid().getWorldData().getCustomLocs("GATE_FIVE").get(0).getBlock().getRelative(BlockFace.DOWN)); getRaid().getWorldData().getCustomLocs("GATE_FIVE").get(0).getBlock().getRelative(BlockFace.DOWN).setType(Material.OBSIDIAN); getRaid().setForceEnd(System.currentTimeMillis() + UtilTime.convert(2, TimeUnit.MINUTES, TimeUnit.MILLISECONDS)); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/six/ChallengeSix.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/six/ChallengeSix.java index 46d3526b3..2face28db 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/six/ChallengeSix.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/six/ChallengeSix.java @@ -11,6 +11,7 @@ import org.bukkit.inventory.ItemStack; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; +import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.worldevent.api.EventCreatureDeathEvent; import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; @@ -53,8 +54,11 @@ public class ChallengeSix extends RaidChallenge UtilPlayer.message(player, F.main(getRaid().getName() + " Raid", "Your final battle awaits!")); player.teleport(_altar); }); + ClansManager.getInstance().getBlockRestore().restore(getRaid().getWorldData().getCustomLocs("GATE_FOUR").get(0).getBlock().getRelative(BlockFace.DOWN)); getRaid().getWorldData().getCustomLocs("GATE_FOUR").get(0).getBlock().getRelative(BlockFace.DOWN).setType(Material.OBSIDIAN); Block gate = getRaid().getWorldData().getCustomLocs("GATE_FIVE").get(0).getBlock(); + ClansManager.getInstance().getBlockRestore().restore(gate); + ClansManager.getInstance().getBlockRestore().restore(gate.getRelative(BlockFace.DOWN)); gate.getRelative(BlockFace.DOWN).setType(Material.GLOWSTONE); gate.setType(Material.SKULL); gate.setData((byte)1); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/three/ChallengeThree.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/three/ChallengeThree.java index 260e59321..a0f6d289c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/three/ChallengeThree.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/three/ChallengeThree.java @@ -17,6 +17,7 @@ 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.game.clans.clans.ClansManager; import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; import mineplex.game.clans.clans.worldevent.raid.wither.creature.archer.DecayingArcher; @@ -55,6 +56,7 @@ public class ChallengeThree extends RaidChallenge { for (Location loc : getRaid().getWorldData().getCustomLocs("C_THREE_TORCH")) { + ClansManager.getInstance().getBlockRestore().restore(loc.getBlock()); loc.getBlock().setType(Material.NETHERRACK); _torches.add(new ChallengeTorch(this, loc.getBlock())); } @@ -70,8 +72,11 @@ public class ChallengeThree extends RaidChallenge UtilPlayer.message(player, F.main(getRaid().getName() + " Raid", "The Torches are lit!")); player.teleport(_altar); }); + ClansManager.getInstance().getBlockRestore().restore(getRaid().getWorldData().getCustomLocs("GATE_ONE").get(0).getBlock().getRelative(BlockFace.DOWN)); getRaid().getWorldData().getCustomLocs("GATE_ONE").get(0).getBlock().getRelative(BlockFace.DOWN).setType(Material.OBSIDIAN); Block gate = getRaid().getWorldData().getCustomLocs("GATE_TWO").get(0).getBlock(); + ClansManager.getInstance().getBlockRestore().restore(gate); + ClansManager.getInstance().getBlockRestore().restore(gate.getRelative(BlockFace.DOWN)); gate.getRelative(BlockFace.DOWN).setType(Material.GLOWSTONE); gate.setType(Material.SKULL); gate.setData((byte)1); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/three/ChallengeTorch.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/three/ChallengeTorch.java index 90b6e0a4e..5426cf44b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/three/ChallengeTorch.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/three/ChallengeTorch.java @@ -4,6 +4,8 @@ import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import mineplex.game.clans.clans.ClansManager; + public class ChallengeTorch { private ChallengeThree _challenge; @@ -23,6 +25,7 @@ public class ChallengeTorch { _challenge.LitTorches++; _extinguish = System.currentTimeMillis() + 3000; + ClansManager.getInstance().getBlockRestore().restore(_block.getRelative(BlockFace.UP)); _block.getRelative(BlockFace.UP).setType(Material.FIRE); } } @@ -35,6 +38,7 @@ public class ChallengeTorch { _extinguish = -1; _challenge.LitTorches--; + ClansManager.getInstance().getBlockRestore().restore(_block.getRelative(BlockFace.UP)); _block.getRelative(BlockFace.UP).setType(Material.AIR); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/two/ChallengeTwo.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/two/ChallengeTwo.java index a18665263..3c205ff53 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/two/ChallengeTwo.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/two/ChallengeTwo.java @@ -9,6 +9,7 @@ import org.bukkit.event.EventHandler; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; +import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.worldevent.api.EventCreatureDeathEvent; import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; @@ -31,7 +32,9 @@ public class ChallengeTwo extends RaidChallenge for (Location loc : getRaid().getWorldData().getCustomLocs("C_ONE_SBT")) { Block b = loc.getBlock(); + ClansManager.getInstance().getBlockRestore().restore(b); b.setType(Material.AIR); + ClansManager.getInstance().getBlockRestore().restore(b.getRelative(BlockFace.UP)); b.getRelative(BlockFace.UP).setType(Material.AIR); getRaid().registerCreature(new UndeadKnight(this, loc)); } @@ -53,6 +56,8 @@ public class ChallengeTwo extends RaidChallenge { getRaid().getPlayers().forEach(player -> UtilPlayer.message(player, F.main(getRaid().getName() + " Raid", "The Undead Mage has fallen!"))); Block gate = getRaid().getWorldData().getCustomLocs("GATE_ONE").get(0).getBlock(); + ClansManager.getInstance().getBlockRestore().restore(gate); + ClansManager.getInstance().getBlockRestore().restore(gate.getRelative(BlockFace.DOWN)); gate.getRelative(BlockFace.DOWN).setType(Material.GLOWSTONE); gate.setType(Material.SKULL); gate.setData((byte)1); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/CharlesWitherton.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/CharlesWitherton.java index b0c942600..225ece46c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/CharlesWitherton.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/CharlesWitherton.java @@ -15,6 +15,8 @@ import net.minecraft.server.v1_8_R3.PathfinderGoalRandomStroll; import org.bukkit.Location; import org.bukkit.craftbukkit.libs.com.google.common.base.Predicate; +import org.bukkit.Material; +import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftWither; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -26,10 +28,11 @@ import org.bukkit.event.HandlerList; import org.bukkit.event.entity.EntityChangeBlockEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.ProjectileLaunchEvent; - +import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.worldevent.api.BossPassive; import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; import mineplex.game.clans.clans.worldevent.raid.RaidCreature; @@ -130,6 +133,21 @@ public class CharlesWitherton extends RaidCreature return; } + for (Block b : UtilBlock.getBlocksInRadius(getEntity().getLocation(), 4)) + { + if (b.getType() == Material.ICE) + { + if (ClansManager.getInstance().getBlockRestore().contains(b)) + { + ClansManager.getInstance().getBlockRestore().restore(b); + } + else + { + b.setType(Material.AIR); + } + } + } + _passive.tick(); _abilities.forEach(BossPassive::tick); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/MiniCharles.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/MiniCharles.java index a59db2880..8326fb4a6 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/MiniCharles.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/MiniCharles.java @@ -12,6 +12,8 @@ import net.minecraft.server.v1_8_R3.PathfinderGoalRandomStroll; import org.bukkit.Location; import org.bukkit.craftbukkit.libs.com.google.common.base.Predicate; +import org.bukkit.Material; +import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftWither; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -23,10 +25,11 @@ import org.bukkit.event.HandlerList; import org.bukkit.event.entity.EntityChangeBlockEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.ProjectileLaunchEvent; - +import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; import mineplex.game.clans.clans.worldevent.raid.RaidCreature; import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; @@ -104,6 +107,21 @@ public class MiniCharles extends RaidCreature return; } + for (Block b : UtilBlock.getBlocksInRadius(getEntity().getLocation(), 4)) + { + if (b.getType() == Material.ICE) + { + if (ClansManager.getInstance().getBlockRestore().contains(b)) + { + ClansManager.getInstance().getBlockRestore().restore(b); + } + else + { + b.setType(Material.AIR); + } + } + } + _passive.tick(); _liveTicks++; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/CampSize.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/CampSize.java deleted file mode 100644 index e6a8d6ca1..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/CampSize.java +++ /dev/null @@ -1,84 +0,0 @@ -package mineplex.game.clans.clans.worldevent.undead; - -import mineplex.core.common.util.UtilMath; - -public enum CampSize -{ - SMALL("Undead Outpost", 15, 0, 1), - - MEDIUM("Undead Village", 20, 10, 2), - - LARGE("Undead City", 30, 20, 3); - - // Base Values - private static final int HUT_MIN = 4; - private static final int HUT_MAX = 8; - private static final int TOWER_MIN = 4; - private static final int TOWER_MAX = 8; - private static final int POLE_MIN = 10; - private static final int POLE_MAX = 20; - private static final int UNDEAD_MIN = 10; - private static final int UNDEAD_MAX = 20; - - private String _name; - private int _areaNeeded; - private int _playersNeeded; - private int _modValue; - - CampSize(String name, int areaNeeded, int playersNeeded, int modValue) - { - _name = name; - _areaNeeded = areaNeeded; - _playersNeeded = playersNeeded; - _modValue = modValue; - } - - public String getName() - { - return _name; - } - - public int getAreaNeeded() - { - return _areaNeeded; - } - - public int getPlayersNeeded() - { - return _playersNeeded; - } - - public int generateHutCount() - { - return _modValue * UtilMath.rRange(HUT_MIN, HUT_MAX); - } - - public int generateTowerCount() - { - return _modValue * UtilMath.rRange(TOWER_MIN, TOWER_MAX); - } - - public int generatePoleCount() - { - return _modValue * UtilMath.rRange(POLE_MIN, POLE_MAX); - } - - public int generateUndeadCount() - { - return _modValue * UtilMath.rRange(UNDEAD_MIN, UNDEAD_MAX); - } - - public static CampSize getCampSize(int playerCount) - { - CampSize campSize = CampSize.SMALL; - - for (CampSize c : values()) - { - if (playerCount >= c.getPlayersNeeded() && (campSize == null || c.getPlayersNeeded() > campSize.getPlayersNeeded())) - campSize = c; - } - - return campSize; - } - -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/CampType.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/CampType.java deleted file mode 100644 index 3d7adeb54..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/CampType.java +++ /dev/null @@ -1,45 +0,0 @@ -package mineplex.game.clans.clans.worldevent.undead; - -import org.bukkit.Material; -import org.bukkit.material.MaterialData; - -public enum CampType -{ - OAK(new MaterialData(Material.LOG, (byte) 0), new MaterialData(Material.WOOD, (byte) 0), Material.ENDER_CHEST, Material.FURNACE), - SPRUCE(new MaterialData(Material.LOG, (byte) 1), new MaterialData(Material.WOOD, (byte) 1), Material.ENDER_CHEST, Material.FURNACE), - BIRCH(new MaterialData(Material.LOG, (byte) 2), new MaterialData(Material.WOOD, (byte) 2), Material.ENDER_CHEST, Material.FURNACE), - JUNGLE(new MaterialData(Material.LOG, (byte) 3), new MaterialData(Material.WOOD, (byte) 3), Material.ENDER_CHEST, Material.FURNACE); - - private MaterialData _log; - private MaterialData _wood; - private Material _chest; - private Material _furance; - - CampType(MaterialData log, MaterialData wood, Material chest, Material furnace) - { - _log = log; - _wood = wood; - _chest = chest; - _furance = furnace; - } - - public MaterialData getLog() - { - return _log; - } - - public MaterialData getWood() - { - return _wood; - } - - public Material getFurnace() - { - return _furance; - } - - public Material getChest() - { - return _chest; - } -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/CityChest.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/CityChest.java new file mode 100644 index 000000000..de7068ca5 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/CityChest.java @@ -0,0 +1,50 @@ +package mineplex.game.clans.clans.worldevent.undead; + +import org.bukkit.Effect; +import org.bukkit.Material; +import org.bukkit.block.Block; + +import mineplex.game.clans.clans.ClansManager; + +public class CityChest +{ + private final boolean _enabled; + private final Block _block; + private boolean _opened; + + public CityChest(Block block, boolean enabled) + { + _block = block; + _enabled = enabled; + _opened = false; + + if (!enabled) + { + _block.setType(Material.AIR); + } + } + + public boolean isEnabled() + { + return _enabled; + } + + public boolean isOpen() + { + return _opened; + } + + @SuppressWarnings("deprecation") + public void open() + { + _block.setType(Material.AIR); + _block.getWorld().playEffect(_block.getLocation(), Effect.STEP_SOUND, Material.ENDER_CHEST.getId()); + ClansManager.getInstance().getLootManager().dropUndeadCity(_block.getLocation()); + _opened = true; + } + + public void revert() + { + _block.setType(Material.ENDER_CHEST); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/UndeadCamp.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/UndeadCamp.java deleted file mode 100644 index 6ccc12bfa..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/UndeadCamp.java +++ /dev/null @@ -1,520 +0,0 @@ -package mineplex.game.clans.clans.worldevent.undead; - -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; - -import mineplex.core.common.util.*; -import mineplex.game.clans.clans.ClansManager; -import org.bukkit.Effect; -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.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.player.PlayerInteractEvent; - -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.worldevent.WorldEventManager; -import mineplex.game.clans.clans.worldevent.undead.creature.UndeadArcher; -import mineplex.game.clans.clans.worldevent.undead.creature.UndeadWarrior; -import mineplex.minecraft.game.classcombat.Skill.SkillFactory; -import mineplex.minecraft.game.core.boss.EventState; -import mineplex.minecraft.game.core.boss.WorldEvent; - -public class UndeadCamp extends WorldEvent -{ - private int _hutLeft = 0; - private int _poleLeft = 0; - private int _towerLeft = 0; - private int _undeadCount = 0; - - private final CampType _campType; - private final CampSize _campSize; - private Set _containers; - private WorldEventManager _eventManager; - - private SkillFactory _skillFactory; - - public UndeadCamp(WorldEventManager eventManager, Location centerLocation, SkillFactory skillFactory) - { - super(eventManager.getClans().getDisguiseManager(), eventManager.getClans().getProjectile(), eventManager.getDamage(), eventManager.getBlockRestore(), eventManager.getClans().getCondition(), "Undead Camp", centerLocation); - - _eventManager = eventManager; - _campSize = CampSize.getCampSize(UtilServer.getPlayers().length); - _campType = CampType.values()[getRandom().nextInt(CampType.values().length)]; - _containers = new HashSet(); - - _hutLeft = _campSize.generateHutCount(); - _poleLeft = _campSize.generatePoleCount(); - _towerLeft = _campSize.generateTowerCount(); - _undeadCount = _campSize.generateUndeadCount(); - - setName(_campSize.getName()); - - _skillFactory = skillFactory; - } - - public WorldEventManager getEventManager() - { - return _eventManager; - } - - @Override - protected void customStart() - { - - } - - @Override - protected void customTick() - { - if (getState() == EventState.PREPARE) - { - if (_hutLeft > 0) - createHut(); - else if (_towerLeft > 0) - createTower(); - else if (_poleLeft > 0) - createLamp(); - else if (getCreatures().size() < _undeadCount) - createUndead(); - else - { - System.out.println("Constructed " + getName() + " at " + UtilWorld.locToStrClean(getCenterLocation()) + "."); - announceStart(); - setState(EventState.LIVE); - } - } - } - - private void createHut() - { - int hutX = UtilMath.r(4) + 2; - int hutZ = UtilMath.r(4) + 2; - int hutY = UtilMath.r(2) + 3; - - int buffer = Math.max(hutX, hutZ) / 2 + 1; - - Location loc = getEventManager().getTerrainFinder().locateSpace(getCenterLocation(), _campSize.getAreaNeeded() - buffer, hutX, hutY + 2, hutZ, true, false, getBlocks().getChangedBlocks()); - - if (loc == null) return; - - boolean xWall = (Math.random() > 0.5); - boolean zWall = (Math.random() > 0.5); - - // Base - for (int x = -hutX; x <= hutX; x++) - for (int z = -hutZ; z <= hutZ; z++) - { - Block block = loc.getBlock().getRelative(x, -1, z); - - // Space - for (int y = 0; y <= hutY; y++) - setBlock(loc.getBlock().getRelative(x, y, z), 0, (byte) 0); - - // Walls - if (!xWall && x == -hutX || xWall && x == hutX || !zWall && z == -hutZ || zWall && z == hutZ) for (int y = 0; y <= hutY; y++) - setBlock(loc.getBlock().getRelative(x, y, z), _campType.getWood().getItemTypeId(), _campType.getWood().getData()); - - // Corners - if (Math.abs(x) == hutX && Math.abs(z) == hutZ) - { - setBlock(block, _campType.getLog().getItemTypeId(), _campType.getLog().getData()); - for (int y = 0; y <= hutY; y++) - setBlock(loc.getBlock().getRelative(x, y, z), _campType.getLog().getItemTypeId(), _campType.getLog().getData()); - - // Support Stands - boolean support = true; - Block below = block; - while (support) - { - below = below.getRelative(BlockFace.DOWN); - - if (!UtilBlock.fullSolid(below) || below.isLiquid()) - setBlock(below, _campType.getLog().getItemTypeId(), _campType.getLog().getData()); - - else - support = false; - } - } - - // Floor & Roof - else - { - setBlock(block, _campType.getWood().getItemTypeId(), _campType.getWood().getData()); - setBlock(loc.getBlock().getRelative(x, hutY - 1, z), 126, (byte) 8); - } - - // Insides - if (Math.abs(x) != hutX && Math.abs(z) != hutZ) - { - if (Math.random() > 0.90) - { - addChest(block.getRelative(BlockFace.UP)); - } - else if (Math.random() > 0.95) - { - addFurnace(block.getRelative(BlockFace.UP)); - } - else if (Math.random() > 0.95) - { - registerCreature(new UndeadWarrior(this, block.getRelative(BlockFace.UP).getLocation().add(0.5, 0.5, 0.5))); - } - } - } - - _hutLeft--; - } - - private void addChest(Block chest) - { - Block side; - int adj = 0; - - side = chest.getRelative(BlockFace.NORTH); - if (side.getType() == Material.CHEST) - { - adj++; - if (side.getRelative(BlockFace.NORTH).getType() == Material.CHEST) return; - if (side.getRelative(BlockFace.SOUTH).getType() == Material.CHEST) return; - if (side.getRelative(BlockFace.EAST).getType() == Material.CHEST) return; - if (side.getRelative(BlockFace.WEST).getType() == Material.CHEST) return; - } - - side = chest.getRelative(BlockFace.SOUTH); - if (side.getType() == Material.CHEST) - { - adj++; - if (side.getRelative(BlockFace.NORTH).getType() == Material.CHEST) return; - if (side.getRelative(BlockFace.SOUTH).getType() == Material.CHEST) return; - if (side.getRelative(BlockFace.EAST).getType() == Material.CHEST) return; - if (side.getRelative(BlockFace.WEST).getType() == Material.CHEST) return; - } - - side = chest.getRelative(BlockFace.EAST); - if (side.getType() == Material.CHEST) - { - adj++; - if (side.getRelative(BlockFace.NORTH).getType() == Material.CHEST) return; - if (side.getRelative(BlockFace.SOUTH).getType() == Material.CHEST) return; - if (side.getRelative(BlockFace.EAST).getType() == Material.CHEST) return; - if (side.getRelative(BlockFace.WEST).getType() == Material.CHEST) return; - } - - side = chest.getRelative(BlockFace.WEST); - if (side.getType() == Material.CHEST) - { - adj++; - if (side.getRelative(BlockFace.NORTH).getType() == Material.CHEST) return; - if (side.getRelative(BlockFace.SOUTH).getType() == Material.CHEST) return; - if (side.getRelative(BlockFace.EAST).getType() == Material.CHEST) return; - if (side.getRelative(BlockFace.WEST).getType() == Material.CHEST) return; - } - - if (adj > 1) return; - - setBlock(chest, 130, (byte) (UtilMath.r(4) + 2)); - _containers.add(chest); - } - - private void addFurnace(Block furnace) - { - Block side; - int adj = 0; - - side = furnace.getRelative(BlockFace.NORTH); - if (side.getType() == Material.FURNACE) - { - adj++; - if (side.getRelative(BlockFace.NORTH).getType() == Material.FURNACE) return; - if (side.getRelative(BlockFace.SOUTH).getType() == Material.FURNACE) return; - if (side.getRelative(BlockFace.EAST).getType() == Material.FURNACE) return; - if (side.getRelative(BlockFace.WEST).getType() == Material.FURNACE) return; - } - - side = furnace.getRelative(BlockFace.SOUTH); - if (side.getType() == Material.FURNACE) - { - adj++; - if (side.getRelative(BlockFace.NORTH).getType() == Material.FURNACE) return; - if (side.getRelative(BlockFace.SOUTH).getType() == Material.FURNACE) return; - if (side.getRelative(BlockFace.EAST).getType() == Material.FURNACE) return; - if (side.getRelative(BlockFace.WEST).getType() == Material.FURNACE) return; - } - - side = furnace.getRelative(BlockFace.EAST); - if (side.getType() == Material.FURNACE) - { - adj++; - if (side.getRelative(BlockFace.NORTH).getType() == Material.FURNACE) return; - if (side.getRelative(BlockFace.SOUTH).getType() == Material.FURNACE) return; - if (side.getRelative(BlockFace.EAST).getType() == Material.FURNACE) return; - if (side.getRelative(BlockFace.WEST).getType() == Material.FURNACE) return; - } - - side = furnace.getRelative(BlockFace.WEST); - if (side.getType() == Material.FURNACE) - { - adj++; - if (side.getRelative(BlockFace.NORTH).getType() == Material.FURNACE) return; - if (side.getRelative(BlockFace.SOUTH).getType() == Material.FURNACE) return; - if (side.getRelative(BlockFace.EAST).getType() == Material.FURNACE) return; - if (side.getRelative(BlockFace.WEST).getType() == Material.FURNACE) return; - } - - if (adj > 1) return; - - setBlock(furnace, 61, (byte) 0); - _containers.add(furnace); - } - - private void createUndead() - { - Location loc = getEventManager().getTerrainFinder().locateSpace(getCenterLocation(), _campSize.getAreaNeeded(), 0, 3, 0, false, true, getBlocks().getChangedBlocks()); - - if (loc == null) return; - - registerCreature(new UndeadWarrior(this, loc.add(0.5, 0.5, 0.5))); - - // _poleLeft--; - // ResetIdleTicks(); - } - - private void createTower() - { - int towerX = UtilMath.r(3) + 1; - int towerZ = UtilMath.r(3) + 1; - int towerY = UtilMath.r(4) + 3; - - int buffer = Math.max(towerX, towerZ) / 2 + 1; - - Location loc = getEventManager().getTerrainFinder().locateSpace(getCenterLocation(), _campSize.getAreaNeeded() - buffer, towerX, towerY + 2, towerZ, false, true, getBlocks().getChangedBlocks()); - - if (loc == null) return; - - int ladder = UtilMath.r(4); - - // Base - for (int x = -towerX; x <= towerX; x++) - for (int z = -towerZ; z <= towerZ; z++) - { - Block block = loc.getBlock().getRelative(x, towerY, z); - - // Space - for (int y = 0; y <= towerY; y++) - setBlock(loc.getBlock().getRelative(x, y, z), 0, (byte) 0); - - // Corner - if (Math.abs(x) == towerX && Math.abs(z) == towerZ) - { - setBlock(block, _campType.getWood().getItemTypeId(), _campType.getWood().getData()); - setBlock(block.getRelative(BlockFace.UP), 85, (byte) 0); - - // Support Stands - boolean support = true; - Block below = block; - while (support) - { - below = below.getRelative(BlockFace.DOWN); - - if (!UtilBlock.fullSolid(below) && !below.isLiquid()) - setBlock(below, 85, (byte) 0); - - else if (below.isLiquid()) - setBlock(below, _campType.getLog().getItemTypeId(), _campType.getLog().getData()); - - else - support = false; - } - - // Ladder - if (ladder == 0 && x == -towerX && z == -towerZ || ladder == 1 && x == -towerX && z == towerZ || ladder == 2 && x == towerX && z == -towerZ || ladder == 3 && x == towerX && z == towerZ) - { - boolean laddering = true; - below = block; - while (laddering) - { - below = below.getRelative(BlockFace.DOWN); - - if (!UtilBlock.fullSolid(below)) - { - setBlock(below, _campType.getWood().getItemTypeId(), _campType.getWood().getData()); - - if (ladder == 0) - setBlock(below.getRelative(-1, 0, 0), 65, (byte) 4); - else if (ladder == 1) - setBlock(below.getRelative(-1, 0, 0), 65, (byte) 4); - else if (ladder == 2) - setBlock(below.getRelative(1, 0, 0), 65, (byte) 5); - else if (ladder == 3) setBlock(below.getRelative(1, 0, 0), 65, (byte) 5); - } - - else - laddering = false; - } - } - } - - // Platform - else - setBlock(block, 126, (byte) 8); - - // Features - if (Math.random() > 0.95) - addChest(block.getRelative(BlockFace.UP)); - - else if (Math.random() > 0.95) registerCreature(new UndeadArcher(this, block.getRelative(BlockFace.UP).getLocation().add(0.5, 0.5, 0.5), _skillFactory)); - } - - _towerLeft--; - } - - private void createLamp() - { - Location loc = getEventManager().getTerrainFinder().locateSpace(getCenterLocation(), _campSize.getAreaNeeded(), 0, 4, 0, false, true, getBlocks().getChangedBlocks()); - - if (loc == null) return; - - setBlock(loc.getBlock(), 85, (byte) 0); - setBlock(loc.getBlock().getRelative(BlockFace.UP), 85, (byte) 0); - setBlock(loc.getBlock().getRelative(BlockFace.UP).getRelative(BlockFace.UP), 50, (byte) 0); - - _poleLeft--; - } - - private void openChest(Block block) - { - _containers.remove(block); - - // Effect - block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.ENDER_CHEST.getId()); - - setBlock(block, Material.AIR); - - // Loot - int count = 1 + UtilMath.r(3); - for (int i = 0; i < count; i++) - { - getEventManager().getLoot().dropCommon(block.getLocation().add(0.5, 0.5, 0.5)); - } - } - - private void openFurnace(Block block) - { - _containers.remove(block); - - block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.FURNACE.getId()); - - setBlock(block, Material.AIR); - - double random = Math.random(); - - if (random < .25) - { - for (int i = 0; i < UtilMath.r(25); i++) - { - block.getWorld().dropItemNaturally(block.getLocation().add(0.5, 0.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.IRON_INGOT)); - } - } - else if (random < .5) - { - for (int i = 0; i < UtilMath.r(25); i++) - { - block.getWorld().dropItemNaturally(block.getLocation().add(0.5, 0.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.GOLD_INGOT)); - } - } - else if (random < .75) - { - for (int i = 0; i < UtilMath.r(25); i++) - { - block.getWorld().dropItemNaturally(block.getLocation().add(0.5, 0.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.DIAMOND)); - } - } - else if (random < 1) - { - for (int i = 0; i < UtilMath.r(25); i++) - { - block.getWorld().dropItemNaturally(block.getLocation().add(0.5, 0.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.LEATHER)); - } - } - } - - @EventHandler - public void checkEnd(UpdateEvent event) - { - if (event.getType() != UpdateType.SEC) return; - - // Remove any broken chests/furnaces - Iterator it = _containers.iterator(); - while (it.hasNext()) - { - Block block = it.next(); - - if (block.getType() != _campType.getChest() && block.getType() != _campType.getFurnace()) - { - it.remove(); - } - } - - if (_containers.size() == 0) - { - triggerEnd(); - } - } - - @EventHandler(priority = EventPriority.HIGHEST) - public void onChestOpen(PlayerInteractEvent event) - { - if(ClansManager.getInstance().getObserverManager().isObserver(event.getPlayer())) return;; - Block block = event.getClickedBlock(); - if (_containers.contains(block)) - { - event.setCancelled(true); - - if (block.getType() == Material.ENDER_CHEST) - { - if (!Recharge.Instance.use(event.getPlayer(), "Loot Chest", 60000, true, false)) - { - return; - } - - openChest(block); - - updateLastActive(); - - UtilPlayer.message(event.getPlayer(), F.main(getName(), "You smash open an " + F.elem("Undead Chest") + "!")); - } - else if (block.getType() == Material.FURNACE) - { - if (!Recharge.Instance.use(event.getPlayer(), "Loot Furnace", 60000, true, false)) - { - return; - } - - openFurnace(block); - - updateLastActive(); - - UtilPlayer.message(event.getPlayer(), F.main(getName(), "You smash open an " + F.elem("Undead Furnace") + "!")); - } - } - } - - - @Override - public void announceStart() - { - for(Player player : UtilServer.getPlayers()) { - if(ClansManager.getInstance().getTutorial().inTutorial(player)) continue; - - UtilTextMiddle.display(C.cGreen + getName(), UtilWorld.locToStrClean(getCenterLocation()), 10, 100, 40, player); - player.sendMessage(F.main("Event", F.elem(getName()) + " has started at coordinates " + F.elem(UtilWorld.locToStrClean(getCenterLocation())))); - } - } -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/UndeadCity.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/UndeadCity.java new file mode 100644 index 000000000..fafdb4a2b --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/UndeadCity.java @@ -0,0 +1,195 @@ +package mineplex.game.clans.clans.worldevent.undead; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.ThreadLocalRandom; + +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.PlayerInteractEvent; + +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.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilWorld; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.worldevent.WorldEventManager; +import mineplex.game.clans.clans.worldevent.api.EventState; +import mineplex.game.clans.clans.worldevent.api.WorldEvent; +import mineplex.game.clans.clans.worldevent.undead.creature.UndeadArcher; +import mineplex.game.clans.clans.worldevent.undead.creature.UndeadWarrior; + +public class UndeadCity extends WorldEvent +{ + private final int _maxChests; + private final int _maxMobs; + private final Map _chests = new HashMap<>(); + private final List _spawnSpots = new ArrayList<>(); + private long _lastSpawn; + + public UndeadCity(WorldEventManager manager) + { + super("Undead City", UndeadCityLocation.getRandomLocation().toLocation(UtilWorld.getWorld("world")), 55, true, manager.getDisguiseManager(), manager.getClans().getProjectile(), manager.getDamage(), manager.getBlockRestore(), manager.getClans().getCondition()); + + _maxChests = UndeadCityLocation.getLastLocation().getMaxChests(); + _maxMobs = UndeadCityLocation.getLastLocation().getMaxMobs(); + } + + @Override + public boolean allowsIcePrison() + { + return true; + } + + @Override + protected void customStart() + { + int addedChests = 0; + int addedMobs = 0; + for (Block block : UtilBlock.getInRadius(getCenterLocation(), 55).keySet()) + { + if (block.getType() == Material.ENDER_CHEST) + { + BlockPosition position = new BlockPosition(block); + CityChest chest = new CityChest(block, addedChests++ < _maxChests); + _chests.put(position, chest); + } + } + for (int i = 0; i < (_maxMobs + 10); i++) + { + Location loc = ClansManager.getInstance().getWorldEvent().getTerrainFinder().locateSpace(getCenterLocation(), 55, 0, 3, 0, false, true, new HashSet<>()); + if (loc == null) + { + continue; + } + _spawnSpots.add(loc); + if (addedMobs++ < _maxMobs) + { + if (ThreadLocalRandom.current().nextInt(2) == 0) + { + registerCreature(new UndeadArcher(this, loc)); + } + else + { + registerCreature(new UndeadWarrior(this, loc)); + } + } + } + + _lastSpawn = System.currentTimeMillis(); + } + + @Override + protected void customTick() + { + if (getState() != EventState.LIVE) + { + return; + } + int active = 0; + for (CityChest chest : _chests.values()) + { + if (chest.isEnabled() && !chest.isOpen()) + { + active++; + } + } + if (active < 1) + { + stop(); + return; + } + if (UtilTime.elapsed(_lastSpawn, 15000) && getCreatures().size() < Math.min(_maxMobs, _spawnSpots.size())) + { + Location loc = UtilMath.randomElement(_spawnSpots); + if (ThreadLocalRandom.current().nextInt(2) == 0) + { + registerCreature(new UndeadArcher(this, loc)); + } + else + { + registerCreature(new UndeadWarrior(this, loc)); + } + + _lastSpawn = System.currentTimeMillis(); + } + } + + @Override + public void customCleanup(boolean onDisable) + { + _chests.values().forEach(CityChest::revert); + } + + @Override + protected void customStop() + { + _chests.clear(); + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onChestOpen(PlayerInteractEvent event) + { + if (UtilPlayer.isSpectator(event.getPlayer()) || event.getPlayer().getGameMode() == GameMode.CREATIVE) + { + return; + } + if (!event.hasBlock()) + { + return; + } + if (!UtilEvent.isAction(event, ActionType.ANY)) + { + return; + } + BlockPosition block = new BlockPosition(event.getClickedBlock()); + if (_chests.containsKey(block)) + { + event.setCancelled(true); + UtilPlayer.message(event.getPlayer(), F.main(getName(), "You smash open an " + F.elem("Undead Chest") + "!")); + _chests.get(block).open(); + } + } + + private static class BlockPosition + { + private final int _x, _y, _z; + + public BlockPosition(Block block) + { + _x = block.getX(); + _y = block.getY(); + _z = block.getZ(); + } + + @Override + public int hashCode() + { + return Objects.hash(_x, _y, _z); + } + + @Override + public boolean equals(Object o) + { + if (o instanceof BlockPosition) + { + BlockPosition pos = (BlockPosition) o; + return pos._x == _x && pos._y == _y && pos._z == _z; + } + + return false; + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/UndeadCityLocation.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/UndeadCityLocation.java new file mode 100644 index 000000000..f76ce2328 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/UndeadCityLocation.java @@ -0,0 +1,50 @@ +package mineplex.game.clans.clans.worldevent.undead; + +import java.util.concurrent.ThreadLocalRandom; + +import org.bukkit.Location; +import org.bukkit.World; + +public enum UndeadCityLocation +{ + CITY(92, 68, 1181, 30, 45) + ; + + private static UndeadCityLocation _lastLocation; + private final double _x, _y, _z; + private final int _maxChests, _maxMobs; + + private UndeadCityLocation(double x, double y, double z, int maxChests, int maxMobs) + { + _x = x; + _y = y; + _z = z; + _maxChests = maxChests; + _maxMobs = maxMobs; + } + + public Location toLocation(World world) + { + return new Location(world, _x, _y, _z); + } + + public int getMaxChests() + { + return _maxChests; + } + + public int getMaxMobs() + { + return _maxMobs; + } + + public static UndeadCityLocation getRandomLocation() + { + return _lastLocation = UndeadCityLocation.values()[ThreadLocalRandom.current().nextInt(UndeadCityLocation.values().length)]; + } + + public static UndeadCityLocation getLastLocation() + { + return _lastLocation; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/creature/UndeadArcher.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/creature/UndeadArcher.java index 657b33af4..4c0fe70f8 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/creature/UndeadArcher.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/creature/UndeadArcher.java @@ -1,15 +1,8 @@ package mineplex.game.clans.clans.worldevent.undead.creature; -import mineplex.core.common.util.UtilMath; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.classcombat.Skill.SkillFactory; -import mineplex.minecraft.game.core.boss.EventCreature; -import mineplex.minecraft.game.core.boss.WorldEvent; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; - import java.util.HashSet; import java.util.Iterator; +import java.util.Set; import org.bukkit.Location; import org.bukkit.Material; @@ -19,26 +12,32 @@ 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.EntityShootBowEvent; 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.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; +import mineplex.core.common.util.UtilMath; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.worldevent.api.EventCreature; +import mineplex.game.clans.clans.worldevent.api.WorldEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + public class UndeadArcher extends EventCreature { public static final int BARBED_LEVEL = 1; - private HashSet _arrows = new HashSet(); + private Set _arrows = new HashSet<>(); - private SkillFactory _skillFactory; - - public UndeadArcher(WorldEvent event, Location spawnLocation, SkillFactory skillFactory) + public UndeadArcher(WorldEvent event, Location spawnLocation) { - super(event, spawnLocation, "Undead Archer", true, 100, Skeleton.class); + super(event, spawnLocation, "Undead Archer", true, 30, 30, true, Skeleton.class); - _skillFactory = skillFactory; + spawnEntity(); } @Override @@ -51,6 +50,11 @@ public class UndeadArcher extends EventCreature 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)); } @@ -155,7 +159,7 @@ public class UndeadArcher extends EventCreature event.AddMod(damager.getName(), "Barbed Arrows", 0, false); // Condition - _skillFactory.Condition().Factory().Slow("Barbed Arrows", damagee, damager, (projectile.getVelocity().length() / 3) * (2 + BARBED_LEVEL), 0, false, true, true, true); + getEvent().getCondition().Factory().Slow("Barbed Arrows", damagee, damager, (projectile.getVelocity().length() / 3) * (2 + BARBED_LEVEL), 0, false, true, true, true); } @EventHandler @@ -170,4 +174,16 @@ public class UndeadArcher extends EventCreature if (arrow.isDead() || !arrow.isValid()) arrowIterator.remove(); } } -} + + @EventHandler + public void onTarget(EntityTargetLivingEntityEvent event) + { + if (getEntity().equals(event.getEntity())) + { + if (!(event.getTarget() instanceof Player)) + { + event.setCancelled(true); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/creature/UndeadWarrior.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/creature/UndeadWarrior.java index 6dc3c7b3c..4884b0f9b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/creature/UndeadWarrior.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/creature/UndeadWarrior.java @@ -1,28 +1,32 @@ package mineplex.game.clans.clans.worldevent.undead.creature; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.entity.Zombie; +import org.bukkit.event.EventHandler; +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; + 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; +import mineplex.game.clans.clans.worldevent.api.EventCreature; +import mineplex.game.clans.clans.worldevent.api.WorldEvent; public class UndeadWarrior extends EventCreature { public UndeadWarrior(WorldEvent event, Location spawnLocation) { - super(event, spawnLocation, "Undead Warrior", true, 100, Zombie.class); + super(event, spawnLocation, "Undead Warrior", true, 50, 30, true, Zombie.class); + + spawnEntity(); } @Override @@ -35,6 +39,10 @@ public class UndeadWarrior extends EventCreature 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)); } @@ -55,7 +63,9 @@ public class UndeadWarrior extends EventCreature getEntity().getWorld().dropItem(getEntity().getLocation(), new org.bukkit.inventory.ItemStack(Material.IRON_BOOTS)); for (int i=0 ; i //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); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldCommand.java index 9bb748156..dd8e46dcc 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldCommand.java @@ -3,7 +3,6 @@ package mineplex.game.clans.economy; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -17,14 +16,9 @@ public class GoldCommand extends CommandBase @Override public void Execute(final Player caller, String[] args) { - if (args == null || args.length == 0) + if (args.length < 2) { - UtilPlayer.message(caller, F.main("Gold", "Your Gold: " + F.elem("" + Plugin.Get(caller).getBalance()))); - return; - } - else if (args.length < 2) - { - UtilPlayer.message(caller, F.main("Gold", "Missing Args: " + F.elem("/gold "))); + UtilPlayer.message(caller, F.main("Gold", "Missing Args: " + F.elem("/givegold "))); return; } @@ -67,16 +61,18 @@ public class GoldCommand extends CommandBase private void rewardGold(final Player caller, final Player target, final String targetName, final int accountId, final int gold) { - Plugin.rewardGold(new Callback() + Plugin.rewardGold(success -> { - public void run(Boolean completed) + if (!success) { - UtilPlayer.message(caller, F.main("Gold", "You gave " + F.elem(gold + " Gold") + " to " + F.name(targetName) + ".")); - - if (target != null) - { - UtilPlayer.message(target, F.main("Gold", F.name(caller.getName()) + " gave you " + F.elem(gold + " Gold") + ".")); - } + UtilPlayer.message(caller, F.main("Gold", "You cannot deduct that much " + F.elem("Gold") + " from " + F.name(targetName) + ".")); + return; + } + UtilPlayer.message(caller, F.main("Gold", "You gave " + F.elem(gold + " Gold") + " to " + F.name(targetName) + ".")); + + if (target != null) + { + UtilPlayer.message(target, F.main("Gold", F.name(caller.getName()) + " gave you " + F.elem(gold + " Gold") + ".")); } }, accountId, targetName, gold, true); } 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 753f4bac4..a10922af4 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 @@ -2,6 +2,7 @@ package mineplex.game.clans.economy; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -13,12 +14,15 @@ import java.util.UUID; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; +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.entity.PlayerDeathEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerPickupItemEvent; +import org.bukkit.event.world.ChunkUnloadEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.metadata.FixedMetadataValue; @@ -68,7 +72,6 @@ public class GoldManager extends MiniDbClientPlugin private TransferTracker _transferTracker; private Set _itemSet; private Map _playerPickupMap; - private BankShop _bankShop; public GoldManager(ClansManager plugin, CoreClientManager clientManager, DonationManager donationManager, ClansDataAccessLayer dataAccessLayer) { @@ -78,16 +81,15 @@ public class GoldManager extends MiniDbClientPlugin _donationManager = donationManager; _serverId = dataAccessLayer.getRepository().getServerId(); _transferTracker = new TransferTracker(); - _itemSet = new HashSet(); - _playerPickupMap = new HashMap(); - _bankShop = new BankShop(plugin, clientManager, donationManager); + _itemSet = new HashSet<>(); + _playerPickupMap = new HashMap<>(); + new BankShop(plugin, clientManager, donationManager); generatePermissions(); } private void generatePermissions() { - PermissionGroup.ADMIN.setPermission(Perm.GIVE_GOLD_COMMAND, true, true); PermissionGroup.ADMIN.setPermission(Perm.SET_GOLD_COMMAND, true, true); } @@ -103,7 +105,6 @@ public class GoldManager extends MiniDbClientPlugin public void onPlayerDeath(PlayerDeathEvent event) { final Player player = event.getEntity(); - final Player killer = player.getKiller(); int gold = getGold(player); final int droppedGold = (int) (gold * DEATH_TAX); @@ -113,16 +114,16 @@ public class GoldManager extends MiniDbClientPlugin { deductGold(success -> { + if (!success) + { + return; + } runSync(() -> { GoldManager.notify(player, "You dropped " + F.elem(droppedGold + "") + " gold on your death!"); + dropGold(deathLocation, droppedGold); }); - // if (killer != null) - // { - // addGold(killer, droppedGold); - // GoldManager.notify(killer, String.format("You looted %d gold off of %s's corpse!", droppedGold, player.getName())); - // } }, player, droppedGold); } } @@ -198,6 +199,13 @@ public class GoldManager extends MiniDbClientPlugin } } } + + @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) + public void onChunkUnload(ChunkUnloadEvent event) + { + List entities = Arrays.asList(event.getChunk().getEntities()); + _itemSet.stream().filter(entities::contains).forEach(Item::remove); + } public int getGold(Player player) { @@ -422,7 +430,7 @@ public class GoldManager extends MiniDbClientPlugin @Override public String getQuery(int accountId, String uuid, String name) { - return "SELECT gold FROM clansGold WHERE id = '" + accountId + "' AND serverId=" + _serverId + ";"; + return "SELECT gold FROM clansGold WHERE accountId = '" + accountId + "' AND serverId=" + _serverId + ";"; } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/CustomRecipes.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/CustomRecipes.java index fe96c7d1e..43ed555dc 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/CustomRecipes.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/CustomRecipes.java @@ -12,7 +12,7 @@ import mineplex.core.common.util.UtilPlayer; public class CustomRecipes implements Listener { - private static final Material[] DISABLED_RECIPES = { Material.EXPLOSIVE_MINECART, Material.JUKEBOX, Material.FISHING_ROD, Material.BED, Material.BOAT, Material.HOPPER, Material.HOPPER_MINECART }; + private static final Material[] DISABLED_RECIPES = { Material.EXPLOSIVE_MINECART, Material.MINECART, Material.JUKEBOX, Material.FISHING_ROD, Material.BED, Material.BOAT, Material.HOPPER, Material.HOPPER_MINECART }; @EventHandler public void onPlayerCraftItem(CraftItemEvent event) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/DurabilityManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/DurabilityManager.java index da8fc5cca..88e83ffc1 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/DurabilityManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/DurabilityManager.java @@ -12,6 +12,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerItemDamageEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; @@ -131,7 +132,7 @@ public class DurabilityManager implements Listener if (_itemDurabilities.containsKey(item.getType())) { int defaultDurability = _itemDurabilities.get(item.getType()); - ItemStackFactory.Instance.SetLoreVar(item, "Durability", Math.min(defaultDurability, subtractFromDefault ? (defaultDurability - itemDamage) : itemDamage) + ""); + ItemStackFactory.Instance.SetLoreVar(item, "Durability", String.valueOf(Math.min(defaultDurability, subtractFromDefault ? (defaultDurability - itemDamage) : itemDamage))); } else { @@ -139,6 +140,31 @@ public class DurabilityManager implements Listener } } + @EventHandler + public void onDamageItem(PlayerItemDamageEvent event) + { + if (event.getItem() == null) + { + return; + } + if (_itemDurabilities.containsKey(event.getItem().getType())) + { + int damage = event.getDamage(); + int defaultDurability = _itemDurabilities.get(event.getItem().getType()); + int currentDurability = ItemStackFactory.Instance.GetLoreVar(event.getItem(), "Durability", defaultDurability); + int newDurability = currentDurability - damage; + if (newDurability > 0) + { + event.setCancelled(true); + ItemStackFactory.Instance.SetLoreVar(event.getItem(), "Durability", String.valueOf(newDurability)); + } + else + { + event.setDamage(999999); + } + } + } + @EventHandler public void onUpdate(UpdateEvent event) { 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 83b1d6a5a..eef4e7627 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 @@ -268,7 +268,7 @@ public class Gameplay extends MiniPlugin return; } - if (_clansManager.getWorldEvent().isInEvent(event.getClickedBlock().getLocation())) + if (_clansManager.getWorldEvent().isInEvent(event.getClickedBlock().getLocation(), false)) { return; } @@ -310,7 +310,7 @@ public class Gameplay extends MiniPlugin { return; } - if (_clansManager.getWorldEvent().isInEvent(event.getBlock().getLocation())) + if (_clansManager.getWorldEvent().isInEvent(event.getBlock().getLocation(), false)) { return; } @@ -498,10 +498,9 @@ public class Gameplay extends MiniPlugin event.setCancelled(true); } - @EventHandler(priority = EventPriority.HIGHEST) + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void disableSaplings(BlockPlaceEvent event) { - if(event.isCancelled()) return; //Can't place this block if (!event.getItemInHand().getType().equals(Material.SAPLING)) { return; @@ -509,42 +508,48 @@ public class Gameplay extends MiniPlugin Block block = event.getBlock(); ClanInfo clan = _clansManager.getClanUtility().getClanByPlayer(event.getPlayer()); - - for (int cX = -32; cX < 32; cX++) + if (clan != null) { - for (int cZ = -32; cZ < 32; cZ++) + ClanTerritory claim = _clansManager.getClanUtility().getClaim(block.getLocation()); + if (claim != null) { - ClanTerritory claim = _clansManager.getClanUtility().getClaim(block.getLocation().add(cX, 0, cZ)); - - if (claim != null && (clan == null || !claim.Owner.equals(clan.getName()))) + if (claim.Owner.equals(clan.getName())) + { + if (!Recharge.Instance.use(event.getPlayer(), "Place Sapling", 20 * 60 * 1000, true, false)) + { + event.setCancelled(true); + return; + } + } + } + } + UtilPlayer.message(event.getPlayer(), F.main("Clans", "You can only place saplings in your own territory!")); + event.setCancelled(true); + } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void disableString(BlockPlaceEvent event) + { + if (!event.getItemInHand().getType().equals(Material.STRING)) + { + return; + } + + Block block = event.getBlock(); + ClanInfo clan = _clansManager.getClanUtility().getClanByPlayer(event.getPlayer()); + if (clan != null) + { + ClanTerritory claim = _clansManager.getClanUtility().getClaim(block.getLocation()); + if (claim != null) + { + if (claim.Owner.equals(clan.getName())) { - UtilPlayer.message(event.getPlayer(), F.main("Clans", "You may not place saplings near other clan's claims.")); - event.setCancelled(true); return; } } } - - if (clan == null || (!clan.equals(_clansManager.getClanUtility().getOwner(block.getLocation())))) - { - if (UtilBlock.getInRadius(block, 10) - .keySet() - .stream() - .filter(other -> other.getType().equals(Material.SAPLING)) - .filter(other -> !other.getLocation().equals(block.getLocation())) - .toArray().length > 0) - { - UtilPlayer.message(event.getPlayer(), F.main("Clans", "You may not place this block close to any other saplings, unless in your territory.")); - event.setCancelled(true); - return; - } - } - - if (!Recharge.Instance.use(event.getPlayer(), "Place Sapling", 20 * 60 * 1000, true, false)) - { - event.setCancelled(true); - return; - } + UtilPlayer.message(event.getPlayer(), F.main("Clans", "You can only place string in your own territory!")); + event.setCancelled(true); } @EventHandler diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/SafeLog.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/SafeLog.java index 350e6228c..48539f17e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/SafeLog.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/SafeLog.java @@ -71,6 +71,11 @@ public class SafeLog extends MiniPlugin isSafeLog = true; } + if (Managers.get(ClansFreezeManager.class).isPanicking(player)) + { + isSafeLog = true; + } + if (Managers.get(RestartManager.class).isRestarting()) { isSafeLog = true; @@ -81,12 +86,19 @@ public class SafeLog extends MiniPlugin isSafeLog = true; } + if (_clansManager.hasTimer(player)) + { + isSafeLog = true; + } + + if (_clansManager.getIncognitoManager().Get(player).Status) + { + isSafeLog = true; + } + if (!isSafeLog) { - if (!_clansManager.getIncognitoManager().Get(player).Status) - { - NPCManager.getInstance().spawnLogoutNpc(player); - } + NPCManager.getInstance().spawnLogoutNpc(player); } } @@ -117,14 +129,11 @@ public class SafeLog extends MiniPlugin stream.close(); - UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() + UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(getPlugin(), () -> { - public void run() - { - _clansManager.ClanTips.displayTip(TipType.NPC_RIPPARONI, player); - UtilPlayer.message(player, F.main("SafeLog", "You were killed by " + F.elem(killerName) + " when you logged out! This happened about " + F.time(UtilTime.MakeStr(System.currentTimeMillis() - time))) + " ago."); - UtilTextMiddle.display("Offline Death", "Log out in a safer place next time!", 15, 80, 40, player); - } + _clansManager.ClanTips.displayTip(TipType.NPC_RIPPARONI, player); + UtilPlayer.message(player, F.main("SafeLog", "You were killed by " + F.elem(killerName) + " when you logged out! This happened about " + F.time(UtilTime.MakeStr(System.currentTimeMillis() - time))) + " ago."); + UtilTextMiddle.display("Offline Death", "Log out in a safer place next time!", 15, 80, 40, player); }, 15); deathFile.delete(); 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 667bbdee1..08c79ee1e 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 @@ -6,21 +6,15 @@ import java.util.UUID; import org.bukkit.ChatColor; import org.bukkit.Material; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftItem; -import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemFactory; import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; -import org.bukkit.event.EventHandler; +import org.bukkit.entity.Player; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; -import mineplex.core.common.util.EnclosedObject; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilServer; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.items.attributes.AttributeContainer; import mineplex.game.clans.items.attributes.ItemAttribute; import mineplex.minecraft.game.core.damage.CustomDamageEvent; @@ -28,9 +22,6 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent; /** * Represents a customizable wrapper for an {@link ItemStack}, enabling the * possession of special abilities, attributes, and triggers on item. - * - * @author MrTwiggy - * */ public class CustomItem implements Listener { @@ -42,6 +33,8 @@ public class CustomItem implements Listener protected transient String _displayName; protected transient String[] _description; protected transient Material _material; + + protected transient Player _lastUser = null; private AttributeContainer _attributes; @@ -51,7 +44,7 @@ public class CustomItem implements Listener public String OriginalOwner = null; - public String getUuid() + public String getUUID() { return _uuid; } @@ -165,7 +158,7 @@ public class CustomItem implements Listener */ public boolean matches(CustomItem item) { - return item.getUuid().equals(_uuid); + return item.getUUID().equals(_uuid); } /** @@ -227,4 +220,4 @@ public class CustomItem implements Listener } _material = material; } -} +} \ 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 53d093716..f366d84c0 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 @@ -10,14 +10,6 @@ import java.util.Map; import java.util.Set; import java.util.UUID; -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.Color; import org.bukkit.FireworkEffect.Type; @@ -87,7 +79,13 @@ 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; /** * Handles converting legendary itemstacks to their respective CustomItem objects */ @@ -226,7 +224,6 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable // Mapping of player names (key) to cached gear set (value). private Map _playerGears = new HashMap<>(); - private CoreClientManager _clientManager; private GearShop _shop; private RuneManager _rune; @@ -241,7 +238,6 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable _instance = this; - _clientManager = clientManager; _shop = new GearShop(this, clientManager, donationManager); _rune = new RuneManager("Rune", plugin); @@ -258,7 +254,6 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable private void generatePermissions() { - PermissionGroup.ADMIN.setPermission(Perm.RUNE_COMMAND, true, true); PermissionGroup.ADMIN.setPermission(Perm.GEAR_COMMAND, true, true); } @@ -305,6 +300,26 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable { return _playerGears.computeIfAbsent(player, PlayerGear::new); } + + public Set> getFindableLegendaries() + { + return LEGENDARY_WEIGHTS.elements(); + } + + public Set> getArmorAttributes() + { + return ARMOR_ATTRIBUTES.elements(); + } + + public Set> getBowAttributes() + { + return BOW_ATTRIBUTES.elements(); + } + + public Set> getWeaponAttributes() + { + return WEAPON_ATTRIBUTES.elements(); + } public CustomItem generateItem() { @@ -362,7 +377,7 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable return factory.getWrapper(); } - private void generateAttributes(AttributeContainer container, ItemType type, int count) + public void generateAttributes(AttributeContainer container, ItemType type, int count) { for (int i = 0; i < count; i++) { @@ -494,30 +509,8 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable return null; } } - else // This is stored in the old format - { - String serialization = getItemSerialization(item); - if (serialization == null) - { - return null; - } - try - { - CustomItem customItem = deserialize(serialization); - - data.put("gearmanager.uuid", new NBTTagString(customItem._uuid)); - data.put("gearmanager.json", new NBTTagString(serialization)); - saveUnhandledTags(item, data); - _customItemCache.put(UUID.fromString(customItem._uuid), customItem); - return customItem; - } - catch (Exception e) - { - System.out.println(serialization); - e.printStackTrace(); - } - return null; - } + + return null; } public static void writeNBT(CustomItem customItem, ItemStack item) @@ -535,7 +528,8 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable { return true; } - return getItemSerialization(item) != null; + + return false; } /** @@ -556,28 +550,6 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable } } - @Deprecated - private static String getItemSerialization(ItemStack item) - { - if (item == null || item.getItemMeta() == null || item.getItemMeta().getLore() == null) return null; - - // fixme Each call to getItemMeta creates a new ItemMeta, a clone of an ArrayList, and a clone of a Hashmap - // Each call to getLore re-clones that ArrayList again - // Reflection may be too slow, but perhaps MethodHandles would be good? - ItemMeta meta = item.getItemMeta(); - - for (String lore : meta.getLore()) - { - if (lore.startsWith(ITEM_SERIALIZATION_TAG)) - { - int tagLength = ITEM_SERIALIZATION_TAG.length(); - return lore.substring(tagLength); - } - } - - return null; // Unable to find any serialized lore lines, hence not a CustomItem. - } - public static String serialize(CustomItem customItem) { return GSON.toJson(customItem, CustomItem.class); @@ -780,16 +752,11 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable while (it.hasNext()) { CustomItem item = it.next(); - if (item.OriginalOwner != null) + if (item._lastUser == null || !item._lastUser.isOnline()) { - UUID uuid = UUID.fromString(item.OriginalOwner); - Player player = Bukkit.getPlayer(uuid); - if (player == null || !player.isOnline()) - { - UtilServer.Unregister(item); - it.remove(); - } + UtilServer.Unregister(item); + it.remove(); } } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/ItemListener.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/ItemListener.java index 02ff57e7e..0467948bd 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/ItemListener.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/ItemListener.java @@ -1,12 +1,5 @@ package mineplex.game.clans.items; -import mineplex.core.common.util.UtilInv; -import mineplex.core.common.util.UtilOfflinePlayer; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import net.minecraft.server.v1_8_R3.PlayerInventory; -import org.bukkit.Bukkit; -import org.bukkit.GameMode; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; @@ -16,16 +9,24 @@ import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerGameModeChangeEvent; +import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerItemHeldEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.metadata.MetadataValue; import org.bukkit.plugin.java.JavaPlugin; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilItem; +import mineplex.core.common.util.UtilServer; +import mineplex.game.clans.clans.invsee.InvseeModifyOnlineInventoryEvent; import mineplex.game.clans.items.attributes.AttributeContainer; import mineplex.game.clans.items.attributes.ItemAttribute; import mineplex.minecraft.game.core.damage.CustomDamageEvent; @@ -140,7 +141,6 @@ public class ItemListener implements Listener, Runnable Entity projectile = event.getProjectile(); projectile.setMetadata(PROJECTILE_META_TAG, new FixedMetadataValue(_plugin, attributes)); - } } } @@ -157,6 +157,85 @@ public class ItemListener implements Listener, Runnable PlayerGear playerGear = getGear(event.getPlayer()); playerGear.onInteract(event); } + + //Handle player gear caching + + @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) + public void onDrop(PlayerDropItemEvent event) + { + GearManager.getInstance().runSyncLater(() -> getGear(event.getPlayer()).updateCache(true), 1); + } + + @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) + public void onPickup(PlayerPickupItemEvent event) + { + GearManager.getInstance().runSyncLater(() -> getGear(event.getPlayer()).updateCache(true), 1); + } + + @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) + public void onClick(InventoryClickEvent event) + { + if (Player.class.isInstance(event.getWhoClicked())) + { + GearManager.getInstance().runSyncLater(() -> getGear((Player)event.getWhoClicked()).updateCache(true), 1); + } + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onJoin(PlayerJoinEvent event) + { + GearManager.getInstance().runSyncLater(() -> + { + if (event.getPlayer().isOnline()) + { + getGear(event.getPlayer()).updateCache(true); + } + }, 5); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onRespawn(PlayerRespawnEvent event) + { + GearManager.getInstance().runSyncLater(() -> getGear(event.getPlayer()).updateCache(true), 1); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onHold(PlayerItemHeldEvent event) + { + GearManager.getInstance().runSyncLater(() -> getGear(event.getPlayer()).updateCache(false), 1); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onInvsee(InvseeModifyOnlineInventoryEvent event) + { + GearManager.getInstance().runSyncLater(() -> getGear(event.getModified()).updateCache(true), 1); + } + + @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) + public void onEquipArmor(PlayerInteractEvent event) + { + if (UtilEvent.isAction(event, ActionType.R)) + { + Player player = event.getPlayer(); + + if (UtilItem.isHelmet(event.getItem()) && player.getInventory().getHelmet() == null) + { + GearManager.getInstance().runSyncLater(() -> getGear(player).updateCache(true), 1); + } + else if (UtilItem.isChestplate(event.getItem()) && player.getInventory().getChestplate() == null) + { + GearManager.getInstance().runSyncLater(() -> getGear(player).updateCache(true), 1); + } + else if (UtilItem.isLeggings(event.getItem()) && player.getInventory().getLeggings() == null) + { + GearManager.getInstance().runSyncLater(() -> getGear(player).updateCache(true), 1); + } + else if (UtilItem.isBoots(event.getItem()) && player.getInventory().getBoots() == null) + { + GearManager.getInstance().runSyncLater(() -> getGear(player).updateCache(true), 1); + } + } + } /** * @param player - the player whose gear is to be fetched @@ -166,4 +245,4 @@ public class ItemListener implements Listener, Runnable { return GearManager.getInstance().getPlayerGear(player); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/PlayerGear.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/PlayerGear.java index 3601524c7..081b68516 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/PlayerGear.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/PlayerGear.java @@ -1,40 +1,30 @@ package mineplex.game.clans.items; -import java.util.HashSet; -import java.util.Set; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; import java.util.function.Consumer; -import org.bukkit.Bukkit; import org.bukkit.entity.Player; -import org.bukkit.event.HandlerList; import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerItemHeldEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.PlayerInventory; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTextMiddle; import mineplex.game.clans.items.legendaries.LegendaryItem; import mineplex.minecraft.game.core.damage.CustomDamageEvent; /** * PlayerGear caches and manages a players set of {@link CustomItem}s that they * currently wield. - * - * @author MrTwiggy - * */ public class PlayerGear { - private boolean _cleanedUp = false; - private Player _owner; + + private CustomItem _weapon, _helmet, _chestplate, _leggings, _boots; + private Map _inventory = new HashMap<>(); public PlayerGear(Player owner) { - this._owner = owner; + _owner = owner; } /** @@ -61,12 +51,37 @@ public class PlayerGear } } + /** + * Refresh the cache of gear due to a potential change + */ + public void updateCache(boolean inventoryChanged) + { + if (inventoryChanged) + { + forEachGear(true, item -> item._lastUser = null); + _inventory.clear(); + for (int i = 0; i < getPlayer().getInventory().getSize(); i++) + { + _inventory.put(i, GearManager.parseItem(getPlayer().getInventory().getItem(i))); + } + } + _weapon = _inventory.get(getPlayer().getInventory().getHeldItemSlot()); + _helmet = GearManager.parseItem(getPlayer().getInventory().getHelmet()); + _chestplate = GearManager.parseItem(getPlayer().getInventory().getChestplate()); + _leggings = GearManager.parseItem(getPlayer().getInventory().getLeggings()); + _boots = GearManager.parseItem(getPlayer().getInventory().getBoots()); + if (inventoryChanged) + { + forEachGear(true, item -> item._lastUser = getPlayer()); + } + } + /** * @return the {@link Player} that owns this gear set. */ public Player getPlayer() { - return this._owner; + return _owner; } public String getPlayerName() @@ -82,7 +97,7 @@ public class PlayerGear */ public void onInteract(PlayerInteractEvent event) { - forEachGear(item -> item.onInteract(event)); + forEachGear(false, item -> item.onInteract(event)); } @@ -94,7 +109,7 @@ public class PlayerGear */ public void onAttack(CustomDamageEvent event) { - forEachGear(item -> item.onAttack(event)); + forEachGear(false, item -> item.onAttack(event)); } /** @@ -105,15 +120,22 @@ public class PlayerGear */ public void onAttacked(CustomDamageEvent event) { - forEachGear(item -> item.onAttacked(event)); + forEachGear(false, item -> item.onAttacked(event)); } - private void forEachGear(Consumer itemConsumer) + private void forEachGear(boolean fullInventory, Consumer itemConsumer) { - CustomItem weapon = getWeapon(); - if (weapon != null) + if (fullInventory) { - itemConsumer.accept(weapon); + _inventory.values().stream().filter(Objects::nonNull).forEach(itemConsumer); + } + else + { + CustomItem weapon = getWeapon(); + if (weapon != null) + { + itemConsumer.accept(weapon); + } } CustomItem helmet = getHelmet(); if (helmet != null) @@ -139,34 +161,34 @@ public class PlayerGear public CustomItem getWeapon() { - return GearManager.parseItem(getPlayer().getInventory().getItemInHand()); + return _weapon; } public CustomItem getHelmet() - { - return GearManager.parseItem(getPlayer().getInventory().getHelmet()); + { + return _helmet; } public CustomItem getChestplate() - { - return GearManager.parseItem(getPlayer().getInventory().getChestplate()); + { + return _chestplate; } public CustomItem getLeggings() - { - return GearManager.parseItem(getPlayer().getInventory().getLeggings()); + { + return _leggings; } public CustomItem getBoots() { - return GearManager.parseItem(getPlayer().getInventory().getBoots()); + return _boots; } - /* + /** * Perform cleanup if necessary. If cleanup was performed, return true. Otherwise return false */ public boolean cleanup() { return !getPlayer().isOnline(); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/RareItemFactory.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/RareItemFactory.java index 7f1af9015..598b7fdb4 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/RareItemFactory.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/RareItemFactory.java @@ -103,18 +103,45 @@ public class RareItemFactory return this; } + public RareItemFactory setSuperPrefix(ItemAttribute superPrefixType) + { + if (superPrefixType != null) + { + setSuperPrefix(superPrefixType.getClass()); + } + return this; + } + public RareItemFactory setPrefix(Class prefix) { _prefix = prefix; return this; } + public RareItemFactory setPrefix(ItemAttribute prefixType) + { + if (prefixType != null) + { + setPrefix(prefixType.getClass()); + } + return this; + } + public RareItemFactory setSuffix(Class suffix) { _suffix = suffix; return this; } + public RareItemFactory setSuffix(ItemAttribute suffixType) + { + if (suffixType != null) + { + setSuffix(suffixType.getClass()); + } + return this; + } + public ItemStack fabricate() { applyAttributes(); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/DemonicScythe.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/DemonicScythe.java index 06d840826..0eb4c3f24 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/DemonicScythe.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/DemonicScythe.java @@ -3,9 +3,11 @@ package mineplex.game.clans.items.legendaries; import org.bukkit.GameMode; import org.bukkit.Material; import org.bukkit.entity.Entity; +import org.bukkit.entity.Horse; import org.bukkit.entity.Player; import mineplex.core.common.util.C; +import mineplex.core.recharge.Recharge; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansUtility; import mineplex.minecraft.game.core.damage.CustomDamageEvent; @@ -66,7 +68,14 @@ public class DemonicScythe extends LegendaryItem { return; } - event.AddMod("Scythe of the Fallen Lord", 8); - wielder.setHealth(Math.min(wielder.getMaxHealth(), wielder.getHealth() + 2)); + if (wielder.getHealth() <= 0) + { + return; + } + event.AddMod("Scythe of the Fallen Lord", 7); + if (!(event.GetDamageeEntity() instanceof Horse) && Recharge.Instance.use(wielder, "Demonic Scythe Heal", 500, false, false)) + { + wielder.setHealth(Math.min(wielder.getMaxHealth(), wielder.getHealth() + 2)); + } } } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MagneticMaul.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MagneticMaul.java index 4f033e705..a65112279 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MagneticMaul.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MagneticMaul.java @@ -48,9 +48,12 @@ public class MagneticMaul extends LegendaryItem return; } - if (isHoldingRightClick() && canPull()) + if (isHoldingRightClick()) { - pullEntities(wielder); + if (canPull()) + { + pullEntities(wielder); + } } else { @@ -87,6 +90,10 @@ public class MagneticMaul extends LegendaryItem { continue; // Skip pulling self } + if (entity.getPassenger() != null && entity.getPassenger().getEntityId() == player.getEntityId()) + { + continue; + } double otherDistance = player.getLocation().distance(entity.getLocation()); double otherTargetDistance = target.distance(entity.getLocation()); @@ -145,4 +152,4 @@ public class MagneticMaul extends LegendaryItem { return _power >= 10 && _heat < 70; } -} +} \ No newline at end of file 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 01f539904..f2a645cea 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 @@ -57,7 +57,7 @@ public class MeridianScepter extends LegendaryItem { if (ClansManager.getInstance().hasTimer(wielder)) { - UtilPlayer.message(wielder, F.main("Clans", "You are not allowed to fire the Meridian Scepter whilst under pvp protection.")); + UtilPlayer.message(wielder, F.main("Clans", "You are not allowed to fire the Meridian Scepter whilst protected from PvP. Run " + F.elem("/pvp") + " to enable PvP!")); return; } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/WindBlade.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/WindBlade.java index 382f0cf0e..0c8956638 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/WindBlade.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/WindBlade.java @@ -195,4 +195,4 @@ public class WindBlade extends LegendaryItem { _power = UtilMath.clamp(_power - power, -20, 80); } -} +} \ No newline at end of file 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 33e26bbb0..a2f7643dd 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 @@ -9,6 +9,8 @@ import org.bukkit.event.Listener; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockDamageEvent; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerItemHeldEvent; +import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; @@ -46,7 +48,8 @@ public class RunedPickaxe extends RareItem return; } - UtilServer.getPlayersCollection().forEach(player -> { + UtilServer.getPlayersCollection().forEach(player -> + { PlayerGear gear = ClansManager.getInstance().getGearManager().getPlayerGear(player); if (!(gear.getWeapon() instanceof RunedPickaxe)) @@ -61,8 +64,7 @@ public class RunedPickaxe extends RareItem UtilTextBottom.displayProgress("Instant mine", (((double) (((double) System.currentTimeMillis()) - ((double) pick._instamineEnabled))) / 12000D), null, true, player); } - if (pick._enabled - && (System.currentTimeMillis() - pick._instamineEnabled) >= 12000) + if (pick._enabled && (System.currentTimeMillis() - pick._instamineEnabled) >= 12000) { Recharge.Instance.use(player, "Instant Mine", 15 * 1000, true, true); @@ -76,6 +78,19 @@ public class RunedPickaxe extends RareItem }); } + @EventHandler + public void onSwap(PlayerItemHeldEvent event) + { + if (event.getPlayer().hasPotionEffect(PotionEffectType.FAST_DIGGING)) + { + ItemStack previous = event.getPlayer().getInventory().getItem(event.getPreviousSlot()); + if (previous != null && previous.getType() == Material.RECORD_7) + { + event.getPlayer().removePotionEffect(PotionEffectType.FAST_DIGGING); + } + } + } + @EventHandler(priority = EventPriority.LOWEST) public void blockDamage(BlockDamageEvent event) { @@ -149,7 +164,8 @@ public class RunedPickaxe extends RareItem public RunedPickaxe() { - super("Runed Pickaxe", UtilText.splitLinesToArray(new String[] { + super("Runed Pickaxe", UtilText.splitLinesToArray(new String[] + { "What an interesting design this pickaxe seems to have!", C.cYellow + "Right-Click" + C.cWhite + " to use " + F.elem("Instant mine") + "." }, LineFormat.LORE), Material.RECORD_7); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/ui/GearPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/ui/GearPage.java index 7bda255f0..960e312be 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/ui/GearPage.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/ui/GearPage.java @@ -151,7 +151,7 @@ public class GearPage extends ShopPageBase { Triple stage2 = doStageTwo(); - if (stage2.getLeft().booleanValue()) + if (stage2.getLeft()) { return; } @@ -166,7 +166,7 @@ public class GearPage extends ShopPageBase { Triple stage3 = doStageThree(); - if (stage3.getLeft().booleanValue()) + if (stage3.getLeft()) { return; } @@ -289,7 +289,7 @@ public class GearPage extends ShopPageBase if (_factory == null || _factory.getItemType() == null) { performBack(); - return Triple.of(Boolean.valueOf(true), stageTitle, stageMaterial); + return Triple.of(true, stageTitle, stageMaterial); } if (_factory.getItemType().equals(ItemType.RARE)) @@ -429,7 +429,7 @@ public class GearPage extends ShopPageBase } } } - return Triple.of(Boolean.valueOf($return), stageTitle, stageMaterial); + return Triple.of($return, stageTitle, stageMaterial); } private Triple doStageThree() throws InstantiationException, IllegalAccessException @@ -439,7 +439,7 @@ public class GearPage extends ShopPageBase if (_factory.getMaterial() == null) { performBack(); - return Triple.of(Boolean.valueOf(true), null, null); + return Triple.of(true, null, null); } Material stageMaterial = _factory.getMaterial(); @@ -535,7 +535,7 @@ public class GearPage extends ShopPageBase } } - return Triple.of(Boolean.valueOf(false), stageTitle, stageMaterial); + return Triple.of(false, stageTitle, stageMaterial); } private Pair doStageFour() throws InstantiationException, IllegalAccessException diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/restart/RestartManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/restart/RestartManager.java index d7d2ac9bb..ba3da6a3c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/restart/RestartManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/restart/RestartManager.java @@ -3,16 +3,20 @@ package mineplex.game.clans.restart; import java.util.Calendar; import java.util.LinkedList; -import net.minecraft.server.v1_8_R3.MinecraftServer; - import org.bukkit.Bukkit; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.event.player.PlayerLoginEvent.Result; +import org.bukkit.event.server.ServerCommandEvent; import org.bukkit.event.server.ServerListPingEvent; import org.bukkit.plugin.java.JavaPlugin; +import com.mineplex.clansqueue.common.ClansQueueMessenger; +import com.mineplex.clansqueue.common.QueueConstant; +import com.mineplex.clansqueue.common.messages.ServerOfflineMessage; + import mineplex.core.MiniPlugin; import mineplex.core.account.permissions.Permission; import mineplex.core.account.permissions.PermissionGroup; @@ -29,9 +33,11 @@ import mineplex.core.slack.SlackAPI; import mineplex.core.slack.SlackMessage; import mineplex.core.slack.SlackTeam; import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.RestartServerEvent; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.gameplay.safelog.npc.NPCManager; +import net.minecraft.server.v1_8_R3.MinecraftServer; public class RestartManager extends MiniPlugin { @@ -82,7 +88,6 @@ public class RestartManager extends MiniPlugin private void generatePermissions() { - PermissionGroup.CMOD.setPermission(Perm.RESTART_COMMAND, false, true); PermissionGroup.QAM.setPermission(Perm.RESTART_COMMAND, false, true); PermissionGroup.ADMIN.setPermission(Perm.RESTART_COMMAND, true, true); @@ -147,6 +152,9 @@ public class RestartManager extends MiniPlugin public void restart() { + ServerOfflineMessage message = new ServerOfflineMessage(); + message.ServerName = UtilServer.getServerName(); + ClansQueueMessenger.getMessenger(UtilServer.getServerName()).transmitMessage(message, QueueConstant.SERVICE_MESSENGER_IDENTIFIER); Bukkit.broadcastMessage(F.main("Clans", "This Clans server will be restarting in " + F.elem(UtilTime.MakeStr(120000)) + "!")); UtilTextMiddle.display(C.cRed + "Server Restart", C.cGray + "This server will restart in " + F.elem(UtilTime.MakeStr(120000)) + "!"); _restartTime = System.currentTimeMillis() + 120000; @@ -170,6 +178,79 @@ public class RestartManager extends MiniPlugin } } + @EventHandler + public void onRestart(RestartServerEvent event) + { + event.setCancelled(true); + + if (_restarting || _restartTime != -1) + { + return; + } + + restart(); + } + + @EventHandler + public void onShutdownCommand(ServerCommandEvent event) + { + String command = event.getCommand().toLowerCase().trim(); + if (command.equals("stop") || command.startsWith("stop ")) + { + if (UtilServer.isTestServer() && command.endsWith(" -f")) + { + return; + } + + event.setCancelled(true); + + if (_restarting || _restartTime != -1) + { + return; + } + + restart(); + } + } + + @EventHandler + public void onShutdownCommand(PlayerCommandPreprocessEvent event) + { + String command = event.getMessage().toLowerCase().trim(); + if (command.startsWith("/") && command.length() > 1) + { + command = command.substring(1); + } + else + { + return; + } + + if (!command.equals("stop") && !command.startsWith("stop ")) + { + return; + } + + if (!event.getPlayer().isOp() && !event.getPlayer().hasPermission("bukkit.command.stop")) + { + return; + } + + if (UtilServer.isTestServer() && command.endsWith(" -f")) + { + return; + } + + event.setCancelled(true); + + if (_restarting || _restartTime != -1) + { + return; + } + + restart(); + } + @EventHandler public void checkRestart(UpdateEvent event) { 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 d2d472edf..a373d6b29 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 @@ -198,4 +198,4 @@ public enum ClansShopItem return null; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ShopItemButton.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ShopItemButton.java index 3e3a4e7b0..a4987b300 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ShopItemButton.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ShopItemButton.java @@ -14,7 +14,6 @@ import mineplex.core.common.util.InventoryUtil; import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; -import mineplex.core.recharge.Recharge; import mineplex.core.shop.item.IButton; import mineplex.core.shop.page.ShopPageBase; import mineplex.game.clans.clans.event.ClansPlayerBuyItemEvent; @@ -57,10 +56,6 @@ public class ShopItemButton> implements IButton @Override public void onClick(final Player player, ClickType clickType) { - if (!Recharge.Instance.use(player, "Attempt Buy Clans Shop Item", 1500, false, false)) - { - return; - } boolean shiftClick = (clickType == ClickType.SHIFT_LEFT || clickType == ClickType.SHIFT_RIGHT); if (clickType == ClickType.SHIFT_RIGHT || clickType == ClickType.RIGHT) @@ -184,4 +179,4 @@ public class ShopItemButton> implements IButton item.setAmount(amount); player.getInventory().addItem(item); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/pvp/PvpShop.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/pvp/PvpShop.java index 3bbd382b0..e4367cd3a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/pvp/PvpShop.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/pvp/PvpShop.java @@ -19,4 +19,4 @@ public class PvpShop extends ShopBase { return new PvpPage(getPlugin(), this, getClientManager(), getDonationManager(), player); } -} +} \ No newline at end of file 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 efae5fd11..783146d1b 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 @@ -7,8 +7,8 @@ import mineplex.core.itemstack.ItemBuilder; import mineplex.core.shop.page.ShopPageBase; 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.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; @@ -39,7 +39,8 @@ public class TNTGenPage extends ShopPageBase if (clan.getGenerator() == null) { - addButton(13, new ItemBuilder(Material.BREWING_STAND_ITEM).setTitle(C.cRed + "Buy TNT Generator").setLore(" ", C.cYellow + ClansShopItem.TNT_GENERATOR.getBuyPrice() + " Gold").build(), (player, click) -> { + addButton(13, new ItemBuilder(Material.BREWING_STAND_ITEM).setTitle(C.cRed + "Buy TNT Generator").setLore(" ", C.cYellow + ClansShopItem.TNT_GENERATOR.getBuyPrice() + " Gold").build(), (player, click) -> + { clearPage(); buildPage(); @@ -54,13 +55,22 @@ public class TNTGenPage extends ShopPageBase 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") + ".")); - clan.inform(F.main("Clans", F.elem(player.getName()) + " purchased a " + F.elem("TNT Generator") + " for the Clan. You can now access it from the " + F.elem("PvP Shop") + "."), player.getName()); - - TntGenerator generator = new TntGenerator(player.getUniqueId().toString()); - clan.setGenerator(generator); - _plugin.getClanDataAccess().updateGenerator(clan, null); + GoldManager.getInstance().deductGold(success -> + { + if (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") + ".")); + clan.inform(F.main("Clans", F.elem(player.getName()) + " purchased a " + F.elem("TNT Generator") + " for the Clan. You can now access it from the " + F.elem("PvP Shop") + "."), player.getName()); + + TntGenerator generator = new TntGenerator(player.getUniqueId().toString()); + clan.setGenerator(generator); + _plugin.getClanDataAccess().updateGenerator(clan, null); + } + else + { + UtilPlayer.message(player, F.main("Clans", "You can not afford to purchase a " + F.elem("TNT Generator") + " for your Clan.")); + _player.playSound(player.getLocation(), Sound.NOTE_BASS, 1, 1); + } }, player, ClansShopItem.TNT_GENERATOR.getBuyPrice()); } else @@ -92,9 +102,10 @@ public class TNTGenPage extends ShopPageBase " ", C.cWhite + "Purchased by " + F.elem(clan.getMembers().get(generator.getBuyer()).getPlayerName()), " ", - C.cWhite + "TNT Available: " + F.elem(Integer.valueOf(generator.getStock())), + C.cWhite + "TNT Available: " + F.elem(generator.getStock()), " ", - C.cWhite + "Next TNT: " + F.elem(nextTnt)).build(), (player, click) -> { + C.cWhite + "Next TNT: " + F.elem(nextTnt)).build(), (player, click) -> + { clearPage(); buildPage(); } @@ -106,7 +117,7 @@ public class TNTGenPage extends ShopPageBase .setTitle(C.cGreen + "TNT Generator") .setLore( " ", - C.cWhite + "TNT Available: " + F.elem(Integer.valueOf(generator.getStock())), + C.cWhite + "TNT Available: " + F.elem(generator.getStock()), " ", C.cWhite + "Next TNT: " + F.elem(nextTnt)).build(), (player, click) -> { @@ -125,7 +136,8 @@ public class TNTGenPage extends ShopPageBase for (int index : indices) { - addButton(index, new ItemBuilder(Material.TNT).setTitle(C.cGreen + "Retrieve TNT").setLore(" ", "Click to collect this TNT.").build(), (player, click) -> { + addButton(index, new ItemBuilder(Material.TNT).setTitle(C.cGreen + "Retrieve TNT").setLore(" ", "Click to collect this TNT.").build(), (player, click) -> + { clearPage(); buildPage(); 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 1a1524f42..161584f22 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 @@ -457,22 +457,22 @@ public class Spawn extends MiniPlugin public static Location getWestTown() { - return new Location(getSpawnWorld(), -440.91, 67, 23.08); + return new Location(getSpawnWorld(), -440.91, 72, 23.08); } public static Location getWestTownCenter() { - return new Location(getSpawnWorld(), -425, 72, 8); + return new Location(getSpawnWorld(), -425, 73, 8); } public static Location getEastTown() { - return new Location(getSpawnWorld(), 440.91, 63, -23.08); + return new Location(getSpawnWorld(), 440.91, 64, -23.08); } public static Location getEastTownCenter() { - return new Location(getSpawnWorld(), 425, 63, -8); + return new Location(getSpawnWorld(), 425, 65, -8); } public static Location getNorthSpawn() diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/AttackEnemyObjective.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/AttackEnemyObjective.java index 2bf5e0555..705c3cfee 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/AttackEnemyObjective.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/AttackEnemyObjective.java @@ -141,14 +141,15 @@ public class AttackEnemyObjective extends OrderedObjective EnclosedObject kill = new EnclosedObject<>(Boolean.FALSE); - _shooters.get(player.getName()).forEach(shooter -> { + _shooters.get(player.getName()).forEach(shooter -> + { if (player.getLocation().distance(shooter.getLocation()) < 5) { kill.Set(Boolean.TRUE); } }); - if (kill.Get().booleanValue()) + if (kill.Get()) { _shooters.get(player.getName()).forEach(shooter -> { UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, shooter.getLocation().add(0, .5, 0), new Vector(0d, 0d, 0d), 0.2f, 15, ViewDist.MAX, player); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/HoldItemGoal.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/HoldItemGoal.java index dde20c741..2f504a8ab 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/HoldItemGoal.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/HoldItemGoal.java @@ -14,7 +14,7 @@ import mineplex.game.clans.tutorial.objective.ObjectiveGoal; public class HoldItemGoal extends ObjectiveGoal> { - private DefaultHashMap> _ticksHeld = new DefaultHashMap<>(key -> new EnclosedObject<>(Integer.valueOf(0))); + private DefaultHashMap> _ticksHeld = new DefaultHashMap<>(key -> new EnclosedObject<>(0)); private Material _material; private long _holdTicks; @@ -63,13 +63,13 @@ public class HoldItemGoal extends ObjectiveGoal> return; } - _ticksHeld.get(player.getName()).Set(Integer.valueOf(_ticksHeld.get(player.getName()).Get().intValue() + 1)); + _ticksHeld.get(player.getName()).Set(_ticksHeld.get(player.getName()).Get() + 1); - if (_ticksHeld.get(player.getName()).Get().intValue() >= 80) + if (_ticksHeld.get(player.getName()).Get() >= 80) { finish(player); } } }); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/attackenemy/BlowUpWallGoal.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/attackenemy/BlowUpWallGoal.java index b4010c28a..756c26a42 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/attackenemy/BlowUpWallGoal.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/attackenemy/BlowUpWallGoal.java @@ -1,6 +1,7 @@ package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.attackenemy; import java.util.HashMap; +import java.util.Map; import org.bukkit.DyeColor; import org.bukkit.Location; @@ -11,7 +12,6 @@ import org.bukkit.entity.Zombie; import org.bukkit.event.EventHandler; 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.fallingblock.FallingBlocks; @@ -64,7 +64,7 @@ public class BlowUpWallGoal extends ObjectiveGoal double radius = 5.2; - HashMap blockList = new HashMap(); + Map blockList = new HashMap<>(); int iR = (int) radius + 1; for (int x = -iR; x <= iR; x++) @@ -91,7 +91,7 @@ public class BlowUpWallGoal extends ObjectiveGoal || block.getType() == Material.SMOOTH_STAIRS || block.getType() == Material.IRON_DOOR_BLOCK) - if (Math.random() < 0.2 + (dist.doubleValue() / 2.55) || dist.doubleValue() < 1.75) + if (Math.random() < 0.2 + (dist / 2.55) || dist < 1.75) { block.setType(Material.AIR, false); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/fields/IdentifyFieldsGoal.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/fields/IdentifyFieldsGoal.java index a4c9186e4..e1d92f26d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/fields/IdentifyFieldsGoal.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/fields/IdentifyFieldsGoal.java @@ -9,14 +9,12 @@ import mineplex.core.common.DefaultHashMap; import mineplex.core.common.util.EnclosedObject; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import mineplex.game.clans.clans.map.events.PlayerGetMapEvent; import mineplex.game.clans.tutorial.objective.ObjectiveGoal; -import mineplex.game.clans.tutorial.tutorials.clans.objective.AttackEnemyObjective; import mineplex.game.clans.tutorial.tutorials.clans.objective.FieldsObjective; public class IdentifyFieldsGoal extends ObjectiveGoal { - private DefaultHashMap> _ticksHeld = new DefaultHashMap<>(key -> new EnclosedObject<>(Integer.valueOf(0))); + private DefaultHashMap> _ticksHeld = new DefaultHashMap<>(key -> new EnclosedObject<>(0)); public IdentifyFieldsGoal(FieldsObjective objective) { @@ -42,7 +40,8 @@ public class IdentifyFieldsGoal extends ObjectiveGoal return; } - getActivePlayers().forEach(uuid -> { + getActivePlayers().forEach(uuid -> + { Player player = Bukkit.getPlayer(uuid); if (player != null && player.isOnline()) @@ -52,13 +51,13 @@ public class IdentifyFieldsGoal extends ObjectiveGoal return; } - _ticksHeld.get(player.getName()).Set(Integer.valueOf(_ticksHeld.get(player.getName()).Get().intValue() + 1)); + _ticksHeld.get(player.getName()).Set(_ticksHeld.get(player.getName()).Get() + 1); - if (_ticksHeld.get(player.getName()).Get().intValue() >= 80) + if (_ticksHeld.get(player.getName()).Get() >= 80) { finish(player); } } }); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/repository/TutorialRepository.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/repository/TutorialRepository.java index a81ababe2..e7d764742 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/repository/TutorialRepository.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/repository/TutorialRepository.java @@ -30,7 +30,8 @@ public class TutorialRepository extends RepositoryBase public void SetTimesPlayed(UUID uuid, int timesPlayed) { // Prevent duplicate entries for individuals - executeQuery(GET, result -> { + executeQuery(GET, result -> + { if (result.next()) executeUpdate(UPDATE, new ColumnInt("timesPlayed", timesPlayed), new ColumnVarChar("uuid", 36, uuid.toString())); else @@ -42,14 +43,15 @@ public class TutorialRepository extends RepositoryBase { EnclosedObject status = new EnclosedObject<>(); - executeQuery(GET, result -> { + executeQuery(GET, result -> + { if (result.next()) - status.Set(Integer.valueOf(result.getInt("timesPlayed"))); + status.Set(result.getInt("timesPlayed")); else - status.Set(Integer.valueOf(0)); + status.Set(0); }, new ColumnVarChar("uuid", 36, uuid.toString())); - return status.Get().intValue(); + return status.Get(); } public int GetTimesPlayed(String name) @@ -61,4 +63,4 @@ public class TutorialRepository extends RepositoryBase { executeUpdate(CREATE_TABLE); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub.Clans/pom.xml b/Plugins/Mineplex.Hub.Clans/pom.xml index b5bc14c36..8da5f3fc8 100644 --- a/Plugins/Mineplex.Hub.Clans/pom.xml +++ b/Plugins/Mineplex.Hub.Clans/pom.xml @@ -23,6 +23,11 @@ ${project.groupId} mineplex-minecraft-game-core ${project.version} + + + ${project.groupId} + mineplex-clansqueue-common + ${project.version} diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java index 39f6d223f..4e600a733 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java @@ -1,5 +1,7 @@ package mineplex.clanshub; +import static mineplex.core.Managers.require; + import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.plugin.java.JavaPlugin; @@ -65,8 +67,6 @@ import mineplex.minecraft.game.core.combat.CombatManager; import mineplex.minecraft.game.core.condition.ConditionManager; import mineplex.minecraft.game.core.damage.DamageManager; -import static mineplex.core.Managers.require; - /** * Main class for clans hub */ @@ -98,7 +98,8 @@ public class ClansHub extends JavaPlugin // new ProfileCacheManager(this); ItemStackFactory.Initialize(this, false); Recharge.Initialize(this); - VisibilityManager.Initialize(this); Give.Initialize(this); + require(VisibilityManager.class); + Give.Initialize(this); Punish punish = new Punish(this, clientManager); BlockRestore blockRestore = require(BlockRestore.class); DonationManager donationManager = require(DonationManager.class); @@ -155,7 +156,7 @@ public class ClansHub extends JavaPlugin BoosterManager boosterManager = new BoosterManager(this, "", clientManager, donationManager, inventoryManager, thankManager); HubManager hubManager = new HubManager(this, blockRestore, clientManager, incognito, donationManager, inventoryManager, condition, disguiseManager, new TaskManager(this, clientManager), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, hologramManager, npcManager, packetHandler, punish, serverStatusManager, customDataManager, thankManager, boosterManager, castleManager); - ClansTransferManager serverManager = new ClansTransferManager(this, clientManager, donationManager, partyManager, portal, hubManager); + ClansTransferManager serverManager = new ClansTransferManager(this, clientManager, donationManager, partyManager, portal); Chat chat = new Chat(this, incognito, clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName()); new MessageManager(this, incognito, clientManager, preferenceManager, ignoreManager, punish, friendManager, chat); diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansServerPage.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansServerPage.java index 3288e0487..3e301fe9b 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansServerPage.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansServerPage.java @@ -5,6 +5,7 @@ import java.util.Collection; import org.bukkit.Material; import org.bukkit.entity.Player; +import mineplex.clanshub.queue.HubQueueManager; import mineplex.core.Managers; import mineplex.core.account.CoreClientManager; import mineplex.core.common.util.C; @@ -22,6 +23,8 @@ import mineplex.game.clans.core.repository.tokens.SimpleClanToken; */ public class ClansServerPage extends ShopPageBase { + private final HubQueueManager _queue = Managers.require(HubQueueManager.class); + public ClansServerPage(ClansTransferManager plugin, ClansServerShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player) { @@ -80,7 +83,33 @@ public class ClansServerPage extends ShopPageBase servers = UtilAlg.sortSet(getPlugin().getServers(true), (o1, o2) -> { - return o1.Name.compareTo(o2.Name); + try + { + int server1; + int server2; + if (o1.Name.contains("-")) + { + server1 = Integer.parseInt(o1.Name.substring(o1.Name.lastIndexOf('-') + 1)); + } + else + { + server1 = Integer.parseInt(o1.Name); + } + if (o2.Name.contains("-")) + { + server2 = Integer.parseInt(o2.Name.substring(o2.Name.lastIndexOf('-') + 1)); + } + else + { + server2 = Integer.parseInt(o2.Name); + } + + return Integer.compare(server1, server2); + } + catch (NumberFormatException ex) + { + return o1.Name.compareTo(o2.Name); + } }); int currentSlot = 9; @@ -95,24 +124,33 @@ public class ClansServerPage extends ShopPageBase servers = UtilAlg.sortSet(getPlugin().getServers(true), (o1, o2) -> { - return o1.Name.compareTo(o2.Name); + try + { + int server1; + int server2; + if (o1.Name.contains("-")) + { + server1 = Integer.parseInt(o1.Name.substring(o1.Name.lastIndexOf('-') + 1)); + } + else + { + server1 = Integer.parseInt(o1.Name); + } + if (o2.Name.contains("-")) + { + server2 = Integer.parseInt(o2.Name.substring(o2.Name.lastIndexOf('-') + 1)); + } + else + { + server2 = Integer.parseInt(o2.Name); + } + + return Integer.compare(server1, server2); + } + catch (NumberFormatException ex) + { + return o1.Name.compareTo(o2.Name); + } }); int currentSlot = 27; diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansServerShop.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansServerShop.java index e56cdcda7..715f3d42a 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansServerShop.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansServerShop.java @@ -17,7 +17,7 @@ public class ClansServerShop extends ShopBase { public ClansServerShop(ClansTransferManager plugin, CoreClientManager clientManager, DonationManager donationManager) { - super(plugin, clientManager, donationManager, "Clans"); + super(plugin, clientManager, donationManager, "Clans Servers"); } @Override diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansTransferManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansTransferManager.java index 92461c015..d1a8d0495 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansTransferManager.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansTransferManager.java @@ -1,5 +1,6 @@ package mineplex.clanshub; +import java.lang.reflect.Field; import java.sql.ResultSet; import java.sql.SQLException; import java.util.HashMap; @@ -7,21 +8,22 @@ import java.util.List; import java.util.Map; import java.util.UUID; -import org.bukkit.Sound; +import org.apache.commons.lang.ArrayUtils; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; 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; +import com.mineplex.ProtocolVersion; +import mineplex.clanshub.queue.HubQueueManager; import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.Permission; import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.common.util.C; import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; import mineplex.core.donation.DonationManager; @@ -47,26 +49,42 @@ public class ClansTransferManager extends MiniDbClientPlugin { STAFF_PAGE, ALLOW_HARDCORE, - JOIN_FULL, + } + + private static final int[] PERMITTED_VERSIONS = {ProtocolVersion.v1_8, ProtocolVersion.v1_12, ProtocolVersion.v1_12_1, ProtocolVersion.v1_12_2}; + private static final Map VERSION_NAMES = new HashMap<>(); + + static + { + for (Field field : ProtocolVersion.class.getFields()) + { + try + { + int protocol = field.getInt(null); + String version = field.getName().replace("v", "").replace("_", "."); + + VERSION_NAMES.put(protocol, version); + } + catch (ReflectiveOperationException ex) {} + } } private static final long SERVER_RELOAD_INTERVAL = 5000; private PartyManager _party; private Portal _portal; - private HubManager _hub; private Region _region; private final Map _servers = new HashMap<>(); private boolean _loading = false; private long _lastLoaded; private ClansServerShop _serverShop; + private final HubQueueManager _queue = require(HubQueueManager.class); - public ClansTransferManager(JavaPlugin plugin, CoreClientManager client, DonationManager donation, PartyManager party, Portal portal, HubManager hub) + public ClansTransferManager(JavaPlugin plugin, CoreClientManager client, DonationManager donation, PartyManager party, Portal portal) { 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); @@ -77,7 +95,21 @@ public class ClansTransferManager extends MiniDbClientPlugin { PermissionGroup.TRAINEE.setPermission(Perm.STAFF_PAGE, true, true); PermissionGroup.TRAINEE.setPermission(Perm.ALLOW_HARDCORE, true, true); - PermissionGroup.ULTRA.setPermission(Perm.JOIN_FULL, true, true); + PermissionGroup.CONTENT.setPermission(Perm.ALLOW_HARDCORE, true, true); + } + + private boolean checkCanJoinClans(Player player) + { + int protocol = ((CraftPlayer)player).getHandle().getProtocol(); + if (ArrayUtils.contains(PERMITTED_VERSIONS, protocol)) + { + return true; + } + + UtilPlayer.message(player, F.main(getName(), "Minecraft Version " + VERSION_NAMES.get(protocol) + " is not supported on Mineplex Clans.\n" + + C.cGray + "Please change your Minecraft version to 1.8.8 or 1.12+ and reconnect!")); + + return false; } /** @@ -98,7 +130,7 @@ public class ClansTransferManager extends MiniDbClientPlugin List servers = Lists.newArrayList(); for (ServerInfo info : _servers.values()) { - if (!info.MOTD.equalsIgnoreCase("Restarting soon") || !onlineOnly) + if (!(info.MOTD.equalsIgnoreCase("Restarting soon") || _queue.getData(info) == null) || !onlineOnly) { servers.add(info); } @@ -115,7 +147,7 @@ public class ClansTransferManager extends MiniDbClientPlugin { for (ServerInfo server : _servers.values()) { - if (server.Name.equalsIgnoreCase(name) && !server.MOTD.equalsIgnoreCase("Restarting soon")) + if (server.Name.equalsIgnoreCase(name) && !server.MOTD.equalsIgnoreCase("Restarting soon") && _queue.getData(server) != null) { return server; } @@ -142,19 +174,6 @@ 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) - { - player.leaveVehicle(); - player.eject(); - - _portal.sendPlayerToServer(player, serverInfo.Name, Intent.PLAYER_REQUEST); - } - @EventHandler public void reloadServers(UpdateEvent event) { @@ -163,13 +182,10 @@ public class ClansTransferManager extends MiniDbClientPlugin return; } _loading = true; - final Runnable after = new Runnable() + final Runnable after = () -> { - public void run() - { - _lastLoaded = System.currentTimeMillis(); - _loading = false; - } + _lastLoaded = System.currentTimeMillis(); + _loading = false; }; runAsync(() -> { @@ -190,61 +206,15 @@ public class ClansTransferManager extends MiniDbClientPlugin }); } - @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 (_party.getPartyByPlayer(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)) - { - 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 (checkCanJoinClans(event.getPlayer())) + { + _serverShop.attemptShopOpen(event.getPlayer()); + } } if (event.getNpc().getName().contains("Return")) { @@ -261,9 +231,12 @@ public class ClansTransferManager extends MiniDbClientPlugin } Player player = (Player) event.getDamager(); - if (event.getNpc().getName().contains("Clans") && Recharge.Instance.use(player, "Go to Clans", 1000, false, false)) + if (event.getNpc().getName().contains("Clans") && Recharge.Instance.use(player, "Go to Clans", 1000, false, false)) { - _serverShop.attemptShopOpen(player); + if (checkCanJoinClans(player)) + { + _serverShop.attemptShopOpen(player); + } } if (event.getNpc().getName().contains("Return") && Recharge.Instance.use(player, "Return to Mineplex", 1000, false, false)) { diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java index 017a243d1..b42990ad2 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java @@ -6,13 +6,6 @@ import java.util.Iterator; import java.util.List; import java.util.Map; -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; @@ -125,6 +118,12 @@ 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; /** * Main manager for clans hub @@ -292,7 +291,8 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter } } - scoreboard.register(HubScoreboardLine.SERVER_TITLE) + scoreboard.register(HubScoreboardLine.START_EMPTY_SPACER) + .register(HubScoreboardLine.SERVER_TITLE) .register(HubScoreboardLine.SERVER_NAME) .register(HubScoreboardLine.SERVER_EMPTY_SPACER) .register(HubScoreboardLine.PLAYER_TITLE) @@ -303,7 +303,6 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter .register(HubScoreboardLine.RANK_EMPTY_SPACER) .register(HubScoreboardLine.WEBSITE_TITLE) .register(HubScoreboardLine.WEBSITE_VALUE) - .register(HubScoreboardLine.END_EMPTY_SPACER) .recalculate(); scoreboard.get(HubScoreboardLine.SERVER_TITLE).write(C.cAqua + C.Bold + "Server"); diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubScoreboardLine.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubScoreboardLine.java index 89601dc4a..4d68ebebc 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubScoreboardLine.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubScoreboardLine.java @@ -4,6 +4,7 @@ import mineplex.core.scoreboard.ScoreboardLine; public enum HubScoreboardLine implements ScoreboardLine { + START_EMPTY_SPACER, SERVER_TITLE, SERVER_NAME, SERVER_EMPTY_SPACER, @@ -14,6 +15,5 @@ public enum HubScoreboardLine implements ScoreboardLine RANK_NAME, RANK_EMPTY_SPACER, WEBSITE_TITLE, - WEBSITE_VALUE, - END_EMPTY_SPACER; + WEBSITE_VALUE; } \ 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 index 33e33f7bb..3946b8367 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubVisibilityManager.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubVisibilityManager.java @@ -6,6 +6,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerQuitEvent; +import mineplex.core.Managers; import mineplex.core.MiniPlugin; import mineplex.core.account.permissions.Permission; import mineplex.core.account.permissions.PermissionGroup; @@ -74,7 +75,9 @@ public class HubVisibilityManager extends MiniPlugin { if (event.getType() != UpdateType.SEC) return; - + + VisibilityManager vm = Managers.get(VisibilityManager.class); + for (Player player : UtilServer.getPlayers()) { boolean hideMe = UtilMath.offset2d(player.getLocation(), Manager.GetSpawn()) == 0 || @@ -92,11 +95,11 @@ public class HubVisibilityManager extends MiniPlugin if (localHideMe || !Manager.getPreferences().get(other).isActive(Preference.SHOW_PLAYERS)) { - VisibilityManager.Instance.setVisibility(player, false, other); + vm.hidePlayer(other, player, "Hub Visibility Manager"); } else { - VisibilityManager.Instance.setVisibility(player, true, other); + vm.showPlayer(other, player, "Hub Visibility Manager"); } } } diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/JoinServerButton.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/JoinServerButton.java index 2c15ae64d..b36467ec6 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/JoinServerButton.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/JoinServerButton.java @@ -3,6 +3,8 @@ package mineplex.clanshub; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; +import mineplex.clanshub.queue.HubQueueManager; +import mineplex.core.Managers; import mineplex.core.shop.item.IButton; import mineplex.core.shop.page.ShopPageBase; @@ -12,13 +14,12 @@ import mineplex.core.shop.page.ShopPageBase; public class JoinServerButton implements IButton { private ShopPageBase _page; - private ClansTransferManager _transferManager; private ServerInfo _serverInfo; + private final HubQueueManager _queue = Managers.require(HubQueueManager.class); - public JoinServerButton(ShopPageBase page, ClansTransferManager transferManager, ServerInfo serverInfo) + public JoinServerButton(ShopPageBase page, ServerInfo serverInfo) { _page = page; - _transferManager = transferManager; _serverInfo = serverInfo; } @@ -37,16 +38,13 @@ public class JoinServerButton implements IButton { if (serverInfo != null) { - System.out.println("Selecting server :" + serverInfo.Name); - int slots = 1; - - if (serverInfo.getAvailableSlots() < slots && !_page.getClientManager().Get(player).hasPermission(ClansTransferManager.Perm.JOIN_FULL)) + if (_queue.Get(player).TargetServer == null || !_queue.Get(player).TargetServer.equals(serverInfo.Name)) { - _page.playDenySound(player); + _queue.attemptEnterQueue(player, _queue.getData(serverInfo)); } else { - _transferManager.selectServer(player, serverInfo); + _queue.leaveQueue(player, true); } } else diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/queue/HubQueueManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/queue/HubQueueManager.java new file mode 100644 index 000000000..83fad6f86 --- /dev/null +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/queue/HubQueueManager.java @@ -0,0 +1,361 @@ +package mineplex.clanshub.queue; + +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.UUID; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.PlayerQuitEvent; + +import com.mineplex.clansqueue.common.ClansQueueMessenger; +import com.mineplex.clansqueue.common.QueueConstant; +import com.mineplex.clansqueue.common.messages.PlayerJoinQueueCallbackMessage; +import com.mineplex.clansqueue.common.messages.PlayerJoinQueueMessage; +import com.mineplex.clansqueue.common.messages.PlayerLeaveQueueMessage; +import com.mineplex.clansqueue.common.messages.PlayerSendToServerMessage; +import com.mineplex.clansqueue.common.messages.QueueDeleteMessage; +import com.mineplex.clansqueue.common.messages.QueuePauseBroadcastMessage; +import com.mineplex.clansqueue.common.messages.QueuePauseUpdateMessage; +import com.mineplex.clansqueue.common.messages.QueueStatusMessage; + +import mineplex.clanshub.ClansTransferManager; +import mineplex.clanshub.ServerInfo; +import mineplex.clanshub.queue.data.ClansQueueData; +import mineplex.clanshub.queue.data.QueuePlayerData; +import mineplex.core.Managers; +import mineplex.core.MiniClientPlugin; +import mineplex.core.ReflectivelyCreateMiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.Permission; +import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.command.CommandBase; +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.util.UtilTime.TimeUnit; +import mineplex.core.portal.Intent; +import mineplex.core.portal.Portal; +import mineplex.core.portal.events.ServerTransferEvent; +import mineplex.core.punish.clans.ClansBanManager; +import mineplex.core.recharge.Recharge; + +@ReflectivelyCreateMiniPlugin +public class HubQueueManager extends MiniClientPlugin +{ + public enum Perm implements Permission + { + JOIN_PAUSED_QUEUE, + TOGGLE_QUEUE_PAUSE, + LIST_QUEUES, + } + + public enum QueuePriority implements Permission + { + BYPASS(-1, PermissionGroup.CONTENT, PermissionGroup.TRAINEE), + PRIORITY(7, PermissionGroup.BUILDER), + ETERNAL(6, PermissionGroup.ETERNAL), + TITAN(5, PermissionGroup.TITAN), + LEGEND(4, PermissionGroup.LEGEND), + HERO(3, PermissionGroup.HERO), + ULTRA(2, PermissionGroup.ULTRA), + DEFAULT(1, PermissionGroup.PLAYER) + ; + + private final int _weight; + private final List _granted; + + private QueuePriority(int weight, PermissionGroup... granted) + { + _weight = weight; + _granted = Collections.unmodifiableList(Arrays.asList(granted)); + } + + public int getWeight() + { + return _weight; + } + + public List getGranted() + { + return _granted; + } + } + + private final CoreClientManager _clientManager = require(CoreClientManager.class); + private final ClansBanManager _punish = require(ClansBanManager.class); + private final Portal _portal = require(Portal.class); + private final Comparator _prioritySorter = (q1, q2) -> + { + if (q1.getWeight() == -1 && q2.getWeight() != -1) + { + return -1; + } + if (q2.getWeight() == -1 && q1.getWeight() != -1) + { + return 1; + } + + return Integer.compare(q1.getWeight(), q2.getWeight()); + }; + private final Map _queueData = new HashMap<>(); + private final ClansQueueMessenger _messenger; + + private HubQueueManager() + { + super("Queue Manager"); + + generatePermissions(); + _messenger = ClansQueueMessenger.getMessenger(UtilServer.getServerName()); + + _messenger.registerListener(PlayerJoinQueueCallbackMessage.class, (callback, origin) -> + { + runSync(() -> + { + Player player = Bukkit.getPlayer(callback.PlayerUUID); + if (player != null) + { + QueuePlayerData data = Get(player); + data.Queued = true; + data.QueuePosition = callback.Position; + UtilPlayer.message(player, F.main(getName(), "You have joined the queue for server " + F.elem(data.TargetServer) + "! Your position: " + F.greenElem("#" + data.QueuePosition))); + } + }); + }); + _messenger.registerListener(PlayerSendToServerMessage.class, (callback, origin) -> + { + runSync(() -> + { + Player player = Bukkit.getPlayer(callback.PlayerUUID); + if (player != null) + { + Get(player).Queued = false; + player.leaveVehicle(); + player.eject(); + _portal.sendPlayerToServer(player, callback.TargetServer, Intent.FORCE_TRANSFER); + } + }); + }); + _messenger.registerListener(QueueStatusMessage.class, (status, origin) -> + { + runSync(() -> + { + status.Snapshots.forEach(snapshot -> + { + ClansQueueData data = _queueData.computeIfAbsent(snapshot.ServerName, (name) -> new ClansQueueData(name)); + + data.QueueMembers = snapshot.Queue.size(); + data.QueuePaused = snapshot.Paused; + snapshot.Queue.entrySet().forEach(entry -> + { + Player player = Bukkit.getPlayer(entry.getKey()); + if (player != null) + { + Get(player).QueuePosition = entry.getValue(); + if (Recharge.Instance.use(player, "Queue Status Update", 7000, false, false)) + { + UtilPlayer.message(player, F.main(getName(), "Your position: " + F.greenElem("#" + entry.getValue()))); + } + } + }); + }); + }); + }); + _messenger.registerListener(QueuePauseBroadcastMessage.class, (broadcast, origin) -> + { + runSync(() -> + { + ClansQueueData data = _queueData.computeIfAbsent(broadcast.ServerName, (name) -> new ClansQueueData(name)); + data.QueuePaused = broadcast.Paused; + GetValues().forEach(qp -> + { + if (qp.TargetServer != null && qp.TargetServer.equals(broadcast.ServerName)) + { + UtilPlayer.message(Bukkit.getPlayer(qp.UniqueId), F.main(getName(), "Queue pause status: " + F.elem(broadcast.Paused))); + } + }); + }); + }); + _messenger.registerListener(QueueDeleteMessage.class, (delete, origin) -> + { + runSync(() -> + { + GetValues().forEach(qp -> + { + if (qp.TargetServer != null && qp.TargetServer.equals(delete.ServerName)) + { + UtilPlayer.message(Bukkit.getPlayer(qp.UniqueId), F.main(getName(), "Queue deleted.")); + } + qp.Queued = false; + qp.QueuePosition = 0; + qp.TargetServer = null; + }); + _queueData.remove(delete.ServerName); + }); + }); + addCommand(new CommandBase(this, Perm.TOGGLE_QUEUE_PAUSE, "pausequeue") + { + @Override + public void Execute(Player caller, String[] args) + { + if (args.length < 1) + { + UtilPlayer.message(caller, F.main(getName(), "Usage: /pausequeue ")); + return; + } + ServerInfo info = Managers.get(ClansTransferManager.class).getServer(args[0]); + if (info != null) + { + ClansQueueData data = getData(info); + if (data != null) + { + QueuePauseUpdateMessage message = new QueuePauseUpdateMessage(); + message.ServerName = data.ServerName; + message.Paused = !data.QueuePaused; + _messenger.transmitMessage(message, QueueConstant.SERVICE_MESSENGER_IDENTIFIER); + UtilPlayer.message(caller, F.main(getName(), "Toggling queue pause")); + return; + } + } + UtilPlayer.message(caller, F.main(getName(), "Queue not found")); + } + }); + addCommand(new CommandBase(this, Perm.LIST_QUEUES, "listqueues") + { + @Override + public void Execute(Player caller, String[] args) + { + StringBuilder queues = new StringBuilder("Queues: ["); + queues.append(_queueData.values().stream().map(data -> data.ServerName).collect(Collectors.joining(", "))); + queues.append(']'); + UtilPlayer.message(caller, F.main(getName(), queues.toString())); + } + }); + } + + private void generatePermissions() + { + for (QueuePriority priority : QueuePriority.values()) + { + priority.getGranted().forEach(group -> group.setPermission(priority, true, true)); + } + PermissionGroup.ADMIN.setPermission(Perm.JOIN_PAUSED_QUEUE, true, true); + PermissionGroup.ADMIN.setPermission(Perm.LIST_QUEUES, true, true); + PermissionGroup.ADMIN.setPermission(Perm.TOGGLE_QUEUE_PAUSE, true, true); + } + + public QueuePriority getHighestPriority(Player player) + { + Optional opt = Stream.of(QueuePriority.values()).filter(_clientManager.Get(player)::hasPermission).sorted(_prioritySorter).findFirst(); + + if (opt.isPresent()) + { + return opt.get(); + } + + return QueuePriority.DEFAULT; + } + + public ClansQueueData getData(ServerInfo info) + { + return _queueData.get(info.Name); + } + + public void attemptEnterQueue(Player player, ClansQueueData data) + { + if (Get(player).TargetServer != null) + { + if (Get(player).Queued) + { + UtilPlayer.message(player, F.main(getName(), "You are already in a queue!")); + } + else + { + UtilPlayer.message(player, F.main(getName(), "You are already entering a queue!")); + } + return; + } + if (data.QueuePaused && !_clientManager.Get(player).hasPermission(Perm.JOIN_PAUSED_QUEUE)) + { + UtilPlayer.message(player, F.main(getName(), "That queue is paused and cannot currently be joined!")); + return; + } + Get(player).TargetServer = data.ServerName; + _punish.loadClient(player.getUniqueId(), client -> + { + if (client.isBanned()) + { + Get(player).TargetServer = null; + String time = UtilTime.convertString(client.getLongestBan().getTimeLeft(), 0, TimeUnit.FIT); + + if (client.getLongestBan().isPermanent()) + { + time = "Permanent"; + } + + String reason = C.cRedB + "You are banned from Clans for " + time + + "\n" + C.cWhite + client.getLongestBan().getReason(); + UtilPlayer.message(player, reason); + } + else + { + QueuePriority priority = getHighestPriority(player); + PlayerJoinQueueMessage message = new PlayerJoinQueueMessage(); + message.PlayerUUID = player.getUniqueId(); + message.TargetServer = data.ServerName; + message.PlayerPriority = priority.getWeight(); + _messenger.transmitMessage(message, QueueConstant.SERVICE_MESSENGER_IDENTIFIER); + UtilPlayer.message(player, F.main(getName(), "Joining queue...")); + } + }); + } + + public void leaveQueue(Player player, boolean informFailure) + { + if (!Get(player).Queued) + { + if (informFailure) + { + UtilPlayer.message(player, F.main(getName(), "You are not part of a queue!")); + } + return; + } + PlayerLeaveQueueMessage message = new PlayerLeaveQueueMessage(); + message.PlayerUUID = player.getUniqueId(); + message.TargetServer = Get(player).TargetServer; + _messenger.transmitMessage(message, QueueConstant.SERVICE_MESSENGER_IDENTIFIER); + Get(player).TargetServer = null; + Get(player).QueuePosition = 0; + Get(player).Queued = false; + UtilPlayer.message(player, F.main(getName(), "You have left the queue for " + F.elem(message.TargetServer) + "!")); + } + + @EventHandler + public void onQuit(PlayerQuitEvent event) + { + leaveQueue(event.getPlayer(), false); + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onTransfer(ServerTransferEvent event) + { + leaveQueue(event.getPlayer(), false); + } + + @Override + protected QueuePlayerData addPlayer(UUID uuid) + { + return new QueuePlayerData(uuid); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/queue/data/ClansQueueData.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/queue/data/ClansQueueData.java new file mode 100644 index 000000000..4512e409e --- /dev/null +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/queue/data/ClansQueueData.java @@ -0,0 +1,30 @@ +package mineplex.clanshub.queue.data; + +public class ClansQueueData +{ + public final String ServerName; + public int QueueMembers; + public boolean QueuePaused; + + public ClansQueueData(String serverName) + { + ServerName = serverName; + } + + @Override + public int hashCode() + { + return ServerName.hashCode(); + } + + @Override + public boolean equals(Object o) + { + if (o == null || !getClass().isInstance(o)) + { + return false; + } + + return ((ClansQueueData)o).ServerName.equals(ServerName); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/queue/data/QueuePlayerData.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/queue/data/QueuePlayerData.java new file mode 100644 index 000000000..c0b05f974 --- /dev/null +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/queue/data/QueuePlayerData.java @@ -0,0 +1,36 @@ +package mineplex.clanshub.queue.data; + +import java.util.UUID; + +public class QueuePlayerData +{ + public final UUID UniqueId; + + public boolean Queued; + + public int QueuePosition; + + public String TargetServer; + + public QueuePlayerData(UUID uuid) + { + UniqueId = uuid; + } + + @Override + public boolean equals(Object o) + { + if (o == null || !getClass().isInstance(o)) + { + return false; + } + + return UniqueId.equals(((QueuePlayerData)o).UniqueId); + } + + @Override + public int hashCode() + { + return UniqueId.hashCode(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementManager.java index bdc080e69..d0b01ec54 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementManager.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementManager.java @@ -106,7 +106,7 @@ public class SalesAnnouncementManager extends MiniPlugin { runSync(() -> { - _data.remove(Integer.valueOf(id)); + _data.remove(id); UtilServer.CallEvent(new SalesAnnouncementRemoteListUpdateEvent()); }); } @@ -115,7 +115,7 @@ public class SalesAnnouncementManager extends MiniPlugin { runSync(() -> { - if (_data.containsKey(Integer.valueOf(id))) + if (_data.containsKey(id)) { _repo.loadAnnouncement(id, data -> { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index 6c235c8ad..66bdcdef1 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -92,7 +92,7 @@ public class Hub extends JavaPlugin implements IRelation ItemStackFactory.Initialize(this, false); Recharge.Initialize(this); - VisibilityManager.Initialize(this); + require(VisibilityManager.class); Give.Initialize(this); Punish punish = new Punish(this, clientManager); BlockRestore blockRestore = require(BlockRestore.class); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java index b96bef681..7df9da325 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java @@ -12,6 +12,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; +import mineplex.core.Managers; import mineplex.core.MiniPlugin; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; @@ -97,8 +98,17 @@ public class HubVisibilityManager extends MiniPlugin // Has preference AND is not close to the spawn AND has not just spawned boolean showOthers = Manager.getPreferences().get(perspective).isActive(Preference.SHOW_PLAYERS) && (!closeToSpawn || !justSpawned); - - VisibilityManager.Instance.setVisibility(subject, !hideMe && showOthers, perspective); + + VisibilityManager vm = Managers.get(VisibilityManager.class); + + if (!hideMe && showOthers) + { + vm.showPlayer(perspective, subject, "Hub Visibility Manager"); + } + else + { + vm.hidePlayer(perspective, subject, "Hub Visibility Manager"); + } } } } @@ -113,6 +123,7 @@ public class HubVisibilityManager extends MiniPlugin Player[] online = UtilServer.getPlayers(); Iterator iterator = _nextShownPlayer.keySet().iterator(); + VisibilityManager vm = Managers.get(VisibilityManager.class); while (iterator.hasNext()) { @@ -129,7 +140,7 @@ public class HubVisibilityManager extends MiniPlugin if (!perspective.equals(subject) && !shouldHide(subject)) { - VisibilityManager.Instance.setVisibility(subject, true, perspective); + vm.showPlayer(perspective, subject, "Hub Visibility Manager"); } _nextShownPlayer.put(perspective, ++index); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementManager.java index 8b4065196..cb35a67ab 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementManager.java @@ -107,7 +107,7 @@ public class SalesAnnouncementManager extends MiniPlugin { runSync(() -> { - _data.remove(Integer.valueOf(id)); + _data.remove(id); UtilServer.CallEvent(new SalesAnnouncementRemoteListUpdateEvent()); }); } @@ -116,7 +116,7 @@ public class SalesAnnouncementManager extends MiniPlugin { runSync(() -> { - if (_data.containsKey(Integer.valueOf(id))) + if (_data.containsKey(id)) { _repo.loadAnnouncement(id, data -> { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementRepository.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementRepository.java index f2fc92511..a7d0c5eda 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementRepository.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementRepository.java @@ -153,7 +153,7 @@ public class SalesAnnouncementRepository extends RepositoryBase { runAsync(() -> { - executeUpdate(UPDATE_ANNOUNCEMENT_STATUS, new ColumnBoolean("enabled", data.isEnabled()), new ColumnInt("id", data.getId().intValue())); + executeUpdate(UPDATE_ANNOUNCEMENT_STATUS, new ColumnBoolean("enabled", data.isEnabled()), new ColumnInt("id", data.getId())); if (after != null) { runSync(after); @@ -165,7 +165,7 @@ public class SalesAnnouncementRepository extends RepositoryBase { runAsync(() -> { - executeUpdate(DELETE_ANNOUNCEMENT, new ColumnInt("id", data.getId().intValue())); + executeUpdate(DELETE_ANNOUNCEMENT, new ColumnInt("id", data.getId())); if (after != null) { runSync(after); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java index 1b2244c1a..df0516404 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java @@ -65,12 +65,12 @@ public class ClientClass public void Load(ClientClassToken token) { - _customBuilds = new NautHashMap>(); - _activeCustomBuilds = new NautHashMap(); + _customBuilds = new NautHashMap<>(); + _activeCustomBuilds = new NautHashMap<>(); for (IPvpClass pvpClass : _classFactory.GetAllClasses()) { - _customBuilds.put(pvpClass, new HashMap()); + _customBuilds.put(pvpClass, new HashMap<>()); _customBuilds.get(pvpClass).put(0, pvpClass.getDefaultBuild()); } @@ -362,6 +362,8 @@ public class ClientClass _client.GetPlayer().sendMessage(F.main("Class", "You equipped " + F.skill(customBuild.Name) + ".")); } + + UtilServer.runSyncLater(() -> validateClassSkills(_client.GetPlayer()), 20L); } public void ListSkills(Player caller) 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 c74556fae..1f4add66d 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 @@ -1,6 +1,7 @@ package mineplex.minecraft.game.classcombat.Skill.Assassin; import java.util.HashMap; +import java.util.Map; import org.bukkit.Bukkit; import org.bukkit.Effect; @@ -8,32 +9,35 @@ import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.entity.Player; import org.bukkit.event.block.Action; import org.bukkit.potion.PotionEffectType; import org.bukkit.util.Vector; -import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; import mineplex.core.common.util.F; 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.core.common.util.UtilTime; import mineplex.core.common.util.UtilWorld; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; import mineplex.minecraft.game.classcombat.Skill.SkillActive; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; import mineplex.minecraft.game.classcombat.Skill.event.SkillTeleportEvent; +import net.minecraft.server.v1_8_R3.AxisAlignedBB; +import net.minecraft.server.v1_8_R3.Entity; public class Blink extends SkillActive { - private HashMap _loc = new HashMap(); - private HashMap _blinkTime = new HashMap(); + private Map _loc = new HashMap<>(); + private Map _blinkTime = new HashMap<>(); + private boolean _allowTrapping = false; public Blink(SkillFactory skills, String name, ClassType classType, SkillType skillType, int cost, int levels, @@ -60,6 +64,7 @@ public class Blink extends SkillActive }); } + @SuppressWarnings("deprecation") @Override public boolean CustomCheck(Player player, int level) { @@ -83,6 +88,7 @@ public class Blink extends SkillActive //Deblink if (_loc.containsKey(player) && _blinkTime.containsKey(player)) + { if (!UtilTime.elapsed(_blinkTime.get(player), 5000)) { //Require 500ms after blink to deblink @@ -90,34 +96,42 @@ public class Blink extends SkillActive Deblink(player, level); return false; - } + } + } return true; } - - @Override - public void Skill(Player player, int level) + + public void blinky(Player player) { - //Smoke Trail - Block lastSmoke = player.getLocation().getBlock(); - + Location start = player.getLocation().add(new Vector(0, 0.2, 0)); + Location test = null; + Location end = start.clone(); + Vector dir = player.getLocation().getDirection(); + AxisAlignedBB box = null; + Entity ent = ((CraftEntity)player).getHandle(); double maxRange = getMaxRange(player); - double curRange = 0; - while (curRange <= maxRange) + double range = 0; + + rangeLoop: while (range <= maxRange) { - Location newTarget = player.getLocation().add(new Vector(0,0.2,0)).add(player.getLocation().getDirection().multiply(curRange)); - - if (!UtilBlock.airFoliage(newTarget.getBlock()) || !UtilBlock.airFoliage(newTarget.getBlock().getRelative(BlockFace.UP))) - break; - + test = start.clone().add(dir.clone().multiply(range)); + float halfWidth = ent.width / 2; + float length = ent.length; + box = new AxisAlignedBB(test.getX() - halfWidth, test.getY(), test.getZ() - halfWidth, test.getX() + halfWidth, test.getY() + length, test.getZ() + halfWidth); + //Lock Players - for (Player cur : player.getWorld().getPlayers()) + playerLoop: for (Player cur : player.getWorld().getPlayers()) { - if (cur.equals(player) || cur.getGameMode() == GameMode.SPECTATOR) - continue; + if (cur.equals(player) || cur.getGameMode() == GameMode.SPECTATOR || UtilPlayer.isSpectator(cur)) + { + continue playerLoop; + } - if (UtilMath.offset(newTarget, cur.getLocation()) > 1) - continue; + if (UtilMath.offset(test, cur.getLocation()) > 1) + { + continue playerLoop; + } //Action Location target = cur.getLocation().add(player.getLocation().subtract(cur.getLocation()).toVector().normalize()); @@ -130,33 +144,111 @@ public class Blink extends SkillActive player.getWorld().playEffect(player.getLocation(), Effect.BLAZE_SHOOT, 0); return; } - - //Progress Forwards - curRange += 0.2; - + + for (Block b : UtilBlock.getInBoundingBox(player.getWorld(), box)) + { + if (UtilBlock.airFoliage(b)) + { + if (b.getType() == Material.STRING && _allowTrapping) + { + break rangeLoop; + } + } + else + { + break rangeLoop; + } + } + + range += 0.2; + end = test.clone(); //Smoke Trail - UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, newTarget.clone().add(0, 0.5, 0), 0, 0, 0, 0, 1, + UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, end.clone().add(0, 0.5, 0), 0, 0, 0, 0, 1, ViewDist.LONGER, UtilServer.getPlayers()); - - lastSmoke = newTarget.getBlock(); } - - //Modify Range - curRange -= 0.4; - if (curRange < 0) - curRange = 0; - - //Destination - Location loc = getDestination(player, curRange); + _loc.put(player, player.getLocation()); - - //Action - if (curRange > 0) + + if (range > 0) { - player.leaveVehicle(); - player.teleport(loc); + player.teleport(end); } + player.setFallDistance(0); + } + @Override + public void Skill(Player player, int level) + { + Location start = player.getLocation().add(new Vector(0, 0.2, 0)); + Location test = null; + Location end = start.clone(); + Vector dir = player.getLocation().getDirection(); + AxisAlignedBB box = null; + Entity ent = ((CraftEntity)player).getHandle(); + double maxRange = getMaxRange(player); + double range = 0; + + rangeLoop: while (range <= maxRange) + { + test = start.clone().add(dir.clone().multiply(range)); + float halfWidth = ent.width / 2; + float length = ent.length; + box = new AxisAlignedBB(test.getX() - halfWidth, test.getY(), test.getZ() - halfWidth, test.getX() + halfWidth, test.getY() + length, test.getZ() + halfWidth); + + //Lock Players + playerLoop: for (Player cur : player.getWorld().getPlayers()) + { + if (cur.equals(player) || cur.getGameMode() == GameMode.SPECTATOR || UtilPlayer.isSpectator(cur)) + { + continue playerLoop; + } + + if (UtilMath.offset(test, cur.getLocation()) > 1) + { + continue playerLoop; + } + + //Action + Location target = cur.getLocation().add(player.getLocation().subtract(cur.getLocation()).toVector().normalize()); + player.teleport(UtilWorld.locMerge(player.getLocation(), target)); + + //Inform + UtilPlayer.message(player, F.main(GetClassType().name(), "You used " + F.skill(GetName()) + ".")); + + //Effect + player.getWorld().playEffect(player.getLocation(), Effect.BLAZE_SHOOT, 0); + return; + } + + for (Block b : UtilBlock.getInBoundingBox(player.getWorld(), box)) + { + if (UtilBlock.airFoliage(b)) + { + if (b.getType() == Material.TRIPWIRE && _allowTrapping) + { + break rangeLoop; + } + } + else + { + break rangeLoop; + } + } + + range += 0.2; + end = test.clone(); + //Smoke Trail + UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, end.clone().add(0, 0.5, 0), 0, 0, 0, 0, 1, + ViewDist.LONGER, UtilServer.getPlayers()); + } + + _loc.put(player, player.getLocation()); + + if (range > 0) + { + player.teleport(end); + } + player.setFallDistance(0); //Inform @@ -238,4 +330,14 @@ public class Blink extends SkillActive { return player.getLocation().add(player.getLocation().getDirection().multiply(range).add(new Vector(0, 0.4, 0))); } -} + + public boolean isAllowTrapping() + { + return _allowTrapping; + } + + public void setAllowTrapping(boolean allowTrapping) + { + _allowTrapping = allowTrapping; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Flash.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Flash.java index 110b30524..6ace97598 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Flash.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Flash.java @@ -1,12 +1,14 @@ package mineplex.minecraft.game.classcombat.Skill.Assassin; import java.util.HashMap; +import java.util.Map; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; -import org.bukkit.block.BlockFace; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.block.Action; @@ -14,22 +16,26 @@ import org.bukkit.potion.PotionEffectType; import org.bukkit.util.Vector; import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.recharge.Recharge; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; import mineplex.minecraft.game.classcombat.Skill.SkillActive; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; import mineplex.minecraft.game.classcombat.Skill.event.SkillTeleportEvent; +import net.minecraft.server.v1_8_R3.AxisAlignedBB; +import net.minecraft.server.v1_8_R3.Entity; public class Flash extends SkillActive { - private HashMap _flash = new HashMap(); + private Map _flash = new HashMap<>(); + private boolean _allowTrapping = false; public Flash(SkillFactory skills, String name, ClassType classType, SkillType skillType, int cost, int levels, @@ -59,6 +65,7 @@ public class Flash extends SkillActive return "Recharge: #8#-1 Seconds per Charge"; } + @SuppressWarnings("deprecation") @Override public boolean CustomCheck(Player player, int level) { @@ -108,97 +115,92 @@ public class Flash extends SkillActive if (charges >= 1 + level) continue; - if (!mineplex.core.recharge.Recharge.Instance.use(cur, "Flash Recharge", 8000 - (1000 * level), false, false)) + if (!Recharge.Instance.use(cur, "Flash Recharge", 8000 - (1000 * level), false, false)) continue; _flash.put(cur, charges + 1); //Inform - UtilPlayer.message(cur, F.main(GetClassType().name(), "Flash Charges: " + F.elem((charges + 1)+""))); + UtilPlayer.message(cur, F.main(GetClassType().name(), "Flash Charges: " + F.elem((charges + 1) + ""))); } } - } + @SuppressWarnings("deprecation") @Override public void Skill(Player player, int level) { //Use Recharge - mineplex.core.recharge.Recharge.Instance.use(player, "Flash Recharge", 8000, false, false); + Recharge.Instance.use(player, "Flash Recharge", 8000, false, false); _flash.put(player, _flash.get(player) - 1); + //Inform + UtilPlayer.message(player, F.main(GetClassType().name(), "Flash Charges: " + F.elem(_flash.get(player) + ""))); + + Location start = player.getLocation().add(new Vector(0, 0.2, 0)); + Location test = null; + Location end = start.clone(); + Vector dir = player.getLocation().getDirection(); + AxisAlignedBB box = null; + Entity ent = ((CraftEntity)player).getHandle(); double maxRange = getMaxRange(player); - double curRange = 0; - while (curRange <= maxRange) + double range = 0; + + rangeLoop: while (range <= maxRange) { - Location newTarget = player.getLocation().add(new Vector(0,0.2,0)).add(player.getLocation().getDirection().multiply(curRange)); - Location aboveTarget = newTarget.getBlock().getRelative(BlockFace.UP).getLocation(); - - // half-slab - boolean newTargetIsSlab = newTarget.getBlock().getType() == Material.STEP || newTarget.getBlock().getType() == Material.WOOD_STEP; - boolean aboveTargetIsSlab = aboveTarget.getBlock().getType() == Material.STEP || aboveTarget.getBlock().getType() == Material.WOOD_STEP; - - boolean newTargetSlabIsBottom = false; - boolean aboveTargetSlabIsBottom = false; - - if(newTargetIsSlab && curRange < 0.5) + test = start.clone().add(dir.clone().multiply(range)); + float halfWidth = ent.width / 2; + float length = ent.length; + box = new AxisAlignedBB(test.getX() - halfWidth, test.getY(), test.getZ() - halfWidth, test.getX() + halfWidth, test.getY() + length, test.getZ() + halfWidth); + for (Block b : UtilBlock.getInBoundingBox(player.getWorld(), box)) { - int newTargetData = (int) newTarget.getBlock().getData(); - - if(newTargetData <= 7) newTargetSlabIsBottom = true; + if (b.getType() == Material.STEP || b.getType() == Material.WOOD_STEP || b.getType() == Material.STONE_SLAB2) + { + boolean bottom = false; + int data = b.getData(); + if (data <= 7) + { + bottom = true; + } + + boolean locIsBottom = (Math.max(test.getY(), b.getY()) - Math.min(test.getY(), b.getY())) < 0.5; + + if (bottom == locIsBottom) + { + break rangeLoop; + } + } + else if (UtilItem.isBoundless(b.getType())) + { + if (b.getType() == Material.TRIPWIRE && _allowTrapping) + { + break rangeLoop; + } + } + else + { + break rangeLoop; + } } - if(aboveTargetIsSlab && curRange < 0.25) - { - int aboveTargetData = (int) aboveTarget.getBlock().getData(); - - if(aboveTargetData <= 7) aboveTargetSlabIsBottom = true; - } - - if ((!newTargetSlabIsBottom && - !UtilItem.isBoundless(aboveTarget.getBlock().getType()) - || (!aboveTargetSlabIsBottom) - && !UtilItem.isBoundless(aboveTarget.getBlock().getType()))) - break; - - if (!UtilItem.isBoundless(newTarget.getBlock().getType()) && UtilItem.isBoundless(aboveTarget.getBlock().getType()) - || !UtilItem.isBoundless(aboveTarget.getBlock().getType()) && !UtilItem.isBoundless(newTarget.getBlock().getType())) - break; - - //Progress Forwards - curRange += 0.1; - + range += 0.1; + end = test.clone(); //Smoke Trail - UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, newTarget.clone().add(0, 0.5, 0), 0, 0, 0, 0, 1, + UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, end.clone().add(0, 0.5, 0), 0, 0, 0, 0, 1, ViewDist.LONGER, UtilServer.getPlayers()); } - - //Modify Range - curRange -= 0.4; - if (curRange < 0) - curRange = 0; - - //Destination - Location loc = getDestination(player, curRange); - if (UtilItem.isBoundless(UtilAlg.moveForward(loc, 0.15d, player.getLocation().getYaw(), false).getBlock().getType())) + if (range > 0) { - loc = UtilAlg.moveForward(loc, 0.25d, player.getLocation().getYaw(), true); + player.teleport(end); } - if (curRange > 0) - player.teleport(loc); - player.setFallDistance(0); - - //Inform - UtilPlayer.message(player, F.main(GetClassType().name(), "Flash Charges: " + F.elem(_flash.get(player)+""))); - + //Effect player.getWorld().playSound(player.getLocation(), Sound.WITHER_SHOOT, 0.4f, 1.2f); player.getWorld().playSound(player.getLocation(), Sound.SILVERFISH_KILL, 1f, 1.6f); - } @Override @@ -216,4 +218,14 @@ public class Flash extends SkillActive { return player.getLocation().add(player.getLocation().getDirection().multiply(range).add(new Vector(0, 0.4, 0))); } -} + + public boolean isAllowTrapping() + { + return _allowTrapping; + } + + public void setAllowTrapping(boolean allowTrapping) + { + _allowTrapping = allowTrapping; + } +} \ No newline at end of file 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 931426de1..10ef5490a 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 @@ -449,6 +449,12 @@ public class BlockToss extends SkillCharge implements IThrown } } } + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } @Override public void Reset(Player player) 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 1ce818b5f..0c32d0503 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 @@ -4,35 +4,32 @@ import java.util.HashSet; import org.bukkit.Bukkit; import org.bukkit.EntityEffect; -import org.bukkit.GameMode; import org.bukkit.Material; -import org.bukkit.block.Block; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerInteractEntityEvent; -import org.bukkit.event.vehicle.VehicleExitEvent; import org.spigotmc.event.entity.EntityDismountEvent; -import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import mineplex.core.Managers; import mineplex.core.common.util.F; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.core.updater.UpdateType; -import mineplex.core.visibility.VisibilityManager; import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.visibility.VisibilityManager; +import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; import mineplex.minecraft.game.classcombat.Skill.SkillActive; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; import mineplex.minecraft.game.classcombat.Skill.event.SkillEvent; import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; public class DwarfToss extends SkillActive { @@ -225,7 +222,9 @@ public class DwarfToss extends SkillActive //Hide! if (target instanceof Player) - VisibilityManager.Instance.setVisibility((Player)target, false, player); + { + Managers.require(VisibilityManager.class).hidePlayer(player, (Player) target, "Dwarf Toss Pickup"); + } //Event UtilServer.getServer().getPluginManager().callEvent(new SkillEvent(player, GetName(), ClassType.Brute, target)); @@ -310,6 +309,8 @@ public class DwarfToss extends SkillActive } } + VisibilityManager vm = Managers.require(VisibilityManager.class); + for (Player cur : voidSet) { LivingEntity target = _holding.remove(cur); @@ -319,7 +320,9 @@ public class DwarfToss extends SkillActive //Show! if (target instanceof Player) - VisibilityManager.Instance.setVisibility((Player)target, true, cur); + { + vm.showPlayer(cur, (Player) target, "Dwarf Toss Pickup"); + } } for (final Player cur : throwSet) @@ -336,7 +339,9 @@ public class DwarfToss extends SkillActive //Show! if (target instanceof Player) - VisibilityManager.Instance.setVisibility((Player)target, true, cur); + { + vm.showPlayer(cur, (Player) target, "Dwarf Toss Pickup"); + } //Throw cur.eject(); @@ -374,6 +379,7 @@ public class DwarfToss extends SkillActive player.eject(); player.leaveVehicle(); + VisibilityManager vm = Managers.require(VisibilityManager.class); for (Player cur : _holding.keySet()) { @@ -386,11 +392,13 @@ public class DwarfToss extends SkillActive //Show! if (target instanceof Player) - VisibilityManager.Instance.setVisibility((Player)target, true, cur); + { + vm.showPlayer(cur, (Player) target, "Dwarf Toss Pickup"); + } } } _holding.remove(player); _time.remove(player); } -} +} \ No newline at end of file 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 588571fdc..294d6fe22 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 @@ -180,4 +180,10 @@ public class FleshHook extends SkillActiveCharge implements IThrown //Remove data.getThrown().remove(); } -} + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } +} \ No newline at end of file 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 14ae0fcf1..f4afb8a81 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 @@ -226,4 +226,10 @@ public class AxeThrow extends SkillActive implements IThrown } } } -} + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/FissureData.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/FissureData.java index e61fd8892..09cf5d30e 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/FissureData.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/FissureData.java @@ -97,16 +97,19 @@ public class FissureData _loc.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getTypeId()); //Slow - for (Player cur : block.getWorld().getPlayers()) { - if(UtilPlayer.isSpectator(cur)) continue; + for (Player cur : block.getWorld().getPlayers()) + { + if (UtilPlayer.isSpectator(cur)) continue; if (!cur.equals(_player)) + { if (UtilMath.offset(block.getLocation().add(0.5, 0.5, 0.5), cur.getLocation()) < 1.5) { //Condition Host.Factory.Condition().Factory().Slow("Fissure", cur, _player, 1 + _level, 1, false, true, true, true); } } + } } } @@ -161,7 +164,8 @@ public class FissureData up.getWorld().playEffect(up.getLocation(), Effect.STEP_SOUND, block.getTypeId()); //Damage - for (Player cur : up.getWorld().getPlayers()) { + for (Player cur : up.getWorld().getPlayers()) + { if (UtilPlayer.isSpectator(cur)) continue; @@ -174,7 +178,8 @@ public class FissureData } //Damage - if (!_hit.contains(cur)) + if (!_hit.contains(cur)) + { if (UtilMath.offset(up.getLocation().add(0.5, 0.5, 0.5), cur.getLocation()) < 1.8) { _hit.add(cur); @@ -189,6 +194,7 @@ public class FissureData //Inform UtilPlayer.message(cur, F.main(Host.GetClassType().name(), F.name(_player.getName()) +" hit you with " + F.skill(Host.GetName(_level)) + ".")); } + } } } //Next Column @@ -210,4 +216,4 @@ public class FissureData _loc = null; _startLoc = null; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/FreezingBlast.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/FreezingBlast.java index ba21f4252..f0147e14f 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/FreezingBlast.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/FreezingBlast.java @@ -147,4 +147,10 @@ public class FreezingBlast extends SkillActive implements IThrown { } -} + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/GlacialBlade.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/GlacialBlade.java index 7f9f0b6a7..eb975e62a 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/GlacialBlade.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/GlacialBlade.java @@ -119,4 +119,10 @@ public class GlacialBlade extends SkillActive implements IThrown { } -} + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } +} \ No newline at end of file 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 a04b31ebc..eb40b9ac9 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 @@ -193,4 +193,10 @@ public class IcePrison extends SkillActive implements IThrown { } -} + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } +} \ No newline at end of file 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 79cbdc825..8772aed09 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 @@ -199,4 +199,10 @@ public class LightningOrb extends SkillActive implements IThrown { } -} + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/Barrage.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/Barrage.java index 5d0fbc73a..d9c8ccd46 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/Barrage.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/Barrage.java @@ -4,17 +4,6 @@ import java.util.HashSet; import java.util.Iterator; import java.util.WeakHashMap; -import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.core.updater.UpdateType; -import mineplex.core.common.util.UtilGear; -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.minecraft.game.classcombat.Skill.SkillChargeBow; -import mineplex.minecraft.game.classcombat.Skill.SkillFactory; - import org.bukkit.Sound; import org.bukkit.entity.Arrow; import org.bukkit.entity.Player; @@ -23,6 +12,18 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.util.Vector; +import mineplex.core.common.util.UtilGear; +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.minecraft.game.classcombat.Class.IPvpClass.ClassType; +import mineplex.minecraft.game.classcombat.Skill.SkillChargeBow; +import mineplex.minecraft.game.classcombat.Skill.SkillFactory; +import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; + public class Barrage extends SkillChargeBow { private WeakHashMap _chargeArrows = new WeakHashMap(); @@ -73,7 +74,13 @@ public class Barrage extends SkillChargeBow _chargeArrows.remove(cur); continue; } - + + if (UtilServer.CallEvent(new SkillTriggerEvent(cur, GetName(), GetClassType())).IsCancelled()) + { + _chargeArrows.remove(cur); + continue; + } + _chargeArrows.put(cur, arrows-1); //Fire Arrow 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 4a0f2ede7..0a93770f5 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 @@ -119,7 +119,8 @@ public class Sharpshooter extends Skill public void missReset(ProjectileHitEvent event) { final Projectile projectile = event.getEntity(); - Factory.runSyncLater(() -> { + Factory.runSyncLater(() -> + { if (!projectile.isDead() && _arrows.containsKey(projectile)) { Player shooter = (Player) projectile.getShooter(); @@ -131,14 +132,14 @@ public class Sharpshooter extends Skill if (!_missedCount.containsKey(shooter)) { - _missedCount.put(shooter, Integer.valueOf(1)); + _missedCount.put(shooter, 1); } else { - _missedCount.put(shooter, Integer.valueOf(_missedCount.get(shooter).intValue() + 1)); + _missedCount.put(shooter, _missedCount.get(shooter) + 1); // Reset - if (_missedCount.get(shooter).intValue() >= 2) + if (_missedCount.get(shooter) >= 2) { _hitCount.remove(shooter); _missedCount.remove(shooter); @@ -199,4 +200,4 @@ public class Sharpshooter extends Skill _hitCount.remove(player); _missedCount.remove(player); } -} +} \ No newline at end of file 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 310146f5a..41a752f2d 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 @@ -9,7 +9,6 @@ import org.bukkit.event.EventHandler; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; -import mineplex.core.common.util.F; import mineplex.core.common.util.UtilTime; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -45,7 +44,7 @@ public class VitalitySpores extends Skill } else { - _lastDamage.put(event.GetDamageePlayer(), Long.valueOf(System.currentTimeMillis())); + _lastDamage.put(event.GetDamageePlayer(), System.currentTimeMillis()); } } } @@ -63,7 +62,7 @@ public class VitalitySpores extends Skill { Entry entry = iterator.next(); - if (UtilTime.elapsed(entry.getValue().longValue(), 10000)) + if (UtilTime.elapsed(entry.getValue(), 10000)) { iterator.remove(); entry.getKey().addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, (20 * (5 + getLevel(entry.getKey()))), 1)); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Skill.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Skill.java index 8288495b2..b43e1c6b1 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Skill.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Skill.java @@ -362,12 +362,12 @@ public abstract class Skill implements ISkill, Listener @Override public void setLocationFilter(LocationFilter filter) { - this._locationFilter = filter; + _locationFilter = filter; } @Override public LocationFilter getLocationFilter() { - return this._locationFilter; + return _locationFilter; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Consume/Apple.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Consume/Apple.java index 08d800a16..2e9d1d5f6 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Consume/Apple.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Consume/Apple.java @@ -81,4 +81,10 @@ public class Apple extends ItemUsable { } -} + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Consume/Soup.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Consume/Soup.java index e24518afe..bccbaefdb 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Consume/Soup.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Consume/Soup.java @@ -68,4 +68,10 @@ public class Soup extends ItemUsable { } -} + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Throwable/Pistol.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Throwable/Pistol.java index adead9093..4700994fb 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Throwable/Pistol.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Throwable/Pistol.java @@ -188,4 +188,10 @@ public class Pistol extends ItemUsable { } -} + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Throwable/PoisonBall.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Throwable/PoisonBall.java index 08293d5a7..4da131381 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Throwable/PoisonBall.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Throwable/PoisonBall.java @@ -72,4 +72,10 @@ public class PoisonBall extends ItemUsable if (ent instanceof Item) ((Item)ent).setPickupDelay(5); } -} + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Throwable/ProximityExplosive.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Throwable/ProximityExplosive.java index 017f6c5fe..5c3835253 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Throwable/ProximityExplosive.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Throwable/ProximityExplosive.java @@ -2,6 +2,7 @@ package mineplex.minecraft.game.classcombat.item.Throwable; import java.util.HashMap; import java.util.Iterator; +import java.util.Map; import org.bukkit.Bukkit; import org.bukkit.Effect; @@ -18,27 +19,28 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.inventory.InventoryPickupItemEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerPickupItemEvent; +import org.bukkit.event.world.ChunkUnloadEvent; -import mineplex.core.projectile.ProjectileUser; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.core.updater.UpdateType; 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.UtilParticle; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.projectile.ProjectileUser; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.classcombat.item.ItemFactory; import mineplex.minecraft.game.classcombat.item.ItemUsable; import mineplex.minecraft.game.classcombat.item.event.ProximityUseEvent; public class ProximityExplosive extends ItemUsable { - private HashMap _armed = new HashMap(); + private Map _armed = new HashMap<>(); public ProximityExplosive(ItemFactory factory, Material type, int amount, boolean canDamage, int gemCost, int tokenCost, @@ -185,5 +187,22 @@ public class ProximityExplosive extends ItemUsable } } } -} - + + @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) + public void chunkUnload(ChunkUnloadEvent event) + { + for (Entity e : event.getChunk().getEntities()) + { + if (_armed.remove(e) != null) + { + e.remove(); + } + } + } + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Throwable/ProximityManager.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Throwable/ProximityManager.java index 9e70eba21..f53033c73 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Throwable/ProximityManager.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Throwable/ProximityManager.java @@ -4,15 +4,10 @@ import java.util.AbstractMap; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; +import java.util.List; +import java.util.Map; import java.util.Map.Entry; -import mineplex.core.common.util.F; -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.classcombat.item.event.ProximityUseEvent; - import org.bukkit.Location; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; @@ -20,11 +15,18 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import mineplex.core.common.util.F; +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.classcombat.item.event.ProximityUseEvent; + public class ProximityManager implements Listener { private int _proxyLimit = 6; - private HashMap>> _proxyMap = new HashMap>>(); + private Map>> _proxyMap = new HashMap<>(); public void setProxyLimit(int limit) { @@ -41,7 +43,7 @@ public class ProximityManager implements Listener if (!_proxyMap.containsKey(event.getPlayer())) _proxyMap.put(event.getPlayer(), new ArrayList>()); - ArrayList> proxies = _proxyMap.get(event.getPlayer()); + List> proxies = _proxyMap.get(event.getPlayer()); //Store New proxies.add(new AbstractMap.SimpleEntry(event.getItemType().GetName(), event.getEntity())); @@ -79,7 +81,7 @@ public class ProximityManager implements Listener continue; } - ArrayList> proxies = _proxyMap.get(player); + List> proxies = _proxyMap.get(player); Iterator> proxyIter = proxies.iterator(); @@ -101,4 +103,4 @@ public class ProximityManager implements Listener playerIter.remove(); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Throwable/ProximityZapper.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Throwable/ProximityZapper.java index 3076b403b..b47364428 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Throwable/ProximityZapper.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Throwable/ProximityZapper.java @@ -2,6 +2,7 @@ package mineplex.minecraft.game.classcombat.item.Throwable; import java.util.HashMap; import java.util.Iterator; +import java.util.Map; import org.bukkit.Bukkit; import org.bukkit.Effect; @@ -17,25 +18,26 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.inventory.InventoryPickupItemEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerPickupItemEvent; +import org.bukkit.event.world.ChunkUnloadEvent; -import mineplex.core.projectile.ProjectileUser; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.core.updater.UpdateType; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilServer; +import mineplex.core.projectile.ProjectileUser; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.classcombat.item.ItemFactory; import mineplex.minecraft.game.classcombat.item.ItemUsable; import mineplex.minecraft.game.classcombat.item.event.ProximityUseEvent; public class ProximityZapper extends ItemUsable { - private HashMap _armed = new HashMap(); + private Map _armed = new HashMap<>(); public ProximityZapper(ItemFactory factory, Material type, int amount, boolean canDamage, int gemCost, int tokenCost, @@ -178,5 +180,22 @@ public class ProximityZapper extends ItemUsable } } } -} - + + @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) + public void chunkUnload(ChunkUnloadEvent event) + { + for (Entity e : event.getChunk().getEntities()) + { + if (_armed.remove(e) != null) + { + e.remove(); + } + } + } + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Throwable/WaterBottle.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Throwable/WaterBottle.java index 99361e426..bc711045b 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Throwable/WaterBottle.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Throwable/WaterBottle.java @@ -76,6 +76,12 @@ public class WaterBottle extends ItemUsable { Break(data); } + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } public void Break(ProjectileUser data) { @@ -96,4 +102,4 @@ public class WaterBottle extends ItemUsable player.setFireTicks(-20); } } -} +} \ No newline at end of file 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 55e9929bb..294e8234f 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 @@ -69,6 +69,12 @@ public class Web extends ItemUsable CreateWeb(data.getThrown()); } + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } + public void CreateWeb(Entity ent) { LivingEntity thrower = Factory.Throw().getThrower(ent); diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderPoison.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderPoison.java index b1bc6cc24..ad330117a 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderPoison.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/broodmother/attacks/SpiderPoison.java @@ -62,5 +62,10 @@ public class SpiderPoison implements IThrown { burst(data); } - -} + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } +} \ 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 index 9c402dab6..e565aa38f 100644 --- 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 @@ -51,4 +51,10 @@ public class IronHook implements IThrown { data.getThrown().remove(); } + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/slimeking/ability/RocketAbility.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/slimeking/ability/RocketAbility.java index d77b039ef..88421942c 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/slimeking/ability/RocketAbility.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/slimeking/ability/RocketAbility.java @@ -132,6 +132,12 @@ public class RocketAbility extends SlimeAbility implements IThrown data.getThrown().remove(); _rocketsHit++; } + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } private static class ShotData { @@ -154,4 +160,4 @@ public class RocketAbility extends SlimeAbility implements IThrown return _target; } } -} +} \ No newline at end of file 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 de8724fa6..af12c96c2 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 @@ -308,6 +308,11 @@ public class Condition return _ticks <= 0; } + + public boolean needsForceRemove() + { + return false; + } public ConditionManager GetManager() { diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/ConditionActive.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/ConditionActive.java index c916f0bea..a8b45abee 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/ConditionActive.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/ConditionActive.java @@ -19,4 +19,4 @@ public class ConditionActive _condition = newCon; newCon.Apply(); } -} +} \ No newline at end of file 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 427680a56..31e2f9466 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 @@ -2,6 +2,7 @@ package mineplex.minecraft.game.core.condition; import java.util.Iterator; +import mineplex.core.Managers; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilTime; import mineplex.core.recharge.Recharge; @@ -73,6 +74,8 @@ public class ConditionEffect implements Listener { if (event.getType() != UpdateType.FAST) return; + + VisibilityManager vm = Managers.require(VisibilityManager.class); for (LivingEntity ent : Manager.GetActiveConditions().keySet()) { @@ -84,17 +87,17 @@ public class ConditionEffect implements Listener //Hide if (Manager.IsCloaked(ent)) { - for (Player other : Bukkit.getServer().getOnlinePlayers()) + for (Player other : Bukkit.getOnlinePlayers()) { - VisibilityManager.Instance.setVisibility(player, false, other); + vm.hidePlayer(other, player, "Cloaking"); } } //Show else { - for (Player other : Bukkit.getServer().getOnlinePlayers()) + for (Player other : Bukkit.getOnlinePlayers()) { - VisibilityManager.Instance.setVisibility(player, true, other); + vm.showPlayer(other, player, "Cloaking"); } } } diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/ConditionManager.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/ConditionManager.java index 54b6e7437..000fd20e1 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/ConditionManager.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/ConditionManager.java @@ -6,22 +6,6 @@ import java.util.LinkedList; import java.util.Map.Entry; import java.util.WeakHashMap; -import mineplex.core.MiniPlugin; -import mineplex.core.common.util.UtilServer; -import mineplex.core.recharge.Recharge; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.core.updater.UpdateType; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilTime.TimeUnit; -import mineplex.minecraft.game.core.condition.Condition.ConditionType; -import mineplex.minecraft.game.core.condition.events.ConditionApplyEvent; -import mineplex.minecraft.game.core.condition.events.ConditionExpireEvent; -import mineplex.minecraft.game.core.damage.DamageManager; - import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.Entity; @@ -31,12 +15,27 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.inventory.InventoryPickupItemEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.plugin.java.JavaPlugin; +import mineplex.core.MiniPlugin; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.condition.Condition.ConditionType; +import mineplex.minecraft.game.core.condition.events.ConditionApplyEvent; +import mineplex.minecraft.game.core.condition.events.ConditionExpireEvent; +import mineplex.minecraft.game.core.damage.DamageManager; + public class ConditionManager extends MiniPlugin { private ConditionFactory _factory; @@ -104,7 +103,7 @@ public class ConditionManager extends MiniPlugin //Add Condition if (!_conditions.containsKey(newCon.GetEnt())) - _conditions.put(newCon.GetEnt(), new LinkedList()); + _conditions.put(newCon.GetEnt(), new LinkedList<>()); _conditions.get(newCon.GetEnt()).add(newCon); @@ -136,7 +135,7 @@ public class ConditionManager extends MiniPlugin public ConditionActive GetIndicatorType(Condition newCon) { if (!_activeConditions.containsKey(newCon.GetEnt())) - _activeConditions.put(newCon.GetEnt(), new LinkedList()); + _activeConditions.put(newCon.GetEnt(), new LinkedList<>()); for (ConditionActive ind : _activeConditions.get(newCon.GetEnt())) if (ind.GetCondition().GetType() == newCon.GetType()) @@ -152,7 +151,7 @@ public class ConditionManager extends MiniPlugin //Get Inds if (!_activeConditions.containsKey(newCon.GetEnt())) - _activeConditions.put(newCon.GetEnt(), new LinkedList()); + _activeConditions.put(newCon.GetEnt(), new LinkedList<>()); LinkedList entInds = _activeConditions.get(newCon.GetEnt()); @@ -169,9 +168,17 @@ public class ConditionManager extends MiniPlugin //Not Additive if (!active.GetCondition().IsExpired()) + { if (active.GetCondition().IsBetterOrEqual(newCon, newCon.IsAdd())) + { return; - + } + } + + if (active.GetCondition().needsForceRemove()) + { + active.GetCondition().Remove(); + } active.SetCondition(newCon); } @@ -195,6 +202,10 @@ public class ConditionManager extends MiniPlugin ConditionExpireEvent conditionExpireEvent = new ConditionExpireEvent(cond); UtilServer.CallEvent(conditionExpireEvent); conditionIterator.remove(); + if (cond.needsForceRemove()) + { + cond.Remove(); + } } } } @@ -215,13 +226,21 @@ public class ConditionManager extends MiniPlugin if (replacement == null) { conditionIndicatorIterator.remove(); + if (conditionIndicator.GetCondition().needsForceRemove()) + { + conditionIndicator.GetCondition().Remove(); + } //Inform if (conditionIndicator.GetCondition().GetInformOff() != null) + { UtilPlayer.message(conditionIndicator.GetCondition().GetEnt(), F.main("Condition", conditionIndicator.GetCondition().GetInformOff())); + } } else + { UpdateActive(conditionIndicator, replacement); + } } } } @@ -380,7 +399,9 @@ public class ConditionManager extends MiniPlugin return; for (Condition cond : _conditions.get(target)) + { if (reason == null || cond.GetReason().equals(reason)) + { if (type == null || cond.GetType() == type) { cond.Expire(); @@ -388,6 +409,8 @@ public class ConditionManager extends MiniPlugin Condition best = GetBestCondition(target, cond.GetType()); if (best != null) best.Apply(); } + } + } } public boolean HasCondition(LivingEntity target, ConditionType type, String reason) @@ -396,9 +419,15 @@ public class ConditionManager extends MiniPlugin return false; for (Condition cond : _conditions.get(target)) + { if (reason == null || cond.GetReason().equals(reason)) + { if (type == null || cond.GetType() == type) + { return true; + } + } + } return false; } @@ -507,41 +536,4 @@ public class ConditionManager extends MiniPlugin } } } - - @EventHandler - public void Debug(PlayerCommandPreprocessEvent event) - { - if (event.getPlayer().getName().equals("Chiss")) - { - if (event.getMessage().equals("/debugcond1")) - { - _factory.Regen("Debug", event.getPlayer(), event.getPlayer(), 30, 0, false, false, false); - event.getPlayer().sendMessage("Regen 1 for 30s"); - event.setCancelled(true); - } - else if (event.getMessage().equals("/debugcond2")) - { - _factory.Regen("Debug", event.getPlayer(), event.getPlayer(), 15, 1, false, false, false); - event.getPlayer().sendMessage("Regen 2 for 15s"); - event.setCancelled(true); - } - else if (event.getMessage().equals("/debugcond3")) - { - _factory.Regen("Debug", event.getPlayer(), event.getPlayer(), 5, 2, false, false, false); - event.getPlayer().sendMessage("Regen 3 for 5s"); - event.setCancelled(true); - } - else if (event.getMessage().equals("/debugcond4")) - { - _factory.Slow("Debug", event.getPlayer(), event.getPlayer(), 5, 0, true, false, false, false); - event.setCancelled(true); - } - else if (event.getMessage().equals("/debugcond5")) - { - _factory.Ignite("Debug", event.getPlayer(), event.getPlayer(), 5, true, false); - event.getPlayer().sendMessage("Regen 1 for 30s"); - event.setCancelled(true); - } - } - } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/conditions/Cloak.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/conditions/Cloak.java index b0d233bb2..3c24e7a01 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/conditions/Cloak.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/conditions/Cloak.java @@ -1,19 +1,19 @@ package mineplex.minecraft.game.core.condition.conditions; +import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Creature; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; -import mineplex.core.common.util.UtilServer; +import mineplex.core.Managers; import mineplex.core.visibility.VisibilityManager; import mineplex.minecraft.game.core.condition.Condition; import mineplex.minecraft.game.core.condition.ConditionManager; public class Cloak extends Condition { - public Cloak(ConditionManager manager, String reason, LivingEntity ent, LivingEntity source, ConditionType type, int mult, int ticks, boolean add, Material visualType, byte visualData, @@ -25,6 +25,12 @@ public class Cloak extends Condition _informOn = "You are now invisible."; _informOff = "You are no longer invisible."; } + + @Override + public boolean needsForceRemove() + { + return true; + } @Override public void Add() @@ -32,7 +38,12 @@ public class Cloak extends Condition if (!(_ent instanceof Player)) return; - VisibilityManager.Instance.setVisibility((Player)_ent, false, UtilServer.getPlayers()); + VisibilityManager vm = Managers.require(VisibilityManager.class); + + Bukkit.getOnlinePlayers().forEach(player -> + { + vm.hidePlayer(player, (Player)_ent, "Cloaking " + _reason); + }); for (Entity ent : _ent.getWorld().getEntities()) { @@ -53,6 +64,11 @@ public class Cloak extends Condition { super.Remove(); - VisibilityManager.Instance.setVisibility((Player)_ent, true, UtilServer.getPlayers()); + VisibilityManager vm = Managers.require(VisibilityManager.class); + + Bukkit.getOnlinePlayers().forEach(player -> + { + vm.showPlayer(player, (Player)_ent, "Cloaking " + _reason); + }); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java index 55dbd6681..9ac23e777 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java @@ -184,6 +184,11 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable int clansDyeBoxesReceived = 0; int clansBuilderBoxesReceived = 0; int hogChestReceived = 0; + int clansGildedDyeBoxesReceived = 0; + int supplyDropsReceived = 0; + int gildedSupplyDropsReceived = 0; + int bossTokenWizardReceived = 0; + int bossTokenSkeletonReceived = 0; for (CoinTransactionToken transaction : donor.getCoinTransactions()) { @@ -428,6 +433,56 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable hogChestReceived += 1; } } + if (transaction.SalesPackageName.startsWith("Clans Gilded Dye Box")) + { + if (transaction.Coins == 0 && transaction.Gems == 0) + { + if (transaction.SalesPackageName.split(" ").length == 5) + clansGildedDyeBoxesReceived += Integer.parseInt(transaction.SalesPackageName.split(" ")[4]); + else if (transaction.SalesPackageName.split(" ").length == 4) + clansGildedDyeBoxesReceived += 1; + } + } + if (transaction.SalesPackageName.startsWith("Clans Supply Drop")) + { + if (transaction.Coins == 0 && transaction.Gems == 0) + { + if (transaction.SalesPackageName.split(" ").length == 4) + supplyDropsReceived += Integer.parseInt(transaction.SalesPackageName.split(" ")[3]); + else if (transaction.SalesPackageName.split(" ").length == 3) + supplyDropsReceived += 1; + } + } + if (transaction.SalesPackageName.startsWith("Clans Gilded Supply Drop")) + { + if (transaction.Coins == 0 && transaction.Gems == 0) + { + if (transaction.SalesPackageName.split(" ").length == 5) + gildedSupplyDropsReceived += Integer.parseInt(transaction.SalesPackageName.split(" ")[4]); + else if (transaction.SalesPackageName.split(" ").length == 4) + gildedSupplyDropsReceived += 1; + } + } + if (transaction.SalesPackageName.startsWith("Clans Boss Token Wizard")) + { + if (transaction.Coins == 0 && transaction.Gems == 0) + { + if (transaction.SalesPackageName.split(" ").length == 5) + bossTokenWizardReceived += Integer.parseInt(transaction.SalesPackageName.split(" ")[4]); + else if (transaction.SalesPackageName.split(" ").length == 4) + bossTokenWizardReceived += 1; + } + } + if (transaction.SalesPackageName.startsWith("Clans Boss Token Skeleton")) + { + if (transaction.Coins == 0 && transaction.Gems == 0) + { + if (transaction.SalesPackageName.split(" ").length == 5) + bossTokenSkeletonReceived += Integer.parseInt(transaction.SalesPackageName.split(" ")[4]); + else if (transaction.SalesPackageName.split(" ").length == 4) + bossTokenSkeletonReceived += 1; + } + } } StatsManager statsManager = Managers.get(StatsManager.class); @@ -469,6 +524,9 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable caller.sendMessage(C.cBlue + "Rune Amplifiers (20 min/60 min) Received: " + C.cYellow + runeAmplifier20 + "/" + runeAmplifier60); caller.sendMessage(C.cBlue + "Clans Dye Boxes Received: " + C.cYellow + clansDyeBoxesReceived + " " + C.cBlue + "Clans Builder Boxes Received: " + C.cYellow + clansBuilderBoxesReceived); caller.sendMessage(C.cBlue + "Clan Banner Usage: " + getLockedPackageStr(client.getUniqueId(), "Clan Banner Usage") + " " + C.cBlue + "Clan Banner Editor: " + getLockedPackageStr(client.getUniqueId(), "Clan Banner Editor")); + caller.sendMessage(C.cBlue + "Clans Gilded Dye Boxes Received: " + C.cYellow + clansGildedDyeBoxesReceived); + caller.sendMessage(C.cBlue + "Supply Drops Received: " + C.cYellow + supplyDropsReceived + " " + C.cBlue + "Gilded Supply Drops Received: " + C.cYellow + gildedSupplyDropsReceived); + caller.sendMessage(C.cBlue + "Wizard Summon Tokens Received: " + C.cYellow + bossTokenWizardReceived + " " + C.cBlue + "Skeleton Summon Tokens Received: " + C.cYellow + bossTokenSkeletonReceived); YearMonth yearMonth = YearMonth.now(); caller.sendMessage(C.cBlue + "Power Play Subscription (" + yearMonth.getMonth().getDisplayName(TextStyle.FULL, Locale.US) + ") " + (powerPlayData.isSubscribed() ? C.cGreen + "Active" : C.cRed + "Inactive")); if (powerPlayData.isSubscribed()) diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java index d3ab58b2b..500435497 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java @@ -21,7 +21,9 @@ import mineplex.staffServer.salespackage.salespackages.AncientChest; import mineplex.staffServer.salespackage.salespackages.ApplyKits; import mineplex.staffServer.salespackage.salespackages.ClanBannerEditor; import mineplex.staffServer.salespackage.salespackages.ClanBannerUsage; +import mineplex.staffServer.salespackage.salespackages.ClansBossToken; import mineplex.staffServer.salespackage.salespackages.ClansBox; +import mineplex.staffServer.salespackage.salespackages.ClansSupplyDrop; import mineplex.staffServer.salespackage.salespackages.Coins; import mineplex.staffServer.salespackage.salespackages.DefaultRank; import mineplex.staffServer.salespackage.salespackages.FreedomChest; @@ -107,7 +109,12 @@ public class SalesPackageManager extends MiniPlugin addSalesPackage(new RuneAmplifier(this, 20)); addSalesPackage(new RuneAmplifier(this, 60)); addSalesPackage(new ClansBox(this, "Dye")); + addSalesPackage(new ClansBox(this, "Gilded Dye")); addSalesPackage(new ClansBox(this, "Builder")); + addSalesPackage(new ClansSupplyDrop(this, false)); + addSalesPackage(new ClansSupplyDrop(this, true)); + addSalesPackage(new ClansBossToken(this, "Wizard")); + addSalesPackage(new ClansBossToken(this, "Skeleton")); addSalesPackage(new PowerPlayClub(this, false)); addSalesPackage(new PowerPlayClub(this, true)); addSalesPackage(new OmegaChest(this)); @@ -197,7 +204,7 @@ 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 || salesPackage instanceof ClansBox) + else if (salesPackage instanceof ClanBannerEditor || salesPackage instanceof ClanBannerUsage || salesPackage instanceof RuneAmplifier || salesPackage instanceof ClansBox || salesPackage instanceof ClansSupplyDrop || salesPackage instanceof ClansBossToken) { clanBuilder = clanBuilder.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/ClansBossToken.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/ClansBossToken.java new file mode 100644 index 000000000..01aa3af40 --- /dev/null +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/ClansBossToken.java @@ -0,0 +1,22 @@ +package mineplex.staffServer.salespackage.salespackages; + +import mineplex.staffServer.salespackage.SalesPackageManager; +import org.bukkit.entity.Player; + +public class ClansBossToken extends SalesPackageBase +{ + private final String _boss; + + public ClansBossToken(SalesPackageManager manager, String boss) + { + super(manager, "1 Clans Boss Token " + boss); + _boss = boss; + } + + public void displayToAgent(Player agent, String playerName) + { + addButton(agent, "/sales item " + playerName + " 1 Item Clans Boss Token " + _boss, "Give 1 Clans Boss Token " + _boss + "."); + agent.sendMessage(" "); + addBackButton(agent, playerName); + } +} diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/ClansSupplyDrop.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/ClansSupplyDrop.java new file mode 100644 index 000000000..3cde09e10 --- /dev/null +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/ClansSupplyDrop.java @@ -0,0 +1,22 @@ +package mineplex.staffServer.salespackage.salespackages; + +import mineplex.staffServer.salespackage.SalesPackageManager; +import org.bukkit.entity.Player; + +public class ClansSupplyDrop extends SalesPackageBase +{ + private final boolean _gilded; + + public ClansSupplyDrop(SalesPackageManager manager, boolean gilded) + { + super(manager, "1 Clans " + (gilded ? "Gilded " : "") + "Supply Drop"); + _gilded = gilded; + } + + public void displayToAgent(Player agent, String playerName) + { + addButton(agent, "/sales item " + playerName + " 1 Item Clans " + (_gilded ? "Gilded " : "") + "Supply Drop", "Give 1 Clans " + (_gilded ? "Gilded " : "") + "Supply Drop."); + agent.sendMessage(" "); + addBackButton(agent, playerName); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java index b361acd2d..295e89cac 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -3,7 +3,6 @@ package nautilus.game.arcade; import java.io.File; import java.util.HashMap; -import mineplex.core.customdata.CustomData; import mineplex.core.imagemap.CustomItemFrames; import net.minecraft.server.v1_8_R3.MinecraftServer; @@ -49,6 +48,7 @@ import mineplex.core.gadget.gadgets.particle.king.CastleManager; import mineplex.core.give.Give; import mineplex.core.hologram.HologramManager; import mineplex.core.ignore.IgnoreManager; +import mineplex.core.imagemap.CustomItemFrames; import mineplex.core.incognito.IncognitoManager; import mineplex.core.inventory.InventoryManager; import mineplex.core.itemstack.ItemStackFactory; @@ -81,7 +81,6 @@ import mineplex.core.visibility.VisibilityManager; import mineplex.core.website.WebsiteLinkManager; import mineplex.minecraft.game.core.combat.CombatManager; import mineplex.minecraft.game.core.damage.DamageManager; - import nautilus.game.arcade.anticheatmetadata.GameInfoMetadata; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.GameServerConfig; @@ -141,7 +140,7 @@ public class Arcade extends JavaPlugin ItemStackFactory.Initialize(this, false); Recharge.Initialize(this); - VisibilityManager.Initialize(this); + require(VisibilityManager.class); Give.Initialize(this); // Publish our server status now, to give us more time to start up diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index 1a2baeb6b..78715aff9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -1252,7 +1252,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation UtilPlayer.setGliding(player, false); UtilPlayer.setAutoDeployDistance(player, 1.15F); - ((CraftEntity) player).getHandle().getDataWatcher().watch(0, Byte.valueOf((byte) 0), EntityLiving.META_ENTITYDATA, (byte) 0); + ((CraftEntity) player).getHandle().getDataWatcher().watch(0, (byte) 0, EntityLiving.META_ENTITYDATA, (byte) 0); player.setCustomName(""); player.setCustomNameVisible(false); 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 9f4aa4ef2..c92d2c0c1 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 @@ -313,7 +313,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed public boolean PrepareAutoAnnounce = true; public boolean PlaySoundGameStart = true; - public double XpMult = 1; + public double XpMult = 2; public boolean SpeedMeasurement = false; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameTeam.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameTeam.java index 3849c5354..b9a593248 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameTeam.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameTeam.java @@ -1,5 +1,19 @@ package nautilus.game.arcade.game; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.concurrent.atomic.AtomicLong; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Color; +import org.bukkit.Location; +import org.bukkit.entity.Creature; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; + +import mineplex.core.Managers; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; @@ -9,17 +23,6 @@ import mineplex.core.visibility.VisibilityManager; import nautilus.game.arcade.gametutorial.GameTutorial; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.KitAvailability; -import org.bukkit.ChatColor; -import org.bukkit.Color; -import org.bukkit.Location; -import org.bukkit.entity.Creature; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.concurrent.atomic.AtomicLong; public class GameTeam { @@ -182,8 +185,9 @@ public class GameTeam _players.put(player, in ? PlayerState.IN : PlayerState.OUT); UtilPlayer.message(player, F.main("Team", _color + C.Bold + "You joined " + getDisplayName() + " Team.")); - - VisibilityManager.Instance.refreshPlayerToAll(player); + + VisibilityManager vm = Managers.require(VisibilityManager.class); + Bukkit.getOnlinePlayers().forEach(pl -> vm.refreshVisibility(pl, player)); } public void DisbandTeam() @@ -476,4 +480,4 @@ public class GameTeam { return this._teamId; } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssaultTDM.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssaultTDM.java index e88701439..a5d9f8e6a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssaultTDM.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssaultTDM.java @@ -441,7 +441,7 @@ public class CastleAssaultTDM extends TeamGame GameTeam red = GetTeam(ChatColor.RED); GameTeam blue = GetTeam(ChatColor.AQUA); - if (_teamKills.get(blue).intValue() >= KILLS_TO_WIN) + if (_teamKills.get(blue) >= KILLS_TO_WIN) { AnnounceEnd(blue); writeFinalScoreboard(blue.GetColor() + blue.GetName(), _teamKills.get(blue)); @@ -495,7 +495,7 @@ public class CastleAssaultTDM extends TeamGame SetState(GameState.End); return; } - if (_teamKills.get(red).intValue() >= KILLS_TO_WIN) + if (_teamKills.get(red) >= KILLS_TO_WIN) { AnnounceEnd(red); writeFinalScoreboard(red.GetColor() + red.GetName(), _teamKills.get(red)); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/PerkBloodlust.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/PerkBloodlust.java index 2fc724eef..366b8544c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/PerkBloodlust.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/PerkBloodlust.java @@ -43,7 +43,7 @@ public class PerkBloodlust extends Perk Integer id = _lusting.remove(event.getEntity()); if (id != null) { - Bukkit.getScheduler().cancelTask(id.intValue()); + Bukkit.getScheduler().cancelTask(id); } } @@ -89,7 +89,7 @@ public class PerkBloodlust extends Perk Integer id = _lusting.remove(player); if (id != null) { - Bukkit.getScheduler().cancelTask(id.intValue()); + Bukkit.getScheduler().cancelTask(id); } player.sendMessage(C.cRed + "You are now channeling bloodlust for " + _duration + " seconds!"); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/deathtag/DeathTag.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/deathtag/DeathTag.java index f2d1cc1d3..486b62291 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/deathtag/DeathTag.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/deathtag/DeathTag.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.deathtag; +import mineplex.core.Managers; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; @@ -24,6 +25,8 @@ import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.NullKit; import nautilus.game.arcade.stats.ComeAtMeBroStatTracker; + +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Material; @@ -277,7 +280,8 @@ public class DeathTag extends SoloGame newKit.ApplyKit(player); //Refresh - VisibilityManager.Instance.refreshPlayerToAll(player); + VisibilityManager vm = Managers.require(VisibilityManager.class); + Bukkit.getOnlinePlayers().forEach(pl -> vm.refreshVisibility(pl, player)); if (forced) { @@ -316,7 +320,8 @@ public class DeathTag extends SoloGame GetKit(player).ApplyKit(player); //Refresh on Spawn - VisibilityManager.Instance.refreshPlayerToAll(player); + VisibilityManager vm = Managers.require(VisibilityManager.class); + Bukkit.getOnlinePlayers().forEach(pl -> vm.refreshVisibility(pl, player)); } }, 0); } 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 1e1151c1a..09d6ff6bd 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,5 +1,6 @@ package nautilus.game.arcade.game.games.event; +import mineplex.core.Managers; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.*; import mineplex.core.disguise.disguises.*; @@ -216,7 +217,8 @@ public class EventGame extends Game GetKits()[0].ApplyKit(player); //Refresh - VisibilityManager.Instance.refreshPlayerToAll(player); + VisibilityManager vm = Managers.require(VisibilityManager.class); + Bukkit.getOnlinePlayers().forEach(pl -> vm.refreshVisibility(pl, player)); //Spawn GetTeamList().get(0).SpawnTeleport(player); @@ -330,47 +332,6 @@ public class EventGame extends Game event.blockList().clear(); } - // @EventHandler - // public void updateVisibility(UpdateEvent event) - // { - // if (!InProgress()) - // return; - // - // if (event.getType() != UpdateType.FAST) - // return; - // - // for (Player player : UtilServer.getPlayers()) - // { - // if (!Manager.getPreferences().Get(player).ShowPlayers) - // { - // for (Player other : UtilServer.getPlayers()) - // { - // if (player.equals(other)) - // continue; - // - // ((CraftPlayer)player).hidePlayer(other, true, false); - // } - // } - // else - // { - // for (Player other : UtilServer.getPlayers()) - // { - // if (player.equals(other)) - // continue; - // - // if ((Manager.getPreferences().Get(player).Invisibility && _mps.isAdmin(player, false)) || ) - // { - // ((CraftPlayer)other).hidePlayer(player, true, false); - // } - // else - // { - // other.showPlayer(player); - // } - // } - // } - // } - // } - @Override public void EndCheck() { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkBlockTossEVO.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkBlockTossEVO.java index 2d91ec76d..2de8ee36c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkBlockTossEVO.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkBlockTossEVO.java @@ -204,7 +204,12 @@ public class PerkBlockTossEVO extends Perk implements IThrown { } - + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } @SuppressWarnings("deprecation") @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkSulphurBombEVO.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkSulphurBombEVO.java index 4baac10db..f37eec459 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkSulphurBombEVO.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkSulphurBombEVO.java @@ -119,6 +119,12 @@ public class PerkSulphurBombEVO extends Perk implements IThrown { Explode(data); } + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } public void Explode(ProjectileUser data) { @@ -135,6 +141,5 @@ public class PerkSulphurBombEVO extends Perk implements IThrown return; event.AddKnockback(GetName(), 1.5); - } - -} + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkWebEVO.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkWebEVO.java index a23144570..ea608e1fd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkWebEVO.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkWebEVO.java @@ -110,6 +110,12 @@ public class PerkWebEVO extends Perk implements IThrown Web(data); } + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } + public void Web(ProjectileUser data) { Location loc = data.getThrown().getLocation(); @@ -121,4 +127,4 @@ public class PerkWebEVO extends Perk implements IThrown Manager.GetBlockRestore().add(loc.getBlock(), 30, (byte)0, 4000); } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/Halloween2016.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/Halloween2016.java index ee5e9d5a0..0fe19b445 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/Halloween2016.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/Halloween2016.java @@ -22,6 +22,7 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; +import mineplex.core.Managers; import mineplex.core.common.Pair; import mineplex.core.common.animation.AnimationPoint; import mineplex.core.common.animation.Animator; @@ -31,14 +32,13 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.pet.PetType; import mineplex.core.reward.rewards.PetReward; import mineplex.core.treasure.reward.RewardRarity; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; - +import mineplex.core.visibility.VisibilityManager; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; @@ -141,16 +141,17 @@ public class Halloween2016 extends Halloween public void unlockAllPlayers() { - if(_lockAllPlayers == null) return; + if (_lockAllPlayers == null) return; _lockAllPlayers = null; - for(Entry> e : _playerPreLockData.entrySet()) + VisibilityManager vm = Managers.require(VisibilityManager.class); + for (Entry> e : _playerPreLockData.entrySet()) { e.getKey().teleport(e.getValue().getLeft()); e.getKey().setGameMode(e.getValue().getRight()); - if(IsAlive(e.getKey())) + if (IsAlive(e.getKey())) { - UtilPlayer.showForAll(e.getKey()); + Bukkit.getOnlinePlayers().forEach(p -> vm.showPlayer(p, e.getKey(), "Halloween 2016 Lock")); } } _playerPreLockData.clear(); @@ -170,21 +171,22 @@ public class Halloween2016 extends Halloween @EventHandler public void lockPlayerTask(UpdateEvent event) { - if(event.getType() != UpdateType.TICK) return; + if (event.getType() != UpdateType.TICK) return; - if(_lockAllPlayers != null) + if (_lockAllPlayers != null) { - for(Player p : Bukkit.getOnlinePlayers()) + VisibilityManager vm = Managers.require(VisibilityManager.class); + for (Player p : Bukkit.getOnlinePlayers()) { - if(!_playerPreLockData.containsKey(p)) + if (!_playerPreLockData.containsKey(p)) { _playerPreLockData.put(p, Pair.create(p.getLocation(), p.getGameMode())); p.setGameMode(GameMode.SPECTATOR); } p.teleport(_lockAllPlayers); - if(IsAlive(p)) + if (IsAlive(p)) { - UtilPlayer.hideFromAll(p); + Bukkit.getOnlinePlayers().forEach(pl -> vm.hidePlayer(pl, p, "Halloween 2016 Lock")); } } } 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 4184d7214..bbc1b6bb3 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 @@ -58,6 +58,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.FireworkMeta; import org.bukkit.util.Vector; +import mineplex.core.Managers; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; @@ -1158,7 +1159,8 @@ public class HideSeek extends TeamGame GetKits()[5].ApplyKit(player); // Refresh - VisibilityManager.Instance.refreshPlayerToAll(player); + VisibilityManager vm = Managers.require(VisibilityManager.class); + Bukkit.getOnlinePlayers().forEach(pl -> vm.refreshVisibility(pl, player)); if (forced) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/forms/BlockForm.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/forms/BlockForm.java index a3c515081..f0cee8975 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/forms/BlockForm.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/forms/BlockForm.java @@ -82,7 +82,7 @@ public class BlockForm extends Form } EntityPlayer player = ((CraftPlayer) Player).getHandle(); - player.getDataWatcher().watch(0, Byte.valueOf((byte) 32), Entity.META_ENTITYDATA, (byte) 32); + player.getDataWatcher().watch(0, (byte) 32, Entity.META_ENTITYDATA, (byte) 32); // Player > Chicken DisguiseChicken disguise = new DisguiseChicken(Player); @@ -209,7 +209,7 @@ public class BlockForm extends Form public void SolidifyUpdate() { if (!Player.isSprinting()) - ((CraftEntity) Player).getHandle().getDataWatcher().watch(0, Byte.valueOf((byte) 32), Entity.META_ENTITYDATA, + ((CraftEntity) Player).getHandle().getDataWatcher().watch(0, (byte) 32, Entity.META_ENTITYDATA, (byte) 32); // Not a Block diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/forms/CreatureForm.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/forms/CreatureForm.java index 22db07638..1b49d903a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/forms/CreatureForm.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/forms/CreatureForm.java @@ -44,7 +44,7 @@ public class CreatureForm extends Form _disguise.setSoundDisguise(new DisguiseCat(Player)); Host.Manager.GetDisguise().disguise(_disguise); - ((CraftEntity)Player).getHandle().getDataWatcher().watch(0, Byte.valueOf((byte) 0), Entity.META_ENTITYDATA, (byte) 0); + ((CraftEntity)Player).getHandle().getDataWatcher().watch(0, (byte) 0, Entity.META_ENTITYDATA, (byte) 0); //Inform UtilPlayer.message(Player, F.main("Game", C.cWhite + "You are now a " + F.elem(UtilEnt.getName(_type)) + "!")); @@ -62,6 +62,6 @@ public class CreatureForm extends Form { Host.Manager.GetDisguise().undisguise(Player); - ((CraftEntity)Player).getHandle().getDataWatcher().watch(0, Byte.valueOf((byte) 0), Entity.META_ENTITYDATA, (byte) 0); + ((CraftEntity)Player).getHandle().getDataWatcher().watch(0, (byte) 0, Entity.META_ENTITYDATA, (byte) 0); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/BombLobbers.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/BombLobbers.java index 4b4aa2c13..542598980 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/BombLobbers.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/BombLobbers.java @@ -610,6 +610,12 @@ public class BombLobbers extends TeamGame implements IThrown } + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } + public void knockbackIncrease(CustomDamageEvent event) { if (event.GetCause() != DamageCause.ENTITY_EXPLOSION && event.GetCause() != DamageCause.BLOCK_EXPLOSION) @@ -617,4 +623,4 @@ public class BombLobbers extends TeamGame implements IThrown event.AddKnockback("Explosion", 1.7D); } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/MilkCow.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/MilkCow.java index b14fb3a9d..3b8731167 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/MilkCow.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/MilkCow.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; +import mineplex.core.Managers; import mineplex.core.common.Pair; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; @@ -305,7 +306,8 @@ public class MilkCow extends SoloGame newKit.ApplyKit(player); //Refresh - VisibilityManager.Instance.refreshPlayerToAll(player); + VisibilityManager vm = Managers.require(VisibilityManager.class); + Bukkit.getOnlinePlayers().forEach(pl -> vm.refreshVisibility(pl, player)); //Turn off flight player.setAllowFlight(false); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/Gun.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/Gun.java index 106e04251..8ba1b2842 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/Gun.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/Gun.java @@ -335,20 +335,23 @@ public class Gun extends StrikeItem { if(_kills == -1) { - new BukkitRunnable() { - public void run() { + new BukkitRunnable() + { + public void run() + { PlayerStats remoteStats = game.getHost().getArcadeManager().GetStatsManager().Get(player);; _kills = (int) remoteStats.getStat(game.getHost().GetName() + "." + getStatNameKills(true)); Player owner = UtilPlayer.searchExact(getOwnerName()); - if(owner != null) { + if (owner != null) + { HashMap localStatsMap = game.getHost().GetStats().get(owner); - if(localStatsMap != null) + if (localStatsMap != null) { Integer kills = localStatsMap.get(game.getHost().GetName() + "." + getStatNameKills(true)); - if(kills != null) + if (kills != null) { - _kills += kills.intValue(); + _kills += kills; } } } @@ -358,12 +361,12 @@ public class Gun extends StrikeItem } } int kls = _kills; - if(kls == -1) kls = 0; + if (kls == -1) kls = 0; String owner = C.Reset + (getOwnerName() == null ? "" : getOwnerName() + "'s "); String reload = C.Bold + getChatName() + (_reloadTick ? ChatColor.RED : ChatColor.WHITE); String kills = C.cYellow + " " + kls + " kills"; - if(!hasCustomSkin()) + if (!hasCustomSkin()) { kills = ""; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/BawkBawkBattles.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/BawkBawkBattles.java index 2a6636c1b..ec49f6a5f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/BawkBawkBattles.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/BawkBawkBattles.java @@ -1633,6 +1633,12 @@ public class BawkBawkBattles extends TeamGame implements IThrown } } } + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } @Override public void Idle(ProjectileUser data) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java index dc255d790..9583fdeae 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java @@ -178,11 +178,16 @@ public class SkillMeteor extends HeroSkill implements IThrown startShower(data); data.getThrown().remove(); } + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } private void startShower(ProjectileUser data) { Manager.GetBlockRestore().add(data.getThrown().getLocation().getBlock(), Material.NETHERRACK.getId(), (byte) 0, 6000); _data.add(new MeteorShowerData((Player) data.getThrower(), data.getThrown().getLocation(), 6000)); } -} - +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillBuildPainting.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillBuildPainting.java index ecd182681..43d868002 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillBuildPainting.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillBuildPainting.java @@ -189,6 +189,12 @@ public class SkillBuildPainting extends HeroSkill implements IThrown damage(data); } + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } + private void damage(ProjectileUser data) { Entity entity = data.getThrown(); @@ -202,4 +208,4 @@ public class SkillBuildPainting extends HeroSkill implements IThrown data.getThrown().remove(); } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillPaint.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillPaint.java index b5f8386bf..c2eb42fc8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillPaint.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillPaint.java @@ -100,4 +100,10 @@ public class SkillPaint extends HeroSkill implements IThrown { } -} + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java index 094700d99..db3a1bb91 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java @@ -91,5 +91,10 @@ public class SkillSnowball extends HeroSkill implements IThrown public void Expire(ProjectileUser data) { } -} - + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAOEHeal.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAOEHeal.java index 64441aa11..10a51f0b6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAOEHeal.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAOEHeal.java @@ -104,6 +104,12 @@ public class SkillAOEHeal extends HeroSkill implements IThrown { deployAoe((Player) data.getThrower(), data.getThrown(), data.getThrown().getLocation()); } + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } @EventHandler public void updateAOE(UpdateEvent event) @@ -198,4 +204,4 @@ public class SkillAOEHeal extends HeroSkill implements IThrown LastHeal = Start; } } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/runner/Runner.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/runner/Runner.java index 53d86ee3d..5d7072534 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/runner/Runner.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/runner/Runner.java @@ -366,4 +366,10 @@ public class Runner extends SoloGame implements IThrown { } -} + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/creeper/PerkCreeperSulphurBomb.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/creeper/PerkCreeperSulphurBomb.java index df921ff65..518cd14bb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/creeper/PerkCreeperSulphurBomb.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/creeper/PerkCreeperSulphurBomb.java @@ -64,6 +64,12 @@ public class PerkCreeperSulphurBomb extends SmashPerk { Explode(data); } + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } private void Explode(ProjectileUser data) { @@ -99,6 +105,12 @@ public class PerkCreeperSulphurBomb extends SmashPerk { Explode(data); } + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } private void Explode(ProjectileUser data) { @@ -216,4 +228,4 @@ public class PerkCreeperSulphurBomb extends SmashPerk event.AddKnockback(GetName(), _knockbackMagnitude); } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/enderman/PerkBlockToss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/enderman/PerkBlockToss.java index 3e48a23da..14fa007f9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/enderman/PerkBlockToss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/enderman/PerkBlockToss.java @@ -244,6 +244,12 @@ public class PerkBlockToss extends SmashPerk implements IThrown public void Expire(ProjectileUser data) { } + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } @EventHandler public void BlockForm(EntityChangeBlockEvent event) @@ -273,4 +279,4 @@ public class PerkBlockToss extends SmashPerk implements IThrown event.AddKnockback(GetName(), _knockbackMagnitude); } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/golem/PerkIronHook.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/golem/PerkIronHook.java index 93ca69da5..bb6d0b45d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/golem/PerkIronHook.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/golem/PerkIronHook.java @@ -128,5 +128,10 @@ public class PerkIronHook extends Perk implements IThrown { data.getThrown().remove(); } - -} + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/guardian/PerkWhirlpoolBlade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/guardian/PerkWhirlpoolBlade.java index 337655ec7..deaeed797 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/guardian/PerkWhirlpoolBlade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/guardian/PerkWhirlpoolBlade.java @@ -160,4 +160,10 @@ public class PerkWhirlpoolBlade extends Perk implements IThrown { data.getThrown().remove(); } -} + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/pig/PerkPigBaconBounce.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/pig/PerkPigBaconBounce.java index 720dc9145..43371b217 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/pig/PerkPigBaconBounce.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/pig/PerkPigBaconBounce.java @@ -159,6 +159,12 @@ public class PerkPigBaconBounce extends SmashPerk implements IThrown { Rebound(data.getThrower(), data.getThrown()); } + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } public void Rebound(LivingEntity player, Entity ent) { @@ -205,4 +211,4 @@ public class PerkPigBaconBounce extends SmashPerk implements IThrown UtilParticle.PlayParticle(ParticleType.HEART, event.getPlayer().getLocation().add(0, 0.5, 0), 0.2f, 0.2f, 0.2f, 0, 4, ViewDist.LONG, UtilServer.getPlayers()); } } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/skeletalhorse/PerkBoneRush.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/skeletalhorse/PerkBoneRush.java index 1f09e42d9..0878a36dd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/skeletalhorse/PerkBoneRush.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/skeletalhorse/PerkBoneRush.java @@ -250,4 +250,10 @@ public class PerkBoneRush extends SmashPerk implements IThrown { _active.remove(event.getEntity().getUniqueId()); } -} + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/slime/PerkSlimeRocket.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/slime/PerkSlimeRocket.java index c8659cd43..ab02a5e92 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/slime/PerkSlimeRocket.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/slime/PerkSlimeRocket.java @@ -334,6 +334,12 @@ public class PerkSlimeRocket extends SmashPerk implements IThrown { } + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } @EventHandler public void SlimeDamage(CustomDamageEvent event) @@ -433,4 +439,4 @@ public class PerkSlimeRocket extends SmashPerk implements IThrown } } } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/spider/PerkWebShot.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/spider/PerkWebShot.java index ec2bb90fa..49556ba4b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/spider/PerkWebShot.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/spider/PerkWebShot.java @@ -137,6 +137,12 @@ public class PerkWebShot extends SmashPerk implements IThrown { Web(data); } + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } public void Web(ProjectileUser data) { @@ -148,4 +154,4 @@ public class PerkWebShot extends SmashPerk implements IThrown Manager.GetBlockRestore().add(loc.getBlock(), 30, (byte) 0, 2000); } } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/squid/PerkFishFlurry.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/squid/PerkFishFlurry.java index 276650c3e..b070f0a57 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/squid/PerkFishFlurry.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/squid/PerkFishFlurry.java @@ -207,6 +207,12 @@ public class PerkFishFlurry extends SmashPerk implements IThrown { data.getThrown().remove(); } + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } @EventHandler public void Knockback(CustomDamageEvent event) @@ -219,4 +225,4 @@ public class PerkFishFlurry extends SmashPerk implements IThrown event.AddKnockback(GetName(), _knockbackMagnitude); event.setKnockbackOrigin(event.GetDamageeEntity().getLocation().add(Math.random() - 0.5, -0.1, Math.random() - 0.5)); } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/squid/PerkInkBlast.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/squid/PerkInkBlast.java index b2e1a00fc..0b2bd8b82 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/squid/PerkInkBlast.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/squid/PerkInkBlast.java @@ -174,4 +174,10 @@ public class PerkInkBlast extends SmashPerk implements IThrown event.AddKnockback(GetName(), _knockbackMagnitude); } -} + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/witch/PerkWitchPotion.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/witch/PerkWitchPotion.java index 217f01b77..e828c0561 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/witch/PerkWitchPotion.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/witch/PerkWitchPotion.java @@ -191,4 +191,10 @@ public class PerkWitchPotion extends SmashPerk implements IThrown { Collide(null, null, data); } -} + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/zombie/PerkZombieBile.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/zombie/PerkZombieBile.java index 7fb954e14..7e4372195 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/zombie/PerkZombieBile.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/zombie/PerkZombieBile.java @@ -189,6 +189,12 @@ public class PerkZombieBile extends SmashPerk implements IThrown { data.getThrown().remove(); } + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } @EventHandler public void Knockback(CustomDamageEvent event) @@ -200,4 +206,4 @@ public class PerkZombieBile extends SmashPerk implements IThrown event.AddKnockback(GetName(), _knockbackMagnitude); } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/stattrackers/PerfectionistTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/stattrackers/PerfectionistTracker.java index 02de00fc5..87aedb4f3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/stattrackers/PerfectionistTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/stattrackers/PerfectionistTracker.java @@ -14,7 +14,6 @@ import org.bukkit.event.EventHandler; public class PerfectionistTracker extends StatTracker { - private SpeedBuilders _game; private NautHashMap _perfectBuilds = new NautHashMap(); @@ -42,9 +41,8 @@ public class PerfectionistTracker extends StatTracker for (Entry entry : _perfectBuilds.entrySet()) { - if (entry.getValue().intValue() == _game.getRoundsPlayed()) + if (entry.getValue() == _game.getRoundsPlayed()) addStat(entry.getKey(), "PerfectWins", 1, true, false); } } - -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/stacker/Stacker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/stacker/Stacker.java index 7198628f8..fc7acb8fe 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/stacker/Stacker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/stacker/Stacker.java @@ -216,4 +216,10 @@ public class Stacker extends SoloGame implements IThrown { } -} + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java index d9477949f..bad3221c9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java @@ -79,6 +79,7 @@ import org.bukkit.scoreboard.Scoreboard; import org.bukkit.scoreboard.Team; import org.bukkit.util.Vector; +import mineplex.core.Managers; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; @@ -640,9 +641,10 @@ public abstract class SurvivalGames extends Game { if (_deathMatchTime == 5) { + VisibilityManager vm = Managers.require(VisibilityManager.class); for (Player player : GetPlayers(true)) { - VisibilityManager.Instance.refreshPlayerToAll(player); + Bukkit.getOnlinePlayers().forEach(pl -> vm.refreshVisibility(pl, player)); } } else if (_deathMatchTime == 0) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGamesTeams.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGamesTeams.java index b0cae8a9b..0b496e13b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGamesTeams.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGamesTeams.java @@ -7,6 +7,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.Map.Entry; +import mineplex.core.Managers; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.MapUtil; @@ -1211,9 +1212,12 @@ public class SurvivalGamesTeams extends TeamGame if (_deathmatchTime <= 0) return; - + + VisibilityManager vm = Managers.require(VisibilityManager.class); for (Player player : GetPlayers(true)) - VisibilityManager.Instance.refreshPlayerToAll(player); + { + Bukkit.getOnlinePlayers().forEach(pl -> vm.refreshVisibility(pl, player)); + } Announce(C.cRed + C.Bold + "Deathmatch in " + _deathmatchTime + "..."); _deathmatchTime--; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/tutorial/TutorialValentines.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/tutorial/TutorialValentines.java index 6ec02a900..8752de715 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/tutorial/TutorialValentines.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/tutorial/TutorialValentines.java @@ -125,7 +125,7 @@ public class TutorialValentines extends GameTutorial for (Entry data : _pigs.entrySet()) { //Move - if (data.getValue().intValue() == 0) + if (data.getValue() == 0) { if (UtilMath.offset(data.getKey().getLocation(), _pigWaypointA) > 1) { @@ -136,7 +136,7 @@ public class TutorialValentines extends GameTutorial data.setValue(1); } } - if (data.getValue().intValue() == 1) + if (data.getValue() == 1) { if (UtilMath.offset(data.getKey().getLocation(), _pigWaypointB) > 1) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellIcePrison.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellIcePrison.java index 8fdab34d3..19f1aa037 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellIcePrison.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellIcePrison.java @@ -106,6 +106,12 @@ public class SpellIcePrison extends Spell implements SpellClick, IThrown { IcePrison(data); } + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } @EventHandler public void onUpdate(UpdateEvent event) @@ -146,4 +152,4 @@ public class SpellIcePrison extends Spell implements SpellClick, IThrown player.getWorld().playSound(player.getLocation(), Sound.CREEPER_HISS, 1.2F, 0.8F); } } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellIceShards.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellIceShards.java index aad833881..3e35119bf 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellIceShards.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellIceShards.java @@ -152,5 +152,10 @@ public class SpellIceShards extends Spell implements SpellClick, IThrown { handleShard(data); } - -} + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellWebShot.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellWebShot.java index 567078d29..2de1041ab 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellWebShot.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellWebShot.java @@ -156,6 +156,12 @@ public class SpellWebShot extends Spell implements SpellClick, IThrown { Web(data, data.getThrown().getLocation()); } + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } public void Web(ProjectileUser data, Location loc) { @@ -166,4 +172,4 @@ public class SpellWebShot extends Spell implements SpellClick, IThrown if (UtilBlock.airFoliage(block)) block.setType(Material.WEB); } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/zombiesurvival/ZombieSurvival.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/zombiesurvival/ZombieSurvival.java index b21be55bc..2360a40d8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/zombiesurvival/ZombieSurvival.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/zombiesurvival/ZombieSurvival.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftCreature; @@ -15,6 +16,7 @@ import org.bukkit.event.entity.EntityCombustEvent; import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.entity.PlayerDeathEvent; +import mineplex.core.Managers; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; @@ -166,7 +168,8 @@ public class ZombieSurvival extends SoloGame newKit.ApplyKit(player); //Refresh - VisibilityManager.Instance.refreshPlayerToAll(player); + VisibilityManager vm = Managers.require(VisibilityManager.class); + Bukkit.getOnlinePlayers().forEach(pl -> vm.refreshVisibility(pl, player)); if (forced) { @@ -203,7 +206,8 @@ public class ZombieSurvival extends SoloGame GetKit(player).ApplyKit(player); //Refresh on Spawn - VisibilityManager.Instance.refreshPlayerToAll(player); + VisibilityManager vm = Managers.require(VisibilityManager.class); + Bukkit.getOnlinePlayers().forEach(pl -> vm.refreshVisibility(pl, player)); } }, 0); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java index 3204c2dbb..374e0003f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java @@ -2,7 +2,9 @@ package nautilus.game.arcade.gametutorial; import java.util.HashMap; +import mineplex.core.Managers; import mineplex.core.common.util.UtilServer; +import mineplex.core.visibility.VisibilityManager; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.gametutorial.events.GameTutorialEndEvent; @@ -56,21 +58,21 @@ public abstract class GameTutorial { _hasStarted = true; _tick = 0; - for(TutorialPhase phase : _phases) + for (TutorialPhase phase : _phases) phase.setTutorial(this); - if(TutorialNotification) + if (TutorialNotification) { TutorialPhase phase = getPhase(1); - for(TutorialText text : phase.getText()) + for (TutorialText text : phase.getText()) { int index = text.ID(); text.setID(index + 1); } TutorialText[] newText = new TutorialText[phase.getText().length + 1]; - for(int i = 0; i < newText.length; i++) + for (int i = 0; i < newText.length; i++) { - if(i == 0) + if (i == 0) { newText[i] = new TutorialText("Please notice that this is a Tutorial", 20, 1); continue; @@ -106,13 +108,13 @@ public abstract class GameTutorial protected void nextPhase(boolean phaseOne) { TutorialPhase from = _currentPhase; - if(!phaseOne) + if (!phaseOne) _currentPhase = getNextPhase(); - if(_currentPhase == null) + if (_currentPhase == null) { // has ended - if(!CustomEnding) + if (!CustomEnding) { onEnd(); _hasEnded = true; @@ -131,7 +133,7 @@ public abstract class GameTutorial else { // setting another Phase, if Tutorial hasn't stopped yet - if(!_hasEnded) + if (!_hasEnded) { Manager.GetChat().Silence(70000, false); onPhaseChange(_currentPhase); @@ -148,7 +150,8 @@ public abstract class GameTutorial private void endTutorial() { - for(final Player player : _players.keySet()) + VisibilityManager vm = Managers.require(VisibilityManager.class); + for (final Player player : _players.keySet()) { Manager.runSyncLater(new Runnable() { @@ -156,18 +159,18 @@ public abstract class GameTutorial public void run() { // Player visibility/fly mode - for(Player other : Manager.GetGame().GetPlayers(false)) + for (Player other : Manager.GetGame().GetPlayers(false)) { - if(player == other) + if (player == other) continue; - other.showPlayer(player); + vm.showPlayer(other, player, "Game Tutorial"); } player.setAllowFlight(false); player.setFlying(false); } }, 5); - if(TeleportOnEnd) + if (TeleportOnEnd) { Manager.runSyncLater(new Runnable() { @@ -188,13 +191,13 @@ public abstract class GameTutorial protected TutorialPhase getNextPhase() { // getting next TutorialPhase - for(TutorialPhase phase : _phases) + for (TutorialPhase phase : _phases) { - if(_currentPhase == null && phase.ID() == 1) + if (_currentPhase == null && phase.ID() == 1) { return phase; } - else if(_currentPhase != null && _currentPhase.ID() + 1 == phase.ID()) + else if (_currentPhase != null && _currentPhase.ID() + 1 == phase.ID()) { return phase; } @@ -204,11 +207,11 @@ public abstract class GameTutorial private void preparePlayers() { - for(Player player : UtilServer.getPlayers()) + for (Player player : UtilServer.getPlayers()) { // setting Players into fly mode and save their Locations int i = 0; - if(Manager.GetGame().GetTeam(player) == _team) + if (Manager.GetGame().GetTeam(player) == _team) { _players.put(player, Manager.GetGame().GetTeam(player).GetSpawns().get(i)); player.setAllowFlight(true); @@ -220,9 +223,9 @@ public abstract class GameTutorial public TutorialPhase getPhase(int index) { - for(TutorialPhase phase : _phases) + for (TutorialPhase phase : _phases) { - if(phase.ID() == index) + if (phase.ID() == index) return phase; } return null; @@ -255,13 +258,13 @@ public abstract class GameTutorial */ public void end() { - if(CustomEnding) + if (CustomEnding) { // Ending onEnd(); _hasEnded = true; Thread thread = _currentPhase.getThread(); - if(thread.isAlive()) + if (thread.isAlive()) thread.destroy(); endTutorial(); @@ -283,14 +286,14 @@ public abstract class GameTutorial public int tick() { - // Fix for Visibility Manager not really working - if(!_hasEnded && hasStarted()) + if (!_hasEnded && hasStarted()) { - for(Player player : UtilServer.getPlayers()) + VisibilityManager vm = Managers.require(VisibilityManager.class); + for (Player player : UtilServer.getPlayers()) { - for(Player other : _players.keySet()) + for (Player other : _players.keySet()) { - player.hidePlayer(other); + vm.hidePlayer(player, other, "Game Tutorial"); } } } @@ -333,6 +336,5 @@ public abstract class GameTutorial public void onPhaseChange(TutorialPhase phase){} - public void onEnd(){} - -} + public void onEnd(){} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkApple.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkApple.java index 18d24b75b..ad3125e95 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkApple.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkApple.java @@ -23,7 +23,6 @@ import mineplex.core.projectile.ProjectileUser; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; - import nautilus.game.arcade.kit.Perk; public class PerkApple extends Perk implements IThrown @@ -141,6 +140,12 @@ public class PerkApple extends Perk implements IThrown { } + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } @EventHandler public void playerDeath(PlayerDeathEvent event) @@ -158,4 +163,4 @@ public class PerkApple extends Perk implements IThrown } } } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkAxeThrower.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkAxeThrower.java index 5f4aab77b..e9272e6eb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkAxeThrower.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkAxeThrower.java @@ -20,7 +20,6 @@ import mineplex.core.common.util.UtilInv; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.projectile.IThrown; import mineplex.core.projectile.ProjectileUser; -import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.kit.Perk; public class PerkAxeThrower extends Perk implements IThrown @@ -107,4 +106,10 @@ public class PerkAxeThrower extends Perk implements IThrown { } -} + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBaconBlast.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBaconBlast.java index a24bec73d..c2d2b1dfe 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBaconBlast.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBaconBlast.java @@ -105,6 +105,12 @@ public class PerkBaconBlast extends Perk implements IThrown { Explode(data); } + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } public void Explode(ProjectileUser data) { @@ -113,4 +119,4 @@ public class PerkBaconBlast extends Perk implements IThrown data.getThrown().getWorld().createExplosion(loc.getX(), loc.getY(), loc.getZ(), 0.5f, false, false); data.getThrown().remove(); } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBlockRestorer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBlockRestorer.java index c4c754d8f..21f79c731 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBlockRestorer.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBlockRestorer.java @@ -92,4 +92,10 @@ public class PerkBlockRestorer extends Perk implements IThrown UtilFirework.playFirework(entity.getLocation(), Type.BALL_LARGE, Color.WHITE, false, true); } -} + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkCowBomb.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkCowBomb.java index 535dc0ca5..a8c1fda22 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkCowBomb.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkCowBomb.java @@ -122,6 +122,12 @@ public class PerkCowBomb extends Perk implements IThrown data.getThrown().getWorld().createExplosion(data.getThrown().getLocation(), 0.5f); data.getThrown().remove(); } + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } @EventHandler public void Knockback(CustomDamageEvent event) @@ -131,4 +137,4 @@ public class PerkCowBomb extends Perk implements IThrown event.AddKnockback(GetName(), 5); } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDirtCannon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDirtCannon.java index 243d29eea..ffb4cbb54 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDirtCannon.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDirtCannon.java @@ -217,5 +217,10 @@ public class PerkDirtCannon extends Perk implements IThrown { } - -} + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkHammerThrow.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkHammerThrow.java index f8ebc7caa..7edb9d0a2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkHammerThrow.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkHammerThrow.java @@ -3,6 +3,21 @@ package nautilus.game.arcade.kit.perks; import java.util.HashMap; import java.util.Iterator; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Giant; +import org.bukkit.entity.Item; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; + import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; @@ -21,21 +36,6 @@ import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.kit.Perk; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.block.Block; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Giant; -import org.bukkit.entity.Item; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerPickupItemEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.util.Vector; - public class PerkHammerThrow extends Perk implements IThrown { private HashMap _thrown = new HashMap(); @@ -156,6 +156,12 @@ public class PerkHammerThrow extends Perk implements IThrown { Rebound(data.getThrower(), data.getThrown()); } + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } public void Rebound(LivingEntity player, Entity ent) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkIronHook.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkIronHook.java index 1b86acc73..97a481d91 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkIronHook.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkIronHook.java @@ -142,5 +142,10 @@ public class PerkIronHook extends Perk implements IThrown { data.getThrown().remove(); } - -} + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkMadScientist.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkMadScientist.java index cc9ddc0f3..8e004186c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkMadScientist.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkMadScientist.java @@ -257,5 +257,10 @@ public class PerkMadScientist extends Perk implements IThrown Manager.GetGame().CreatureAllowOverride = false; } - -} + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkRevealer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkRevealer.java index 37dabb0f8..3ec71307e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkRevealer.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkRevealer.java @@ -142,6 +142,12 @@ public class PerkRevealer extends Perk implements IThrown { explode(data); } + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } private void explode(ProjectileUser data) { @@ -182,4 +188,4 @@ public class PerkRevealer extends Perk implements IThrown { return _revealedPlayers; } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSquidRifle.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSquidRifle.java index 0157bf271..d1d7a5837 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSquidRifle.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSquidRifle.java @@ -152,6 +152,12 @@ public class PerkSquidRifle extends Perk implements IThrown { Explode(data); } + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } public void Explode(ProjectileUser data) { @@ -172,4 +178,4 @@ public class PerkSquidRifle extends Perk implements IThrown e.printStackTrace(); } } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSquidShotgun.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSquidShotgun.java index 797468967..26299d6eb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSquidShotgun.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSquidShotgun.java @@ -169,6 +169,12 @@ public class PerkSquidShotgun extends Perk implements IThrown { Explode(data); } + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } public void Explode(ProjectileUser data) { @@ -189,4 +195,4 @@ public class PerkSquidShotgun extends Perk implements IThrown e.printStackTrace(); } } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSquidSniper.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSquidSniper.java index 96b38e418..d11253b89 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSquidSniper.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSquidSniper.java @@ -160,6 +160,12 @@ public class PerkSquidSniper extends Perk implements IThrown { Explode(data); } + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } public void Explode(ProjectileUser data) { @@ -180,4 +186,4 @@ public class PerkSquidSniper extends Perk implements IThrown e.printStackTrace(); } } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkThrower.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkThrower.java index 839267354..73b51e75a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkThrower.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkThrower.java @@ -19,7 +19,6 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.projectile.IThrown; import mineplex.core.projectile.ProjectileUser; import mineplex.core.recharge.Recharge; -import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.kit.Perk; public class PerkThrower extends Perk implements IThrown @@ -125,4 +124,10 @@ public class PerkThrower extends Perk implements IThrown { } -} + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWeb.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWeb.java index dcaa8df8d..5aeba25f5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWeb.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWeb.java @@ -129,6 +129,12 @@ public class PerkWeb extends Perk implements IThrown Web(data); } + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } + public void Web(ProjectileUser data) { Location loc = data.getThrown().getLocation(); @@ -136,4 +142,4 @@ public class PerkWeb extends Perk implements IThrown Manager.GetBlockRestore().add(loc.getBlock(), 30, (byte) 0, 4000); } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitherWeb.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitherWeb.java index d643727a3..0f9ad5992 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitherWeb.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitherWeb.java @@ -95,6 +95,12 @@ public class PerkWitherWeb extends Perk implements IThrown { Web(data); } + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } public void Web(ProjectileUser data) { @@ -104,4 +110,4 @@ public class PerkWitherWeb extends Perk implements IThrown if (data.getThrown().getTicksLived() > 3) Manager.GetBlockRestore().add(loc.getBlock(), 30, (byte) 0, 3000); } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWoolBomb.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWoolBomb.java index 073500018..31e51e04e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWoolBomb.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWoolBomb.java @@ -349,6 +349,12 @@ public class PerkWoolBomb extends Perk implements IThrown { solidify(data.getThrower(), false); } + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } @EventHandler public void colorExpireUpdate(UpdateEvent event) @@ -410,4 +416,4 @@ public class PerkWoolBomb extends Perk implements IThrown event.AddKnockback(GetName(), _knockbackMagnitude); } -} +} \ No newline at end of file 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 913432715..8da55ff06 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 @@ -72,7 +72,6 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.condition.Condition.ConditionType; import mineplex.minecraft.game.core.damage.CustomDamageEvent; - import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; @@ -824,7 +823,7 @@ public class GameFlagManager implements Listener Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), () -> { Long t = Double.valueOf(timeF).longValue(); - _respawnTimers.put(player, Long.valueOf(System.currentTimeMillis() + UtilTime.convert(t, TimeUnit.SECONDS, TimeUnit.MILLISECONDS))); + _respawnTimers.put(player, System.currentTimeMillis() + UtilTime.convert(t, TimeUnit.SECONDS, TimeUnit.MILLISECONDS)); }, 6); int run = Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), () -> { @@ -843,7 +842,7 @@ public class GameFlagManager implements Listener _respawnRunnables.remove(player); }, (int)(time * 20d)); - _respawnRunnables.put(player, Integer.valueOf(run)); + _respawnRunnables.put(player, run); } } @@ -1292,7 +1291,7 @@ public class GameFlagManager implements Listener _respawnTimers.clear(); for (Integer r : _respawnRunnables.values()) { - Bukkit.getScheduler().cancelTask(r.intValue()); + Bukkit.getScheduler().cancelTask(r); } _respawnRunnables.clear(); return; @@ -1302,7 +1301,7 @@ public class GameFlagManager implements Listener _respawnTimers.clear(); for (Integer r : _respawnRunnables.values()) { - Bukkit.getScheduler().cancelTask(r.intValue()); + Bukkit.getScheduler().cancelTask(r); } _respawnRunnables.clear(); return; @@ -1317,12 +1316,12 @@ public class GameFlagManager implements Listener respawnIterator.remove(); continue; } - if (System.currentTimeMillis() >= next.getValue().longValue()) + if (System.currentTimeMillis() >= next.getValue()) { respawnIterator.remove(); continue; } - long sec = UtilTime.convert(next.getValue().longValue() - System.currentTimeMillis(), TimeUnit.MILLISECONDS, TimeUnit.SECONDS); + long sec = UtilTime.convert(next.getValue() - System.currentTimeMillis(), TimeUnit.MILLISECONDS, TimeUnit.SECONDS); ChatColor color = ChatColor.RED; if (sec < 8) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java index 455ef8c40..24d9f717f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java @@ -714,7 +714,7 @@ public class GameHostManager implements Listener { if (isCommunityServer()) { - if (getOwner().getId().intValue() == event.getCommunity().getId().intValue()) + if (getOwner().getId() == event.getCommunity().getId()) { setHostExpired(true, getOwner().getName() + " has disbanded and abandoned the server. Thanks for playing!"); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java index a0edb1a15..a2069084b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java @@ -39,10 +39,9 @@ import mineplex.core.gadget.types.GadgetType; import mineplex.core.portal.GenericServer; import mineplex.core.portal.Intent; import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.RestartServerEvent; +import mineplex.core.updater.event.RestartTriggerEvent; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.condition.Condition.ConditionType; - import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.events.GamePrepareCountdownCommence; import nautilus.game.arcade.events.GameStateChangeEvent; @@ -452,9 +451,9 @@ public class GameManager implements Listener } @EventHandler - public void restartServerCheck(RestartServerEvent event) + public void restartServerCheck(RestartTriggerEvent event) { - if (Manager.GetGame() != null && Manager.GetGame().GetState() != GameState.Recruit) + if (Manager.GetGame() != null && Manager.GetGame().GetState() != GameState.Recruit && event.getReason() == RestartTriggerEvent.RestartReason.UPDATE) event.setCancelled(true); } diff --git a/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/Hub.java b/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/Hub.java index 65885886a..2588beddb 100644 --- a/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/Hub.java +++ b/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/Hub.java @@ -84,7 +84,7 @@ public class Hub extends JavaPlugin ItemStackFactory.Initialize(this, false); Recharge.Initialize(this); - VisibilityManager.Initialize(this); + require(VisibilityManager.class); Give.Initialize(this); // Velocity Fix diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java index 2e5e560c9..b644aa575 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java @@ -139,7 +139,7 @@ public class GemHunters extends JavaPlugin Recharge.Initialize(this); // Visibility - VisibilityManager.Initialize(this); + require(VisibilityManager.class); // Give Give.Initialize(this); diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/death/DeathModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/death/DeathModule.java index cf5a05dcc..ed5f9e55d 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/death/DeathModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/death/DeathModule.java @@ -26,6 +26,7 @@ import org.bukkit.event.player.PlayerQuitEvent; import com.google.common.collect.Sets; +import mineplex.core.Managers; import mineplex.core.MiniPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; import mineplex.core.common.util.C; @@ -36,6 +37,7 @@ import mineplex.core.common.util.UtilTime; import mineplex.core.stats.StatsManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.visibility.VisibilityManager; import mineplex.gemhunters.death.event.PlayerCustomRespawnEvent; import mineplex.gemhunters.playerstatus.PlayerStatusModule; import mineplex.gemhunters.playerstatus.PlayerStatusType; @@ -146,9 +148,10 @@ public class DeathModule extends MiniPlugin player.setFlying(true); player.setGameMode(GameMode.CREATIVE); + VisibilityManager vm = Managers.require(VisibilityManager.class); for (Player other : Bukkit.getOnlinePlayers()) { - other.hidePlayer(player); + vm.hidePlayer(other, player, "GH Respawning"); } _playerStatus.setStatus(player, PlayerStatusType.DANGER, true); @@ -162,10 +165,11 @@ public class DeathModule extends MiniPlugin player.setAllowFlight(false); player.setGameMode(GameMode.SURVIVAL); _spawn.teleportToSpawn(player); - + + VisibilityManager vm = Managers.require(VisibilityManager.class); for (Player other : Bukkit.getOnlinePlayers()) { - other.showPlayer(player); + vm.showPlayer(other, player, "GH Respawning"); } PlayerCustomRespawnEvent event = new PlayerCustomRespawnEvent(player); @@ -245,4 +249,4 @@ public class DeathModule extends MiniPlugin { return _toRemove.containsKey(player.getUniqueId()); } -} +} \ No newline at end of file diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/CashOutModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/CashOutModule.java index cd5e5ca08..efbf10c39 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/CashOutModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/CashOutModule.java @@ -187,6 +187,8 @@ public class CashOutModule extends MiniPlugin session.endSession(); iterator.remove(); + player.getInventory().clear(); + if (UtilServer.isTestServer()) { kickPlayer(player); diff --git a/Plugins/pom.xml b/Plugins/pom.xml index 95880e508..e6a20d519 100644 --- a/Plugins/pom.xml +++ b/Plugins/pom.xml @@ -25,6 +25,8 @@ Mineplex.Database Mineplex.DDoSProtectionSwitcher Mineplex.EnjinTranslator + Mineplex.ClansQueue.Common + Mineplex.ClansQueue Mineplex.Game.Clans Mineplex.Game.Clans.Core Mineplex.Game.Clans.Compensation