Merge remote-tracking branch 'refs/remotes/origin/develop' into update/hub-makeover

This commit is contained in:
Sam 2017-10-01 14:41:38 +01:00
commit 4a9689bd17
343 changed files with 8478 additions and 2810 deletions

View File

@ -99,6 +99,7 @@ public class ClansGenerator extends JavaPlugin implements Runnable, Listener
getServer().getPluginManager().registerEvents(this, this); getServer().getPluginManager().registerEvents(this, this);
} }
@SuppressWarnings("deprecation")
@EventHandler @EventHandler
public void onPopulate(ChunkPopulateEvent event) public void onPopulate(ChunkPopulateEvent event)
{ {
@ -117,6 +118,27 @@ public class ClansGenerator extends JavaPlugin implements Runnable, Listener
{ {
getLogger().info("Removing dungeon pieces"); 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;
} }
} }
} }

View File

@ -0,0 +1,23 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.mineplex</groupId>
<artifactId>mineplex-parent</artifactId>
<version>dev-SNAPSHOT</version>
<relativePath>../plugin.xml</relativePath>
</parent>
<name>ClansQueue-Common</name>
<artifactId>mineplex-clansqueue-common</artifactId>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>mineplex-serverdata</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,8 @@
package com.mineplex.clansqueue.common;
public class ClansQueueMessage
{
protected String Origin;
protected String BodyClass;
protected String BodySerialized;
}

View File

@ -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);
}
}

View File

@ -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<String, ClansQueueMessenger> _messengers = new ConcurrentHashMap<>();
private final String _identifier;
private final JedisPool _readPool;
private final JedisPool _writePool;
@SuppressWarnings("rawtypes")
private final Map<String, Class> _bodyTypes = Collections.synchronizedMap(new HashMap<>());
@SuppressWarnings("rawtypes")
private final Map<String, List<BiConsumer>> _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 <T extends ClansQueueMessageBody> void registerListener(Class<T> messageType, BiConsumer<T, String> 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 <T extends ClansQueueMessageBody> void receiveMessage(ClansQueueMessage message)
{
if (_listeners.containsKey(message.BodyClass) && _bodyTypes.containsKey(message.BodyClass))
{
T body = Utility.deserialize(message.BodySerialized, (Class<T>)_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));
}
}

View File

@ -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;
}

View File

@ -0,0 +1,13 @@
package com.mineplex.clansqueue.common;
import java.util.LinkedList;
public class SortableLinkedList<T extends Comparable<T>> extends LinkedList<T>
{
private static final long serialVersionUID = -1751886037436467545L;
public void sort()
{
sort((t1, t2) -> t1.compareTo(t2));
}
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -0,0 +1,8 @@
package com.mineplex.clansqueue.common.messages;
import com.mineplex.clansqueue.common.ClansQueueMessageBody;
public class QueueDeleteMessage extends ClansQueueMessageBody
{
public String ServerName;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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<QueueSnapshot> Snapshots = new ArrayList<>();
public static class QueueSnapshot
{
public String ServerName;
public Map<UUID, Integer> Queue;
public boolean Paused;
}
}

View File

@ -0,0 +1,8 @@
package com.mineplex.clansqueue.common.messages;
import com.mineplex.clansqueue.common.ClansQueueMessageBody;
public class ServerOfflineMessage extends ClansQueueMessageBody
{
public String ServerName;
}

View File

@ -0,0 +1,8 @@
package com.mineplex.clansqueue.common.messages;
import com.mineplex.clansqueue.common.ClansQueueMessageBody;
public class ServerOnlineMessage extends ClansQueueMessageBody
{
public String ServerName;
}

View File

@ -0,0 +1,48 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.mineplex</groupId>
<artifactId>mineplex-plugin</artifactId>
<version>dev-SNAPSHOT</version>
<relativePath>../plugin.xml</relativePath>
</parent>
<name>ClansQueue</name>
<artifactId>mineplex-clansqueue</artifactId>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>mineplex-clansqueue-common</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<configuration>
<minimizeJar>false</minimizeJar>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.mineplex.clansqueue.service.QueueService</mainClass>
</transformer>
</transformers>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -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<String, ConsoleCommand> _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);
}
}

View File

@ -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<String, ConsoleCommand> _commands;
public CommandSystem(QueueService service, Map<String, ConsoleCommand> 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<ConsoleCommand> 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.");
}
}
}
}
}

View File

@ -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);
}

View File

@ -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 <Server>");
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();
}
}

View File

@ -0,0 +1,41 @@
package com.mineplex.clansqueue.service.commands;
import java.util.Map;
public class HelpCommand extends ConsoleCommand
{
private final Map<String, ConsoleCommand> _commands;
public HelpCommand(Map<String, ConsoleCommand> 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();
}
}

View File

@ -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();
}
}

View File

@ -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 <Server>");
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();
}
}

View File

@ -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();
}
}

View File

@ -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 <Server>");
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();
}
}

View File

@ -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<String, ClansServer> _servers = new HashMap<>();
private final Map<ClansServer, ServerQueue> _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<ServerQueue> 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<ServerQueue> 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<ClansServer> 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();
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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<UUID, String> _sending = new LinkedHashMap<>();
private final Map<UUID, String> _bypassing = new LinkedHashMap<>();
private final SortableLinkedList<PlayerQueue> _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<UUID, String> getNextSend()
{
synchronized (_sendLock)
{
Map<UUID, String> sending = new LinkedHashMap<>();
sending.putAll(_sending);
_sending.clear();
return sending;
}
}
public Map<UUID, QueuePlayer> getPlayers()
{
synchronized (_queueLock)
{
Map<UUID, QueuePlayer> 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<QueuePlayer> callback)
{
synchronized (_queueLock)
{
Optional<PlayerQueue> 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<UUID, String> 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<PlayerQueue>
{
private final int _weight;
private final Queue<QueuePlayer> _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;
}
}
}

View File

@ -78,7 +78,7 @@ public class UtilCollections
{ {
for (int i = 0; i < elements.length; i++) 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++) 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()); return optionalList.stream().filter(Optional::isPresent).map(Optional::get).collect(Collectors.toList());
} }
} }

View File

@ -54,5 +54,4 @@ public class AnimationPoint
{ {
return Objects.hash(_tick, _move); return Objects.hash(_tick, _move);
} }
}
}

View File

@ -6,6 +6,7 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Objects;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
@ -154,7 +155,7 @@ public class IntlString
@Override @Override
public int hashCode() public int hashCode()
{ {
return toString().hashCode(); return Objects.hash(getKey(), getArguments());
} }
@Override @Override
@ -220,7 +221,7 @@ public class IntlString
@Override @Override
public int hashCode() public int hashCode()
{ {
return toString().hashCode(); return Objects.hash(getArgument(), getStyle());
} }
@Override @Override

View File

@ -45,7 +45,8 @@ public class SkinData
public final static SkinData STEVE = new SkinData("eyJ0aW1lc3RhbXAiOjE0NjY3MzgxOTAzNDYsInByb2ZpbGVJZCI6ImJiYjg3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YXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzczMTY5YWQwZTUyYjM1N2NiZGYxZDU0NGVkNGNmOWJmOTI4YmI0ZWNlMDhlY2YyY2M0YmYyYTlmMjJhODI4MmQifX19", "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("eyJ0aW1lc3RhbXAiOjE1MDEzNjU5Mjc3OTMsInByb2ZpbGVJZCI6ImJiMDgwOTFhOTJlZDQzYWQ5NGYxZWRmZDc0NmIwYTJjIiwicHJvZmlsZU5hbWUiOiJJcDRuZHgiLCJzaWduY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MubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzJkODc1ZGY4NzM3MDk1YjczZDQ5YmJkZTE5YjM5NDg0MzIxMjY5Y2MyNTU5YTlkMzQ2NWU1OGRiYTJkOWFiNSJ9fX0=", "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 // Comments this out for now, so it doesn't load the player profile

View File

@ -1,15 +1,7 @@
package mineplex.core.common.util; 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.Collection;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -17,12 +9,21 @@ import java.util.UUID;
import java.util.WeakHashMap; import java.util.WeakHashMap;
import java.util.concurrent.ConcurrentHashMap; 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<V> implements Map<UUID, V> public class PlayerMap<V> implements Map<UUID, V>
{ {
private static final Object LOCK = new Object(); private static final Object LOCK = new Object();
private static final RemovalListener REMOVAL_LISTENER = new RemovalListener(); private static final RemovalListener REMOVAL_LISTENER = new RemovalListener();
private static final Set<PlayerMap<?>> ALL_PLAYER_MAPS = Sets.newSetFromMap(new WeakHashMap<>()); private static final Set<PlayerMap<?>> ALL_PLAYER_MAPS = Collections.newSetFromMap(new WeakHashMap<>());
static static
{ {
@ -231,4 +232,4 @@ public class PlayerMap<V> implements Map<UUID, V>
} }
} }
} }
} }

View File

