diff --git a/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java index 4575de030..8c5125364 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java @@ -1,6 +1,7 @@ package mineplex.core.punish; import java.util.HashMap; +import java.util.UUID; import java.util.logging.Level; import mineplex.core.account.CoreClient; @@ -35,6 +36,8 @@ import mineplex.core.punish.Tokens.PunishClientToken; import mineplex.core.punish.Tokens.PunishmentToken; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.serverdata.commands.AddPunishCommand; +import mineplex.serverdata.commands.RemovePunishCommand; import mineplex.serverdata.commands.ServerCommandManager; public class Punish extends MiniPlugin @@ -233,6 +236,10 @@ public class Punish extends MiniPlugin } else if (banResult == PunishmentResponse.Punished) { + runAsync(() -> + { + ServerCommandManager.getInstance().publishCommand(new AddPunishCommand(finalPlayerName, category.name(), sentence.name(), reason, duration, finalCallerName, caller != null ? caller.getUniqueId().toString() : null)); + }); final String durationString = UtilTime.convertString(finalDuration < 0 ? -1 : (long)(finalDuration * 3600000), 1, TimeUnit.FIT); if (sentence == PunishmentSentence.Ban) @@ -385,7 +392,19 @@ public class Punish extends MiniPlugin public void RemovePunishment(int punishmentId, String target, final Player admin, String reason, Callback callback) { CoreClient client = _clientManager.Get(admin); - _repository.RemovePunishment(callback, punishmentId, target, reason, client.getName()); + _repository.RemovePunishment(string -> + { + runAsync(() -> + { + PunishmentResponse punishResponse = PunishmentResponse.valueOf(string); + if (punishResponse == PunishmentResponse.PunishmentRemoved) + { + ServerCommandManager.getInstance().publishCommand(new RemovePunishCommand(punishmentId, target, admin.getName(), admin.getUniqueId(), reason)); + } + }); + + callback.run(string); + }, punishmentId, target, reason, client.getName()); } public void RemoveBan(String name, String reason) diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/AddPunishCommand.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/AddPunishCommand.java new file mode 100644 index 000000000..9112bef37 --- /dev/null +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/AddPunishCommand.java @@ -0,0 +1,30 @@ +package mineplex.serverdata.commands; + +import java.util.UUID; + +public class AddPunishCommand extends ServerCommand +{ + private final String _target; + private final String _category; + private final String _sentence; + private final String _reason; + private final long _duration; + private final String _admin; + private final String _adminUUID; + + public AddPunishCommand(String finalPlayerName, String category, String sentence, String reason, long duration, String finalCallerName, String uuid) + { + this._target = finalPlayerName; + this._category = category; + this._sentence = sentence; + this._reason = reason; + this._duration = duration; + this._admin = finalCallerName; + this._adminUUID = uuid; + } + + @Override + public void run() + { + } +} diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/RemovePunishCommand.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/RemovePunishCommand.java new file mode 100644 index 000000000..87c2ecf22 --- /dev/null +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/RemovePunishCommand.java @@ -0,0 +1,26 @@ +package mineplex.serverdata.commands; + +import java.util.UUID; + +public class RemovePunishCommand extends ServerCommand +{ + private final int _punishmentId; + private final String _target; + private final String _admin; + private final String _adminUUID; + private final String _reason; + + public RemovePunishCommand(int punishmentId, String target, String admin, UUID adminUUID, String reason) + { + _punishmentId = punishmentId; + _target = target; + _admin = admin; + _adminUUID = adminUUID.toString(); + _reason = reason; + } + + @Override + public void run() + { + } +} diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/ServerCommand.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/ServerCommand.java index 5f6e546b8..d4da082b3 100644 --- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/ServerCommand.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/ServerCommand.java @@ -1,10 +1,11 @@ package mineplex.serverdata.commands; -public abstract class ServerCommand +public abstract class ServerCommand { // The names of servers targetted to receive this ServerCommand. + private String _fromServer; private String[] _targetServers; /** @@ -14,6 +15,7 @@ public abstract class ServerCommand public ServerCommand(String... targetServers) { _targetServers = targetServers; + _fromServer = ServerCommandManager.getInstance().getServerName(); } public void setTargetServers(String... targetServers) diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/ServerCommandManager.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/ServerCommandManager.java index 089f29e97..b0b45e06d 100644 --- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/ServerCommandManager.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/ServerCommandManager.java @@ -25,6 +25,10 @@ public class ServerCommandManager private String _localServerName; public void initializeServer(String serverName) { _localServerName = serverName; } public boolean isServerInitialized() { return _localServerName != null; } + public String getServerName() + { + return this._localServerName; + } /** * Private class constructor to prevent non-singleton instances.