mirror of
https://github.com/songoda/UltimateModeration.git
synced 2024-11-21 17:56:28 +01:00
Merge branch 'development'
This commit is contained in:
commit
3e9af568f4
26
.editorconfig
Normal file
26
.editorconfig
Normal file
@ -0,0 +1,26 @@
|
||||
root = true
|
||||
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
# max_line_length = 120
|
||||
tab_width = 4
|
||||
trim_trailing_whitespace = true
|
||||
ij_continuation_indent_size = 8
|
||||
ij_formatter_off_tag = @formatter:off
|
||||
ij_formatter_on_tag = @formatter:on
|
||||
ij_formatter_tags_enabled = true
|
||||
|
||||
|
||||
[{*.yaml,*.yml,*.json,*.lang,*.graphqlconfig,*.har,*.jsb2,*.jsb3,*.webmanifest,.babelrc,.eslintrc,.prettierrc,.stylelintrc,bowerrc,jest.config}]
|
||||
indent_size = 2
|
||||
tab_width = 2
|
||||
|
||||
|
||||
[{*.markdown,*.md,*.html,*.htm,*.ng,*.sht,*.shtm,*.shtml,*.ts,*.ats,*.js,*.cjs,*.bash,*.sh,*.zsh}]
|
||||
indent_size = 2
|
||||
tab_width = 2
|
1
.github/FUNDING.yml
vendored
Normal file
1
.github/FUNDING.yml
vendored
Normal file
@ -0,0 +1 @@
|
||||
custom: [ 'https://craftaro.to/+' ]
|
38
.gitignore
vendored
38
.gitignore
vendored
@ -1,34 +1,10 @@
|
||||
# Compiled class file
|
||||
*.class
|
||||
|
||||
# Log file
|
||||
*.log
|
||||
|
||||
# BlueJ files
|
||||
*.ctxt
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.nar
|
||||
*.settings
|
||||
*.ear
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
/.gradle/
|
||||
/.settings/
|
||||
## JetBrains IDEs
|
||||
/.idea/
|
||||
/build/
|
||||
/bin/
|
||||
/target/
|
||||
*.iml
|
||||
src/\.DS_Store
|
||||
|
||||
\.DS_Store
|
||||
## Maven
|
||||
/**/target/
|
||||
dependency-reduced-pom.xml
|
||||
|
||||
## Misc.
|
||||
.DS_Store
|
||||
|
152
pom.xml
152
pom.xml
@ -1,104 +1,115 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0">
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>UltimateModeration</artifactId>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<version>2.0.15</version>
|
||||
|
||||
<groupId>com.craftaro</groupId>
|
||||
<artifactId>UltimateModeration</artifactId>
|
||||
<version>3.3.0</version>
|
||||
|
||||
<name>UltimateModeration</name>
|
||||
<description>Take complete control over your server with punishment templates via a simplified yet powerful moderation system</description>
|
||||
<url>https://craftaro.com/marketplace/product/29</url>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.release>8</maven.compiler.release>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<issueManagement>
|
||||
<url>https://discord.gg/craftaro</url>
|
||||
<system>Discord server</system>
|
||||
</issueManagement>
|
||||
|
||||
<scm>
|
||||
<url>https://github.com/craftaro/UltimateModeration</url>
|
||||
<connection>scm:git:git://github.com/craftaro/UltimateModeration.git</connection>
|
||||
</scm>
|
||||
|
||||
<build>
|
||||
<defaultGoal>clean install</defaultGoal>
|
||||
<finalName>UltimateModeration-${project.version}</finalName>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.0</version>
|
||||
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>com.google.code.maven-replacer-plugin</groupId>
|
||||
<artifactId>replacer</artifactId>
|
||||
<version>1.5.3</version>
|
||||
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>prepare-package</phase>
|
||||
<goals>
|
||||
<goal>replace</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
|
||||
<configuration>
|
||||
<file>${project.build.directory}/classes/plugin.yml</file>
|
||||
<replacements>
|
||||
<replacement>
|
||||
<token>maven-version-number</token>
|
||||
<value>${project.version}</value>
|
||||
</replacement>
|
||||
</replacements>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<version>3.5.3</version>
|
||||
|
||||
<executions>
|
||||
<execution>
|
||||
<id>shaded</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
|
||||
<configuration>
|
||||
<shadedArtifactAttached>false</shadedArtifactAttached>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<finalName>${project.name}-${project.version}</finalName>
|
||||
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>com.songoda:SongodaCore</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<shadedArtifactAttached>false</shadedArtifactAttached>
|
||||
<useDependencyReducedPomInJar>true</useDependencyReducedPomInJar>
|
||||
<minimizeJar>true</minimizeJar>
|
||||
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>com.craftaro.core</pattern>
|
||||
<shadedPattern>com.craftaro.ultimatemoderation.core</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>*:*</artifact>
|
||||
|
||||
<excludes>
|
||||
<exclude>META-INF/*.SF</exclude>
|
||||
<exclude>META-INF/*.DSA</exclude>
|
||||
<exclude>META-INF/*.RSA</exclude>
|
||||
<exclude>META-INF/**</exclude>
|
||||
<exclude>LICENSE</exclude>
|
||||
<exclude>LICENSE.**</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
|
||||
<filter>
|
||||
<artifact>com.craftaro:CraftaroCore</artifact>
|
||||
<excludeDefaults>false</excludeDefaults>
|
||||
<includes>
|
||||
<include>**/nms/v*/**</include>
|
||||
<include>**/third_party/net/kyori/**</include>
|
||||
</includes>
|
||||
<excludes>
|
||||
<exclude>**/third_party/org/apache/**</exclude>
|
||||
<exclude>**/third_party/com/zaxxer/**</exclude>
|
||||
<exclude>**/third_party/org/jooq/**</exclude>
|
||||
<exclude>**/third_party/org/mariadb/**</exclude>
|
||||
<exclude>**/third_party/com/h2database/**</exclude>
|
||||
<exclude>**/third_party/org/h2/**</exclude>
|
||||
<exclude>**/third_party/com/cryptomorin/**</exclude>
|
||||
<exclude>**/third_party/org/reactivestreams/**</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
</filters>
|
||||
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>com.songoda.core</pattern>
|
||||
<shadedPattern>${project.groupId}.ultimatemoderation.core</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>songoda-public</id>
|
||||
<url>https://repo.songoda.com/repository/public/</url>
|
||||
<id>craftaro-minecraft-plugins</id>
|
||||
<url>https://repo.craftaro.com/repository/minecraft-plugins/</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>spigotmc-repo</id>
|
||||
<id>SpigotMC</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
|
||||
@ -106,13 +117,18 @@
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io/</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>songoda-public</id>
|
||||
<url>https://repo.craftaro.com/repository/public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>SongodaCore</artifactId>
|
||||
<version>2.6.19</version>
|
||||
<groupId>com.craftaro</groupId>
|
||||
<artifactId>CraftaroCore</artifactId>
|
||||
<version>3.5.0-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
|
@ -0,0 +1,237 @@
|
||||
package com.craftaro.ultimatemoderation;
|
||||
|
||||
import com.craftaro.core.SongodaCore;
|
||||
import com.craftaro.core.SongodaPlugin;
|
||||
import com.craftaro.core.commands.CommandManager;
|
||||
import com.craftaro.core.compatibility.ServerVersion;
|
||||
import com.craftaro.core.configuration.Config;
|
||||
import com.craftaro.core.gui.GuiManager;
|
||||
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.craftaro.ultimatemoderation.commands.CommandBan;
|
||||
import com.craftaro.ultimatemoderation.commands.CommandClearChat;
|
||||
import com.craftaro.ultimatemoderation.commands.CommandHelp;
|
||||
import com.craftaro.ultimatemoderation.commands.CommandKick;
|
||||
import com.craftaro.ultimatemoderation.commands.CommandMute;
|
||||
import com.craftaro.ultimatemoderation.commands.CommandRandomPlayer;
|
||||
import com.craftaro.ultimatemoderation.commands.CommandReload;
|
||||
import com.craftaro.ultimatemoderation.commands.CommandRunTemplate;
|
||||
import com.craftaro.ultimatemoderation.commands.CommandSettings;
|
||||
import com.craftaro.ultimatemoderation.commands.CommandSlowMode;
|
||||
import com.craftaro.ultimatemoderation.commands.CommandStaffChat;
|
||||
import com.craftaro.ultimatemoderation.commands.CommandTicket;
|
||||
import com.craftaro.ultimatemoderation.commands.CommandToggleChat;
|
||||
import com.craftaro.ultimatemoderation.commands.CommandUltimateModeration;
|
||||
import com.craftaro.ultimatemoderation.commands.CommandUnBan;
|
||||
import com.craftaro.ultimatemoderation.commands.CommandUnMute;
|
||||
import com.craftaro.ultimatemoderation.commands.CommandVanish;
|
||||
import com.craftaro.ultimatemoderation.commands.CommandWarn;
|
||||
import com.craftaro.ultimatemoderation.database.DataHelper;
|
||||
import com.craftaro.ultimatemoderation.database.migrations._1_InitialMigration;
|
||||
import com.craftaro.ultimatemoderation.listeners.BlockListener;
|
||||
import com.craftaro.ultimatemoderation.listeners.ChatListener;
|
||||
import com.craftaro.ultimatemoderation.listeners.CommandListener;
|
||||
import com.craftaro.ultimatemoderation.listeners.DeathListener;
|
||||
import com.craftaro.ultimatemoderation.listeners.DropListener;
|
||||
import com.craftaro.ultimatemoderation.listeners.InventoryListener;
|
||||
import com.craftaro.ultimatemoderation.listeners.LoginListener;
|
||||
import com.craftaro.ultimatemoderation.listeners.MobTargetLister;
|
||||
import com.craftaro.ultimatemoderation.listeners.MoveListener;
|
||||
import com.craftaro.ultimatemoderation.listeners.SkyBlockListener;
|
||||
import com.craftaro.ultimatemoderation.listeners.SpyingDismountListener;
|
||||
import com.craftaro.ultimatemoderation.moderate.ModerationManager;
|
||||
import com.craftaro.ultimatemoderation.punish.AppliedPunishment;
|
||||
import com.craftaro.ultimatemoderation.punish.PunishmentNote;
|
||||
import com.craftaro.ultimatemoderation.punish.player.PunishmentManager;
|
||||
import com.craftaro.ultimatemoderation.punish.template.Template;
|
||||
import com.craftaro.ultimatemoderation.punish.template.TemplateManager;
|
||||
import com.craftaro.ultimatemoderation.settings.Settings;
|
||||
import com.craftaro.ultimatemoderation.staffchat.StaffChatManager;
|
||||
import com.craftaro.ultimatemoderation.tasks.DataTask;
|
||||
import com.craftaro.ultimatemoderation.tasks.SlowModeTask;
|
||||
import com.craftaro.ultimatemoderation.tickets.Ticket;
|
||||
import com.craftaro.ultimatemoderation.tickets.TicketManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class UltimateModeration extends SongodaPlugin {
|
||||
private final GuiManager guiManager = new GuiManager(this);
|
||||
private TicketManager ticketManager;
|
||||
private TemplateManager templateManager;
|
||||
private CommandManager commandManager;
|
||||
private PunishmentManager punishmentManager;
|
||||
private StaffChatManager staffChatManager;
|
||||
private ModerationManager moderationManager;
|
||||
private DataHelper dataHelper;
|
||||
private DataTask dataTask;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link JavaPlugin#getPlugin(Class)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static UltimateModeration getInstance() {
|
||||
return getPlugin(UltimateModeration.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginLoad() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginDisable() {
|
||||
if (dataTask != null) {
|
||||
dataTask.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginEnable() {
|
||||
// Run Songoda Updater
|
||||
SongodaCore.registerPlugin(this, 29, XMaterial.DIAMOND_CHESTPLATE);
|
||||
|
||||
// Setup Config
|
||||
Settings.setupConfig();
|
||||
this.setLocale(Settings.LANGUGE_MODE.getString(), false);
|
||||
|
||||
// Register commands
|
||||
this.commandManager = new CommandManager(this);
|
||||
this.commandManager.addCommand(new CommandUltimateModeration(this))
|
||||
.addSubCommands(
|
||||
new CommandReload(this),
|
||||
new CommandSettings(this, this.guiManager),
|
||||
new CommandHelp(this)
|
||||
);
|
||||
this.commandManager.addCommand(new CommandBan(this));
|
||||
this.commandManager.addCommand(new CommandClearChat(this));
|
||||
this.commandManager.addCommand(new CommandKick(this));
|
||||
this.commandManager.addCommand(new CommandMute(this));
|
||||
this.commandManager.addCommand(new CommandRandomPlayer(this));
|
||||
this.commandManager.addCommand(new CommandRunTemplate(this));
|
||||
this.commandManager.addCommand(new CommandSlowMode(this));
|
||||
this.commandManager.addCommand(new CommandStaffChat(this));
|
||||
this.commandManager.addCommand(new CommandTicket(this, this.guiManager));
|
||||
this.commandManager.addCommand(new CommandToggleChat(this));
|
||||
this.commandManager.addCommand(new CommandUnBan(this));
|
||||
this.commandManager.addCommand(new CommandUnMute(this));
|
||||
this.commandManager.addCommand(new CommandVanish());
|
||||
this.commandManager.addCommand(new CommandWarn(this));
|
||||
|
||||
// Setup Managers
|
||||
this.ticketManager = new TicketManager();
|
||||
this.templateManager = new TemplateManager();
|
||||
this.punishmentManager = new PunishmentManager();
|
||||
this.staffChatManager = new StaffChatManager();
|
||||
this.moderationManager = new ModerationManager(this);
|
||||
|
||||
try {
|
||||
initDatabase(Arrays.asList(new _1_InitialMigration()));
|
||||
this.dataHelper = new DataHelper(getDataManager(), this);
|
||||
|
||||
} 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.");
|
||||
emergencyStop();
|
||||
return;
|
||||
}
|
||||
|
||||
// Register Listeners
|
||||
this.guiManager.init();
|
||||
PluginManager pluginManager = Bukkit.getPluginManager();
|
||||
pluginManager.registerEvents(new CommandListener(this), this);
|
||||
pluginManager.registerEvents(new DeathListener(), this);
|
||||
pluginManager.registerEvents(new MoveListener(this), this);
|
||||
pluginManager.registerEvents(new DropListener(this), this);
|
||||
pluginManager.registerEvents(new InventoryListener(this), this);
|
||||
pluginManager.registerEvents(new ChatListener(this), this);
|
||||
pluginManager.registerEvents(new LoginListener(this), this);
|
||||
pluginManager.registerEvents(new MobTargetLister(), this);
|
||||
pluginManager.registerEvents(new BlockListener(this), this);
|
||||
if (pluginManager.isPluginEnabled("FabledSkyBlock")) {
|
||||
pluginManager.registerEvents(new SkyBlockListener(), this);
|
||||
}
|
||||
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) {
|
||||
pluginManager.registerEvents(new SpyingDismountListener(this), this);
|
||||
}
|
||||
|
||||
// Start tasks
|
||||
SlowModeTask.startTask(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataLoad() {
|
||||
getDataManager().getAsyncPool().execute(() -> {
|
||||
// Load data from DB
|
||||
this.dataHelper.getTemplates((templates) -> {
|
||||
for (Template template : templates) {
|
||||
this.templateManager.addTemplate(template);
|
||||
}
|
||||
});
|
||||
this.dataHelper.getAppliedPunishments((appliedPunishments) -> {
|
||||
for (AppliedPunishment punishment : appliedPunishments) {
|
||||
this.punishmentManager.getPlayer(punishment.getVictim()).addPunishment(punishment);
|
||||
}
|
||||
});
|
||||
this.dataHelper.getNotes((notes) -> {
|
||||
for (PunishmentNote note : notes) {
|
||||
this.punishmentManager.getPlayer(note.getSubject()).addNotes(note);
|
||||
}
|
||||
});
|
||||
this.dataHelper.getTickets((tickets) -> {
|
||||
for (Ticket ticket : tickets.values()) {
|
||||
this.ticketManager.addTicket(ticket);
|
||||
}
|
||||
});
|
||||
});
|
||||
if (dataTask != null) {
|
||||
dataTask.cancel();
|
||||
}
|
||||
dataTask = new DataTask(this.dataHelper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigReload() {
|
||||
this.setLocale(getConfig().getString("System.Language Mode"), true);
|
||||
this.locale.reloadMessages();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Config> getExtraConfig() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public CommandManager getCommandManager() {
|
||||
return this.commandManager;
|
||||
}
|
||||
|
||||
public TemplateManager getTemplateManager() {
|
||||
return this.templateManager;
|
||||
}
|
||||
|
||||
public PunishmentManager getPunishmentManager() {
|
||||
return this.punishmentManager;
|
||||
}
|
||||
|
||||
public TicketManager getTicketManager() {
|
||||
return this.ticketManager;
|
||||
}
|
||||
|
||||
public StaffChatManager getStaffChatManager() {
|
||||
return this.staffChatManager;
|
||||
}
|
||||
|
||||
public GuiManager getGuiManager() {
|
||||
return this.guiManager;
|
||||
}
|
||||
|
||||
public ModerationManager getModerationManager() {
|
||||
return this.moderationManager;
|
||||
}
|
||||
|
||||
public DataHelper getDataHelper() {
|
||||
return this.dataHelper;
|
||||
}
|
||||
}
|
@ -1,11 +1,11 @@
|
||||
package com.songoda.ultimatemoderation.commands;
|
||||
package com.craftaro.ultimatemoderation.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.punish.Punishment;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentType;
|
||||
import com.songoda.ultimatemoderation.utils.Methods;
|
||||
import com.songoda.ultimatemoderation.utils.VaultPermissions;
|
||||
import com.craftaro.core.commands.AbstractCommand;
|
||||
import com.craftaro.core.utils.TimeUtils;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.ultimatemoderation.punish.Punishment;
|
||||
import com.craftaro.ultimatemoderation.punish.PunishmentType;
|
||||
import com.craftaro.ultimatemoderation.utils.VaultPermissions;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -17,7 +17,6 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandBan extends AbstractCommand {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
public CommandBan(UltimateModeration plugin) {
|
||||
@ -27,21 +26,23 @@ public class CommandBan extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length < 1)
|
||||
if (args.length < 1) {
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
// I dream of the day where someone creates a ticket because
|
||||
// they can't ban someone for the reason "Stole me 2h sword".
|
||||
// I dream of the day when someone creates a ticket because
|
||||
// they can't ban someone for the reason "Stole me 2h sword"
|
||||
long duration = 0;
|
||||
StringBuilder reasonBuilder = new StringBuilder();
|
||||
if (args.length > 1) {
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
String line = args[i];
|
||||
long time = Methods.parseTime(line);
|
||||
if (time != 0)
|
||||
long time = TimeUtils.parseTime(line);
|
||||
if (time != 0) {
|
||||
duration += time;
|
||||
else
|
||||
} else {
|
||||
reasonBuilder.append(line).append(" ");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -49,21 +50,21 @@ public class CommandBan extends AbstractCommand {
|
||||
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(args[0]);
|
||||
|
||||
if (plugin.getPunishmentManager().getPlayer(player).getActivePunishments()
|
||||
if (this.plugin.getPunishmentManager().getPlayer(player).getActivePunishments()
|
||||
.stream().anyMatch(appliedPunishment -> appliedPunishment.getPunishmentType() == PunishmentType.BAN)) {
|
||||
plugin.getLocale().newMessage("That player is already banned.").sendPrefixedMessage(sender);
|
||||
this.plugin.getLocale().newMessage("That player is already banned.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
if (duration == 0 && !sender.hasPermission("um.ban.permanent")) {
|
||||
plugin.getLocale().getMessage("event.general.nopermission").sendPrefixedMessage(sender);
|
||||
this.plugin.getLocale().getMessage("event.general.nopermission").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
long durationFinal = duration;
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> {
|
||||
if (sender instanceof Player && VaultPermissions.hasPermission(player, "um.ban.exempt")) {
|
||||
plugin.getLocale().newMessage("You cannot ban this player.").sendPrefixedMessage(sender);
|
||||
this.plugin.getLocale().newMessage("You cannot ban this player.").sendPrefixedMessage(sender);
|
||||
return;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.songoda.ultimatemoderation.commands;
|
||||
package com.craftaro.ultimatemoderation.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.core.commands.AbstractCommand;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -11,7 +11,6 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandClearChat extends AbstractCommand {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
public CommandClearChat(UltimateModeration plugin) {
|
||||
@ -21,9 +20,9 @@ public class CommandClearChat extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
|
||||
if (args.length != 0 && !args[0].equalsIgnoreCase("force"))
|
||||
if (args.length != 0 && !args[0].equalsIgnoreCase("force")) {
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (!player.hasPermission("um.clearchat.bypass") || isForced(args)) {
|
||||
@ -32,13 +31,14 @@ public class CommandClearChat extends AbstractCommand {
|
||||
player.sendMessage(toSend);
|
||||
}
|
||||
|
||||
plugin.getLocale().getMessage("command.clearchat.cleared")
|
||||
this.plugin.getLocale().getMessage("command.clearchat.cleared")
|
||||
.processPlaceholder("player", sender.getName()).sendPrefixedMessage(player);
|
||||
|
||||
if (player.hasPermission("um.clearchat.bypass") && !isForced(args)) {
|
||||
plugin.getLocale().getMessage("command.clearchat.immune").sendMessage(player);
|
||||
this.plugin.getLocale().getMessage("command.clearchat.immune").sendMessage(player);
|
||||
}
|
||||
}
|
||||
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
@ -1,14 +1,13 @@
|
||||
package com.songoda.ultimatemoderation.commands;
|
||||
package com.craftaro.ultimatemoderation.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.utils.Methods;
|
||||
import com.craftaro.core.commands.AbstractCommand;
|
||||
import com.craftaro.core.utils.TextUtils;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CommandHelp extends AbstractCommand {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
public CommandHelp(UltimateModeration plugin) {
|
||||
@ -19,15 +18,15 @@ public class CommandHelp extends AbstractCommand {
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
sender.sendMessage("");
|
||||
plugin.getLocale().getMessage("&7Version " + plugin.getDescription().getVersion() + " Created with <3 by &5&l&oSongoda")
|
||||
this.plugin.getLocale().getMessage("&7Version " + this.plugin.getDescription().getVersion() + " Created with <3 by &5&l&oSongoda")
|
||||
.sendPrefixedMessage(sender);
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage(Methods.formatText("&7Welcome to UltimateModeration! To get started try using the /um command to access the moderation panel."));
|
||||
sender.sendMessage(TextUtils.formatText("&7Welcome to UltimateModeration! To get started try using the /um command to access the moderation panel."));
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage(Methods.formatText("&6Commands:"));
|
||||
for (AbstractCommand command : plugin.getCommandManager().getAllCommands()) {
|
||||
sender.sendMessage(TextUtils.formatText("&6Commands:"));
|
||||
for (AbstractCommand command : this.plugin.getCommandManager().getAllCommands()) {
|
||||
if (command.getPermissionNode() == null || sender.hasPermission(command.getPermissionNode())) {
|
||||
sender.sendMessage(Methods.formatText("&8 - &a" + command.getSyntax() + "&7 - " + command.getDescription()));
|
||||
sender.sendMessage(TextUtils.formatText("&8 - &a" + command.getSyntax() + "&7 - " + command.getDescription()));
|
||||
}
|
||||
}
|
||||
sender.sendMessage("");
|
@ -1,9 +1,9 @@
|
||||
package com.songoda.ultimatemoderation.commands;
|
||||
package com.craftaro.ultimatemoderation.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.punish.Punishment;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentType;
|
||||
import com.craftaro.core.commands.AbstractCommand;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.ultimatemoderation.punish.Punishment;
|
||||
import com.craftaro.ultimatemoderation.punish.PunishmentType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -14,7 +14,6 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandKick extends AbstractCommand {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
public CommandKick(UltimateModeration plugin) {
|
||||
@ -24,8 +23,9 @@ public class CommandKick extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length < 1)
|
||||
if (args.length < 1) {
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
StringBuilder reasonBuilder = new StringBuilder();
|
||||
if (args.length > 1) {
|
||||
@ -40,7 +40,7 @@ public class CommandKick extends AbstractCommand {
|
||||
OfflinePlayer player = Bukkit.getPlayer(args[0]);
|
||||
|
||||
if (sender instanceof Player && player.getPlayer().hasPermission("um.kick.exempt")) {
|
||||
plugin.getLocale().newMessage("You cannot kick this player.").sendPrefixedMessage(sender);
|
||||
this.plugin.getLocale().newMessage("You cannot kick this player.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
package com.songoda.ultimatemoderation.commands;
|
||||
package com.craftaro.ultimatemoderation.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.punish.Punishment;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentType;
|
||||
import com.songoda.ultimatemoderation.utils.Methods;
|
||||
import com.songoda.ultimatemoderation.utils.VaultPermissions;
|
||||
import com.craftaro.core.commands.AbstractCommand;
|
||||
import com.craftaro.core.utils.TimeUtils;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.ultimatemoderation.punish.Punishment;
|
||||
import com.craftaro.ultimatemoderation.punish.PunishmentType;
|
||||
import com.craftaro.ultimatemoderation.utils.VaultPermissions;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -17,7 +17,6 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandMute extends AbstractCommand {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
public CommandMute(UltimateModeration plugin) {
|
||||
@ -27,21 +26,23 @@ public class CommandMute extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length < 1)
|
||||
if (args.length < 1) {
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
// I dream of the day where someone creates a ticket because
|
||||
// I dream of the day when someone creates a ticket because
|
||||
// they can't ban someone for the reason "Stole me 2h sword".
|
||||
long duration = 0;
|
||||
StringBuilder reasonBuilder = new StringBuilder();
|
||||
if (args.length > 1) {
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
String line = args[i];
|
||||
long time = Methods.parseTime(line);
|
||||
if (time != 0)
|
||||
long time = TimeUtils.parseTime(line);
|
||||
if (time != 0) {
|
||||
duration += time;
|
||||
else
|
||||
} else {
|
||||
reasonBuilder.append(line).append(" ");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -50,13 +51,13 @@ public class CommandMute extends AbstractCommand {
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(args[0]);
|
||||
|
||||
if (sender instanceof Player && VaultPermissions.hasPermission(player, "um.mute.exempt")) {
|
||||
plugin.getLocale().newMessage("You cannot mute that player.").sendPrefixedMessage(sender);
|
||||
this.plugin.getLocale().newMessage("You cannot mute that player.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
if (plugin.getPunishmentManager().getPlayer(player).getActivePunishments()
|
||||
if (this.plugin.getPunishmentManager().getPlayer(player).getActivePunishments()
|
||||
.stream().anyMatch(appliedPunishment -> appliedPunishment.getPunishmentType() == PunishmentType.MUTE)) {
|
||||
plugin.getLocale().newMessage("That player is already muted.").sendPrefixedMessage(sender);
|
||||
this.plugin.getLocale().newMessage("That player is already muted.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.songoda.ultimatemoderation.commands;
|
||||
package com.craftaro.ultimatemoderation.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.core.commands.AbstractCommand;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -11,7 +11,6 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandRandomPlayer extends AbstractCommand {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
public CommandRandomPlayer(UltimateModeration plugin) {
|
||||
@ -26,7 +25,7 @@ public class CommandRandomPlayer extends AbstractCommand {
|
||||
players.remove(sender);
|
||||
|
||||
if (players.size() == 0) {
|
||||
plugin.getLocale().newMessage("&cYou are the only one online!").sendPrefixedMessage(sender);
|
||||
this.plugin.getLocale().newMessage("&cYou are the only one online!").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
@ -1,13 +1,12 @@
|
||||
package com.songoda.ultimatemoderation.commands;
|
||||
package com.craftaro.ultimatemoderation.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.core.commands.AbstractCommand;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CommandReload extends AbstractCommand {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
public CommandReload(UltimateModeration plugin) {
|
||||
@ -17,8 +16,8 @@ public class CommandReload extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
plugin.reloadConfig();
|
||||
plugin.getLocale().newMessage("&7Configuration and Language files reloaded.").sendPrefixedMessage(sender);
|
||||
this.plugin.reloadConfig();
|
||||
this.plugin.getLocale().newMessage("&7Configuration and Language files reloaded.").sendPrefixedMessage(sender);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
package com.songoda.ultimatemoderation.commands;
|
||||
package com.craftaro.ultimatemoderation.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.punish.template.Template;
|
||||
import com.craftaro.core.commands.AbstractCommand;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.ultimatemoderation.punish.template.Template;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -12,7 +12,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandRunTemplate extends AbstractCommand {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
public CommandRunTemplate(UltimateModeration plugin) {
|
||||
@ -34,7 +33,7 @@ public class CommandRunTemplate extends AbstractCommand {
|
||||
}
|
||||
String templateStr = templateBuilder.toString().trim();
|
||||
|
||||
Template template = plugin.getTemplateManager().getTemplate(templateStr);
|
||||
Template template = this.plugin.getTemplateManager().getTemplate(templateStr);
|
||||
|
||||
if (template == null) {
|
||||
sender.sendMessage("That template does not exist...");
|
||||
@ -56,7 +55,7 @@ public class CommandRunTemplate extends AbstractCommand {
|
||||
return players;
|
||||
} else if (args.length == 2) {
|
||||
List<String> lines = new ArrayList<>();
|
||||
for (Template template : plugin.getTemplateManager().getTemplates()) {
|
||||
for (Template template : this.plugin.getTemplateManager().getTemplates()) {
|
||||
lines.add(template.getName());
|
||||
}
|
||||
}
|
@ -1,16 +1,15 @@
|
||||
package com.songoda.ultimatemoderation.commands;
|
||||
package com.craftaro.ultimatemoderation.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.core.configuration.editor.PluginConfigGui;
|
||||
import com.songoda.core.gui.GuiManager;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.core.commands.AbstractCommand;
|
||||
import com.craftaro.core.configuration.editor.PluginConfigGui;
|
||||
import com.craftaro.core.gui.GuiManager;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CommandSettings extends AbstractCommand {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
private final GuiManager guiManager;
|
||||
|
||||
@ -22,8 +21,7 @@ public class CommandSettings extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
Player player = (Player) sender;
|
||||
guiManager.showGUI((Player) sender, new PluginConfigGui(plugin));
|
||||
this.guiManager.showGUI((Player) sender, new PluginConfigGui(this.plugin));
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
package com.songoda.ultimatemoderation.commands;
|
||||
package com.craftaro.ultimatemoderation.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.listeners.ChatListener;
|
||||
import com.songoda.ultimatemoderation.utils.Methods;
|
||||
import com.craftaro.core.commands.AbstractCommand;
|
||||
import com.craftaro.core.utils.TimeUtils;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.ultimatemoderation.listeners.ChatListener;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -12,7 +12,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandSlowMode extends AbstractCommand {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
public CommandSlowMode(UltimateModeration plugin) {
|
||||
@ -24,18 +23,19 @@ public class CommandSlowMode extends AbstractCommand {
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length == 0) {
|
||||
ChatListener.setSlowModeOverride(0);
|
||||
plugin.getLocale().getMessage("event.slowmode.disabled").sendPrefixedMessage(sender);
|
||||
this.plugin.getLocale().getMessage("event.slowmode.disabled").sendPrefixedMessage(sender);
|
||||
return ReturnType.SUCCESS;
|
||||
} else if (args.length != 1)
|
||||
} else if (args.length != 1) {
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
long delay = Methods.parseTime(args[0]);
|
||||
long delay = TimeUtils.parseTime(args[0]);
|
||||
|
||||
ChatListener.setSlowModeOverride(delay);
|
||||
|
||||
Bukkit.getOnlinePlayers().forEach(player ->
|
||||
plugin.getLocale().getMessage("event.slowmode.enabled")
|
||||
.processPlaceholder("delay", Methods.makeReadable(delay)).sendPrefixedMessage(player));
|
||||
this.plugin.getLocale().getMessage("event.slowmode.enabled")
|
||||
.processPlaceholder("delay", TimeUtils.makeReadable(delay)).sendPrefixedMessage(player));
|
||||
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
package com.songoda.ultimatemoderation.commands;
|
||||
package com.craftaro.ultimatemoderation.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.staffchat.StaffChannel;
|
||||
import com.craftaro.core.commands.AbstractCommand;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.ultimatemoderation.staffchat.StaffChannel;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -10,7 +10,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandStaffChat extends AbstractCommand {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
public CommandStaffChat(UltimateModeration plugin) {
|
||||
@ -20,33 +19,36 @@ public class CommandStaffChat extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length != 1)
|
||||
if (args.length != 1) {
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
String channelName = args[0];
|
||||
Player player = (Player) sender;
|
||||
|
||||
if (channelName.trim().equalsIgnoreCase("leave")) {
|
||||
for (StaffChannel channel : plugin.getStaffChatManager().getChats().values()) {
|
||||
if (!channel.listMembers().contains(player.getUniqueId())) continue;
|
||||
for (StaffChannel channel : this.plugin.getStaffChatManager().getChats().values()) {
|
||||
if (!channel.listMembers().contains(player.getUniqueId())) {
|
||||
continue;
|
||||
}
|
||||
channel.removeMember(player);
|
||||
plugin.getLocale().getMessage("event.staffchat.leave")
|
||||
this.plugin.getLocale().getMessage("event.staffchat.leave")
|
||||
.processPlaceholder("channel", channel.getChannelName()).sendPrefixedMessage(player);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
plugin.getLocale().getMessage("event.staffchat.nochannels").sendPrefixedMessage(player);
|
||||
this.plugin.getLocale().getMessage("event.staffchat.nochannels").sendPrefixedMessage(player);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
plugin.getLocale().getMessage("event.staffchat.join")
|
||||
this.plugin.getLocale().getMessage("event.staffchat.join")
|
||||
.processPlaceholder("channel", channelName).sendPrefixedMessage(player);
|
||||
plugin.getStaffChatManager().getChat(channelName).addMember(player);
|
||||
this.plugin.getStaffChatManager().getChat(channelName).addMember(player);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender sender, String... args) {
|
||||
return new ArrayList<>(plugin.getStaffChatManager().getChats().keySet());
|
||||
return new ArrayList<>(this.plugin.getStaffChatManager().getChats().keySet());
|
||||
}
|
||||
|
||||
@Override
|
@ -1,16 +1,15 @@
|
||||
package com.songoda.ultimatemoderation.commands;
|
||||
package com.craftaro.ultimatemoderation.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.core.gui.GuiManager;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.gui.TicketManagerGui;
|
||||
import com.craftaro.core.commands.AbstractCommand;
|
||||
import com.craftaro.core.gui.GuiManager;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.ultimatemoderation.gui.TicketManagerGui;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CommandTicket extends AbstractCommand {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
private final GuiManager guiManager;
|
||||
|
||||
@ -23,7 +22,7 @@ public class CommandTicket extends AbstractCommand {
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
Player senderP = ((Player) sender);
|
||||
guiManager.showGUI(senderP, new TicketManagerGui(plugin, senderP, senderP));
|
||||
this.guiManager.showGUI(senderP, new TicketManagerGui(this.plugin, senderP, senderP));
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@ -46,5 +45,4 @@ public class CommandTicket extends AbstractCommand {
|
||||
public String getDescription() {
|
||||
return "Opens the ticket interface.";
|
||||
}
|
||||
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
package com.songoda.ultimatemoderation.commands;
|
||||
package com.craftaro.ultimatemoderation.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.core.locale.Message;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.listeners.ChatListener;
|
||||
import com.craftaro.core.commands.AbstractCommand;
|
||||
import com.craftaro.core.locale.Message;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.ultimatemoderation.listeners.ChatListener;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -11,7 +11,6 @@ import org.bukkit.entity.Player;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandToggleChat extends AbstractCommand {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
/*
|
||||
@ -26,25 +25,25 @@ public class CommandToggleChat extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
toggled = !toggled;
|
||||
this.toggled = !this.toggled;
|
||||
|
||||
Message message = toggled ? plugin.getLocale().getMessage("command.togglechat.toggledOn")
|
||||
: plugin.getLocale().getMessage("command.togglechat.toggledOff");
|
||||
Message message = this.toggled ? this.plugin.getLocale().getMessage("command.togglechat.toggledOn")
|
||||
: this.plugin.getLocale().getMessage("command.togglechat.toggledOff");
|
||||
|
||||
ChatListener.setChatToggled(toggled);
|
||||
ChatListener.setChatToggled(this.toggled);
|
||||
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
|
||||
message.sendPrefixedMessage(player);
|
||||
|
||||
if (!player.hasPermission(getPermissionNode() + ".bypass"))
|
||||
if (!player.hasPermission(getPermissionNode() + ".bypass")) {
|
||||
continue;
|
||||
|
||||
plugin.getLocale().getMessage("command.togglechat.bypass").sendMessage(player);
|
||||
}
|
||||
this.plugin.getLocale().getMessage("command.togglechat.bypass").sendMessage(player);
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player))
|
||||
if (!(sender instanceof Player)) {
|
||||
message.sendPrefixedMessage(sender);
|
||||
}
|
||||
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
@ -1,15 +1,14 @@
|
||||
package com.songoda.ultimatemoderation.commands;
|
||||
package com.craftaro.ultimatemoderation.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.gui.MainGui;
|
||||
import com.craftaro.core.commands.AbstractCommand;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.ultimatemoderation.gui.MainGui;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CommandUltimateModeration extends AbstractCommand {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
public CommandUltimateModeration(UltimateModeration plugin) {
|
||||
@ -19,7 +18,7 @@ public class CommandUltimateModeration extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
plugin.getGuiManager().showGUI((Player) sender, new MainGui(plugin, (Player) sender));
|
||||
this.plugin.getGuiManager().showGUI((Player) sender, new MainGui(this.plugin, (Player) sender));
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
package com.songoda.ultimatemoderation.commands;
|
||||
package com.craftaro.ultimatemoderation.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentType;
|
||||
import com.songoda.ultimatemoderation.punish.player.PlayerPunishData;
|
||||
import com.craftaro.core.commands.AbstractCommand;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.ultimatemoderation.punish.PunishmentType;
|
||||
import com.craftaro.ultimatemoderation.punish.player.PlayerPunishData;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -13,7 +13,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandUnBan extends AbstractCommand {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
public CommandUnBan(UltimateModeration plugin) {
|
||||
@ -23,22 +22,23 @@ public class CommandUnBan extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length != 1)
|
||||
if (args.length != 1) {
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(args[0]);
|
||||
|
||||
if (!plugin.getPunishmentManager().getPlayer(player).getActivePunishments()
|
||||
if (!this.plugin.getPunishmentManager().getPlayer(player).getActivePunishments()
|
||||
.stream().anyMatch(appliedPunishment -> appliedPunishment.getPunishmentType() == PunishmentType.BAN)) {
|
||||
plugin.getLocale().newMessage("That player isn't banned.").sendPrefixedMessage(sender);
|
||||
this.plugin.getLocale().newMessage("That player isn't banned.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
PlayerPunishData playerPunishData = plugin.getPunishmentManager().getPlayer(player);
|
||||
PlayerPunishData playerPunishData = this.plugin.getPunishmentManager().getPlayer(player);
|
||||
|
||||
playerPunishData.expirePunishments(PunishmentType.BAN);
|
||||
|
||||
plugin.getLocale().getMessage("event.unban.success")
|
||||
this.plugin.getLocale().getMessage("event.unban.success")
|
||||
.processPlaceholder("player", player.getName()).sendPrefixedMessage(sender);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
package com.songoda.ultimatemoderation.commands;
|
||||
package com.craftaro.ultimatemoderation.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentType;
|
||||
import com.songoda.ultimatemoderation.punish.player.PlayerPunishData;
|
||||
import com.craftaro.core.commands.AbstractCommand;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.ultimatemoderation.punish.PunishmentType;
|
||||
import com.craftaro.ultimatemoderation.punish.player.PlayerPunishData;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -13,7 +13,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandUnMute extends AbstractCommand {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
public CommandUnMute(UltimateModeration plugin) {
|
||||
@ -28,18 +27,18 @@ public class CommandUnMute extends AbstractCommand {
|
||||
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(args[0]);
|
||||
|
||||
if (!plugin.getPunishmentManager().getPlayer(player).getActivePunishments()
|
||||
if (!this.plugin.getPunishmentManager().getPlayer(player).getActivePunishments()
|
||||
.stream().anyMatch(appliedPunishment -> appliedPunishment.getPunishmentType() == PunishmentType.MUTE)) {
|
||||
plugin.getLocale().newMessage("That player isn't muted.").sendPrefixedMessage(sender);
|
||||
this.plugin.getLocale().newMessage("That player isn't muted.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
PlayerPunishData playerPunishData = plugin.getPunishmentManager().getPlayer(player);
|
||||
PlayerPunishData playerPunishData = this.plugin.getPunishmentManager().getPlayer(player);
|
||||
|
||||
playerPunishData.expirePunishments(PunishmentType.MUTE);
|
||||
|
||||
plugin.getLocale().newMessage(plugin.getLocale().getMessage("event.unmute.success")
|
||||
.processPlaceholder("player", player.getName()).getMessage()).sendPrefixedMessage(sender);
|
||||
this.plugin.getLocale().newMessage(this.plugin.getLocale().getMessage("event.unmute.success")
|
||||
.processPlaceholder("player", player.getName()).toText()).sendPrefixedMessage(sender);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
package com.songoda.ultimatemoderation.commands;
|
||||
package com.craftaro.ultimatemoderation.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.settings.Settings;
|
||||
import com.craftaro.core.commands.AbstractCommand;
|
||||
import com.craftaro.core.compatibility.ServerVersion;
|
||||
import com.craftaro.third_party.com.cryptomorin.xseries.XSound;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.ultimatemoderation.settings.Settings;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@ -18,7 +18,6 @@ import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class CommandVanish extends AbstractCommand {
|
||||
|
||||
private static final List<UUID> inVanish = new ArrayList<>();
|
||||
|
||||
public CommandVanish() {
|
||||
@ -28,7 +27,9 @@ public class CommandVanish extends AbstractCommand {
|
||||
public static void registerVanishedPlayers(Player player) {
|
||||
for (UUID uuid : inVanish) {
|
||||
Player vanished = Bukkit.getPlayer(uuid);
|
||||
if (vanished == null) continue;
|
||||
if (vanished == null) {
|
||||
continue;
|
||||
}
|
||||
if (player.hasPermission("um.vanish.bypass")) {
|
||||
player.showPlayer(vanished);
|
||||
} else {
|
||||
@ -44,20 +45,22 @@ public class CommandVanish extends AbstractCommand {
|
||||
|
||||
if (inVanish.contains(uuid)) {
|
||||
inVanish.remove(uuid);
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9))
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) {
|
||||
player.setInvulnerable(false);
|
||||
}
|
||||
player.setCanPickupItems(true);
|
||||
instance.getLocale().getMessage("command.vanish.toggledOff").sendPrefixedMessage(player);
|
||||
} else {
|
||||
inVanish.add(uuid);
|
||||
player.setCanPickupItems(false);
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9))
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) {
|
||||
player.setInvulnerable(true);
|
||||
}
|
||||
instance.getLocale().getMessage("command.vanish.toggledOn").sendPrefixedMessage(player);
|
||||
|
||||
}
|
||||
if (Settings.VANISH_EFFECTS.getBoolean()) {
|
||||
player.getWorld().playSound(player.getLocation(), Sound.valueOf(Settings.VANISH_SOUND.getString()), 1L, 1L);
|
||||
XSound.matchXSound(Settings.VANISH_SOUND.getString()).ifPresent(sound -> sound.play(player));
|
||||
|
||||
if (Settings.VANISH_BATS.getBoolean()) {
|
||||
List<Entity> entities = new ArrayList<>();
|
||||
@ -74,15 +77,17 @@ public class CommandVanish extends AbstractCommand {
|
||||
float xx = (float) (0 + (Math.random() * 1));
|
||||
float yy = (float) (0 + (Math.random() * 2));
|
||||
float zz = (float) (0 + (Math.random() * 1));
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_12))
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_12)) {
|
||||
player.getWorld().spawnParticle(Particle.valueOf(Settings.VANISH_PARTICLE.getString()), player.getLocation().add(0, 1, 0), 35, xx, yy, zz, 0);
|
||||
}
|
||||
}
|
||||
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
if (inVanish.contains(uuid))
|
||||
if (inVanish.contains(uuid)) {
|
||||
registerVanishedPlayers(p);
|
||||
else
|
||||
} else {
|
||||
p.showPlayer(player);
|
||||
}
|
||||
}
|
||||
for (Entity e : player.getNearbyEntities(30, 30, 30)) {
|
||||
if (e instanceof Monster) {
|
@ -1,11 +1,11 @@
|
||||
package com.songoda.ultimatemoderation.commands;
|
||||
package com.craftaro.ultimatemoderation.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.punish.Punishment;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentType;
|
||||
import com.songoda.ultimatemoderation.utils.Methods;
|
||||
import com.songoda.ultimatemoderation.utils.VaultPermissions;
|
||||
import com.craftaro.core.commands.AbstractCommand;
|
||||
import com.craftaro.core.utils.TimeUtils;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.ultimatemoderation.punish.Punishment;
|
||||
import com.craftaro.ultimatemoderation.punish.PunishmentType;
|
||||
import com.craftaro.ultimatemoderation.utils.VaultPermissions;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -17,7 +17,6 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandWarn extends AbstractCommand {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
public CommandWarn(UltimateModeration plugin) {
|
||||
@ -27,21 +26,23 @@ public class CommandWarn extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length < 1)
|
||||
if (args.length < 1) {
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
// I dream of the day where someone creates a ticket because
|
||||
// I dream of the day when someone creates a ticket because
|
||||
// they can't ban someone for the reason "Stole me 2h sword".
|
||||
long duration = 0;
|
||||
StringBuilder reasonBuilder = new StringBuilder();
|
||||
if (args.length > 1) {
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
String line = args[i];
|
||||
long time = Methods.parseTime(line);
|
||||
if (time != 0)
|
||||
long time = TimeUtils.parseTime(line);
|
||||
if (time != 0) {
|
||||
duration += time;
|
||||
else
|
||||
} else {
|
||||
reasonBuilder.append(line).append(" ");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -50,7 +51,7 @@ public class CommandWarn extends AbstractCommand {
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(args[0]);
|
||||
|
||||
if (sender instanceof Player && VaultPermissions.hasPermission(player, "um.warning.exempt")) {
|
||||
plugin.getLocale().newMessage("You cannot warn that player.").sendPrefixedMessage(sender);
|
||||
this.plugin.getLocale().newMessage("You cannot warn that player.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
@ -1,16 +1,26 @@
|
||||
package com.songoda.ultimatemoderation.database;
|
||||
package com.craftaro.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 com.craftaro.core.chat.AdventureUtils;
|
||||
import com.craftaro.core.database.DataManager;
|
||||
import com.craftaro.core.database.DatabaseConnector;
|
||||
import com.craftaro.core.utils.TextUtils;
|
||||
import com.craftaro.core.utils.TimeUtils;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.ultimatemoderation.punish.AppliedPunishment;
|
||||
import com.craftaro.ultimatemoderation.punish.Punishment;
|
||||
import com.craftaro.ultimatemoderation.punish.PunishmentNote;
|
||||
import com.craftaro.ultimatemoderation.punish.PunishmentType;
|
||||
import com.craftaro.ultimatemoderation.punish.player.PlayerPunishData;
|
||||
import com.craftaro.ultimatemoderation.punish.player.PunishmentManager;
|
||||
import com.craftaro.ultimatemoderation.punish.template.Template;
|
||||
import com.craftaro.ultimatemoderation.punish.template.TemplateManager;
|
||||
import com.craftaro.ultimatemoderation.tickets.Ticket;
|
||||
import com.craftaro.ultimatemoderation.tickets.TicketResponse;
|
||||
import com.craftaro.ultimatemoderation.tickets.TicketStatus;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.sql.Connection;
|
||||
@ -18,21 +28,217 @@ import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class DataManager extends DataManagerAbstract {
|
||||
public class DataHelper {
|
||||
private final DatabaseConnector databaseConnector;
|
||||
private final DataManager dataManager;
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
public DataManager(DatabaseConnector databaseConnector, Plugin plugin) {
|
||||
super(databaseConnector, plugin);
|
||||
//Store highest punishment id for each type, we query for new punishment ids regular to keep data up to date
|
||||
//Table, id
|
||||
private final HashMap<String, Integer> punishmentIds = new HashMap<>();
|
||||
public final List<String> TABLES = Arrays.asList("punishments", "templates", "notes", "tickets"); //TODO: Add ticket_responses?
|
||||
|
||||
public DataHelper(DataManager dataManager, UltimateModeration plugin) {
|
||||
this.dataManager = dataManager;
|
||||
this.databaseConnector = dataManager.getDatabaseConnector();
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
private void runAsync(Runnable runnable) {
|
||||
this.dataManager.getAsyncPool().execute(runnable);
|
||||
}
|
||||
|
||||
private void sync(Runnable runnable) {
|
||||
Bukkit.getScheduler().runTask(this.plugin, runnable);
|
||||
}
|
||||
|
||||
private String getTablePrefix() {
|
||||
return this.dataManager.getTablePrefix();
|
||||
}
|
||||
|
||||
private int getHighestPunishmentId(String table) {
|
||||
return this.punishmentIds.getOrDefault(table, 0);
|
||||
}
|
||||
|
||||
private void setHighestPunishmentId(String table, int id) {
|
||||
this.punishmentIds.put(table, id);
|
||||
}
|
||||
|
||||
//Method is called async, no need to make it async here
|
||||
public void updateData() {
|
||||
//We query all table ids to get the highest id for each punishment type
|
||||
for (String table : TABLES) {
|
||||
try (Connection connection = this.databaseConnector.getConnection()) {
|
||||
Statement statement = connection.createStatement();
|
||||
String selectHighestId = "SELECT MAX(id) FROM " + this.getTablePrefix() + table;
|
||||
ResultSet result = statement.executeQuery(selectHighestId);
|
||||
if (result.next()) {
|
||||
int maxId = result.getInt(1);
|
||||
//Check if the id is higher than the current highest id we cached
|
||||
if (maxId > this.getHighestPunishmentId(table)) {
|
||||
int oldId = this.getHighestPunishmentId(table);
|
||||
this.setHighestPunishmentId(table, maxId);
|
||||
|
||||
//Load all new data
|
||||
switch (table) {
|
||||
case "punishments":
|
||||
PreparedStatement punishmentStatement = connection.prepareStatement("SELECT * FROM " + this.getTablePrefix() + "punishments WHERE id > ?");
|
||||
punishmentStatement.setInt(1, oldId);
|
||||
ResultSet punishmentResult = punishmentStatement.executeQuery();
|
||||
while (punishmentResult.next()) {
|
||||
int id = punishmentResult.getInt("id");
|
||||
PunishmentType punishmentType = PunishmentType.valueOf(punishmentResult.getString("type"));
|
||||
long duration = punishmentResult.getLong("duration");
|
||||
String reason = punishmentResult.getString("reason");
|
||||
UUID victim = UUID.fromString(punishmentResult.getString("victim"));
|
||||
UUID punisher = UUID.fromString(punishmentResult.getString("punisher"));
|
||||
long expiration = punishmentResult.getLong("expiration");
|
||||
AppliedPunishment punishment = new AppliedPunishment(punishmentType, duration, reason, victim, punisher, expiration, id);
|
||||
plugin.getPunishmentManager().getPlayer(punishment.getVictim()).addPunishment(punishment);
|
||||
|
||||
//If punishment is a BAN check if the player is online and kick them
|
||||
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(punishment.getVictim());
|
||||
switch (punishmentType) {
|
||||
case BAN:
|
||||
if (offlinePlayer.isOnline()) {
|
||||
Bukkit.getScheduler().runTask(plugin, () -> offlinePlayer.getPlayer().kickPlayer(plugin.getLocale()
|
||||
.getMessage("event.ban.message")
|
||||
.processPlaceholder("reason", reason == null ? "" : reason)
|
||||
.processPlaceholder("duration", TimeUtils.makeReadable(duration)).toText()));
|
||||
}
|
||||
break;
|
||||
case KICK:
|
||||
if (offlinePlayer.isOnline()) {
|
||||
Bukkit.getScheduler().runTask(plugin, () -> offlinePlayer.getPlayer().kickPlayer(plugin.getLocale()
|
||||
.getMessage("event.kick.message")
|
||||
.processPlaceholder("reason", reason == null ? "" : reason).toText()));
|
||||
}
|
||||
break;
|
||||
case MUTE:
|
||||
PlayerPunishData playerPunishData = plugin.getPunishmentManager().getPlayer(offlinePlayer);
|
||||
if (!playerPunishData.getActivePunishments(PunishmentType.MUTE).isEmpty()) {
|
||||
return;
|
||||
}
|
||||
sendMessage(offlinePlayer, punishment);
|
||||
break;
|
||||
case WARNING:
|
||||
sendMessage(offlinePlayer, punishment);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "templates":
|
||||
PreparedStatement templateStatement = connection.prepareStatement("SELECT * FROM " + this.getTablePrefix() + "templates WHERE id > ?");
|
||||
templateStatement.setInt(1, oldId);
|
||||
ResultSet templateResult = templateStatement.executeQuery();
|
||||
while (templateResult.next()) {
|
||||
int id = templateResult.getInt("id");
|
||||
PunishmentType punishmentType = PunishmentType.valueOf(templateResult.getString("punishment_type"));
|
||||
long duration = templateResult.getLong("duration");
|
||||
String reason = templateResult.getString("reason");
|
||||
String name = templateResult.getString("name");
|
||||
UUID creator = UUID.fromString(templateResult.getString("creator"));
|
||||
Template template = new Template(punishmentType, duration, reason, creator, name, id);
|
||||
plugin.getTemplateManager().addTemplate(template);
|
||||
}
|
||||
break;
|
||||
case "notes":
|
||||
PreparedStatement noteStatement = connection.prepareStatement("SELECT * FROM " + this.getTablePrefix() + "notes WHERE id > ?");
|
||||
noteStatement.setInt(1, oldId);
|
||||
ResultSet noteResult = noteStatement.executeQuery();
|
||||
while (noteResult.next()) {
|
||||
int id = noteResult.getInt("id");
|
||||
String noteString = noteResult.getString("note");
|
||||
UUID author = UUID.fromString(noteResult.getString("author"));
|
||||
UUID subject = UUID.fromString(noteResult.getString("subject"));
|
||||
long creation = noteResult.getLong("creation");
|
||||
PunishmentNote note = new PunishmentNote(id, noteString, author, subject, creation);
|
||||
plugin.getPunishmentManager().getPlayer(note.getSubject()).addNotes(note);
|
||||
}
|
||||
break;
|
||||
case "tickets":
|
||||
PreparedStatement ticketStatement = connection.prepareStatement("SELECT * FROM " + this.getTablePrefix() + "tickets WHERE id > ?");
|
||||
ticketStatement.setInt(1, oldId);
|
||||
ResultSet ticketResult = ticketStatement.executeQuery();
|
||||
while (ticketResult.next()) {
|
||||
int id = ticketResult.getInt("id");
|
||||
UUID victim = UUID.fromString(ticketResult.getString("victim"));
|
||||
String subject = ticketResult.getString("subject");
|
||||
String type = ticketResult.getString("type");
|
||||
TicketStatus status = TicketStatus.valueOf(ticketResult.getString("status"));
|
||||
|
||||
String world = ticketResult.getString("world");
|
||||
double x = ticketResult.getDouble("x");
|
||||
double y = ticketResult.getDouble("y");
|
||||
double z = ticketResult.getDouble("z");
|
||||
float pitch = ticketResult.getFloat("pitch");
|
||||
float yaw = ticketResult.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);
|
||||
|
||||
//Query ticket responses for the ticket and load them if they exist
|
||||
PreparedStatement responseStatement = connection.prepareStatement("SELECT * FROM " + this.getTablePrefix() + "ticket_responses WHERE ticket_id = ?");
|
||||
responseStatement.setInt(1, id);
|
||||
ResultSet responseResult = responseStatement.executeQuery();
|
||||
while (responseResult.next()) {
|
||||
UUID author = UUID.fromString(responseResult.getString("author"));
|
||||
String message = responseResult.getString("message");
|
||||
long postedDate = responseResult.getLong("posted_date");
|
||||
TicketResponse ticketResponse = new TicketResponse(author, message, postedDate);
|
||||
ticketResponse.setTicketId(id);
|
||||
ticket.addResponse(ticketResponse);
|
||||
}
|
||||
|
||||
plugin.getTicketManager().addTicket(ticket);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void sendMessage(OfflinePlayer offlineVictim, Punishment punishment) {
|
||||
if (!offlineVictim.isOnline()) {
|
||||
return;
|
||||
}
|
||||
Player victim = offlineVictim.getPlayer();
|
||||
UltimateModeration plugin = UltimateModeration.getInstance();
|
||||
|
||||
String punishSuccess = AdventureUtils.toLegacy(plugin.getLocale()
|
||||
.getMessage("event." + punishment.getPunishmentType().name().toLowerCase() + ".message").getPrefixedMessage());
|
||||
|
||||
if (punishment.getReason() != null) {
|
||||
punishSuccess += plugin.getLocale().getMessage("event.punish.reason")
|
||||
.processPlaceholder("reason", punishment.getReason()).getMessage();
|
||||
}
|
||||
|
||||
if (punishment.getDuration() != -1) {
|
||||
punishSuccess += plugin.getLocale().getMessage("event.punish.yourduration")
|
||||
.processPlaceholder("duration", TimeUtils.makeReadable(punishment.getDuration())).getMessage();
|
||||
}
|
||||
|
||||
victim.sendMessage(punishSuccess + TextUtils.formatText("&7."));
|
||||
}
|
||||
|
||||
public void createTemplate(Template template) {
|
||||
this.runAsync(() -> {
|
||||
try (Connection connection = this.databaseConnector.getConnection()) {
|
||||
int nextId = this.dataManager.getNextId("templates");
|
||||
|
||||
String createTemplate = "INSERT INTO " + this.getTablePrefix() + "templates (punishment_type, duration, reason, name, creator) VALUES (?, ?, ?, ?, ?)";
|
||||
PreparedStatement statement = connection.prepareStatement(createTemplate);
|
||||
statement.setString(1, template.getPunishmentType().name());
|
||||
@ -42,8 +248,7 @@ public class DataManager extends DataManagerAbstract {
|
||||
statement.setString(5, template.getCreator().toString());
|
||||
statement.executeUpdate();
|
||||
|
||||
int templateId = this.lastInsertedId(connection, "templates");
|
||||
template.setId(templateId);
|
||||
template.setId(nextId);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
@ -82,6 +287,9 @@ public class DataManager extends DataManagerAbstract {
|
||||
templates.add(template);
|
||||
}
|
||||
|
||||
//Get the highest id for the table and cache it
|
||||
this.setHighestPunishmentId("templates", templates.stream().mapToInt(Template::getId).max().orElse(0));
|
||||
|
||||
this.sync(() -> callback.accept(templates));
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
@ -92,6 +300,8 @@ public class DataManager extends DataManagerAbstract {
|
||||
public void createAppliedPunishment(AppliedPunishment punishment) {
|
||||
this.runAsync(() -> {
|
||||
try (Connection connection = this.databaseConnector.getConnection()) {
|
||||
int nextId = this.dataManager.getNextId("punishments");
|
||||
|
||||
String createPunishment = "INSERT INTO " + this.getTablePrefix() + "punishments (type, duration, reason, victim, punisher, expiration) VALUES (?, ?, ?, ?, ?, ?)";
|
||||
PreparedStatement statement = connection.prepareStatement(createPunishment);
|
||||
statement.setString(1, punishment.getPunishmentType().name());
|
||||
@ -102,8 +312,7 @@ public class DataManager extends DataManagerAbstract {
|
||||
statement.setLong(6, punishment.getExpiration());
|
||||
statement.executeUpdate();
|
||||
|
||||
int punishmentId = this.lastInsertedId(connection, "punishments");
|
||||
punishment.setId(punishmentId);
|
||||
punishment.setId(nextId);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
@ -160,6 +369,9 @@ public class DataManager extends DataManagerAbstract {
|
||||
appliedPunishments.add(new AppliedPunishment(punishmentType, duration, reason, victim, punisher, expiration, id));
|
||||
}
|
||||
|
||||
//Get the highest id for the table and cache it
|
||||
this.setHighestPunishmentId("punishments", appliedPunishments.stream().mapToInt(AppliedPunishment::getId).max().orElse(0));
|
||||
|
||||
this.sync(() -> callback.accept(appliedPunishments));
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
@ -170,6 +382,8 @@ public class DataManager extends DataManagerAbstract {
|
||||
public void createNote(PunishmentNote note) {
|
||||
this.runAsync(() -> {
|
||||
try (Connection connection = this.databaseConnector.getConnection()) {
|
||||
int nextId = this.dataManager.getNextId("notes");
|
||||
|
||||
String createNote = "INSERT INTO " + this.getTablePrefix() + "notes (note, author, subject, creation) VALUES (?, ?, ?, ?)";
|
||||
PreparedStatement statement = connection.prepareStatement(createNote);
|
||||
statement.setString(1, note.getNote());
|
||||
@ -178,8 +392,7 @@ public class DataManager extends DataManagerAbstract {
|
||||
statement.setLong(4, note.getCreationDate());
|
||||
statement.executeUpdate();
|
||||
|
||||
int noteId = this.lastInsertedId(connection, "notes");
|
||||
note.setId(noteId);
|
||||
note.setId(nextId);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
@ -215,6 +428,9 @@ public class DataManager extends DataManagerAbstract {
|
||||
notes.add(new PunishmentNote(id, note, author, subject, creation));
|
||||
}
|
||||
|
||||
//Get the highest id for the table and cache it
|
||||
this.setHighestPunishmentId("notes", notes.stream().mapToInt(PunishmentNote::getId).max().orElse(0));
|
||||
|
||||
this.sync(() -> callback.accept(notes));
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
@ -225,6 +441,8 @@ public class DataManager extends DataManagerAbstract {
|
||||
public void createTicket(Ticket ticket) {
|
||||
this.runAsync(() -> {
|
||||
try (Connection connection = this.databaseConnector.getConnection()) {
|
||||
int nextId = this.dataManager.getNextId("tickets");
|
||||
|
||||
String createTicket = "INSERT INTO " + this.getTablePrefix() + "tickets (victim, subject, type, status, world, x, y, z, pitch, yaw) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
PreparedStatement statement = connection.prepareStatement(createTicket);
|
||||
statement.setString(1, ticket.getVictim().toString());
|
||||
@ -246,8 +464,7 @@ public class DataManager extends DataManagerAbstract {
|
||||
createTicketResponse(response);
|
||||
}
|
||||
|
||||
int ticketId = this.lastInsertedId(connection, "tickets");
|
||||
ticket.setId(ticketId);
|
||||
ticket.setId(nextId);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
@ -286,12 +503,22 @@ public class DataManager extends DataManagerAbstract {
|
||||
|
||||
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());
|
||||
if (location != null) {
|
||||
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());
|
||||
} else {
|
||||
statement.setString(5, "");
|
||||
statement.setDouble(6, 0);
|
||||
statement.setDouble(7, 0);
|
||||
statement.setDouble(8, 0);
|
||||
statement.setFloat(9, 0);
|
||||
statement.setFloat(10, 0);
|
||||
}
|
||||
|
||||
statement.setInt(11, ticket.getId());
|
||||
statement.executeUpdate();
|
||||
} catch (Exception ex) {
|
||||
@ -324,10 +551,13 @@ public class DataManager extends DataManagerAbstract {
|
||||
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)
|
||||
;
|
||||
ticket.setId(id);
|
||||
|
||||
tickets.put(id, ticket);
|
||||
}
|
||||
|
||||
//Get the highest id for the table and cache it
|
||||
this.setHighestPunishmentId("tickets", tickets.keySet().stream().max(Integer::compareTo).orElse(0));
|
||||
}
|
||||
|
||||
try (Statement statement = connection.createStatement()) {
|
@ -1,22 +1,20 @@
|
||||
package com.songoda.ultimatemoderation.database.migrations;
|
||||
package com.craftaro.ultimatemoderation.database.migrations;
|
||||
|
||||
import com.songoda.core.database.DataMigration;
|
||||
import com.songoda.core.database.MySQLConnector;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.core.database.DataMigration;
|
||||
import com.craftaro.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" : "";
|
||||
String autoIncrement = " AUTO_INCREMENT";
|
||||
|
||||
// Create templates table
|
||||
try (Statement statement = connection.createStatement()) {
|
||||
@ -81,5 +79,4 @@ public class _1_InitialMigration extends DataMigration {
|
||||
")");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
209
src/main/java/com/craftaro/ultimatemoderation/gui/MainGui.java
Normal file
209
src/main/java/com/craftaro/ultimatemoderation/gui/MainGui.java
Normal file
@ -0,0 +1,209 @@
|
||||
package com.craftaro.ultimatemoderation.gui;
|
||||
|
||||
import com.craftaro.core.gui.AnvilGui;
|
||||
import com.craftaro.core.gui.Gui;
|
||||
import com.craftaro.core.gui.GuiUtils;
|
||||
import com.craftaro.core.utils.ItemUtils;
|
||||
import com.craftaro.core.utils.TextUtils;
|
||||
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.ultimatemoderation.punish.PunishmentType;
|
||||
import com.craftaro.ultimatemoderation.punish.player.PlayerPunishData;
|
||||
import com.craftaro.ultimatemoderation.settings.Settings;
|
||||
import com.craftaro.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 final 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()) {
|
||||
this.players.add(player.getUniqueId());
|
||||
}
|
||||
for (UUID uuid : plugin.getPunishmentManager().getPunishments().keySet()) {
|
||||
if (Bukkit.getOfflinePlayer(uuid).isOnline()) {
|
||||
continue;
|
||||
}
|
||||
this.players.add(uuid);
|
||||
}
|
||||
|
||||
setTitle(plugin.getLocale().getMessage("gui.players.title").getMessage());
|
||||
|
||||
showPage();
|
||||
}
|
||||
|
||||
private void showPage() {
|
||||
if (this.inventory != null) {
|
||||
this.inventory.clear();
|
||||
}
|
||||
setActionForRange(0, 53, null);
|
||||
|
||||
// decorate the edges
|
||||
ItemStack glass2 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_2.getMaterial(XMaterial.BLUE_STAINED_GLASS_PANE));
|
||||
ItemStack glass3 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_3.getMaterial(XMaterial.LIGHT_BLUE_STAINED_GLASS_PANE));
|
||||
|
||||
// edges will be type 3
|
||||
mirrorFill(0, 2, true, true, glass3);
|
||||
mirrorFill(1, 1, true, true, glass3);
|
||||
|
||||
// decorate corners with type 2
|
||||
mirrorFill(0, 0, true, true, glass2);
|
||||
mirrorFill(1, 0, true, true, glass2);
|
||||
mirrorFill(0, 1, true, true, glass2);
|
||||
|
||||
setButton(5, 2, GuiUtils.createButtonItem(XMaterial.ENDER_PEARL,
|
||||
this.plugin.getLocale().getMessage("gui.players.search").getMessage()),
|
||||
(event) -> {
|
||||
AnvilGui gui = new AnvilGui(event.player, this);
|
||||
gui.setAction(event2 -> {
|
||||
List<UUID> players = new ArrayList<>(this.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.isEmpty()) {
|
||||
this.players.clear();
|
||||
this.players.addAll(found);
|
||||
showPage();
|
||||
} else {
|
||||
this.plugin.getLocale().getMessage("gui.players.nonefound").sendMessage(event.player);
|
||||
}
|
||||
event2.player.closeInventory();
|
||||
});
|
||||
|
||||
ItemStack item = new ItemStack(Material.PAPER);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(this.plugin.getLocale().getMessage("gui.players.name").toText());
|
||||
item.setItemMeta(meta);
|
||||
|
||||
gui.setInput(item);
|
||||
this.guiManager.showGUI(event.player, gui);
|
||||
});
|
||||
|
||||
setButton(5, 3, GuiUtils.createButtonItem(XMaterial.HOPPER, TextUtils.formatText("&6" + this.currentOnline.getTranslation())),
|
||||
(event) -> {
|
||||
this.currentOnline = this.currentOnline.next();
|
||||
this.page = 1;
|
||||
showPage();
|
||||
});
|
||||
|
||||
|
||||
if (this.viewer.hasPermission("um.tickets")) {
|
||||
setButton(5, 5, GuiUtils.createButtonItem(XMaterial.CHEST,
|
||||
this.plugin.getLocale().getMessage("gui.players.button.tickets").getMessage()),
|
||||
(event) -> this.guiManager.showGUI(event.player, new TicketManagerGui(this.plugin, null, this.viewer)));
|
||||
}
|
||||
|
||||
if (this.viewer.hasPermission("um.templates")) {
|
||||
setButton(5, 6, GuiUtils.createButtonItem(XMaterial.MAP,
|
||||
this.plugin.getLocale().getMessage("gui.players.button.templatemanager").getMessage()),
|
||||
(events) -> this.guiManager.showGUI(events.player, new TemplateManagerGui(this.plugin, this.viewer)));
|
||||
}
|
||||
|
||||
|
||||
List<UUID> toUse = this.players.stream()
|
||||
.filter(u -> this.currentOnline == Online.BOTH
|
||||
|| this.currentOnline == Online.ONLINE && Bukkit.getOfflinePlayer(u).isOnline()
|
||||
|| this.currentOnline == Online.OFFLINE && !Bukkit.getOfflinePlayer(u).isOnline()).collect(Collectors.toList());
|
||||
|
||||
this.pages = (int) Math.max(1, Math.ceil(toUse.size() / ((double) 28)));
|
||||
|
||||
final List<UUID> toUseFinal = toUse.stream().skip((this.page - 1) * 28).limit(28).collect(Collectors.toList());
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> {
|
||||
int num = 11;
|
||||
for (UUID uuid : toUseFinal) {
|
||||
if (num == 16 || num == 36) {
|
||||
num = num + 2;
|
||||
}
|
||||
OfflinePlayer pl = Bukkit.getOfflinePlayer(uuid);
|
||||
ItemStack skull = ItemUtils.getPlayerSkull(pl);
|
||||
setItem(num, skull);
|
||||
|
||||
PlayerPunishData playerPunishData = this.plugin.getPunishmentManager().getPlayer(pl);
|
||||
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
lore.add(this.plugin.getLocale().getMessage("gui.players.click").toText());
|
||||
lore.add("");
|
||||
|
||||
int ticketAmt = (int) this.plugin.getTicketManager().getTicketsAbout(pl).stream()
|
||||
.filter(t -> t.getStatus() == TicketStatus.OPEN).count();
|
||||
|
||||
if (ticketAmt == 0) {
|
||||
lore.add(this.plugin.getLocale().getMessage("gui.players.notickets").toText());
|
||||
} else {
|
||||
if (ticketAmt == 1) {
|
||||
lore.add(this.plugin.getLocale().getMessage("gui.players.ticketsone").toText());
|
||||
} else {
|
||||
lore.add(this.plugin.getLocale().getMessage("gui.players.tickets")
|
||||
.processPlaceholder("amount", ticketAmt).toText());
|
||||
}
|
||||
}
|
||||
|
||||
int warningAmt = playerPunishData.getActivePunishments(PunishmentType.WARNING).size();
|
||||
|
||||
if (warningAmt == 0) {
|
||||
lore.add(this.plugin.getLocale().getMessage("gui.players.nowarnings").toText());
|
||||
} else {
|
||||
if (warningAmt == 1) {
|
||||
lore.add(this.plugin.getLocale().getMessage("gui.players.warningsone").toText());
|
||||
} else {
|
||||
lore.add(this.plugin.getLocale().getMessage("gui.players.warnings")
|
||||
.processPlaceholder("amount", warningAmt).toText());
|
||||
}
|
||||
}
|
||||
|
||||
setButton(num, GuiUtils.createButtonItem(skull, TextUtils.formatText("&7&l" + pl.getName()), lore),
|
||||
(event) -> this.guiManager.showGUI(event.player, new PlayerGui(this.plugin, pl, this.viewer)));
|
||||
|
||||
num++;
|
||||
}
|
||||
});
|
||||
|
||||
// enable page events
|
||||
setNextPage(4, 7, GuiUtils.createButtonItem(XMaterial.ARROW, this.plugin.getLocale().getMessage("gui.general.next").getMessage()));
|
||||
setPrevPage(4, 1, GuiUtils.createButtonItem(XMaterial.ARROW, this.plugin.getLocale().getMessage("gui.general.back").getMessage()));
|
||||
setOnPage((event) -> showPage());
|
||||
}
|
||||
|
||||
private enum Online {
|
||||
ONLINE, OFFLINE, BOTH;
|
||||
|
||||
public Online next() {
|
||||
return values()[(this.ordinal() != values().length - 1 ? this.ordinal() + 1 : 0)];
|
||||
}
|
||||
|
||||
public String getTranslation() {
|
||||
return UltimateModeration.getPlugin(UltimateModeration.class)
|
||||
.getLocale()
|
||||
.getMessage("gui.players.online." + this.name().toLowerCase())
|
||||
.toText();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,12 +1,12 @@
|
||||
package com.songoda.ultimatemoderation.gui;
|
||||
package com.craftaro.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 com.craftaro.core.gui.Gui;
|
||||
import com.craftaro.core.gui.GuiUtils;
|
||||
import com.craftaro.core.utils.TextUtils;
|
||||
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.ultimatemoderation.moderate.AbstractModeration;
|
||||
import com.craftaro.ultimatemoderation.settings.Settings;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -15,7 +15,6 @@ 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);
|
||||
@ -24,8 +23,8 @@ public class ModerateGui extends Gui {
|
||||
.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));
|
||||
ItemStack glass2 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_2.getMaterial(XMaterial.BLUE_STAINED_GLASS_PANE));
|
||||
ItemStack glass3 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_3.getMaterial(XMaterial.LIGHT_BLUE_STAINED_GLASS_PANE));
|
||||
|
||||
// edges will be type 3
|
||||
mirrorFill(0, 2, true, true, glass3);
|
||||
@ -37,9 +36,9 @@ public class ModerateGui extends Gui {
|
||||
mirrorFill(2, 0, false, true, glass2);
|
||||
mirrorFill(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)));
|
||||
setButton(8, GuiUtils.createButtonItem(XMaterial.OAK_DOOR,
|
||||
plugin.getLocale().getMessage("gui.general.back").getMessage()),
|
||||
(event) -> this.guiManager.showGUI(event.player, new PlayerGui(plugin, toModerate, event.player)));
|
||||
|
||||
int[] slots = new int[]{11, 13, 15, 29, 31, 33};
|
||||
|
||||
@ -47,11 +46,14 @@ public class ModerateGui extends Gui {
|
||||
|
||||
int i = 0;
|
||||
for (AbstractModeration moderation : moderations) {
|
||||
if (!moderation.hasPermission(player) || moderation.isExempt(toModerate)) continue;
|
||||
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())),
|
||||
TextUtils.formatText("&6&l" + moderation.getProper()),
|
||||
TextUtils.formatText("&7" + moderation.getDescription())),
|
||||
(event) -> moderation.runPreModeration(player, toModerate));
|
||||
i++;
|
||||
}
|
@ -0,0 +1,148 @@
|
||||
package com.craftaro.ultimatemoderation.gui;
|
||||
|
||||
import com.craftaro.core.gui.Gui;
|
||||
import com.craftaro.core.gui.GuiUtils;
|
||||
import com.craftaro.core.input.ChatPrompt;
|
||||
import com.craftaro.core.utils.TextUtils;
|
||||
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.ultimatemoderation.punish.PunishmentNote;
|
||||
import com.craftaro.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 (this.inventory != null) {
|
||||
this.inventory.clear();
|
||||
}
|
||||
setActionForRange(0, 53, null);
|
||||
|
||||
int numNotes = this.plugin.getPunishmentManager().getPlayer(this.toModerate).getNotes().size();
|
||||
this.pages = (int) Math.max(1, Math.ceil(numNotes / ((double) 28)));
|
||||
|
||||
List<PunishmentNote> notes = this.plugin.getPunishmentManager().getPlayer(this.toModerate).getNotes().stream()
|
||||
.skip((this.page - 1) * 28).limit(28).collect(Collectors.toList());
|
||||
|
||||
// enable page events
|
||||
setNextPage(0, 1, GuiUtils.createButtonItem(XMaterial.ARROW, this.plugin.getLocale().getMessage("gui.general.next").getMessage()));
|
||||
setPrevPage(0, 3, GuiUtils.createButtonItem(XMaterial.ARROW, this.plugin.getLocale().getMessage("gui.general.back").getMessage()));
|
||||
setOnPage((event) -> showPage());
|
||||
|
||||
// decorate the edges
|
||||
ItemStack glass2 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_2.getMaterial(XMaterial.BLUE_STAINED_GLASS_PANE));
|
||||
ItemStack glass3 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_3.getMaterial(XMaterial.LIGHT_BLUE_STAINED_GLASS_PANE));
|
||||
|
||||
// edges will be type 3
|
||||
mirrorFill(0, 2, true, true, glass3);
|
||||
mirrorFill(1, 1, true, true, glass3);
|
||||
|
||||
// decorate corners with type 2
|
||||
mirrorFill(0, 0, true, true, glass2);
|
||||
mirrorFill(1, 0, true, true, glass2);
|
||||
mirrorFill(0, 1, true, true, glass2);
|
||||
|
||||
setButton(5, 5, GuiUtils.createButtonItem(XMaterial.OAK_DOOR,
|
||||
this.plugin.getLocale().getMessage("gui.general.back").getMessage()),
|
||||
(event) -> this.guiManager.showGUI(event.player, new PlayerGui(this.plugin, this.toModerate, event.player)));
|
||||
|
||||
if (this.create) {
|
||||
setButton(5, 3, GuiUtils.createButtonItem(XMaterial.REDSTONE,
|
||||
this.plugin.getLocale().getMessage("gui.notes.create").getMessage()),
|
||||
(event) -> {
|
||||
ChatPrompt.showPrompt(this.plugin, event.player,
|
||||
this.plugin.getLocale().getMessage("gui.notes.type").toText(),
|
||||
(response) -> {
|
||||
PunishmentNote note = new PunishmentNote(response.getMessage(),
|
||||
event.player.getUniqueId(), this.toModerate.getUniqueId(),
|
||||
System.currentTimeMillis());
|
||||
this.plugin.getPunishmentManager().getPlayer(this.toModerate).addNotes(note);
|
||||
this.plugin.getDataHelper().createNote(note);
|
||||
|
||||
showPage();
|
||||
}).setOnClose(() -> this.guiManager.showGUI(event.player, new NotesManagerGui(this.plugin, this.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(this.plugin.getLocale().getMessage("gui.notes.createdby")
|
||||
.processPlaceholder("player", Bukkit.getOfflinePlayer(note.getAuthor()).getName())
|
||||
.toText());
|
||||
lore.add(this.plugin.getLocale().getMessage("gui.notes.createdon")
|
||||
.processPlaceholder("sent", format.format(new Date(note.getCreationDate())))
|
||||
.toText());
|
||||
if (this.delete) {
|
||||
lore.add(this.plugin.getLocale().getMessage("gui.notes.remove").toText());
|
||||
}
|
||||
|
||||
setButton(num, GuiUtils.createButtonItem(XMaterial.MAP, TextUtils.formatText(name), TextUtils.formatText(lore)),
|
||||
(event) -> {
|
||||
if (this.delete) {
|
||||
this.plugin.getPunishmentManager().getPlayer(this.toModerate).removeNotes(note);
|
||||
this.plugin.getDataHelper().deleteNote(note);
|
||||
showPage();
|
||||
}
|
||||
});
|
||||
|
||||
num++;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,18 +1,17 @@
|
||||
package com.songoda.ultimatemoderation.gui;
|
||||
package com.craftaro.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 com.craftaro.core.gui.Gui;
|
||||
import com.craftaro.core.gui.GuiUtils;
|
||||
import com.craftaro.core.utils.ItemUtils;
|
||||
import com.craftaro.core.utils.TextUtils;
|
||||
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.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);
|
||||
@ -28,8 +27,8 @@ public class PlayerGui extends Gui {
|
||||
.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));
|
||||
ItemStack glass2 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_2.getMaterial(XMaterial.BLUE_STAINED_GLASS_PANE));
|
||||
ItemStack glass3 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_3.getMaterial(XMaterial.LIGHT_BLUE_STAINED_GLASS_PANE));
|
||||
|
||||
// edges will be type 3
|
||||
mirrorFill(0, 2, true, true, glass3);
|
||||
@ -47,36 +46,41 @@ public class PlayerGui extends Gui {
|
||||
+ 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)));
|
||||
setButton(8, GuiUtils.createButtonItem(XMaterial.OAK_DOOR,
|
||||
plugin.getLocale().getMessage("gui.general.back").getMessage()),
|
||||
(event) -> this.guiManager.showGUI(event.player, new MainGui(plugin, event.player)));
|
||||
|
||||
if (punish)
|
||||
setButton(38, GuiUtils.createButtonItem(CompatibleMaterial.ANVIL,
|
||||
plugin.getLocale().getMessage("gui.player.punish").getMessage()),
|
||||
if (punish) {
|
||||
setButton(38, GuiUtils.createButtonItem(XMaterial.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()),
|
||||
if (tickets) {
|
||||
setButton(30, GuiUtils.createButtonItem(XMaterial.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()),
|
||||
if (toModerate.isOnline() && punishments) {
|
||||
setButton(32, GuiUtils.createButtonItem(XMaterial.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()),
|
||||
if (notes) {
|
||||
setButton(42, GuiUtils.createButtonItem(XMaterial.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)));
|
||||
if (moderate) {
|
||||
setButton(40, GuiUtils.createButtonItem(XMaterial.DIAMOND_CHESTPLATE,
|
||||
plugin.getLocale().getMessage("gui.player.moderate").getMessage()),
|
||||
(event) -> this.guiManager.showGUI(player, new ModerateGui(plugin, toModerate, event.player)));
|
||||
}
|
||||
}
|
||||
}
|
351
src/main/java/com/craftaro/ultimatemoderation/gui/PunishGui.java
Normal file
351
src/main/java/com/craftaro/ultimatemoderation/gui/PunishGui.java
Normal file
@ -0,0 +1,351 @@
|
||||
package com.craftaro.ultimatemoderation.gui;
|
||||
|
||||
import com.craftaro.core.gui.AnvilGui;
|
||||
import com.craftaro.core.gui.Gui;
|
||||
import com.craftaro.core.gui.GuiUtils;
|
||||
import com.craftaro.core.utils.ItemUtils;
|
||||
import com.craftaro.core.utils.TextUtils;
|
||||
import com.craftaro.core.utils.TimeUtils;
|
||||
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.ultimatemoderation.punish.Punishment;
|
||||
import com.craftaro.ultimatemoderation.punish.PunishmentType;
|
||||
import com.craftaro.ultimatemoderation.punish.template.Template;
|
||||
import com.craftaro.ultimatemoderation.settings.Settings;
|
||||
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(this.task));
|
||||
paint();
|
||||
}
|
||||
|
||||
public void paint() {
|
||||
if (this.inventory != null) {
|
||||
this.inventory.clear();
|
||||
}
|
||||
setActionForRange(0, 53, null);
|
||||
|
||||
// decorate the edges
|
||||
ItemStack glass2 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_2.getMaterial(XMaterial.BLUE_STAINED_GLASS_PANE));
|
||||
ItemStack glass3 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_3.getMaterial(XMaterial.LIGHT_BLUE_STAINED_GLASS_PANE));
|
||||
|
||||
// edges will be type 3
|
||||
mirrorFill(0, 2, true, true, glass3);
|
||||
mirrorFill(1, 1, true, true, glass3);
|
||||
|
||||
// decorate corners with type 2
|
||||
mirrorFill(0, 0, true, true, glass2);
|
||||
mirrorFill(1, 0, true, true, glass2);
|
||||
mirrorFill(2, 0, false, true, glass2);
|
||||
mirrorFill(0, 1, true, true, glass2);
|
||||
|
||||
if (this.toModerate != null) {
|
||||
setItem(13, GuiUtils.createButtonItem(ItemUtils.getPlayerSkull(this.toModerate),
|
||||
TextUtils.formatText("&6&l" + this.toModerate.getName())));
|
||||
}
|
||||
|
||||
if (this.player.hasPermission("um." + this.type.toString().toLowerCase())) {
|
||||
setButton(22, GuiUtils.createButtonItem(XMaterial.EMERALD_BLOCK,
|
||||
this.plugin.getLocale().getMessage("gui.punish.submit").getMessage()),
|
||||
(event) -> {
|
||||
if (!this.player.hasPermission("um." + this.type.toString().toLowerCase())) {
|
||||
return;
|
||||
}
|
||||
if (this.duration == -1 && this.type == PunishmentType.BAN && !this.player.hasPermission("um.ban.permanent")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.toModerate == null) {
|
||||
if (this.reason == null || this.templateName == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.template == null) {
|
||||
finishTemplate();
|
||||
} else {
|
||||
updateTemplate();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
switch (this.type) {
|
||||
case BAN:
|
||||
case MUTE:
|
||||
case WARNING:
|
||||
new Punishment(this.type, this.duration, this.reason).execute(this.player, this.toModerate);
|
||||
break;
|
||||
case KICK:
|
||||
new Punishment(this.type, this.reason).execute(this.player, this.toModerate);
|
||||
break;
|
||||
}
|
||||
this.player.closeInventory();
|
||||
});
|
||||
}
|
||||
|
||||
setButton(8, GuiUtils.createButtonItem(XMaterial.OAK_DOOR,
|
||||
this.plugin.getLocale().getMessage("gui.general.back").getMessage()),
|
||||
(event) -> {
|
||||
if (this.toModerate != null) {
|
||||
this.guiManager.showGUI(this.player, new PlayerGui(this.plugin, this.toModerate, this.player));
|
||||
} else {
|
||||
this.guiManager.showGUI(this.player, new TemplateManagerGui(this.plugin, this.player));
|
||||
}
|
||||
});
|
||||
|
||||
setButton(28, GuiUtils.createButtonItem(XMaterial.ANVIL,
|
||||
this.plugin.getLocale().getMessage("gui.punish.type.punishment").toText(),
|
||||
TextUtils.formatText("&7" + this.type.getTranslation()),
|
||||
"",
|
||||
this.plugin.getLocale().getMessage("gui.punish.type.punishment.click").toText()),
|
||||
(event) -> {
|
||||
this.type = this.type.next();
|
||||
this.justSaved = false;
|
||||
paint();
|
||||
});
|
||||
|
||||
ItemStack templateItem = this.toModerate != null ? GuiUtils.createButtonItem(XMaterial.MAP,
|
||||
this.plugin.getLocale().getMessage("gui.punish.type.template").toText(),
|
||||
this.plugin.getLocale().getMessage("gui.punish.type.template.current")
|
||||
.processPlaceholder("template",
|
||||
this.template == null
|
||||
? this.plugin.getLocale().getMessage("gui.general.none").toText()
|
||||
: this.template.getName()).toText(),
|
||||
"",
|
||||
this.plugin.getLocale().getMessage(this.plugin.getTemplateManager().getTemplates().size() == 0
|
||||
? "gui.punish.type.template.none"
|
||||
: "gui.punish.type.template.click").toText())
|
||||
: GuiUtils.createButtonItem(XMaterial.MAP,
|
||||
this.plugin.getLocale().getMessage("gui.punish.type.name").toText(),
|
||||
this.plugin.getLocale().getMessage("gui.punish.type.name.current")
|
||||
.processPlaceholder("name",
|
||||
this.templateName == null
|
||||
? this.plugin.getLocale().getMessage("gui.punish.type.name.current").toText()
|
||||
: this.templateName).toText(),
|
||||
"",
|
||||
this.plugin.getLocale().getMessage("gui.punish.type.name.current.click").toText());
|
||||
|
||||
setButton(30, templateItem, (event) -> {
|
||||
if (this.toModerate == null) {
|
||||
nameTemplate();
|
||||
return;
|
||||
}
|
||||
if (this.plugin.getTemplateManager().getTemplates().size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.player.hasPermission("um.templates.use")) {
|
||||
this.guiManager.showGUI(this.player, new TemplateSelectorGui(this.plugin, this, this.player));
|
||||
}
|
||||
});
|
||||
|
||||
if (this.type != PunishmentType.KICK) {
|
||||
setButton(32, GuiUtils.createButtonItem(XMaterial.CLOCK,
|
||||
this.plugin.getLocale().getMessage("gui.punish.type.duration").toText(),
|
||||
this.plugin.getLocale().getMessage("gui.punish.type.duration.leftclick").toText(),
|
||||
this.plugin.getLocale().getMessage("gui.punish.type.duration.rightclick").toText(),
|
||||
"",
|
||||
this.plugin.getLocale().getMessage("gui.punish.type.duration.current").toText(),
|
||||
TextUtils.formatText("&6" + (this.duration == -1 ? this.plugin.getLocale().getMessage("gui.general.permanent").toText()
|
||||
: TimeUtils.makeReadable(this.duration)))),
|
||||
(event) -> {
|
||||
if (this.type == PunishmentType.KICK) {
|
||||
return;
|
||||
}
|
||||
if (event.clickType == ClickType.LEFT) {
|
||||
AnvilGui gui = new AnvilGui(this.player, this);
|
||||
gui.setAction(evt -> {
|
||||
this.duration = TimeUtils.parseTime(gui.getInputText());
|
||||
this.justSaved = false;
|
||||
this.guiManager.showGUI(this.player, this);
|
||||
paint();
|
||||
});
|
||||
|
||||
ItemStack item = new ItemStack(Material.PAPER);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
|
||||
meta.setDisplayName(this.duration == -1 || this.duration == 0 ? "1d 1h 1m" : TimeUtils.makeReadable(this.duration));
|
||||
item.setItemMeta(meta);
|
||||
|
||||
gui.setInput(item);
|
||||
this.guiManager.showGUI(this.player, gui);
|
||||
} else {
|
||||
this.duration = -1;
|
||||
paint();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
setButton(34, GuiUtils.createButtonItem(XMaterial.PAPER,
|
||||
this.plugin.getLocale().getMessage("gui.punish.type.reason").toText(),
|
||||
this.plugin.getLocale().getMessage("gui.punish.type.reason.click").toText(),
|
||||
"",
|
||||
this.plugin.getLocale().getMessage("gui.punish.type.reason.current").toText(),
|
||||
TextUtils.formatText("&6" + this.reason)), (event) -> {
|
||||
|
||||
AnvilGui gui = new AnvilGui(this.player, this);
|
||||
gui.setAction(evnt -> {
|
||||
this.reason = gui.getInputText();
|
||||
this.justSaved = false;
|
||||
this.guiManager.showGUI(this.player, this);
|
||||
paint();
|
||||
});
|
||||
|
||||
ItemStack item = GuiUtils.createButtonItem(XMaterial.PAPER,
|
||||
this.reason == null ? this.plugin.getLocale().getMessage("gui.general.reason").toText() : this.reason);
|
||||
|
||||
gui.setInput(item);
|
||||
this.guiManager.showGUI(this.player, gui);
|
||||
});
|
||||
}
|
||||
|
||||
private void notifyTemplate() {
|
||||
if (this.reason == null || (this.justSaved && this.template != null)) {
|
||||
this.inventory.setItem(4, null);
|
||||
return;
|
||||
}
|
||||
|
||||
XMaterial material = XMaterial.WHITE_WOOL;
|
||||
String name = this.plugin.getLocale().getMessage("gui.punish.template.create").toText();
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
lore.add(this.plugin.getLocale().getMessage("gui.punish.template.create2").toText());
|
||||
|
||||
if (!this.justSaved && this.template != null) {
|
||||
name = this.plugin.getLocale().getMessage("gui.punish.template.leftclick").toText();
|
||||
lore.clear();
|
||||
lore.add(this.plugin.getLocale().getMessage("gui.punish.template.leftclick2")
|
||||
.processPlaceholder("template", this.template.getName()).toText());
|
||||
lore.add("");
|
||||
lore.add(this.plugin.getLocale().getMessage("gui.punish.template.rightclick").toText());
|
||||
}
|
||||
|
||||
if (getItem(4) != null && XMaterial.WHITE_WOOL.isSimilar(getItem(4))) {
|
||||
material = XMaterial.YELLOW_WOOL;
|
||||
}
|
||||
|
||||
setButton(4, GuiUtils.createButtonItem(material, name, lore), (event) -> {
|
||||
|
||||
if (this.reason == null || this.duration == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.template != null && event.clickType == ClickType.LEFT) {
|
||||
updateTemplate();
|
||||
return;
|
||||
}
|
||||
nameTemplate();
|
||||
});
|
||||
}
|
||||
|
||||
public void runTask() {
|
||||
this.task = Bukkit.getScheduler().scheduleSyncRepeatingTask(this.plugin, this::notifyTemplate, 10L, 10L);
|
||||
}
|
||||
|
||||
private void nameTemplate() {
|
||||
AnvilGui gui = new AnvilGui(this.player, this);
|
||||
gui.setAction(event -> {
|
||||
this.templateName = gui.getInputText();
|
||||
|
||||
if (this.reason != null && this.templateName != null) {
|
||||
if (this.template == null) {
|
||||
finishTemplate();
|
||||
} else {
|
||||
updateTemplate();
|
||||
}
|
||||
}
|
||||
|
||||
this.justSaved = true;
|
||||
this.guiManager.showGUI(this.player, this);
|
||||
paint();
|
||||
});
|
||||
|
||||
ItemStack item = GuiUtils.createButtonItem(XMaterial.PAPER,
|
||||
this.template == null ? this.plugin.getLocale().getMessage("gui.general.templatename").toText() : this.template.getName());
|
||||
|
||||
gui.setInput(item);
|
||||
this.guiManager.showGUI(this.player, gui);
|
||||
}
|
||||
|
||||
private void updateTemplate() {
|
||||
Template template = new Template(this.type, this.duration, this.reason, this.template.getCreator(), this.templateName);
|
||||
this.plugin.getTemplateManager().removeTemplate(this.template);
|
||||
this.plugin.getTemplateManager().addTemplate(template);
|
||||
this.plugin.getDataHelper().deleteTemplate(this.template);
|
||||
this.plugin.getDataHelper().createTemplate(template);
|
||||
this.justSaved = true;
|
||||
if (this.toModerate == null) {
|
||||
this.guiManager.showGUI(this.player, new TemplateManagerGui(this.plugin, this.player));
|
||||
}
|
||||
}
|
||||
|
||||
private void finishTemplate() {
|
||||
Template template = new Template(this.type, this.duration, this.reason, this.player, this.templateName);
|
||||
this.plugin.getTemplateManager().addTemplate(template);
|
||||
this.plugin.getDataHelper().createTemplate(template);
|
||||
this.template = template;
|
||||
if (this.toModerate == null) {
|
||||
this.guiManager.showGUI(this.player, new TemplateManagerGui(this.plugin, this.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,15 +1,15 @@
|
||||
package com.songoda.ultimatemoderation.gui;
|
||||
package com.craftaro.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.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.craftaro.core.gui.Gui;
|
||||
import com.craftaro.core.gui.GuiUtils;
|
||||
import com.craftaro.core.utils.TextUtils;
|
||||
import com.craftaro.core.utils.TimeUtils;
|
||||
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.ultimatemoderation.punish.AppliedPunishment;
|
||||
import com.craftaro.ultimatemoderation.punish.PunishmentType;
|
||||
import com.craftaro.ultimatemoderation.punish.player.PlayerPunishData;
|
||||
import com.craftaro.ultimatemoderation.settings.Settings;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -19,7 +19,6 @@ import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class PunishmentsGui extends Gui {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
private final OfflinePlayer toModerate;
|
||||
|
||||
@ -39,18 +38,19 @@ public class PunishmentsGui extends Gui {
|
||||
}
|
||||
|
||||
protected void showPage() {
|
||||
if (inventory != null)
|
||||
inventory.clear();
|
||||
if (this.inventory != null) {
|
||||
this.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()));
|
||||
setNextPage(0, 5, GuiUtils.createButtonItem(XMaterial.ARROW, this.plugin.getLocale().getMessage("gui.general.next").getMessage()));
|
||||
setPrevPage(0, 1, GuiUtils.createButtonItem(XMaterial.ARROW, this.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));
|
||||
ItemStack glass2 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_2.getMaterial(XMaterial.BLUE_STAINED_GLASS_PANE));
|
||||
ItemStack glass3 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_3.getMaterial(XMaterial.LIGHT_BLUE_STAINED_GLASS_PANE));
|
||||
|
||||
// edges will be type 3
|
||||
mirrorFill(0, 2, true, true, glass3);
|
||||
@ -61,25 +61,27 @@ public class PunishmentsGui extends Gui {
|
||||
mirrorFill(1, 0, true, true, glass2);
|
||||
mirrorFill(0, 1, true, true, glass2);
|
||||
|
||||
PlayerPunishData playerPunishData = plugin.getPunishmentManager().getPlayer(toModerate);
|
||||
PlayerPunishData playerPunishData = this.plugin.getPunishmentManager().getPlayer(this.toModerate);
|
||||
|
||||
List<PunishmentHolder> punishments = new ArrayList<>();
|
||||
|
||||
if (currentActivity == Activity.ACTIVE || currentActivity == Activity.BOTH) {
|
||||
if (this.currentActivity == Activity.ACTIVE || this.currentActivity == Activity.BOTH) {
|
||||
for (AppliedPunishment punishment : playerPunishData.getActivePunishments()) {
|
||||
if (punishmentType != PunishmentType.ALL) {
|
||||
if (punishment.getPunishmentType() != punishmentType)
|
||||
if (this.punishmentType != PunishmentType.ALL) {
|
||||
if (punishment.getPunishmentType() != this.punishmentType) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
punishments.add(new PunishmentHolder(Activity.ACTIVE, punishment));
|
||||
}
|
||||
}
|
||||
|
||||
if (currentActivity == Activity.EXPIRED || currentActivity == Activity.BOTH) {
|
||||
if (this.currentActivity == Activity.EXPIRED || this.currentActivity == Activity.BOTH) {
|
||||
for (AppliedPunishment punishment : playerPunishData.getExpiredPunishments()) {
|
||||
if (punishmentType != PunishmentType.ALL) {
|
||||
if (punishment.getPunishmentType() != punishmentType)
|
||||
if (this.punishmentType != PunishmentType.ALL) {
|
||||
if (punishment.getPunishmentType() != this.punishmentType) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
punishments.add(new PunishmentHolder(Activity.EXPIRED, punishment));
|
||||
}
|
||||
@ -88,78 +90,76 @@ public class PunishmentsGui extends Gui {
|
||||
int numNotes = punishments.size();
|
||||
this.pages = (int) Math.floor(numNotes / 28.0);
|
||||
|
||||
punishments = punishments.stream().skip((page - 1) * 28).limit(28)
|
||||
punishments = punishments.stream().skip((this.page - 1) * 28).limit(28)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
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)));
|
||||
setButton(5, 4, GuiUtils.createButtonItem(XMaterial.OAK_DOOR,
|
||||
this.plugin.getLocale().getMessage("gui.general.back").getMessage()),
|
||||
(event) -> this.guiManager.showGUI(event.player, new PlayerGui(this.plugin, this.toModerate, event.player)));
|
||||
|
||||
setButton(5, 3, GuiUtils.createButtonItem(CompatibleMaterial.APPLE, Methods.formatText("&6" + currentActivity.getTranslation())),
|
||||
setButton(5, 3, GuiUtils.createButtonItem(XMaterial.APPLE, TextUtils.formatText("&6" + this.currentActivity.getTranslation())),
|
||||
(event) -> {
|
||||
this.currentActivity = currentActivity.next();
|
||||
this.currentActivity = this.currentActivity.next();
|
||||
this.page = 1;
|
||||
showPage();
|
||||
});
|
||||
|
||||
setButton(5, 5, GuiUtils.createButtonItem(CompatibleMaterial.DIAMOND_SWORD, Methods.formatText("&6" + punishmentType.name())),
|
||||
setButton(5, 5, GuiUtils.createButtonItem(XMaterial.DIAMOND_SWORD, TextUtils.formatText("&6" + this.punishmentType.name())),
|
||||
(event) -> {
|
||||
this.punishmentType = punishmentType.nextFilter();
|
||||
this.punishmentType = this.punishmentType.nextFilter();
|
||||
this.page = 1;
|
||||
showPage();
|
||||
});
|
||||
|
||||
int num = 11;
|
||||
for (PunishmentHolder punishmentHolder : punishments) {
|
||||
if (num == 16 || num == 36)
|
||||
if (num == 16 || num == 36) {
|
||||
num = num + 2;
|
||||
}
|
||||
AppliedPunishment appliedPunishment = punishmentHolder.getAppliedPunishment();
|
||||
Activity activity = punishmentHolder.getActivity();
|
||||
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
lore.add("");
|
||||
lore.add(plugin.getLocale().getMessage("gui.punishments.reason").getMessage());
|
||||
lore.add(this.plugin.getLocale().getMessage("gui.punishments.reason").toText());
|
||||
lore.add("&7" + appliedPunishment.getReason());
|
||||
if (appliedPunishment.getPunishmentType() != PunishmentType.KICK) {
|
||||
lore.add("");
|
||||
lore.add(plugin.getLocale().getMessage("gui.punishments.duration").getMessage());
|
||||
lore.add(this.plugin.getLocale().getMessage("gui.punishments.duration").toText());
|
||||
lore.add("&7" + (appliedPunishment.getDuration() != -1
|
||||
? Methods.makeReadable(appliedPunishment.getDuration())
|
||||
: plugin.getLocale().getMessage("gui.general.permanent").getMessage()));
|
||||
? TimeUtils.makeReadable(appliedPunishment.getDuration())
|
||||
: this.plugin.getLocale().getMessage("gui.general.permanent").toText()));
|
||||
lore.add("");
|
||||
lore.add(plugin.getLocale().getMessage("gui.punishments.punisher").getMessage());
|
||||
lore.add(this.plugin.getLocale().getMessage("gui.punishments.punisher").toText());
|
||||
lore.add("&7" + (appliedPunishment.getPunisher() == null ? "Console" : Bukkit.getOfflinePlayer(appliedPunishment.getPunisher()).getName()));
|
||||
if (activity == Activity.ACTIVE) {
|
||||
lore.add("");
|
||||
if (appliedPunishment.getDuration() != -1) {
|
||||
lore.add(plugin.getLocale().getMessage("gui.punishments.remaining").getMessage());
|
||||
lore.add("&7" + Methods.makeReadable(appliedPunishment.getTimeRemaining()));
|
||||
lore.add(this.plugin.getLocale().getMessage("gui.punishments.remaining").toText());
|
||||
lore.add("&7" + TimeUtils.makeReadable(appliedPunishment.getTimeRemaining()));
|
||||
lore.add("");
|
||||
}
|
||||
lore.add(plugin.getLocale().getMessage("gui.punishments.click").getMessage());
|
||||
lore.add(this.plugin.getLocale().getMessage("gui.punishments.click").toText());
|
||||
}
|
||||
}
|
||||
lore.add("");
|
||||
setButton(num, GuiUtils.createButtonItem(CompatibleMaterial.MAP,
|
||||
TextUtils.formatText("&6&l" + appliedPunishment.getPunishmentType().getTranslation() + " - &7&l" + activity.getTranslation()),
|
||||
TextUtils.formatText(lore)),
|
||||
setButton(num, GuiUtils.createButtonItem(XMaterial.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);
|
||||
this.plugin.getDataHelper().updateAppliedPunishment(appliedPunishment);
|
||||
showPage();
|
||||
}
|
||||
});
|
||||
|
||||
num++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private class PunishmentHolder {
|
||||
|
||||
private static class PunishmentHolder {
|
||||
private final Activity activity;
|
||||
private final AppliedPunishment appliedPunishment;
|
||||
|
||||
@ -169,26 +169,26 @@ public class PunishmentsGui extends Gui {
|
||||
}
|
||||
|
||||
public Activity getActivity() {
|
||||
return activity;
|
||||
return this.activity;
|
||||
}
|
||||
|
||||
public AppliedPunishment getAppliedPunishment() {
|
||||
return appliedPunishment;
|
||||
return this.appliedPunishment;
|
||||
}
|
||||
}
|
||||
|
||||
private enum Activity {
|
||||
|
||||
BOTH, ACTIVE, EXPIRED;
|
||||
|
||||
private static Activity[] vals = values();
|
||||
|
||||
public Activity next() {
|
||||
return vals[(this.ordinal() != vals.length - 1 ? this.ordinal() + 1 : 0)];
|
||||
return values()[(this.ordinal() != values().length - 1 ? this.ordinal() + 1 : 0)];
|
||||
}
|
||||
|
||||
public String getTranslation() {
|
||||
return UltimateModeration.getInstance().getLocale().getMessage("gui.punishments.activity." + this.name().toLowerCase()).getMessage();
|
||||
return UltimateModeration.getPlugin(UltimateModeration.class)
|
||||
.getLocale()
|
||||
.getMessage("gui.punishments.activity." + this.name().toLowerCase())
|
||||
.toText();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,131 @@
|
||||
package com.craftaro.ultimatemoderation.gui;
|
||||
|
||||
import com.craftaro.core.gui.Gui;
|
||||
import com.craftaro.core.gui.GuiUtils;
|
||||
import com.craftaro.core.utils.TextUtils;
|
||||
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.ultimatemoderation.punish.PunishmentType;
|
||||
import com.craftaro.ultimatemoderation.punish.template.Template;
|
||||
import com.craftaro.ultimatemoderation.settings.Settings;
|
||||
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;
|
||||
|
||||
private int page = 1;
|
||||
|
||||
public TemplateManagerGui(UltimateModeration plugin, Player player) {
|
||||
super(6);
|
||||
setDefaultItem(null);
|
||||
this.plugin = plugin;
|
||||
this.player = player;
|
||||
|
||||
setTitle(plugin.getLocale().getMessage("gui.templatemanager.title").getMessage());
|
||||
toCurrentPage();
|
||||
}
|
||||
|
||||
private void toPrevPage() {
|
||||
if (this.page <= 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
--this.page;
|
||||
toCurrentPage();
|
||||
}
|
||||
|
||||
private void toNextPage() {
|
||||
if (findTemplates(this.page + 1, this.punishmentType).size() > 0) {
|
||||
++this.page;
|
||||
toCurrentPage();
|
||||
}
|
||||
}
|
||||
|
||||
private void toCurrentPage() {
|
||||
if (this.inventory != null) {
|
||||
this.inventory.clear();
|
||||
}
|
||||
|
||||
setActionForRange(0, 53, null);
|
||||
|
||||
int numTemplates = this.plugin.getTemplateManager().getTemplates().size();
|
||||
this.pages = (int) Math.floor(numTemplates / 28.0);
|
||||
|
||||
// decorate the edges
|
||||
ItemStack glass2 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_2.getMaterial(XMaterial.BLUE_STAINED_GLASS_PANE));
|
||||
ItemStack glass3 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_3.getMaterial(XMaterial.LIGHT_BLUE_STAINED_GLASS_PANE));
|
||||
|
||||
// edges will be type 3
|
||||
mirrorFill(0, 2, true, true, glass3);
|
||||
mirrorFill(1, 1, true, true, glass3);
|
||||
|
||||
// decorate corners with type 2
|
||||
mirrorFill(0, 0, true, true, glass2);
|
||||
mirrorFill(1, 0, true, true, glass2);
|
||||
mirrorFill(0, 1, true, true, glass2);
|
||||
|
||||
setButton(5, 3, GuiUtils.createButtonItem(XMaterial.DIAMOND_SWORD, TextUtils.formatText("&6" + this.punishmentType.name())),
|
||||
(event) -> {
|
||||
this.punishmentType = this.punishmentType.nextFilter();
|
||||
this.page = 1;
|
||||
toCurrentPage();
|
||||
});
|
||||
|
||||
setButton(5, 4, GuiUtils.createButtonItem(XMaterial.OAK_DOOR,
|
||||
this.plugin.getLocale().getMessage("gui.general.back").getMessage()),
|
||||
(event) -> this.guiManager.showGUI(event.player, new MainGui(this.plugin, event.player)));
|
||||
|
||||
if (this.player.hasPermission("um.templates.create")) {
|
||||
setButton(5, 5, GuiUtils.createButtonItem(XMaterial.REDSTONE,
|
||||
this.plugin.getLocale().getMessage("gui.templatemanager.create").getMessage()),
|
||||
(event) -> this.guiManager.showGUI(event.player, new PunishGui(this.plugin, null, null, this.player)));
|
||||
}
|
||||
|
||||
List<Template> templates = findTemplates(this.page, this.punishmentType);
|
||||
|
||||
int num = 11;
|
||||
for (Template template : templates) {
|
||||
if (num == 16 || num == 36) {
|
||||
num = num + 2;
|
||||
}
|
||||
|
||||
setButton(num, GuiUtils.createButtonItem(XMaterial.MAP, TextUtils.formatText("&6&l" + template.getName()),
|
||||
this.plugin.getLocale().getMessage("gui.templatemanager.leftclick").toText(),
|
||||
this.plugin.getLocale().getMessage("gui.templatemanager.rightclick").toText()),
|
||||
(event) -> {
|
||||
if (event.clickType == ClickType.LEFT) {
|
||||
if (this.player.hasPermission("um.templates.edit"))
|
||||
this.guiManager.showGUI(this.player, new PunishGui(this.plugin, null, template, this.player));
|
||||
} else if (event.clickType == ClickType.RIGHT) {
|
||||
if (this.player.hasPermission("um.templates.destroy")) {
|
||||
this.plugin.getTemplateManager().removeTemplate(template);
|
||||
this.plugin.getDataHelper().deleteTemplate(template);
|
||||
}
|
||||
|
||||
toCurrentPage();
|
||||
}
|
||||
});
|
||||
|
||||
++num;
|
||||
}
|
||||
|
||||
setButton(0, 3, GuiUtils.createButtonItem(XMaterial.ARROW, this.plugin.getLocale().getMessage("gui.general.back").getMessage()), (event) -> toPrevPage());
|
||||
setButton(0, 5, GuiUtils.createButtonItem(XMaterial.ARROW, this.plugin.getLocale().getMessage("gui.general.next").getMessage()), (event) -> toNextPage());
|
||||
}
|
||||
|
||||
private List<Template> findTemplates(int page, PunishmentType punishmentType) {
|
||||
return this.plugin.getTemplateManager().getTemplates().stream()
|
||||
.filter(template -> punishmentType == PunishmentType.ALL || template.getPunishmentType() == punishmentType)
|
||||
.skip((page - 1) * 28L)
|
||||
.limit(28)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package com.craftaro.ultimatemoderation.gui;
|
||||
|
||||
import com.craftaro.core.gui.Gui;
|
||||
import com.craftaro.core.gui.GuiUtils;
|
||||
import com.craftaro.core.utils.TextUtils;
|
||||
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.ultimatemoderation.punish.template.Template;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class TemplateSelectorGui extends Gui {
|
||||
private final UltimateModeration plugin;
|
||||
private final 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(XMaterial.OAK_DOOR,
|
||||
this.plugin.getLocale().getMessage("gui.general.back").getMessage()),
|
||||
(event) -> {
|
||||
this.guiManager.showGUI(event.player, this.punish);
|
||||
this.punish.runTask();
|
||||
});
|
||||
|
||||
ArrayList<Template> templates = new ArrayList<>(this.plugin.getTemplateManager().getTemplates());
|
||||
for (int i = 0; i < templates.size(); i++) {
|
||||
Template template = templates.get(i);
|
||||
setButton(18 + i, GuiUtils.createButtonItem(XMaterial.MAP, TextUtils.formatText("&6&l" + template.getName()),
|
||||
this.plugin.getLocale().getMessage("gui.templateselector.click").toText()),
|
||||
(event) -> {
|
||||
this.punish.setType(template.getPunishmentType());
|
||||
this.punish.setDuration(template.getDuration());
|
||||
this.punish.setReason(template.getReason());
|
||||
this.punish.setTemplate(template);
|
||||
this.punish.runTask();
|
||||
this.punish.paint();
|
||||
this.guiManager.showGUI(event.player, this.punish);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
159
src/main/java/com/craftaro/ultimatemoderation/gui/TicketGui.java
Normal file
159
src/main/java/com/craftaro/ultimatemoderation/gui/TicketGui.java
Normal file
@ -0,0 +1,159 @@
|
||||
package com.craftaro.ultimatemoderation.gui;
|
||||
|
||||
import com.craftaro.core.gui.Gui;
|
||||
import com.craftaro.core.gui.GuiUtils;
|
||||
import com.craftaro.core.input.ChatPrompt;
|
||||
import com.craftaro.core.utils.TextUtils;
|
||||
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.ultimatemoderation.settings.Settings;
|
||||
import com.craftaro.ultimatemoderation.staffchat.StaffChatManager;
|
||||
import com.craftaro.ultimatemoderation.tickets.Ticket;
|
||||
import com.craftaro.ultimatemoderation.tickets.TicketResponse;
|
||||
import com.craftaro.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 final StaffChatManager chatManager;
|
||||
|
||||
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.chatManager = plugin.getStaffChatManager();
|
||||
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 (this.inventory != null) {
|
||||
this.inventory.clear();
|
||||
}
|
||||
setActionForRange(0, 53, null);
|
||||
|
||||
int numNotes = this.ticket.getResponses().size();
|
||||
this.pages = (int) Math.floor(numNotes / 28.0);
|
||||
|
||||
List<TicketResponse> responses = this.ticket.getResponses().stream().skip((this.page - 1) * 28).limit(28)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// decorate the edges
|
||||
ItemStack glass2 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_2.getMaterial(XMaterial.BLUE_STAINED_GLASS_PANE));
|
||||
ItemStack glass3 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_3.getMaterial(XMaterial.LIGHT_BLUE_STAINED_GLASS_PANE));
|
||||
|
||||
// edges will be type 3
|
||||
mirrorFill(0, 2, true, true, glass3);
|
||||
mirrorFill(1, 1, true, true, glass3);
|
||||
|
||||
// decorate corners with type 2
|
||||
mirrorFill(0, 0, true, true, glass2);
|
||||
mirrorFill(1, 0, true, true, glass2);
|
||||
mirrorFill(0, 1, true, true, glass2);
|
||||
|
||||
// enable page event
|
||||
setNextPage(4, 7, GuiUtils.createButtonItem(XMaterial.ARROW, this.plugin.getLocale().getMessage("gui.general.next").getMessage()));
|
||||
setPrevPage(4, 1, GuiUtils.createButtonItem(XMaterial.ARROW, this.plugin.getLocale().getMessage("gui.general.back").getMessage()));
|
||||
setOnPage((event) -> showPage());
|
||||
|
||||
if (this.player.hasPermission("um.tickets.openclose")) {
|
||||
setButton(5, 3, GuiUtils.createButtonItem(XMaterial.LEVER, TextUtils.formatText("&6" + this.ticket.getStatus().getStatus())),
|
||||
(event) -> {
|
||||
this.ticket.setStatus(this.ticket.getStatus() == TicketStatus.OPEN ? TicketStatus.CLOSED : TicketStatus.OPEN);
|
||||
this.plugin.getDataHelper().updateTicket(this.ticket);
|
||||
// Notify staff of ticket status
|
||||
this.chatManager.getChat("ticket").messageAll(this.plugin.getLocale().getMessage("notify.ticket.status").toText().replace("%tid%", String.valueOf(this.ticket.getId())).replace("%type%", this.ticket.getType()).replace("%player%", Bukkit.getPlayer(this.ticket.getVictim()).getDisplayName()).replace("%status%", this.ticket.getStatus().toString()));
|
||||
showPage();
|
||||
});
|
||||
}
|
||||
|
||||
setButton(4, GuiUtils.createButtonItem(XMaterial.OAK_DOOR,
|
||||
this.plugin.getLocale().getMessage("gui.general.back").getMessage()),
|
||||
(event) -> {
|
||||
this.plugin.getGuiManager().showGUI(event.player, new TicketManagerGui(this.plugin, this.toModerate, event.player));
|
||||
});
|
||||
|
||||
if (this.player.hasPermission("um.ticket.clicktotele") && this.ticket.getLocation() != null) {
|
||||
setButton(5, 5, GuiUtils.createButtonItem(XMaterial.ENDER_PEARL,
|
||||
this.plugin.getLocale().getMessage("gui.ticket.clicktotele").getMessage()),
|
||||
(event) -> this.player.teleport(this.ticket.getLocation()));
|
||||
}
|
||||
|
||||
if (this.player.hasPermission("um.tickets.respond")) {
|
||||
setButton(5, 4, GuiUtils.createButtonItem(XMaterial.WRITABLE_BOOK, this.plugin.getLocale().getMessage("gui.ticket.respond").getMessage()),
|
||||
(event) -> {
|
||||
ChatPrompt.showPrompt(this.plugin, this.player, this.plugin.getLocale().getMessage("gui.ticket.what").toText(), (evnt) -> {
|
||||
TicketResponse response = this.ticket.addResponse(new TicketResponse(this.player, evnt.getMessage(), System.currentTimeMillis()));
|
||||
this.plugin.getDataHelper().createTicketResponse(response);
|
||||
// Notify staff of ticket response.
|
||||
this.chatManager.getChat("ticket").messageAll(this.plugin.getLocale().getMessage("notify.ticket.response").toText().replace("%tid%", "" + this.ticket.getId()).replace("%type%", this.ticket.getType()).replace("%player%", Bukkit.getPlayer(this.ticket.getVictim()).getDisplayName()));
|
||||
showPage();
|
||||
}).setOnClose(() -> this.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(this.plugin.getLocale().getMessage("gui.ticket.postedby")
|
||||
.processPlaceholder("player", Bukkit.getOfflinePlayer(ticketResponse.getAuthor()).getName()).toText());
|
||||
lore.add(this.plugin.getLocale().getMessage("gui.ticket.createdon")
|
||||
.processPlaceholder("sent", format.format(new Date(ticketResponse.getPostedDate()))).toText());
|
||||
|
||||
setItem(num, GuiUtils.createButtonItem(XMaterial.MAP, TextUtils.formatText(name), lore));
|
||||
num++;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,170 @@
|
||||
package com.craftaro.ultimatemoderation.gui;
|
||||
|
||||
import com.craftaro.core.gui.AnvilGui;
|
||||
import com.craftaro.core.gui.Gui;
|
||||
import com.craftaro.core.gui.GuiUtils;
|
||||
import com.craftaro.core.utils.TextUtils;
|
||||
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.ultimatemoderation.settings.Settings;
|
||||
import com.craftaro.ultimatemoderation.tickets.Ticket;
|
||||
import com.craftaro.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;
|
||||
|
||||
// FIXME: Pagination not working (probably in other GUIs too) (copy own one from TemplateManagerGui)
|
||||
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 (this.inventory != null) {
|
||||
this.inventory.clear();
|
||||
}
|
||||
setActionForRange(0, 53, null);
|
||||
|
||||
List<Ticket> tickets = this.toModerate != null
|
||||
? this.plugin.getTicketManager().getTicketsAbout(this.toModerate, this.status)
|
||||
: this.plugin.getTicketManager().getTickets(this.status);
|
||||
|
||||
int numTickets = tickets.size();
|
||||
this.pages = (int) Math.floor(numTickets / 28.0);
|
||||
|
||||
tickets = tickets.stream().skip((this.page - 1) * 28).limit(28).collect(Collectors.toList());
|
||||
|
||||
// decorate the edges
|
||||
ItemStack glass2 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_2.getMaterial(XMaterial.BLUE_STAINED_GLASS_PANE));
|
||||
ItemStack glass3 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_3.getMaterial(XMaterial.LIGHT_BLUE_STAINED_GLASS_PANE));
|
||||
|
||||
// edges will be type 3
|
||||
mirrorFill(0, 2, true, true, glass3);
|
||||
mirrorFill(1, 1, true, true, glass3);
|
||||
|
||||
// decorate corners with type 2
|
||||
mirrorFill(0, 0, true, true, glass2);
|
||||
mirrorFill(1, 0, true, true, glass2);
|
||||
mirrorFill(0, 1, true, true, glass2);
|
||||
|
||||
// enable page event
|
||||
setNextPage(4, 7, GuiUtils.createButtonItem(XMaterial.ARROW, this.plugin.getLocale().getMessage("gui.general.next").getMessage()));
|
||||
setPrevPage(4, 1, GuiUtils.createButtonItem(XMaterial.ARROW, this.plugin.getLocale().getMessage("gui.general.back").getMessage()));
|
||||
setOnPage((event) -> showPage());
|
||||
|
||||
setButton(5, 3, GuiUtils.createButtonItem(XMaterial.LEVER, TextUtils.formatText("&6" + this.status.getStatus())),
|
||||
(event) -> {
|
||||
this.status = this.status == TicketStatus.OPEN ? TicketStatus.CLOSED : TicketStatus.OPEN;
|
||||
this.page = 1;
|
||||
showPage();
|
||||
});
|
||||
|
||||
if (this.toModerate != null && this.player.hasPermission("um.tickets.create")) {
|
||||
setButton(5, 5, GuiUtils.createButtonItem(XMaterial.REDSTONE,
|
||||
this.plugin.getLocale().getMessage("gui.tickets.create").getMessage()),
|
||||
(event) -> createNew(this.player, this.toModerate));
|
||||
}
|
||||
|
||||
if (this.player.hasPermission("um.ticket")) {
|
||||
setButton(5, 4, GuiUtils.createButtonItem(XMaterial.OAK_DOOR,
|
||||
this.plugin.getLocale().getMessage("gui.general.back").getMessage()),
|
||||
(event) -> {
|
||||
if (this.toModerate == null) {
|
||||
this.plugin.getGuiManager().showGUI(this.player, new MainGui(this.plugin, this.player));
|
||||
} else {
|
||||
this.plugin.getGuiManager().showGUI(event.player, new PlayerGui(this.plugin, this.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(this.plugin.getLocale().getMessage("gui.ticket.status")
|
||||
.processPlaceholder("status", ticket.getStatus().getStatus()).toText());
|
||||
|
||||
if (this.toModerate != null) {
|
||||
lore.add(this.plugin.getLocale().getMessage("gui.tickets.player")
|
||||
.processPlaceholder("player", Bukkit.getOfflinePlayer(ticket.getVictim()).getName()).toText());
|
||||
}
|
||||
lore.add(this.plugin.getLocale().getMessage("gui.ticket.type")
|
||||
.processPlaceholder("type", ticket.getType()).toText());
|
||||
lore.add(this.plugin.getLocale().getMessage("gui.ticket.createdon")
|
||||
.processPlaceholder("sent", format.format(new Date(ticket.getCreationDate()))).toText());
|
||||
lore.add(this.plugin.getLocale().getMessage("gui.tickets.click").toText());
|
||||
|
||||
setButton(num, GuiUtils.createButtonItem(XMaterial.MAP,
|
||||
TextUtils.formatText(name), TextUtils.formatText(lore)),
|
||||
(event) -> this.guiManager.showGUI(this.player, new TicketGui(this.plugin, ticket, this.toModerate, this.player)));
|
||||
num++;
|
||||
}
|
||||
}
|
||||
|
||||
public static void createNew(Player player, OfflinePlayer toModerate) {
|
||||
UltimateModeration plugin = UltimateModeration.getPlugin(UltimateModeration.class);
|
||||
|
||||
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(XMaterial.PAPER,
|
||||
plugin.getLocale().getMessage("gui.tickets.subject").getMessage());
|
||||
|
||||
gui.setInput(item);
|
||||
plugin.getGuiManager().showGUI(player, gui);
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package com.craftaro.ultimatemoderation.gui;
|
||||
|
||||
import com.craftaro.core.gui.Gui;
|
||||
import com.craftaro.core.gui.GuiUtils;
|
||||
import com.craftaro.core.input.ChatPrompt;
|
||||
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.ultimatemoderation.settings.Settings;
|
||||
import com.craftaro.ultimatemoderation.staffchat.StaffChatManager;
|
||||
import com.craftaro.ultimatemoderation.tickets.Ticket;
|
||||
import com.craftaro.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;
|
||||
|
||||
public TicketTypeGui(UltimateModeration plugin, OfflinePlayer toModerate, Player player, String subject) {
|
||||
super(3);
|
||||
this.chatManager = plugin.getStaffChatManager();
|
||||
|
||||
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(XMaterial.PAPER, types.get(i)),
|
||||
(event) -> {
|
||||
Ticket ticket = new Ticket(toModerate, subject, types.get(fi));
|
||||
ChatPrompt.showPrompt(plugin,
|
||||
player, plugin.getLocale().getMessage("gui.tickets.what").toText(),
|
||||
event2 -> {
|
||||
plugin.getTicketManager().addTicket(ticket);
|
||||
|
||||
// Notify staff
|
||||
this.chatManager.getChat("ticket").messageAll(plugin.getLocale().getMessage("notify.ticket.created").toText().replace("%tid%", String.valueOf(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.getDataHelper().createTicket(ticket);
|
||||
}).setOnClose(() ->
|
||||
this.guiManager.showGUI(event.player, new TicketGui(plugin, ticket, toModerate, player)));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package com.craftaro.ultimatemoderation.listeners;
|
||||
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.ultimatemoderation.staffchat.StaffChatManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BlockListener implements Listener {
|
||||
private final UltimateModeration instance;
|
||||
private final StaffChatManager chat;
|
||||
|
||||
public BlockListener(UltimateModeration ultimateModeration) {
|
||||
this.instance = ultimateModeration;
|
||||
this.chat = ultimateModeration.getStaffChatManager();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
Block block = event.getBlock();
|
||||
Material material = block.getType();
|
||||
|
||||
List<String> blocks = this.instance.getConfig().getStringList("Main.Notify Blocks List");
|
||||
|
||||
for (String broken : blocks) {
|
||||
if (!broken.equalsIgnoreCase(material.name())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (player.hasPermission("um.trackblockbreaks") && this.instance.getConfig().getBoolean("Main.Notify Blocks")) {
|
||||
this.chat.getChat("notify").messageAll("&7[UM] &a" + Bukkit.getPlayer(player.getUniqueId()).getDisplayName()
|
||||
+ this.instance
|
||||
.getLocale()
|
||||
.getMessage("notify.block.main")
|
||||
.toText()
|
||||
.replace("%material%", material.name())
|
||||
+ "(" + block.getX() + ", " + block.getY() + ", " + block.getZ() + ")&a!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,11 +1,11 @@
|
||||
package com.songoda.ultimatemoderation.listeners;
|
||||
package com.craftaro.ultimatemoderation.listeners;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.punish.AppliedPunishment;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentType;
|
||||
import com.songoda.ultimatemoderation.settings.Settings;
|
||||
import com.songoda.ultimatemoderation.staffchat.StaffChannel;
|
||||
import com.songoda.ultimatemoderation.utils.Methods;
|
||||
import com.craftaro.core.utils.TimeUtils;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.ultimatemoderation.settings.Settings;
|
||||
import com.craftaro.ultimatemoderation.staffchat.StaffChannel;
|
||||
import com.craftaro.ultimatemoderation.punish.AppliedPunishment;
|
||||
import com.craftaro.ultimatemoderation.punish.PunishmentType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -18,7 +18,6 @@ import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ChatListener implements Listener {
|
||||
|
||||
private static long slowModeOverride = 0;
|
||||
|
||||
private static boolean isChatToggled = true; // true means people can talk, false means muted
|
||||
@ -32,7 +31,7 @@ public class ChatListener implements Listener {
|
||||
isChatToggled = toggled;
|
||||
}
|
||||
|
||||
private static List<Log> chatLog = new ArrayList<>();
|
||||
private static final List<Log> chatLog = new ArrayList<>();
|
||||
|
||||
public static long getSlowModeOverride() {
|
||||
return slowModeOverride;
|
||||
@ -41,14 +40,15 @@ public class ChatListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onChat(AsyncPlayerChatEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (!onChat(player, event.getMessage()))
|
||||
if (!onChat(player, event.getMessage())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean onChat(Player player, String message) {
|
||||
UltimateModeration instance = UltimateModeration.getInstance();
|
||||
|
||||
long slowmode = slowModeOverride == 0 ? Methods.parseTime(Settings.SLOW_MODE.getString()) : slowModeOverride;
|
||||
long slowmode = slowModeOverride == 0 ? TimeUtils.parseTime(Settings.SLOW_MODE.getString()) : slowModeOverride;
|
||||
|
||||
if (!player.hasPermission("um.slowmode.bypass") && slowmode != 0) {
|
||||
List<Log> chats = chatLog.stream().filter(log -> log.player == player.getUniqueId()).collect(Collectors.toList());
|
||||
@ -63,7 +63,9 @@ public class ChatListener implements Listener {
|
||||
boolean isCancelled = false;
|
||||
|
||||
for (StaffChannel channel : instance.getStaffChatManager().getChats().values()) {
|
||||
if (!channel.listMembers().contains(player.getUniqueId())) continue;
|
||||
if (!channel.listMembers().contains(player.getUniqueId())) {
|
||||
continue;
|
||||
}
|
||||
isCancelled = true;
|
||||
channel.processMessage(message, player);
|
||||
}
|
||||
@ -95,10 +97,9 @@ public class ChatListener implements Listener {
|
||||
}
|
||||
|
||||
public static class Log {
|
||||
|
||||
private UUID player;
|
||||
private long sent;
|
||||
private String message;
|
||||
private final UUID player;
|
||||
private final long sent;
|
||||
private final String message;
|
||||
|
||||
Log(UUID player, long sent, String message) {
|
||||
this.player = player;
|
||||
@ -107,16 +108,15 @@ public class ChatListener implements Listener {
|
||||
}
|
||||
|
||||
public UUID getPlayer() {
|
||||
return player;
|
||||
return this.player;
|
||||
}
|
||||
|
||||
public long getSent() {
|
||||
return sent;
|
||||
return this.sent;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
return this.message;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,10 +1,10 @@
|
||||
package com.songoda.ultimatemoderation.listeners;
|
||||
package com.craftaro.ultimatemoderation.listeners;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
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;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.ultimatemoderation.moderate.moderations.SpyModeration;
|
||||
import com.craftaro.ultimatemoderation.settings.Settings;
|
||||
import com.craftaro.ultimatemoderation.punish.AppliedPunishment;
|
||||
import com.craftaro.ultimatemoderation.punish.PunishmentType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -14,8 +14,7 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandListener implements Listener {
|
||||
|
||||
private UltimateModeration instance;
|
||||
private final UltimateModeration instance;
|
||||
|
||||
public CommandListener(UltimateModeration ultimateModeration) {
|
||||
this.instance = ultimateModeration;
|
||||
@ -24,36 +23,34 @@ public class CommandListener implements Listener {
|
||||
@EventHandler
|
||||
public void onCommand(PlayerCommandPreprocessEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
String command = event.getMessage();
|
||||
|
||||
List<AppliedPunishment> appliedPunishments = instance.getPunishmentManager().getPlayer(player).getActivePunishments(PunishmentType.MUTE);
|
||||
List<AppliedPunishment> appliedPunishments = this.instance.getPunishmentManager().getPlayer(player).getActivePunishments(PunishmentType.MUTE);
|
||||
if (!appliedPunishments.isEmpty()) {
|
||||
if (Settings.MUTE_DISABLED_COMMANDS.getStringList().stream()
|
||||
.anyMatch(s -> command.toUpperCase().startsWith("/" + s.toUpperCase())))
|
||||
if (Settings.MUTE_DISABLED_COMMANDS.getStringList().stream().anyMatch(s -> command.toUpperCase().startsWith("/" + s.toUpperCase()))) {
|
||||
event.setCancelled(true);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
List<String> blockedCommands = Settings.BLOCKED_COMMANDS.getStringList();
|
||||
|
||||
for (String cmd : blockedCommands) {
|
||||
if (command.toUpperCase().startsWith("/" + cmd.toUpperCase())
|
||||
&& (command.toUpperCase().endsWith(cmd.toUpperCase()) || (command.contains(" ") && command.split(" ")[0].toUpperCase().endsWith(cmd.toUpperCase())))
|
||||
&& !player.hasPermission("um.commandblock.bypass")) {
|
||||
event.setCancelled(true);
|
||||
event.setMessage("-");
|
||||
instance.getLocale().getMessage("event.command.blocked").sendPrefixedMessage(player);
|
||||
this.instance.getLocale().getMessage("event.command.blocked").sendPrefixedMessage(player);
|
||||
}
|
||||
}
|
||||
|
||||
if (!player.hasPermission("um.commandspy.immune")) {
|
||||
for (Player pl : Bukkit.getOnlinePlayers()) {
|
||||
if (pl != player && pl.hasPermission("um.commandspy") && SpyModeration.isSpying(pl))
|
||||
instance.getLocale().getMessage("command.commandspy.deny")
|
||||
if (pl != player && pl.hasPermission("um.commandspy") && SpyModeration.isSpying(pl)) {
|
||||
this.instance.getLocale().getMessage("command.commandspy.deny")
|
||||
.processPlaceholder("player", player.getName())
|
||||
.processPlaceholder("command", command)
|
||||
.sendPrefixedMessage(pl);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package com.songoda.ultimatemoderation.listeners;
|
||||
package com.craftaro.ultimatemoderation.listeners;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -13,14 +12,7 @@ import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class DeathListener implements Listener {
|
||||
|
||||
private static Map<UUID, List<ItemStack>> playerDrops = new HashMap<>();
|
||||
|
||||
private UltimateModeration instance;
|
||||
|
||||
public DeathListener(UltimateModeration ultimateModeration) {
|
||||
this.instance = ultimateModeration;
|
||||
}
|
||||
private static final Map<UUID, List<ItemStack>> playerDrops = new HashMap<>();
|
||||
|
||||
public static List<ItemStack> getLastDrop(Player player) {
|
||||
return playerDrops.get(player.getUniqueId());
|
@ -1,15 +1,14 @@
|
||||
package com.songoda.ultimatemoderation.listeners;
|
||||
package com.craftaro.ultimatemoderation.listeners;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.moderate.moderations.FreezeModeration;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.ultimatemoderation.moderate.moderations.FreezeModeration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
|
||||
public class DropListener implements Listener {
|
||||
|
||||
private UltimateModeration instance;
|
||||
private final UltimateModeration instance;
|
||||
|
||||
public DropListener(UltimateModeration ultimateModeration) {
|
||||
this.instance = ultimateModeration;
|
||||
@ -20,7 +19,7 @@ public class DropListener implements Listener {
|
||||
Player player = event.getPlayer();
|
||||
if (FreezeModeration.isFrozen(player)) {
|
||||
event.setCancelled(true);
|
||||
instance.getLocale().getMessage("command.freeze.nope").sendPrefixedMessage(player);
|
||||
this.instance.getLocale().getMessage("command.freeze.nope").sendPrefixedMessage(player);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,15 +1,14 @@
|
||||
package com.songoda.ultimatemoderation.listeners;
|
||||
package com.craftaro.ultimatemoderation.listeners;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.moderate.moderations.FreezeModeration;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.ultimatemoderation.moderate.moderations.FreezeModeration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
|
||||
public class InventoryListener implements Listener {
|
||||
|
||||
private UltimateModeration plugin;
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
public InventoryListener(UltimateModeration ultimateModeration) {
|
||||
this.plugin = ultimateModeration;
|
||||
@ -17,11 +16,14 @@ public class InventoryListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onMove(InventoryClickEvent event) {
|
||||
if (!(event.getWhoClicked() instanceof Player)) return;
|
||||
if (!(event.getWhoClicked() instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
if (FreezeModeration.isFrozen(player)) {
|
||||
event.setCancelled(true);
|
||||
plugin.getLocale().getMessage("command.freeze.nope").sendPrefixedMessage(player);
|
||||
this.plugin.getLocale().getMessage("command.freeze.nope").sendPrefixedMessage(player);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,11 +1,11 @@
|
||||
package com.songoda.ultimatemoderation.listeners;
|
||||
package com.craftaro.ultimatemoderation.listeners;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.commands.CommandVanish;
|
||||
import com.songoda.ultimatemoderation.punish.AppliedPunishment;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentType;
|
||||
import com.songoda.ultimatemoderation.punish.player.PlayerPunishData;
|
||||
import com.songoda.ultimatemoderation.utils.Methods;
|
||||
import com.craftaro.core.utils.TimeUtils;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.ultimatemoderation.commands.CommandVanish;
|
||||
import com.craftaro.ultimatemoderation.punish.AppliedPunishment;
|
||||
import com.craftaro.ultimatemoderation.punish.PunishmentType;
|
||||
import com.craftaro.ultimatemoderation.punish.player.PlayerPunishData;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -15,8 +15,7 @@ import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import java.util.List;
|
||||
|
||||
public class LoginListener implements Listener {
|
||||
|
||||
private UltimateModeration instance;
|
||||
private final UltimateModeration instance;
|
||||
|
||||
public LoginListener(UltimateModeration ultimateModeration) {
|
||||
this.instance = ultimateModeration;
|
||||
@ -24,17 +23,19 @@ public class LoginListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPreLogin(AsyncPlayerPreLoginEvent event) {
|
||||
PlayerPunishData playerPunishData = instance.getPunishmentManager().getPlayer(event.getUniqueId());
|
||||
PlayerPunishData playerPunishData = this.instance.getPunishmentManager().getPlayer(event.getUniqueId());
|
||||
|
||||
List<AppliedPunishment> appliedPunishments = playerPunishData.getActivePunishments(PunishmentType.BAN);
|
||||
|
||||
if (appliedPunishments.isEmpty()) return;
|
||||
if (appliedPunishments.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
AppliedPunishment appliedPunishment = playerPunishData.getActivePunishments(PunishmentType.BAN).get(0);
|
||||
|
||||
event.setKickMessage(instance.getLocale().getMessage("event.ban.message")
|
||||
event.setKickMessage(this.instance.getLocale().getMessage("event.ban.message")
|
||||
.processPlaceholder("reason", appliedPunishment.getReason() == null ? "" : appliedPunishment.getReason())
|
||||
.processPlaceholder("duration", Methods.makeReadable(appliedPunishment.getTimeRemaining())).getMessage());
|
||||
.processPlaceholder("duration", TimeUtils.makeReadable(appliedPunishment.getTimeRemaining())).toText());
|
||||
|
||||
event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_BANNED);
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.songoda.ultimatemoderation.listeners;
|
||||
package com.craftaro.ultimatemoderation.listeners;
|
||||
|
||||
import com.songoda.ultimatemoderation.commands.CommandVanish;
|
||||
import com.craftaro.ultimatemoderation.commands.CommandVanish;
|
||||
import org.bukkit.entity.Monster;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -9,15 +9,17 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
|
||||
|
||||
public class MobTargetLister implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onMobTagetEvent(EntityTargetLivingEntityEvent e) {
|
||||
if (!(e.getTarget() instanceof Player)) return;
|
||||
if (!(e.getEntity() instanceof Monster)) return;
|
||||
if (!(e.getTarget() instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
if (!(e.getEntity() instanceof Monster)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (CommandVanish.isVanished(((Player) e.getTarget()).getPlayer())) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,15 +1,14 @@
|
||||
package com.songoda.ultimatemoderation.listeners;
|
||||
package com.craftaro.ultimatemoderation.listeners;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.moderate.moderations.FreezeModeration;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.ultimatemoderation.moderate.moderations.FreezeModeration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
public class MoveListener implements Listener {
|
||||
|
||||
private UltimateModeration instance;
|
||||
private final UltimateModeration instance;
|
||||
|
||||
public MoveListener(UltimateModeration ultimateModeration) {
|
||||
this.instance = ultimateModeration;
|
||||
@ -20,7 +19,7 @@ public class MoveListener implements Listener {
|
||||
Player player = event.getPlayer();
|
||||
if (FreezeModeration.isFrozen(player)) {
|
||||
event.setCancelled(true);
|
||||
instance.getLocale().getMessage("command.freeze.nope").sendPrefixedMessage(player);
|
||||
this.instance.getLocale().getMessage("command.freeze.nope").sendPrefixedMessage(player);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,22 +1,14 @@
|
||||
package com.songoda.ultimatemoderation.listeners;
|
||||
package com.craftaro.ultimatemoderation.listeners;
|
||||
|
||||
import com.songoda.skyblock.api.event.player.PlayerIslandChatEvent;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public class SkyBlockListener implements Listener {
|
||||
|
||||
private UltimateModeration instance;
|
||||
|
||||
public SkyBlockListener(UltimateModeration ultimateModeration) {
|
||||
this.instance = ultimateModeration;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onIslandChat(PlayerIslandChatEvent event) {
|
||||
if (!ChatListener.onChat(event.getPlayer(), event.getMessage()))
|
||||
if (!ChatListener.onChat(event.getPlayer(), event.getMessage())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
package com.songoda.ultimatemoderation.listeners;
|
||||
package com.craftaro.ultimatemoderation.listeners;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.moderate.moderations.SpyModeration;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.ultimatemoderation.moderate.moderations.SpyModeration;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -17,21 +17,31 @@ import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class SpyingDismountListener implements Listener {
|
||||
private static final Map<UUID, GameMode> gamemodes = new HashMap<>();
|
||||
|
||||
private static Map<UUID, GameMode> gamemodes = new HashMap<>();
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
public SpyingDismountListener(UltimateModeration plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onEntityDismountEvent(EntityDismountEvent event) {
|
||||
if (!(event.getDismounted() instanceof Player)) return;
|
||||
if (!(event.getEntity() instanceof Player)) return;
|
||||
if (!(event.getDismounted() instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
if (!(event.getEntity() instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (SpyModeration.isSpying((((Player) event.getEntity()).getPlayer()))) {
|
||||
Player player = (Player) event.getEntity();
|
||||
gamemodes.put(player.getUniqueId(), player.getGameMode());
|
||||
player.setGameMode(GameMode.SPECTATOR);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(UltimateModeration.getInstance(), () -> {
|
||||
|
||||
if (player.getGameMode() == GameMode.SPECTATOR)
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(this.plugin, () -> {
|
||||
if (player.getGameMode() == GameMode.SPECTATOR) {
|
||||
player.setSpectatorTarget(event.getDismounted());
|
||||
}
|
||||
}, 5L);
|
||||
}
|
||||
}
|
||||
@ -39,8 +49,10 @@ public class SpyingDismountListener implements Listener {
|
||||
@EventHandler
|
||||
public void onSneak(PlayerToggleSneakEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (player.isSneaking() || !SpyModeration.isSpying(player) || player.getGameMode() != GameMode.SPECTATOR)
|
||||
if (player.isSneaking() || !SpyModeration.isSpying(player) || player.getGameMode() != GameMode.SPECTATOR) {
|
||||
return;
|
||||
}
|
||||
|
||||
SpyModeration.spy(null, player);
|
||||
}
|
||||
|
@ -1,14 +1,13 @@
|
||||
package com.songoda.ultimatemoderation.moderate;
|
||||
package com.craftaro.ultimatemoderation.moderate;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.utils.VaultPermissions;
|
||||
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.ultimatemoderation.utils.VaultPermissions;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public abstract class AbstractModeration {
|
||||
|
||||
protected final UltimateModeration plugin;
|
||||
private final boolean requireOnline, allowConsole;
|
||||
|
||||
@ -20,7 +19,7 @@ public abstract class AbstractModeration {
|
||||
|
||||
public abstract ModerationType getType();
|
||||
|
||||
public abstract CompatibleMaterial getIcon();
|
||||
public abstract XMaterial getIcon();
|
||||
|
||||
public abstract String getProper();
|
||||
|
||||
@ -43,12 +42,12 @@ public abstract class AbstractModeration {
|
||||
}
|
||||
|
||||
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 (this.requireOnline && !toModerate.isOnline()) {
|
||||
this.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);
|
||||
this.plugin.getLocale().newMessage(toModerate.getName() + " is exempt from this moderation.").sendPrefixedMessage(runner);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -58,10 +57,10 @@ public abstract class AbstractModeration {
|
||||
protected abstract boolean runModeration(CommandSender runner, OfflinePlayer toModerate);
|
||||
|
||||
public boolean isRequireOnline() {
|
||||
return requireOnline;
|
||||
return this.requireOnline;
|
||||
}
|
||||
|
||||
public boolean isAllowConsole() {
|
||||
return allowConsole;
|
||||
return this.allowConsole;
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
package com.songoda.ultimatemoderation.moderate;
|
||||
package com.craftaro.ultimatemoderation.moderate;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.core.commands.AbstractCommand;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -11,7 +11,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GenericModerationCommand extends AbstractCommand {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
private final AbstractModeration moderation;
|
||||
|
||||
@ -23,17 +22,18 @@ public class GenericModerationCommand extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length != 1)
|
||||
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...");
|
||||
this.plugin.getLocale().newMessage("&cThis player has never played this server before...");
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
moderation.runPreModeration(sender, player);
|
||||
this.moderation.runPreModeration(sender, player);
|
||||
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
@ -52,16 +52,16 @@ public class GenericModerationCommand extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return moderation.getPermission();
|
||||
return this.moderation.getPermission();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/" + moderation.getProper() + " <player>";
|
||||
return "/" + this.moderation.getProper() + " <player>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return moderation.getDescription();
|
||||
return this.moderation.getDescription();
|
||||
}
|
||||
}
|
@ -1,18 +1,17 @@
|
||||
package com.songoda.ultimatemoderation.moderate;
|
||||
package com.craftaro.ultimatemoderation.moderate;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.moderate.moderations.FreezeModeration;
|
||||
import com.songoda.ultimatemoderation.moderate.moderations.InvSeeModeration;
|
||||
import com.songoda.ultimatemoderation.moderate.moderations.ReviveModeration;
|
||||
import com.songoda.ultimatemoderation.moderate.moderations.SpyModeration;
|
||||
import com.songoda.ultimatemoderation.moderate.moderations.ViewEnderChestModeration;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.ultimatemoderation.moderate.moderations.FreezeModeration;
|
||||
import com.craftaro.ultimatemoderation.moderate.moderations.InvSeeModeration;
|
||||
import com.craftaro.ultimatemoderation.moderate.moderations.ReviveModeration;
|
||||
import com.craftaro.ultimatemoderation.moderate.moderations.SpyModeration;
|
||||
import com.craftaro.ultimatemoderation.moderate.moderations.ViewEnderChestModeration;
|
||||
|
||||
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) {
|
@ -1,7 +1,5 @@
|
||||
package com.songoda.ultimatemoderation.moderate;
|
||||
package com.craftaro.ultimatemoderation.moderate;
|
||||
|
||||
public enum ModerationType {
|
||||
|
||||
FREEZE, SPY, INV_SEE, ENDER_VIEW, REVIVE
|
||||
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
package com.songoda.ultimatemoderation.moderate.moderations;
|
||||
package com.craftaro.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 com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.ultimatemoderation.moderate.AbstractModeration;
|
||||
import com.craftaro.ultimatemoderation.moderate.ModerationType;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@ -12,7 +12,6 @@ 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) {
|
||||
@ -26,8 +25,8 @@ public class FreezeModeration extends AbstractModeration {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompatibleMaterial getIcon() {
|
||||
return CompatibleMaterial.BLUE_ICE;
|
||||
public XMaterial getIcon() {
|
||||
return XMaterial.BLUE_ICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -44,16 +43,18 @@ public class FreezeModeration extends AbstractModeration {
|
||||
protected boolean runModeration(CommandSender runner, OfflinePlayer toModerate) {
|
||||
if (frozen.contains(toModerate.getUniqueId())) {
|
||||
frozen.remove(toModerate.getUniqueId());
|
||||
plugin.getLocale().getMessage("command.freeze.remove")
|
||||
this.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());
|
||||
if (toModerate.isOnline()) {
|
||||
this.plugin.getLocale().getMessage("command.freeze.alertremove").sendPrefixedMessage(toModerate.getPlayer());
|
||||
}
|
||||
} else {
|
||||
frozen.add(toModerate.getUniqueId());
|
||||
plugin.getLocale().getMessage("command.freeze.add")
|
||||
this.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());
|
||||
if (toModerate.isOnline()) {
|
||||
this.plugin.getLocale().getMessage("command.freeze.alertadd").sendPrefixedMessage(toModerate.getPlayer());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
@ -1,15 +1,14 @@
|
||||
package com.songoda.ultimatemoderation.moderate.moderations;
|
||||
package com.craftaro.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 com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.ultimatemoderation.moderate.AbstractModeration;
|
||||
import com.craftaro.ultimatemoderation.moderate.ModerationType;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class InvSeeModeration extends AbstractModeration {
|
||||
|
||||
public InvSeeModeration(UltimateModeration plugin) {
|
||||
super(plugin, true, false);
|
||||
registerCommand(plugin);
|
||||
@ -21,8 +20,8 @@ public class InvSeeModeration extends AbstractModeration {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompatibleMaterial getIcon() {
|
||||
return CompatibleMaterial.CHEST;
|
||||
public XMaterial getIcon() {
|
||||
return XMaterial.CHEST;
|
||||
}
|
||||
|
||||
@Override
|
@ -1,11 +1,11 @@
|
||||
package com.songoda.ultimatemoderation.moderate.moderations;
|
||||
package com.craftaro.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 com.craftaro.core.utils.PlayerUtils;
|
||||
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.ultimatemoderation.listeners.DeathListener;
|
||||
import com.craftaro.ultimatemoderation.moderate.AbstractModeration;
|
||||
import com.craftaro.ultimatemoderation.moderate.ModerationType;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -14,9 +14,12 @@ import org.bukkit.inventory.ItemStack;
|
||||
import java.util.List;
|
||||
|
||||
public class ReviveModeration extends AbstractModeration {
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
public ReviveModeration(UltimateModeration plugin) {
|
||||
super(plugin, true, true);
|
||||
this.plugin = plugin;
|
||||
|
||||
registerCommand(plugin);
|
||||
}
|
||||
|
||||
@ -26,8 +29,8 @@ public class ReviveModeration extends AbstractModeration {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompatibleMaterial getIcon() {
|
||||
return CompatibleMaterial.POTION;
|
||||
public XMaterial getIcon() {
|
||||
return XMaterial.POTION;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -43,11 +46,10 @@ public class ReviveModeration extends AbstractModeration {
|
||||
@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);
|
||||
this.plugin.getLocale().getMessage("command.revive.noloot").sendPrefixedMessage(runner);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -56,8 +58,8 @@ public class ReviveModeration extends AbstractModeration {
|
||||
|
||||
PlayerUtils.giveItem(toModeratePlayer, dropArr);
|
||||
|
||||
instance.getLocale().getMessage("command.revive.revived").sendPrefixedMessage(toModeratePlayer);
|
||||
instance.getLocale().getMessage("command.revive.success")
|
||||
this.plugin.getLocale().getMessage("command.revive.revived").sendPrefixedMessage(toModeratePlayer);
|
||||
this.plugin.getLocale().getMessage("command.revive.success")
|
||||
.processPlaceholder("player", toModerate.getName()).sendPrefixedMessage(runner);
|
||||
return true;
|
||||
}
|
@ -1,12 +1,12 @@
|
||||
package com.songoda.ultimatemoderation.moderate.moderations;
|
||||
package com.craftaro.ultimatemoderation.moderate.moderations;
|
||||
|
||||
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 com.songoda.ultimatemoderation.moderate.AbstractModeration;
|
||||
import com.songoda.ultimatemoderation.moderate.ModerationType;
|
||||
import com.craftaro.core.compatibility.ServerVersion;
|
||||
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.ultimatemoderation.commands.CommandVanish;
|
||||
import com.craftaro.ultimatemoderation.listeners.SpyingDismountListener;
|
||||
import com.craftaro.ultimatemoderation.moderate.AbstractModeration;
|
||||
import com.craftaro.ultimatemoderation.moderate.ModerationType;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -17,8 +17,7 @@ import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class SpyModeration extends AbstractModeration {
|
||||
|
||||
private static Map<UUID, Spy> spying = new HashMap<>();
|
||||
private static final Map<UUID, Spy> spying = new HashMap<>();
|
||||
|
||||
public SpyModeration(UltimateModeration plugin) {
|
||||
super(plugin, true, false);
|
||||
@ -31,8 +30,8 @@ public class SpyModeration extends AbstractModeration {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompatibleMaterial getIcon() {
|
||||
return CompatibleMaterial.ENDER_EYE;
|
||||
public XMaterial getIcon() {
|
||||
return XMaterial.ENDER_EYE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -53,10 +52,11 @@ public class SpyModeration extends AbstractModeration {
|
||||
if (spying.containsKey(runnerPlayer.getUniqueId())) {
|
||||
Spy spyingEntry = spying.remove(runnerPlayer.getUniqueId());
|
||||
runnerPlayer.teleport(spyingEntry.getLastLocation());
|
||||
if (spyingEntry.isVanishApplied() && CommandVanish.isVanished(runnerPlayer))
|
||||
if (spyingEntry.isVanishApplied() && CommandVanish.isVanished(runnerPlayer)) {
|
||||
CommandVanish.vanish(runnerPlayer);
|
||||
}
|
||||
|
||||
plugin.getLocale().getMessage("command.spy.returned").sendPrefixedMessage(runner);
|
||||
this.plugin.getLocale().getMessage("command.spy.returned").sendPrefixedMessage(runner);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -74,8 +74,9 @@ public class SpyModeration extends AbstractModeration {
|
||||
if (spying.containsKey(senderP) && oPlayer == null) {
|
||||
Spy spyingEntry = spying.remove(senderP.getUniqueId());
|
||||
senderP.teleport(spyingEntry.getLastLocation());
|
||||
if (spyingEntry.isVanishApplied() && CommandVanish.isVanished(senderP))
|
||||
if (spyingEntry.isVanishApplied() && CommandVanish.isVanished(senderP)) {
|
||||
CommandVanish.vanish(senderP);
|
||||
}
|
||||
senderP.setGameMode(SpyingDismountListener.getGamemodes().get(senderP.getUniqueId()));
|
||||
|
||||
UltimateModeration.getInstance().getLocale().getMessage("command.spy.returned").sendPrefixedMessage(senderP);
|
||||
@ -114,8 +115,8 @@ public class SpyModeration extends AbstractModeration {
|
||||
}
|
||||
|
||||
public static class Spy {
|
||||
private Location lastLocation;
|
||||
private boolean vanishApplied;
|
||||
private final Location lastLocation;
|
||||
private final boolean vanishApplied;
|
||||
|
||||
public Spy(Location lastLocation, boolean vanishApplied) {
|
||||
this.lastLocation = lastLocation;
|
||||
@ -123,11 +124,11 @@ public class SpyModeration extends AbstractModeration {
|
||||
}
|
||||
|
||||
public Location getLastLocation() {
|
||||
return lastLocation;
|
||||
return this.lastLocation;
|
||||
}
|
||||
|
||||
public boolean isVanishApplied() {
|
||||
return vanishApplied;
|
||||
return this.vanishApplied;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,15 +1,14 @@
|
||||
package com.songoda.ultimatemoderation.moderate.moderations;
|
||||
package com.craftaro.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 com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.ultimatemoderation.moderate.ModerationType;
|
||||
import com.craftaro.ultimatemoderation.moderate.AbstractModeration;
|
||||
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);
|
||||
@ -21,8 +20,8 @@ public class ViewEnderChestModeration extends AbstractModeration {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompatibleMaterial getIcon() {
|
||||
return CompatibleMaterial.ENDER_CHEST;
|
||||
public XMaterial getIcon() {
|
||||
return XMaterial.ENDER_CHEST;
|
||||
}
|
||||
|
||||
@Override
|
@ -1,9 +1,8 @@
|
||||
package com.songoda.ultimatemoderation.punish;
|
||||
package com.craftaro.ultimatemoderation.punish;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class AppliedPunishment extends Punishment {
|
||||
|
||||
private final UUID victim;
|
||||
private final UUID punisher;
|
||||
private long expiration;
|
||||
@ -30,15 +29,15 @@ public class AppliedPunishment extends Punishment {
|
||||
}
|
||||
|
||||
public UUID getVictim() {
|
||||
return victim;
|
||||
return this.victim;
|
||||
}
|
||||
|
||||
public UUID getPunisher() {
|
||||
return punisher;
|
||||
return this.punisher;
|
||||
}
|
||||
|
||||
public long getExpiration() {
|
||||
return expiration;
|
||||
return this.expiration;
|
||||
}
|
||||
|
||||
public void expire() {
|
||||
@ -46,6 +45,6 @@ public class AppliedPunishment extends Punishment {
|
||||
}
|
||||
|
||||
public long getTimeRemaining() {
|
||||
return expiration - System.currentTimeMillis();
|
||||
return this.expiration - System.currentTimeMillis();
|
||||
}
|
||||
}
|
@ -1,15 +1,16 @@
|
||||
package com.songoda.ultimatemoderation.punish;
|
||||
package com.craftaro.ultimatemoderation.punish;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.punish.player.PlayerPunishData;
|
||||
import com.songoda.ultimatemoderation.utils.Methods;
|
||||
import com.craftaro.core.chat.AdventureUtils;
|
||||
import com.craftaro.core.utils.TextUtils;
|
||||
import com.craftaro.core.utils.TimeUtils;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.ultimatemoderation.punish.player.PlayerPunishData;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Punishment {
|
||||
|
||||
private int id;
|
||||
|
||||
private final PunishmentType punishmentType;
|
||||
@ -44,23 +45,24 @@ public class Punishment {
|
||||
public void execute(CommandSender punisher, OfflinePlayer victim) {
|
||||
UltimateModeration plugin = UltimateModeration.getInstance();
|
||||
|
||||
if (!punisher.hasPermission("Um." + punishmentType)) {
|
||||
if (!punisher.hasPermission("Um." + this.punishmentType)) {
|
||||
plugin.getLocale().getMessage("event.general.nopermission").sendPrefixedMessage(punisher);
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerPunishData playerPunishData = plugin.getPunishmentManager().getPlayer(victim);
|
||||
switch (punishmentType) {
|
||||
switch (this.punishmentType) {
|
||||
case BAN:
|
||||
if (!playerPunishData.getActivePunishments(PunishmentType.BAN).isEmpty()) {
|
||||
plugin.getLocale().getMessage("event.ban.already").sendPrefixedMessage(punisher);
|
||||
return;
|
||||
}
|
||||
if (victim.isOnline())
|
||||
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()));
|
||||
.processPlaceholder("reason", this.reason == null ? "" : this.reason)
|
||||
.processPlaceholder("duration", TimeUtils.makeReadable(this.duration)).toText()));
|
||||
}
|
||||
break;
|
||||
case MUTE:
|
||||
if (!playerPunishData.getActivePunishments(PunishmentType.MUTE).isEmpty()) {
|
||||
@ -70,62 +72,69 @@ public class Punishment {
|
||||
sendMessage(victim);
|
||||
break;
|
||||
case KICK:
|
||||
if (victim.isOnline())
|
||||
if (victim.isOnline()) {
|
||||
Bukkit.getScheduler().runTask(plugin, () -> victim.getPlayer().kickPlayer(plugin.getLocale()
|
||||
.getMessage("event.kick.message")
|
||||
.processPlaceholder("reason", reason == null ? "" : reason).getMessage()));
|
||||
.processPlaceholder("reason", this.reason == null ? "" : this.reason).toText()));
|
||||
}
|
||||
break;
|
||||
case WARNING:
|
||||
sendMessage(victim);
|
||||
break;
|
||||
}
|
||||
|
||||
String punishSuccess = plugin.getLocale()
|
||||
.getMessage("event." + punishmentType.name().toLowerCase() + ".success")
|
||||
String punishSuccess = AdventureUtils.toLegacy(plugin.getLocale()
|
||||
.getMessage("event." + this.punishmentType.name().toLowerCase() + ".success")
|
||||
.processPlaceholder("player", victim.getName())
|
||||
.getPrefixedMessage();
|
||||
.getPrefixedMessage());
|
||||
|
||||
if (reason != null)
|
||||
if (this.reason != null) {
|
||||
punishSuccess += plugin.getLocale().getMessage("event.punish.reason")
|
||||
.processPlaceholder("reason", reason).getMessage();
|
||||
.processPlaceholder("reason", this.reason).getMessage();
|
||||
}
|
||||
|
||||
if (duration != -1 && duration != 0)
|
||||
if (this.duration != -1 && this.duration != 0) {
|
||||
punishSuccess += plugin.getLocale().getMessage("event.punish.theirduration")
|
||||
.processPlaceholder("duration", Methods.makeReadable(duration)).getMessage();
|
||||
.processPlaceholder("duration", TimeUtils.makeReadable(this.duration)).getMessage();
|
||||
}
|
||||
|
||||
punisher.sendMessage(punishSuccess + Methods.formatText("&7."));
|
||||
punisher.sendMessage(punishSuccess + TextUtils.formatText("&7."));
|
||||
|
||||
AppliedPunishment appliedPunishment = apply(victim, punisher);
|
||||
if (duration != 0) {
|
||||
if (this.duration != 0) {
|
||||
playerPunishData.addPunishment(appliedPunishment);
|
||||
} else {
|
||||
appliedPunishment.expire();
|
||||
playerPunishData.addExpiredPunishment(appliedPunishment);
|
||||
}
|
||||
plugin.getDataManager().createAppliedPunishment(appliedPunishment);
|
||||
plugin.getDataHelper().createAppliedPunishment(appliedPunishment);
|
||||
}
|
||||
|
||||
public void sendMessage(OfflinePlayer offlineVictim) {
|
||||
if (!offlineVictim.isOnline()) return;
|
||||
if (!offlineVictim.isOnline()) {
|
||||
return;
|
||||
}
|
||||
Player victim = offlineVictim.getPlayer();
|
||||
UltimateModeration plugin = UltimateModeration.getInstance();
|
||||
|
||||
String punishSuccess = plugin.getLocale()
|
||||
.getMessage("event." + punishmentType.name().toLowerCase() + ".message").getPrefixedMessage();
|
||||
String punishSuccess = AdventureUtils.toLegacy(plugin.getLocale()
|
||||
.getMessage("event." + this.punishmentType.name().toLowerCase() + ".message").getPrefixedMessage());
|
||||
|
||||
if (reason != null)
|
||||
if (this.reason != null) {
|
||||
punishSuccess += plugin.getLocale().getMessage("event.punish.reason")
|
||||
.processPlaceholder("reason", reason).getMessage();
|
||||
.processPlaceholder("reason", this.reason).getMessage();
|
||||
}
|
||||
|
||||
if (duration != -1)
|
||||
if (this.duration != -1) {
|
||||
punishSuccess += plugin.getLocale().getMessage("event.punish.yourduration")
|
||||
.processPlaceholder("duration", Methods.makeReadable(duration)).getMessage();
|
||||
.processPlaceholder("duration", TimeUtils.makeReadable(this.duration)).getMessage();
|
||||
}
|
||||
|
||||
victim.sendMessage(punishSuccess + Methods.formatText("&7."));
|
||||
victim.sendMessage(punishSuccess + TextUtils.formatText("&7."));
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
@ -1,9 +1,8 @@
|
||||
package com.songoda.ultimatemoderation.punish;
|
||||
package com.craftaro.ultimatemoderation.punish;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class PunishmentNote {
|
||||
|
||||
private int id;
|
||||
|
||||
private final String note;
|
||||
@ -27,7 +26,7 @@ public class PunishmentNote {
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
@ -35,18 +34,18 @@ public class PunishmentNote {
|
||||
}
|
||||
|
||||
public String getNote() {
|
||||
return note;
|
||||
return this.note;
|
||||
}
|
||||
|
||||
public UUID getAuthor() {
|
||||
return author;
|
||||
return this.author;
|
||||
}
|
||||
|
||||
public UUID getSubject() {
|
||||
return subject;
|
||||
return this.subject;
|
||||
}
|
||||
|
||||
public long getCreationDate() {
|
||||
return creationDate;
|
||||
return this.creationDate;
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package com.craftaro.ultimatemoderation.punish;
|
||||
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
|
||||
public enum PunishmentType {
|
||||
ALL, BAN, KICK, WARNING, MUTE;
|
||||
|
||||
public PunishmentType next() {
|
||||
PunishmentType next = values()[(this.ordinal() != values().length - 1 ? this.ordinal() + 1 : 0)];
|
||||
|
||||
if (next == ALL) {
|
||||
next = next.next();
|
||||
}
|
||||
|
||||
return next;
|
||||
}
|
||||
|
||||
public PunishmentType nextFilter() {
|
||||
return values()[(this.ordinal() != values().length - 1 ? this.ordinal() + 1 : 0)];
|
||||
}
|
||||
|
||||
public String getTranslation() {
|
||||
return UltimateModeration.getPlugin(UltimateModeration.class)
|
||||
.getLocale()
|
||||
.getMessage("gui.punishmenttypes." + this.name().toLowerCase())
|
||||
.toText();
|
||||
}
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
package com.songoda.ultimatemoderation.punish.player;
|
||||
package com.craftaro.ultimatemoderation.punish.player;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.punish.AppliedPunishment;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentNote;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentType;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.ultimatemoderation.punish.AppliedPunishment;
|
||||
import com.craftaro.ultimatemoderation.punish.PunishmentNote;
|
||||
import com.craftaro.ultimatemoderation.punish.PunishmentType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@ -12,7 +12,6 @@ import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class PlayerPunishData {
|
||||
|
||||
private final UUID player;
|
||||
|
||||
private final List<AppliedPunishment> activePunishments = new ArrayList<>();
|
||||
@ -30,27 +29,27 @@ public class PlayerPunishData {
|
||||
}
|
||||
|
||||
public UUID getPlayer() {
|
||||
return player;
|
||||
return this.player;
|
||||
}
|
||||
|
||||
public List<AppliedPunishment> getActivePunishments() {
|
||||
audit();
|
||||
return new ArrayList<>(activePunishments);
|
||||
return new ArrayList<>(this.activePunishments);
|
||||
}
|
||||
|
||||
public List<AppliedPunishment> getActivePunishments(PunishmentType type) {
|
||||
audit();
|
||||
return activePunishments.stream().filter(punishment -> punishment.getPunishmentType() == type).collect(Collectors.toList());
|
||||
return this.activePunishments.stream().filter(punishment -> punishment.getPunishmentType() == type).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<AppliedPunishment> getExpiredPunishments() {
|
||||
audit();
|
||||
return new ArrayList<>(expiredPunishments);
|
||||
return new ArrayList<>(this.expiredPunishments);
|
||||
}
|
||||
|
||||
public List<AppliedPunishment> getExpiredPunishments(PunishmentType type) {
|
||||
audit();
|
||||
return expiredPunishments.stream().filter(punishment -> punishment.getPunishmentType() == type).collect(Collectors.toList());
|
||||
return this.expiredPunishments.stream().filter(punishment -> punishment.getPunishmentType() == type).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public AppliedPunishment[] addPunishment(AppliedPunishment... appliedPunishments) {
|
||||
@ -74,7 +73,7 @@ public class PlayerPunishData {
|
||||
}
|
||||
|
||||
public List<PunishmentNote> getNotes() {
|
||||
return new ArrayList<>(punishmentNotes);
|
||||
return new ArrayList<>(this.punishmentNotes);
|
||||
}
|
||||
|
||||
public PunishmentNote[] addNotes(PunishmentNote... notes) {
|
||||
@ -92,7 +91,7 @@ public class PlayerPunishData {
|
||||
}
|
||||
|
||||
private void audit(boolean forced, PunishmentType punishmentType) {
|
||||
List<AppliedPunishment> expired = activePunishments.stream().filter(appliedPunishment ->
|
||||
List<AppliedPunishment> expired = this.activePunishments.stream().filter(appliedPunishment ->
|
||||
(appliedPunishment.getDuration() != -1 || forced || appliedPunishment.getExpiration() == -1)
|
||||
&& (appliedPunishment.getPunishmentType() == punishmentType || punishmentType == PunishmentType.ALL)
|
||||
&& appliedPunishment.getExpiration() <= System.currentTimeMillis()).collect(Collectors.toList());
|
||||
@ -103,10 +102,10 @@ public class PlayerPunishData {
|
||||
|
||||
public void expirePunishments(PunishmentType type) {
|
||||
List<AppliedPunishment> toAudit = new ArrayList<>();
|
||||
activePunishments.stream().filter(appliedPunishment ->
|
||||
this.activePunishments.stream().filter(appliedPunishment ->
|
||||
type == appliedPunishment.getPunishmentType()).forEach(appliedPunishment -> {
|
||||
appliedPunishment.expire();
|
||||
UltimateModeration.getInstance().getDataManager().updateAppliedPunishment(appliedPunishment);
|
||||
UltimateModeration.getInstance().getDataHelper().updateAppliedPunishment(appliedPunishment);
|
||||
toAudit.add(appliedPunishment);
|
||||
});
|
||||
toAudit.forEach(appliedPunishment -> this.audit(true, type));
|
@ -1,4 +1,4 @@
|
||||
package com.songoda.ultimatemoderation.punish.player;
|
||||
package com.craftaro.ultimatemoderation.punish.player;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
@ -8,11 +8,10 @@ import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PunishmentManager {
|
||||
|
||||
private Map<UUID, PlayerPunishData> punishments = new HashMap<>();
|
||||
private final Map<UUID, PlayerPunishData> punishments = new HashMap<>();
|
||||
|
||||
public Map<UUID, PlayerPunishData> getPunishments() {
|
||||
return Collections.unmodifiableMap(punishments);
|
||||
return Collections.unmodifiableMap(this.punishments);
|
||||
}
|
||||
|
||||
public PlayerPunishData getPlayer(OfflinePlayer player) {
|
||||
@ -20,6 +19,6 @@ public class PunishmentManager {
|
||||
}
|
||||
|
||||
public PlayerPunishData getPlayer(UUID player) {
|
||||
return punishments.computeIfAbsent(player, PlayerPunishData::new);
|
||||
return this.punishments.computeIfAbsent(player, PlayerPunishData::new);
|
||||
}
|
||||
}
|
@ -1,13 +1,12 @@
|
||||
package com.songoda.ultimatemoderation.punish.template;
|
||||
package com.craftaro.ultimatemoderation.punish.template;
|
||||
|
||||
import com.songoda.ultimatemoderation.punish.Punishment;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentType;
|
||||
import com.craftaro.ultimatemoderation.punish.Punishment;
|
||||
import com.craftaro.ultimatemoderation.punish.PunishmentType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class Template extends Punishment {
|
||||
|
||||
private final String templateName;
|
||||
private final UUID creator;
|
||||
|
||||
@ -30,10 +29,10 @@ public class Template extends Punishment {
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return templateName;
|
||||
return this.templateName;
|
||||
}
|
||||
|
||||
public UUID getCreator() {
|
||||
return creator;
|
||||
return this.creator;
|
||||
}
|
||||
}
|
@ -1,19 +1,17 @@
|
||||
package com.songoda.ultimatemoderation.punish.template;
|
||||
package com.craftaro.ultimatemoderation.punish.template;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class TemplateManager {
|
||||
|
||||
private static final List<Template> templates = new LinkedList<>();
|
||||
|
||||
public Template getTemplate(String name) {
|
||||
for (Template template : templates) {
|
||||
if (formatName(template.getName()).equals(formatName(name)))
|
||||
if (formatName(template.getName()).equals(formatName(name))) {
|
||||
return template;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -33,7 +31,9 @@ public class TemplateManager {
|
||||
}
|
||||
|
||||
private String formatName(String name) {
|
||||
if (name == null) return null;
|
||||
if (name == null) {
|
||||
return null;
|
||||
}
|
||||
name = name.toUpperCase().trim();
|
||||
name = name.replace(" ", "_");
|
||||
return name;
|
@ -0,0 +1,80 @@
|
||||
package com.craftaro.ultimatemoderation.settings;
|
||||
|
||||
import com.craftaro.core.compatibility.CompatibleMaterial;
|
||||
import com.craftaro.core.configuration.Config;
|
||||
import com.craftaro.core.configuration.ConfigSetting;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Settings {
|
||||
static final Config CONFIG = UltimateModeration.getPlugin(UltimateModeration.class).getCoreConfig();
|
||||
|
||||
public static final ConfigSetting VANISH_EFFECTS = new ConfigSetting(CONFIG, "Main.Enable Vanish Effects", true,
|
||||
"Show particles and play sound when going in and out of vanish.");
|
||||
|
||||
public static final ConfigSetting VANISH_SOUND = new ConfigSetting(CONFIG, "Main.Vanish Sound", "ENTITY_GENERIC_EXPLODE",
|
||||
"Sound to be played when going into vanish.");
|
||||
|
||||
public static final ConfigSetting VANISH_BATS = new ConfigSetting(CONFIG, "Main.Release Bats On Vanish", true,
|
||||
"Shows bats when entering vanish.");
|
||||
|
||||
public static final ConfigSetting VANISH_PARTICLE = new ConfigSetting(CONFIG, "Main.Vanish Particle", "EXPLOSION_NORMAL",
|
||||
"Show particles when entering vanish.");
|
||||
|
||||
public static final ConfigSetting SLOW_MODE = new ConfigSetting(CONFIG, "Main.SLOW_MODE", "0s",
|
||||
"Limits how often a player can send a chat message by the corresponding amount.");
|
||||
|
||||
public static final ConfigSetting BLOCKED_COMMANDS = new ConfigSetting(CONFIG, "Main.Blocked Commands", Arrays.asList("Fly", "Op", "Plugins", "Pl"),
|
||||
"Prevents players from running the specified commands.");
|
||||
|
||||
public static final ConfigSetting AUTOSAVE = new ConfigSetting(CONFIG, "Main.Auto Save Interval In Seconds", 15,
|
||||
"The amount of time in between saving to file.",
|
||||
"This is purely a safety function to prevent against unplanned crashes or",
|
||||
"restarts. With that said it is advised to keep this enabled.",
|
||||
"If however you enjoy living on the edge, feel free to turn it off.");
|
||||
|
||||
public static final ConfigSetting STAFFCHAT_COLOR_CODE = new ConfigSetting(CONFIG, "Main.Staff Chat Color Code", 'b',
|
||||
"Color of messages sent in staff chat.");
|
||||
|
||||
public static final ConfigSetting TICKET_TYPES = new ConfigSetting(CONFIG, "Main.Ticket Types", Arrays.asList("Grief", "Player Report", "Bug Report", "Suggestion", "Other"),
|
||||
"Types of tickets players can open.");
|
||||
|
||||
public static final ConfigSetting MUTE_DISABLED_COMMANDS = new ConfigSetting(CONFIG, "Main.Mute Disabled Commands", Arrays.asList("minecraft:me", "minecraft:tell"),
|
||||
"Commands disabled when a player is muted.");
|
||||
|
||||
public static final ConfigSetting GLASS_TYPE_1 = new ConfigSetting(CONFIG, "Interfaces.Glass Type 1", "GRAY_STAINED_GLASS_PANE");
|
||||
public static final ConfigSetting GLASS_TYPE_2 = new ConfigSetting(CONFIG, "Interfaces.Glass Type 2", "BLUE_STAINED_GLASS_PANE");
|
||||
public static final ConfigSetting GLASS_TYPE_3 = new ConfigSetting(CONFIG, "Interfaces.Glass Type 3", "LIGHT_BLUE_STAINED_GLASS_PANE");
|
||||
|
||||
public static final ConfigSetting LANGUGE_MODE = new ConfigSetting(CONFIG, "System.Language Mode", "en_US",
|
||||
"The enabled language file.",
|
||||
"More language files (if available) can be found in the plugins data folder.");
|
||||
|
||||
public static final ConfigSetting NOTIFY_BLOCK = new ConfigSetting(CONFIG, "Main.Notify Blocks", true, "Notify Staff on Block Break");
|
||||
|
||||
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 DATA_UPDATE_INTERVAL = new ConfigSetting(CONFIG, "Main.Data Update Interval", 20,
|
||||
"The amount of time in between updating the data from the database in ticks.");
|
||||
|
||||
public static void setupConfig() {
|
||||
CONFIG.load();
|
||||
CONFIG.setAutoremove(true).setAutosave(true);
|
||||
|
||||
// convert glass pane settings
|
||||
int color;
|
||||
if ((color = GLASS_TYPE_1.getInt(-1)) != -1) {
|
||||
CONFIG.set(GLASS_TYPE_1.getKey(), CompatibleMaterial.getGlassPaneForColor(color).name());
|
||||
}
|
||||
if ((color = GLASS_TYPE_2.getInt(-1)) != -1) {
|
||||
CONFIG.set(GLASS_TYPE_2.getKey(), CompatibleMaterial.getGlassPaneForColor(color).name());
|
||||
}
|
||||
if ((color = GLASS_TYPE_3.getInt(-1)) != -1) {
|
||||
CONFIG.set(GLASS_TYPE_3.getKey(), CompatibleMaterial.getGlassPaneForColor(color).name());
|
||||
}
|
||||
|
||||
CONFIG.saveChanges();
|
||||
}
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
package com.songoda.ultimatemoderation.staffchat;
|
||||
package com.craftaro.ultimatemoderation.staffchat;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.settings.Settings;
|
||||
import com.songoda.ultimatemoderation.utils.Methods;
|
||||
import com.craftaro.core.utils.TextUtils;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.ultimatemoderation.settings.Settings;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -11,7 +11,6 @@ import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class StaffChannel {
|
||||
|
||||
private final String channelName;
|
||||
private char chatChar = Settings.STAFFCHAT_COLOR_CODE.getChar();
|
||||
private final List<UUID> members = new ArrayList<>();
|
||||
@ -22,40 +21,47 @@ public class StaffChannel {
|
||||
}
|
||||
|
||||
public List<UUID> listMembers() {
|
||||
return new ArrayList<>(members);
|
||||
return new ArrayList<>(this.members);
|
||||
}
|
||||
|
||||
public void addMember(Player player) {
|
||||
if (members.contains(player.getUniqueId())) return;
|
||||
if (this.members.contains(player.getUniqueId())) {
|
||||
return;
|
||||
}
|
||||
messageAll(UltimateModeration.getInstance().getLocale()
|
||||
.getMessage("event.staffchat.alljoin")
|
||||
.processPlaceholder("player", player.getName()).getMessage(), player);
|
||||
.processPlaceholder("player", player.getName()).toText(), player);
|
||||
|
||||
UltimateModeration.getInstance().getStaffChatManager().getChats().values().stream().forEach(members1 -> {
|
||||
UltimateModeration.getInstance()
|
||||
.getStaffChatManager()
|
||||
.getChats()
|
||||
.values()
|
||||
.stream()
|
||||
.forEach(members1 -> {
|
||||
if (members1.listMembers().contains(player.getUniqueId())) {
|
||||
members1.removeMember(player);
|
||||
}
|
||||
});
|
||||
members.add(player.getUniqueId());
|
||||
if (chatLog.size() > 5) {
|
||||
chatLog.stream().skip(chatLog.size() - 3).forEach(message -> player.sendMessage(Methods.formatText(message)));
|
||||
this.members.add(player.getUniqueId());
|
||||
if (this.chatLog.size() > 5) {
|
||||
this.chatLog.stream().skip(this.chatLog.size() - 3).forEach(message -> player.sendMessage(TextUtils.formatText(message)));
|
||||
}
|
||||
}
|
||||
|
||||
public void removeMember(Player player) {
|
||||
members.remove(player.getUniqueId());
|
||||
this.members.remove(player.getUniqueId());
|
||||
messageAll(UltimateModeration.getInstance().getLocale()
|
||||
.getMessage("event.staffchat.allleave")
|
||||
.processPlaceholder("player", player.getName()).getMessage(), player);
|
||||
.processPlaceholder("player", player.getName()).toText(), player);
|
||||
}
|
||||
|
||||
public void processMessage(String message, Player player) {
|
||||
messageAll(UltimateModeration.getInstance().getLocale()
|
||||
.getMessage("event.staffchat.format")
|
||||
.processPlaceholder("color", chatChar)
|
||||
.processPlaceholder("channel", channelName)
|
||||
.processPlaceholder("color", String.valueOf(this.chatChar))
|
||||
.processPlaceholder("channel", this.channelName)
|
||||
.processPlaceholder("player", player.getDisplayName())
|
||||
.processPlaceholder("message", message).getMessage());
|
||||
.processPlaceholder("message", message).toText());
|
||||
}
|
||||
|
||||
public void messageAll(String message) {
|
||||
@ -63,20 +69,24 @@ public class StaffChannel {
|
||||
}
|
||||
|
||||
public void messageAll(String message, Player exempt) {
|
||||
chatLog.add(message);
|
||||
this.chatLog.add(message);
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (exempt != null && player == exempt) continue;
|
||||
if (!members.contains(player.getUniqueId()) && !player.hasPermission("um.staffchat.spy")) continue;
|
||||
player.sendMessage(Methods.formatText(message));
|
||||
if (exempt != null && player == exempt) {
|
||||
continue;
|
||||
}
|
||||
if (!this.members.contains(player.getUniqueId()) && !player.hasPermission("um.staffchat.spy")) {
|
||||
continue;
|
||||
}
|
||||
player.sendMessage(TextUtils.formatText(message));
|
||||
}
|
||||
}
|
||||
|
||||
public String getChannelName() {
|
||||
return channelName;
|
||||
return this.channelName;
|
||||
}
|
||||
|
||||
public char getChatChar() {
|
||||
return chatChar;
|
||||
return this.chatChar;
|
||||
}
|
||||
|
||||
public void setChatChar(char chatChar) {
|
@ -1,27 +1,28 @@
|
||||
package com.songoda.ultimatemoderation.staffchat;
|
||||
package com.craftaro.ultimatemoderation.staffchat;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class StaffChatManager {
|
||||
|
||||
private final Map<String, StaffChannel> chats = new HashMap<>();
|
||||
|
||||
public Map<String, StaffChannel> getChats() {
|
||||
return Collections.unmodifiableMap(chats);
|
||||
return Collections.unmodifiableMap(this.chats);
|
||||
}
|
||||
|
||||
public StaffChannel getChat(String channel) {
|
||||
return chats.computeIfAbsent(formatName(channel), k -> new StaffChannel(formatName(channel)));
|
||||
return this.chats.computeIfAbsent(formatName(channel), k -> new StaffChannel(formatName(channel)));
|
||||
}
|
||||
|
||||
public void removeChat(String channel) {
|
||||
chats.remove(formatName(channel));
|
||||
this.chats.remove(formatName(channel));
|
||||
}
|
||||
|
||||
private String formatName(String name) {
|
||||
if (name == null) return null;
|
||||
if (name == null) {
|
||||
return null;
|
||||
}
|
||||
name = name.toUpperCase().trim();
|
||||
name = name.replace(" ", "_");
|
||||
return name;
|
@ -0,0 +1,31 @@
|
||||
package com.craftaro.ultimatemoderation.tasks;
|
||||
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.ultimatemoderation.database.DataHelper;
|
||||
import com.craftaro.ultimatemoderation.punish.Punishment;
|
||||
import com.craftaro.ultimatemoderation.punish.player.PunishmentManager;
|
||||
import com.craftaro.ultimatemoderation.settings.Settings;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
public class DataTask implements Runnable {
|
||||
|
||||
private BukkitTask task;
|
||||
private final DataHelper dataHelper;
|
||||
|
||||
public DataTask(DataHelper dataHelper) {
|
||||
this.dataHelper = dataHelper;
|
||||
this.task = Bukkit.getScheduler().runTaskTimerAsynchronously(UltimateModeration.getPlugin(UltimateModeration.class), this, 0, Settings.DATA_UPDATE_INTERVAL.getInt());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
//Update punisment data
|
||||
dataHelper.updateData();
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
task.cancel();
|
||||
}
|
||||
}
|
@ -1,10 +1,10 @@
|
||||
package com.songoda.ultimatemoderation.tasks;
|
||||
package com.craftaro.ultimatemoderation.tasks;
|
||||
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.listeners.ChatListener;
|
||||
import com.songoda.ultimatemoderation.settings.Settings;
|
||||
import com.songoda.ultimatemoderation.utils.Methods;
|
||||
import com.craftaro.core.compatibility.ServerVersion;
|
||||
import com.craftaro.core.utils.TimeUtils;
|
||||
import com.craftaro.ultimatemoderation.UltimateModeration;
|
||||
import com.craftaro.ultimatemoderation.listeners.ChatListener;
|
||||
import com.craftaro.ultimatemoderation.settings.Settings;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -14,7 +14,6 @@ import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class SlowModeTask extends BukkitRunnable {
|
||||
|
||||
private static SlowModeTask instance;
|
||||
private static UltimateModeration plugin;
|
||||
|
||||
@ -34,29 +33,33 @@ public class SlowModeTask extends BukkitRunnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
long slowmode = ChatListener.getSlowModeOverride() == 0 ? Methods.parseTime(Settings.SLOW_MODE.getString()) : ChatListener.getSlowModeOverride();
|
||||
long slowmode = ChatListener.getSlowModeOverride() == 0 ? TimeUtils.parseTime(Settings.SLOW_MODE.getString()) : ChatListener.getSlowModeOverride();
|
||||
|
||||
if (slowmode == 0) return;
|
||||
if (slowmode == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<ChatListener.Log> logs = ChatListener.getLogs();
|
||||
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
if (player.hasPermission("um.slowmode.bypass")) return;
|
||||
if (player.hasPermission("um.slowmode.bypass")) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<ChatListener.Log> chats = logs.stream().filter(log -> log.getPlayer() == player.getUniqueId()).collect(Collectors.toList());
|
||||
if (chats.size() == 0) return;
|
||||
if (chats.size() == 0) {
|
||||
return;
|
||||
}
|
||||
ChatListener.Log last = chats.get(chats.size() - 1);
|
||||
|
||||
if ((System.currentTimeMillis() - last.getSent()) < (slowmode + 1000)) {
|
||||
int remaining = (int) ((slowmode / 1000) - (System.currentTimeMillis() - last.getSent()) / 1000);
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9))
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) {
|
||||
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(remaining == 0
|
||||
? plugin.getLocale().getMessage("event.slowmode.done").getMessage()
|
||||
: plugin.getLocale().getMessage("event.slowmode.wait").processPlaceholder("delay", remaining).getMessage()));
|
||||
? plugin.getLocale().getMessage("event.slowmode.done").toText()
|
||||
: plugin.getLocale().getMessage("event.slowmode.wait").processPlaceholder("delay", remaining).toText()));
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.songoda.ultimatemoderation.tickets;
|
||||
package com.craftaro.ultimatemoderation.tickets;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@ -8,7 +8,6 @@ import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Ticket {
|
||||
|
||||
private int id;
|
||||
|
||||
private TicketStatus status = TicketStatus.OPEN;
|
@ -1,4 +1,4 @@
|
||||
package com.songoda.ultimatemoderation.tickets;
|
||||
package com.craftaro.ultimatemoderation.tickets;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
@ -9,7 +9,6 @@ import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class TicketManager {
|
||||
|
||||
private final TreeMap<Integer, Ticket> registeredTickets = new TreeMap<>();
|
||||
|
||||
public Ticket addTicket(Ticket ticket) {
|
@ -1,11 +1,10 @@
|
||||
package com.songoda.ultimatemoderation.tickets;
|
||||
package com.craftaro.ultimatemoderation.tickets;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class TicketResponse {
|
||||
|
||||
private int ticketId;
|
||||
|
||||
private final UUID author;
|
@ -1,7 +1,6 @@
|
||||
package com.songoda.ultimatemoderation.tickets;
|
||||
package com.craftaro.ultimatemoderation.tickets;
|
||||
|
||||
public enum TicketStatus {
|
||||
|
||||
OPEN("Open"),
|
||||
CLOSED("Closed");
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.songoda.ultimatemoderation.utils;
|
||||
package com.craftaro.ultimatemoderation.utils;
|
||||
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -6,20 +6,18 @@ import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
|
||||
public class VaultPermissions {
|
||||
|
||||
// Vault
|
||||
private static Permission vaultPermission = null;
|
||||
|
||||
static {
|
||||
if (Bukkit.getServer().getPluginManager().getPlugin("Vault") != null) {
|
||||
RegisteredServiceProvider<Permission> permissionRsp = Bukkit.getServer().getServicesManager().getRegistration(Permission.class);
|
||||
if (permissionRsp != null) vaultPermission = permissionRsp.getProvider();
|
||||
if (permissionRsp != null) {
|
||||
vaultPermission = permissionRsp.getProvider();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean hasPermission(OfflinePlayer offlinePlayer, String perm) {
|
||||
if (vaultPermission != null)
|
||||
return vaultPermission.playerHas(Bukkit.getWorlds().get(0).getName(), offlinePlayer, perm);
|
||||
return false;
|
||||
return vaultPermission != null && vaultPermission.playerHas(Bukkit.getWorlds().get(0).getName(), offlinePlayer, perm);
|
||||
}
|
||||
}
|
@ -1,222 +0,0 @@
|
||||
package com.songoda.ultimatemoderation;
|
||||
|
||||
import com.songoda.core.SongodaCore;
|
||||
import com.songoda.core.SongodaPlugin;
|
||||
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.player.PunishmentManager;
|
||||
import com.songoda.ultimatemoderation.punish.template.Template;
|
||||
import com.songoda.ultimatemoderation.punish.template.TemplateManager;
|
||||
import com.songoda.ultimatemoderation.settings.Settings;
|
||||
import com.songoda.ultimatemoderation.staffchat.StaffChatManager;
|
||||
import com.songoda.ultimatemoderation.tasks.SlowModeTask;
|
||||
import com.songoda.ultimatemoderation.tickets.Ticket;
|
||||
import com.songoda.ultimatemoderation.tickets.TicketManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class UltimateModeration extends SongodaPlugin {
|
||||
private static UltimateModeration INSTANCE;
|
||||
|
||||
private final GuiManager guiManager = new GuiManager(this);
|
||||
private TicketManager ticketManager;
|
||||
private TemplateManager templateManager;
|
||||
private CommandManager commandManager;
|
||||
private PunishmentManager punishmentManager;
|
||||
private StaffChatManager staffChatManager;
|
||||
private ModerationManager moderationManager;
|
||||
|
||||
private DatabaseConnector databaseConnector;
|
||||
private DataManager dataManager;
|
||||
|
||||
public static UltimateModeration getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginLoad() {
|
||||
INSTANCE = this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginDisable() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginEnable() {
|
||||
// Run Songoda Updater
|
||||
SongodaCore.registerPlugin(this, 29, CompatibleMaterial.DIAMOND_CHESTPLATE);
|
||||
|
||||
// Setup Config
|
||||
Settings.setupConfig();
|
||||
this.setLocale(Settings.LANGUGE_MODE.getString(), false);
|
||||
|
||||
// Register commands
|
||||
this.commandManager = new CommandManager(this);
|
||||
this.commandManager.addCommand(new CommandUltimateModeration(this))
|
||||
.addSubCommands(
|
||||
new CommandReload(this),
|
||||
new CommandSettings(this, guiManager),
|
||||
new CommandHelp(this)
|
||||
);
|
||||
this.commandManager.addCommand(new CommandBan(this));
|
||||
this.commandManager.addCommand(new CommandClearChat(this));
|
||||
this.commandManager.addCommand(new CommandKick(this));
|
||||
this.commandManager.addCommand(new CommandMute(this));
|
||||
this.commandManager.addCommand(new CommandRandomPlayer(this));
|
||||
this.commandManager.addCommand(new CommandRunTemplate(this));
|
||||
this.commandManager.addCommand(new CommandSlowMode(this));
|
||||
this.commandManager.addCommand(new CommandStaffChat(this));
|
||||
this.commandManager.addCommand(new CommandTicket(this, guiManager));
|
||||
this.commandManager.addCommand(new CommandToggleChat(this));
|
||||
this.commandManager.addCommand(new CommandUnBan(this));
|
||||
this.commandManager.addCommand(new CommandUnMute(this));
|
||||
this.commandManager.addCommand(new CommandVanish());
|
||||
this.commandManager.addCommand(new CommandWarn(this));
|
||||
|
||||
// Setup Managers
|
||||
this.ticketManager = new TicketManager();
|
||||
this.templateManager = new TemplateManager();
|
||||
this.punishmentManager = new PunishmentManager();
|
||||
this.staffChatManager = new StaffChatManager();
|
||||
this.moderationManager = new ModerationManager(this);
|
||||
|
||||
|
||||
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();
|
||||
int poolSize = Settings.MYSQL_POOL_SIZE.getInt();
|
||||
|
||||
this.databaseConnector = new MySQLConnector(this, hostname, port, database, username, password, useSSL, poolSize);
|
||||
this.getLogger().info("Data handler connected using MySQL.");
|
||||
} else {
|
||||
this.databaseConnector = new SQLiteConnector(this);
|
||||
this.getLogger().info("Data handler connected using SQLite.");
|
||||
}
|
||||
|
||||
this.dataManager = new DataManager(this.databaseConnector, this);
|
||||
DataMigrationManager dataMigrationManager = new DataMigrationManager(this.databaseConnector, this.dataManager,
|
||||
new _1_InitialMigration());
|
||||
dataMigrationManager.runMigrations();
|
||||
|
||||
} 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.");
|
||||
emergencyStop();
|
||||
return;
|
||||
}
|
||||
|
||||
// Register Listeners
|
||||
guiManager.init();
|
||||
PluginManager pluginManager = Bukkit.getPluginManager();
|
||||
pluginManager.registerEvents(new CommandListener(this), this);
|
||||
pluginManager.registerEvents(new DeathListener(this), this);
|
||||
pluginManager.registerEvents(new MoveListener(this), this);
|
||||
pluginManager.registerEvents(new DropListener(this), this);
|
||||
pluginManager.registerEvents(new InventoryListener(this), this);
|
||||
pluginManager.registerEvents(new ChatListener(this), this);
|
||||
pluginManager.registerEvents(new LoginListener(this), this);
|
||||
pluginManager.registerEvents(new MobTargetLister(), this);
|
||||
pluginManager.registerEvents(new BlockListener(this), this);
|
||||
if (pluginManager.isPluginEnabled("FabledSkyBlock"))
|
||||
pluginManager.registerEvents(new SkyBlockListener(this), this);
|
||||
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13))
|
||||
pluginManager.registerEvents(new SpyingDismountListener(), this);
|
||||
|
||||
// Start tasks
|
||||
SlowModeTask.startTask(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataLoad() {
|
||||
getDataManager().runAsync(() -> {
|
||||
// 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);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigReload() {
|
||||
this.setLocale(getConfig().getString("System.Language Mode"), true);
|
||||
this.locale.reloadMessages();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Config> getExtraConfig() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public CommandManager getCommandManager() {
|
||||
return commandManager;
|
||||
}
|
||||
|
||||
public TemplateManager getTemplateManager() {
|
||||
return templateManager;
|
||||
}
|
||||
|
||||
public PunishmentManager getPunishmentManager() {
|
||||
return punishmentManager;
|
||||
}
|
||||
|
||||
public TicketManager getTicketManager() {
|
||||
return ticketManager;
|
||||
}
|
||||
|
||||
public StaffChatManager getStaffChatManager() {
|
||||
return staffChatManager;
|
||||
}
|
||||
|
||||
public DataManager getDataManager() {
|
||||
return dataManager;
|
||||
}
|
||||
|
||||
public DatabaseConnector getDatabaseConnector() {
|
||||
return databaseConnector;
|
||||
}
|
||||
|
||||
public GuiManager getGuiManager() {
|
||||
return guiManager;
|
||||
}
|
||||
|
||||
public ModerationManager getModerationManager() {
|
||||
return moderationManager;
|
||||
}
|
||||
}
|
@ -1,201 +0,0 @@
|
||||
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 final 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
|
||||
mirrorFill(0, 2, true, true, glass3);
|
||||
mirrorFill(1, 1, true, true, glass3);
|
||||
|
||||
// decorate corners with type 2
|
||||
mirrorFill(0, 0, true, true, glass2);
|
||||
mirrorFill(1, 0, true, true, glass2);
|
||||
mirrorFill(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.clear();
|
||||
this.players.addAll(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)));
|
||||
|
||||
final List<UUID> toUseFinal = toUse.stream().skip((page - 1) * 28).limit(28).collect(Collectors.toList());
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||
int num = 11;
|
||||
for (UUID uuid : toUseFinal) {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,143 +0,0 @@
|
||||
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
|
||||
mirrorFill(0, 2, true, true, glass3);
|
||||
mirrorFill(1, 1, true, true, glass3);
|
||||
|
||||
// decorate corners with type 2
|
||||
mirrorFill(0, 0, true, true, glass2);
|
||||
mirrorFill(1, 0, true, true, glass2);
|
||||
mirrorFill(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++;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,329 +0,0 @@
|
||||
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
|
||||
mirrorFill(0, 2, true, true, glass3);
|
||||
mirrorFill(1, 1, true, true, glass3);
|
||||
|
||||
// decorate corners with type 2
|
||||
mirrorFill(0, 0, true, true, glass2);
|
||||
mirrorFill(1, 0, true, true, glass2);
|
||||
mirrorFill(2, 0, false, true, glass2);
|
||||
mirrorFill(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 == 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().removeTemplate(this.template);
|
||||
plugin.getTemplateManager().addTemplate(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,133 +0,0 @@
|
||||
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.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;
|
||||
|
||||
private int page = 1;
|
||||
|
||||
public TemplateManagerGui(UltimateModeration plugin, Player player) {
|
||||
super(6);
|
||||
setDefaultItem(null);
|
||||
this.plugin = plugin;
|
||||
this.player = player;
|
||||
|
||||
setTitle(plugin.getLocale().getMessage("gui.templatemanager.title").getMessage());
|
||||
toCurrentPage();
|
||||
}
|
||||
|
||||
private void toPrevPage() {
|
||||
if (this.page <= 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
--this.page;
|
||||
toCurrentPage();
|
||||
}
|
||||
|
||||
private void toNextPage() {
|
||||
if (findTemplates(this.page + 1, this.punishmentType).size() > 0) {
|
||||
++this.page;
|
||||
toCurrentPage();
|
||||
}
|
||||
}
|
||||
|
||||
private void toCurrentPage() {
|
||||
if (inventory != null) {
|
||||
inventory.clear();
|
||||
}
|
||||
|
||||
setActionForRange(0, 53, null);
|
||||
|
||||
int numTemplates = plugin.getTemplateManager().getTemplates().size();
|
||||
this.pages = (int) Math.floor(numTemplates / 28.0);
|
||||
|
||||
// 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
|
||||
mirrorFill(0, 2, true, true, glass3);
|
||||
mirrorFill(1, 1, true, true, glass3);
|
||||
|
||||
// decorate corners with type 2
|
||||
mirrorFill(0, 0, true, true, glass2);
|
||||
mirrorFill(1, 0, true, true, glass2);
|
||||
mirrorFill(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;
|
||||
toCurrentPage();
|
||||
});
|
||||
|
||||
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)));
|
||||
}
|
||||
|
||||
List<Template> templates = findTemplates(this.page, this.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);
|
||||
plugin.getDataManager().deleteTemplate(template);
|
||||
}
|
||||
|
||||
toCurrentPage();
|
||||
}
|
||||
});
|
||||
|
||||
++num;
|
||||
}
|
||||
|
||||
setButton(0, 3, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, plugin.getLocale().getMessage("gui.general.back").getMessage()), (event) -> toPrevPage());
|
||||
setButton(0, 5, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, plugin.getLocale().getMessage("gui.general.next").getMessage()), (event) -> toNextPage());
|
||||
}
|
||||
|
||||
private List<Template> findTemplates(int page, PunishmentType punishmentType) {
|
||||
return plugin.getTemplateManager().getTemplates().stream()
|
||||
.filter(template -> punishmentType == PunishmentType.ALL || template.getPunishmentType() == punishmentType)
|
||||
.skip((page - 1) * 28L)
|
||||
.limit(28)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
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 final 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());
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,153 +0,0 @@
|
||||
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 final 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
|
||||
mirrorFill(0, 2, true, true, glass3);
|
||||
mirrorFill(1, 1, true, true, glass3);
|
||||
|
||||
// decorate corners with type 2
|
||||
mirrorFill(0, 0, true, true, glass2);
|
||||
mirrorFill(1, 0, true, true, glass2);
|
||||
mirrorFill(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++;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,163 +0,0 @@
|
||||
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 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;
|
||||
|
||||
// FIXME: Pagination not working (probably in other GUIs too) (copy own one from TemplateManagerGui)
|
||||
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
|
||||
mirrorFill(0, 2, true, true, glass3);
|
||||
mirrorFill(1, 1, true, true, glass3);
|
||||
|
||||
// decorate corners with type 2
|
||||
mirrorFill(0, 0, true, true, glass2);
|
||||
mirrorFill(1, 0, true, true, glass2);
|
||||
mirrorFill(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);
|
||||
}
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
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,43 +0,0 @@
|
||||
package com.songoda.ultimatemoderation.listeners;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.staffchat.StaffChatManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BlockListener implements Listener {
|
||||
|
||||
private UltimateModeration instance;
|
||||
private StaffChatManager chat = UltimateModeration.getInstance().getStaffChatManager();
|
||||
|
||||
public BlockListener(UltimateModeration ultimateModeration) {
|
||||
this.instance = ultimateModeration;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
|
||||
Player player = event.getPlayer();
|
||||
Block block = event.getBlock();
|
||||
Material material = block.getType();
|
||||
|
||||
List<String> blocks = instance.getConfig().getStringList("Main.Notify Blocks List");
|
||||
|
||||
for (String broken : blocks) {
|
||||
if (!broken.equalsIgnoreCase(material.name())) continue;
|
||||
|
||||
if (player.hasPermission("um.trackblockbreaks") && instance.getConfig().getBoolean("Main.Notify Blocks")) {
|
||||
chat.getChat("notify").messageAll("&7[UM] &a" + Bukkit.getPlayer(player.getUniqueId()).getDisplayName()
|
||||
+ UltimateModeration.getInstance().getLocale().getMessage("notify.block.main").getMessage().replace("%material%", material.name()) + "(" + block.getX() + ", " + block.getY() + ", " + block.getZ() + ")&a!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
package com.songoda.ultimatemoderation.punish;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
|
||||
public enum PunishmentType {
|
||||
|
||||
ALL, BAN, KICK, WARNING, MUTE;
|
||||
|
||||
private static PunishmentType[] vals = values();
|
||||
|
||||
public PunishmentType next() {
|
||||
PunishmentType next = vals[(this.ordinal() != vals.length - 1 ? this.ordinal() + 1 : 0)];
|
||||
|
||||
if (next == ALL)
|
||||
next = next.next();
|
||||
|
||||
return next;
|
||||
}
|
||||
|
||||
public PunishmentType nextFilter() {
|
||||
return vals[(this.ordinal() != vals.length - 1 ? this.ordinal() + 1 : 0)];
|
||||
}
|
||||
|
||||
public String getTranslation() {
|
||||
return UltimateModeration.getInstance().getLocale().getMessage("gui.punishmenttypes." + this.name().toLowerCase()).getMessage();
|
||||
}
|
||||
}
|
@ -1,87 +0,0 @@
|
||||
package com.songoda.ultimatemoderation.settings;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.configuration.Config;
|
||||
import com.songoda.core.configuration.ConfigSetting;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Settings {
|
||||
|
||||
static final Config config = UltimateModeration.getInstance().getCoreConfig();
|
||||
|
||||
public static final ConfigSetting VANISH_EFFECTS = new ConfigSetting(config, "Main.Enable Vanish Effects", true,
|
||||
"Show particles and play sound when going in and out of vanish.");
|
||||
|
||||
public static final ConfigSetting VANISH_SOUND = new ConfigSetting(config, "Main.Vanish Sound", "ENTITY_GENERIC_EXPLODE",
|
||||
"Sound to be played when going into vanish.");
|
||||
|
||||
public static final ConfigSetting VANISH_BATS = new ConfigSetting(config, "Main.Release Bats On Vanish", true,
|
||||
"Shows bats when entering vanish.");
|
||||
|
||||
public static final ConfigSetting VANISH_PARTICLE = new ConfigSetting(config, "Main.Vanish Particle", "EXPLOSION_NORMAL",
|
||||
"Show particles when entering vanish.");
|
||||
|
||||
public static final ConfigSetting SLOW_MODE = new ConfigSetting(config, "Main.SLOW_MODE", "0s",
|
||||
"Limits how often a player can send a chat message by the corresponding amount.");
|
||||
|
||||
public static final ConfigSetting BLOCKED_COMMANDS = new ConfigSetting(config, "Main.Blocked Commands", Arrays.asList("Fly", "Op", "Plugins", "Pl"),
|
||||
"Prevents players from running the specified commands.");
|
||||
|
||||
public static final ConfigSetting AUTOSAVE = new ConfigSetting(config, "Main.Auto Save Interval In Seconds", 15,
|
||||
"The amount of time in between saving to file.",
|
||||
"This is purely a safety function to prevent against unplanned crashes or",
|
||||
"restarts. With that said it is advised to keep this enabled.",
|
||||
"If however you enjoy living on the edge, feel free to turn it off.");
|
||||
|
||||
public static final ConfigSetting STAFFCHAT_COLOR_CODE = new ConfigSetting(config, "Main.Staff Chat Color Code", 'b',
|
||||
"Color of messages sent in staff chat.");
|
||||
|
||||
public static final ConfigSetting TICKET_TYPES = new ConfigSetting(config, "Main.Ticket Types", Arrays.asList("Grief", "Player Report", "Bug Report", "Suggestion", "Other"),
|
||||
"Types of tickets players can open.");
|
||||
|
||||
public static final ConfigSetting MUTE_DISABLED_COMMANDS = new ConfigSetting(config, "Main.Mute Disabled Commands", Arrays.asList("minecraft:me", "minecraft:tell"),
|
||||
"Commands disabled when a player is muted.");
|
||||
|
||||
public static final ConfigSetting GLASS_TYPE_1 = new ConfigSetting(config, "Interfaces.Glass Type 1", "GRAY_STAINED_GLASS_PANE");
|
||||
public static final ConfigSetting GLASS_TYPE_2 = new ConfigSetting(config, "Interfaces.Glass Type 2", "BLUE_STAINED_GLASS_PANE");
|
||||
public static final ConfigSetting GLASS_TYPE_3 = new ConfigSetting(config, "Interfaces.Glass Type 3", "LIGHT_BLUE_STAINED_GLASS_PANE");
|
||||
|
||||
public static final ConfigSetting LANGUGE_MODE = new ConfigSetting(config, "System.Language Mode", "en_US",
|
||||
"The enabled language file.",
|
||||
"More language files (if available) can be found in the plugins data folder.");
|
||||
|
||||
public static final ConfigSetting NOTIFY_BLOCK = new ConfigSetting(config, "Main.Notify Blocks", true, "Notify Staff on Block Break");
|
||||
|
||||
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 final ConfigSetting MYSQL_POOL_SIZE = new ConfigSetting(config, "MySQL.Pool Size", 3, "Determines the number of connections the pool is using. Increase this value if you are getting timeout errors when more players online.");
|
||||
|
||||
public static void setupConfig() {
|
||||
config.load();
|
||||
config.setAutoremove(true).setAutosave(true);
|
||||
|
||||
// convert glass pane settings
|
||||
int color;
|
||||
if ((color = GLASS_TYPE_1.getInt(-1)) != -1) {
|
||||
config.set(GLASS_TYPE_1.getKey(), CompatibleMaterial.getGlassPaneColor(color).name());
|
||||
}
|
||||
if ((color = GLASS_TYPE_2.getInt(-1)) != -1) {
|
||||
config.set(GLASS_TYPE_2.getKey(), CompatibleMaterial.getGlassPaneColor(color).name());
|
||||
}
|
||||
if ((color = GLASS_TYPE_3.getInt(-1)) != -1) {
|
||||
config.set(GLASS_TYPE_3.getKey(), CompatibleMaterial.getGlassPaneColor(color).name());
|
||||
}
|
||||
|
||||
config.saveChanges();
|
||||
}
|
||||
}
|
@ -1,192 +0,0 @@
|
||||
package com.songoda.ultimatemoderation.utils;
|
||||
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class Methods {
|
||||
|
||||
private static Map<String, Location> serializeCache = new HashMap<>();
|
||||
|
||||
public static ItemStack getGlass() {
|
||||
UltimateModeration instance = UltimateModeration.getInstance();
|
||||
return Methods.getGlass(instance.getConfig().getBoolean("Interfaces.Replace Glass Type 1 With Rainbow Glass"), instance.getConfig().getInt("Interfaces.Glass Type 1"));
|
||||
}
|
||||
|
||||
public static ItemStack getBackgroundGlass(boolean type) {
|
||||
UltimateModeration instance = UltimateModeration.getInstance();
|
||||
if (type)
|
||||
return getGlass(false, instance.getConfig().getInt("Interfaces.Glass Type 2"));
|
||||
else
|
||||
return getGlass(false, instance.getConfig().getInt("Interfaces.Glass Type 3"));
|
||||
}
|
||||
|
||||
private static ItemStack getGlass(Boolean rainbow, int type) {
|
||||
int randomNum = 1 + (int) (Math.random() * 6);
|
||||
ItemStack glass;
|
||||
if (rainbow) {
|
||||
glass = new ItemStack(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13) ?
|
||||
Material.LEGACY_STAINED_GLASS_PANE : Material.valueOf("STAINED_GLASS_PANE"), 1, (short) randomNum);
|
||||
} else {
|
||||
glass = new ItemStack(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13) ?
|
||||
Material.LEGACY_STAINED_GLASS_PANE : Material.valueOf("STAINED_GLASS_PANE"), 1, (short) type);
|
||||
}
|
||||
ItemMeta glassmeta = glass.getItemMeta();
|
||||
glassmeta.setDisplayName("§l");
|
||||
glass.setItemMeta(glassmeta);
|
||||
return glass;
|
||||
}
|
||||
|
||||
public static String formatText(String text) {
|
||||
if (text == null || text.equals(""))
|
||||
return "";
|
||||
return formatText(text, false);
|
||||
}
|
||||
|
||||
public static String formatText(String text, boolean cap) {
|
||||
if (text == null || text.equals(""))
|
||||
return "";
|
||||
if (cap)
|
||||
text = text.substring(0, 1).toUpperCase() + text.substring(1);
|
||||
return ChatColor.translateAlternateColorCodes('&', text);
|
||||
}
|
||||
|
||||
public static String formatTitle(String text) {
|
||||
if (text == null || text.equals(""))
|
||||
return "";
|
||||
if (!ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) {
|
||||
if (text.length() > 31)
|
||||
text = text.substring(0, 29) + "...";
|
||||
}
|
||||
text = formatText(text);
|
||||
return text;
|
||||
}
|
||||
|
||||
public static String makeReadable(Long time) {
|
||||
if (time == null)
|
||||
return "";
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
long days = TimeUnit.MILLISECONDS.toDays(time);
|
||||
long hours = TimeUnit.MILLISECONDS.toHours(time) - TimeUnit.DAYS.toHours(TimeUnit.MILLISECONDS.toDays(time));
|
||||
long minutes = TimeUnit.MILLISECONDS.toMinutes(time) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(time));
|
||||
long seconds = TimeUnit.MILLISECONDS.toSeconds(time) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(time));
|
||||
|
||||
if (days != 0L)
|
||||
sb.append(" ").append(days).append("d");
|
||||
if (hours != 0L)
|
||||
sb.append(" ").append(hours).append("h");
|
||||
if (minutes != 0L)
|
||||
sb.append(" ").append(minutes).append("m");
|
||||
if (seconds != 0L)
|
||||
sb.append(" ").append(seconds).append("s");
|
||||
return sb.toString().trim();
|
||||
}
|
||||
|
||||
|
||||
public static long parseTime(String input) {
|
||||
long result = 0;
|
||||
StringBuilder number = new StringBuilder();
|
||||
for (int i = 0; i < input.length(); i++) {
|
||||
char c = input.charAt(i);
|
||||
if (Character.isDigit(c)) {
|
||||
number.append(c);
|
||||
} else if (Character.isLetter(c) && (number.length() > 0)) {
|
||||
result += convert(Integer.parseInt(number.toString()), c);
|
||||
number = new StringBuilder();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static long convert(long value, char unit) {
|
||||
switch (unit) {
|
||||
case 'd':
|
||||
return value * 1000 * 60 * 60 * 24;
|
||||
case 'h':
|
||||
return value * 1000 * 60 * 60;
|
||||
case 'm':
|
||||
return value * 1000 * 60;
|
||||
case 's':
|
||||
return value * 1000;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
public static String convertToInvisibleString(String s) {
|
||||
if (s == null || s.equals(""))
|
||||
return "";
|
||||
StringBuilder hidden = new StringBuilder();
|
||||
for (char c : s.toCharArray()) hidden.append(ChatColor.COLOR_CHAR + "").append(c);
|
||||
return hidden.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the location of the block specified.
|
||||
*
|
||||
* @param b The block whose location is to be saved.
|
||||
* @return The serialized data.
|
||||
*/
|
||||
public static String serializeLocation(Block b) {
|
||||
if (b == null)
|
||||
return "";
|
||||
return serializeLocation(b.getLocation());
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the location specified.
|
||||
*
|
||||
* @param location The location that is to be saved.
|
||||
* @return The serialized data.
|
||||
*/
|
||||
public static String serializeLocation(Location location) {
|
||||
if (location == null || location.getWorld() == null)
|
||||
return "";
|
||||
String w = location.getWorld().getName();
|
||||
double x = location.getX();
|
||||
double y = location.getY();
|
||||
double z = location.getZ();
|
||||
String str = w + ":" + x + ":" + y + ":" + z;
|
||||
str = str.replace(".0", "").replace("/", "");
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserializes a location from the string.
|
||||
*
|
||||
* @param str The string to parse.
|
||||
* @return The location that was serialized in the string.
|
||||
*/
|
||||
public static Location unserializeLocation(String str) {
|
||||
if (str == null || str.equals(""))
|
||||
return null;
|
||||
if (serializeCache.containsKey(str)) {
|
||||
return serializeCache.get(str).clone();
|
||||
}
|
||||
String cacheKey = str;
|
||||
str = str.replace("y:", ":").replace("z:", ":").replace("w:", "").replace("x:", ":").replace("/", ".");
|
||||
List<String> args = Arrays.asList(str.split("\\s*:\\s*"));
|
||||
|
||||
World world = Bukkit.getWorld(args.get(0));
|
||||
double x = Double.parseDouble(args.get(1)), y = Double.parseDouble(args.get(2)), z = Double.parseDouble(args.get(3));
|
||||
Location location = new Location(world, x, y, z, 0, 0);
|
||||
serializeCache.put(cacheKey, location.clone());
|
||||
return location;
|
||||
}
|
||||
|
||||
}
|
@ -1,96 +1,121 @@
|
||||
name: UltimateModeration
|
||||
description: UltimateModeration
|
||||
main: com.songoda.ultimatemoderation.UltimateModeration
|
||||
version: maven-version-number
|
||||
author: Songoda
|
||||
name: ${project.name}
|
||||
description: ${project.description}
|
||||
version: ${project.version}
|
||||
api-version: 1.13
|
||||
softdepend: [Vault, FabledSkyBlock]
|
||||
|
||||
main: com.craftaro.ultimatemoderation.UltimateModeration
|
||||
softdepend:
|
||||
- Vault
|
||||
- FabledSkyBlock
|
||||
|
||||
author: Craftaro
|
||||
website: ${project.url}
|
||||
|
||||
commands:
|
||||
UltimateModeration:
|
||||
description: View information on this plugin.
|
||||
default: true
|
||||
aliases: [um, p]
|
||||
aliases: [ um, p ]
|
||||
usage: /um
|
||||
|
||||
ClearChat:
|
||||
description: Clear the chat
|
||||
default: false
|
||||
aliases: [cc]
|
||||
aliases: [ cc ]
|
||||
usage: /cc
|
||||
|
||||
ToggleChat:
|
||||
description: Toggle chat
|
||||
default: false
|
||||
aliases: [tc]
|
||||
aliases: [ tc ]
|
||||
usage: /tc
|
||||
|
||||
RandomPlayer:
|
||||
description: Random Player
|
||||
default: false
|
||||
aliases: [rp]
|
||||
aliases: [ rp ]
|
||||
usage: /rp
|
||||
|
||||
Vanish:
|
||||
description: Vanish
|
||||
default: false
|
||||
aliases: [v]
|
||||
aliases: [ v ]
|
||||
usage: /v
|
||||
|
||||
Spy:
|
||||
description: Spy
|
||||
default: false
|
||||
usage: /spy
|
||||
|
||||
Revive:
|
||||
description: Revive
|
||||
default: false
|
||||
usage: /revive
|
||||
|
||||
InvSee:
|
||||
description: InvSee
|
||||
default: false
|
||||
usage: /invsee
|
||||
|
||||
Freeze:
|
||||
description: Freeze
|
||||
default: false
|
||||
usage: /freeze
|
||||
|
||||
ViewEnderChest:
|
||||
description: ViewEnderChest
|
||||
default: false
|
||||
usage: /ViewEnderChest
|
||||
|
||||
Ban:
|
||||
description: Ban
|
||||
default: false
|
||||
usage: /ban
|
||||
|
||||
Unban:
|
||||
description: Unban
|
||||
default: false
|
||||
usage: /unban
|
||||
|
||||
Kick:
|
||||
description: Kick
|
||||
default: false
|
||||
usage: /kick
|
||||
|
||||
Mute:
|
||||
description: Mute
|
||||
default: false
|
||||
usage: /mute
|
||||
|
||||
Unmute:
|
||||
description: Unmute
|
||||
default: false
|
||||
usage: /unmute
|
||||
|
||||
Warn:
|
||||
description: Warn
|
||||
default: false
|
||||
usage: /warn
|
||||
|
||||
RunTemplate:
|
||||
description: RunTemplate
|
||||
default: false
|
||||
usage: /runtemplate
|
||||
|
||||
Ticket:
|
||||
description: Ticket
|
||||
default: false
|
||||
aliases: [tickets]
|
||||
aliases: [ tickets ]
|
||||
usage: /ticket
|
||||
|
||||
StaffChat:
|
||||
description: StaffChat
|
||||
default: false
|
||||
aliases: [sc]
|
||||
aliases: [ sc ]
|
||||
usage: /staffchat
|
||||
|
||||
SlowMode:
|
||||
description: SlowMode
|
||||
default: false
|
||||
aliases: [sm]
|
||||
ussage: /slowmode
|
||||
aliases: [ sm ]
|
||||
ussage: /slowmode
|
||||
|
Loading…
Reference in New Issue
Block a user