@ -9,16 +9,6 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.UUID; 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.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.SkullType; import org.bukkit.SkullType;
@ -47,6 +37,16 @@ import com.mojang.authlib.GameProfile;
import mineplex.core.common.Pair; import mineplex.core.common.Pair;
import mineplex.core.common.block.MultiBlockUpdaterAgent; import mineplex.core.common.block.MultiBlockUpdaterAgent;
import mineplex.core.common.skin.SkinData; 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 public class UtilBlock
{ {
@ -109,6 +109,7 @@ public class UtilBlock
blockAirFoliageSet.add((byte) Material.AIR.getId()); blockAirFoliageSet.add((byte) Material.AIR.getId());
blockAirFoliageSet.add((byte) Material.SAPLING.getId()); blockAirFoliageSet.add((byte) Material.SAPLING.getId());
blockAirFoliageSet.add((byte) Material.LONG_GRASS.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.DEAD_BUSH.getId());
blockAirFoliageSet.add((byte) Material.YELLOW_FLOWER.getId()); blockAirFoliageSet.add((byte) Material.YELLOW_FLOWER.getId());
blockAirFoliageSet.add((byte) Material.RED_ROSE.getId()); blockAirFoliageSet.add((byte) Material.RED_ROSE.getId());
@ -628,6 +629,14 @@ public class UtilBlock
return false; return false;
} }
public static List<Block> 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<Block> getInBoundingBox(Location a, Location b) public static ArrayList<Block> getInBoundingBox(Location a, Location b)
{ {
return getInBoundingBox(a, b, true); return getInBoundingBox(a, b, true);

View File

@ -947,21 +947,22 @@ public class UtilEnt
**/ **/
public static int getNewEntityId(boolean modifynumber) public static int getNewEntityId(boolean modifynumber)
{ {
try try
{ {
Field field = net.minecraft.server.v1_8_R3.Entity.class.getDeclaredField("entityCount"); Field field = net.minecraft.server.v1_8_R3.Entity.class.getDeclaredField("entityCount");
field.setAccessible(true); field.setAccessible(true);
int entityId = field.getInt(null); int entityId = field.getInt(null);
if (modifynumber) { if (modifynumber)
field.set(null, Integer.valueOf(entityId + 1)); {
} field.set(null, entityId + 1);
return entityId; }
} return entityId;
catch (Exception ex) }
{ catch (Exception ex)
ex.printStackTrace(); {
} ex.printStackTrace();
return -1; }
return -1;
} }
public static Entity getEntityById(int entityId) public static Entity getEntityById(int entityId)

View File

@ -670,7 +670,7 @@ public class UtilItem
public static boolean isBoundless(Material material) 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) public static boolean isBoundless(ItemStack stack)

View File

@ -133,38 +133,6 @@ public class UtilPlayer
return entry.trackedPlayers.contains(ep); return entry.trackedPlayers.contains(ep);
} }
public static void hideFrom(Player player, Collection<Player> players) {
players.stream().forEach(p->p.hidePlayer(player));
}
public static void showFor(Player player, Collection<Player> players) {
players.stream().forEach(p->p.hidePlayer(player));
}
public static void hideFromAll(Player player, Collection<Player> except) {
UtilServer.getPlayersCollection().stream().filter(p->!except.contains(p)).forEach(p->p.hidePlayer(player));
}
public static void showForAll(Player player, Collection<Player> 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) public static boolean is1_9(Player player)
{ {

View File

@ -1,8 +1,18 @@
package mineplex.core.common.util; package mineplex.core.common.util;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map;
import java.util.UUID; 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 mineplex.core.common.DummyEntity;
import net.minecraft.server.v1_8_R3.DataWatcher; import net.minecraft.server.v1_8_R3.DataWatcher;
import net.minecraft.server.v1_8_R3.Entity; 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.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; 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 public class UtilTextTop
{ {
// Base Commands // Base Commands
@ -42,7 +41,7 @@ public class UtilTextTop
public static final int EntityDragonId = 777777; public static final int EntityDragonId = 777777;
public static final int EntityWitherId = 777778; public static final int EntityWitherId = 777778;
public static final UUID BossUUID = UUID.fromString("178f5cde-2fb0-3e73-8296-967ec7e46748"); public static final UUID BossUUID = UUID.fromString("178f5cde-2fb0-3e73-8296-967ec7e46748");
private static HashMap<String, BukkitRunnable> _lastUpdated = new HashMap<String, BukkitRunnable>(); private static Map<String, BukkitRunnable> _lastUpdated = new HashMap<>();
// Display // Display
public static void displayTextBar(final Player player, double healthPercent, String text) 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)) if (UtilPlayer.is1_9(player))
{ {

View File

@ -1,13 +1,12 @@
package mineplex.core.common.util.particles; 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.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import mineplex.core.common.util.UtilParticle;
public class ColoredParticle extends ParticleData public class ColoredParticle extends ParticleData
{ {
private ParticleColor _color; private ParticleColor _color;
public ColoredParticle(UtilParticle.ParticleType particleType, ParticleColor color, Location location) 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) public void setColor(ParticleColor color)
{ {
_color = color; _color = color;
} }
}
}

View File

@ -7,7 +7,6 @@ import org.bukkit.entity.Player;
public class ParticleData public class ParticleData
{ {
protected UtilParticle.ParticleType _particleType; protected UtilParticle.ParticleType _particleType;
protected Location _location; protected Location _location;
@ -18,8 +17,8 @@ public class ParticleData
} }
/** /**
* Displays the particles for all the players with a different ammount * Displays the particles for all the players with a different amount
* @param count the ammount of particles * @param count the amount of particles
*/ */
public void display(int count) public void display(int count)
{ {
@ -73,5 +72,4 @@ public class ParticleData
{ {
return _location; return _location;
} }
}
}

View File

@ -9,10 +9,9 @@ import java.util.stream.Collectors;
public class WeightSet<T> public class WeightSet<T>
{ {
private static Random random = new Random(); private static Random random = new Random();
private Set<Weight<T>> _weights = new HashSet<Weight<T>>(); private Set<Weight<T>> _weights = new HashSet<>();
private volatile transient Set<T> _keyset; private volatile transient Set<T> _keyset;
@ -50,10 +49,18 @@ public class WeightSet<T>
computeKeyset(); computeKeyset();
} }
public void add(int weight, T element) public Weight<T> add(int weight, T element)
{ {
_weights.add(new Weight<T>(weight, element)); Weight<T> w = new Weight<>(weight, element);
_weights.add(w);
computeKeyset(); computeKeyset();
return w;
}
public void remove(Weight<T> weight)
{
_weights.remove(weight);
} }
private int getTotalWeight() private int getTotalWeight()
@ -89,11 +96,11 @@ public class WeightSet<T>
public Set<T> elements() public Set<T> elements()
{ {
return this._keyset; return _keyset;
} }
private void computeKeyset() private void computeKeyset()
{ {
_keyset = Collections.unmodifiableSet(_weights.stream().map(Weight::getValue).collect(Collectors.toSet())); _keyset = Collections.unmodifiableSet(_weights.stream().map(Weight::getValue).collect(Collectors.toSet()));
} }
} }

View File

@ -617,7 +617,6 @@ public class CoreClientManager extends MiniPlugin
if (client.hasPermission(Perm.JOIN_FULL)) if (client.hasPermission(Perm.JOIN_FULL))
{ {
event.allow(); event.allow();
event.setResult(PlayerLoginEvent.Result.ALLOWED);
return; return;
} }

View File

@ -50,7 +50,7 @@ public enum PermissionGroup
//SUB-GROUPS //SUB-GROUPS
QA("qa", "", "Members of the Quality Assurance team.", ChatColor.WHITE, 50, false), 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), 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), TM("tm", "", "Members of the Trainee Management team.", ChatColor.WHITE, 52, false),
MC("mc", "", "Members of the Moderator Coordination team.", ChatColor.WHITE, 49, 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), EVENTMOD("eventmod", "", "Members of the Event Management team.", ChatColor.WHITE, -1, false),

View File

@ -5,6 +5,7 @@ import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import org.bukkit.Effect; import org.bukkit.Effect;
@ -15,6 +16,7 @@ import org.bukkit.block.BlockFace;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.event.block.BlockPistonExtendEvent; import org.bukkit.event.block.BlockPistonExtendEvent;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.world.ChunkUnloadEvent; import org.bukkit.event.world.ChunkUnloadEvent;
@ -29,7 +31,7 @@ import mineplex.core.updater.event.UpdateEvent;
@ReflectivelyCreateMiniPlugin @ReflectivelyCreateMiniPlugin
public class BlockRestore extends MiniPlugin public class BlockRestore extends MiniPlugin
{ {
private HashMap<Block, BlockRestoreData> _blocks = new HashMap<Block, BlockRestoreData>(); private Map<Block, BlockRestoreData> _blocks = new HashMap<>();
private LinkedList<BlockRestoreMap> _restoreMaps; private LinkedList<BlockRestoreMap> _restoreMaps;
private BlockRestore() private BlockRestore()
@ -266,7 +268,7 @@ public class BlockRestore extends MiniPlugin
return null; return null;
} }
public HashMap<Block, BlockRestoreData> getBlocks() public Map<Block, BlockRestoreData> getBlocks()
{ {
return _blocks; return _blocks;
} }
@ -282,6 +284,15 @@ public class BlockRestore extends MiniPlugin
{ {
_restoreMaps.remove(blockRestore); _restoreMaps.remove(blockRestore);
} }
@EventHandler
public void onBlockPhysics(BlockPhysicsEvent event)
{
if (_blocks.containsKey(event.getBlock()))
{
event.setCancelled(true);
}
}
@Override @Override
public void disable() public void disable()
@ -294,4 +305,4 @@ public class BlockRestore extends MiniPlugin
restoreAll(); restoreAll();
} }
} }

View File

