Various changes for network security
This commit is contained in:
parent
f4a9253505
commit
1c96196359
@ -13,6 +13,7 @@ import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UUIDFetcher;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.serverdata.commands.UpdateRankCommand;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -52,8 +53,13 @@ public class UpdateRank extends CommandBase<CoreClientManager>
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), ChatColor.RED + "" + ChatColor.BOLD + "Invalid rank!"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
final Rank rank = tempRank;
|
||||
|
||||
Plugin.runAsync(() ->
|
||||
{
|
||||
new UpdateRankCommand(caller.getName(), caller.getUniqueId().toString(), playerName, rank.name()).publish();
|
||||
});
|
||||
|
||||
Plugin.getRepository().matchPlayerName(new Callback<List<String>>()
|
||||
{
|
||||
|
@ -209,48 +209,47 @@ public class AntiHack extends MiniPlugin
|
||||
{
|
||||
CoreClient coreClient = _clientManager.Get(player);
|
||||
|
||||
Consumer<Consumer<PunishmentResponse>> doPunish = after ->
|
||||
{
|
||||
JsonObject custom = new JsonObject();
|
||||
custom.addProperty("ban-reason", CheckManager.getCheckSimpleName(cause));
|
||||
String id = generateId();
|
||||
String finalMessage = "[GWEN] " + id;
|
||||
JsonObject custom = new JsonObject();
|
||||
custom.addProperty("ban-reason", CheckManager.getCheckSimpleName(cause));
|
||||
|
||||
String id = generateId();
|
||||
String finalMessage = "[GWEN] " + id;
|
||||
_logger.saveMetadata(player, id, () ->
|
||||
_logger.saveMetadata(player, id, () ->
|
||||
{
|
||||
Consumer<Consumer<PunishmentResponse>> doPunish = after ->
|
||||
{
|
||||
runAsync(() ->
|
||||
{
|
||||
GwenBanNotification notification = new GwenBanNotification(_thisServer, player.getName(), player.getUniqueId().toString(), CheckManager.getCheckSimpleName(cause), id);
|
||||
ServerCommandManager.getInstance().publishCommand(notification);
|
||||
});
|
||||
|
||||
_punish.AddPunishment(coreClient.getName(), Category.Hacking, finalMessage, AntiHack.NAME, 3, true, -1, true, after);
|
||||
}, custom);
|
||||
};
|
||||
|
||||
if (coreClient.GetRank().has(Rank.TWITCH))
|
||||
{
|
||||
doPunish.accept(result ->
|
||||
{
|
||||
_pendingBan.remove(player);
|
||||
_banned.add(player.getUniqueId());
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
runBanAnimation(player, () ->
|
||||
doPunish.accept(result ->
|
||||
runAsync(() ->
|
||||
{
|
||||
if (result == PunishmentResponse.Punished)
|
||||
new GwenBanNotification(_thisServer, player.getName(), player.getUniqueId().toString(), coreClient.GetRank().name(), CheckManager.getCheckSimpleName(cause), id).publish();
|
||||
});
|
||||
|
||||
_punish.AddPunishment(coreClient.getName(), Category.Hacking, finalMessage, AntiHack.NAME, 3, true, -1, true, after);
|
||||
};
|
||||
|
||||
if (coreClient.GetRank().has(Rank.TWITCH))
|
||||
{
|
||||
doPunish.accept(result ->
|
||||
{
|
||||
_pendingBan.remove(player);
|
||||
_banned.add(player.getUniqueId());
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
runBanAnimation(player, () ->
|
||||
doPunish.accept(result ->
|
||||
{
|
||||
announceBan(player);
|
||||
_banned.add(player.getUniqueId());
|
||||
_banWaveManager.flagDone(coreClient);
|
||||
}
|
||||
_pendingBan.remove(player);
|
||||
})
|
||||
);
|
||||
}
|
||||
if (result == PunishmentResponse.Punished)
|
||||
{
|
||||
announceBan(player);
|
||||
_banned.add(player.getUniqueId());
|
||||
_banWaveManager.flagDone(coreClient);
|
||||
}
|
||||
_pendingBan.remove(player);
|
||||
})
|
||||
);
|
||||
}
|
||||
}, custom);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -68,8 +68,7 @@ public class BanWaveManager extends MiniPlugin
|
||||
{
|
||||
runAsync(() ->
|
||||
{
|
||||
GwenBanwaveNotification notification = new GwenBanwaveNotification(UtilServer.getServerName(), player.getName(), player.getUniqueId().toString(), CheckManager.getCheckSimpleName(checkClass), id, timeToBan);
|
||||
ServerCommandManager.getInstance().publishCommand(notification);
|
||||
new GwenBanwaveNotification(UtilServer.getServerName(), player.getName(), player.getUniqueId().toString(), client.GetRank().name(), CheckManager.getCheckSimpleName(checkClass), id, timeToBan).publish();
|
||||
});
|
||||
|
||||
JsonObject custom = new JsonObject();
|
||||
|
@ -7,14 +7,16 @@ public class GwenBanNotification extends ServerCommand
|
||||
private final String _serverName;
|
||||
private final String _playerName;
|
||||
private final String _playerUUID;
|
||||
private final String _playerRank;
|
||||
private final String _hackType;
|
||||
private final String _metadataId;
|
||||
|
||||
public GwenBanNotification(String serverName, String playerName, String playerUUID, String hackType, String metadataId)
|
||||
public GwenBanNotification(String serverName, String playerName, String playerUUID, String playerRank, String hackType, String metadataId)
|
||||
{
|
||||
_serverName = serverName;
|
||||
_playerName = playerName;
|
||||
_playerUUID = playerUUID;
|
||||
_playerRank = playerRank;
|
||||
_hackType = hackType;
|
||||
_metadataId = metadataId;
|
||||
}
|
||||
|
@ -7,15 +7,17 @@ public class GwenBanwaveNotification extends ServerCommand
|
||||
private final String _serverName;
|
||||
private final String _playerName;
|
||||
private final String _playerUUID;
|
||||
private final String _playerRank;
|
||||
private final String _hackType;
|
||||
private final String _metadataId;
|
||||
private final long _timeToBan;
|
||||
|
||||
public GwenBanwaveNotification(String serverName, String playerName, String playerUUID, String hackType, String metadataId, long timeToBan)
|
||||
public GwenBanwaveNotification(String serverName, String playerName, String playerUUID, String playerRank, String hackType, String metadataId, long timeToBan)
|
||||
{
|
||||
_serverName = serverName;
|
||||
_playerName = playerName;
|
||||
_playerUUID = playerUUID;
|
||||
_playerRank = playerRank;
|
||||
_hackType = hackType;
|
||||
_metadataId = metadataId;
|
||||
_timeToBan = timeToBan;
|
||||
|
@ -18,10 +18,12 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.event.ClientWebResponseEvent;
|
||||
import mineplex.core.common.Constants;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.Callback;
|
||||
@ -243,7 +245,7 @@ public class Punish extends MiniPlugin
|
||||
{
|
||||
runAsync(() ->
|
||||
{
|
||||
ServerCommandManager.getInstance().publishCommand(new AddPunishCommand(finalPlayerName, category.name(), sentence.name(), reason, duration, finalCallerName, caller != null ? caller.getUniqueId().toString() : null));
|
||||
new AddPunishCommand(finalPlayerName, severity, category.name(), sentence.name(), reason, duration, finalCallerName, caller != null ? caller.getUniqueId().toString() : null).publish();
|
||||
});
|
||||
final String durationString = UtilTime.convertString(finalDuration < 0 ? -1 : (long)(finalDuration * 3600000), 1, TimeUnit.FIT);
|
||||
|
||||
@ -398,7 +400,7 @@ public class Punish extends MiniPlugin
|
||||
}
|
||||
}
|
||||
|
||||
public void RemovePunishment(int punishmentId, String target, final Player admin, String reason, Callback<String> callback)
|
||||
public void RemovePunishment(Punishment punishment, String target, final Player admin, String reason, Callback<String> callback)
|
||||
{
|
||||
CoreClient client = _clientManager.Get(admin);
|
||||
_repository.RemovePunishment(string ->
|
||||
@ -408,12 +410,12 @@ public class Punish extends MiniPlugin
|
||||
PunishmentResponse punishResponse = PunishmentResponse.valueOf(string);
|
||||
if (punishResponse == PunishmentResponse.PunishmentRemoved)
|
||||
{
|
||||
ServerCommandManager.getInstance().publishCommand(new RemovePunishCommand(punishmentId, target, admin.getName(), admin.getUniqueId(), reason));
|
||||
ServerCommandManager.getInstance().publishCommand(new RemovePunishCommand(Constants.GSON.fromJson(Constants.GSON.toJson(punishment), JsonObject.class), target, admin.getName(), admin.getUniqueId(), reason));
|
||||
}
|
||||
});
|
||||
|
||||
callback.run(string);
|
||||
}, punishmentId, target, reason, client.getName());
|
||||
}, punishment.GetPunishmentId(), target, reason, client.getName());
|
||||
}
|
||||
|
||||
public CoreClientManager GetClients()
|
||||
|
@ -511,7 +511,7 @@ public class PunishPage extends CraftInventoryCustom implements Listener
|
||||
|
||||
public void RemovePunishment(final Punishment punishment, final ItemStack item)
|
||||
{
|
||||
_plugin.RemovePunishment(punishment.GetPunishmentId(), _target, _player, _reason, new Callback<String>()
|
||||
_plugin.RemovePunishment(punishment, _target, _player, _reason, new Callback<String>()
|
||||
{
|
||||
@Override
|
||||
public void run(String result)
|
||||
|
@ -39,6 +39,7 @@ import mineplex.core.common.util.BukkitFuture;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.serverdata.commands.TwoFactorResetCommand;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
|
||||
@ReflectivelyCreateMiniPlugin
|
||||
@ -88,6 +89,10 @@ public class TwoFactorAuth extends MiniClientPlugin<TwoFactorData>
|
||||
if (args.length == 1) // Resetting their own 2FA
|
||||
{
|
||||
caller.sendMessage(F.main("2FA", "Resetting 2FA.."));
|
||||
runAsync(() ->
|
||||
{
|
||||
new TwoFactorResetCommand(caller.getName(), caller.getUniqueId().toString(), caller.getName(), caller.getUniqueId().toString()).publish();
|
||||
});
|
||||
_repository.deletePlayerData(_clientManager.getAccountId(caller)).whenComplete(BukkitFuture.complete((__, err) ->
|
||||
{
|
||||
if (err != null)
|
||||
@ -119,6 +124,10 @@ public class TwoFactorAuth extends MiniClientPlugin<TwoFactorData>
|
||||
}
|
||||
|
||||
caller.sendMessage(F.main("2FA", "Resetting 2FA for \"" + client.getName() + "\""));
|
||||
runAsync(() ->
|
||||
{
|
||||
new TwoFactorResetCommand(caller.getName(), caller.getUniqueId().toString(), client.getName(), client.getUniqueId() == null ? "null" : client.getUniqueId().toString()).publish();
|
||||
});
|
||||
_repository.deletePlayerData(client.getAccountId()).whenComplete(BukkitFuture.complete((__, err) ->
|
||||
{
|
||||
if (err != null)
|
||||
|
@ -11,10 +11,12 @@ public class AddPunishCommand extends ServerCommand
|
||||
private final long _duration;
|
||||
private final String _admin;
|
||||
private final String _adminUUID;
|
||||
private final int _severity;
|
||||
|
||||
public AddPunishCommand(String finalPlayerName, String category, String sentence, String reason, long duration, String finalCallerName, String uuid)
|
||||
public AddPunishCommand(String finalPlayerName, int severity, String category, String sentence, String reason, long duration, String finalCallerName, String uuid)
|
||||
{
|
||||
this._target = finalPlayerName;
|
||||
this._severity = severity;
|
||||
this._category = category;
|
||||
this._sentence = sentence;
|
||||
this._reason = reason;
|
||||
|
@ -2,17 +2,19 @@ package mineplex.serverdata.commands;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
public class RemovePunishCommand extends ServerCommand
|
||||
{
|
||||
private final int _punishmentId;
|
||||
private final JsonObject _punishment;
|
||||
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)
|
||||
public RemovePunishCommand(JsonObject punishment, String target, String admin, UUID adminUUID, String reason)
|
||||
{
|
||||
_punishmentId = punishmentId;
|
||||
_punishment = punishment;
|
||||
_target = target;
|
||||
_admin = admin;
|
||||
_adminUUID = adminUUID.toString();
|
||||
|
@ -0,0 +1,17 @@
|
||||
package mineplex.serverdata.commands;
|
||||
|
||||
public class TwoFactorResetCommand extends ServerCommand
|
||||
{
|
||||
private String _adminName;
|
||||
private String _adminUUID;
|
||||
private String _targetName;
|
||||
private String _targetUUID;
|
||||
|
||||
public TwoFactorResetCommand(String adminName, String adminUUID, String targetName, String targetUUID)
|
||||
{
|
||||
_adminName = adminName;
|
||||
_adminUUID = adminUUID;
|
||||
_targetName = targetName;
|
||||
_targetUUID = targetUUID;
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package mineplex.serverdata.commands;
|
||||
|
||||
public class UpdateRankCommand extends ServerCommand
|
||||
{
|
||||
private String _callerName;
|
||||
private String _callerUUID;
|
||||
private String _targetName;
|
||||
private String _targetRankNew;
|
||||
|
||||
public UpdateRankCommand(String callerName, String callerUUID, String targetName, String targetRankNew)
|
||||
{
|
||||
_callerName = callerName;
|
||||
_callerUUID = callerUUID;
|
||||
_targetName = targetName;
|
||||
_targetRankNew = targetRankNew;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user