mirror of
https://github.com/songoda/UltimateModeration.git
synced 2024-11-13 22:05:17 +01:00
Redid most of the plugin.
This commit is contained in:
parent
b1cd9d459d
commit
aee2620109
@ -6,13 +6,19 @@ import com.songoda.core.commands.CommandManager;
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.core.configuration.Config;
|
||||
import com.songoda.core.database.DataMigrationManager;
|
||||
import com.songoda.core.database.DatabaseConnector;
|
||||
import com.songoda.core.database.MySQLConnector;
|
||||
import com.songoda.core.database.SQLiteConnector;
|
||||
import com.songoda.core.gui.GuiManager;
|
||||
import com.songoda.ultimatemoderation.commands.*;
|
||||
import com.songoda.ultimatemoderation.database.DataManager;
|
||||
import com.songoda.ultimatemoderation.database.migrations._1_InitialMigration;
|
||||
import com.songoda.ultimatemoderation.listeners.*;
|
||||
import com.songoda.ultimatemoderation.moderate.ModerationManager;
|
||||
import com.songoda.ultimatemoderation.punish.AppliedPunishment;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentNote;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentType;
|
||||
import com.songoda.ultimatemoderation.punish.player.PlayerPunishData;
|
||||
import com.songoda.ultimatemoderation.punish.player.PunishmentManager;
|
||||
import com.songoda.ultimatemoderation.punish.template.Template;
|
||||
import com.songoda.ultimatemoderation.punish.template.TemplateManager;
|
||||
@ -27,11 +33,14 @@ import com.songoda.ultimatemoderation.tickets.TicketManager;
|
||||
import com.songoda.ultimatemoderation.tickets.TicketResponse;
|
||||
import com.songoda.ultimatemoderation.tickets.TicketStatus;
|
||||
import com.songoda.ultimatemoderation.utils.Methods;
|
||||
import com.songoda.ultimatemoderation.utils.gui.AbstractGUI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class UltimateModeration extends SongodaPlugin {
|
||||
@ -43,8 +52,10 @@ public class UltimateModeration extends SongodaPlugin {
|
||||
private CommandManager commandManager;
|
||||
private PunishmentManager punishmentManager;
|
||||
private StaffChatManager staffChatManager;
|
||||
private ModerationManager moderationManager;
|
||||
|
||||
private Storage storage;
|
||||
private DatabaseConnector databaseConnector;
|
||||
private DataManager dataManager;
|
||||
|
||||
public static UltimateModeration getInstance() {
|
||||
return INSTANCE;
|
||||
@ -57,8 +68,6 @@ public class UltimateModeration extends SongodaPlugin {
|
||||
|
||||
@Override
|
||||
public void onPluginDisable() {
|
||||
storage.doSave();
|
||||
this.storage.closeConnection();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -80,23 +89,17 @@ public class UltimateModeration extends SongodaPlugin {
|
||||
);
|
||||
this.commandManager.addCommand(new CommandBan(this));
|
||||
this.commandManager.addCommand(new CommandClearChat(this));
|
||||
this.commandManager.addCommand(new CommandCommandSpy(this));
|
||||
this.commandManager.addCommand(new CommandFreeze(this));
|
||||
this.commandManager.addCommand(new CommandInvSee(this));
|
||||
this.commandManager.addCommand(new CommandKick(this));
|
||||
this.commandManager.addCommand(new CommandMute(this));
|
||||
this.commandManager.addCommand(new CommandRandomPlayer(this));
|
||||
this.commandManager.addCommand(new CommandRevive(this));
|
||||
this.commandManager.addCommand(new CommandRunTemplate(this));
|
||||
this.commandManager.addCommand(new CommandSlowMode(this));
|
||||
this.commandManager.addCommand(new CommandSpy(this));
|
||||
this.commandManager.addCommand(new CommandStaffChat(this));
|
||||
this.commandManager.addCommand(new CommandTicket(this));
|
||||
this.commandManager.addCommand(new CommandToggleChat(this));
|
||||
this.commandManager.addCommand(new CommandUnBan(this));
|
||||
this.commandManager.addCommand(new CommandUnMute(this));
|
||||
this.commandManager.addCommand(new CommandVanish(this));
|
||||
this.commandManager.addCommand(new CommandViewEnderChest(this));
|
||||
this.commandManager.addCommand(new CommandWarn(this));
|
||||
|
||||
// Setup Managers
|
||||
@ -104,14 +107,138 @@ public class UltimateModeration extends SongodaPlugin {
|
||||
this.templateManager = new TemplateManager();
|
||||
this.punishmentManager = new PunishmentManager();
|
||||
this.staffChatManager = new StaffChatManager();
|
||||
this.moderationManager = new ModerationManager(this);
|
||||
|
||||
// Load data
|
||||
this.checkStorage();
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(this, this::loadFromFile, 1L);
|
||||
// Database stuff, go!
|
||||
try {
|
||||
if (Settings.MYSQL_ENABLED.getBoolean()) {
|
||||
String hostname = Settings.MYSQL_HOSTNAME.getString();
|
||||
int port = Settings.MYSQL_PORT.getInt();
|
||||
String database = Settings.MYSQL_DATABASE.getString();
|
||||
String username = Settings.MYSQL_USERNAME.getString();
|
||||
String password = Settings.MYSQL_PASSWORD.getString();
|
||||
boolean useSSL = Settings.MYSQL_USE_SSL.getBoolean();
|
||||
|
||||
this.databaseConnector = new MySQLConnector(this, hostname, port, database, username, password, useSSL);
|
||||
this.getLogger().info("Data handler connected using MySQL.");
|
||||
} else {
|
||||
this.databaseConnector = new SQLiteConnector(this);
|
||||
this.getLogger().info("Data handler connected using SQLite.");
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
this.getLogger().severe("Fatal error trying to connect to database. Please make sure all your connection settings are correct and try again. Plugin has been disabled.");
|
||||
this.emergencyStop();
|
||||
}
|
||||
|
||||
this.dataManager = new DataManager(this.databaseConnector, this);
|
||||
DataMigrationManager dataMigrationManager = new DataMigrationManager(this.databaseConnector, this.dataManager,
|
||||
new _1_InitialMigration());
|
||||
dataMigrationManager.runMigrations();
|
||||
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(this, () -> {
|
||||
// Legacy Data
|
||||
File folder = getDataFolder();
|
||||
File dataFile = new File(folder, "data.yml");
|
||||
|
||||
boolean converted = false;
|
||||
if (dataFile.exists()) {
|
||||
converted = true;
|
||||
Storage storage = new StorageYaml(this);
|
||||
console.sendMessage("[" + getDescription().getName() + "] " + ChatColor.RED + "Conversion process starting DO NOT turn off your server... " +
|
||||
"UltimateModeration hasn't fully loaded yet so its best users don't interact with the plugin until conversion completes.");
|
||||
if (storage.containsGroup("templates")) {
|
||||
for (StorageRow row : storage.getRowsByGroup("templates")) {
|
||||
Template template = new Template(PunishmentType.valueOf(row.get("type").asString()),
|
||||
row.get("duration").asLong(),
|
||||
row.get("reason").asString(),
|
||||
UUID.fromString(row.get("creator").asString()),
|
||||
row.get("name").asString());
|
||||
dataManager.createTemplate(template);
|
||||
}
|
||||
}
|
||||
|
||||
if (storage.containsGroup("punishments")) {
|
||||
for (StorageRow row : storage.getRowsByGroup("punishments")) {
|
||||
AppliedPunishment appliedPunishment = new AppliedPunishment(PunishmentType.valueOf(row.get("type").asString()),
|
||||
row.get("duration").asLong(),
|
||||
row.get("reason").asString(),
|
||||
UUID.fromString(row.get("victim").asString()),
|
||||
row.get("punisher").asObject() == null ? null : UUID.fromString(row.get("punisher").asString()),
|
||||
row.get("expiration").asLong());
|
||||
dataManager.createAppliedPunishment(appliedPunishment);
|
||||
}
|
||||
}
|
||||
|
||||
if (storage.containsGroup("notes")) {
|
||||
for (StorageRow row : storage.getRowsByGroup("notes")) {
|
||||
PunishmentNote note = new PunishmentNote(row.get("note").asString(),
|
||||
UUID.fromString(row.get("author").asString()),
|
||||
UUID.fromString(row.get("subject").asString()),
|
||||
row.get("creation").asLong());
|
||||
dataManager.createNote(note);
|
||||
}
|
||||
}
|
||||
|
||||
Map<Integer, Ticket> tickets = new HashMap<>();
|
||||
if (storage.containsGroup("tickets")) {
|
||||
for (StorageRow row : storage.getRowsByGroup("tickets")) {
|
||||
|
||||
int id = Integer.parseInt(row.get("id").asString());
|
||||
Ticket ticket = new Ticket(
|
||||
UUID.fromString(row.get("player").asString()),
|
||||
row.get("subject").asString(),
|
||||
row.get("type").asString());
|
||||
ticket.setId(id);
|
||||
ticket.setLocation(Methods.unserializeLocation(row.get("location").asString()));
|
||||
ticket.setStatus(TicketStatus.valueOf(row.get("status").asString()));
|
||||
tickets.put(id, ticket);
|
||||
}
|
||||
}
|
||||
|
||||
if (storage.containsGroup("ticketresponses")) {
|
||||
for (StorageRow row : storage.getRowsByGroup("ticketresponses")) {
|
||||
int id = row.get("ticketid").asInt();
|
||||
TicketResponse ticketResponse = new TicketResponse(
|
||||
UUID.fromString(row.get("author").asString()),
|
||||
row.get("message").asString(),
|
||||
Long.parseLong(row.get("posted").asString()));
|
||||
|
||||
tickets.get(id).addResponse(ticketResponse);
|
||||
ticketResponse.setTicketId(id);
|
||||
}
|
||||
}
|
||||
for (Ticket ticket : tickets.values())
|
||||
dataManager.createTicket(ticket);
|
||||
}
|
||||
dataFile.delete();
|
||||
|
||||
final boolean convrted = converted;
|
||||
getDataManager().queueAsync(() -> {
|
||||
if (convrted)
|
||||
console.sendMessage("[" + getDescription().getName() + "] " + ChatColor.GREEN + "Conversion complete :)");
|
||||
// Load data from DB
|
||||
this.dataManager.getTemplates((templates) -> {
|
||||
for (Template template : templates) {
|
||||
this.templateManager.addTemplate(template);
|
||||
}
|
||||
});
|
||||
this.dataManager.getAppliedPunishments((appliedPunishments) -> {
|
||||
for (AppliedPunishment punishment : appliedPunishments)
|
||||
this.punishmentManager.getPlayer(punishment.getVictim()).addPunishment(punishment);
|
||||
});
|
||||
this.dataManager.getNotes((notes) -> {
|
||||
for (PunishmentNote note : notes)
|
||||
this.punishmentManager.getPlayer(note.getSubject()).addNotes(note);
|
||||
});
|
||||
this.dataManager.getTickets((tickets) -> {
|
||||
for (Ticket ticket : tickets.values())
|
||||
this.ticketManager.addTicket(ticket);
|
||||
});
|
||||
}, "create");
|
||||
}, 20);
|
||||
|
||||
// Register Listeners
|
||||
guiManager.init();
|
||||
AbstractGUI.initializeListeners(this);
|
||||
PluginManager pluginManager = Bukkit.getPluginManager();
|
||||
pluginManager.registerEvents(new CommandListener(this), this);
|
||||
pluginManager.registerEvents(new DeathListener(this), this);
|
||||
@ -130,85 +257,6 @@ public class UltimateModeration extends SongodaPlugin {
|
||||
|
||||
// Start tasks
|
||||
SlowModeTask.startTask(this);
|
||||
|
||||
int timeout = Settings.AUTOSAVE.getInt() * 60 * 20;
|
||||
Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> storage.doSave(), timeout, timeout);
|
||||
}
|
||||
|
||||
private void checkStorage() {
|
||||
this.storage = new StorageYaml(this);
|
||||
}
|
||||
|
||||
private void loadFromFile() {
|
||||
if (storage.containsGroup("templates")) {
|
||||
for (StorageRow row : storage.getRowsByGroup("templates")) {
|
||||
Template template = new Template(PunishmentType.valueOf(row.get("type").asString()),
|
||||
row.get("duration").asLong(),
|
||||
row.get("reason").asString(),
|
||||
UUID.fromString(row.get("creator").asString()),
|
||||
row.get("name").asString(),
|
||||
UUID.fromString(row.get("uuid").asString()));
|
||||
templateManager.addTemplate(template);
|
||||
}
|
||||
}
|
||||
if (storage.containsGroup("punishments")) {
|
||||
for (StorageRow row : storage.getRowsByGroup("punishments")) {
|
||||
UUID playerUUID = UUID.fromString(row.get("victim").asString());
|
||||
AppliedPunishment appliedPunishment = new AppliedPunishment(PunishmentType.valueOf(row.get("type").asString()),
|
||||
row.get("duration").asLong(),
|
||||
row.get("reason").asString(),
|
||||
UUID.fromString(row.get("victim").asString()),
|
||||
row.get("punisher").asObject() == null ? null : UUID.fromString(row.get("punisher").asString()),
|
||||
row.get("expiration").asLong(),
|
||||
playerUUID);
|
||||
PlayerPunishData playerPunishData = getPunishmentManager().getPlayer(playerUUID);
|
||||
playerPunishData.addPunishment(appliedPunishment);
|
||||
playerPunishData.audit();
|
||||
}
|
||||
}
|
||||
|
||||
if (storage.containsGroup("notes")) {
|
||||
for (StorageRow row : storage.getRowsByGroup("notes")) {
|
||||
UUID playerUUID = UUID.fromString(row.get("subject").asString());
|
||||
PunishmentNote note = new PunishmentNote(UUID.fromString(row.get("uuid").asString()),
|
||||
row.get("note").asString(),
|
||||
UUID.fromString(row.get("author").asString()),
|
||||
UUID.fromString(row.get("subject").asString()),
|
||||
row.get("creation").asLong());
|
||||
|
||||
PlayerPunishData playerPunishData = getPunishmentManager().getPlayer(playerUUID);
|
||||
playerPunishData.addNotes(note);
|
||||
}
|
||||
}
|
||||
|
||||
if (storage.containsGroup("tickets")) {
|
||||
for (StorageRow row : storage.getRowsByGroup("tickets")) {
|
||||
|
||||
int id = Integer.parseInt(row.get("id").asString());
|
||||
Ticket ticket = new Ticket(
|
||||
UUID.fromString(row.get("player").asString()),
|
||||
row.get("subject").asString(),
|
||||
row.get("type").asString());
|
||||
ticket.setTicketId(id);
|
||||
ticket.setLocation(Methods.unserializeLocation(row.get("location").asString()));
|
||||
ticket.setStatus(TicketStatus.valueOf(row.get("status").asString()));
|
||||
ticketManager.addTicket(ticket, id);
|
||||
}
|
||||
}
|
||||
|
||||
if (storage.containsGroup("ticketresponses")) {
|
||||
for (StorageRow row : storage.getRowsByGroup("ticketresponses")) {
|
||||
int id = row.get("ticketid").asInt();
|
||||
TicketResponse ticketResponse = new TicketResponse(
|
||||
UUID.fromString(row.get("author").asString()),
|
||||
row.get("message").asString(),
|
||||
Long.parseLong(row.get("posted").asString()));
|
||||
ticketResponse.setTicketId(id);
|
||||
ticketManager.getTicket(id).addResponse(ticketResponse);
|
||||
|
||||
}
|
||||
}
|
||||
storage.doSave();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -242,7 +290,19 @@ public class UltimateModeration extends SongodaPlugin {
|
||||
return staffChatManager;
|
||||
}
|
||||
|
||||
public DataManager getDataManager() {
|
||||
return dataManager;
|
||||
}
|
||||
|
||||
public DatabaseConnector getDatabaseConnector() {
|
||||
return databaseConnector;
|
||||
}
|
||||
|
||||
public GuiManager getGuiManager() {
|
||||
return guiManager;
|
||||
}
|
||||
|
||||
public ModerationManager getModerationManager() {
|
||||
return moderationManager;
|
||||
}
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ public class CommandBan extends AbstractCommand {
|
||||
|
||||
long durationFinal = duration;
|
||||
Bukkit.getScheduler().runTaskAsynchronously(instance, () -> {
|
||||
if (sender instanceof Player && VaultPermissions.hasPermission(Bukkit.getWorlds().get(0).getName(), player, "um.ban.exempt")) {
|
||||
if (sender instanceof Player && VaultPermissions.hasPermission(player, "um.ban.exempt")) {
|
||||
instance.getLocale().newMessage("You cannot ban this player.").sendPrefixedMessage(sender);
|
||||
return;
|
||||
}
|
||||
|
@ -1,59 +0,0 @@
|
||||
package com.songoda.ultimatemoderation.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class CommandCommandSpy extends AbstractCommand {
|
||||
|
||||
private UltimateModeration instance;
|
||||
private static List<UUID> inSpy = new ArrayList<>();
|
||||
|
||||
public CommandCommandSpy(UltimateModeration instance) {
|
||||
super(CommandType.CONSOLE_OK, "CommandSpy");
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
public static boolean isSpying(Player player) {
|
||||
return !inSpy.contains(player.getUniqueId());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
Player player = ((Player) sender);
|
||||
|
||||
if (inSpy.contains(player.getUniqueId())) {
|
||||
inSpy.remove(player.getUniqueId());
|
||||
instance.getLocale().getMessage("command.commandspy.toggleOn").sendPrefixedMessage(player);
|
||||
} else {
|
||||
inSpy.add(player.getUniqueId());
|
||||
instance.getLocale().getMessage("command.commandspy.toggleOff").sendPrefixedMessage(player);
|
||||
}
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender sender, String... args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "Um.commandspy";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/Commandspy";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Allows you to see inside of a players enderchest.";
|
||||
}
|
||||
}
|
@ -1,91 +0,0 @@
|
||||
package com.songoda.ultimatemoderation.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class CommandFreeze extends AbstractCommand {
|
||||
|
||||
private UltimateModeration instance;
|
||||
private static List<UUID> frozen = new ArrayList<>();
|
||||
|
||||
public CommandFreeze(UltimateModeration instance) {
|
||||
super(CommandType.CONSOLE_OK, "Freeze");
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
public static void freeze(OfflinePlayer player, CommandSender sender) {
|
||||
UltimateModeration instance = UltimateModeration.getInstance();
|
||||
if (frozen.contains(player.getUniqueId())) {
|
||||
frozen.remove(player.getUniqueId());
|
||||
instance.getLocale().getMessage("command.freeze.remove")
|
||||
.processPlaceholder("player", player.getPlayer().getDisplayName()).sendPrefixedMessage(sender);
|
||||
instance.getLocale().getMessage("command.freeze.alertremove").sendPrefixedMessage(sender);
|
||||
} else {
|
||||
frozen.add(player.getUniqueId());
|
||||
instance.getLocale().getMessage("command.freeze.add")
|
||||
.processPlaceholder("player", player.getPlayer().getDisplayName()).sendPrefixedMessage(sender);
|
||||
instance.getLocale().getMessage("command.freeze.alertadd").sendPrefixedMessage(player.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isFrozen(OfflinePlayer player) {
|
||||
return frozen.contains(player.getUniqueId());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length != 1)
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
|
||||
Player player = Bukkit.getPlayer(args[0]);
|
||||
|
||||
if (player == null) {
|
||||
instance.getLocale().newMessage("That player does not exist or is not online.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
if (sender instanceof Player && player.hasPermission("um.freeze.exempt")) {
|
||||
instance.getLocale().newMessage("That player cannot be frozen.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
freeze(player, sender);
|
||||
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender sender, String... args) {
|
||||
if (args.length == 1) {
|
||||
List<String> players = new ArrayList<>();
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
players.add(player.getName());
|
||||
}
|
||||
return players;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "um.freeze";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/Freeze <player>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Allows you to freeze a player.";
|
||||
}
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
package com.songoda.ultimatemoderation.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandInvSee extends AbstractCommand {
|
||||
|
||||
private UltimateModeration instance;
|
||||
|
||||
public CommandInvSee(UltimateModeration instance) {
|
||||
super(CommandType.PLAYER_ONLY, "InvSee");
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length != 1)
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
|
||||
Player player = Bukkit.getPlayer(args[0]);
|
||||
|
||||
if (player == null) {
|
||||
instance.getLocale().newMessage("That player does not exist or is not online").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
if (player.hasPermission("um.invsee.exempt")) {
|
||||
instance.getLocale().newMessage("You cannot invsee that player.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
((Player) sender).openInventory(player.getInventory());
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender sender, String... args) {
|
||||
if (args.length == 1) {
|
||||
List<String> players = new ArrayList<>();
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
players.add(player.getName());
|
||||
}
|
||||
return players;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "um.invsee";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/InvSee <player>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Allows you to see inside of a players inventory.";
|
||||
}
|
||||
}
|
@ -13,7 +13,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandKick extends AbstractCommand {
|
||||
public class CommandKick extends AbstractCommand {
|
||||
|
||||
private UltimateModeration instance;
|
||||
|
||||
|
@ -54,7 +54,7 @@ public class CommandMute extends AbstractCommand {
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
if (sender instanceof Player && VaultPermissions.hasPermission(Bukkit.getWorlds().get(0).getName(), player, "um.mute.exempt")) {
|
||||
if (sender instanceof Player && VaultPermissions.hasPermission(player, "um.mute.exempt")) {
|
||||
instance.getLocale().newMessage("You cannot mute that player.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ public class CommandRandomPlayer extends AbstractCommand {
|
||||
players.remove(sender);
|
||||
|
||||
if (players.size() == 0) {
|
||||
instance.getLocale().newMessage("&c You are the only one online!").sendPrefixedMessage(sender);
|
||||
instance.getLocale().newMessage("&cYou are the only one online!").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
|
@ -1,90 +0,0 @@
|
||||
package com.songoda.ultimatemoderation.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.listeners.DeathListener;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandRevive extends AbstractCommand {
|
||||
|
||||
private UltimateModeration instance;
|
||||
|
||||
public CommandRevive(UltimateModeration instance) {
|
||||
super(CommandType.CONSOLE_OK, "Revive");
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length != 1)
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
|
||||
Player player = Bukkit.getPlayer(args[0]);
|
||||
|
||||
if (player == null) {
|
||||
instance.getLocale().newMessage("That player does not exist or is not online.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
if (!(revive(player, sender))) return ReturnType.FAILURE;
|
||||
|
||||
instance.getLocale().getMessage("command.revive.revived").sendPrefixedMessage(player);
|
||||
instance.getLocale().getMessage("command.revive.success")
|
||||
.processPlaceholder("player", player.getName()).sendPrefixedMessage(sender);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender sender, String... args) {
|
||||
if (args.length == 1) {
|
||||
List<String> players = new ArrayList<>();
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
players.add(player.getName());
|
||||
}
|
||||
return players;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean revive(Player player, CommandSender sender) {
|
||||
UltimateModeration instance = UltimateModeration.getInstance();
|
||||
List<ItemStack> drops = DeathListener.getLastDrop(player);
|
||||
|
||||
if (drops == null) {
|
||||
instance.getLocale().getMessage("command.revive.noloot").sendPrefixedMessage(sender);
|
||||
return false;
|
||||
}
|
||||
|
||||
ItemStack[] dropArr = new ItemStack[drops.size()];
|
||||
dropArr = drops.toArray(dropArr);
|
||||
|
||||
HashMap<Integer, ItemStack> leftOver = player.getInventory().addItem(dropArr);
|
||||
|
||||
for (ItemStack item : leftOver.values()) {
|
||||
player.getWorld().dropItemNaturally(player.getLocation(), item);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "um.revive";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/Revive <player>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Allows you to revive a player.";
|
||||
}
|
||||
}
|
@ -62,7 +62,7 @@ public class CommandRunTemplate extends AbstractCommand {
|
||||
} else if (args.length == 2) {
|
||||
List<String> lines = new ArrayList<>();
|
||||
for (Template template : instance.getTemplateManager().getTemplates().values()) {
|
||||
lines.add(template.getTemplateName());
|
||||
lines.add(template.getName());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -2,7 +2,7 @@ package com.songoda.ultimatemoderation.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.gui.GUITicketManager;
|
||||
import com.songoda.ultimatemoderation.gui.TicketManagerGui;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -21,7 +21,7 @@ public class CommandTicket extends AbstractCommand {
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
Player senderP = ((Player) sender);
|
||||
|
||||
new GUITicketManager(instance, senderP, senderP);
|
||||
new TicketManagerGui(instance, senderP, senderP);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@ package com.songoda.ultimatemoderation.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.gui.GUIPlayers;
|
||||
import com.songoda.ultimatemoderation.gui.MainGui;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -19,7 +19,7 @@ public class CommandUltimateModeration extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
new GUIPlayers(instance, (Player) sender);
|
||||
instance.getGuiManager().showGUI((Player) sender, new MainGui(instance, (Player) sender));
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@ -40,6 +40,6 @@ public class CommandUltimateModeration extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Displays this page.";
|
||||
return "Displays the moderation panel.";
|
||||
}
|
||||
}
|
||||
|
@ -72,6 +72,6 @@ public class CommandUnBan extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Allows you to ban players.";
|
||||
return "Allows you to unban players.";
|
||||
}
|
||||
}
|
||||
|
@ -1,69 +0,0 @@
|
||||
package com.songoda.ultimatemoderation.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandViewEnderChest extends AbstractCommand {
|
||||
|
||||
private UltimateModeration instance;
|
||||
|
||||
public CommandViewEnderChest(UltimateModeration instance) {
|
||||
super(CommandType.PLAYER_ONLY, "ViewEnderChest");
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
|
||||
if (args.length != 1)
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
|
||||
Player player = Bukkit.getPlayer(args[0]);
|
||||
|
||||
if (player == null) {
|
||||
instance.getLocale().newMessage("That player does not exist or is not online.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
if (player.hasPermission("um.viewenderchest.exempt")) {
|
||||
instance.getLocale().newMessage("You cannot view the enderchest of that player.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
((Player) sender).openInventory(player.getEnderChest());
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender sender, String... args) {
|
||||
if (args.length == 1) {
|
||||
List<String> players = new ArrayList<>();
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
players.add(player.getName());
|
||||
}
|
||||
return players;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "um.viewenderchest";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/ViewEnderChest <player>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Allows you to see inside of a players enderchest.";
|
||||
}
|
||||
}
|
@ -49,12 +49,12 @@ public class CommandWarn extends AbstractCommand {
|
||||
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(args[0]);
|
||||
|
||||
if (player == null) {
|
||||
if (!player.hasPlayedBefore()) {
|
||||
instance.getLocale().newMessage("That player does not exist.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
if (sender instanceof Player && VaultPermissions.hasPermission(Bukkit.getWorlds().get(0).getName(), player, "um.warning.exempt")) {
|
||||
if (sender instanceof Player && VaultPermissions.hasPermission(player, "um.warning.exempt")) {
|
||||
instance.getLocale().newMessage("You cannot warn that player.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
@ -0,0 +1,321 @@
|
||||
package com.songoda.ultimatemoderation.database;
|
||||
|
||||
import com.songoda.core.database.DataManagerAbstract;
|
||||
import com.songoda.core.database.DatabaseConnector;
|
||||
import com.songoda.ultimatemoderation.punish.AppliedPunishment;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentNote;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentType;
|
||||
import com.songoda.ultimatemoderation.punish.template.Template;
|
||||
import com.songoda.ultimatemoderation.tickets.Ticket;
|
||||
import com.songoda.ultimatemoderation.tickets.TicketResponse;
|
||||
import com.songoda.ultimatemoderation.tickets.TicketStatus;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class DataManager extends DataManagerAbstract {
|
||||
|
||||
public DataManager(DatabaseConnector databaseConnector, Plugin plugin) {
|
||||
super(databaseConnector, plugin);
|
||||
}
|
||||
|
||||
public void createTemplate(Template template) {
|
||||
this.queueAsync(() -> this.databaseConnector.connect(connection -> {
|
||||
String createTemplate = "INSERT INTO " + this.getTablePrefix() + "templates (punishment_type, duration, reason, name, creator) VALUES (?, ?, ?, ?, ?)";
|
||||
try (PreparedStatement statement = connection.prepareStatement(createTemplate)) {
|
||||
statement.setString(1, template.getPunishmentType().name());
|
||||
statement.setLong(2, template.getDuration());
|
||||
statement.setString(3, template.getReason());
|
||||
statement.setString(4, template.getName());
|
||||
statement.setString(5, template.getCreator().toString());
|
||||
statement.executeUpdate();
|
||||
}
|
||||
|
||||
int templateId = this.lastInsertedId(connection, "templates");
|
||||
template.setId(templateId);
|
||||
}), "create");
|
||||
}
|
||||
|
||||
public void deleteTemplate(Template template) {
|
||||
this.async(() -> this.databaseConnector.connect(connection -> {
|
||||
String deleteTemplate = "DELETE FROM " + this.getTablePrefix() + "templates WHERE id = ?";
|
||||
try (PreparedStatement statement = connection.prepareStatement(deleteTemplate)) {
|
||||
statement.setLong(1, template.getId());
|
||||
statement.executeUpdate();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
public void getTemplates(Consumer<List<Template>> callback) {
|
||||
List<Template> templates = new ArrayList<>();
|
||||
this.async(() -> this.databaseConnector.connect(connection -> {
|
||||
try (Statement statement = connection.createStatement()) {
|
||||
String selectTemplates = "SELECT * FROM " + this.getTablePrefix() + "templates";
|
||||
ResultSet result = statement.executeQuery(selectTemplates);
|
||||
while (result.next()) {
|
||||
int id = result.getInt("id");
|
||||
PunishmentType punishmentType = PunishmentType.valueOf(result.getString("punishment_type"));
|
||||
long duration = result.getLong("duration");
|
||||
String reason = result.getString("reason");
|
||||
String name = result.getString("name");
|
||||
UUID creator = UUID.fromString(result.getString("creator"));
|
||||
Template template = new Template(punishmentType, duration, reason, creator, name);
|
||||
template.setId(id);
|
||||
templates.add(template);
|
||||
}
|
||||
}
|
||||
|
||||
this.sync(() -> callback.accept(templates));
|
||||
}));
|
||||
}
|
||||
|
||||
public void createAppliedPunishment(AppliedPunishment punishment) {
|
||||
this.queueAsync(() -> this.databaseConnector.connect(connection -> {
|
||||
String createPunishment = "INSERT INTO " + this.getTablePrefix() + "punishments (type, duration, reason, victim, punisher, expiration) VALUES (?, ?, ?, ?, ?, ?)";
|
||||
try (PreparedStatement statement = connection.prepareStatement(createPunishment)) {
|
||||
statement.setString(1, punishment.getPunishmentType().name());
|
||||
statement.setLong(2, punishment.getDuration());
|
||||
statement.setString(3, punishment.getReason());
|
||||
statement.setString(4, punishment.getVictim().toString());
|
||||
statement.setString(5, punishment.getPunisher().toString());
|
||||
statement.setLong(6, punishment.getExpiration());
|
||||
statement.executeUpdate();
|
||||
}
|
||||
|
||||
int punishmentId = this.lastInsertedId(connection, "punishments");
|
||||
punishment.setId(punishmentId);
|
||||
}), "create");
|
||||
}
|
||||
|
||||
public void deleteAppliedPunishment(AppliedPunishment punishment) {
|
||||
this.async(() -> this.databaseConnector.connect(connection -> {
|
||||
String deletePunishment = "DELETE FROM " + this.getTablePrefix() + "punishments WHERE id = ?";
|
||||
try (PreparedStatement statement = connection.prepareStatement(deletePunishment)) {
|
||||
statement.setLong(1, punishment.getId());
|
||||
statement.executeUpdate();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
public void updateAppliedPunishment(AppliedPunishment punishment) {
|
||||
this.async(() -> this.databaseConnector.connect(connection -> {
|
||||
String updatePunishment = "UPDATE " + this.getTablePrefix() + "punishments set type = ?, duration = ?, reason = ?, victim = ?, punisher = ?, expiration = ? WHERE id = ?";
|
||||
try (PreparedStatement statement = connection.prepareStatement(updatePunishment)) {
|
||||
statement.setString(1, punishment.getPunishmentType().name());
|
||||
statement.setLong(2, punishment.getDuration());
|
||||
statement.setString(3, punishment.getReason());
|
||||
statement.setString(4, punishment.getVictim().toString());
|
||||
statement.setString(5, punishment.getPunisher().toString());
|
||||
statement.setLong(6, punishment.getExpiration());
|
||||
statement.setLong(7, punishment.getId());
|
||||
statement.executeUpdate();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
public void getAppliedPunishments(Consumer<List<AppliedPunishment>> callback) {
|
||||
List<AppliedPunishment> appliedPunishments = new ArrayList<>();
|
||||
this.async(() -> this.databaseConnector.connect(connection -> {
|
||||
try (Statement statement = connection.createStatement()) {
|
||||
String selectPunishments = "SELECT * FROM " + this.getTablePrefix() + "punishments";
|
||||
ResultSet result = statement.executeQuery(selectPunishments);
|
||||
while (result.next()) {
|
||||
int id = result.getInt("id");
|
||||
PunishmentType punishmentType = PunishmentType.valueOf(result.getString("type"));
|
||||
long duration = result.getLong("duration");
|
||||
String reason = result.getString("reason");
|
||||
UUID victim = UUID.fromString(result.getString("victim"));
|
||||
UUID punisher = UUID.fromString(result.getString("punisher"));
|
||||
long expiration = result.getLong("expiration");
|
||||
appliedPunishments.add(new AppliedPunishment(punishmentType, duration, reason, victim, punisher, expiration, id));
|
||||
}
|
||||
}
|
||||
|
||||
this.sync(() -> callback.accept(appliedPunishments));
|
||||
}));
|
||||
}
|
||||
|
||||
public void createNote(PunishmentNote note) {
|
||||
this.queueAsync(() -> this.databaseConnector.connect(connection -> {
|
||||
String createNote = "INSERT INTO " + this.getTablePrefix() + "notes (note, author, subject, creation) VALUES (?, ?, ?, ?)";
|
||||
try (PreparedStatement statement = connection.prepareStatement(createNote)) {
|
||||
statement.setString(1, note.getNote());
|
||||
statement.setString(2, note.getAuthor().toString());
|
||||
statement.setString(3, note.getSubject().toString());
|
||||
statement.setLong(4, note.getCreationDate());
|
||||
statement.executeUpdate();
|
||||
}
|
||||
|
||||
int noteId = this.lastInsertedId(connection, "notes");
|
||||
note.setId(noteId);
|
||||
}), "create");
|
||||
}
|
||||
|
||||
public void deleteNote(PunishmentNote note) {
|
||||
this.async(() -> this.databaseConnector.connect(connection -> {
|
||||
String deleteNote = "DELETE FROM " + this.getTablePrefix() + "notes WHERE id = ?";
|
||||
try (PreparedStatement statement = connection.prepareStatement(deleteNote)) {
|
||||
statement.setLong(1, note.getId());
|
||||
statement.executeUpdate();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
public void getNotes(Consumer<List<PunishmentNote>> callback) {
|
||||
List<PunishmentNote> notes = new ArrayList<>();
|
||||
this.async(() -> this.databaseConnector.connect(connection -> {
|
||||
try (Statement statement = connection.createStatement()) {
|
||||
String getNotes = "SELECT * FROM " + this.getTablePrefix() + "notes";
|
||||
ResultSet result = statement.executeQuery(getNotes);
|
||||
while (result.next()) {
|
||||
int id = result.getInt("id");
|
||||
String note = result.getString("note");
|
||||
UUID author = UUID.fromString(result.getString("author"));
|
||||
UUID subject = UUID.fromString(result.getString("subject"));
|
||||
long creation = result.getLong("creation");
|
||||
notes.add(new PunishmentNote(id, note, author, subject, creation));
|
||||
}
|
||||
}
|
||||
|
||||
this.sync(() -> callback.accept(notes));
|
||||
}));
|
||||
}
|
||||
|
||||
public void createTicket(Ticket ticket) {
|
||||
this.queueAsync(() -> this.databaseConnector.connect(connection -> {
|
||||
String createTicket = "INSERT INTO " + this.getTablePrefix() + "tickets (victim, subject, type, status, world, x, y, z, pitch, yaw) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
try (PreparedStatement statement = connection.prepareStatement(createTicket)) {
|
||||
statement.setString(1, ticket.getVictim().toString());
|
||||
statement.setString(2, ticket.getSubject());
|
||||
statement.setString(3, ticket.getType());
|
||||
statement.setString(4, ticket.getStatus().name());
|
||||
|
||||
Location location = ticket.getLocation();
|
||||
|
||||
statement.setString(5, location.getWorld().getName());
|
||||
statement.setDouble(6, location.getX());
|
||||
statement.setDouble(7, location.getY());
|
||||
statement.setDouble(8, location.getZ());
|
||||
statement.setFloat(9, location.getPitch());
|
||||
statement.setFloat(10, location.getYaw());
|
||||
statement.executeUpdate();
|
||||
}
|
||||
|
||||
for (TicketResponse response : ticket.getResponses())
|
||||
createTicketResponse(response);
|
||||
|
||||
int ticketId = this.lastInsertedId(connection, "tickets");
|
||||
ticket.setId(ticketId);
|
||||
}), "create");
|
||||
}
|
||||
|
||||
public void deleteTicket(Ticket ticket) {
|
||||
this.async(() -> this.databaseConnector.connect(connection -> {
|
||||
String deleteTicket = "DELETE FROM " + this.getTablePrefix() + "tickets WHERE id = ?";
|
||||
try (PreparedStatement statement = connection.prepareStatement(deleteTicket)) {
|
||||
statement.setLong(1, ticket.getId());
|
||||
statement.executeUpdate();
|
||||
}
|
||||
|
||||
String deleteTicketResponses = "DELETE FROM " + this.getTablePrefix() + "ticket_responses WHERE ticket_id = ?";
|
||||
try (PreparedStatement statement = connection.prepareStatement(deleteTicketResponses)) {
|
||||
statement.setLong(1, ticket.getId());
|
||||
statement.executeUpdate();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
public void updateTicket(Ticket ticket) {
|
||||
this.async(() -> this.databaseConnector.connect(connection -> {
|
||||
String updateTicket = "UPDATE " + this.getTablePrefix() + "tickets SET victim = ?, subject = ?, type = ?, status = ?, world = ?, x = ?, y = ?, z = ?, pitch = ?, yaw = ? WHERE id = ?";
|
||||
try (PreparedStatement statement = connection.prepareStatement(updateTicket)) {
|
||||
statement.setString(1, ticket.getVictim().toString());
|
||||
statement.setString(2, ticket.getSubject());
|
||||
statement.setString(3, ticket.getType());
|
||||
statement.setString(4, ticket.getStatus().name());
|
||||
|
||||
Location location = ticket.getLocation();
|
||||
|
||||
statement.setString(5, location.getWorld().getName());
|
||||
statement.setDouble(6, location.getX());
|
||||
statement.setDouble(7, location.getY());
|
||||
statement.setDouble(8, location.getZ());
|
||||
statement.setFloat(9, location.getPitch());
|
||||
statement.setFloat(10, location.getYaw());
|
||||
statement.setInt(11, ticket.getId());
|
||||
statement.executeUpdate();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
public void getTickets(Consumer<Map<Integer, Ticket>> callback) {
|
||||
Map<Integer, Ticket> tickets = new TreeMap<>();
|
||||
this.async(() -> this.databaseConnector.connect(connection -> {
|
||||
try (Statement statement = connection.createStatement()) {
|
||||
String selectTickets = "SELECT * FROM " + this.getTablePrefix() + "tickets";
|
||||
ResultSet result = statement.executeQuery(selectTickets);
|
||||
while (result.next()) {
|
||||
int id = result.getInt("id");
|
||||
UUID victim = UUID.fromString(result.getString("victim"));
|
||||
String subject = result.getString("subject");
|
||||
String type = result.getString("type");
|
||||
TicketStatus status = TicketStatus.valueOf(result.getString("status"));
|
||||
|
||||
String world = result.getString("world");
|
||||
double x = result.getDouble("x");
|
||||
double y = result.getDouble("y");
|
||||
double z = result.getDouble("z");
|
||||
float pitch = result.getFloat("pitch");
|
||||
float yaw = result.getFloat("yaw");
|
||||
|
||||
Location location = Bukkit.getWorld(world) == null ? null : new Location(Bukkit.getWorld(world), x, y, z, yaw, pitch);
|
||||
|
||||
Ticket ticket = new Ticket(id, victim, subject, type, status, location);
|
||||
ticket.setId(id)
|
||||
;
|
||||
tickets.put(id, ticket);
|
||||
}
|
||||
}
|
||||
|
||||
try (Statement statement = connection.createStatement()) {
|
||||
String selectTickets = "SELECT * FROM " + this.getTablePrefix() + "ticket_responses";
|
||||
ResultSet result = statement.executeQuery(selectTickets);
|
||||
while (result.next()) {
|
||||
int id = result.getInt("ticket_id");
|
||||
|
||||
Ticket ticket = tickets.get(id);
|
||||
if (ticket == null) continue;
|
||||
|
||||
UUID author = UUID.fromString(result.getString("author"));
|
||||
String message = result.getString("message");
|
||||
long postedDate = result.getLong("posted_date");
|
||||
|
||||
TicketResponse ticketResponse = new TicketResponse(author, message, postedDate);
|
||||
ticketResponse.setTicketId(id);
|
||||
|
||||
ticket.addResponse(ticketResponse);
|
||||
}
|
||||
}
|
||||
|
||||
this.sync(() -> callback.accept(tickets));
|
||||
}));
|
||||
}
|
||||
|
||||
public void createTicketResponse(TicketResponse ticketResponse) {
|
||||
this.queueAsync(() -> this.databaseConnector.connect(connection -> {
|
||||
String createTicketResponse = "INSERT INTO " + this.getTablePrefix() + "ticket_responses (ticket_id, author, message, posted_date) VALUES (?, ?, ?, ?)";
|
||||
try (PreparedStatement statement = connection.prepareStatement(createTicketResponse)) {
|
||||
statement.setInt(1, ticketResponse.getTicketId());
|
||||
statement.setString(2, ticketResponse.getAuthor().toString());
|
||||
statement.setString(3, ticketResponse.getMessage());
|
||||
statement.setLong(4, ticketResponse.getPostedDate());
|
||||
statement.executeUpdate();
|
||||
}
|
||||
}), "create");
|
||||
}
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
package com.songoda.ultimatemoderation.database.migrations;
|
||||
|
||||
import com.songoda.core.database.DataMigration;
|
||||
import com.songoda.core.database.MySQLConnector;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
|
||||
public class _1_InitialMigration extends DataMigration {
|
||||
|
||||
public _1_InitialMigration() {
|
||||
super(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void migrate(Connection connection, String tablePrefix) throws SQLException {
|
||||
String autoIncrement = UltimateModeration.getInstance().getDatabaseConnector() instanceof MySQLConnector ? " AUTO_INCREMENT" : "";
|
||||
|
||||
// Create templates table
|
||||
try (Statement statement = connection.createStatement()) {
|
||||
statement.execute("CREATE TABLE " + tablePrefix + "templates (" +
|
||||
"id INTEGER PRIMARY KEY" + autoIncrement + ", " +
|
||||
"punishment_type VARCHAR(15) NOT NULL, " +
|
||||
"duration BIGINT NOT NULL," + // If -1 then its permanent
|
||||
"reason TEXT," + // If null then no reason is given
|
||||
"name VARCHAR(100), " +
|
||||
"creator VARCHAR(36) NOT NULL" +
|
||||
")");
|
||||
}
|
||||
|
||||
// Create punishments table
|
||||
try (Statement statement = connection.createStatement()) {
|
||||
statement.execute("CREATE TABLE " + tablePrefix + "punishments (" +
|
||||
"id INTEGER PRIMARY KEY" + autoIncrement + ", " +
|
||||
"type VARCHAR(15) NOT NULL, " +
|
||||
"duration BIGINT," + // If null then its permanent
|
||||
"reason TEXT," + // If null then no reason is given
|
||||
"victim VARCHAR(36) NOT NULL," +
|
||||
"punisher VARCHAR(36) NOT NULL," +
|
||||
"expiration BIGINT" + // If null then its permanent
|
||||
")");
|
||||
}
|
||||
|
||||
// Create notes table
|
||||
try (Statement statement = connection.createStatement()) {
|
||||
statement.execute("CREATE TABLE " + tablePrefix + "notes (" +
|
||||
"id INTEGER PRIMARY KEY" + autoIncrement + ", " +
|
||||
"note TEXT NOT NULL, " +
|
||||
"author VARCHAR(36) NOT NULL," +
|
||||
"subject VARCHAR (36) NOT NULL," +
|
||||
"creation BIGINT" +
|
||||
")");
|
||||
}
|
||||
|
||||
// Create tickets table
|
||||
try (Statement statement = connection.createStatement()) {
|
||||
statement.execute("CREATE TABLE " + tablePrefix + "tickets (" +
|
||||
"id INTEGER PRIMARY KEY" + autoIncrement + ", " +
|
||||
"victim VARCHAR(36) NOT NULL," +
|
||||
"subject TEXT NOT NULL," +
|
||||
"type VARCHAR(50) NOT NULL, " +
|
||||
"status VARCHAR(10) NOT NULL, " +
|
||||
"world TEXT NOT NULL, " +
|
||||
"x DOUBLE NOT NULL, " +
|
||||
"y DOUBLE NOT NULL, " +
|
||||
"z DOUBLE NOT NULL, " +
|
||||
"pitch FLOAT NOT NULL, " +
|
||||
"yaw FLOAT NOT NULL " +
|
||||
")");
|
||||
}
|
||||
|
||||
// Create ticket responses table
|
||||
try (Statement statement = connection.createStatement()) {
|
||||
statement.execute("CREATE TABLE " + tablePrefix + "ticket_responses (" +
|
||||
"ticket_id INTEGER NOT NULL, " +
|
||||
"author VARCHAR(36) NOT NULL," +
|
||||
"message TEXT NOT NULL," +
|
||||
"posted_date BIGINT" +
|
||||
")");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,86 +0,0 @@
|
||||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.commands.CommandFreeze;
|
||||
import com.songoda.ultimatemoderation.commands.CommandRevive;
|
||||
import com.songoda.ultimatemoderation.commands.CommandSpy;
|
||||
import com.songoda.ultimatemoderation.utils.gui.AbstractGUI;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class GUIModerate extends AbstractGUI {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
private final OfflinePlayer toModerate;
|
||||
private boolean freeze, spy, invsee, enderview, revive;
|
||||
|
||||
public GUIModerate(UltimateModeration plugin, OfflinePlayer toModerate, Player player) {
|
||||
super(player);
|
||||
this.plugin = plugin;
|
||||
this.toModerate = toModerate;
|
||||
this.freeze = !toModerate.getPlayer().hasPermission("um.freeze.exempt") && player.hasPermission("um.freeze");
|
||||
this.spy = !toModerate.getPlayer().hasPermission("um.spy.exempt") && player.hasPermission("um.spy");
|
||||
this.invsee = !toModerate.getPlayer().hasPermission("um.invsee.exempt") && player.hasPermission("um.invsee");
|
||||
this.enderview = !toModerate.getPlayer().hasPermission("um.viewenderchest.exempt") && player.hasPermission("um.viewenderchest");
|
||||
this.revive = player.hasPermission("um.revive");
|
||||
|
||||
init(plugin.getLocale().getMessage("gui.moderate.title")
|
||||
.processPlaceholder("toModerate", toModerate.getName()).getMessage(), 45);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void constructGUI() {
|
||||
|
||||
createButton(8, CompatibleMaterial.OAK_DOOR.getMaterial(), plugin.getLocale().getMessage("gui.general.back").getMessage());
|
||||
|
||||
if (freeze)
|
||||
createButton(10, ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.BLUE_ICE : Material.valueOf("PACKED_ICE"), "&6&lFreeze", "&7Stop this player from moving.", "", "&7Currently:&6 " + (CommandFreeze.isFrozen(toModerate) ? "Frozen" : "Unfrozen"));
|
||||
if (spy) createButton(12, Material.SADDLE, "&6&lSpy", "&7Spy on this player");
|
||||
if (invsee) createButton(14, Material.CHEST, "&c&lInventory", "&7Access this players Inventory.");
|
||||
if (enderview) createButton(16, Material.ENDER_CHEST, "&a&lEnderchest", "&7Access this players Enderchest");
|
||||
if (revive)
|
||||
createButton(28, ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.SPLASH_POTION : Material.valueOf("POTION"), "&c&lRevive", "&7Revive this player.");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerClickables() {
|
||||
registerClickable(8, ((player1, inventory1, cursor, slot, type) ->
|
||||
new GUIPlayer(plugin, toModerate, player1)));
|
||||
|
||||
if (freeze) {
|
||||
registerClickable(10, ((player1, inventory1, cursor, slot, type) -> {
|
||||
CommandFreeze.freeze(toModerate, player);
|
||||
constructGUI();
|
||||
}));
|
||||
}
|
||||
|
||||
if (spy) {
|
||||
registerClickable(12, ((player1, inventory1, cursor, slot, type) -> {
|
||||
CommandSpy.spy(toModerate, player);
|
||||
player.closeInventory();
|
||||
}));
|
||||
}
|
||||
|
||||
if (invsee) {
|
||||
registerClickable(14, ((player1, inventory1, cursor, slot, type) ->
|
||||
player.openInventory(toModerate.getPlayer().getInventory())));
|
||||
}
|
||||
|
||||
if (enderview) {
|
||||
registerClickable(16, ((player1, inventory1, cursor, slot, type) ->
|
||||
player.openInventory(toModerate.getPlayer().getEnderChest())));
|
||||
}
|
||||
|
||||
if (revive) {
|
||||
registerClickable(28, ((player1, inventory1, cursor, slot, type) ->
|
||||
CommandRevive.revive(toModerate.getPlayer(), player)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerOnCloses() {
|
||||
}
|
||||
}
|
@ -1,148 +0,0 @@
|
||||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentNote;
|
||||
import com.songoda.ultimatemoderation.utils.AbstractChatConfirm;
|
||||
import com.songoda.ultimatemoderation.utils.gui.AbstractGUI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class GUINotesManager extends AbstractGUI {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
private final OfflinePlayer toModerate;
|
||||
|
||||
private int page = 0;
|
||||
|
||||
private boolean create, delete;
|
||||
|
||||
public GUINotesManager(UltimateModeration plugin, OfflinePlayer toModerate, Player player) {
|
||||
super(player);
|
||||
this.plugin = plugin;
|
||||
this.toModerate = toModerate;
|
||||
this.create = player.hasPermission("um.notes.create");
|
||||
this.delete = player.hasPermission("um.notes.delete");
|
||||
|
||||
init(plugin.getLocale().getMessage("gui.notes.title")
|
||||
.processPlaceholder("tonotes", player.getName()).getMessage(), 54);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void constructGUI() {
|
||||
inventory.clear();
|
||||
resetClickables();
|
||||
registerClickables();
|
||||
|
||||
for (int i = 0; i < 9; i++)
|
||||
createButton(9 + i, ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.GRAY_STAINED_GLASS_PANE : new ItemStack(Material.valueOf("STAINED_GLASS_PANE")), "&1");
|
||||
|
||||
int numNotes = plugin.getPunishmentManager().getPlayer(toModerate).getNotes().size();
|
||||
int maxPage = (int) Math.floor(numNotes / 36.0);
|
||||
|
||||
List<PunishmentNote> notes = plugin.getPunishmentManager().getPlayer(toModerate).getNotes().stream()
|
||||
.skip(page * 36).limit(36).collect(Collectors.toList());
|
||||
|
||||
if (page != 0) {
|
||||
createButton(1, Material.ARROW, plugin.getLocale().getMessage("gui.general.previous").getMessage());
|
||||
registerClickable(1, ((player1, inventory1, cursor, slot, type) -> {
|
||||
page--;
|
||||
constructGUI();
|
||||
}));
|
||||
}
|
||||
|
||||
if (page != maxPage) {
|
||||
createButton(3, Material.ARROW, plugin.getLocale().getMessage("gui.general.next").getMessage());
|
||||
registerClickable(3, ((player1, inventory1, cursor, slot, type) -> {
|
||||
page++;
|
||||
constructGUI();
|
||||
}));
|
||||
}
|
||||
|
||||
createButton(8, ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)
|
||||
? Material.OAK_DOOR
|
||||
: Material.valueOf("WOOD_DOOR"), plugin.getLocale().getMessage("gui.general.back").getMessage());
|
||||
|
||||
if (create) createButton(6, Material.REDSTONE, plugin.getLocale().getMessage("gui.notes.create").getMessage());
|
||||
|
||||
for (int i = 0; i < notes.size(); i++) {
|
||||
PunishmentNote note = notes.get(i);
|
||||
|
||||
String noteStr = note.getNote();
|
||||
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
int lastIndex = 0;
|
||||
for (int n = 0; n < noteStr.length(); n++) {
|
||||
if (n - lastIndex < 20)
|
||||
continue;
|
||||
|
||||
if (noteStr.charAt(n) == ' ') {
|
||||
lore.add("&6" + noteStr.substring(lastIndex, n).trim());
|
||||
lastIndex = n;
|
||||
}
|
||||
}
|
||||
|
||||
if (lastIndex - noteStr.length() < 20)
|
||||
lore.add("&6" + noteStr.substring(lastIndex, noteStr.length()).trim());
|
||||
|
||||
String name = lore.get(0);
|
||||
lore.remove(0);
|
||||
|
||||
lore.add("");
|
||||
|
||||
SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy");
|
||||
|
||||
lore.add(plugin.getLocale().getMessage("gui.notes.createdby")
|
||||
.processPlaceholder("player", Bukkit.getOfflinePlayer(note.getAuthor()).getName())
|
||||
.getMessage());
|
||||
lore.add(plugin.getLocale().getMessage("gui.notes.createdon")
|
||||
.processPlaceholder("sent", format.format(new Date(note.getCreationDate())))
|
||||
.getMessage());
|
||||
if (delete) lore.add(plugin.getLocale().getMessage("gui.notes.remove").getMessage());
|
||||
|
||||
createButton(18 + i, Material.MAP, name, lore);
|
||||
|
||||
if (delete) {
|
||||
registerClickable(18 + i, ((player1, inventory1, cursor, slot, type) -> {
|
||||
plugin.getPunishmentManager().getPlayer(toModerate).removeNote(note);
|
||||
constructGUI();
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerClickables() {
|
||||
registerClickable(8, ((player1, inventory1, cursor, slot, type) ->
|
||||
new GUIPlayer(plugin, toModerate, player1)));
|
||||
|
||||
if (create) {
|
||||
registerClickable(6, ((player1, inventory1, cursor, slot, type) -> {
|
||||
plugin.getLocale().getMessage("gui.notes.type").sendMessage(player);
|
||||
AbstractChatConfirm abstractChatConfirm = new AbstractChatConfirm(player, event -> {
|
||||
plugin.getPunishmentManager().getPlayer(toModerate).addNotes(new PunishmentNote(event.getMessage(),
|
||||
player.getUniqueId(), toModerate.getUniqueId(), System.currentTimeMillis()));
|
||||
constructGUI();
|
||||
});
|
||||
|
||||
abstractChatConfirm.setOnClose(() ->
|
||||
init(setTitle, inventory.getSize()));
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerOnCloses() {
|
||||
}
|
||||
}
|
@ -1,94 +0,0 @@
|
||||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.utils.gui.AbstractGUI;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
public class GUIPlayer extends AbstractGUI {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
private final OfflinePlayer toModerate;
|
||||
|
||||
private boolean punish, tickets, punishments, notes, moderate;
|
||||
|
||||
public GUIPlayer(UltimateModeration plugin, OfflinePlayer toModerate, Player player) {
|
||||
super(player);
|
||||
this.plugin = plugin;
|
||||
this.toModerate = toModerate;
|
||||
this.punish = player.hasPermission("um.punish");
|
||||
this.tickets = player.hasPermission("um.tickets");
|
||||
this.punishments = player.hasPermission("um.punishments");
|
||||
this.notes = player.hasPermission("um.notes");
|
||||
this.moderate = player.hasPermission("um.moderation");
|
||||
|
||||
init(plugin.getLocale().getMessage("gui.player.title")
|
||||
.processPlaceholder("toModerate", toModerate.getName()).getMessage(), 54);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void constructGUI() {
|
||||
ItemStack head = new ItemStack(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.PLAYER_HEAD : Material.valueOf("SKULL_ITEM"), 1, (byte) 3);
|
||||
SkullMeta meta = ((SkullMeta) head.getItemMeta());
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13))
|
||||
meta.setOwningPlayer(toModerate);
|
||||
else
|
||||
meta.setOwner(toModerate.getName());
|
||||
head.setItemMeta(meta);
|
||||
|
||||
createButton(13, head, "&7&l" + toModerate.getName(),
|
||||
player.isOnline() ? "&a" + plugin.getLocale().getMessage("gui.players.online.online") : "&c" + plugin.getLocale().getMessage("gui.players.online.offline"));
|
||||
|
||||
createButton(8, CompatibleMaterial.OAK_DOOR.getMaterial(), plugin.getLocale().getMessage("gui.general.back").getMessage());
|
||||
|
||||
if (punish) createButton(38, Material.ANVIL, plugin.getLocale().getMessage("gui.player.punish").getMessage());
|
||||
if (tickets) createButton(30, Material.CHEST, plugin.getLocale().getMessage("gui.player.tickets").getMessage());
|
||||
if (player.isOnline() && punishments)
|
||||
createButton(32, Material.DIAMOND_SWORD, plugin.getLocale().getMessage("gui.player.punishments").getMessage());
|
||||
if (notes) createButton(42, Material.MAP, plugin.getLocale().getMessage("gui.player.notes").getMessage());
|
||||
if (moderate)
|
||||
createButton(40, Material.DIAMOND_CHESTPLATE, plugin.getLocale().getMessage("gui.player.moderate").getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerClickables() {
|
||||
registerClickable(8, ((player1, inventory1, cursor, slot, type) ->
|
||||
new GUIPlayers(plugin, player1)));
|
||||
|
||||
if (punish) {
|
||||
registerClickable(38, ((player1, inventory1, cursor, slot, type) ->
|
||||
new GUIPunish(plugin, toModerate, null, player1)));
|
||||
}
|
||||
|
||||
if (tickets) {
|
||||
registerClickable(30, ((player1, inventory1, cursor, slot, type) ->
|
||||
new GUITicketManager(plugin, toModerate, player1)));
|
||||
}
|
||||
|
||||
if (punishments) {
|
||||
registerClickable(32, ((player1, inventory1, cursor, slot, type) ->
|
||||
new GUIPunishments(plugin, toModerate, player1)));
|
||||
}
|
||||
|
||||
if (notes) {
|
||||
registerClickable(42, ((player1, inventory1, cursor, slot, type) ->
|
||||
new GUINotesManager(plugin, toModerate, player1)));
|
||||
}
|
||||
|
||||
if (moderate) {
|
||||
registerClickable(40, ((player1, inventory1, cursor, slot, type) ->
|
||||
new GUIModerate(plugin, toModerate, player1)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerOnCloses() {
|
||||
|
||||
}
|
||||
}
|
@ -1,218 +0,0 @@
|
||||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.core.gui.AnvilGui;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentType;
|
||||
import com.songoda.ultimatemoderation.punish.player.PlayerPunishData;
|
||||
import com.songoda.ultimatemoderation.tickets.TicketStatus;
|
||||
import com.songoda.ultimatemoderation.utils.gui.AbstractGUI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class GUIPlayers extends AbstractGUI {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
private int task;
|
||||
private int page = 0;
|
||||
private Online currentOnline = Online.ONLINE;
|
||||
|
||||
private List<UUID> players = new ArrayList<>();
|
||||
|
||||
public GUIPlayers(UltimateModeration plugin, Player player) {
|
||||
super(player);
|
||||
this.plugin = plugin;
|
||||
|
||||
for (Player p : Bukkit.getOnlinePlayers())
|
||||
players.add(p.getUniqueId());
|
||||
for (UUID uuid : plugin.getPunishmentManager().getPunishments().keySet()) {
|
||||
if (Bukkit.getOfflinePlayer(uuid).isOnline()) continue;
|
||||
players.add(uuid);
|
||||
}
|
||||
|
||||
init(plugin.getLocale().getMessage("gui.players.title").getMessage(), 54);
|
||||
runTask();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void constructGUI() {
|
||||
inventory.clear();
|
||||
resetClickables();
|
||||
registerClickables();
|
||||
|
||||
List<UUID> toUse = players.stream()
|
||||
.filter(u -> currentOnline == Online.BOTH
|
||||
|| currentOnline == Online.ONLINE && Bukkit.getOfflinePlayer(u).isOnline()
|
||||
|| currentOnline == Online.OFFLINE && !Bukkit.getOfflinePlayer(u).isOnline())
|
||||
.skip(page * 36).limit(36).collect(Collectors.toList());
|
||||
|
||||
|
||||
int numNotes = toUse.size();
|
||||
int maxPage = (int) Math.floor(numNotes / 36.0);
|
||||
|
||||
if (page != 0) {
|
||||
createButton(46, Material.ARROW, plugin.getLocale().getMessage("gui.general.previous").getMessage());
|
||||
registerClickable(46, ((player1, inventory1, cursor, slot, type) -> {
|
||||
page--;
|
||||
constructGUI();
|
||||
}));
|
||||
}
|
||||
|
||||
if (maxPage != page) {
|
||||
createButton(48, Material.ARROW, plugin.getLocale().getMessage("gui.general.next").getMessage());
|
||||
registerClickable(48, ((player1, inventory1, cursor, slot, type) -> {
|
||||
page++;
|
||||
constructGUI();
|
||||
}));
|
||||
}
|
||||
|
||||
for (int i = 0; i < toUse.size(); i++) {
|
||||
OfflinePlayer pl = Bukkit.getOfflinePlayer(toUse.get(i));
|
||||
|
||||
PlayerPunishData playerPunishData = plugin.getPunishmentManager().getPlayer(pl);
|
||||
|
||||
ItemStack head = new ItemStack(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.PLAYER_HEAD : Material.valueOf("SKULL_ITEM"), 1, (byte) 3);
|
||||
SkullMeta meta = ((SkullMeta) head.getItemMeta());
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13))
|
||||
meta.setOwningPlayer(pl);
|
||||
else
|
||||
meta.setOwner(pl.getName());
|
||||
head.setItemMeta(meta);
|
||||
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
lore.add(plugin.getLocale().getMessage("gui.players.click").getMessage());
|
||||
lore.add("");
|
||||
|
||||
int ticketAmt = (int) plugin.getTicketManager().getTicketsAbout(pl).stream()
|
||||
.filter(t -> t.getStatus() == TicketStatus.OPEN).count();
|
||||
|
||||
if (ticketAmt == 0)
|
||||
lore.add(plugin.getLocale().getMessage("gui.players.notickets").getMessage());
|
||||
else {
|
||||
if (ticketAmt == 1)
|
||||
lore.add(plugin.getLocale().getMessage("gui.players.ticketsone").getMessage());
|
||||
else
|
||||
lore.add(plugin.getLocale().getMessage("gui.players.tickets")
|
||||
.processPlaceholder("amount", ticketAmt).getMessage());
|
||||
}
|
||||
|
||||
int warningAmt = playerPunishData.getActivePunishments(PunishmentType.WARNING).size();
|
||||
|
||||
if (warningAmt == 0)
|
||||
lore.add(plugin.getLocale().getMessage("gui.players.nowarnings").getMessage());
|
||||
else {
|
||||
if (warningAmt == 1)
|
||||
lore.add(plugin.getLocale().getMessage("gui.players.warningsone").getMessage());
|
||||
else
|
||||
lore.add(plugin.getLocale().getMessage("gui.players.warnings")
|
||||
.processPlaceholder("amount", warningAmt).getMessage());
|
||||
}
|
||||
|
||||
|
||||
createButton(i, head, "&7&l" + pl.getName(), lore);
|
||||
registerClickable(i, (player1, inventory1, cursor, slot, type) -> new GUIPlayer(plugin, pl, player));
|
||||
}
|
||||
|
||||
for (int i = 0; i < 9; i++)
|
||||
createButton(36 + i, ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.GRAY_STAINED_GLASS_PANE : new ItemStack(Material.valueOf("STAINED_GLASS_PANE")), "&1");
|
||||
|
||||
createButton(46, Material.ENDER_PEARL, plugin.getLocale().getMessage("gui.players.search").getMessage());
|
||||
createButton(47, Material.HOPPER, "&6" + currentOnline.getTranslation());
|
||||
|
||||
if (player.hasPermission("um.tickets"))
|
||||
createButton(51, Material.CHEST, plugin.getLocale().getMessage("gui.players.button.tickets").getMessage());
|
||||
|
||||
if (player.hasPermission("um.templates"))
|
||||
createButton(52, Material.MAP, plugin.getLocale().getMessage("gui.players.button.templatemanager").getMessage());
|
||||
}
|
||||
|
||||
|
||||
private enum Online {
|
||||
|
||||
ONLINE, OFFLINE, BOTH;
|
||||
|
||||
private static Online[] vals = values();
|
||||
|
||||
public Online next() {
|
||||
return vals[(this.ordinal() != vals.length - 1 ? this.ordinal() + 1 : 0)];
|
||||
}
|
||||
|
||||
public String getTranslation() {
|
||||
return UltimateModeration.getInstance().getLocale()
|
||||
.getMessage("gui.players.online." + this.name().toLowerCase()).getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
private void runTask() {
|
||||
task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, this::constructGUI, 5L, 5L);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerClickables() {
|
||||
|
||||
registerClickable(46, ((player1, inventory1, cursor, slot, type) -> {
|
||||
AnvilGui gui = new AnvilGui(player1);
|
||||
gui.setAction(event -> {
|
||||
List<UUID> players = new ArrayList<>(plugin.getPunishmentManager().getPunishments().keySet());
|
||||
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (players.contains(player.getUniqueId())) continue;
|
||||
players.add(player.getUniqueId());
|
||||
}
|
||||
|
||||
List<UUID> found = players.stream().filter(uuid -> Bukkit.getOfflinePlayer(uuid).getName().toLowerCase().contains(gui.getInputText().toLowerCase())).collect(Collectors.toList());
|
||||
|
||||
if (found.size() >= 1) {
|
||||
this.players = found;
|
||||
constructGUI();
|
||||
player.openInventory(this.inventory);
|
||||
} else {
|
||||
plugin.getLocale().getMessage("gui.players.nonefound").sendMessage(player);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
ItemStack item = new ItemStack(Material.PAPER);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(plugin.getLocale().getMessage("gui.players.name").getMessage());
|
||||
item.setItemMeta(meta);
|
||||
|
||||
gui.setInput(item);
|
||||
plugin.getGuiManager().showGUI(player, gui);
|
||||
}));
|
||||
|
||||
registerClickable(47, ((player1, inventory1, cursor, slot, type) -> {
|
||||
this.currentOnline = currentOnline.next();
|
||||
this.page = 0;
|
||||
constructGUI();
|
||||
}));
|
||||
|
||||
if (player.hasPermission("um.tickets")) {
|
||||
registerClickable(51, (player1, inventory1, cursor, slot, type) -> {
|
||||
new GUITicketManager(plugin, null, player);
|
||||
});
|
||||
}
|
||||
|
||||
if (player.hasPermission("um.templates")) {
|
||||
registerClickable(52, (player1, inventory1, cursor, slot, type) -> {
|
||||
if (player.hasPermission("um.templates")) new GUITemplateManager(plugin, player);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerOnCloses() {
|
||||
registerOnClose(((player1, inventory1) -> Bukkit.getScheduler().cancelTask(task)));
|
||||
}
|
||||
}
|
@ -1,325 +0,0 @@
|
||||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.punish.Punishment;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentType;
|
||||
import com.songoda.ultimatemoderation.punish.template.Template;
|
||||
import com.songoda.ultimatemoderation.utils.Methods;
|
||||
import com.songoda.ultimatemoderation.utils.gui.AbstractAnvilGUI;
|
||||
import com.songoda.ultimatemoderation.utils.gui.AbstractGUI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class GUIPunish extends AbstractGUI {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
private final OfflinePlayer toModerate;
|
||||
|
||||
private Template template;
|
||||
private boolean justSaved = false;
|
||||
|
||||
private PunishmentType type = PunishmentType.BAN;
|
||||
private long duration = -1;
|
||||
private String reason = null;
|
||||
|
||||
private String templateName = null;
|
||||
|
||||
private int task;
|
||||
|
||||
public GUIPunish(UltimateModeration plugin, OfflinePlayer toModerate, Template template, Player player) {
|
||||
super(player);
|
||||
this.plugin = plugin;
|
||||
this.toModerate = toModerate;
|
||||
if (template != null) {
|
||||
this.template = template;
|
||||
this.type = template.getPunishmentType();
|
||||
this.duration = template.getDuration();
|
||||
this.reason = template.getReason();
|
||||
this.templateName = template.getTemplateName();
|
||||
}
|
||||
|
||||
init(toModerate == null ? plugin.getLocale().getMessage("gui.punish.title.template").getMessage()
|
||||
: plugin.getLocale().getMessage("gui.punish.title")
|
||||
.processPlaceholder("toModerate", toModerate.getName()).getMessage(), 45);
|
||||
if (toModerate != null) runTask();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void constructGUI() {
|
||||
inventory.clear();
|
||||
|
||||
if (toModerate != null) {
|
||||
ItemStack head = new ItemStack(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.PLAYER_HEAD : Material.valueOf("SKULL_ITEM"), 1, (byte) 3);
|
||||
SkullMeta meta = ((SkullMeta) head.getItemMeta());
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13))
|
||||
meta.setOwningPlayer(toModerate);
|
||||
else
|
||||
meta.setOwner(toModerate.getName());
|
||||
head.setItemMeta(meta);
|
||||
|
||||
createButton(13, head, "&7&l" + toModerate.getName());
|
||||
}
|
||||
|
||||
if (player.hasPermission("um." + type.toString().toLowerCase()))
|
||||
createButton(22, Material.EMERALD_BLOCK, plugin.getLocale().getMessage("gui.punish.submit").getMessage());
|
||||
|
||||
createButton(8, ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)
|
||||
? Material.OAK_DOOR
|
||||
: Material.valueOf("WOOD_DOOR"), plugin.getLocale().getMessage("gui.general.back").getMessage());
|
||||
|
||||
createButton(28, Material.ANVIL,
|
||||
plugin.getLocale().getMessage("gui.punish.type.punishment").getMessage(),
|
||||
"&7" + type.getTranslation(),
|
||||
"",
|
||||
plugin.getLocale().getMessage("gui.punish.type.punishment.click").getMessage());
|
||||
|
||||
if (toModerate != null) {
|
||||
createButton(30, Material.MAP,
|
||||
plugin.getLocale().getMessage("gui.punish.type.template").getMessage(),
|
||||
plugin.getLocale().getMessage("gui.punish.type.template.current")
|
||||
.processPlaceholder("template",
|
||||
template == null
|
||||
? plugin.getLocale().getMessage("gui.general.none")
|
||||
: template.getTemplateName()).getMessage(),
|
||||
"",
|
||||
plugin.getLocale().getMessage(plugin.getTemplateManager().getTemplates().size() == 0
|
||||
? "gui.punish.type.template.none"
|
||||
: "gui.punish.type.template.click").getMessage());
|
||||
} else {
|
||||
createButton(30, Material.MAP,
|
||||
plugin.getLocale().getMessage("gui.punish.type.name").getMessage(),
|
||||
plugin.getLocale().getMessage("gui.punish.type.name.current")
|
||||
.processPlaceholder("template",
|
||||
templateName == null
|
||||
? plugin.getLocale().getMessage("gui.punish.type.name.current").getMessage()
|
||||
: templateName).getMessage(),
|
||||
"",
|
||||
plugin.getLocale().getMessage("gui.punish.type.name.current.click").getMessage());
|
||||
}
|
||||
|
||||
if (type != PunishmentType.KICK) {
|
||||
createButton(32, ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)
|
||||
? Material.CLOCK
|
||||
: Material.valueOf("WATCH"),
|
||||
plugin.getLocale().getMessage("gui.punish.type.duration").getMessage(),
|
||||
plugin.getLocale().getMessage("gui.punish.type.duration.leftclick").getMessage(),
|
||||
plugin.getLocale().getMessage("gui.punish.type.duration.rightclick").getMessage(),
|
||||
"",
|
||||
plugin.getLocale().getMessage("gui.punish.type.duration.current").getMessage(),
|
||||
"&6" + (duration == -1 ? plugin.getLocale().getMessage("gui.general.permanent").getMessage()
|
||||
: Methods.makeReadable(duration)));
|
||||
}
|
||||
|
||||
createButton(34, Material.PAPER,
|
||||
plugin.getLocale().getMessage("gui.punish.type.reason").getMessage(),
|
||||
plugin.getLocale().getMessage("gui.punish.type.reason.click").getMessage(),
|
||||
"",
|
||||
plugin.getLocale().getMessage("gui.punish.type.reason.current").getMessage(),
|
||||
"&6" + reason);
|
||||
}
|
||||
|
||||
private void notifyTemplate() {
|
||||
if (reason == null || duration == 0 || (justSaved && template != null)) {
|
||||
inventory.setItem(4, null);
|
||||
return;
|
||||
}
|
||||
|
||||
Material material = ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.WHITE_WOOL : Material.valueOf("WOOL");
|
||||
String name = plugin.getLocale().getMessage("gui.punish.template.create").getMessage();
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
lore.add(plugin.getLocale().getMessage("gui.punish.template.create2").getMessage());
|
||||
|
||||
if (!justSaved && template != null) {
|
||||
name = plugin.getLocale().getMessage("gui.punish.template.leftclick").getMessage();
|
||||
lore.clear();
|
||||
lore.add(plugin.getLocale().getMessage("gui.punish.template.leftclick2")
|
||||
.processPlaceholder("template", template.getTemplateName()).getMessage());
|
||||
lore.add("");
|
||||
lore.add(plugin.getLocale().getMessage("gui.punish.template.rightclick").getMessage());
|
||||
}
|
||||
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13) && inventory.getItem(4) != null && inventory.getItem(4).getType() == Material.WHITE_WOOL)
|
||||
material = Material.YELLOW_WOOL;
|
||||
|
||||
createButton(4, material, name, lore);
|
||||
}
|
||||
|
||||
public void runTask() {
|
||||
task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, this::notifyTemplate, 10L, 10L);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerClickables() {
|
||||
registerClickable(8, ((player1, inventory1, cursor, slot, type) -> {
|
||||
if (toModerate != null)
|
||||
new GUIPlayer(plugin, toModerate, player);
|
||||
else
|
||||
new GUITemplateManager(plugin, player);
|
||||
}));
|
||||
|
||||
registerClickable(28, ((player1, inventory1, cursor, slot, type) -> {
|
||||
this.type = this.type.next();
|
||||
justSaved = false;
|
||||
constructGUI();
|
||||
}));
|
||||
|
||||
registerClickable(4, ((player1, inventory1, cursor, slot, type) -> {
|
||||
if (reason == null || duration == 0) return;
|
||||
|
||||
if (template != null && type == ClickType.LEFT) {
|
||||
updateTemplate();
|
||||
return;
|
||||
}
|
||||
nameTemplate();
|
||||
}));
|
||||
|
||||
registerClickable(30, ((player1, inventory1, cursor, slot, type) -> {
|
||||
if (toModerate == null) {
|
||||
nameTemplate();
|
||||
return;
|
||||
}
|
||||
if (plugin.getTemplateManager().getTemplates().size() == 0) return;
|
||||
|
||||
if (player.hasPermission("um.templates.use")) new GUITemplateSelector(plugin, this, player);
|
||||
}));
|
||||
|
||||
registerClickable(32, ((player1, inventory1, cursor, slot, type) -> {
|
||||
if (this.type == PunishmentType.KICK) return;
|
||||
if (type == ClickType.LEFT) {
|
||||
AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event -> {
|
||||
this.duration = Methods.parseTime(event.getName());
|
||||
justSaved = false;
|
||||
});
|
||||
|
||||
gui.setOnClose((player2, inventory3) -> init(setTitle, inventory.getSize()));
|
||||
|
||||
ItemStack item = new ItemStack(Material.PAPER);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
|
||||
meta.setDisplayName(duration == -1 || duration == 0 ? "1d 1h 1m" : Methods.makeReadable(duration));
|
||||
item.setItemMeta(meta);
|
||||
|
||||
gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, item);
|
||||
gui.open();
|
||||
} else {
|
||||
duration = -1;
|
||||
constructGUI();
|
||||
}
|
||||
}));
|
||||
|
||||
|
||||
registerClickable(34, ((player1, inventory1, cursor, slot, type) -> {
|
||||
AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event -> {
|
||||
this.reason = event.getName();
|
||||
justSaved = false;
|
||||
});
|
||||
|
||||
gui.setOnClose((player2, inventory3) -> init(setTitle, inventory.getSize()));
|
||||
|
||||
ItemStack item = new ItemStack(Material.PAPER);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(reason == null ? plugin.getLocale().getMessage("gui.general.reason").getMessage() : reason);
|
||||
item.setItemMeta(meta);
|
||||
|
||||
gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, item);
|
||||
gui.open();
|
||||
}));
|
||||
|
||||
registerClickable(22, ((player1, inventory1, cursor, slot, type1) -> {
|
||||
if (!player.hasPermission("um." + type.toString().toLowerCase())) return;
|
||||
if (duration == -1 && type == PunishmentType.BAN && !player.hasPermission("um.ban.permanent")) return;
|
||||
|
||||
if (toModerate == null) {
|
||||
if (reason == null || duration == 0 || templateName == null) return;
|
||||
|
||||
if (template == null)
|
||||
finishTemplate();
|
||||
else
|
||||
updateTemplate();
|
||||
return;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case BAN:
|
||||
case MUTE:
|
||||
case WARNING:
|
||||
new Punishment(type, duration, reason).execute(player, toModerate);
|
||||
break;
|
||||
case KICK:
|
||||
new Punishment(type, reason).execute(player, toModerate);
|
||||
break;
|
||||
}
|
||||
|
||||
new GUIPlayer(plugin, toModerate, player);
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerOnCloses() {
|
||||
registerOnClose(((player1, inventory1) -> Bukkit.getScheduler().cancelTask(task)));
|
||||
}
|
||||
|
||||
private void nameTemplate() {
|
||||
AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event -> {
|
||||
this.templateName = event.getName();
|
||||
|
||||
if (toModerate != null)
|
||||
finishTemplate();
|
||||
|
||||
justSaved = true;
|
||||
});
|
||||
|
||||
gui.setOnClose((player2, inventory3) ->
|
||||
init(setTitle, inventory.getSize()));
|
||||
|
||||
ItemStack item = new ItemStack(Material.PAPER);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(plugin.getLocale().getMessage("gui.general.templatename").getMessage());
|
||||
item.setItemMeta(meta);
|
||||
|
||||
gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, item);
|
||||
gui.open();
|
||||
}
|
||||
|
||||
private void updateTemplate() {
|
||||
Template template = new Template(this.type, this.duration, this.reason, this.template.getCreator(), this.templateName);
|
||||
plugin.getTemplateManager().updateTemplate(this.template.getUUID(), template);
|
||||
justSaved = true;
|
||||
if (toModerate == null)
|
||||
new GUITemplateManager(plugin, player);
|
||||
}
|
||||
|
||||
private void finishTemplate() {
|
||||
Template template = new Template(this.type, this.duration, this.reason, player, templateName);
|
||||
plugin.getTemplateManager().addTemplate(template);
|
||||
this.template = template;
|
||||
if (toModerate == null)
|
||||
new GUITemplateManager(plugin, player);
|
||||
}
|
||||
|
||||
public void setTemplate(Template template) {
|
||||
this.justSaved = true;
|
||||
this.template = template;
|
||||
}
|
||||
|
||||
public void setType(PunishmentType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public void setDuration(long duration) {
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public void setReason(String reason) {
|
||||
this.reason = reason;
|
||||
}
|
||||
}
|
@ -1,114 +0,0 @@
|
||||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentType;
|
||||
import com.songoda.ultimatemoderation.punish.template.Template;
|
||||
import com.songoda.ultimatemoderation.utils.Methods;
|
||||
import com.songoda.ultimatemoderation.utils.gui.AbstractGUI;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class GUITemplateManager extends AbstractGUI {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
private int page = 0;
|
||||
|
||||
private PunishmentType punishmentType = PunishmentType.ALL;
|
||||
|
||||
public GUITemplateManager(UltimateModeration plugin, Player player) {
|
||||
super(player);
|
||||
this.plugin = plugin;
|
||||
|
||||
init(plugin.getLocale().getMessage("gui.templatemanager.title").getMessage(), 54);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void constructGUI() {
|
||||
inventory.clear();
|
||||
resetClickables();
|
||||
registerClickables();
|
||||
|
||||
int numTemplates = plugin.getTemplateManager().getTemplates().size();
|
||||
int maxPage = (int) Math.floor(numTemplates / 36.0);
|
||||
|
||||
List<Template> templates = plugin.getTemplateManager().getTemplates().values().stream().skip(page * 36).limit(36)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (page != 0) {
|
||||
createButton(1, Material.ARROW, plugin.getLocale().getMessage("gui.general.previous").getMessage());
|
||||
registerClickable(1, ((player1, inventory1, cursor, slot, type) -> {
|
||||
page--;
|
||||
constructGUI();
|
||||
}));
|
||||
}
|
||||
|
||||
if (page != maxPage) {
|
||||
createButton(5, Material.ARROW, plugin.getLocale().getMessage("gui.general.next").getMessage());
|
||||
registerClickable(5, ((player1, inventory1, cursor, slot, type) -> {
|
||||
page++;
|
||||
constructGUI();
|
||||
}));
|
||||
}
|
||||
|
||||
createButton(3, Material.DIAMOND_SWORD, Methods.formatText("&6" + punishmentType.name()));
|
||||
|
||||
createButton(8, ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)
|
||||
? Material.OAK_DOOR
|
||||
: Material.valueOf("WOOD_DOOR"),
|
||||
plugin.getLocale().getMessage("gui.general.back").getMessage());
|
||||
|
||||
if (player.hasPermission("um.templates.create"))
|
||||
createButton(7, Material.REDSTONE, plugin.getLocale().getMessage("gui.templatemanager.create").getMessage());
|
||||
|
||||
for (int i = 0; i < 9; i++)
|
||||
createButton(9 + i, ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.GRAY_STAINED_GLASS_PANE : new ItemStack(Material.valueOf("STAINED_GLASS_PANE")), "&1");
|
||||
|
||||
if (punishmentType != PunishmentType.ALL)
|
||||
templates.removeIf(template -> template.getPunishmentType() != punishmentType);
|
||||
for (int i = 0; i < templates.size(); i++) {
|
||||
Template template = templates.get(i);
|
||||
createButton(18 + i, Material.MAP, "&6&l" + template.getTemplateName(),
|
||||
plugin.getLocale().getMessage("gui.templatemanager.leftclick").getMessage(),
|
||||
plugin.getLocale().getMessage("gui.templatemanager.rightclick").getMessage());
|
||||
|
||||
registerClickable(18 + i, ((player1, inventory1, cursor, slot, type) -> {
|
||||
if (type == ClickType.LEFT) {
|
||||
if (player.hasPermission("um.templates.edit")) new GUIPunish(plugin, null, template, player);
|
||||
} else if (type == ClickType.RIGHT) {
|
||||
if (player.hasPermission("um.templates.destroy"))
|
||||
plugin.getTemplateManager().removeTemplate(template.getUUID());
|
||||
constructGUI();
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerClickables() {
|
||||
registerClickable(8, ((player1, inventory1, cursor, slot, type) ->
|
||||
new GUIPlayers(plugin, player)));
|
||||
|
||||
if (player.hasPermission("um.templates.create")) {
|
||||
registerClickable(7, ((player1, inventory1, cursor, slot, type) -> {
|
||||
new GUIPunish(plugin, null, null, player);
|
||||
}));
|
||||
}
|
||||
|
||||
registerClickable(3, ((player1, inventory1, cursor, slot, type) -> {
|
||||
this.punishmentType = punishmentType.nextFilter();
|
||||
this.page = 0;
|
||||
constructGUI();
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerOnCloses() {
|
||||
}
|
||||
}
|
@ -1,65 +0,0 @@
|
||||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.punish.template.Template;
|
||||
import com.songoda.ultimatemoderation.utils.gui.AbstractGUI;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class GUITemplateSelector extends AbstractGUI {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
private GUIPunish punish;
|
||||
|
||||
public GUITemplateSelector(UltimateModeration plugin, GUIPunish punish, Player player) {
|
||||
super(player);
|
||||
this.plugin = plugin;
|
||||
this.punish = punish;
|
||||
|
||||
init(plugin.getLocale().getMessage("gui.templateselector.title").getMessage(), 54);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void constructGUI() {
|
||||
createButton(8, CompatibleMaterial.OAK_DOOR.getMaterial(),
|
||||
plugin.getLocale().getMessage("gui.general.back").getMessage());
|
||||
|
||||
for (int i = 0; i < 9; i++)
|
||||
createButton(9 + i, ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.GRAY_STAINED_GLASS_PANE : new ItemStack(Material.valueOf("STAINED_GLASS_PANE")), "&1");
|
||||
|
||||
ArrayList<Template> templates = new ArrayList<>(plugin.getTemplateManager().getTemplates().values());
|
||||
for (int i = 0; i < templates.size(); i++) {
|
||||
Template template = templates.get(i);
|
||||
createButton(18 + i, Material.MAP, "&6&l" + template.getTemplateName(),
|
||||
plugin.getLocale().getMessage("gui.templateselector.click").getMessage());
|
||||
|
||||
registerClickable(18 + i, ((player1, inventory1, cursor, slot, type) -> {
|
||||
punish.setType(template.getPunishmentType());
|
||||
punish.setDuration(template.getDuration());
|
||||
punish.setReason(template.getReason());
|
||||
punish.setTemplate(template);
|
||||
punish.init(setTitle, punish.getInventory().getSize());
|
||||
punish.runTask();
|
||||
}));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerClickables() {
|
||||
registerClickable(8, ((player1, inventory1, cursor, slot, type) -> {
|
||||
punish.init(punish.getSetTitle(), punish.getInventory().getSize());
|
||||
punish.runTask();
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerOnCloses() {
|
||||
|
||||
}
|
||||
}
|
@ -1,164 +0,0 @@
|
||||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.tickets.Ticket;
|
||||
import com.songoda.ultimatemoderation.tickets.TicketResponse;
|
||||
import com.songoda.ultimatemoderation.tickets.TicketStatus;
|
||||
import com.songoda.ultimatemoderation.utils.AbstractChatConfirm;
|
||||
import com.songoda.ultimatemoderation.utils.gui.AbstractGUI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import com.songoda.ultimatemoderation.staffchat.*;
|
||||
|
||||
public class GUITicket extends AbstractGUI {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
private StaffChatManager chatManager = UltimateModeration.getInstance().getStaffChatManager();
|
||||
|
||||
private final Ticket ticket;
|
||||
|
||||
private final OfflinePlayer toModerate;
|
||||
private int page = 0;
|
||||
|
||||
public GUITicket(UltimateModeration plugin, Ticket ticket, OfflinePlayer toModerate, Player player) {
|
||||
super(player);
|
||||
this.ticket = ticket;
|
||||
this.plugin = plugin;
|
||||
this.toModerate = toModerate;
|
||||
|
||||
init(plugin.getLocale().getMessage("gui.ticket.title")
|
||||
.processPlaceholder("id", ticket.getTicketId()).getMessage(), 54);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void constructGUI() {
|
||||
inventory.clear();
|
||||
resetClickables();
|
||||
registerClickables();
|
||||
|
||||
int numNotes = ticket.getResponses().size();
|
||||
int maxPage = (int) Math.floor(numNotes / 36.0);
|
||||
|
||||
List<TicketResponse> responses = ticket.getResponses().stream().skip(page * 36).limit(36)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (page != 0) {
|
||||
createButton(1, Material.ARROW, plugin.getLocale().getMessage("gui.general.previous").getMessage());
|
||||
registerClickable(1, ((player1, inventory1, cursor, slot, type) -> {
|
||||
page--;
|
||||
constructGUI();
|
||||
}));
|
||||
}
|
||||
|
||||
if (page != maxPage) {
|
||||
createButton(3, Material.ARROW, plugin.getLocale().getMessage("gui.general.next").getMessage());
|
||||
registerClickable(3, ((player1, inventory1, cursor, slot, type) -> {
|
||||
page++;
|
||||
constructGUI();
|
||||
}));
|
||||
}
|
||||
|
||||
if (player.hasPermission("um.tickets.openclose"))
|
||||
createButton(5, Material.REDSTONE, "&6" + ticket.getStatus().getStatus());
|
||||
|
||||
createButton(8, ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)
|
||||
? Material.OAK_DOOR
|
||||
: Material.valueOf("WOOD_DOOR"),
|
||||
plugin.getLocale().getMessage("gui.general.back").getMessage());
|
||||
|
||||
if (player.hasPermission("um.ticket.clicktotele") && ticket.getLocation() != null)
|
||||
createButton(7, Material.REDSTONE,
|
||||
plugin.getLocale().getMessage("gui.ticket.clicktotele").getMessage());
|
||||
|
||||
if (player.hasPermission("um.tickets.respond"))
|
||||
createButton(6, Material.REDSTONE, plugin.getLocale().getMessage("gui.ticket.respond").getMessage());
|
||||
|
||||
for (int i = 0; i < 9; i++)
|
||||
createButton(9 + i, ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.GRAY_STAINED_GLASS_PANE : new ItemStack(Material.valueOf("STAINED_GLASS_PANE")), "&1");
|
||||
|
||||
for (int i = 0; i < responses.size(); i++) {
|
||||
TicketResponse ticketResponse = responses.get(i);
|
||||
|
||||
String subjectStr = ticketResponse.getMessage();
|
||||
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
int lastIndex = 0;
|
||||
for (int n = 0; n < subjectStr.length(); n++) {
|
||||
if (n - lastIndex < 20)
|
||||
continue;
|
||||
|
||||
if (subjectStr.charAt(n) == ' ') {
|
||||
lore.add("&6" + subjectStr.substring(lastIndex, n).trim());
|
||||
lastIndex = n;
|
||||
}
|
||||
}
|
||||
|
||||
if (lastIndex - subjectStr.length() < 20)
|
||||
lore.add("&6" + subjectStr.substring(lastIndex, subjectStr.length()).trim());
|
||||
|
||||
String name = lore.get(0);
|
||||
lore.remove(0);
|
||||
|
||||
lore.add("");
|
||||
|
||||
SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy");
|
||||
|
||||
|
||||
lore.add(plugin.getLocale().getMessage("gui.ticket.postedby")
|
||||
.processPlaceholder("player", Bukkit.getOfflinePlayer(ticketResponse.getAuthor()).getName()).getMessage());
|
||||
lore.add(plugin.getLocale().getMessage("gui.ticket.createdon")
|
||||
.processPlaceholder("sent", format.format(new Date(ticketResponse.getPostedDate()))).getMessage());
|
||||
|
||||
createButton(18 + i, Material.MAP, name, lore);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerClickables() {
|
||||
registerClickable(8, ((player1, inventory1, cursor, slot, type) ->
|
||||
new GUITicketManager(plugin, toModerate, player)));
|
||||
|
||||
if (player.hasPermission("um.tickets.clicktotele") && ticket.getLocation() != null) {
|
||||
registerClickable(7, ((player1, inventory1, cursor, slot, type) ->
|
||||
player.teleport(ticket.getLocation())));
|
||||
}
|
||||
|
||||
if (player.hasPermission("um.tickets.openclose")) {
|
||||
registerClickable(5, ((player1, inventory1, cursor, slot, type) -> {
|
||||
ticket.setStatus(ticket.getStatus() == TicketStatus.OPEN ? TicketStatus.CLOSED : TicketStatus.OPEN);
|
||||
// Notify staff of ticket status
|
||||
chatManager.getChat("ticket").messageAll(UltimateModeration.getInstance().getLocale().getMessage("notify.ticket.status").getMessage().replace("%tid%", ""+ticket.getTicketId()).replace("%type%", ticket.getType()).replace("%player%", Bukkit.getPlayer(ticket.getVictim()).getDisplayName()).replace("%status%", ticket.getStatus().toString()));
|
||||
constructGUI();
|
||||
}));
|
||||
}
|
||||
|
||||
if (player.hasPermission("um.tickets.respond")) {
|
||||
registerClickable(6, ((player1, inventory1, cursor, slot, type) -> {
|
||||
player.sendMessage(plugin.getLocale().getMessage("gui.ticket.what").getMessage());
|
||||
AbstractChatConfirm abstractChatConfirm = new AbstractChatConfirm(player, event2 -> {
|
||||
ticket.addResponse(new TicketResponse(player, event2.getMessage(), System.currentTimeMillis()));
|
||||
// Notify staff of ticket response.
|
||||
chatManager.getChat("ticket").messageAll(UltimateModeration.getInstance().getLocale().getMessage("notify.ticket.response").getMessage().replace("%tid%", ""+ticket.getTicketId()).replace("%type%", ticket.getType()).replace("%player%", Bukkit.getPlayer(ticket.getVictim()).getDisplayName()));
|
||||
constructGUI();
|
||||
});
|
||||
|
||||
abstractChatConfirm.setOnClose(() ->
|
||||
init(setTitle, inventory.getSize()));
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerOnCloses() {
|
||||
}
|
||||
}
|
@ -1,173 +0,0 @@
|
||||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.tickets.Ticket;
|
||||
import com.songoda.ultimatemoderation.tickets.TicketStatus;
|
||||
import com.songoda.ultimatemoderation.utils.Methods;
|
||||
import com.songoda.ultimatemoderation.utils.gui.AbstractAnvilGUI;
|
||||
import com.songoda.ultimatemoderation.utils.gui.AbstractGUI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class GUITicketManager extends AbstractGUI {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
private final OfflinePlayer toModerate;
|
||||
|
||||
private TicketStatus status = TicketStatus.OPEN;
|
||||
|
||||
private int page = 0;
|
||||
|
||||
public GUITicketManager(UltimateModeration plugin, OfflinePlayer toModerate, Player player) {
|
||||
super(player);
|
||||
this.plugin = plugin;
|
||||
this.toModerate = toModerate;
|
||||
|
||||
init(plugin.getLocale().getMessage(toModerate != null ? "gui.tickets.titlesingle" : "gui.tickets.title")
|
||||
.processPlaceholder("toModerate", toModerate != null ? toModerate.getName() : "").getMessage(), 54);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void constructGUI() {
|
||||
inventory.clear();
|
||||
resetClickables();
|
||||
registerClickables();
|
||||
|
||||
List<Ticket> tickets = toModerate != null ? plugin.getTicketManager().getTicketsAbout(toModerate, status) : plugin.getTicketManager().getTickets(status);
|
||||
|
||||
int numTickets = tickets.size();
|
||||
int maxPage = (int) Math.floor(numTickets / 36.0);
|
||||
|
||||
tickets = tickets.stream().skip(page * 36).limit(36).collect(Collectors.toList());
|
||||
|
||||
if (page != 0) {
|
||||
createButton(1, Material.ARROW, plugin.getLocale().getMessage("gui.general.previous").getMessage());
|
||||
registerClickable(1, ((player1, inventory1, cursor, slot, type) -> {
|
||||
page--;
|
||||
constructGUI();
|
||||
}));
|
||||
}
|
||||
|
||||
if (maxPage >= 36) {
|
||||
createButton(5, Material.ARROW, plugin.getLocale().getMessage("gui.general.next").getMessage());
|
||||
registerClickable(5, ((player1, inventory1, cursor, slot, type) -> {
|
||||
page++;
|
||||
constructGUI();
|
||||
}));
|
||||
}
|
||||
|
||||
createButton(3, Material.DIAMOND_SWORD, Methods.formatText("&6" + status.getStatus()));
|
||||
|
||||
if (toModerate != null && player.hasPermission("um.tickets.create"))
|
||||
createButton(7, Material.REDSTONE, plugin.getLocale().getMessage("gui.tickets.create").getMessage());
|
||||
|
||||
if (player.hasPermission("um.ticket"))
|
||||
createButton(8, CompatibleMaterial.OAK_DOOR.getMaterial(),
|
||||
plugin.getLocale().getMessage("gui.general.back").getMessage());
|
||||
|
||||
for (int i = 0; i < 9; i++)
|
||||
createButton(9 + i, ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.GRAY_STAINED_GLASS_PANE : new ItemStack(Material.valueOf("STAINED_GLASS_PANE")), "&1");
|
||||
|
||||
for (int i = 0; i < tickets.size(); i++) {
|
||||
Ticket ticket = tickets.get(i);
|
||||
|
||||
String subjectStr = ticket.getSubject();
|
||||
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
int lastIndex = 0;
|
||||
for (int n = 0; n < subjectStr.length(); n++) {
|
||||
if (n - lastIndex < 20)
|
||||
continue;
|
||||
|
||||
if (subjectStr.charAt(n) == ' ') {
|
||||
lore.add("&6" + subjectStr.substring(lastIndex, n).trim());
|
||||
lastIndex = n;
|
||||
}
|
||||
}
|
||||
|
||||
if (lastIndex - subjectStr.length() < 20)
|
||||
lore.add("&6" + subjectStr.substring(lastIndex, subjectStr.length()).trim() + " &7- " + ticket.getTicketId());
|
||||
|
||||
String name = lore.get(0);
|
||||
lore.remove(0);
|
||||
|
||||
lore.add("");
|
||||
|
||||
SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy");
|
||||
|
||||
lore.add(plugin.getLocale().getMessage("gui.ticket.status")
|
||||
.processPlaceholder("status", ticket.getStatus().getStatus()).getMessage());
|
||||
|
||||
if (toModerate != null)
|
||||
lore.add(plugin.getLocale().getMessage("gui.tickets.player")
|
||||
.processPlaceholder("player", Bukkit.getOfflinePlayer(ticket.getVictim()).getName()).getMessage());
|
||||
lore.add(plugin.getLocale().getMessage("gui.ticket.type")
|
||||
.processPlaceholder("type", ticket.getType()).getMessage());
|
||||
lore.add(plugin.getLocale().getMessage("gui.ticket.createdon")
|
||||
.processPlaceholder("sent", format.format(new Date(ticket.getCreationDate()))).getMessage());
|
||||
lore.add(plugin.getLocale().getMessage("gui.tickets.click").getMessage());
|
||||
|
||||
createButton(18 + i, Material.MAP, name, lore);
|
||||
|
||||
registerClickable(18 + i, ((player1, inventory1, cursor, slot, type) ->
|
||||
new GUITicket(plugin, ticket, toModerate, player)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerClickables() {
|
||||
if (player.hasPermission("um.moderate")) {
|
||||
registerClickable(8, ((player1, inventory1, cursor, slot, type) -> {
|
||||
if (toModerate == null)
|
||||
new GUIPlayers(plugin, player);
|
||||
else
|
||||
new GUIPlayer(plugin, toModerate, player1);
|
||||
}));
|
||||
}
|
||||
|
||||
registerClickable(3, ((player1, inventory1, cursor, slot, type) -> {
|
||||
this.status = status == TicketStatus.OPEN ? TicketStatus.CLOSED : TicketStatus.OPEN;
|
||||
this.page = 0;
|
||||
constructGUI();
|
||||
}));
|
||||
|
||||
if (toModerate != null && player.hasPermission("um.tickets.create")) {
|
||||
registerClickable(7, ((player1, inventory1, cursor, slot, type) ->
|
||||
createNew(player, toModerate)));
|
||||
}
|
||||
}
|
||||
|
||||
public static void createNew(Player player, OfflinePlayer toModerate) {
|
||||
UltimateModeration plugin = UltimateModeration.getInstance();
|
||||
|
||||
AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event ->
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () ->
|
||||
new GUITicketType(plugin, toModerate, player, event.getName()), 1L));
|
||||
|
||||
ItemStack item = new ItemStack(Material.PAPER);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(plugin.getLocale().getMessage("gui.tickets.subject").getMessage());
|
||||
item.setItemMeta(meta);
|
||||
|
||||
gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, item);
|
||||
gui.open();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerOnCloses() {
|
||||
}
|
||||
}
|
@ -1,70 +0,0 @@
|
||||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.tickets.Ticket;
|
||||
import com.songoda.ultimatemoderation.tickets.TicketResponse;
|
||||
import com.songoda.ultimatemoderation.utils.AbstractChatConfirm;
|
||||
import com.songoda.ultimatemoderation.utils.gui.AbstractGUI;
|
||||
import com.songoda.ultimatemoderation.settings.Settings;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import com.songoda.ultimatemoderation.staffchat.*;
|
||||
|
||||
import java.util.List;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class GUITicketType extends AbstractGUI {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
private StaffChatManager chatManager = UltimateModeration.getInstance().getStaffChatManager();
|
||||
|
||||
private final OfflinePlayer toModerate;
|
||||
private final String subject;
|
||||
|
||||
public GUITicketType(UltimateModeration plugin, OfflinePlayer toModerate, Player player, String subject) {
|
||||
super(player);
|
||||
this.plugin = plugin;
|
||||
this.toModerate = toModerate;
|
||||
this.subject = subject;
|
||||
|
||||
init(plugin.getLocale().getMessage("gui.ticket.picktype").getMessage(), 27);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void constructGUI() {
|
||||
inventory.clear();
|
||||
resetClickables();
|
||||
registerClickables();
|
||||
|
||||
List<String> types = Settings.TICKET_TYPES.getStringList();
|
||||
|
||||
for (int i = 0; i < types.size(); i ++) {
|
||||
createButton(i, Material.PAPER, types.get(i));
|
||||
final int fi = i;
|
||||
registerClickable(i, (player1, inventory1, cursor, slot, type) -> {
|
||||
Ticket ticket = new Ticket(toModerate, subject, types.get(fi));
|
||||
player.sendMessage(plugin.getLocale().getMessage("gui.tickets.what").getMessage());
|
||||
AbstractChatConfirm abstractChatConfirm = new AbstractChatConfirm(player, event2 -> {
|
||||
plugin.getTicketManager().addTicket(ticket);
|
||||
// Notify staff
|
||||
chatManager.getChat("ticket").messageAll(UltimateModeration.getInstance().getLocale().getMessage("notify.ticket.created").getMessage().replace("%tid%", ""+ticket.getTicketId()).replace("%type%", ticket.getType()).replace("%player%", Bukkit.getPlayer(ticket.getVictim()).getDisplayName()));
|
||||
if (player == toModerate)
|
||||
ticket.setLocation(player.getLocation());
|
||||
ticket.addResponse(new TicketResponse(player, event2.getMessage(), System.currentTimeMillis()));
|
||||
});
|
||||
|
||||
abstractChatConfirm.setOnClose(() ->
|
||||
new GUITicket(plugin, ticket, toModerate, player));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerClickables() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerOnCloses() {
|
||||
}
|
||||
}
|
198
src/main/java/com/songoda/ultimatemoderation/gui/MainGui.java
Normal file
198
src/main/java/com/songoda/ultimatemoderation/gui/MainGui.java
Normal file
@ -0,0 +1,198 @@
|
||||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.gui.AnvilGui;
|
||||
import com.songoda.core.gui.Gui;
|
||||
import com.songoda.core.gui.GuiUtils;
|
||||
import com.songoda.core.utils.ItemUtils;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentType;
|
||||
import com.songoda.ultimatemoderation.punish.player.PlayerPunishData;
|
||||
import com.songoda.ultimatemoderation.settings.Settings;
|
||||
import com.songoda.ultimatemoderation.tickets.TicketStatus;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class MainGui extends Gui {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
private Online currentOnline = Online.ONLINE;
|
||||
|
||||
private List<UUID> players = new ArrayList<>();
|
||||
private final Player viewer;
|
||||
|
||||
public MainGui(UltimateModeration plugin, Player viewer) {
|
||||
this.plugin = plugin;
|
||||
setRows(6);
|
||||
setDefaultItem(null);
|
||||
this.viewer = viewer;
|
||||
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
players.add(player.getUniqueId());
|
||||
for (UUID uuid : plugin.getPunishmentManager().getPunishments().keySet()) {
|
||||
if (Bukkit.getOfflinePlayer(uuid).isOnline()) continue;
|
||||
players.add(uuid);
|
||||
}
|
||||
|
||||
setTitle(plugin.getLocale().getMessage("gui.players.title").getMessage());
|
||||
|
||||
showPage();
|
||||
}
|
||||
|
||||
private void showPage() {
|
||||
if (inventory != null)
|
||||
inventory.clear();
|
||||
setActionForRange(0, 53, null);
|
||||
|
||||
// decorate the edges
|
||||
ItemStack glass2 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_2.getMaterial(CompatibleMaterial.BLUE_STAINED_GLASS_PANE));
|
||||
ItemStack glass3 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_3.getMaterial(CompatibleMaterial.LIGHT_BLUE_STAINED_GLASS_PANE));
|
||||
|
||||
// edges will be type 3
|
||||
GuiUtils.mirrorFill(this, 0, 2, true, true, glass3);
|
||||
GuiUtils.mirrorFill(this, 1, 1, true, true, glass3);
|
||||
|
||||
// decorate corners with type 2
|
||||
GuiUtils.mirrorFill(this, 0, 0, true, true, glass2);
|
||||
GuiUtils.mirrorFill(this, 1, 0, true, true, glass2);
|
||||
GuiUtils.mirrorFill(this, 0, 1, true, true, glass2);
|
||||
|
||||
setButton(5, 2, GuiUtils.createButtonItem(CompatibleMaterial.ENDER_PEARL,
|
||||
plugin.getLocale().getMessage("gui.players.search").getMessage()),
|
||||
(event) -> {
|
||||
AnvilGui gui = new AnvilGui(event.player, this);
|
||||
gui.setAction(event2 -> {
|
||||
List<UUID> players = new ArrayList<>(plugin.getPunishmentManager().getPunishments().keySet());
|
||||
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
if (players.contains(p.getUniqueId())) continue;
|
||||
players.add(p.getUniqueId());
|
||||
}
|
||||
|
||||
List<UUID> found = players.stream().filter(uuid -> Bukkit.getOfflinePlayer(uuid).getName().toLowerCase().contains(gui.getInputText().toLowerCase())).collect(Collectors.toList());
|
||||
|
||||
if (found.size() >= 1) {
|
||||
this.players = found;
|
||||
showPage();
|
||||
} else {
|
||||
plugin.getLocale().getMessage("gui.players.nonefound").sendMessage(event.player);
|
||||
}
|
||||
event2.player.closeInventory();
|
||||
});
|
||||
|
||||
ItemStack item = new ItemStack(Material.PAPER);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(plugin.getLocale().getMessage("gui.players.name").getMessage());
|
||||
item.setItemMeta(meta);
|
||||
|
||||
gui.setInput(item);
|
||||
guiManager.showGUI(event.player, gui);
|
||||
});
|
||||
|
||||
setButton(5, 3, GuiUtils.createButtonItem(CompatibleMaterial.HOPPER, TextUtils.formatText("&6" + currentOnline.getTranslation())),
|
||||
(event) -> {
|
||||
this.currentOnline = currentOnline.next();
|
||||
this.page = 1;
|
||||
showPage();
|
||||
});
|
||||
|
||||
|
||||
if (viewer.hasPermission("um.tickets"))
|
||||
setButton(5, 5, GuiUtils.createButtonItem(CompatibleMaterial.CHEST,
|
||||
plugin.getLocale().getMessage("gui.players.button.tickets").getMessage()),
|
||||
(event) -> guiManager.showGUI(event.player, new TicketManagerGui(plugin, null, viewer)));
|
||||
|
||||
if (viewer.hasPermission("um.templates"))
|
||||
setButton(5, 6, GuiUtils.createButtonItem(CompatibleMaterial.MAP,
|
||||
plugin.getLocale().getMessage("gui.players.button.templatemanager").getMessage()),
|
||||
(events) -> guiManager.showGUI(events.player, new TemplateManagerGui(plugin, viewer)));
|
||||
|
||||
|
||||
List<UUID> toUse = players.stream()
|
||||
.filter(u -> currentOnline == Online.BOTH
|
||||
|| currentOnline == Online.ONLINE && Bukkit.getOfflinePlayer(u).isOnline()
|
||||
|| currentOnline == Online.OFFLINE && !Bukkit.getOfflinePlayer(u).isOnline()).collect(Collectors.toList());
|
||||
|
||||
this.pages = (int) Math.max(1, Math.ceil(toUse.size() / ((double) 28)));
|
||||
|
||||
toUse = toUse.stream().skip((page - 1) * 28).limit(28).collect(Collectors.toList());
|
||||
|
||||
int num = 11;
|
||||
for (UUID uuid : toUse) {
|
||||
if (num == 16 || num == 36)
|
||||
num = num + 2;
|
||||
OfflinePlayer pl = Bukkit.getOfflinePlayer(uuid);
|
||||
ItemStack skull = ItemUtils.getPlayerSkull(pl);
|
||||
setItem(num, skull);
|
||||
|
||||
PlayerPunishData playerPunishData = plugin.getPunishmentManager().getPlayer(pl);
|
||||
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
lore.add(plugin.getLocale().getMessage("gui.players.click").getMessage());
|
||||
lore.add("");
|
||||
|
||||
int ticketAmt = (int) plugin.getTicketManager().getTicketsAbout(pl).stream()
|
||||
.filter(t -> t.getStatus() == TicketStatus.OPEN).count();
|
||||
|
||||
if (ticketAmt == 0)
|
||||
lore.add(plugin.getLocale().getMessage("gui.players.notickets").getMessage());
|
||||
else {
|
||||
if (ticketAmt == 1)
|
||||
lore.add(plugin.getLocale().getMessage("gui.players.ticketsone").getMessage());
|
||||
else
|
||||
lore.add(plugin.getLocale().getMessage("gui.players.tickets")
|
||||
.processPlaceholder("amount", ticketAmt).getMessage());
|
||||
}
|
||||
|
||||
int warningAmt = playerPunishData.getActivePunishments(PunishmentType.WARNING).size();
|
||||
|
||||
if (warningAmt == 0)
|
||||
lore.add(plugin.getLocale().getMessage("gui.players.nowarnings").getMessage());
|
||||
else {
|
||||
if (warningAmt == 1)
|
||||
lore.add(plugin.getLocale().getMessage("gui.players.warningsone").getMessage());
|
||||
else
|
||||
lore.add(plugin.getLocale().getMessage("gui.players.warnings")
|
||||
.processPlaceholder("amount", warningAmt).getMessage());
|
||||
}
|
||||
|
||||
setButton(num, GuiUtils.createButtonItem(skull, TextUtils.formatText("&7&l" + pl.getName()), lore),
|
||||
(event) -> guiManager.showGUI(event.player, new PlayerGui(plugin, pl, viewer)));
|
||||
|
||||
num++;
|
||||
}
|
||||
|
||||
// enable page events
|
||||
setNextPage(4, 7, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, plugin.getLocale().getMessage("gui.general.next").getMessage()));
|
||||
setPrevPage(4, 1, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, plugin.getLocale().getMessage("gui.general.back").getMessage()));
|
||||
setOnPage((event) -> showPage());
|
||||
}
|
||||
|
||||
private enum Online {
|
||||
|
||||
ONLINE, OFFLINE, BOTH;
|
||||
|
||||
private static Online[] vals = values();
|
||||
|
||||
public Online next() {
|
||||
return vals[(this.ordinal() != vals.length - 1 ? this.ordinal() + 1 : 0)];
|
||||
}
|
||||
|
||||
public String getTranslation() {
|
||||
return UltimateModeration.getInstance().getLocale()
|
||||
.getMessage("gui.players.online." + this.name().toLowerCase()).getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.gui.Gui;
|
||||
import com.songoda.core.gui.GuiUtils;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.moderate.AbstractModeration;
|
||||
import com.songoda.ultimatemoderation.settings.Settings;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ModerateGui extends Gui {
|
||||
|
||||
public ModerateGui(UltimateModeration plugin, OfflinePlayer toModerate, Player player) {
|
||||
super(5);
|
||||
setDefaultItem(null);
|
||||
|
||||
setTitle(plugin.getLocale().getMessage("gui.moderate.title")
|
||||
.processPlaceholder("toModerate", toModerate.getName()).getMessage());
|
||||
|
||||
// decorate the edges
|
||||
ItemStack glass2 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_2.getMaterial(CompatibleMaterial.BLUE_STAINED_GLASS_PANE));
|
||||
ItemStack glass3 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_3.getMaterial(CompatibleMaterial.LIGHT_BLUE_STAINED_GLASS_PANE));
|
||||
|
||||
// edges will be type 3
|
||||
GuiUtils.mirrorFill(this, 0, 2, true, true, glass3);
|
||||
GuiUtils.mirrorFill(this, 1, 1, true, true, glass3);
|
||||
|
||||
// decorate corners with type 2
|
||||
GuiUtils.mirrorFill(this, 0, 0, true, true, glass2);
|
||||
GuiUtils.mirrorFill(this, 1, 0, true, true, glass2);
|
||||
GuiUtils.mirrorFill(this, 2, 0, false, true, glass2);
|
||||
GuiUtils.mirrorFill(this, 0, 1, true, true, glass2);
|
||||
|
||||
setButton(8, GuiUtils.createButtonItem(CompatibleMaterial.OAK_DOOR,
|
||||
plugin.getLocale().getMessage("gui.general.back").getMessage()),
|
||||
(event) -> guiManager.showGUI(event.player, new PlayerGui(plugin, toModerate, event.player)));
|
||||
|
||||
int[] slots = new int[]{11, 13, 15, 29, 31, 33};
|
||||
|
||||
List<AbstractModeration> moderations = new ArrayList<>(plugin.getModerationManager().getModerations().values());
|
||||
|
||||
int i = 0;
|
||||
for (AbstractModeration moderation : moderations) {
|
||||
if (!moderation.hasPermission(player) || moderation.isExempt(toModerate)) continue;
|
||||
int slot = slots[i];
|
||||
setButton(slot, GuiUtils.createButtonItem(moderation.getIcon(),
|
||||
TextUtils.formatText("&6&l" + moderation.getProper()),
|
||||
TextUtils.formatText("&7" + moderation.getDescription())),
|
||||
(event) -> moderation.runPreModeration(player, toModerate));
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,143 @@
|
||||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.gui.Gui;
|
||||
import com.songoda.core.gui.GuiUtils;
|
||||
import com.songoda.core.input.ChatPrompt;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentNote;
|
||||
import com.songoda.ultimatemoderation.settings.Settings;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class NotesManagerGui extends Gui {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
private final OfflinePlayer toModerate;
|
||||
|
||||
private final boolean create, delete;
|
||||
|
||||
public NotesManagerGui(UltimateModeration plugin, OfflinePlayer toModerate, Player player) {
|
||||
this.plugin = plugin;
|
||||
setRows(6);
|
||||
setDefaultItem(null);
|
||||
this.toModerate = toModerate;
|
||||
this.create = player.hasPermission("um.notes.create");
|
||||
this.delete = player.hasPermission("um.notes.delete");
|
||||
|
||||
setTitle(plugin.getLocale().getMessage("gui.notes.title")
|
||||
.processPlaceholder("tonotes", player.getName()).getMessage());
|
||||
|
||||
showPage();
|
||||
}
|
||||
|
||||
private void showPage() {
|
||||
if (inventory != null)
|
||||
inventory.clear();
|
||||
setActionForRange(0, 53, null);
|
||||
|
||||
int numNotes = plugin.getPunishmentManager().getPlayer(toModerate).getNotes().size();
|
||||
this.pages = (int) Math.max(1, Math.ceil(numNotes / ((double) 28)));
|
||||
|
||||
List<PunishmentNote> notes = plugin.getPunishmentManager().getPlayer(toModerate).getNotes().stream()
|
||||
.skip((page - 1) * 28).limit(28).collect(Collectors.toList());
|
||||
|
||||
// enable page events
|
||||
setNextPage(0, 1, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, plugin.getLocale().getMessage("gui.general.next").getMessage()));
|
||||
setPrevPage(0, 3, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, plugin.getLocale().getMessage("gui.general.back").getMessage()));
|
||||
setOnPage((event) -> showPage());
|
||||
|
||||
// decorate the edges
|
||||
ItemStack glass2 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_2.getMaterial(CompatibleMaterial.BLUE_STAINED_GLASS_PANE));
|
||||
ItemStack glass3 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_3.getMaterial(CompatibleMaterial.LIGHT_BLUE_STAINED_GLASS_PANE));
|
||||
|
||||
// edges will be type 3
|
||||
GuiUtils.mirrorFill(this, 0, 2, true, true, glass3);
|
||||
GuiUtils.mirrorFill(this, 1, 1, true, true, glass3);
|
||||
|
||||
// decorate corners with type 2
|
||||
GuiUtils.mirrorFill(this, 0, 0, true, true, glass2);
|
||||
GuiUtils.mirrorFill(this, 1, 0, true, true, glass2);
|
||||
GuiUtils.mirrorFill(this, 0, 1, true, true, glass2);
|
||||
|
||||
setButton(5, 5, GuiUtils.createButtonItem(CompatibleMaterial.OAK_DOOR,
|
||||
plugin.getLocale().getMessage("gui.general.back").getMessage()),
|
||||
(event) -> guiManager.showGUI(event.player, new PlayerGui(plugin, toModerate, event.player)));
|
||||
|
||||
if (create)
|
||||
setButton(5, 3, GuiUtils.createButtonItem(CompatibleMaterial.REDSTONE,
|
||||
plugin.getLocale().getMessage("gui.notes.create").getMessage()),
|
||||
(event) -> {
|
||||
ChatPrompt.showPrompt(plugin, event.player,
|
||||
plugin.getLocale().getMessage("gui.notes.type").getMessage(),
|
||||
(response) -> {
|
||||
PunishmentNote note = new PunishmentNote(response.getMessage(),
|
||||
event.player.getUniqueId(), toModerate.getUniqueId(),
|
||||
System.currentTimeMillis());
|
||||
plugin.getPunishmentManager().getPlayer(toModerate).addNotes(note);
|
||||
plugin.getDataManager().createNote(note);
|
||||
|
||||
showPage();
|
||||
}).setOnClose(() -> guiManager.showGUI(event.player, new NotesManagerGui(plugin, toModerate, event.player)));
|
||||
});
|
||||
|
||||
int num = 11;
|
||||
for (PunishmentNote note : notes) {
|
||||
if (num == 16 || num == 36)
|
||||
num = num + 2;
|
||||
String noteStr = note.getNote();
|
||||
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
int lastIndex = 0;
|
||||
for (int n = 0; n < noteStr.length(); n++) {
|
||||
if (n - lastIndex < 20)
|
||||
continue;
|
||||
|
||||
if (noteStr.charAt(n) == ' ') {
|
||||
lore.add("&6" + noteStr.substring(lastIndex, n).trim());
|
||||
lastIndex = n;
|
||||
}
|
||||
}
|
||||
|
||||
if (lastIndex - noteStr.length() < 20)
|
||||
lore.add("&6" + noteStr.substring(lastIndex).trim());
|
||||
|
||||
String name = lore.get(0);
|
||||
lore.remove(0);
|
||||
|
||||
lore.add("");
|
||||
|
||||
SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy");
|
||||
|
||||
lore.add(plugin.getLocale().getMessage("gui.notes.createdby")
|
||||
.processPlaceholder("player", Bukkit.getOfflinePlayer(note.getAuthor()).getName())
|
||||
.getMessage());
|
||||
lore.add(plugin.getLocale().getMessage("gui.notes.createdon")
|
||||
.processPlaceholder("sent", format.format(new Date(note.getCreationDate())))
|
||||
.getMessage());
|
||||
if (delete) lore.add(plugin.getLocale().getMessage("gui.notes.remove").getMessage());
|
||||
|
||||
setButton(num, GuiUtils.createButtonItem(CompatibleMaterial.MAP, TextUtils.formatText(name), TextUtils.formatText(lore)),
|
||||
(event) -> {
|
||||
if (delete) {
|
||||
plugin.getPunishmentManager().getPlayer(toModerate).removeNotes(note);
|
||||
plugin.getDataManager().deleteNote(note);
|
||||
showPage();
|
||||
}
|
||||
});
|
||||
|
||||
num++;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.gui.Gui;
|
||||
import com.songoda.core.gui.GuiUtils;
|
||||
import com.songoda.core.utils.ItemUtils;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.settings.Settings;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class PlayerGui extends Gui {
|
||||
|
||||
public PlayerGui(UltimateModeration plugin, OfflinePlayer toModerate, Player player) {
|
||||
super(6);
|
||||
setDefaultItem(null);
|
||||
boolean punish = player.hasPermission("um.punish");
|
||||
boolean tickets = player.hasPermission("um.tickets");
|
||||
boolean punishments = player.hasPermission("um.punishments");
|
||||
boolean notes = player.hasPermission("um.notes");
|
||||
boolean moderate = player.hasPermission("um.moderation");
|
||||
|
||||
setDefaultItem(null);
|
||||
|
||||
setTitle(plugin.getLocale().getMessage("gui.player.title")
|
||||
.processPlaceholder("toModerate", toModerate.getName()).getMessage());
|
||||
|
||||
// decorate the edges
|
||||
ItemStack glass2 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_2.getMaterial(CompatibleMaterial.BLUE_STAINED_GLASS_PANE));
|
||||
ItemStack glass3 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_3.getMaterial(CompatibleMaterial.LIGHT_BLUE_STAINED_GLASS_PANE));
|
||||
|
||||
// edges will be type 3
|
||||
GuiUtils.mirrorFill(this, 0, 2, true, true, glass3);
|
||||
GuiUtils.mirrorFill(this, 1, 1, true, true, glass3);
|
||||
|
||||
// decorate corners with type 2
|
||||
GuiUtils.mirrorFill(this, 0, 0, true, true, glass2);
|
||||
GuiUtils.mirrorFill(this, 1, 0, true, true, glass2);
|
||||
GuiUtils.mirrorFill(this, 0, 1, true, true, glass2);
|
||||
|
||||
ItemStack head = ItemUtils.getPlayerSkull(toModerate);
|
||||
|
||||
setItem(13, GuiUtils.createButtonItem(head, TextUtils.formatText("&7&l" + toModerate.getName()),
|
||||
TextUtils.formatText(toModerate.isOnline() ? "&a"
|
||||
+ plugin.getLocale().getMessage("gui.players.online.online").getMessage()
|
||||
: "&c" + plugin.getLocale().getMessage("gui.players.online.offline").getMessage())));
|
||||
|
||||
setButton(8, GuiUtils.createButtonItem(CompatibleMaterial.OAK_DOOR,
|
||||
plugin.getLocale().getMessage("gui.general.back").getMessage()),
|
||||
(event) -> guiManager.showGUI(event.player, new MainGui(plugin, event.player)));
|
||||
|
||||
if (punish)
|
||||
setButton(38, GuiUtils.createButtonItem(CompatibleMaterial.ANVIL,
|
||||
plugin.getLocale().getMessage("gui.player.punish").getMessage()),
|
||||
(event) -> plugin.getGuiManager().showGUI(player,
|
||||
new PunishGui(plugin, toModerate, null, event.player)));
|
||||
|
||||
if (tickets)
|
||||
setButton(30, GuiUtils.createButtonItem(CompatibleMaterial.CHEST,
|
||||
plugin.getLocale().getMessage("gui.player.tickets").getMessage()),
|
||||
(event) -> plugin.getGuiManager().showGUI(player,
|
||||
new TicketManagerGui(plugin, toModerate, event.player)));
|
||||
|
||||
if (toModerate.isOnline() && punishments)
|
||||
setButton(32, GuiUtils.createButtonItem(CompatibleMaterial.DIAMOND_SWORD,
|
||||
plugin.getLocale().getMessage("gui.player.punishments").getMessage()),
|
||||
(event) -> plugin.getGuiManager().showGUI(player, new PunishmentsGui(plugin, toModerate)));
|
||||
|
||||
if (notes)
|
||||
setButton(42, GuiUtils.createButtonItem(CompatibleMaterial.MAP,
|
||||
plugin.getLocale().getMessage("gui.player.notes").getMessage()),
|
||||
(event) -> plugin.getGuiManager().showGUI(player,
|
||||
new NotesManagerGui(plugin, toModerate, event.player)));
|
||||
|
||||
if (moderate)
|
||||
setButton(40, GuiUtils.createButtonItem(CompatibleMaterial.DIAMOND_CHESTPLATE,
|
||||
plugin.getLocale().getMessage("gui.player.moderate").getMessage()),
|
||||
(event) -> guiManager.showGUI(player, new ModerateGui(plugin, toModerate, event.player)));
|
||||
}
|
||||
}
|
328
src/main/java/com/songoda/ultimatemoderation/gui/PunishGui.java
Normal file
328
src/main/java/com/songoda/ultimatemoderation/gui/PunishGui.java
Normal file
@ -0,0 +1,328 @@
|
||||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.gui.AnvilGui;
|
||||
import com.songoda.core.gui.Gui;
|
||||
import com.songoda.core.gui.GuiUtils;
|
||||
import com.songoda.core.utils.ItemUtils;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.punish.Punishment;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentType;
|
||||
import com.songoda.ultimatemoderation.punish.template.Template;
|
||||
import com.songoda.ultimatemoderation.settings.Settings;
|
||||
import com.songoda.ultimatemoderation.utils.Methods;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class PunishGui extends Gui {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
private final Player player;
|
||||
private final OfflinePlayer toModerate;
|
||||
|
||||
private Template template;
|
||||
private boolean justSaved = false;
|
||||
|
||||
private PunishmentType type = PunishmentType.BAN;
|
||||
private long duration = -1;
|
||||
private String reason = null;
|
||||
|
||||
private String templateName = null;
|
||||
|
||||
private int task;
|
||||
|
||||
public PunishGui(UltimateModeration plugin, OfflinePlayer toModerate, Template template, Player player) {
|
||||
super(5);
|
||||
setDefaultItem(null);
|
||||
this.player = player;
|
||||
this.plugin = plugin;
|
||||
this.toModerate = toModerate;
|
||||
if (template != null) {
|
||||
this.template = template;
|
||||
this.type = template.getPunishmentType();
|
||||
this.duration = template.getDuration();
|
||||
this.reason = template.getReason();
|
||||
this.templateName = template.getName();
|
||||
}
|
||||
|
||||
setTitle(toModerate == null ? plugin.getLocale().getMessage("gui.punish.title.template").getMessage()
|
||||
: plugin.getLocale().getMessage("gui.punish.title")
|
||||
.processPlaceholder("toModerate", toModerate.getName()).getMessage());
|
||||
if (toModerate != null) runTask();
|
||||
|
||||
setOnClose((event) -> Bukkit.getScheduler().cancelTask(task));
|
||||
paint();
|
||||
}
|
||||
|
||||
public void paint() {
|
||||
if (inventory != null)
|
||||
inventory.clear();
|
||||
setActionForRange(0, 53, null);
|
||||
|
||||
// decorate the edges
|
||||
ItemStack glass2 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_2.getMaterial(CompatibleMaterial.BLUE_STAINED_GLASS_PANE));
|
||||
ItemStack glass3 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_3.getMaterial(CompatibleMaterial.LIGHT_BLUE_STAINED_GLASS_PANE));
|
||||
|
||||
// edges will be type 3
|
||||
GuiUtils.mirrorFill(this, 0, 2, true, true, glass3);
|
||||
GuiUtils.mirrorFill(this, 1, 1, true, true, glass3);
|
||||
|
||||
// decorate corners with type 2
|
||||
GuiUtils.mirrorFill(this, 0, 0, true, true, glass2);
|
||||
GuiUtils.mirrorFill(this, 1, 0, true, true, glass2);
|
||||
GuiUtils.mirrorFill(this, 2, 0, false, true, glass2);
|
||||
GuiUtils.mirrorFill(this, 0, 1, true, true, glass2);
|
||||
|
||||
if (toModerate != null)
|
||||
setItem(13, GuiUtils.createButtonItem(ItemUtils.getPlayerSkull(toModerate),
|
||||
TextUtils.formatText("&6&l" + toModerate.getName())));
|
||||
|
||||
if (player.hasPermission("um." + type.toString().toLowerCase()))
|
||||
setButton(22, GuiUtils.createButtonItem(CompatibleMaterial.EMERALD_BLOCK,
|
||||
plugin.getLocale().getMessage("gui.punish.submit").getMessage()),
|
||||
(event) -> {
|
||||
if (!player.hasPermission("um." + type.toString().toLowerCase())) return;
|
||||
if (duration == -1 && type == PunishmentType.BAN && !player.hasPermission("um.ban.permanent"))
|
||||
return;
|
||||
|
||||
if (toModerate == null) {
|
||||
if (reason == null || templateName == null) return;
|
||||
|
||||
if (template == null)
|
||||
finishTemplate();
|
||||
else
|
||||
updateTemplate();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
switch (type) {
|
||||
case BAN:
|
||||
case MUTE:
|
||||
case WARNING:
|
||||
new Punishment(type, duration, reason).execute(player, toModerate);
|
||||
break;
|
||||
case KICK:
|
||||
new Punishment(type, reason).execute(player, toModerate);
|
||||
break;
|
||||
}
|
||||
player.closeInventory();
|
||||
});
|
||||
|
||||
setButton(8, GuiUtils.createButtonItem(CompatibleMaterial.OAK_DOOR,
|
||||
plugin.getLocale().getMessage("gui.general.back").getMessage()),
|
||||
(event) -> {
|
||||
if (toModerate != null)
|
||||
guiManager.showGUI(player, new PlayerGui(plugin, toModerate, player));
|
||||
else
|
||||
guiManager.showGUI(player, new TemplateManagerGui(plugin, player));
|
||||
});
|
||||
|
||||
setButton(28, GuiUtils.createButtonItem(CompatibleMaterial.ANVIL,
|
||||
plugin.getLocale().getMessage("gui.punish.type.punishment").getMessage(),
|
||||
TextUtils.formatText("&7" + type.getTranslation()),
|
||||
"",
|
||||
plugin.getLocale().getMessage("gui.punish.type.punishment.click").getMessage()),
|
||||
(event) -> {
|
||||
this.type = this.type.next();
|
||||
justSaved = false;
|
||||
paint();
|
||||
});
|
||||
|
||||
ItemStack templateItem = toModerate != null ? GuiUtils.createButtonItem(CompatibleMaterial.MAP,
|
||||
plugin.getLocale().getMessage("gui.punish.type.template").getMessage(),
|
||||
plugin.getLocale().getMessage("gui.punish.type.template.current")
|
||||
.processPlaceholder("template",
|
||||
template == null
|
||||
? plugin.getLocale().getMessage("gui.general.none").getMessage()
|
||||
: template.getName()).getMessage(),
|
||||
"",
|
||||
plugin.getLocale().getMessage(plugin.getTemplateManager().getTemplates().size() == 0
|
||||
? "gui.punish.type.template.none"
|
||||
: "gui.punish.type.template.click").getMessage())
|
||||
: GuiUtils.createButtonItem(CompatibleMaterial.MAP,
|
||||
plugin.getLocale().getMessage("gui.punish.type.name").getMessage(),
|
||||
plugin.getLocale().getMessage("gui.punish.type.name.current")
|
||||
.processPlaceholder("name",
|
||||
templateName == null
|
||||
? plugin.getLocale().getMessage("gui.punish.type.name.current").getMessage()
|
||||
: templateName).getMessage(),
|
||||
"",
|
||||
plugin.getLocale().getMessage("gui.punish.type.name.current.click").getMessage());
|
||||
|
||||
setButton(30, templateItem, (event) -> {
|
||||
if (toModerate == null) {
|
||||
nameTemplate();
|
||||
return;
|
||||
}
|
||||
if (plugin.getTemplateManager().getTemplates().size() == 0) return;
|
||||
|
||||
if (player.hasPermission("um.templates.use"))
|
||||
guiManager.showGUI(player, new TemplateSelectorGui(plugin, this, player));
|
||||
});
|
||||
|
||||
if (type != PunishmentType.KICK) {
|
||||
setButton(32, GuiUtils.createButtonItem(CompatibleMaterial.CLOCK,
|
||||
plugin.getLocale().getMessage("gui.punish.type.duration").getMessage(),
|
||||
plugin.getLocale().getMessage("gui.punish.type.duration.leftclick").getMessage(),
|
||||
plugin.getLocale().getMessage("gui.punish.type.duration.rightclick").getMessage(),
|
||||
"",
|
||||
plugin.getLocale().getMessage("gui.punish.type.duration.current").getMessage(),
|
||||
TextUtils.formatText("&6" + (duration == -1 ? plugin.getLocale().getMessage("gui.general.permanent").getMessage()
|
||||
: Methods.makeReadable(duration)))),
|
||||
(event) -> {
|
||||
if (this.type == PunishmentType.KICK) return;
|
||||
if (event.clickType == ClickType.LEFT) {
|
||||
AnvilGui gui = new AnvilGui(player, this);
|
||||
gui.setAction(evt -> {
|
||||
this.duration = Methods.parseTime(gui.getInputText());
|
||||
justSaved = false;
|
||||
guiManager.showGUI(player, this);
|
||||
paint();
|
||||
});
|
||||
|
||||
ItemStack item = new ItemStack(Material.PAPER);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
|
||||
meta.setDisplayName(duration == -1 || duration == 0 ? "1d 1h 1m" : Methods.makeReadable(duration));
|
||||
item.setItemMeta(meta);
|
||||
|
||||
gui.setInput(item);
|
||||
guiManager.showGUI(player, gui);
|
||||
} else {
|
||||
duration = -1;
|
||||
paint();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
setButton(34, GuiUtils.createButtonItem(CompatibleMaterial.PAPER,
|
||||
plugin.getLocale().getMessage("gui.punish.type.reason").getMessage(),
|
||||
plugin.getLocale().getMessage("gui.punish.type.reason.click").getMessage(),
|
||||
"",
|
||||
plugin.getLocale().getMessage("gui.punish.type.reason.current").getMessage(),
|
||||
TextUtils.formatText("&6" + reason)), (event) -> {
|
||||
|
||||
AnvilGui gui = new AnvilGui(player, this);
|
||||
gui.setAction(evnt -> {
|
||||
this.reason = gui.getInputText();
|
||||
justSaved = false;
|
||||
guiManager.showGUI(player, this);
|
||||
paint();
|
||||
});
|
||||
|
||||
ItemStack item = GuiUtils.createButtonItem(CompatibleMaterial.PAPER,
|
||||
reason == null ? plugin.getLocale().getMessage("gui.general.reason").getMessage() : reason);
|
||||
|
||||
gui.setInput(item);
|
||||
guiManager.showGUI(player, gui);
|
||||
});
|
||||
}
|
||||
|
||||
private void notifyTemplate() {
|
||||
if (reason == null || (justSaved && template != null)) {
|
||||
inventory.setItem(4, null);
|
||||
return;
|
||||
}
|
||||
|
||||
CompatibleMaterial material = CompatibleMaterial.WHITE_WOOL;
|
||||
String name = plugin.getLocale().getMessage("gui.punish.template.create").getMessage();
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
lore.add(plugin.getLocale().getMessage("gui.punish.template.create2").getMessage());
|
||||
|
||||
if (!justSaved && template != null) {
|
||||
name = plugin.getLocale().getMessage("gui.punish.template.leftclick").getMessage();
|
||||
lore.clear();
|
||||
lore.add(plugin.getLocale().getMessage("gui.punish.template.leftclick2")
|
||||
.processPlaceholder("template", template.getName()).getMessage());
|
||||
lore.add("");
|
||||
lore.add(plugin.getLocale().getMessage("gui.punish.template.rightclick").getMessage());
|
||||
}
|
||||
|
||||
if (getItem(4) != null && CompatibleMaterial.getMaterial(getItem(4)) == CompatibleMaterial.WHITE_WOOL)
|
||||
material = CompatibleMaterial.YELLOW_WOOL;
|
||||
|
||||
setButton(4, GuiUtils.createButtonItem(material, name, lore), (event) -> {
|
||||
|
||||
if (reason == null || duration == 0) return;
|
||||
|
||||
if (template != null && event.clickType == ClickType.LEFT) {
|
||||
updateTemplate();
|
||||
return;
|
||||
}
|
||||
nameTemplate();
|
||||
});
|
||||
}
|
||||
|
||||
public void runTask() {
|
||||
task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, this::notifyTemplate, 10L, 10L);
|
||||
}
|
||||
|
||||
private void nameTemplate() {
|
||||
AnvilGui gui = new AnvilGui(player, this);
|
||||
gui.setAction(event -> {
|
||||
this.templateName = gui.getInputText();
|
||||
|
||||
if (reason != null && templateName != null) {
|
||||
if (template == null)
|
||||
finishTemplate();
|
||||
else
|
||||
updateTemplate();
|
||||
}
|
||||
|
||||
justSaved = true;
|
||||
guiManager.showGUI(player, this);
|
||||
paint();
|
||||
});
|
||||
|
||||
ItemStack item = GuiUtils.createButtonItem(CompatibleMaterial.PAPER,
|
||||
template.getName() == null ? plugin.getLocale().getMessage("gui.general.templatename").getMessage() : template.getName());
|
||||
|
||||
gui.setInput(item);
|
||||
guiManager.showGUI(player, gui);
|
||||
}
|
||||
|
||||
private void updateTemplate() {
|
||||
Template template = new Template(this.type, this.duration, this.reason, this.template.getCreator(), this.templateName);
|
||||
plugin.getTemplateManager().updateTemplate(this.template.getId(), template);
|
||||
plugin.getDataManager().deleteTemplate(this.template);
|
||||
plugin.getDataManager().createTemplate(template);
|
||||
justSaved = true;
|
||||
if (toModerate == null)
|
||||
guiManager.showGUI(player, new TemplateManagerGui(plugin, player));
|
||||
}
|
||||
|
||||
private void finishTemplate() {
|
||||
Template template = new Template(this.type, this.duration, this.reason, player, templateName);
|
||||
plugin.getTemplateManager().addTemplate(template);
|
||||
plugin.getDataManager().createTemplate(template);
|
||||
this.template = template;
|
||||
if (toModerate == null)
|
||||
guiManager.showGUI(player, new TemplateManagerGui(plugin, player));
|
||||
}
|
||||
|
||||
public void setTemplate(Template template) {
|
||||
this.justSaved = true;
|
||||
this.template = template;
|
||||
}
|
||||
|
||||
public void setType(PunishmentType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public void setDuration(long duration) {
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public void setReason(String reason) {
|
||||
this.reason = reason;
|
||||
}
|
||||
}
|
@ -1,23 +1,24 @@
|
||||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.gui.Gui;
|
||||
import com.songoda.core.gui.GuiUtils;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.punish.AppliedPunishment;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentType;
|
||||
import com.songoda.ultimatemoderation.punish.player.PlayerPunishData;
|
||||
import com.songoda.ultimatemoderation.settings.Settings;
|
||||
import com.songoda.ultimatemoderation.utils.Methods;
|
||||
import com.songoda.ultimatemoderation.utils.gui.AbstractGUI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class GUIPunishments extends AbstractGUI {
|
||||
public class PunishmentsGui extends Gui {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
private final OfflinePlayer toModerate;
|
||||
@ -25,22 +26,40 @@ public class GUIPunishments extends AbstractGUI {
|
||||
private Activity currentActivity = Activity.BOTH;
|
||||
private PunishmentType punishmentType = PunishmentType.ALL;
|
||||
|
||||
private int page = 0;
|
||||
|
||||
public GUIPunishments(UltimateModeration plugin, OfflinePlayer toModerate, Player player) {
|
||||
super(player);
|
||||
public PunishmentsGui(UltimateModeration plugin, OfflinePlayer toModerate) {
|
||||
super(6);
|
||||
setDefaultItem(null);
|
||||
this.plugin = plugin;
|
||||
this.toModerate = toModerate;
|
||||
|
||||
init(plugin.getLocale().getMessage("gui.punishments.title")
|
||||
.processPlaceholder("toModerate", toModerate.getName()).getMessage(), 54);
|
||||
setTitle(plugin.getLocale().getMessage("gui.punishments.title")
|
||||
.processPlaceholder("toModerate", toModerate.getName()).getMessage());
|
||||
|
||||
showPage();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void constructGUI() {
|
||||
inventory.clear();
|
||||
resetClickables();
|
||||
registerClickables();
|
||||
protected void showPage() {
|
||||
if (inventory != null)
|
||||
inventory.clear();
|
||||
setActionForRange(0, 53, null);
|
||||
|
||||
|
||||
setNextPage(0, 5, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, plugin.getLocale().getMessage("gui.general.next").getMessage()));
|
||||
setPrevPage(0, 1, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, plugin.getLocale().getMessage("gui.general.back").getMessage()));
|
||||
setOnPage((event) -> showPage());
|
||||
|
||||
// decorate the edges
|
||||
ItemStack glass2 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_2.getMaterial(CompatibleMaterial.BLUE_STAINED_GLASS_PANE));
|
||||
ItemStack glass3 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_3.getMaterial(CompatibleMaterial.LIGHT_BLUE_STAINED_GLASS_PANE));
|
||||
|
||||
// edges will be type 3
|
||||
GuiUtils.mirrorFill(this, 0, 2, true, true, glass3);
|
||||
GuiUtils.mirrorFill(this, 1, 1, true, true, glass3);
|
||||
|
||||
// decorate corners with type 2
|
||||
GuiUtils.mirrorFill(this, 0, 0, true, true, glass2);
|
||||
GuiUtils.mirrorFill(this, 1, 0, true, true, glass2);
|
||||
GuiUtils.mirrorFill(this, 0, 1, true, true, glass2);
|
||||
|
||||
PlayerPunishData playerPunishData = plugin.getPunishmentManager().getPlayer(toModerate);
|
||||
|
||||
@ -67,39 +86,33 @@ public class GUIPunishments extends AbstractGUI {
|
||||
}
|
||||
|
||||
int numNotes = punishments.size();
|
||||
int maxPage = (int) Math.floor(numNotes / 36.0);
|
||||
this.pages = (int) Math.floor(numNotes / 28.0);
|
||||
|
||||
punishments = punishments.stream().skip(page * 36).limit(36)
|
||||
punishments = punishments.stream().skip((page - 1) * 28).limit(28)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (page != 0) {
|
||||
createButton(1, Material.ARROW, plugin.getLocale().getMessage("gui.general.previous").getMessage());
|
||||
registerClickable(1, ((player1, inventory1, cursor, slot, type) -> {
|
||||
page--;
|
||||
constructGUI();
|
||||
}));
|
||||
}
|
||||
setButton(5,4, GuiUtils.createButtonItem(CompatibleMaterial.OAK_DOOR,
|
||||
plugin.getLocale().getMessage("gui.general.back").getMessage()),
|
||||
(event) -> guiManager.showGUI(event.player, new PlayerGui(plugin, toModerate, event.player)));
|
||||
|
||||
if (page != maxPage) {
|
||||
createButton(6, Material.ARROW, plugin.getLocale().getMessage("gui.general.next").getMessage());
|
||||
registerClickable(6, ((player1, inventory1, cursor, slot, type) -> {
|
||||
page++;
|
||||
constructGUI();
|
||||
}));
|
||||
}
|
||||
setButton(5,3, GuiUtils.createButtonItem(CompatibleMaterial.APPLE, Methods.formatText("&6" + currentActivity.getTranslation())),
|
||||
(event) -> {
|
||||
this.currentActivity = currentActivity.next();
|
||||
this.page = 1;
|
||||
showPage();
|
||||
});
|
||||
|
||||
createButton(8, ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)
|
||||
? Material.OAK_DOOR
|
||||
: Material.valueOf("WOOD_DOOR"), plugin.getLocale().getMessage("gui.general.back").getMessage());
|
||||
setButton(5,5, GuiUtils.createButtonItem(CompatibleMaterial.DIAMOND_SWORD, Methods.formatText("&6" + punishmentType.name())),
|
||||
(event) -> {
|
||||
this.punishmentType = punishmentType.nextFilter();
|
||||
this.page = 1;
|
||||
showPage();
|
||||
});
|
||||
|
||||
createButton(3, Material.APPLE, Methods.formatText("&6" + currentActivity.getTranslation()));
|
||||
createButton(4, Material.DIAMOND_SWORD, Methods.formatText("&6" + punishmentType.name()));
|
||||
|
||||
for (int i = 0; i < 9; i++)
|
||||
createButton(9 + i, ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.GRAY_STAINED_GLASS_PANE : new ItemStack(Material.valueOf("STAINED_GLASS_PANE")), "&1");
|
||||
|
||||
int currentSlot = 18;
|
||||
int num = 11;
|
||||
for (PunishmentHolder punishmentHolder : punishments) {
|
||||
if (num == 16 || num == 36)
|
||||
num = num + 2;
|
||||
AppliedPunishment appliedPunishment = punishmentHolder.getAppliedPunishment();
|
||||
Activity activity = punishmentHolder.getActivity();
|
||||
|
||||
@ -112,7 +125,7 @@ public class GUIPunishments extends AbstractGUI {
|
||||
lore.add(plugin.getLocale().getMessage("gui.punishments.duration").getMessage());
|
||||
lore.add("&7" + (appliedPunishment.getDuration() != -1
|
||||
? Methods.makeReadable(appliedPunishment.getDuration())
|
||||
: plugin.getLocale().getMessage("gui.general.permanent")));
|
||||
: plugin.getLocale().getMessage("gui.general.permanent").getMessage()));
|
||||
lore.add("");
|
||||
lore.add(plugin.getLocale().getMessage("gui.punishments.punisher").getMessage());
|
||||
lore.add("&7" + (appliedPunishment.getPunisher() == null ? "Console" : Bukkit.getOfflinePlayer(appliedPunishment.getPunisher()).getName()));
|
||||
@ -124,43 +137,26 @@ public class GUIPunishments extends AbstractGUI {
|
||||
lore.add("");
|
||||
}
|
||||
lore.add(plugin.getLocale().getMessage("gui.punishments.click").getMessage());
|
||||
|
||||
registerClickable(currentSlot, ((player1, inventory1, cursor, slot, type) -> {
|
||||
appliedPunishment.expire();
|
||||
constructGUI();
|
||||
}));
|
||||
}
|
||||
}
|
||||
lore.add("");
|
||||
createButton(currentSlot, Material.MAP,
|
||||
"&6&l" + appliedPunishment.getPunishmentType().getTranslation() + " - &7&l" + activity.getTranslation(), lore);
|
||||
setButton(num, GuiUtils.createButtonItem(CompatibleMaterial.MAP,
|
||||
TextUtils.formatText("&6&l" + appliedPunishment.getPunishmentType().getTranslation() + " - &7&l" + activity.getTranslation()),
|
||||
TextUtils.formatText(lore)),
|
||||
(event) -> {
|
||||
if (appliedPunishment.getPunishmentType() != PunishmentType.KICK
|
||||
&& activity == Activity.ACTIVE) {
|
||||
appliedPunishment.expire();
|
||||
plugin.getDataManager().updateAppliedPunishment(appliedPunishment);
|
||||
showPage();
|
||||
}
|
||||
});
|
||||
|
||||
currentSlot++;
|
||||
num ++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerClickables() {
|
||||
registerClickable(8, ((player1, inventory1, cursor, slot, type) ->
|
||||
new GUIPlayer(plugin, toModerate, player)));
|
||||
|
||||
registerClickable(3, ((player1, inventory1, cursor, slot, type) -> {
|
||||
this.currentActivity = currentActivity.next();
|
||||
this.page = 0;
|
||||
constructGUI();
|
||||
}));
|
||||
|
||||
registerClickable(4, ((player1, inventory1, cursor, slot, type) -> {
|
||||
this.punishmentType = punishmentType.nextFilter();
|
||||
this.page = 0;
|
||||
constructGUI();
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerOnCloses() {
|
||||
}
|
||||
|
||||
private class PunishmentHolder {
|
||||
|
@ -0,0 +1,104 @@
|
||||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.gui.Gui;
|
||||
import com.songoda.core.gui.GuiUtils;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentNote;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentType;
|
||||
import com.songoda.ultimatemoderation.punish.template.Template;
|
||||
import com.songoda.ultimatemoderation.settings.Settings;
|
||||
import com.songoda.ultimatemoderation.utils.Methods;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class TemplateManagerGui extends Gui {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
private PunishmentType punishmentType = PunishmentType.ALL;
|
||||
private final Player player;
|
||||
|
||||
public TemplateManagerGui(UltimateModeration plugin, Player player) {
|
||||
super(6);
|
||||
setDefaultItem(null);
|
||||
this.plugin = plugin;
|
||||
this.player = player;
|
||||
|
||||
setTitle(plugin.getLocale().getMessage("gui.templatemanager.title").getMessage());
|
||||
showPage();
|
||||
}
|
||||
|
||||
protected void showPage() {
|
||||
if (inventory != null)
|
||||
inventory.clear();
|
||||
setActionForRange(0, 53, null);
|
||||
|
||||
int numTemplates = plugin.getTemplateManager().getTemplates().size();
|
||||
this.pages = (int) Math.floor(numTemplates / 28.0);
|
||||
|
||||
List<Template> templates = plugin.getTemplateManager().getTemplates().values().stream().skip((page - 1) * 28).limit(28)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
setNextPage(0, 5, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, plugin.getLocale().getMessage("gui.general.next").getMessage()));
|
||||
setPrevPage(0, 1, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, plugin.getLocale().getMessage("gui.general.back").getMessage()));
|
||||
setOnPage((event) -> showPage());
|
||||
|
||||
// decorate the edges
|
||||
ItemStack glass2 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_2.getMaterial(CompatibleMaterial.BLUE_STAINED_GLASS_PANE));
|
||||
ItemStack glass3 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_3.getMaterial(CompatibleMaterial.LIGHT_BLUE_STAINED_GLASS_PANE));
|
||||
|
||||
// edges will be type 3
|
||||
GuiUtils.mirrorFill(this, 0, 2, true, true, glass3);
|
||||
GuiUtils.mirrorFill(this, 1, 1, true, true, glass3);
|
||||
|
||||
// decorate corners with type 2
|
||||
GuiUtils.mirrorFill(this, 0, 0, true, true, glass2);
|
||||
GuiUtils.mirrorFill(this, 1, 0, true, true, glass2);
|
||||
GuiUtils.mirrorFill(this, 0, 1, true, true, glass2);
|
||||
|
||||
setButton(5, 3, GuiUtils.createButtonItem(CompatibleMaterial.DIAMOND_SWORD, Methods.formatText("&6" + punishmentType.name())),
|
||||
(event) -> {
|
||||
this.punishmentType = punishmentType.nextFilter();
|
||||
this.page = 1;
|
||||
showPage();
|
||||
});
|
||||
|
||||
setButton(5, 4, GuiUtils.createButtonItem(CompatibleMaterial.OAK_DOOR,
|
||||
plugin.getLocale().getMessage("gui.general.back").getMessage()),
|
||||
(event) -> guiManager.showGUI(event.player, new MainGui(plugin, event.player)));
|
||||
|
||||
if (player.hasPermission("um.templates.create"))
|
||||
setButton(5, 5, GuiUtils.createButtonItem(CompatibleMaterial.REDSTONE,
|
||||
plugin.getLocale().getMessage("gui.templatemanager.create").getMessage()),
|
||||
(event) -> guiManager.showGUI(event.player, new PunishGui(plugin, null, null, player)));
|
||||
|
||||
if (punishmentType != PunishmentType.ALL)
|
||||
templates.removeIf(template -> template.getPunishmentType() != punishmentType);
|
||||
int num = 11;
|
||||
for (Template template : templates) {
|
||||
if (num == 16 || num == 36)
|
||||
num = num + 2;
|
||||
setButton(num, GuiUtils.createButtonItem(CompatibleMaterial.MAP, TextUtils.formatText("&6&l" + template.getName()),
|
||||
plugin.getLocale().getMessage("gui.templatemanager.leftclick").getMessage(),
|
||||
plugin.getLocale().getMessage("gui.templatemanager.rightclick").getMessage()),
|
||||
(event) -> {
|
||||
if (event.clickType == ClickType.LEFT) {
|
||||
if (player.hasPermission("um.templates.edit"))
|
||||
guiManager.showGUI(player, new PunishGui(plugin, null, template, player));
|
||||
} else if (event.clickType == ClickType.RIGHT) {
|
||||
if (player.hasPermission("um.templates.destroy"))
|
||||
plugin.getTemplateManager().removeTemplate(template);
|
||||
showPage();
|
||||
}
|
||||
});
|
||||
num ++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.gui.Gui;
|
||||
import com.songoda.core.gui.GuiUtils;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.punish.template.Template;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class TemplateSelectorGui extends Gui {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
private PunishGui punish;
|
||||
|
||||
public TemplateSelectorGui(UltimateModeration plugin, PunishGui punish, Player player) {
|
||||
super(6);
|
||||
setDefaultItem(null);
|
||||
this.plugin = plugin;
|
||||
this.punish = punish;
|
||||
|
||||
setTitle(plugin.getLocale().getMessage("gui.templateselector.title").getMessage());
|
||||
paint();
|
||||
}
|
||||
|
||||
private void paint() {
|
||||
setButton(8, GuiUtils.createButtonItem(CompatibleMaterial.OAK_DOOR,
|
||||
plugin.getLocale().getMessage("gui.general.back").getMessage()),
|
||||
(event) -> {
|
||||
guiManager.showGUI(event.player, punish);
|
||||
punish.runTask();
|
||||
});
|
||||
|
||||
ArrayList<Template> templates = new ArrayList<>(plugin.getTemplateManager().getTemplates().values());
|
||||
for (int i = 0; i < templates.size(); i++) {
|
||||
Template template = templates.get(i);
|
||||
setButton(18 + i, GuiUtils.createButtonItem(CompatibleMaterial.MAP, TextUtils.formatText("&6&l" + template.getName()),
|
||||
plugin.getLocale().getMessage("gui.templateselector.click").getMessage()),
|
||||
(event) -> {
|
||||
punish.setType(template.getPunishmentType());
|
||||
punish.setDuration(template.getDuration());
|
||||
punish.setReason(template.getReason());
|
||||
punish.setTemplate(template);
|
||||
punish.runTask();
|
||||
punish.paint();
|
||||
guiManager.showGUI(event.player, punish);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
153
src/main/java/com/songoda/ultimatemoderation/gui/TicketGui.java
Normal file
153
src/main/java/com/songoda/ultimatemoderation/gui/TicketGui.java
Normal file
@ -0,0 +1,153 @@
|
||||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.gui.Gui;
|
||||
import com.songoda.core.gui.GuiUtils;
|
||||
import com.songoda.core.input.ChatPrompt;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.settings.Settings;
|
||||
import com.songoda.ultimatemoderation.staffchat.StaffChatManager;
|
||||
import com.songoda.ultimatemoderation.tickets.Ticket;
|
||||
import com.songoda.ultimatemoderation.tickets.TicketResponse;
|
||||
import com.songoda.ultimatemoderation.tickets.TicketStatus;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class TicketGui extends Gui {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
private StaffChatManager chatManager = UltimateModeration.getInstance().getStaffChatManager();
|
||||
|
||||
private final Ticket ticket;
|
||||
|
||||
private final Player player;
|
||||
private final OfflinePlayer toModerate;
|
||||
|
||||
|
||||
public TicketGui(UltimateModeration plugin, Ticket ticket, OfflinePlayer toModerate, Player player) {
|
||||
super(6);
|
||||
setDefaultItem(null);
|
||||
this.ticket = ticket;
|
||||
this.plugin = plugin;
|
||||
this.player = player;
|
||||
this.toModerate = toModerate;
|
||||
|
||||
setTitle(plugin.getLocale().getMessage("gui.ticket.title")
|
||||
.processPlaceholder("subject", ticket.getSubject())
|
||||
.processPlaceholder("id", ticket.getId()).getMessage());
|
||||
|
||||
showPage();
|
||||
}
|
||||
|
||||
private void showPage() {
|
||||
if (inventory != null)
|
||||
inventory.clear();
|
||||
setActionForRange(0, 53, null);
|
||||
|
||||
int numNotes = ticket.getResponses().size();
|
||||
this.pages = (int) Math.floor(numNotes / 28.0);
|
||||
|
||||
List<TicketResponse> responses = ticket.getResponses().stream().skip((page - 1) * 28).limit(28)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// decorate the edges
|
||||
ItemStack glass2 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_2.getMaterial(CompatibleMaterial.BLUE_STAINED_GLASS_PANE));
|
||||
ItemStack glass3 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_3.getMaterial(CompatibleMaterial.LIGHT_BLUE_STAINED_GLASS_PANE));
|
||||
|
||||
// edges will be type 3
|
||||
GuiUtils.mirrorFill(this, 0, 2, true, true, glass3);
|
||||
GuiUtils.mirrorFill(this, 1, 1, true, true, glass3);
|
||||
|
||||
// decorate corners with type 2
|
||||
GuiUtils.mirrorFill(this, 0, 0, true, true, glass2);
|
||||
GuiUtils.mirrorFill(this, 1, 0, true, true, glass2);
|
||||
GuiUtils.mirrorFill(this, 0, 1, true, true, glass2);
|
||||
|
||||
// enable page event
|
||||
setNextPage(4, 7, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, plugin.getLocale().getMessage("gui.general.next").getMessage()));
|
||||
setPrevPage(4, 1, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, plugin.getLocale().getMessage("gui.general.back").getMessage()));
|
||||
setOnPage((event) -> showPage());
|
||||
|
||||
if (player.hasPermission("um.tickets.openclose"))
|
||||
setButton(5, 3, GuiUtils.createButtonItem(CompatibleMaterial.LEVER, TextUtils.formatText("&6" + ticket.getStatus().getStatus())),
|
||||
(event) -> {
|
||||
ticket.setStatus(ticket.getStatus() == TicketStatus.OPEN ? TicketStatus.CLOSED : TicketStatus.OPEN);
|
||||
plugin.getDataManager().updateTicket(ticket);
|
||||
// Notify staff of ticket status
|
||||
chatManager.getChat("ticket").messageAll(UltimateModeration.getInstance().getLocale().getMessage("notify.ticket.status").getMessage().replace("%tid%", "" + ticket.getId()).replace("%type%", ticket.getType()).replace("%player%", Bukkit.getPlayer(ticket.getVictim()).getDisplayName()).replace("%status%", ticket.getStatus().toString()));
|
||||
showPage();
|
||||
});
|
||||
|
||||
setButton(4, GuiUtils.createButtonItem(CompatibleMaterial.OAK_DOOR,
|
||||
plugin.getLocale().getMessage("gui.general.back").getMessage()),
|
||||
(event) -> {
|
||||
plugin.getGuiManager().showGUI(event.player, new TicketManagerGui(plugin, toModerate, event.player));
|
||||
});
|
||||
|
||||
if (player.hasPermission("um.ticket.clicktotele") && ticket.getLocation() != null)
|
||||
setButton(5, 5, GuiUtils.createButtonItem(CompatibleMaterial.ENDER_PEARL,
|
||||
plugin.getLocale().getMessage("gui.ticket.clicktotele").getMessage()),
|
||||
(event) -> player.teleport(ticket.getLocation()));
|
||||
|
||||
if (player.hasPermission("um.tickets.respond"))
|
||||
setButton(5,4, GuiUtils.createButtonItem(CompatibleMaterial.WRITABLE_BOOK, plugin.getLocale().getMessage("gui.ticket.respond").getMessage()),
|
||||
(event) -> {
|
||||
ChatPrompt.showPrompt(plugin, player, plugin.getLocale().getMessage("gui.ticket.what").getMessage(), (evnt) -> {
|
||||
TicketResponse response = ticket.addResponse(new TicketResponse(player, evnt.getMessage(), System.currentTimeMillis()));
|
||||
plugin.getDataManager().createTicketResponse(response);
|
||||
// Notify staff of ticket response.
|
||||
chatManager.getChat("ticket").messageAll(UltimateModeration.getInstance().getLocale().getMessage("notify.ticket.response").getMessage().replace("%tid%", "" + ticket.getId()).replace("%type%", ticket.getType()).replace("%player%", Bukkit.getPlayer(ticket.getVictim()).getDisplayName()));
|
||||
showPage();
|
||||
}).setOnClose(() -> guiManager.showGUI(event.player, this));
|
||||
});
|
||||
|
||||
|
||||
int num = 11;
|
||||
for (TicketResponse ticketResponse : responses) {
|
||||
if (num == 16 || num == 36)
|
||||
num = num + 2;
|
||||
|
||||
String subjectStr = ticketResponse.getMessage();
|
||||
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
int lastIndex = 0;
|
||||
for (int n = 0; n < subjectStr.length(); n++) {
|
||||
if (n - lastIndex < 20)
|
||||
continue;
|
||||
|
||||
if (subjectStr.charAt(n) == ' ') {
|
||||
lore.add(TextUtils.formatText("&6" + subjectStr.substring(lastIndex, n).trim()));
|
||||
lastIndex = n;
|
||||
}
|
||||
}
|
||||
|
||||
if (lastIndex - subjectStr.length() < 20)
|
||||
lore.add(TextUtils.formatText("&6" + subjectStr.substring(lastIndex).trim()));
|
||||
|
||||
String name = lore.get(0);
|
||||
lore.remove(0);
|
||||
|
||||
lore.add("");
|
||||
|
||||
SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy");
|
||||
|
||||
|
||||
lore.add(plugin.getLocale().getMessage("gui.ticket.postedby")
|
||||
.processPlaceholder("player", Bukkit.getOfflinePlayer(ticketResponse.getAuthor()).getName()).getMessage());
|
||||
lore.add(plugin.getLocale().getMessage("gui.ticket.createdon")
|
||||
.processPlaceholder("sent", format.format(new Date(ticketResponse.getPostedDate()))).getMessage());
|
||||
|
||||
setItem(num, GuiUtils.createButtonItem(CompatibleMaterial.MAP, TextUtils.formatText(name), lore));
|
||||
num ++;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,165 @@
|
||||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.gui.AnvilGui;
|
||||
import com.songoda.core.gui.Gui;
|
||||
import com.songoda.core.gui.GuiUtils;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.settings.Settings;
|
||||
import com.songoda.ultimatemoderation.tickets.Ticket;
|
||||
import com.songoda.ultimatemoderation.tickets.TicketStatus;
|
||||
import com.songoda.ultimatemoderation.utils.Methods;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class TicketManagerGui extends Gui {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
private final OfflinePlayer toModerate;
|
||||
|
||||
private TicketStatus status = TicketStatus.OPEN;
|
||||
|
||||
private final Player player;
|
||||
|
||||
public TicketManagerGui(UltimateModeration plugin, OfflinePlayer toModerate, Player player) {
|
||||
super(6);
|
||||
setDefaultItem(null);
|
||||
this.plugin = plugin;
|
||||
this.toModerate = toModerate;
|
||||
this.player = player;
|
||||
|
||||
setTitle(plugin.getLocale().getMessage(toModerate != null ? "gui.tickets.titlesingle" : "gui.tickets.title")
|
||||
.processPlaceholder("toModerate", toModerate != null ? toModerate.getName() : "").getMessage());
|
||||
showPage();
|
||||
}
|
||||
|
||||
private void showPage() {
|
||||
if (inventory != null)
|
||||
inventory.clear();
|
||||
setActionForRange(0, 53, null);
|
||||
|
||||
List<Ticket> tickets = toModerate != null
|
||||
? plugin.getTicketManager().getTicketsAbout(toModerate, status)
|
||||
: plugin.getTicketManager().getTickets(status);
|
||||
|
||||
int numTickets = tickets.size();
|
||||
this.pages = (int) Math.floor(numTickets / 28.0);
|
||||
|
||||
tickets = tickets.stream().skip((page - 1) * 28).limit(28).collect(Collectors.toList());
|
||||
|
||||
// decorate the edges
|
||||
ItemStack glass2 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_2.getMaterial(CompatibleMaterial.BLUE_STAINED_GLASS_PANE));
|
||||
ItemStack glass3 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_3.getMaterial(CompatibleMaterial.LIGHT_BLUE_STAINED_GLASS_PANE));
|
||||
|
||||
// edges will be type 3
|
||||
GuiUtils.mirrorFill(this, 0, 2, true, true, glass3);
|
||||
GuiUtils.mirrorFill(this, 1, 1, true, true, glass3);
|
||||
|
||||
// decorate corners with type 2
|
||||
GuiUtils.mirrorFill(this, 0, 0, true, true, glass2);
|
||||
GuiUtils.mirrorFill(this, 1, 0, true, true, glass2);
|
||||
GuiUtils.mirrorFill(this, 0, 1, true, true, glass2);
|
||||
|
||||
// enable page event
|
||||
setNextPage(4, 7, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, plugin.getLocale().getMessage("gui.general.next").getMessage()));
|
||||
setPrevPage(4, 1, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, plugin.getLocale().getMessage("gui.general.back").getMessage()));
|
||||
setOnPage((event) -> showPage());
|
||||
|
||||
setButton(5, 3, GuiUtils.createButtonItem(CompatibleMaterial.LEVER, TextUtils.formatText("&6" + status.getStatus())),
|
||||
(event) -> {
|
||||
this.status = status == TicketStatus.OPEN ? TicketStatus.CLOSED : TicketStatus.OPEN;
|
||||
this.page = 1;
|
||||
showPage();
|
||||
});
|
||||
|
||||
if (toModerate != null && player.hasPermission("um.tickets.create"))
|
||||
setButton(5,5, GuiUtils.createButtonItem(CompatibleMaterial.REDSTONE,
|
||||
plugin.getLocale().getMessage("gui.tickets.create").getMessage()),
|
||||
(event) -> createNew(player, toModerate));
|
||||
|
||||
if (player.hasPermission("um.ticket"))
|
||||
setButton(5, 4, GuiUtils.createButtonItem(CompatibleMaterial.OAK_DOOR,
|
||||
plugin.getLocale().getMessage("gui.general.back").getMessage()),
|
||||
(event) -> {
|
||||
if (toModerate == null)
|
||||
plugin.getGuiManager().showGUI(player, new MainGui(plugin, player));
|
||||
else
|
||||
plugin.getGuiManager().showGUI(event.player, new PlayerGui(plugin, toModerate, event.player));
|
||||
});
|
||||
|
||||
int num = 11;
|
||||
for (Ticket ticket : tickets) {
|
||||
if (num == 16 || num == 36)
|
||||
num = num + 2;
|
||||
|
||||
String subjectStr = ticket.getSubject();
|
||||
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
int lastIndex = 0;
|
||||
for (int n = 0; n < subjectStr.length(); n++) {
|
||||
if (n - lastIndex < 20)
|
||||
continue;
|
||||
|
||||
if (subjectStr.charAt(n) == ' ') {
|
||||
lore.add("&6" + subjectStr.substring(lastIndex, n).trim());
|
||||
lastIndex = n;
|
||||
}
|
||||
}
|
||||
|
||||
if (lastIndex - subjectStr.length() < 20)
|
||||
lore.add("&6" + subjectStr.substring(lastIndex).trim() + " &7- " + ticket.getId());
|
||||
|
||||
String name = lore.get(0);
|
||||
lore.remove(0);
|
||||
|
||||
lore.add("");
|
||||
|
||||
SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy");
|
||||
|
||||
lore.add(plugin.getLocale().getMessage("gui.ticket.status")
|
||||
.processPlaceholder("status", ticket.getStatus().getStatus()).getMessage());
|
||||
|
||||
if (toModerate != null)
|
||||
lore.add(plugin.getLocale().getMessage("gui.tickets.player")
|
||||
.processPlaceholder("player", Bukkit.getOfflinePlayer(ticket.getVictim()).getName()).getMessage());
|
||||
lore.add(plugin.getLocale().getMessage("gui.ticket.type")
|
||||
.processPlaceholder("type", ticket.getType()).getMessage());
|
||||
lore.add(plugin.getLocale().getMessage("gui.ticket.createdon")
|
||||
.processPlaceholder("sent", format.format(new Date(ticket.getCreationDate()))).getMessage());
|
||||
lore.add(plugin.getLocale().getMessage("gui.tickets.click").getMessage());
|
||||
|
||||
setButton(num, GuiUtils.createButtonItem(CompatibleMaterial.MAP,
|
||||
TextUtils.formatText(name), TextUtils.formatText(lore)),
|
||||
(event) -> guiManager.showGUI(player, new TicketGui(plugin, ticket, toModerate, player)));
|
||||
num ++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void createNew(Player player, OfflinePlayer toModerate) {
|
||||
UltimateModeration plugin = UltimateModeration.getInstance();
|
||||
|
||||
AnvilGui gui = new AnvilGui(player);
|
||||
gui.setAction((event) ->
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () ->
|
||||
plugin.getGuiManager().showGUI(player,
|
||||
new TicketTypeGui(plugin, toModerate, player, gui.getInputText())), 1L));
|
||||
|
||||
ItemStack item = GuiUtils.createButtonItem(CompatibleMaterial.PAPER,
|
||||
plugin.getLocale().getMessage("gui.tickets.subject").getMessage());
|
||||
|
||||
gui.setInput(item);
|
||||
plugin.getGuiManager().showGUI(player, gui);
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.gui.Gui;
|
||||
import com.songoda.core.gui.GuiUtils;
|
||||
import com.songoda.core.input.ChatPrompt;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.settings.Settings;
|
||||
import com.songoda.ultimatemoderation.staffchat.StaffChatManager;
|
||||
import com.songoda.ultimatemoderation.tickets.Ticket;
|
||||
import com.songoda.ultimatemoderation.tickets.TicketResponse;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TicketTypeGui extends Gui {
|
||||
|
||||
private final StaffChatManager chatManager = UltimateModeration.getInstance().getStaffChatManager();
|
||||
|
||||
public TicketTypeGui(UltimateModeration plugin, OfflinePlayer toModerate, Player player, String subject) {
|
||||
super(3);
|
||||
setDefaultItem(null);
|
||||
|
||||
setTitle(plugin.getLocale().getMessage("gui.ticket.picktype").getMessage());
|
||||
|
||||
|
||||
List<String> types = Settings.TICKET_TYPES.getStringList();
|
||||
|
||||
for (int i = 0; i < types.size(); i++) {
|
||||
final int fi = i;
|
||||
setButton(i, GuiUtils.createButtonItem(CompatibleMaterial.PAPER, types.get(i)),
|
||||
(event) -> {
|
||||
Ticket ticket = new Ticket(toModerate, subject, types.get(fi));
|
||||
ChatPrompt.showPrompt(plugin,
|
||||
player, plugin.getLocale().getMessage("gui.tickets.what").getMessage(),
|
||||
event2 -> {
|
||||
plugin.getTicketManager().addTicket(ticket);
|
||||
|
||||
// Notify staff
|
||||
chatManager.getChat("ticket").messageAll(UltimateModeration.getInstance().getLocale().getMessage("notify.ticket.created").getMessage().replace("%tid%", "" + ticket.getId()).replace("%type%", ticket.getType()).replace("%player%", Bukkit.getPlayer(ticket.getVictim()).getDisplayName()));
|
||||
if (player == toModerate)
|
||||
ticket.setLocation(player.getLocation());
|
||||
ticket.addResponse(new TicketResponse(player, event2.getMessage(), System.currentTimeMillis()));
|
||||
plugin.getDataManager().createTicket(ticket);
|
||||
}).setOnClose(() ->
|
||||
guiManager.showGUI(event.player, new TicketGui(plugin, ticket, toModerate, player)));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
package com.songoda.ultimatemoderation.listeners;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.commands.CommandCommandSpy;
|
||||
import com.songoda.ultimatemoderation.moderate.moderations.SpyModeration;
|
||||
import com.songoda.ultimatemoderation.punish.AppliedPunishment;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentType;
|
||||
import com.songoda.ultimatemoderation.settings.Settings;
|
||||
@ -49,7 +49,7 @@ public class CommandListener implements Listener {
|
||||
|
||||
if (!player.hasPermission("um.commandspy.immune")) {
|
||||
for (Player pl : Bukkit.getOnlinePlayers()) {
|
||||
if (pl != player && pl.hasPermission("um.commandspy") && CommandCommandSpy.isSpying(pl))
|
||||
if (pl != player && pl.hasPermission("um.commandspy") && SpyModeration.isSpying(pl))
|
||||
instance.getLocale().getMessage("command.commandspy.deny")
|
||||
.processPlaceholder("player", player.getName())
|
||||
.processPlaceholder("command", command)
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.songoda.ultimatemoderation.listeners;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.commands.CommandFreeze;
|
||||
import com.songoda.ultimatemoderation.moderate.moderations.FreezeModeration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -18,7 +18,7 @@ public class DropListener implements Listener {
|
||||
@EventHandler
|
||||
public void onMove(PlayerDropItemEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (CommandFreeze.isFrozen(player)) {
|
||||
if (FreezeModeration.isFrozen(player)) {
|
||||
event.setCancelled(true);
|
||||
instance.getLocale().getMessage("command.freeze.nope").sendPrefixedMessage(player);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.songoda.ultimatemoderation.listeners;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.commands.CommandFreeze;
|
||||
import com.songoda.ultimatemoderation.moderate.moderations.FreezeModeration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -9,19 +9,19 @@ import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
|
||||
public class InventoryListener implements Listener {
|
||||
|
||||
private UltimateModeration instance;
|
||||
private UltimateModeration plugin;
|
||||
|
||||
public InventoryListener(UltimateModeration ultimateModeration) {
|
||||
this.instance = ultimateModeration;
|
||||
this.plugin = ultimateModeration;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onMove(InventoryClickEvent event) {
|
||||
if (!(event.getWhoClicked() instanceof Player)) return;
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
if (CommandFreeze.isFrozen(player)) {
|
||||
if (FreezeModeration.isFrozen(player)) {
|
||||
event.setCancelled(true);
|
||||
instance.getLocale().getMessage("command.freeze.nope").sendPrefixedMessage(player);
|
||||
plugin.getLocale().getMessage("command.freeze.nope").sendPrefixedMessage(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.songoda.ultimatemoderation.listeners;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.commands.CommandFreeze;
|
||||
import com.songoda.ultimatemoderation.moderate.moderations.FreezeModeration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -18,7 +18,7 @@ public class MoveListener implements Listener {
|
||||
@EventHandler
|
||||
public void onMove(PlayerMoveEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (CommandFreeze.isFrozen(player)) {
|
||||
if (FreezeModeration.isFrozen(player)) {
|
||||
event.setCancelled(true);
|
||||
instance.getLocale().getMessage("command.freeze.nope").sendPrefixedMessage(player);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.songoda.ultimatemoderation.listeners;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.commands.CommandSpy;
|
||||
import com.songoda.ultimatemoderation.moderate.moderations.SpyModeration;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -24,7 +24,7 @@ public class SpyingDismountListener implements Listener {
|
||||
public void onEntityDismountEvent(EntityDismountEvent event) {
|
||||
if (!(event.getDismounted() instanceof Player)) return;
|
||||
if (!(event.getEntity() instanceof Player)) return;
|
||||
if (CommandSpy.isSpying((((Player) event.getEntity()).getPlayer()))) {
|
||||
if (SpyModeration.isSpying((((Player) event.getEntity()).getPlayer()))) {
|
||||
Player player = (Player) event.getEntity();
|
||||
gamemodes.put(player.getUniqueId(), player.getGameMode());
|
||||
player.setGameMode(GameMode.SPECTATOR);
|
||||
@ -39,8 +39,8 @@ public class SpyingDismountListener implements Listener {
|
||||
@EventHandler
|
||||
public void onSneak(PlayerToggleSneakEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (player.isSneaking() || !CommandSpy.isSpying(player) || player.getGameMode() != GameMode.SPECTATOR) return;
|
||||
CommandSpy.spy(null, player);
|
||||
if (player.isSneaking() || !SpyModeration.isSpying(player) || player.getGameMode() != GameMode.SPECTATOR) return;
|
||||
SpyModeration.spy(null, player);
|
||||
}
|
||||
|
||||
public static Map<UUID, GameMode> getGamemodes() {
|
||||
|
@ -0,0 +1,68 @@
|
||||
package com.songoda.ultimatemoderation.moderate;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.utils.VaultPermissions;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public abstract class AbstractModeration {
|
||||
|
||||
protected final UltimateModeration plugin;
|
||||
private final boolean requireOnline, allowConsole;
|
||||
|
||||
protected AbstractModeration(UltimateModeration plugin, boolean requireOnline, boolean allowConsole) {
|
||||
this.plugin = plugin;
|
||||
this.requireOnline = requireOnline;
|
||||
this.allowConsole = allowConsole;
|
||||
}
|
||||
|
||||
public abstract ModerationType getType();
|
||||
|
||||
public abstract CompatibleMaterial getIcon();
|
||||
|
||||
public abstract String getProper();
|
||||
|
||||
public abstract String getDescription();
|
||||
|
||||
public String getPermission() {
|
||||
return "ultimatemoderation." + getType().name().toLowerCase();
|
||||
}
|
||||
|
||||
public boolean hasPermission(Player player) {
|
||||
return player.hasPermission(getPermission());
|
||||
}
|
||||
|
||||
public boolean isExempt(OfflinePlayer player) {
|
||||
return VaultPermissions.hasPermission(player, "ultimatemoderation." + getType().name().toLowerCase() + ".exempt");
|
||||
}
|
||||
|
||||
protected void registerCommand(UltimateModeration plugin) {
|
||||
plugin.getCommandManager().addCommand(new GenericModerationCommand(plugin, this));
|
||||
}
|
||||
|
||||
public boolean runPreModeration(CommandSender runner, OfflinePlayer toModerate) {
|
||||
if (requireOnline && !toModerate.isOnline()) {
|
||||
plugin.getLocale().newMessage(toModerate.getName() + " must be online for this moderation.").sendPrefixedMessage(runner);
|
||||
}
|
||||
|
||||
if (isExempt(toModerate)) {
|
||||
plugin.getLocale().newMessage(toModerate.getName() + " is exempt from this moderation.").sendPrefixedMessage(runner);
|
||||
return false;
|
||||
}
|
||||
|
||||
return runModeration(runner, toModerate);
|
||||
}
|
||||
|
||||
protected abstract boolean runModeration(CommandSender runner, OfflinePlayer toModerate);
|
||||
|
||||
public boolean isRequireOnline() {
|
||||
return requireOnline;
|
||||
}
|
||||
|
||||
public boolean isAllowConsole() {
|
||||
return allowConsole;
|
||||
}
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package com.songoda.ultimatemoderation.moderate;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GenericModerationCommand extends AbstractCommand {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
private final AbstractModeration moderation;
|
||||
|
||||
public GenericModerationCommand(UltimateModeration plugin, AbstractModeration moderation) {
|
||||
super(moderation.isAllowConsole() ? CommandType.CONSOLE_OK : CommandType.PLAYER_ONLY, moderation.getProper());
|
||||
this.plugin = plugin;
|
||||
this.moderation = moderation;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length != 1)
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(args[0]);
|
||||
|
||||
if (!player.hasPlayedBefore()) {
|
||||
plugin.getLocale().newMessage("&cThis player has never played this server before...");
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
moderation.runPreModeration(sender, player);
|
||||
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender sender, String... args) {
|
||||
if (args.length == 1) {
|
||||
List<String> players = new ArrayList<>();
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
players.add(player.getName());
|
||||
}
|
||||
return players;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return moderation.getPermission();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/" + moderation.getProper() + " <player>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return moderation.getDescription();
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package com.songoda.ultimatemoderation.moderate;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.moderate.moderations.*;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public class ModerationManager {
|
||||
|
||||
private static final Map<ModerationType, AbstractModeration> moderations = new TreeMap<>();
|
||||
|
||||
public ModerationManager(UltimateModeration plugin) {
|
||||
|
||||
addAllModerations(new FreezeModeration(plugin),
|
||||
new ReviveModeration(plugin),
|
||||
new InvSeeModeration(plugin),
|
||||
new ViewEnderChestModeration(plugin),
|
||||
new SpyModeration(plugin));
|
||||
}
|
||||
|
||||
public AbstractModeration addModeration(AbstractModeration moderation) {
|
||||
return moderations.put(moderation.getType(), moderation);
|
||||
}
|
||||
|
||||
public void addAllModerations(AbstractModeration... moderations) {
|
||||
for (AbstractModeration moderation : moderations) {
|
||||
ModerationManager.moderations.put(moderation.getType(), moderation);
|
||||
}
|
||||
}
|
||||
|
||||
public Map<ModerationType, AbstractModeration> getModerations() {
|
||||
return Collections.unmodifiableMap(moderations);
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package com.songoda.ultimatemoderation.moderate;
|
||||
|
||||
public enum ModerationType {
|
||||
|
||||
FREEZE, SPY, INV_SEE, ENDER_VIEW, REVIVE
|
||||
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package com.songoda.ultimatemoderation.moderate.moderations;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.moderate.AbstractModeration;
|
||||
import com.songoda.ultimatemoderation.moderate.ModerationType;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class FreezeModeration extends AbstractModeration {
|
||||
|
||||
private static final List<UUID> frozen = new ArrayList<>();
|
||||
|
||||
public FreezeModeration(UltimateModeration plugin) {
|
||||
super(plugin, false, true);
|
||||
registerCommand(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModerationType getType() {
|
||||
return ModerationType.FREEZE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompatibleMaterial getIcon() {
|
||||
return CompatibleMaterial.BLUE_ICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProper() {
|
||||
return "Freeze";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Allows you to freeze a player.";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean runModeration(CommandSender runner, OfflinePlayer toModerate) {
|
||||
if (frozen.contains(toModerate.getUniqueId())) {
|
||||
frozen.remove(toModerate.getUniqueId());
|
||||
plugin.getLocale().getMessage("command.freeze.remove")
|
||||
.processPlaceholder("player", toModerate.getPlayer().getDisplayName()).sendPrefixedMessage(runner);
|
||||
if (toModerate.isOnline())
|
||||
plugin.getLocale().getMessage("command.freeze.alertremove").sendPrefixedMessage(toModerate.getPlayer());
|
||||
} else {
|
||||
frozen.add(toModerate.getUniqueId());
|
||||
plugin.getLocale().getMessage("command.freeze.add")
|
||||
.processPlaceholder("player", toModerate.getPlayer().getDisplayName()).sendPrefixedMessage(runner);
|
||||
if (toModerate.isOnline())
|
||||
plugin.getLocale().getMessage("command.freeze.alertadd").sendPrefixedMessage(toModerate.getPlayer());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean isFrozen(OfflinePlayer player) {
|
||||
return frozen.contains(player.getUniqueId());
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package com.songoda.ultimatemoderation.moderate.moderations;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.moderate.AbstractModeration;
|
||||
import com.songoda.ultimatemoderation.moderate.ModerationType;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class InvSeeModeration extends AbstractModeration {
|
||||
|
||||
public InvSeeModeration(UltimateModeration plugin) {
|
||||
super(plugin, true, false);
|
||||
registerCommand(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModerationType getType() {
|
||||
return ModerationType.INV_SEE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompatibleMaterial getIcon() {
|
||||
return CompatibleMaterial.CHEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProper() {
|
||||
return "InvSee";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Allows you to see inside of a players inventory.";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean runModeration(CommandSender runner, OfflinePlayer toModerate) {
|
||||
Player toModeratePlayer = (Player) toModerate;
|
||||
|
||||
((Player) runner).openInventory(toModeratePlayer.getInventory());
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package com.songoda.ultimatemoderation.moderate.moderations;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.utils.PlayerUtils;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.listeners.DeathListener;
|
||||
import com.songoda.ultimatemoderation.moderate.AbstractModeration;
|
||||
import com.songoda.ultimatemoderation.moderate.ModerationType;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ReviveModeration extends AbstractModeration {
|
||||
|
||||
public ReviveModeration(UltimateModeration plugin) {
|
||||
super(plugin, true, true);
|
||||
registerCommand(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModerationType getType() {
|
||||
return ModerationType.REVIVE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompatibleMaterial getIcon() {
|
||||
return CompatibleMaterial.POTION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProper() {
|
||||
return "Revive";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Allows you to revive a player.";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean runModeration(CommandSender runner, OfflinePlayer toModerate) {
|
||||
Player toModeratePlayer = (Player) toModerate;
|
||||
UltimateModeration instance = UltimateModeration.getInstance();
|
||||
List<ItemStack> drops = DeathListener.getLastDrop(toModeratePlayer);
|
||||
|
||||
if (drops == null) {
|
||||
instance.getLocale().getMessage("command.revive.noloot").sendPrefixedMessage(runner);
|
||||
return false;
|
||||
}
|
||||
|
||||
ItemStack[] dropArr = new ItemStack[drops.size()];
|
||||
dropArr = drops.toArray(dropArr);
|
||||
|
||||
PlayerUtils.giveItem(toModeratePlayer, dropArr);
|
||||
|
||||
instance.getLocale().getMessage("command.revive.revived").sendPrefixedMessage(toModeratePlayer);
|
||||
instance.getLocale().getMessage("command.revive.success")
|
||||
.processPlaceholder("player", toModerate.getName()).sendPrefixedMessage(runner);
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,27 +1,71 @@
|
||||
package com.songoda.ultimatemoderation.commands;
|
||||
package com.songoda.ultimatemoderation.moderate.moderations;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.commands.CommandVanish;
|
||||
import com.songoda.ultimatemoderation.listeners.SpyingDismountListener;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import com.songoda.ultimatemoderation.moderate.AbstractModeration;
|
||||
import com.songoda.ultimatemoderation.moderate.ModerationType;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class CommandSpy extends AbstractCommand {
|
||||
|
||||
private UltimateModeration instance;
|
||||
public class SpyModeration extends AbstractModeration {
|
||||
|
||||
private static Map<UUID, Spy> spying = new HashMap<>();
|
||||
|
||||
public CommandSpy(UltimateModeration instance) {
|
||||
super(CommandType.PLAYER_ONLY, "Spy");
|
||||
this.instance = instance;
|
||||
public SpyModeration(UltimateModeration plugin) {
|
||||
super(plugin, true, false);
|
||||
registerCommand(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModerationType getType() {
|
||||
return ModerationType.SPY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompatibleMaterial getIcon() {
|
||||
return CompatibleMaterial.ENDER_EYE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProper() {
|
||||
return "Spy";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Allows you to spy on a player.";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean runModeration(CommandSender runner, OfflinePlayer toModerate) {
|
||||
Player toModeratePlayer = (Player) toModerate;
|
||||
Player runnerPlayer = (Player) runner;
|
||||
|
||||
if (spying.containsKey(runnerPlayer.getUniqueId())) {
|
||||
Spy spyingEntry = spying.remove(runnerPlayer.getUniqueId());
|
||||
runnerPlayer.teleport(spyingEntry.getLastLocation());
|
||||
if (spyingEntry.isVanishApplied() && CommandVanish.isVanished(runnerPlayer))
|
||||
CommandVanish.vanish(runnerPlayer);
|
||||
|
||||
plugin.getLocale().getMessage("command.spy.returned").sendPrefixedMessage(runner);
|
||||
return true;
|
||||
}
|
||||
|
||||
spy(toModeratePlayer, runnerPlayer);
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isSpying(OfflinePlayer player) {
|
||||
return spying.containsKey(player.getUniqueId());
|
||||
}
|
||||
|
||||
public static void spy(OfflinePlayer oPlayer, Player senderP) {
|
||||
@ -71,73 +115,6 @@ public class CommandSpy extends AbstractCommand {
|
||||
.processPlaceholder("player", player.getName()).sendPrefixedMessage(senderP);
|
||||
}
|
||||
|
||||
public static boolean isSpying(OfflinePlayer player) {
|
||||
return spying.containsKey(player.getUniqueId());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length > 1)
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
|
||||
Player senderP = ((Player) sender);
|
||||
|
||||
if (args.length == 0 || spying.containsKey(senderP.getUniqueId())) {
|
||||
if (!spying.containsKey(senderP.getUniqueId()))
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
Spy spyingEntry = spying.remove(senderP.getUniqueId());
|
||||
senderP.teleport(spyingEntry.getLastLocation());
|
||||
if (spyingEntry.isVanishApplied() && CommandVanish.isVanished(senderP))
|
||||
CommandVanish.vanish(senderP);
|
||||
|
||||
instance.getLocale().getMessage("command.spy.returned").sendPrefixedMessage(sender);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
Player player = Bukkit.getPlayer(args[0]);
|
||||
|
||||
if (player == null) {
|
||||
instance.getLocale().newMessage("That player does not exist or is not online.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
if (player.hasPermission("um.spy.exempt")) {
|
||||
instance.getLocale().newMessage("You cannot spy on that player.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
spy(player, senderP);
|
||||
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender sender, String... args) {
|
||||
if (args.length == 1) {
|
||||
List<String> players = new ArrayList<>();
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
players.add(player.getName());
|
||||
}
|
||||
return players;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "um.spy";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/Spy [player]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Allows you to spy on a player.";
|
||||
}
|
||||
|
||||
public static class Spy {
|
||||
private Location lastLocation;
|
||||
private boolean vanishApplied;
|
@ -0,0 +1,45 @@
|
||||
package com.songoda.ultimatemoderation.moderate.moderations;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.moderate.AbstractModeration;
|
||||
import com.songoda.ultimatemoderation.moderate.ModerationType;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ViewEnderChestModeration extends AbstractModeration {
|
||||
|
||||
public ViewEnderChestModeration(UltimateModeration plugin) {
|
||||
super(plugin, true, false);
|
||||
registerCommand(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModerationType getType() {
|
||||
return ModerationType.ENDER_VIEW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompatibleMaterial getIcon() {
|
||||
return CompatibleMaterial.ENDER_CHEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProper() {
|
||||
return "ViewEnderChest";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Allows you to see inside of a players ender chest.";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean runModeration(CommandSender runner, OfflinePlayer toModerate) {
|
||||
Player toModeratePlayer = (Player) toModerate;
|
||||
|
||||
((Player) runner).openInventory(toModeratePlayer.getInventory());
|
||||
return false;
|
||||
}
|
||||
}
|
@ -8,8 +8,8 @@ public class AppliedPunishment extends Punishment {
|
||||
private final UUID punisher;
|
||||
private long expiration;
|
||||
|
||||
public AppliedPunishment(PunishmentType punishmentType, long duration, String reason, UUID victim, UUID punisher, long expiration, UUID uuid) {
|
||||
super(punishmentType, duration, reason, uuid);
|
||||
public AppliedPunishment(PunishmentType punishmentType, long duration, String reason, UUID victim, UUID punisher, long expiration, int id) {
|
||||
super(punishmentType, duration, reason, id);
|
||||
this.victim = victim;
|
||||
this.punisher = punisher;
|
||||
this.expiration = expiration;
|
||||
|
@ -8,42 +8,37 @@ import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class Punishment {
|
||||
|
||||
private final UUID uuid;
|
||||
private int id;
|
||||
|
||||
private final PunishmentType punishmentType;
|
||||
private final long duration;
|
||||
private final String reason;
|
||||
|
||||
public Punishment(PunishmentType punishmentType, long duration, String reason, UUID uuid) {
|
||||
public Punishment(PunishmentType punishmentType, long duration, String reason, int id) {
|
||||
this.punishmentType = punishmentType;
|
||||
this.duration = duration;
|
||||
this.reason = reason;
|
||||
this.uuid = uuid;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Punishment(PunishmentType punishmentType, long duration, String reason) {
|
||||
this.punishmentType = punishmentType;
|
||||
this.duration = duration;
|
||||
this.reason = reason;
|
||||
this.uuid = UUID.randomUUID();
|
||||
}
|
||||
|
||||
public Punishment(PunishmentType punishmentType, String reason) {
|
||||
this.punishmentType = punishmentType;
|
||||
this.duration = -1;
|
||||
this.duration = 0;
|
||||
this.reason = reason;
|
||||
this.uuid = UUID.randomUUID();
|
||||
}
|
||||
|
||||
protected Punishment(Punishment punishment) {
|
||||
this.punishmentType = punishment.getPunishmentType();
|
||||
this.duration = punishment.getDuration();
|
||||
this.reason = punishment.getReason();
|
||||
this.uuid = punishment.getUUID();
|
||||
}
|
||||
|
||||
public void execute(CommandSender punisher, OfflinePlayer victim) {
|
||||
@ -61,14 +56,11 @@ public class Punishment {
|
||||
plugin.getLocale().getMessage("event.ban.already").sendPrefixedMessage(punisher);
|
||||
return;
|
||||
}
|
||||
if (victim.isOnline()) {
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
victim.getPlayer().kickPlayer(plugin.getLocale()
|
||||
.getMessage("event.ban.message")
|
||||
.processPlaceholder("reason", reason == null ? "" : reason)
|
||||
.processPlaceholder("duration", Methods.makeReadable(duration)).getMessage());
|
||||
});
|
||||
}
|
||||
if (victim.isOnline())
|
||||
Bukkit.getScheduler().runTask(plugin, () -> victim.getPlayer().kickPlayer(plugin.getLocale()
|
||||
.getMessage("event.ban.message")
|
||||
.processPlaceholder("reason", reason == null ? "" : reason)
|
||||
.processPlaceholder("duration", Methods.makeReadable(duration)).getMessage()));
|
||||
break;
|
||||
case MUTE:
|
||||
if (!playerPunishData.getActivePunishments(PunishmentType.MUTE).isEmpty()) {
|
||||
@ -78,14 +70,10 @@ public class Punishment {
|
||||
sendMessage(victim);
|
||||
break;
|
||||
case KICK:
|
||||
if (victim.isOnline()) {
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
victim.getPlayer().kickPlayer(plugin.getLocale()
|
||||
.getMessage("event.ban.message")
|
||||
.processPlaceholder("reason", reason == null ? "" : reason)
|
||||
.processPlaceholder("duration", Methods.makeReadable(duration)).getMessage());
|
||||
});
|
||||
}
|
||||
if (victim.isOnline())
|
||||
Bukkit.getScheduler().runTask(plugin, () -> victim.getPlayer().kickPlayer(plugin.getLocale()
|
||||
.getMessage("event.kick.message")
|
||||
.processPlaceholder("reason", reason == null ? "" : reason).getMessage()));
|
||||
break;
|
||||
case WARNING:
|
||||
sendMessage(victim);
|
||||
@ -101,13 +89,20 @@ public class Punishment {
|
||||
punishSuccess += plugin.getLocale().getMessage("event.punish.reason")
|
||||
.processPlaceholder("reason", reason).getMessage();
|
||||
|
||||
if (duration != -1)
|
||||
if (duration != -1 && duration != 0)
|
||||
punishSuccess += plugin.getLocale().getMessage("event.punish.theirduration")
|
||||
.processPlaceholder("duration", Methods.makeReadable(duration)).getMessage();
|
||||
|
||||
punisher.sendMessage(punishSuccess + Methods.formatText("&7."));
|
||||
|
||||
playerPunishData.addPunishment(apply(victim, punisher));
|
||||
AppliedPunishment appliedPunishment = apply(victim, punisher);
|
||||
if (duration != 0) {
|
||||
playerPunishData.addPunishment(appliedPunishment);
|
||||
} else {
|
||||
appliedPunishment.expire();
|
||||
playerPunishData.addExpiredPunishment(appliedPunishment);
|
||||
}
|
||||
plugin.getDataManager().createAppliedPunishment(appliedPunishment);
|
||||
}
|
||||
|
||||
public void sendMessage(OfflinePlayer offlineVictim) {
|
||||
@ -129,8 +124,12 @@ public class Punishment {
|
||||
victim.sendMessage(punishSuccess + Methods.formatText("&7."));
|
||||
}
|
||||
|
||||
public UUID getUUID() {
|
||||
return uuid;
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public PunishmentType getPunishmentType() {
|
||||
@ -147,7 +146,7 @@ public class Punishment {
|
||||
|
||||
private AppliedPunishment apply(OfflinePlayer player, CommandSender punisher) {
|
||||
return new AppliedPunishment(this, player.getUniqueId(),
|
||||
punisher == null ? null : punisher instanceof OfflinePlayer ? ((OfflinePlayer)punisher).getUniqueId() : null, System.currentTimeMillis() + this.duration);
|
||||
punisher == null ? null : punisher instanceof OfflinePlayer ? ((OfflinePlayer) punisher).getUniqueId() : null, System.currentTimeMillis() + this.duration);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,15 +4,15 @@ import java.util.UUID;
|
||||
|
||||
public class PunishmentNote {
|
||||
|
||||
private final UUID uuid;
|
||||
private int id;
|
||||
|
||||
private final String note;
|
||||
private final UUID author;
|
||||
private final UUID subject;
|
||||
private final long creationDate;
|
||||
|
||||
public PunishmentNote(UUID uuid, String note, UUID author, UUID subject, long creationDate) {
|
||||
this.uuid = uuid;
|
||||
public PunishmentNote(int id, String note, UUID author, UUID subject, long creationDate) {
|
||||
this.id = id;
|
||||
this.note = note;
|
||||
this.author = author;
|
||||
this.subject = subject;
|
||||
@ -20,15 +20,18 @@ public class PunishmentNote {
|
||||
}
|
||||
|
||||
public PunishmentNote(String note, UUID author, UUID subject, long creationDate) {
|
||||
this.uuid = UUID.randomUUID();
|
||||
this.note = note;
|
||||
this.author = author;
|
||||
this.subject = subject;
|
||||
this.creationDate = creationDate;
|
||||
}
|
||||
|
||||
public UUID getUUID() {
|
||||
return uuid;
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getNote() {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.songoda.ultimatemoderation.punish.player;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentNote;
|
||||
import com.songoda.ultimatemoderation.punish.AppliedPunishment;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentType;
|
||||
@ -57,6 +58,11 @@ public class PlayerPunishData {
|
||||
return appliedPunishments;
|
||||
}
|
||||
|
||||
public AppliedPunishment[] addExpiredPunishment(AppliedPunishment... appliedPunishments) {
|
||||
this.expiredPunishments.addAll(Arrays.asList(appliedPunishments));
|
||||
return appliedPunishments;
|
||||
}
|
||||
|
||||
public AppliedPunishment[] removePunishment(AppliedPunishment... appliedPunishments) {
|
||||
this.activePunishments.removeAll(Arrays.asList(appliedPunishments));
|
||||
return appliedPunishments;
|
||||
@ -76,7 +82,7 @@ public class PlayerPunishData {
|
||||
return notes;
|
||||
}
|
||||
|
||||
public PunishmentNote[] removeNote(PunishmentNote... notes) {
|
||||
public PunishmentNote[] removeNotes(PunishmentNote... notes) {
|
||||
this.punishmentNotes.removeAll(Arrays.asList(notes));
|
||||
return notes;
|
||||
}
|
||||
@ -100,6 +106,7 @@ public class PlayerPunishData {
|
||||
activePunishments.stream().filter(appliedPunishment ->
|
||||
type == appliedPunishment.getPunishmentType()).forEach(appliedPunishment -> {
|
||||
appliedPunishment.expire();
|
||||
UltimateModeration.getInstance().getDataManager().updateAppliedPunishment(appliedPunishment);
|
||||
toAudit.add(appliedPunishment);
|
||||
});
|
||||
toAudit.forEach(appliedPunishment -> this.audit(true, type));
|
||||
|
@ -11,25 +11,25 @@ public class Template extends Punishment {
|
||||
private final String templateName;
|
||||
private final UUID creator;
|
||||
|
||||
public Template(PunishmentType punishmentType, long duration, String reason, Player creator, String templateName) {
|
||||
public Template(PunishmentType punishmentType, long duration, String reason, Player creator, String name) {
|
||||
super(punishmentType, duration, reason);
|
||||
this.creator = creator.getUniqueId();
|
||||
this.templateName = templateName;
|
||||
this.templateName = name;
|
||||
}
|
||||
|
||||
public Template(PunishmentType punishmentType, long duration, String reason, UUID creator, String templateName, UUID uuid) {
|
||||
super(punishmentType, duration, reason, uuid);
|
||||
public Template(PunishmentType punishmentType, long duration, String reason, UUID creator, String name, int id) {
|
||||
super(punishmentType, duration, reason, id);
|
||||
this.creator = creator;
|
||||
this.templateName = templateName;
|
||||
this.templateName = name;
|
||||
}
|
||||
|
||||
public Template(PunishmentType punishmentType, long duration, String reason, UUID creator, String templateName) {
|
||||
public Template(PunishmentType punishmentType, long duration, String reason, UUID creator, String name) {
|
||||
super(punishmentType, duration, reason);
|
||||
this.creator = creator;
|
||||
this.templateName = templateName;
|
||||
this.templateName = name;
|
||||
}
|
||||
|
||||
public String getTemplateName() {
|
||||
public String getName() {
|
||||
return templateName;
|
||||
}
|
||||
|
||||
|
@ -1,36 +1,33 @@
|
||||
package com.songoda.ultimatemoderation.punish.template;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
public class TemplateManager {
|
||||
|
||||
private static final Map<UUID, Template> templates = new HashMap<>();
|
||||
private static final Map<Integer, Template> templates = new HashMap<>();
|
||||
|
||||
public Template getTemplate(String name) {
|
||||
for (Template template : templates.values()) {
|
||||
if (formatName(template.getTemplateName()).equals(formatName(name)))
|
||||
if (formatName(template.getName()).equals(formatName(name)))
|
||||
return template;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Template addTemplate(Template template) {
|
||||
return templates.put(template.getUUID(), template);
|
||||
return templates.put(template.getId(), template);
|
||||
}
|
||||
|
||||
public Template removeTemplate(UUID uuid) {
|
||||
return templates.remove(uuid);
|
||||
public Template removeTemplate(Template template) {
|
||||
return templates.remove(template.getId());
|
||||
}
|
||||
|
||||
public Template updateTemplate(UUID uuid, Template template) {
|
||||
templates.remove(uuid);
|
||||
public Template updateTemplate(int id, Template template) {
|
||||
templates.remove(id);
|
||||
return addTemplate(template);
|
||||
}
|
||||
|
||||
public Map<UUID, Template> getTemplates() {
|
||||
public Map<Integer, Template> getTemplates() {
|
||||
return Collections.unmodifiableMap(templates);
|
||||
}
|
||||
|
||||
@ -40,5 +37,4 @@ public class TemplateManager {
|
||||
name = name.replace(" ", "_");
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -59,6 +59,14 @@ public class Settings {
|
||||
public static final ConfigSetting NOTIFY_BLOCK_LIST = new ConfigSetting(config, "Main.Notify Blocks List", Arrays.asList("DIAMOND_ORE", "EMERALD_ORE"),
|
||||
"Blocks that will give a notification when mined.");
|
||||
|
||||
public static final ConfigSetting MYSQL_ENABLED = new ConfigSetting(config, "MySQL.Enabled", false, "Set to 'true' to use MySQL instead of SQLite for data storage.");
|
||||
public static final ConfigSetting MYSQL_HOSTNAME = new ConfigSetting(config, "MySQL.Hostname", "localhost");
|
||||
public static final ConfigSetting MYSQL_PORT = new ConfigSetting(config, "MySQL.Port", 3306);
|
||||
public static final ConfigSetting MYSQL_DATABASE = new ConfigSetting(config, "MySQL.Database", "your-database");
|
||||
public static final ConfigSetting MYSQL_USERNAME = new ConfigSetting(config, "MySQL.Username", "user");
|
||||
public static final ConfigSetting MYSQL_PASSWORD = new ConfigSetting(config, "MySQL.Password", "pass");
|
||||
public static final ConfigSetting MYSQL_USE_SSL = new ConfigSetting(config, "MySQL.Use SSL", false);
|
||||
|
||||
public static void setupConfig() {
|
||||
config.load();
|
||||
config.setAutoremove(true).setAutosave(true);
|
||||
|
@ -30,54 +30,6 @@ public abstract class Storage {
|
||||
public abstract void prepareSaveItem(String group, StorageItem... items);
|
||||
|
||||
public void updateData(UltimateModeration instance) {
|
||||
// Save game data
|
||||
for (Template template : instance.getTemplateManager().getTemplates().values()) {
|
||||
prepareSaveItem("templates", new StorageItem("uuid", template.getUUID().toString()),
|
||||
new StorageItem("type", template.getPunishmentType().name()),
|
||||
new StorageItem("duration", template.getDuration()),
|
||||
new StorageItem("reason", template.getReason()),
|
||||
new StorageItem("name", template.getTemplateName()),
|
||||
new StorageItem("creator", template.getCreator().toString()));
|
||||
}
|
||||
|
||||
for (PlayerPunishData playerPunishData : instance.getPunishmentManager().getPunishments().values()) {
|
||||
List<AppliedPunishment> appliedPunishments = playerPunishData.getActivePunishments();
|
||||
appliedPunishments.addAll(playerPunishData.getExpiredPunishments());
|
||||
for (AppliedPunishment appliedPunishment : appliedPunishments) {
|
||||
prepareSaveItem("punishments", new StorageItem("uuid", appliedPunishment.getUUID().toString()),
|
||||
new StorageItem("type", appliedPunishment.getPunishmentType().name()),
|
||||
new StorageItem("duration", appliedPunishment.getDuration()),
|
||||
new StorageItem("reason", appliedPunishment.getReason()),
|
||||
new StorageItem("victim", appliedPunishment.getVictim().toString()),
|
||||
new StorageItem("punisher", appliedPunishment.getPunisher() == null ? null : appliedPunishment.getPunisher().toString()),
|
||||
new StorageItem("expiration", appliedPunishment.getExpiration()));
|
||||
}
|
||||
|
||||
List<PunishmentNote> notes = playerPunishData.getNotes();
|
||||
for (PunishmentNote note : notes) {
|
||||
prepareSaveItem("notes", new StorageItem("uuid", note.getUUID().toString()),
|
||||
new StorageItem("note", note.getNote()),
|
||||
new StorageItem("author", note.getAuthor().toString()),
|
||||
new StorageItem("subject", note.getSubject().toString()),
|
||||
new StorageItem("creation", note.getCreationDate()));
|
||||
}
|
||||
}
|
||||
|
||||
for (Ticket ticket : instance.getTicketManager().getTickets()) {
|
||||
prepareSaveItem("tickets", new StorageItem("id", String.valueOf(ticket.getTicketId())),
|
||||
new StorageItem("player", ticket.getVictim().toString()),
|
||||
new StorageItem("subject", ticket.getSubject()),
|
||||
new StorageItem("type", ticket.getType()),
|
||||
new StorageItem("location", Methods.serializeLocation(ticket.getLocation())),
|
||||
new StorageItem("status", ticket.getStatus().toString()));
|
||||
|
||||
for (TicketResponse ticketResponse : ticket.getResponses()) {
|
||||
prepareSaveItem("ticketresponses", new StorageItem("posted", String.valueOf(ticketResponse.getPostedDate())),
|
||||
new StorageItem("ticketid", ticket.getTicketId()),
|
||||
new StorageItem("author", ticketResponse.getAuthor().toString()),
|
||||
new StorageItem("message", ticketResponse.getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void doSave();
|
||||
|
@ -9,7 +9,7 @@ import java.util.UUID;
|
||||
|
||||
public class Ticket {
|
||||
|
||||
private int ticketId;
|
||||
private int id;
|
||||
|
||||
private TicketStatus status = TicketStatus.OPEN;
|
||||
private Location location = null;
|
||||
@ -32,26 +32,21 @@ public class Ticket {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Ticket(OfflinePlayer victim, String subject, String type, TicketResponse response) {
|
||||
this.victim = victim.getUniqueId();
|
||||
this.subject = subject;
|
||||
this.type = type;
|
||||
this.tickets.add(response);
|
||||
}
|
||||
|
||||
public Ticket(UUID victim, String subject, String type, TicketResponse response) {
|
||||
public Ticket(int id, UUID victim, String subject, String type, TicketStatus status, Location location) {
|
||||
this.id = id;
|
||||
this.victim = victim;
|
||||
this.subject = subject;
|
||||
this.type = type;
|
||||
this.tickets.add(response);
|
||||
this.status = status;
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public int getTicketId() {
|
||||
return ticketId;
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setTicketId(int ticketId) {
|
||||
this.ticketId = ticketId;
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public List<TicketResponse> getResponses() {
|
||||
@ -59,7 +54,7 @@ public class Ticket {
|
||||
}
|
||||
|
||||
public TicketResponse addResponse(TicketResponse response) {
|
||||
response.setTicketId(ticketId);
|
||||
response.setTicketId(id);
|
||||
tickets.add(response);
|
||||
return response;
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.songoda.ultimatemoderation.tickets;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
@ -11,8 +10,8 @@ public class TicketManager {
|
||||
private final TreeMap<Integer, Ticket> registeredTickets = new TreeMap<>();
|
||||
|
||||
public Ticket addTicket(Ticket ticket) {
|
||||
int id = registeredTickets.isEmpty() ? 1 : registeredTickets.lastEntry().getValue().getTicketId() + 1;
|
||||
ticket.setTicketId(id);
|
||||
int id = registeredTickets.isEmpty() ? 1 : registeredTickets.lastEntry().getValue().getId() + 1;
|
||||
ticket.setId(id);
|
||||
return addTicket(ticket, id);
|
||||
}
|
||||
|
||||
|
@ -1,102 +0,0 @@
|
||||
package com.songoda.ultimatemoderation.utils;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class AbstractChatConfirm implements Listener {
|
||||
|
||||
private static final List<UUID> registered = new ArrayList<>();
|
||||
|
||||
private final Player player;
|
||||
private final ChatConfirmHandler handler;
|
||||
|
||||
private OnClose onClose = null;
|
||||
|
||||
public AbstractChatConfirm(Player player, ChatConfirmHandler hander) {
|
||||
this.player = player;
|
||||
this.handler = hander;
|
||||
player.closeInventory();
|
||||
initializeListeners(UltimateModeration.getInstance());
|
||||
registered.add(player.getUniqueId());
|
||||
}
|
||||
|
||||
private Listener listener;
|
||||
|
||||
public void initializeListeners(JavaPlugin plugin) {
|
||||
|
||||
this.listener = new Listener() {
|
||||
@EventHandler
|
||||
public void onChat(AsyncPlayerChatEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (!AbstractChatConfirm.isRegistered(player)) return;
|
||||
|
||||
AbstractChatConfirm.unregister(player);
|
||||
event.setCancelled(true);
|
||||
|
||||
ChatConfirmEvent chatConfirmEvent = new ChatConfirmEvent(player, event.getMessage());
|
||||
|
||||
handler.onChat(chatConfirmEvent);
|
||||
|
||||
if (onClose != null) {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(UltimateModeration.getInstance(), () ->
|
||||
onClose.onClose(), 0L);
|
||||
}
|
||||
HandlerList.unregisterAll(listener);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(listener, UltimateModeration.getInstance());
|
||||
}
|
||||
|
||||
public static boolean isRegistered(Player player) {
|
||||
return registered.contains(player.getUniqueId());
|
||||
}
|
||||
|
||||
public static boolean unregister(Player player) {
|
||||
return registered.remove(player.getUniqueId());
|
||||
}
|
||||
|
||||
public interface ChatConfirmHandler {
|
||||
void onChat(ChatConfirmEvent event);
|
||||
}
|
||||
|
||||
public void setOnClose(OnClose onClose) {
|
||||
this.onClose = onClose;
|
||||
}
|
||||
|
||||
public interface OnClose {
|
||||
void onClose();
|
||||
}
|
||||
|
||||
public class ChatConfirmEvent {
|
||||
|
||||
private final Player player;
|
||||
private final String message;
|
||||
|
||||
public ChatConfirmEvent(Player player, String message) {
|
||||
this.player = player;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -17,8 +17,8 @@ public class VaultPermissions {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean hasPermission(String world, OfflinePlayer offlinePlayer, String perm) {
|
||||
if (vaultPermission != null) return vaultPermission.playerHas(world, offlinePlayer, perm);
|
||||
public static boolean hasPermission(OfflinePlayer offlinePlayer, String perm) {
|
||||
if (vaultPermission != null) return vaultPermission.playerHas(Bukkit.getWorlds().get(0).getName(), offlinePlayer, perm);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1,289 +0,0 @@
|
||||
package com.songoda.ultimatemoderation.utils.gui;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.utils.version.NMSUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class AbstractAnvilGUI {
|
||||
private static Class<?> BlockPositionClass;
|
||||
private static Class<?> PacketPlayOutOpenWindowClass;
|
||||
private static Class<?> IChatBaseComponentClass;
|
||||
private static Class<?> ICraftingClass;
|
||||
private static Class<?> ContainerAnvilClass;
|
||||
private static Class<?> ChatMessageClass;
|
||||
private static Class<?> EntityHumanClass;
|
||||
private static Class<?> ContainerClass;
|
||||
private static Class<?> ContainerAccessClass;
|
||||
private static Class<?> WorldClass;
|
||||
private static Class<?> PlayerInventoryClass;
|
||||
private static Class<?> ContainersClass;
|
||||
private static Class<?> CraftPlayerClass;
|
||||
|
||||
private Player player;
|
||||
private Map<AnvilSlot, ItemStack> items = new HashMap<>();
|
||||
private OnClose onClose = null;
|
||||
private Inventory inv;
|
||||
private Listener listener;
|
||||
|
||||
static {
|
||||
BlockPositionClass = NMSUtil.getNMSClass("BlockPosition");
|
||||
PacketPlayOutOpenWindowClass = NMSUtil.getNMSClass("PacketPlayOutOpenWindow");
|
||||
IChatBaseComponentClass = NMSUtil.getNMSClass("IChatBaseComponent");
|
||||
ICraftingClass = NMSUtil.getNMSClass("ICrafting");
|
||||
ContainerAnvilClass = NMSUtil.getNMSClass("ContainerAnvil");
|
||||
EntityHumanClass = NMSUtil.getNMSClass("EntityHuman");
|
||||
ChatMessageClass = NMSUtil.getNMSClass("ChatMessage");
|
||||
ContainerClass = NMSUtil.getNMSClass("Container");
|
||||
WorldClass = NMSUtil.getNMSClass("World");
|
||||
PlayerInventoryClass = NMSUtil.getNMSClass("PlayerInventory");
|
||||
CraftPlayerClass = NMSUtil.getCraftClass("entity.CraftPlayer");
|
||||
|
||||
if (NMSUtil.getVersionNumber() > 13) {
|
||||
ContainerAccessClass = NMSUtil.getNMSClass("ContainerAccess");
|
||||
ContainersClass = NMSUtil.getNMSClass("Containers");
|
||||
}
|
||||
}
|
||||
|
||||
public AbstractAnvilGUI(Player player, AnvilClickEventHandler handler) {
|
||||
UltimateModeration instance = UltimateModeration.getInstance();
|
||||
this.player = player;
|
||||
|
||||
this.listener = new Listener() {
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
if (event.getWhoClicked() instanceof Player && event.getInventory().equals(AbstractAnvilGUI.this.inv)) {
|
||||
event.setCancelled(true);
|
||||
|
||||
ItemStack item = event.getCurrentItem();
|
||||
int slot = event.getRawSlot();
|
||||
|
||||
if (item == null || item.getType().equals(Material.AIR) || slot != 2)
|
||||
return;
|
||||
|
||||
String name = "";
|
||||
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta != null && meta.hasDisplayName())
|
||||
name = meta.getDisplayName();
|
||||
|
||||
AnvilClickEvent clickEvent = new AnvilClickEvent(AnvilSlot.bySlot(slot), name);
|
||||
handler.onAnvilClick(clickEvent);
|
||||
|
||||
if (clickEvent.getWillClose())
|
||||
event.getWhoClicked().closeInventory();
|
||||
|
||||
if (clickEvent.getWillDestroy())
|
||||
AbstractAnvilGUI.this.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onInventoryClose(InventoryCloseEvent event) {
|
||||
if (event.getPlayer() instanceof Player && AbstractAnvilGUI.this.inv.equals(event.getInventory())) {
|
||||
Inventory inv = event.getInventory();
|
||||
player.setLevel(player.getLevel() - 1);
|
||||
inv.clear();
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> {
|
||||
if (AbstractAnvilGUI.this.onClose != null)
|
||||
AbstractAnvilGUI.this.onClose.onClose(player, inv);
|
||||
AbstractAnvilGUI.this.destroy();
|
||||
}, 1L);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
if (event.getPlayer().equals(AbstractAnvilGUI.this.player)) {
|
||||
player.setLevel(player.getLevel() - 1);
|
||||
AbstractAnvilGUI.this.destroy();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(this.listener, instance);
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
public void setSlot(AnvilSlot slot, ItemStack item) {
|
||||
this.items.put(slot, item);
|
||||
}
|
||||
|
||||
public void open() {
|
||||
this.player.setLevel(this.player.getLevel() + 1);
|
||||
|
||||
try {
|
||||
Object craftPlayer = CraftPlayerClass.cast(this.player);
|
||||
Method getHandleMethod = CraftPlayerClass.getMethod("getHandle");
|
||||
Object entityPlayer = getHandleMethod.invoke(craftPlayer);
|
||||
Object playerInventory = NMSUtil.getFieldObject(entityPlayer, NMSUtil.getField(entityPlayer.getClass(), "inventory", false));
|
||||
Object world = NMSUtil.getFieldObject(entityPlayer, NMSUtil.getField(entityPlayer.getClass(), "world", false));
|
||||
Object blockPosition = BlockPositionClass.getConstructor(int.class, int.class, int.class).newInstance(0, 0, 0);
|
||||
|
||||
Object container;
|
||||
|
||||
if (NMSUtil.getVersionNumber() > 13) {
|
||||
container = ContainerAnvilClass
|
||||
.getConstructor(int.class, PlayerInventoryClass, ContainerAccessClass)
|
||||
.newInstance(7, playerInventory, ContainerAccessClass.getMethod("at", WorldClass, BlockPositionClass).invoke(null, world, blockPosition));
|
||||
} else {
|
||||
container = ContainerAnvilClass
|
||||
.getConstructor(PlayerInventoryClass, WorldClass, BlockPositionClass, EntityHumanClass)
|
||||
.newInstance(playerInventory, world, blockPosition, entityPlayer);
|
||||
}
|
||||
|
||||
NMSUtil.getField(ContainerClass, "checkReachable", true).set(container, false);
|
||||
|
||||
Method getBukkitViewMethod = container.getClass().getMethod("getBukkitView");
|
||||
Object bukkitView = getBukkitViewMethod.invoke(container);
|
||||
Method getTopInventoryMethod = bukkitView.getClass().getMethod("getTopInventory");
|
||||
this.inv = (Inventory) getTopInventoryMethod.invoke(bukkitView);
|
||||
|
||||
for (AnvilSlot slot : this.items.keySet()) {
|
||||
this.inv.setItem(slot.getSlot(), this.items.get(slot));
|
||||
}
|
||||
|
||||
Method nextContainerCounterMethod = entityPlayer.getClass().getMethod("nextContainerCounter");
|
||||
int c = (int) nextContainerCounterMethod.invoke(entityPlayer);
|
||||
|
||||
Constructor<?> chatMessageConstructor = ChatMessageClass.getConstructor(String.class, Object[].class);
|
||||
Object inventoryTitle = chatMessageConstructor.newInstance("Repairing", new Object[]{});
|
||||
|
||||
Object packet;
|
||||
|
||||
if (NMSUtil.getVersionNumber() > 13) {
|
||||
packet = PacketPlayOutOpenWindowClass
|
||||
.getConstructor(int.class, ContainersClass, IChatBaseComponentClass)
|
||||
.newInstance(c, ContainersClass.getField("ANVIL").get(null), inventoryTitle);
|
||||
} else {
|
||||
packet = PacketPlayOutOpenWindowClass
|
||||
.getConstructor(int.class, String.class, IChatBaseComponentClass, int.class)
|
||||
.newInstance(c, "minecraft:anvil", inventoryTitle, 0);
|
||||
}
|
||||
|
||||
NMSUtil.sendPacket(this.player, packet);
|
||||
|
||||
Field activeContainerField = NMSUtil.getField(EntityHumanClass, "activeContainer", true);
|
||||
|
||||
if (activeContainerField != null) {
|
||||
activeContainerField.set(entityPlayer, container);
|
||||
NMSUtil.getField(ContainerClass, "windowId", true).set(activeContainerField.get(entityPlayer), c);
|
||||
Method addSlotListenerMethod = activeContainerField.get(entityPlayer).getClass().getMethod("addSlotListener", ICraftingClass);
|
||||
addSlotListenerMethod.invoke(activeContainerField.get(entityPlayer), entityPlayer);
|
||||
|
||||
if (NMSUtil.getVersionNumber() > 13) {
|
||||
ContainerClass.getMethod("setTitle", IChatBaseComponentClass).invoke(container, inventoryTitle);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
this.player = null;
|
||||
this.items = null;
|
||||
|
||||
HandlerList.unregisterAll(this.listener);
|
||||
|
||||
this.listener = null;
|
||||
}
|
||||
|
||||
private OnClose getOnClose() {
|
||||
return this.onClose;
|
||||
}
|
||||
|
||||
public void setOnClose(OnClose onClose) {
|
||||
this.onClose = onClose;
|
||||
}
|
||||
|
||||
public enum AnvilSlot {
|
||||
INPUT_LEFT(0),
|
||||
INPUT_RIGHT(1),
|
||||
OUTPUT(2);
|
||||
|
||||
private int slot;
|
||||
|
||||
AnvilSlot(int slot) {
|
||||
this.slot = slot;
|
||||
}
|
||||
|
||||
public static AnvilSlot bySlot(int slot) {
|
||||
for (AnvilSlot anvilSlot : values()) {
|
||||
if (anvilSlot.getSlot() == slot) {
|
||||
return anvilSlot;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getSlot() {
|
||||
return this.slot;
|
||||
}
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface AnvilClickEventHandler {
|
||||
void onAnvilClick(AnvilClickEvent event);
|
||||
}
|
||||
|
||||
public class AnvilClickEvent {
|
||||
private AnvilSlot slot;
|
||||
|
||||
private String name;
|
||||
|
||||
private boolean close = true;
|
||||
private boolean destroy = true;
|
||||
|
||||
public AnvilClickEvent(AnvilSlot slot, String name) {
|
||||
this.slot = slot;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public AnvilSlot getSlot() {
|
||||
return this.slot;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public boolean getWillClose() {
|
||||
return this.close;
|
||||
}
|
||||
|
||||
public void setWillClose(boolean close) {
|
||||
this.close = close;
|
||||
}
|
||||
|
||||
public boolean getWillDestroy() {
|
||||
return this.destroy;
|
||||
}
|
||||
|
||||
public void setWillDestroy(boolean destroy) {
|
||||
this.destroy = destroy;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,245 +0,0 @@
|
||||
package com.songoda.ultimatemoderation.utils.gui;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.utils.Methods;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class AbstractGUI implements Listener {
|
||||
|
||||
private static boolean listenersInitialized = false;
|
||||
protected final Player player;
|
||||
protected Inventory inventory = null;
|
||||
protected String setTitle = null;
|
||||
protected boolean cancelBottom = false;
|
||||
private Map<Range, Clickable> clickables = new HashMap<>();
|
||||
private List<OnClose> onCloses = new ArrayList<>();
|
||||
private Map<Range, Boolean> draggableRanges = new HashMap<>();
|
||||
|
||||
public AbstractGUI(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public static void initializeListeners(JavaPlugin plugin) {
|
||||
if (listenersInitialized) return;
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(new Listener() {
|
||||
@EventHandler
|
||||
public void onClickGUI(InventoryClickEvent event) {
|
||||
Inventory inventory = event.getClickedInventory();
|
||||
if (inventory == null) return;
|
||||
AbstractGUI gui = getGUIFromInventory(inventory);
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
|
||||
boolean bottom = false;
|
||||
|
||||
InventoryType type = event.getClickedInventory().getType();
|
||||
if (type != InventoryType.CHEST && type != InventoryType.PLAYER) return;
|
||||
|
||||
if (gui == null && event.getWhoClicked().getOpenInventory().getTopInventory() != null) {
|
||||
Inventory top = event.getWhoClicked().getOpenInventory().getTopInventory();
|
||||
gui = getGUIFromInventory(top);
|
||||
|
||||
if (gui != null && gui.cancelBottom) event.setCancelled(true);
|
||||
bottom = true;
|
||||
}
|
||||
|
||||
if (gui == null) return;
|
||||
|
||||
if (!bottom) event.setCancelled(true);
|
||||
|
||||
if (!gui.draggableRanges.isEmpty() && !bottom) {
|
||||
for (Map.Entry<Range, Boolean> entry : gui.draggableRanges.entrySet()) {
|
||||
Range range = entry.getKey();
|
||||
if (range.getMax() == range.getMin() && event.getSlot() == range.getMin()
|
||||
|| event.getSlot() >= range.getMin() && event.getSlot() <= range.getMax()) {
|
||||
event.setCancelled(!entry.getValue());
|
||||
if (!entry.getValue()) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Map<Range, Clickable> entries = new HashMap<>(gui.clickables);
|
||||
|
||||
for (Map.Entry<Range, Clickable> entry : entries.entrySet()) {
|
||||
Range range = entry.getKey();
|
||||
if (range.isBottom() && !bottom || !range.isBottom() && bottom || range.getClickType() != null && range.getClickType() != event.getClick())
|
||||
continue;
|
||||
if (event.getSlot() >= range.getMin() && event.getSlot() <= range.getMax()) {
|
||||
entry.getValue().Clickable(player, inventory, event.getCursor(), event.getSlot(), event.getClick());
|
||||
player.playSound(player.getLocation(), entry.getKey().getOnClickSound(), 1F, 1F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onCloseGUI(InventoryCloseEvent event) {
|
||||
Inventory inventory = event.getInventory();
|
||||
AbstractGUI gui = getGUIFromInventory(inventory);
|
||||
|
||||
if (gui == null || gui.inventory == null) return;
|
||||
|
||||
for (OnClose onClose : gui.onCloses) {
|
||||
onClose.onClose((Player) event.getPlayer(), inventory);
|
||||
}
|
||||
gui.destory();
|
||||
}
|
||||
|
||||
private AbstractGUI getGUIFromInventory(Inventory inventory) {
|
||||
if (inventory.getHolder() == null) return null;
|
||||
InventoryHolder holder = inventory.getHolder();
|
||||
if (!(holder instanceof GUIHolder)) return null;
|
||||
|
||||
return ((AbstractGUI.GUIHolder) holder).getGUI();
|
||||
}
|
||||
}, plugin);
|
||||
listenersInitialized = true;
|
||||
}
|
||||
|
||||
public void init(String title, int slots) {
|
||||
if (inventory == null
|
||||
|| inventory.getSize() != slots
|
||||
|| Methods.formatTitle(title) != player.getOpenInventory().getTitle()) {
|
||||
this.inventory = Bukkit.getServer().createInventory(new GUIHolder(), slots, Methods.formatTitle(title));
|
||||
this.setTitle = Methods.formatTitle(title);
|
||||
if (this.clickables.size() == 0)
|
||||
registerClickables();
|
||||
if (this.onCloses.size() == 0)
|
||||
registerOnCloses();
|
||||
}
|
||||
constructGUI();
|
||||
initializeListeners(UltimateModeration.getInstance());
|
||||
player.openInventory(inventory);
|
||||
}
|
||||
|
||||
private void destory() {
|
||||
onCloses.clear();
|
||||
clickables.clear();
|
||||
draggableRanges.clear();
|
||||
}
|
||||
|
||||
protected abstract void constructGUI();
|
||||
|
||||
protected void addDraggable(Range range, boolean option) {
|
||||
this.draggableRanges.put(range, option);
|
||||
}
|
||||
|
||||
protected void removeDraggable() {
|
||||
this.draggableRanges.clear();
|
||||
}
|
||||
|
||||
protected abstract void registerClickables();
|
||||
|
||||
protected abstract void registerOnCloses();
|
||||
|
||||
protected ItemStack createButton(int slot, Inventory inventory, ItemStack item, String name, String... lore) {
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
|
||||
if (lore != null && lore.length != 0) {
|
||||
List<String> newLore = new ArrayList<>();
|
||||
for (String line : lore) newLore.add(ChatColor.translateAlternateColorCodes('&', line));
|
||||
meta.setLore(newLore);
|
||||
}
|
||||
item.setItemMeta(meta);
|
||||
inventory.setItem(slot, item);
|
||||
return item;
|
||||
}
|
||||
|
||||
protected ItemStack createButton(int slot, ItemStack item, String name, ArrayList<String> lore) {
|
||||
return createButton(slot, inventory, item, name, lore.toArray(new String[0]));
|
||||
}
|
||||
|
||||
|
||||
protected ItemStack createButton(int slot, ItemStack item, String name, String... lore) {
|
||||
return createButton(slot, inventory, item, name, lore);
|
||||
}
|
||||
|
||||
protected ItemStack createButton(int slot, Object item, String name, String... lore) {
|
||||
if (item instanceof ItemStack)
|
||||
return createButton(slot, inventory, (ItemStack)item, name, lore);
|
||||
else
|
||||
return createButton(slot, inventory, (Material)item, name, lore);
|
||||
}
|
||||
|
||||
protected ItemStack createButton(int slot, Inventory inventory, Material material, String name, String... lore) {
|
||||
return createButton(slot, inventory, new ItemStack(material), name, lore);
|
||||
}
|
||||
|
||||
protected ItemStack createButton(int slot, Material material, String name, String... lore) {
|
||||
return createButton(slot, inventory, new ItemStack(material), name, lore);
|
||||
}
|
||||
|
||||
protected ItemStack createButton(int slot, Material material, String name, ArrayList<String> lore) {
|
||||
return createButton(slot, material, name, lore.toArray(new String[0]));
|
||||
}
|
||||
|
||||
protected void registerClickable(int min, int max, ClickType clickType, boolean bottom, Clickable clickable) {
|
||||
clickables.put(new Range(min, max, clickType, bottom), clickable);
|
||||
}
|
||||
|
||||
protected void registerClickable(int min, int max, ClickType clickType, Clickable clickable) {
|
||||
registerClickable(min, max, clickType, false, clickable);
|
||||
}
|
||||
|
||||
protected void registerClickable(int slot, ClickType clickType, Clickable clickable) {
|
||||
registerClickable(slot, slot, clickType, false, clickable);
|
||||
}
|
||||
|
||||
protected void registerClickable(int min, int max, Clickable clickable) {
|
||||
registerClickable(min, max, null, false, clickable);
|
||||
}
|
||||
|
||||
protected void registerClickable(int slot, boolean bottom, Clickable clickable) {
|
||||
registerClickable(slot, slot, null, bottom, clickable);
|
||||
}
|
||||
|
||||
protected void registerClickable(int slot, Clickable clickable) {
|
||||
registerClickable(slot, slot, null, false, clickable);
|
||||
}
|
||||
|
||||
protected void resetClickables() {
|
||||
clickables.clear();
|
||||
}
|
||||
|
||||
protected void registerOnClose(OnClose onClose) {
|
||||
onCloses.add(onClose);
|
||||
}
|
||||
|
||||
public Inventory getInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
public class GUIHolder implements InventoryHolder {
|
||||
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
public AbstractGUI getGUI() {
|
||||
return AbstractGUI.this;
|
||||
}
|
||||
}
|
||||
|
||||
public String getSetTitle() {
|
||||
return setTitle;
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
package com.songoda.ultimatemoderation.utils.gui;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public interface Clickable {
|
||||
|
||||
void Clickable(Player player, Inventory inventory, ItemStack cursor, int slot, ClickType type);
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
package com.songoda.ultimatemoderation.utils.gui;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
public interface OnClose {
|
||||
|
||||
void onClose(Player player, Inventory inventory);
|
||||
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
package com.songoda.ultimatemoderation.utils.gui;
|
||||
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
public class Range {
|
||||
|
||||
private int min;
|
||||
private int max;
|
||||
private ClickType clickType;
|
||||
private boolean bottom;
|
||||
private Sound onClickSound;
|
||||
|
||||
public Range(int min, int max, ClickType clickType, boolean bottom) {
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
this.clickType = clickType;
|
||||
this.bottom = bottom;
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) onClickSound = Sound.UI_BUTTON_CLICK;
|
||||
}
|
||||
|
||||
public Range(int min, int max, Sound onClickSound, ClickType clickType, boolean bottom) {
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
this.onClickSound = onClickSound;
|
||||
this.clickType = clickType;
|
||||
this.bottom = bottom;
|
||||
}
|
||||
|
||||
public int getMin() {
|
||||
return min;
|
||||
}
|
||||
|
||||
public int getMax() {
|
||||
return max;
|
||||
}
|
||||
|
||||
public ClickType getClickType() {
|
||||
return clickType;
|
||||
}
|
||||
|
||||
public boolean isBottom() {
|
||||
return bottom;
|
||||
}
|
||||
|
||||
public Sound getOnClickSound() {
|
||||
return onClickSound;
|
||||
}
|
||||
}
|
@ -1,100 +0,0 @@
|
||||
package com.songoda.ultimatemoderation.utils.version;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class NMSUtil {
|
||||
|
||||
public static String getVersion() {
|
||||
String name = Bukkit.getServer().getClass().getPackage().getName();
|
||||
return name.substring(name.lastIndexOf('.') + 1) + ".";
|
||||
}
|
||||
|
||||
public static int getVersionNumber() {
|
||||
String name = getVersion().substring(3);
|
||||
return Integer.valueOf(name.substring(0, name.length() - 4));
|
||||
}
|
||||
|
||||
public static int getVersionReleaseNumber() {
|
||||
String NMSVersion = getVersion();
|
||||
return Integer.valueOf(NMSVersion.substring(NMSVersion.length() - 2).replace(".", ""));
|
||||
}
|
||||
|
||||
public static Class<?> getNMSClass(String className) {
|
||||
try {
|
||||
String fullName = "net.minecraft.server." + getVersion() + className;
|
||||
Class<?> clazz = Class.forName(fullName);
|
||||
return clazz;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Class<?> getCraftClass(String className) {
|
||||
try {
|
||||
String fullName = "org.bukkit.craftbukkit." + getVersion() + className;
|
||||
Class<?> clazz = Class.forName(fullName);
|
||||
return clazz;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Field getField(Class<?> clazz, String name, boolean declared) {
|
||||
try {
|
||||
Field field;
|
||||
|
||||
if (declared) {
|
||||
field = clazz.getDeclaredField(name);
|
||||
} else {
|
||||
field = clazz.getField(name);
|
||||
}
|
||||
|
||||
field.setAccessible(true);
|
||||
return field;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Object getFieldObject(Object object, Field field) {
|
||||
try {
|
||||
return field.get(object);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setField(Object object, String fieldName, Object fieldValue, boolean declared) {
|
||||
try {
|
||||
Field field;
|
||||
|
||||
if (declared) {
|
||||
field = object.getClass().getDeclaredField(fieldName);
|
||||
} else {
|
||||
field = object.getClass().getField(fieldName);
|
||||
}
|
||||
|
||||
field.setAccessible(true);
|
||||
field.set(object, fieldValue);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendPacket(Player player, Object packet) {
|
||||
try {
|
||||
Object handle = player.getClass().getMethod("getHandle").invoke(player);
|
||||
Object playerConnection = handle.getClass().getField("playerConnection").get(handle);
|
||||
playerConnection.getClass().getMethod("sendPacket", getNMSClass("Packet")).invoke(playerConnection, packet);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@ -51,7 +51,7 @@ event:
|
||||
yourduration: '&7. &7Your punishment will be lifted in &6%duration%'
|
||||
ban:
|
||||
success: '&7You have banned &6%player%'
|
||||
message: '&7You have been banned'
|
||||
message: '&7You have been banned for &6%reason%&7. Your ban will expire after &6%duration%&7.'
|
||||
already: '&cThis user is already banned.'
|
||||
unban:
|
||||
success: '&7You have unbanned &6%player%'
|
||||
@ -63,7 +63,7 @@ event:
|
||||
success: '&7You have unmuted &6%player%'
|
||||
kick:
|
||||
success: '&7You have kicked &6%player%'
|
||||
message: '&7You have been kicked'
|
||||
message: '&7You have been kicked for &6%reason%&7.'
|
||||
warning:
|
||||
success: '&7You have warned &6%player%'
|
||||
message: '&7You have been warned'
|
||||
@ -194,7 +194,7 @@ gui:
|
||||
what: '&6What would you like to say in your first ticket post?'
|
||||
subject: Ticket Subject
|
||||
ticket:
|
||||
title: '&8Tickets > %id%'
|
||||
title: '&8Tickets > %subject% %id%'
|
||||
type: '&7Type &6%type%&7.'
|
||||
picktype: '&8Pick a ticket type.'
|
||||
clicktotele: '&6Teleport to ticket location.'
|
||||
|
@ -31,11 +31,14 @@ commands:
|
||||
default: false
|
||||
aliases: [v]
|
||||
usage: /v
|
||||
ViewEnderChest:
|
||||
description: ViewEnderChest
|
||||
Spy:
|
||||
description: Spy
|
||||
default: false
|
||||
aliases: [vec]
|
||||
usage: /vec
|
||||
usage: /spy
|
||||
Revive:
|
||||
description: Revive
|
||||
default: false
|
||||
usage: /revive
|
||||
InvSee:
|
||||
description: InvSee
|
||||
default: false
|
||||
@ -44,18 +47,10 @@ commands:
|
||||
description: Freeze
|
||||
default: false
|
||||
usage: /freeze
|
||||
Revive:
|
||||
description: Revive
|
||||
ViewEnderChest:
|
||||
description: ViewEnderChest
|
||||
default: false
|
||||
usage: /revive
|
||||
Spy:
|
||||
description: Spy
|
||||
default: false
|
||||
usage: /spy
|
||||
CommandSpy:
|
||||
description: CommandSpy
|
||||
default: false
|
||||
usage: /commandspy
|
||||
usage: /ViewEnderChest
|
||||
Ban:
|
||||
description: Ban
|
||||
default: false
|
||||
|
Loading…
Reference in New Issue
Block a user