@ -365,7 +365,7 @@ public class Chat extends MiniPlugin
for (Function<AsyncPlayerChatEvent, Boolean> filter : _highPriorityFilters) for (Function<AsyncPlayerChatEvent, Boolean> filter : _highPriorityFilters)
{ {
if (filter.apply(event).booleanValue()) if (filter.apply(event))
{ {
event.setCancelled(true); event.setCancelled(true);
return; return;
@ -433,7 +433,7 @@ public class Chat extends MiniPlugin
for (Function<AsyncPlayerChatEvent, Boolean> filter : _lowPriorityFilters) for (Function<AsyncPlayerChatEvent, Boolean> filter : _lowPriorityFilters)
{ {
if (filter.apply(event).booleanValue()) if (filter.apply(event))
{ {
event.setCancelled(true); event.setCancelled(true);
return; return;

View File

@ -137,7 +137,7 @@ public class CommunityJoinRequestsPage extends CommunitiesGUIPage
@EventHandler @EventHandler
public void onMembershipUpdate(CommunityMembershipUpdateEvent event) public void onMembershipUpdate(CommunityMembershipUpdateEvent event)
{ {
if (event.getCommunity().getId().intValue() != _community.getId().intValue()) if (event.getCommunity().getId() != _community.getId())
{ {
return; return;
} }
@ -155,7 +155,7 @@ public class CommunityJoinRequestsPage extends CommunitiesGUIPage
@EventHandler @EventHandler
public void onRequestsUpdate(CommunityJoinRequestsUpdateEvent event) public void onRequestsUpdate(CommunityJoinRequestsUpdateEvent event)
{ {
if (event.getCommunity().getId().intValue() != _community.getId().intValue()) if (event.getCommunity().getId() != _community.getId())
{ {
return; return;
} }
@ -165,7 +165,7 @@ public class CommunityJoinRequestsPage extends CommunitiesGUIPage
@EventHandler @EventHandler
public void onCommunityDisband(CommunityDisbandEvent event) public void onCommunityDisband(CommunityDisbandEvent event)
{ {
if (_community.getId().intValue() == event.getCommunity().getId().intValue()) if (_community.getId() == event.getCommunity().getId())
{ {
Viewer.closeInventory(); Viewer.closeInventory();
} }

View File

@ -158,7 +158,7 @@ public class CommunityMembersPage extends CommunitiesGUIPage
@EventHandler @EventHandler
public void onRequestsUpdate(CommunityJoinRequestsUpdateEvent event) public void onRequestsUpdate(CommunityJoinRequestsUpdateEvent event)
{ {
if (event.getCommunity().getId().intValue() != _community.getId().intValue()) if (event.getCommunity().getId() != _community.getId())
{ {
return; return;
} }
@ -171,7 +171,7 @@ public class CommunityMembersPage extends CommunitiesGUIPage
@EventHandler @EventHandler
public void onMembershipUpdate(CommunityMembershipUpdateEvent event) public void onMembershipUpdate(CommunityMembershipUpdateEvent event)
{ {
if (event.getCommunity().getId().intValue() != _community.getId().intValue()) if (event.getCommunity().getId() != _community.getId())
{ {
return; return;
} }
@ -182,7 +182,7 @@ public class CommunityMembersPage extends CommunitiesGUIPage
@EventHandler @EventHandler
public void onCommunityDisband(CommunityDisbandEvent event) public void onCommunityDisband(CommunityDisbandEvent event)
{ {
if (_community.getId().intValue() == event.getCommunity().getId().intValue()) if (_community.getId() == event.getCommunity().getId())
{ {
Viewer.closeInventory(); Viewer.closeInventory();
} }

View File

@ -109,7 +109,7 @@ public class CommunitySettingsPage extends CommunitiesGUIPage
@EventHandler @EventHandler
public void onRequestsUpdate(CommunityJoinRequestsUpdateEvent event) public void onRequestsUpdate(CommunityJoinRequestsUpdateEvent event)
{ {
if (event.getCommunity().getId().intValue() != _community.getId().intValue()) if (event.getCommunity().getId() != _community.getId())
{ {
return; return;
} }
@ -122,7 +122,7 @@ public class CommunitySettingsPage extends CommunitiesGUIPage
@EventHandler @EventHandler
public void onMembershipUpdate(CommunityMembershipUpdateEvent event) public void onMembershipUpdate(CommunityMembershipUpdateEvent event)
{ {
if (event.getCommunity().getId().intValue() != _community.getId().intValue()) if (event.getCommunity().getId() != _community.getId())
{ {
return; return;
} }
@ -136,7 +136,7 @@ public class CommunitySettingsPage extends CommunitiesGUIPage
@EventHandler @EventHandler
public void onSettingsUpdate(CommunitySettingUpdateEvent event) public void onSettingsUpdate(CommunitySettingUpdateEvent event)
{ {
if (event.getCommunity().getId().intValue() != _community.getId().intValue()) if (event.getCommunity().getId() != _community.getId())
{ {
return; return;
} }
@ -146,7 +146,7 @@ public class CommunitySettingsPage extends CommunitiesGUIPage
@EventHandler @EventHandler
public void onCommunityDisband(CommunityDisbandEvent event) public void onCommunityDisband(CommunityDisbandEvent event)
{ {
if (_community.getId().intValue() == event.getCommunity().getId().intValue()) if (_community.getId() == event.getCommunity().getId())
{ {
Viewer.closeInventory(); Viewer.closeInventory();
} }

View File

@ -72,7 +72,7 @@ public class DisguisePlayer extends DisguiseHuman
private DisguisePlayer(Entity entity) private DisguisePlayer(Entity entity)
{ {
super(EntityType.PLAYER, 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(entity);
this._profile = UtilGameProfile.clone(gameProfile); _profile = UtilGameProfile.clone(gameProfile);
} }
/** /**
@ -101,16 +101,16 @@ public class DisguisePlayer extends DisguiseHuman
{ {
this(entity); this(entity);
this._requestedUsername = username; _requestedUsername = username;
this._requestedSkin = skin; _requestedSkin = skin;
} }
public DisguisePlayer(Entity entity, String username, SkinData skinData) public DisguisePlayer(Entity entity, String username, SkinData skinData)
{ {
this(entity); this(entity);
this._requestedUsername = username; _requestedUsername = username;
this._requestedSkinData = skinData; _requestedSkinData = skinData;
} }
/** /**
@ -121,7 +121,7 @@ public class DisguisePlayer extends DisguiseHuman
*/ */
public Future<Object> initialize(Runnable onComplete) public Future<Object> initialize(Runnable onComplete)
{ {
if (this._profile != null && this._profile.isComplete()) if (_profile != null && _profile.isComplete())
{ {
onComplete.run(); onComplete.run();
return CompletableFuture.completedFuture(null); return CompletableFuture.completedFuture(null);
@ -139,8 +139,8 @@ public class DisguisePlayer extends DisguiseHuman
_requestedSkinData = SkinData.constructFromGameProfile(profileOfSkin, true, true); _requestedSkinData = SkinData.constructFromGameProfile(profileOfSkin, true, true);
} }
this._profile = new GameProfile(profileOfUsername.getId(), profileOfUsername.getName()); _profile = new GameProfile(profileOfUsername.getId(), profileOfUsername.getName());
this._profile.getProperties().put("textures", _requestedSkinData.getProperty()); _profile.getProperties().put("textures", _requestedSkinData.getProperty());
} }
catch (Exception e) catch (Exception e)
{ {
@ -171,8 +171,8 @@ public class DisguisePlayer extends DisguiseHuman
public void showInTabList(boolean show, int delay) public void showInTabList(boolean show, int delay)
{ {
this._showInTabList = show; _showInTabList = show;
this._showInTabListDelay = delay; _showInTabListDelay = delay;
} }
public BlockFace getSleepingDirection() public BlockFace getSleepingDirection()
@ -446,12 +446,12 @@ public class DisguisePlayer extends DisguiseHuman
public boolean showInTabList() public boolean showInTabList()
{ {
return this._showInTabList; return _showInTabList;
} }
public int getShowInTabListDelay() public int getShowInTabListDelay()
{ {
return this._showInTabListDelay; return _showInTabListDelay;
} }
private WorldSettings.EnumGamemode getAppropriateGamemode() private WorldSettings.EnumGamemode getAppropriateGamemode()
@ -465,25 +465,25 @@ public class DisguisePlayer extends DisguiseHuman
private GameProfile getSelfProfile() private GameProfile getSelfProfile()
{ {
GameProfile selfProfile = new GameProfile(getOriginalUUID(), this._profile.getName()); GameProfile selfProfile = new GameProfile(getOriginalUUID(), _profile.getName());
selfProfile.getProperties().putAll(this._profile.getProperties()); selfProfile.getProperties().putAll(_profile.getProperties());
return selfProfile; return selfProfile;
} }
public boolean replaceOriginalName() public boolean replaceOriginalName()
{ {
return this._replaceOriginalName; return _replaceOriginalName;
} }
public int replaceOriginalNameDelay() public int replaceOriginalNameDelay()
{ {
return this._replaceOriginalNameDelay; return _replaceOriginalNameDelay;
} }
public void setReplaceOriginalName(boolean b, int delay) public void setReplaceOriginalName(boolean b, int delay)
{ {
this._replaceOriginalName = b; _replaceOriginalName = b;
this._replaceOriginalNameDelay = delay; _replaceOriginalNameDelay = delay;
} }
public Hologram getHologram() public Hologram getHologram()
@ -504,16 +504,14 @@ public class DisguisePlayer extends DisguiseHuman
private UUID getOriginalUUID() private UUID getOriginalUUID()
{ {
if (this._originalProfile.getProperties().containsKey(PlayerDisguiseManager.ORIGINAL_UUID_KEY)) if (_originalProfile.getProperties().containsKey(PlayerDisguiseManager.ORIGINAL_UUID_KEY))
{ {
try try
{ {
return UUID.fromString(this._originalProfile.getProperties().get(PlayerDisguiseManager.ORIGINAL_UUID_KEY).iterator().next().getValue()); return UUID.fromString(_originalProfile.getProperties().get(PlayerDisguiseManager.ORIGINAL_UUID_KEY).iterator().next().getValue());
}
catch (IllegalArgumentException ignored)
{
} }
catch (IllegalArgumentException ignored) {}
} }
return this._originalProfile.getId(); return _originalProfile.getId();
} }
} }

View File

@ -1,19 +1,22 @@
package mineplex.core.donation.gold; 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.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.SQLException; 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 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 int DUPLICATE_PRIMARY_KEY_ERROR_CODE = 1062;
private static final String UPDATE_ACCOUNT_GOLD = "INSERT INTO clansGold (serverId, id, gold) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE gold=gold+?"; 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 SET_ACCOUNT_GOLD = "INSERT INTO clansGold (serverId, id, gold) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE gold=?"; 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() {} public GoldRepository() {}
@ -23,16 +26,48 @@ public class GoldRepository
{ {
try (Connection connection = DBPool.getAccount().getConnection()) try (Connection connection = DBPool.getAccount().getConnection())
{ {
PreparedStatement statement = connection.prepareStatement(UPDATE_ACCOUNT_GOLD); try (PreparedStatement statement = connection.prepareStatement(INSERT_ACCOUNT_GOLD))
statement.setInt(1, serverId);
statement.setInt(2, accountId);
statement.setInt(3, gold);
statement.setInt(4, gold);
statement.executeUpdate();
if (callback != null)
{ {
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) catch (SQLException e)
@ -51,7 +86,7 @@ public class GoldRepository
{ {
if (gold < 0) if (gold < 0)
{ {
throw new IllegalArgumentException("gold cannot be negative"); throw new IllegalArgumentException("Gold cannot be negative");
} }
Bukkit.getScheduler().runTaskAsynchronously(UtilServer.getPlugin(), () -> Bukkit.getScheduler().runTaskAsynchronously(UtilServer.getPlugin(), () ->
@ -62,7 +97,6 @@ public class GoldRepository
statement.setInt(1, serverId); statement.setInt(1, serverId);
statement.setInt(2, accountId); statement.setInt(2, accountId);
statement.setInt(3, gold); statement.setInt(3, gold);
statement.setInt(4, gold);
statement.executeUpdate(); statement.executeUpdate();
if (callback != null) if (callback != null)

View File

@ -99,4 +99,10 @@ public class ItemFleshHook extends ItemGadget implements IThrown
{ {
data.getThrown().remove(); data.getThrown().remove();
} }
}
@Override
public void ChunkUnload(ProjectileUser data)
{
data.getThrown().remove();
}
}

View File

@ -182,6 +182,12 @@ public class ItemFreezeCannon extends ItemGadget implements IThrown
smash(data.getThrown()); smash(data.getThrown());
} }
@Override
public void ChunkUnload(ProjectileUser data)
{
data.getThrown().remove();
}
public void smash(Entity ent) public void smash(Entity ent)
{ {
//Effect //Effect
@ -190,5 +196,4 @@ public class ItemFreezeCannon extends ItemGadget implements IThrown
//Remove //Remove
ent.remove(); ent.remove();
} }
}
}

View File

@ -101,6 +101,12 @@ public class ItemMelonLauncher extends ItemGadget implements IThrown
smash(data.getThrown()); smash(data.getThrown());
} }
@Override
public void ChunkUnload(ProjectileUser data)
{
data.getThrown().remove();
}
public void smash(Entity ent) public void smash(Entity ent)
{ {
//Effect //Effect
@ -160,4 +166,4 @@ public class ItemMelonLauncher extends ItemGadget implements IThrown
item.remove(); item.remove();
} }
} }
} }

View File

@ -108,6 +108,12 @@ public class ItemPartyPopper extends ItemGadget implements IThrown
Explode(data); Explode(data);
} }
@Override
public void ChunkUnload(ProjectileUser data)
{
data.getThrown().remove();
}
@EventHandler @EventHandler
public void particleTrail(UpdateEvent event) public void particleTrail(UpdateEvent event)
{ {
@ -140,4 +146,4 @@ public class ItemPartyPopper extends ItemGadget implements IThrown
data.getThrown().remove(); data.getThrown().remove();
*/ */
} }
} }

View File

@ -152,6 +152,12 @@ public class MorphBat extends MorphGadget implements IThrown
{ {
data.getThrown().remove(); data.getThrown().remove();
} }
@Override
public void ChunkUnload(ProjectileUser data)
{
data.getThrown().remove();
}
@EventHandler @EventHandler
public void Flap(PlayerToggleFlightEvent event) public void Flap(PlayerToggleFlightEvent event)
@ -201,4 +207,4 @@ public class MorphBat extends MorphGadget implements IThrown
} }
} }
} }
} }

View File

@ -25,7 +25,6 @@ import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilText; import mineplex.core.common.util.UtilText;
import mineplex.core.disguise.disguises.DisguiseSkeleton; import mineplex.core.disguise.disguises.DisguiseSkeleton;
import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.GadgetManager;
@ -35,11 +34,10 @@ import mineplex.core.recharge.Recharge;
import mineplex.core.recharge.RechargeData; import mineplex.core.recharge.RechargeData;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.visibility.VisibilityManager;
public class MorphChristmasKing extends MorphGadget public class MorphChristmasKing extends MorphGadget
{ {
private Map<Projectile, Player> _snowball = new WeakHashMap<Projectile, Player>(); private Map<Projectile, Player> _snowball = new WeakHashMap<>();
public MorphChristmasKing(GadgetManager manager) public MorphChristmasKing(GadgetManager manager)
{ {
@ -69,9 +67,6 @@ public class MorphChristmasKing extends MorphGadget
UtilMorph.disguise(player, disguise, Manager); UtilMorph.disguise(player, disguise, Manager);
player.getInventory().setHelmet(new ItemStack(Material.JACK_O_LANTERN)); player.getInventory().setHelmet(new ItemStack(Material.JACK_O_LANTERN));
VisibilityManager.Instance.setVisibility(player, false, UtilServer.getPlayers());
VisibilityManager.Instance.setVisibility(player, true, UtilServer.getPlayers());
} }
@Override @Override

View File

@ -1,11 +1,10 @@
package mineplex.core.gadget.gadgets.morph; package mineplex.core.gadget.gadgets.morph;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Random; import java.util.Random;
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Item; import org.bukkit.entity.Item;
@ -15,8 +14,6 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerToggleSneakEvent; import org.bukkit.event.player.PlayerToggleSneakEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import com.google.common.collect.Lists;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.LineFormat; 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.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilText; import mineplex.core.common.util.UtilText;
import mineplex.core.disguise.disguises.DisguiseBlock; import mineplex.core.disguise.disguises.DisguiseBlock;
import mineplex.core.disguise.disguises.DisguiseSkeleton; import mineplex.core.disguise.disguises.DisguiseSkeleton;
@ -39,13 +35,13 @@ import mineplex.core.packethandler.PacketInfo;
import mineplex.core.recharge.Recharge; import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; 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 public class MorphPumpkinKing extends MorphGadget implements IPacketHandler
{ {
private static final int CROWN_POINTS = 12; private static final int CROWN_POINTS = 12;
private List<JackOBomb> _bombs = Lists.newArrayList(); private List<JackOBomb> _bombs = new ArrayList<>();
public MorphPumpkinKing(GadgetManager manager) public MorphPumpkinKing(GadgetManager manager)
{ {
@ -75,9 +71,6 @@ public class MorphPumpkinKing extends MorphGadget implements IPacketHandler
UtilMorph.disguise(player, disguise, Manager); UtilMorph.disguise(player, disguise, Manager);
player.getInventory().setHelmet(new ItemStack(Material.JACK_O_LANTERN)); player.getInventory().setHelmet(new ItemStack(Material.JACK_O_LANTERN));
VisibilityManager.Instance.setVisibility(player, false, UtilServer.getPlayers());
VisibilityManager.Instance.setVisibility(player, true, UtilServer.getPlayers());
} }
@Override @Override

View File

@ -155,5 +155,10 @@ public class MorphSquid extends MorphGadget implements IThrown
{ {
data.getThrown().remove(); data.getThrown().remove();
} }
} @Override
public void ChunkUnload(ProjectileUser data)
{
data.getThrown().remove();
}
}

View File

@ -141,6 +141,12 @@ public class MorphVillager extends MorphGadget implements IThrown
{ {
} }
@Override
public void ChunkUnload(ProjectileUser data)
{
data.getThrown().remove();
}
@EventHandler @EventHandler
public void Pickup(PlayerPickupItemEvent event) public void Pickup(PlayerPickupItemEvent event)
@ -175,4 +181,4 @@ public class MorphVillager extends MorphGadget implements IThrown
} }
} }
} }
} }

View File

@ -81,7 +81,6 @@ public class ParticleCandyCane extends ParticleGadget
{ {
Double y = _map.get(p.getUniqueId()); Double y = _map.get(p.getUniqueId());
if (y == null) return 3; if (y == null) return 3;
return y.doubleValue(); return y;
} }
}
}

View File

@ -3,6 +3,7 @@ package mineplex.core.gadget.gadgets.wineffect;
import java.util.*; import java.util.*;
import java.util.Map.Entry; import java.util.Map.Entry;
import mineplex.core.Managers;
import mineplex.core.common.util.*; import mineplex.core.common.util.*;
import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist; 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.hologram.Hologram;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; 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.EntityCreature;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntity.PacketPlayOutRelEntityMove; import net.minecraft.server.v1_8_R3.PacketPlayOutEntity.PacketPlayOutRelEntityMove;
import net.minecraft.server.v1_8_R3.PathfinderGoal; import net.minecraft.server.v1_8_R3.PathfinderGoal;
import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
@ -52,7 +56,7 @@ public class WinEffectBabyChicken extends WinEffectGadget
_tick = 0; _tick = 0;
List<Location> circle = UtilShapes.getPointsInCircle(getBaseLocation(), _team.size(), 3); List<Location> 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); Player p = _team.get(i);
Location l = circle.get(i); Location l = circle.get(i);
@ -72,8 +76,9 @@ public class WinEffectBabyChicken extends WinEffectGadget
chicken.setCustomNameVisible(true); chicken.setCustomNameVisible(true);
UtilEnt.removeGoalSelectors(chicken); 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; return chicken;
} }
@ -87,11 +92,11 @@ public class WinEffectBabyChicken extends WinEffectGadget
_tick++; _tick++;
if(_tick < 20*2) if (_tick < 20*2)
{ {
return; return;
} }
else if(_tick == 20*2) else if (_tick == 20*2)
{ {
Location loc = _npc.getEntity().getBukkitEntity().getLocation(); 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, 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); 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); 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); 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())); e.getKey().setLocation(e.getKey().getLocation().add(e.getValue()));
} }
for(Chicken c : _teamChickens) for (Chicken c : _teamChickens)
{ {
UtilEnt.CreatureLook(c, _chicken); UtilEnt.CreatureLook(c, _chicken);
} }
} }
@Override @Override
public void finish() 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.keySet().forEach(h -> h.stop());
_text.clear(); _text.clear();
_chicken.remove(); _chicken.remove();
UtilParticle.PlayParticleToAll(ParticleType.EXPLODE, _chicken.getLocation().add(0, 0.15, 0), 0.3f, 0.3f, 0.3f, 0.1f, 50, ViewDist.NORMAL); UtilParticle.PlayParticleToAll(ParticleType.EXPLODE, _chicken.getLocation().add(0, 0.15, 0), 0.3f, 0.3f, 0.3f, 0.1f, 50, ViewDist.NORMAL);
_chicken = null; _chicken = null;
_teamChickens.forEach(c -> c.remove()); _teamChickens.forEach(c -> c.remove());
_team.forEach(p -> UtilPlayer.showForAll(p));
} }
@Override @Override
@ -205,5 +216,4 @@ public class WinEffectBabyChicken extends WinEffectGadget
_ent.getNavigation().a(loc.getX(), loc.getY(), loc.getZ(), _speed); _ent.getNavigation().a(loc.getX(), loc.getY(), loc.getZ(), _speed);
} }
} }
}
}

View File

@ -4,6 +4,7 @@ import java.awt.Color;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
@ -12,6 +13,7 @@ import org.bukkit.entity.Skeleton;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import mineplex.core.Managers;
import mineplex.core.common.skin.SkinData; import mineplex.core.common.skin.SkinData;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.LineFormat;
@ -31,6 +33,7 @@ import mineplex.core.particleeffects.BabyFireworkEffect;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.utils.UtilVariant; import mineplex.core.utils.UtilVariant;
import mineplex.core.visibility.VisibilityManager;
public class WinEffectHalloween extends WinEffectGadget public class WinEffectHalloween extends WinEffectGadget
{ {
@ -72,9 +75,13 @@ public class WinEffectHalloween extends WinEffectGadget
@Override @Override
public void finish() public void finish()
{ {
UtilPlayer.showForAll(_player); VisibilityManager vm = Managers.require(VisibilityManager.class);
_team.forEach(p -> UtilPlayer.showForAll(p)); Bukkit.getOnlinePlayers().forEach(pl ->
_nonTeam.forEach(p -> UtilPlayer.showForAll(p)); {
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.forEach(d -> d.getEntity().getBukkitEntity().remove());
_disguisePlayers.clear(); _disguisePlayers.clear();
} }
@ -123,7 +130,8 @@ public class WinEffectHalloween extends WinEffectGadget
_npc.getEntity().getBukkitEntity().remove(); _npc.getEntity().getBukkitEntity().remove();
spawnSkeleton(); spawnSkeleton();
spawnGhosts(); 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); _player.getWorld().playSound(getBaseLocation(), Sound.CAT_MEOW, .5f, .5f);
} }
@ -145,6 +153,7 @@ public class WinEffectHalloween extends WinEffectGadget
{ {
int i = 0; int i = 0;
List<Location> circle = UtilShapes.getPointsInCircle(getBaseLocation(), _nonTeam.size(), 7); List<Location> circle = UtilShapes.getPointsInCircle(getBaseLocation(), _nonTeam.size(), 7);
VisibilityManager vm = Managers.require(VisibilityManager.class);
for (Player player : _nonTeam) for (Player player : _nonTeam)
{ {
ItemStack playerHead = UtilSkull.getPlayerHead(player.getName(), player.getName() + " skull", null); 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 disguisePlayer = getNPC(player, ghostLoc, SkinData.GHOST);
disguisePlayer.setHelmet(playerHead); disguisePlayer.setHelmet(playerHead);
UtilEnt.CreatureLook(disguisePlayer.getEntity().getBukkitEntity(), getBaseLocation()); 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++) for (int j = 0; j < 5; j++)
{ {
playFirework(ghostLoc.clone().add(0, 1, 0), j, false); playFirework(ghostLoc.clone().add(0, 1, 0), j, false);
@ -183,5 +192,4 @@ public class WinEffectHalloween extends WinEffectGadget
babyFireworkEffect.setCount(6); babyFireworkEffect.setCount(6);
babyFireworkEffect.start(); babyFireworkEffect.start();
} }
}
}

View File

@ -6,6 +6,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Color; import org.bukkit.Color;
import org.bukkit.FireworkEffect; import org.bukkit.FireworkEffect;
import org.bukkit.GameMode; import org.bukkit.GameMode;
@ -25,18 +26,19 @@ import org.bukkit.util.Vector;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionGroup;
import mineplex.core.Managers;
import mineplex.core.common.block.schematic.Schematic; import mineplex.core.common.block.schematic.Schematic;
import mineplex.core.common.block.schematic.UtilSchematic; import mineplex.core.common.block.schematic.UtilSchematic;
import mineplex.core.common.skin.SkinData; import mineplex.core.common.skin.SkinData;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.disguise.disguises.DisguisePlayer;
import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.GadgetManager;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.visibility.VisibilityManager;
/** /**
* A wrapper for different win effects * A wrapper for different win effects
@ -111,7 +113,12 @@ public abstract class WinEffectGadget extends Gadget
} }
finally 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; _player = null;
_baseLocation = null; _baseLocation = null;
_team.clear(); _team.clear();
@ -229,11 +236,15 @@ public abstract class WinEffectGadget extends Gadget
{ {
createBarriers(loc); createBarriers(loc);
BukkitRunnable bRunnable = new BukkitRunnable() { BukkitRunnable bRunnable = new BukkitRunnable()
{
@Override @Override
public void run() { public void run()
for(Player p : UtilServer.getPlayers()) { {
UtilPlayer.hideFromAll(p); 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.eject();
p.teleport(loc); p.teleport(loc);
p.setGameMode(GameMode.ADVENTURE); p.setGameMode(GameMode.ADVENTURE);

View File

@ -5,17 +5,9 @@ import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.UUID; 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.Location;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; 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.UtilEnt;
import mineplex.core.common.util.UtilPlayer; 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. * 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. * 1.7 packets uses both EntityIDs while 1.8 uses only the first.
*/ */
private ArrayList<Integer> _entityIds = new ArrayList<>(); private List<Integer> _entityIds = new ArrayList<>();
private Entity _followEntity; private Entity _followEntity;
private HologramManager _hologramManager; private HologramManager _hologramManager;
private String[] _hologramText = new String[0]; private String[] _hologramText = new String[0];
@ -49,8 +49,8 @@ public class Hologram {
private boolean _makeSpawnPackets = true; private boolean _makeSpawnPackets = true;
private Packet[] _packets1_8; private Packet[] _packets1_8;
private Packet[] _packets1_9; private Packet[] _packets1_9;
private HashSet<UUID> _playersInList = new HashSet<>(); private Set<UUID> _playersInList = new HashSet<>();
private ArrayList<Player> _playersTracking = new ArrayList<>(); private List<Player> _playersTracking = new ArrayList<>();
private boolean _removeEntityDeath; private boolean _removeEntityDeath;
private HologramTarget _target = HologramTarget.BLACKLIST; private HologramTarget _target = HologramTarget.BLACKLIST;
private int _viewDistance = 70; private int _viewDistance = 70;
@ -223,7 +223,7 @@ public class Hologram {
/** /**
* @return The list of players that are in the holograms whitelist or blacklist. * @return The list of players that are in the holograms whitelist or blacklist.
*/ */
protected ArrayList<Player> getPlayersTracking() protected List<Player> getPlayersTracking()
{ {
return _playersTracking; return _playersTracking;
} }
@ -334,7 +334,7 @@ public class Hologram {
for (int i = _entityIds.size(); i < _hologramText.length; i++) for (int i = _entityIds.size(); i < _hologramText.length; i++)
{ {
_entityIds.add(Integer.valueOf(UtilEnt.getNewEntityId())); _entityIds.add(UtilEnt.getNewEntityId());
} }
} }
else else

View File

@ -12,6 +12,7 @@ import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.Managers;
import mineplex.core.MiniDbClientPlugin; import mineplex.core.MiniDbClientPlugin;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
import mineplex.core.account.permissions.Permission; import mineplex.core.account.permissions.Permission;
@ -28,6 +29,7 @@ import mineplex.core.packethandler.PacketHandler;
import mineplex.core.preferences.PreferencesManager; import mineplex.core.preferences.PreferencesManager;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.visibility.VisibilityManager;
public class IncognitoManager extends MiniDbClientPlugin<IncognitoClient> public class IncognitoManager extends MiniDbClientPlugin<IncognitoClient>
{ {
@ -73,6 +75,8 @@ public class IncognitoManager extends MiniDbClientPlugin<IncognitoClient>
public boolean toggle(Player caller) public boolean toggle(Player caller)
{ {
boolean enabled = !Get(caller).Status; boolean enabled = !Get(caller).Status;
VisibilityManager vm = Managers.require(VisibilityManager.class);
IncognitoStatusChangeEvent event = UtilServer.CallEvent(new IncognitoStatusChangeEvent(caller, enabled)); IncognitoStatusChangeEvent event = UtilServer.CallEvent(new IncognitoStatusChangeEvent(caller, enabled));
@ -89,7 +93,7 @@ public class IncognitoManager extends MiniDbClientPlugin<IncognitoClient>
{ {
for (Player other : UtilServer.getPlayers()) for (Player other : UtilServer.getPlayers())
{ {
other.showPlayer(caller); vm.showPlayer(other, caller, "Incognito Mode");
} }
} }
} }
@ -104,6 +108,8 @@ public class IncognitoManager extends MiniDbClientPlugin<IncognitoClient>
{ {
Player player = event.getPlayer(); Player player = event.getPlayer();
VisibilityManager vm = Managers.require(VisibilityManager.class);
if (Get(event.getPlayer()).Status && !_clientManager.Get(event.getPlayer()).hasPermission(Perm.USE_INCOGNITO)) if (Get(event.getPlayer()).Status && !_clientManager.Get(event.getPlayer()).hasPermission(Perm.USE_INCOGNITO))
{ {
Get(event.getPlayer()).Status = false; Get(event.getPlayer()).Status = false;
@ -128,7 +134,7 @@ public class IncognitoManager extends MiniDbClientPlugin<IncognitoClient>
{ {
if (customEvent != null && !customEvent.isCancelled() && !canSeeThroughIncognito(other, player)) if (customEvent != null && !customEvent.isCancelled() && !canSeeThroughIncognito(other, player))
{ {
other.hidePlayer(player); vm.hidePlayer(other, player, "Incognito Mode");
} }
if (Get(other).Status) if (Get(other).Status)
@ -137,7 +143,7 @@ public class IncognitoManager extends MiniDbClientPlugin<IncognitoClient>
if (!customEvent2.isCancelled() && !canSeeThroughIncognito(player, other)) if (!customEvent2.isCancelled() && !canSeeThroughIncognito(player, other))
{ {
player.hidePlayer(other); vm.hidePlayer(player, other, "Incognito Mode");
} }
} }
} }
@ -151,6 +157,8 @@ public class IncognitoManager extends MiniDbClientPlugin<IncognitoClient>
return; return;
} }
VisibilityManager vm = Managers.require(VisibilityManager.class);
for (Player player : UtilServer.getPlayers()) for (Player player : UtilServer.getPlayers())
{ {
for (Player other : UtilServer.getPlayers()) for (Player other : UtilServer.getPlayers())
@ -161,7 +169,7 @@ public class IncognitoManager extends MiniDbClientPlugin<IncognitoClient>
if (!customEvent.isCancelled() && !canSeeThroughIncognito(other, player)) if (!customEvent.isCancelled() && !canSeeThroughIncognito(other, player))
{ {
other.hidePlayer(player); vm.hidePlayer(other, player, "Incognito Mode");
} }
Get(player).Hidden = !customEvent.isCancelled(); Get(player).Hidden = !customEvent.isCancelled();
@ -177,7 +185,7 @@ public class IncognitoManager extends MiniDbClientPlugin<IncognitoClient>
if (!customEvent.isCancelled() && !canSeeThroughIncognito(player, other)) if (!customEvent.isCancelled() && !canSeeThroughIncognito(player, other))
{ {
player.hidePlayer(other); vm.hidePlayer(player, other, "Incognito Mode");
} }
Get(other).Hidden = !customEvent.isCancelled(); Get(other).Hidden = !customEvent.isCancelled();

View File

@ -71,7 +71,7 @@ public class GiveItemCommand extends CommandBase<InventoryManager>
{ {
Plugin.addItemToInventoryForOffline(success -> 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))); UtilPlayer.message(caller, F.main("Item", "You gave " + F.elem(amount + " " + itemName) + " to offline player " + F.name(playerName)));
} }

View File

@ -133,7 +133,7 @@ public class LeaderboardManager extends MiniPlugin
final int index = i; final int index = i;
Managers.get(StatsManager.class).loadStatId(board.getStatNames()[index], id -> Managers.get(StatsManager.class).loadStatId(board.getStatNames()[index], id ->
{ {
board.setStatId(index, id.intValue()); board.setStatId(index, id);
}); });
} }
} }

View File

@ -59,4 +59,10 @@ public class RandomItem
return _item.getType() == item.getItemStack().getType(); return _item.getType() == item.getItemStack().getType();
} }
@Override
public int hashCode()
{
return _item.getType().hashCode();
}
} }

View File

@ -70,4 +70,10 @@ public class Poll
} }
return false; return false;
} }
@Override
public int hashCode()
{
return Integer.hashCode(getId());
}
} }

View File

@ -38,7 +38,7 @@ public class SendCommand extends CommandBase<Portal>
Plugin.doesServerExist(serverTarget, serverExists -> 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!")); UtilPlayer.message(player, F.main(Plugin.getName(), C.cGray + "Server " + C.cGold + serverTarget + C.cGray + " does not exist!"));
return; return;

View File

@ -39,7 +39,7 @@ public class ServerCommand extends CommandBase<Portal>
{ {
Plugin.doesServerExist(args[0], serverExists -> Plugin.doesServerExist(args[0], serverExists ->
{ {
if (!serverExists.booleanValue()) if (!serverExists)
{ {
UtilPlayer.message( UtilPlayer.message(
player, player,
@ -60,11 +60,8 @@ public class ServerCommand extends CommandBase<Portal>
} }
else if (servUp.startsWith("CLANS-")) 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) if (deniedAccess)

View File

@ -9,4 +9,5 @@ public interface IThrown
public void Collide(LivingEntity target, Block block, ProjectileUser data); public void Collide(LivingEntity target, Block block, ProjectileUser data);
public void Idle(ProjectileUser data); public void Idle(ProjectileUser data);
public void Expire(ProjectileUser data); public void Expire(ProjectileUser data);
public void ChunkUnload(ProjectileUser data);
} }

View File

@ -5,11 +5,6 @@ import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.WeakHashMap; 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.Effect;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
@ -19,8 +14,14 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.inventory.InventoryPickupItemEvent; import org.bukkit.event.inventory.InventoryPickupItemEvent;
import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.event.world.ChunkUnloadEvent;
import org.bukkit.plugin.java.JavaPlugin; 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 public class ProjectileManager extends MiniPlugin
{ {
private WeakHashMap<Entity, ProjectileUser> _thrown = new WeakHashMap<Entity, ProjectileUser>(); private WeakHashMap<Entity, ProjectileUser> _thrown = new WeakHashMap<Entity, ProjectileUser>();
@ -212,4 +213,16 @@ public class ProjectileManager extends MiniPlugin
if (_thrown.containsKey(event.getItem())) if (_thrown.containsKey(event.getItem()))
event.setCancelled(true); 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();
}
}
}
}

View File

@ -2,6 +2,18 @@ package mineplex.core.projectile;
import java.util.List; 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.UtilBlock;
import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType; 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.MovingObjectPosition;
import net.minecraft.server.v1_8_R3.Vec3D; 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 class ProjectileUser
{ {
public ProjectileManager Throw; public ProjectileManager Throw;
@ -186,6 +185,10 @@ public class ProjectileUser
_canHit = canHit; _canHit = canHit;
} }
public void chunkUnload()
{
_callback.ChunkUnload(this);
}
public void effect(UpdateEvent event) public void effect(UpdateEvent event)
{ {

View File

@ -18,9 +18,11 @@ public class ClansBan
private Timestamp _unbanTime; private Timestamp _unbanTime;
private boolean _permanent; private boolean _permanent;
private boolean _removed; private boolean _removed;
private String _removeAdmin;
private String _removeReason;
private UUID _uuid; 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; _id = id;
_uuid = uuid; _uuid = uuid;
@ -30,6 +32,8 @@ public class ClansBan
_unbanTime = unbanTime; _unbanTime = unbanTime;
_permanent = permanent; _permanent = permanent;
_removed = removed; _removed = removed;
_removeAdmin = removeAdmin;
_removeReason = removeReason;
} }
public int getId() public int getId()
@ -93,9 +97,21 @@ public class ClansBan
{ {
return _uuid; return _uuid;
} }
public String getRemoveAdmin()
{
return _removeAdmin;
}
public String getRemoveReason()
{
return _removeReason;
}
public void remove() public void remove(String admin, String reason)
{ {
_removed = true; _removed = true;
_removeAdmin = admin;
_removeReason = reason;
} }
} }

View File

@ -18,6 +18,7 @@ public class ClansBanClient
{ {
_uuid = uuid; _uuid = uuid;
_bans = bans; _bans = bans;
sortBans();
} }
public boolean isBanned() public boolean isBanned()
@ -87,4 +88,28 @@ public class ClansBanClient
return longest; 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());
});
}
} }

View File

@ -65,14 +65,15 @@ public class ClansBanManager extends MiniPlugin
private void generatePermissions() private void generatePermissions()
{ {
PermissionGroup.ADMIN.setPermission(Perm.ALERT_PUNISHMENT, true, true); PermissionGroup.ADMIN.setPermission(Perm.ALERT_PUNISHMENT, true, true);
PermissionGroup.CMOD.setPermission(Perm.ALERT_PUNISHMENT, false, true); PermissionGroup.CMOD.setPermission(Perm.ALERT_PUNISHMENT, false, true);
PermissionGroup.CMA.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.ADMIN.setPermission(Perm.PUNISHMENT_COMMAND, true, true);
PermissionGroup.CMOD.setPermission(Perm.PUNISHMENT_COMMAND, false, true); PermissionGroup.CMOD.setPermission(Perm.PUNISHMENT_COMMAND, false, true);
PermissionGroup.CMA.setPermission(Perm.PUNISHMENT_COMMAND, false, true); PermissionGroup.CMA.setPermission(Perm.PUNISHMENT_COMMAND, false, true);
PermissionGroup.QA.setPermission(Perm.PUNISHMENT_COMMAND, true, true);
} }
@Override @Override
@ -108,6 +109,7 @@ public class ClansBanManager extends MiniPlugin
if (ban.isPresent()) if (ban.isPresent())
{ {
target._bans.add(ban.get()); target._bans.add(ban.get());
target.sortBans();
String banTimeFormatted = target.getBanTimeFormatted(); String banTimeFormatted = target.getBanTimeFormatted();
if (targetName != null) 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))); 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())) if (!target._uuid.equals(ban.getUUID()))
{ {
return; return;
} }
ban.remove(); _repository.removeBan(ban, admin, reason, () ->
_repository.removeBan(ban); {
ban.remove(admin, reason);
callback.run(); target.sortBans();
if (callback != null)
{
callback.run();
}
});
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)

View File

@ -15,14 +15,16 @@ import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.Managers; import mineplex.core.Managers;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.UtilServer;
import mineplex.serverdata.database.DBPool; import mineplex.serverdata.database.DBPool;
import mineplex.serverdata.database.RepositoryBase; import mineplex.serverdata.database.RepositoryBase;
import mineplex.serverdata.database.column.ColumnInt; import mineplex.serverdata.database.column.ColumnInt;
import mineplex.serverdata.database.column.ColumnVarChar;
public class ClansBanRepository extends RepositoryBase 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 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 WHERE id = ?;"; 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 = ?;"; private static final String GET_ALL_BANS = "SELECT * FROM clanBans WHERE uuid = ?;";
public ClansBanRepository(JavaPlugin plugin) public ClansBanRepository(JavaPlugin plugin)
@ -47,13 +49,15 @@ public class ClansBanRepository extends RepositoryBase
stmt.setTimestamp(5, unbanTime); stmt.setTimestamp(5, unbanTime);
stmt.setBoolean(6, time == -1); stmt.setBoolean(6, time == -1);
stmt.setBoolean(7, false); stmt.setBoolean(7, false);
stmt.setString(8, null);
stmt.setString(9, null);
stmt.executeUpdate(); stmt.executeUpdate();
ResultSet resultSet = stmt.getGeneratedKeys(); ResultSet resultSet = stmt.getGeneratedKeys();
if (resultSet.next()) if (resultSet.next())
{ {
int id = resultSet.getInt(1); 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 else
{ {
@ -90,8 +94,10 @@ public class ClansBanRepository extends RepositoryBase
Timestamp unbanTime = resultSet.getTimestamp(6); Timestamp unbanTime = resultSet.getTimestamp(6);
boolean permanent = resultSet.getBoolean(7); boolean permanent = resultSet.getBoolean(7);
boolean removed = resultSet.getBoolean(8); 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); 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);
}
});
} }
} }

View File

@ -26,14 +26,15 @@ public class ClansBanCommand extends CommandBase<ClansBanManager>
{ {
final String playerName = args[0]; final String playerName = args[0];
String reason = args[1]; StringBuilder reasonBuilder = new StringBuilder(args[1]);
for (int i = 2; i < args.length; i++) 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 -> Plugin.loadClient(playerName, client ->
{ {

View File

@ -96,9 +96,11 @@ public class ClansBanPage extends ShopPageBase<ClansBanManager, ClansBanShop>
.addLore(C.cGray + "Admin: " + C.cYellow + ban.getAdmin()) .addLore(C.cGray + "Admin: " + C.cYellow + ban.getAdmin())
.addLore(C.cGray + "Permanent: " + C.cYellow + (ban.isPermanent() ? "Yes" : "No")) .addLore(C.cGray + "Permanent: " + C.cYellow + (ban.isPermanent() ? "Yes" : "No"))
.addLore(C.cGray + "Reason: " + C.cYellow + ban.getReason(), 16) .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() ? " " : 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()) .setGlow(ban.isActive())
.build(); .build();
} }
@ -112,9 +114,11 @@ public class ClansBanPage extends ShopPageBase<ClansBanManager, ClansBanShop>
.addLore(C.cGray + "Time Left: " + C.cYellow + (ban.isActive() ? ban.getBanTimeFormatted(false) : "None")) .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 + "Permanent: " + C.cYellow + (ban.isPermanent() ? "Yes" : "No"))
.addLore(C.cGray + "Reason: " + C.cYellow + ban.getReason(), 16) .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() ? " " : 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()) .setGlow(ban.isActive())
.build(); .build();
} }
@ -123,13 +127,10 @@ public class ClansBanPage extends ShopPageBase<ClansBanManager, ClansBanShop>
{ {
if (ban.isActive()) 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<ClansBanManager, ClansBanShop>
private void performBan() private void performBan()
{ {
if (_time == 0 && !_permanent)
{
playDenySound(getPlayer());
return;
}
getPlugin().ban(_victimClient, _victimName, getPlayer().getName(), _permanent ? -1 : _time, _reason, getPlayer(), ban -> getPlugin().ban(_victimClient, _victimName, getPlayer().getName(), _permanent ? -1 : _time, _reason, getPlayer(), ban ->
{ {
if (ban.isPresent()) if (ban.isPresent())

View File

@ -85,4 +85,10 @@ public class InventoryReward extends Reward
{ {
return obj instanceof InventoryReward && ((InventoryReward) obj).getPackageName().equals(_packageName); return obj instanceof InventoryReward && ((InventoryReward) obj).getPackageName().equals(_packageName);
} }
}
@Override
public int hashCode()
{
return _packageName.hashCode();
}
}

View File

@ -48,4 +48,10 @@ public class RuneAmplifierReward extends InventoryReward
{ {
return obj instanceof RuneAmplifierReward && ((RuneAmplifierReward) obj)._minutes == _minutes; return obj instanceof RuneAmplifierReward && ((RuneAmplifierReward) obj)._minutes == _minutes;
} }
@Override
public int hashCode()
{
return Integer.hashCode(_minutes);
}
} }

View File

@ -96,4 +96,10 @@ public class SpinTicketReward extends Reward
{ {
return obj instanceof SpinTicketReward; return obj instanceof SpinTicketReward;
} }
@Override
public int hashCode()
{
return getClass().hashCode();
}
} }

View File

@ -129,12 +129,6 @@ public class ShopItem extends ItemStack
return new ShopItem(super.clone(), _name, _deliveryName, _deliveryAmount, _locked, _displayItem); 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) protected void UpdateVisual(boolean clone)
{ {
ItemMeta meta = getItemMeta(); ItemMeta meta = getItemMeta();
@ -220,4 +214,4 @@ public class ShopItem extends ItemStack
return this; return this;
} }
} }

View File

@ -128,4 +128,4 @@ public class SlackAPI
return _instance; return _instance;
} }
} }

View File

@ -157,4 +157,4 @@ public class SlackMessage
{ {
_content = content; _content = content;
} }
} }

View File

@ -10,6 +10,10 @@ public enum SlackTeam
// QA team - mineplexqa.slack.com // QA team - mineplexqa.slack.com
QA("Mineplex QA", "todo", "todo", "todo"), // TODO: new details 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(); return "https://hooks.slack.com/services/" + getId1() + "/" + getId2() + "/" + getToken();
} }
} }

View File

@ -128,7 +128,7 @@ public class StatsManager extends MiniDbClientPlugin<PlayerStats>
{ {
final int statId = _stats.get(statName); final int statId = _stats.get(statName);
runSync(() -> idConsumer.accept(Integer.valueOf(statId))); runSync(() -> idConsumer.accept(statId));
}); });
} }

View File

@ -15,6 +15,7 @@ import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.Managers;
import mineplex.core.MiniPlugin; import mineplex.core.MiniPlugin;
import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.util.C; 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.texttutorial.tutorial.TutorialData;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.visibility.VisibilityManager;
public class TextTutorialManager extends MiniPlugin public class TextTutorialManager extends MiniPlugin
{ {
@ -59,6 +61,7 @@ public class TextTutorialManager extends MiniPlugin
if (!(event.getRightClicked() instanceof LivingEntity)) if (!(event.getRightClicked() instanceof LivingEntity))
return; return;
VisibilityManager vm = Managers.require(VisibilityManager.class);
LivingEntity ent = (LivingEntity)event.getRightClicked(); LivingEntity ent = (LivingEntity)event.getRightClicked();
String name = ent.getCustomName(); String name = ent.getCustomName();
@ -74,7 +77,7 @@ public class TextTutorialManager extends MiniPlugin
for (Player other : Bukkit.getOnlinePlayers()) for (Player other : Bukkit.getOnlinePlayers())
{ {
other.hidePlayer(event.getPlayer()); vm.hidePlayer(other, event.getPlayer(), "Core Text Tutorial");
} }
((CraftPlayer) event.getPlayer()).getHandle().spectating = true; ((CraftPlayer) event.getPlayer()).getHandle().spectating = true;
@ -89,7 +92,9 @@ public class TextTutorialManager extends MiniPlugin
{ {
if (event.getType() != UpdateType.TICK) if (event.getType() != UpdateType.TICK)
return; return;
VisibilityManager vm = Managers.require(VisibilityManager.class);
for (final Tutorial tut : _tutorials) for (final Tutorial tut : _tutorials)
{ {
Iterator<TutorialData> iterator = tut.getTutorialDatas().iterator(); Iterator<TutorialData> iterator = tut.getTutorialDatas().iterator();
@ -117,7 +122,7 @@ public class TextTutorialManager extends MiniPlugin
for (Player other : Bukkit.getOnlinePlayers()) for (Player other : Bukkit.getOnlinePlayers())
{ {
other.showPlayer(player); vm.showPlayer(other, player, "Core Text Tutorial");
} }
((CraftPlayer) player).getHandle().spectating = false; ((CraftPlayer) player).getHandle().spectating = false;
@ -155,12 +160,13 @@ public class TextTutorialManager extends MiniPlugin
public void hidePlayer(PlayerJoinEvent event) public void hidePlayer(PlayerJoinEvent event)
{ {
Player player = event.getPlayer(); Player player = event.getPlayer();
VisibilityManager vm = Managers.require(VisibilityManager.class);
for (Player other : Bukkit.getOnlinePlayers()) for (Player other : Bukkit.getOnlinePlayers())
{ {
if (isInTutorial(other)) 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) public void playerQuit(PlayerQuitEvent event)
{ {
for (Tutorial tut : _tutorials) for (Tutorial tut : _tutorials)
{
tut.stopTutorial(event.getPlayer()); tut.stopTutorial(event.getPlayer());
}
} }
@EventHandler @EventHandler
public void cancelInteract(PlayerInteractEvent event) public void cancelInteract(PlayerInteractEvent event)
{ {
if (isInTutorial(event.getPlayer())) if (isInTutorial(event.getPlayer()))
{
event.setCancelled(true); event.setCancelled(true);
}
} }
public boolean isInTutorial(Player player) public boolean isInTutorial(Player player)
@ -184,9 +194,11 @@ public class TextTutorialManager extends MiniPlugin
for (Tutorial tutorial : _tutorials) for (Tutorial tutorial : _tutorials)
{ {
if (tutorial.isInTutorial(player)) if (tutorial.isInTutorial(player))
{
return true; return true;
}
} }
return false; return false;
} }
} }

View File

@ -25,6 +25,7 @@ import mineplex.core.titles.tracks.award.AprilFools2017Track;
import mineplex.core.titles.tracks.award.Bridges2017Track; import mineplex.core.titles.tracks.award.Bridges2017Track;
import mineplex.core.titles.tracks.award.CastleSiegeTesterTrack; import mineplex.core.titles.tracks.award.CastleSiegeTesterTrack;
import mineplex.core.titles.tracks.award.ClansRaidTrack; 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.DongerTrack;
import mineplex.core.titles.tracks.custom.EarlyBirdTrack; import mineplex.core.titles.tracks.custom.EarlyBirdTrack;
import mineplex.core.titles.tracks.custom.HappyGaryTrack; import mineplex.core.titles.tracks.custom.HappyGaryTrack;
@ -119,6 +120,7 @@ public class TrackManager extends MiniPlugin
registerTrack(new AlienInvasionTrack()); registerTrack(new AlienInvasionTrack());
registerTrack(new ClansRaidTrack()); registerTrack(new ClansRaidTrack());
registerTrack(new CastleSiegeTesterTrack()); registerTrack(new CastleSiegeTesterTrack());
registerTrack(new Minestrike2017Track());
// Staff tracks // Staff tracks
registerTrack(new BuilderTrack()); registerTrack(new BuilderTrack());

View File

@ -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)
));
}
}

View File

@ -22,12 +22,14 @@ import mineplex.core.account.permissions.PermissionGroup;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilServer;
import mineplex.core.portal.GenericServer; import mineplex.core.portal.GenericServer;
import mineplex.core.portal.Intent; import mineplex.core.portal.Intent;
import mineplex.core.portal.Portal; import mineplex.core.portal.Portal;
import mineplex.core.updater.command.BuildVersionCommand; import mineplex.core.updater.command.BuildVersionCommand;
import mineplex.core.updater.command.RestartServerCommand; import mineplex.core.updater.command.RestartServerCommand;
import mineplex.core.updater.event.RestartServerEvent; import mineplex.core.updater.event.RestartServerEvent;
import mineplex.core.updater.event.RestartTriggerEvent;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.serverdata.Region; import mineplex.serverdata.Region;
import mineplex.serverdata.commands.RestartCommand; import mineplex.serverdata.commands.RestartCommand;
@ -50,6 +52,7 @@ public class FileUpdater extends MiniPlugin
private boolean _needUpdate; private boolean _needUpdate;
private boolean _enabled = true; private boolean _enabled = true;
private boolean _restartTriggered = false;
private Properties _buildProperties; private Properties _buildProperties;
@ -77,7 +80,6 @@ public class FileUpdater extends MiniPlugin
private void generatePermissions() private void generatePermissions()
{ {
PermissionGroup.MOD.setPermission(Perm.BVERSION_COMMAND, true, true); PermissionGroup.MOD.setPermission(Perm.BVERSION_COMMAND, true, true);
PermissionGroup.ADMIN.setPermission(Perm.RESTART_COMMAND, true, true); PermissionGroup.ADMIN.setPermission(Perm.RESTART_COMMAND, true, true);
PermissionGroup.QAM.setPermission(Perm.RESTART_COMMAND, false, true); PermissionGroup.QAM.setPermission(Perm.RESTART_COMMAND, false, true);
@ -112,10 +114,17 @@ public class FileUpdater extends MiniPlugin
if (event.getType() != UpdateType.SLOWER) if (event.getType() != UpdateType.SLOWER)
return; return;
if (!_needUpdate || !_enabled) if (!_needUpdate || !_enabled || _restartTriggered)
return; 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); 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.")); 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); }, 60L);
getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(getPlugin(), () ->
{ {
public void run() getPlugin().getServer().shutdown();
{
getPlugin().getServer().shutdown();
}
}, 100L); }, 100L);
} }
} }

View File

@ -1,14 +1,5 @@
package mineplex.core.updater; 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.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -17,6 +8,18 @@ import org.bukkit.event.Listener;
import org.bukkit.event.server.ServerListPingEvent; import org.bukkit.event.server.ServerListPingEvent;
import org.bukkit.plugin.java.JavaPlugin; 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 public class RestartHandler implements CommandCallback, Listener
{ {
private JavaPlugin _plugin; private JavaPlugin _plugin;
@ -51,6 +54,16 @@ public class RestartHandler implements CommandCallback, Listener
if (!serverName.equalsIgnoreCase(_serverName) || _region != region) if (!serverName.equalsIgnoreCase(_serverName) || _region != region)
return; return;
if (UtilServer.CallEvent(new RestartTriggerEvent(RestartTriggerEvent.RestartReason.COMMAND)).isCancelled())
{
return;
}
if (UtilServer.CallEvent(new RestartServerEvent(RestartServerEvent.RestartReason.COMMAND)).isCancelled())
{
return;
}
_restarting = true; _restarting = true;
for (Player player : Bukkit.getOnlinePlayers()) 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.")); 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); }, 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); }, 100L);
} }
} }
} }

View File

@ -8,6 +8,12 @@ public class RestartServerEvent extends Event implements Cancellable
{ {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
private boolean _cancelled = false; private boolean _cancelled = false;
private final RestartReason _reason;
public RestartServerEvent(RestartReason reason)
{
_reason = reason;
}
public HandlerList getHandlers() public HandlerList getHandlers()
{ {
@ -18,6 +24,11 @@ public class RestartServerEvent extends Event implements Cancellable
{ {
return handlers; return handlers;
} }
public RestartReason getReason()
{
return _reason;
}
@Override @Override
public boolean isCancelled() public boolean isCancelled()
@ -30,4 +41,10 @@ public class RestartServerEvent extends Event implements Cancellable
{ {
_cancelled = cancel; _cancelled = cancel;
} }
}
public enum RestartReason
{
COMMAND,
UPDATE
}
}

View File

@ -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
}
}

View File

@ -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<Player, Boolean> _shouldHide = new NautHashMap<Player, Boolean>();
private NautHashMap<Player, Boolean> _lastState = new NautHashMap<Player, Boolean>();
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<Player> 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<Player> targetIter = _lastState.keySet().iterator(); targetIter.hasNext();)
{
Player target = targetIter.next();
if (!target.isOnline() || !target.isValid())
{
targetIter.remove();
}
}
}
TimingManager.stopTotal("VisData attemptToProcessUpdate lastState");
}
}

Some files were not shown because too many files have changed in this diff Show More