Compare commits

...

9 Commits

Author SHA1 Message Date
Christian Koop e89fab45b6
pom.xml: Updates maven repos 2023-07-20 17:58:27 +02:00
Christian Koop c59bc9fbbd
Use XSound from CraftaroCore v3 instead of Bukkit's API 2023-07-20 17:45:39 +02:00
Christian Koop a7be9a968f
Migrate from SongodaCore to CraftaroCore v3.0.0-SNAPSHOT 2023-07-20 17:41:31 +02:00
Christian Koop fda115a751
Updates `.gitignore` 2023-07-20 17:32:55 +02:00
Christian Koop 6953fab6c4
Modernize and clean up `pom.xml` and `plugin.yml` 2023-07-20 17:32:55 +02:00
Christian Koop 52319a1e19
Creates `.editorconfig` 2023-07-20 17:32:55 +02:00
Christian Koop b55395bbab
Creates `.github/FUNDING.yml` 2023-07-20 17:32:55 +02:00
Christian Koop ab27ca52d3
Heavy code style changes and slight refactoring 2023-07-20 17:32:55 +02:00
craftaro-plugins-overview[bot] 9c011f1ccb
Updates contents of README.md (#2)
Co-authored-by: craftaro-plugins-overview[bot] <111250264+craftaro-plugins-overview[bot]@users.noreply.github.com>
2023-07-20 17:11:14 +02:00
76 changed files with 1210 additions and 1230 deletions

26
.editorconfig Normal file
View 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
View File

@ -0,0 +1 @@
custom: [ 'https://craftaro.to/+' ]

38
.gitignore vendored
View File

@ -1,34 +1,10 @@
# Compiled class file ## JetBrains IDEs
*.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/
/.idea/ /.idea/
/build/
/bin/
/target/
*.iml *.iml
src/\.DS_Store
\.DS_Store ## Maven
/**/target/
dependency-reduced-pom.xml
## Misc.
.DS_Store

View File

@ -1 +1,45 @@
<!--suppress HtmlDeprecatedAttribute -->
<div align="center">
<img src="https://craftaro.com/images/products/336/icons/uAFvXnRqNFuGG7gTkTj34CTn78854mummd4AtB1l.png" width="128px">
# UltimateModeration # UltimateModeration
**Take complete control over your server with punishment templates via a simplified yet powerful moderation system**
[![Discord][Discord shield]][Discord invite]
[![Patreon][Patreon shield]][Patreon page]
<br>
[![Latest version][Latest version shield]][Marketplace page]
[![bStats Servers][bStats shield]][bStats page]
</div>
## Download (Marketplace)
You can visit [our marketplace][Marketplace page] to download UltimateModeration as well as take a
look at many other fantastic plugins which are sure to catch your eye.
## Documentation
You can find all the information about UltimateModeration, including dependencies, commands, permissions and incompatible
plugins on [our wiki][Plugin wiki].
Feel free to also contribute to the wiki as a way to help others in the community with using the plugin.
## Support
If you encounter any issues while using the plugin, feel free to contact us on
[our Discord server][Discord invite].
## Suggestions
For suggestions about features you think should be added to the plugin to increase its functionality, feel free to
create a thread over on [our Discord server][Discord invite].
[Marketplace page]: https://craftaro.com/marketplace/product/29
[Plugin wiki]: https://wiki.craftaro.com/index.php/Ultimate_Moderation
[Patreon page]: https://www.patreon.com/join/songoda
[Discord invite]: https://discord.gg/craftaro
[bStats page]: https://bstats.org/plugin/bukkit/UltimateModeration/4346
[Patreon shield]: https://img.shields.io/badge/-Support_us_on_Patreon-F96854.svg?logo=patreon&style=flat&logoColor=white
[Discord shield]: https://img.shields.io/discord/293212540723396608?color=5865F2&label=Discord&logo=discord&logoColor=5865F2
[bStats shield]: https://img.shields.io/bstats/servers/4346?label=Servers
[Latest version shield]: https://img.shields.io/badge/dynamic/xml?style=flat&color=blue&logo=github&logoColor=white&label=Latest&url=https%3A%2F%2Fraw.githubusercontent.com%2Fcraftaro%2FUltimateModeration%2Fmaster%2Fpom.xml&query=%2F*%5Blocal-name()%3D'project'%5D%2F*%5Blocal-name()%3D'version'%5D

137
pom.xml
View File

@ -1,104 +1,104 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"> <?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>
<groupId>com.songoda</groupId> <groupId>com.songoda</groupId>
<artifactId>UltimateModeration</artifactId> <artifactId>UltimateModeration</artifactId>
<modelVersion>4.0.0</modelVersion>
<version>2.0.15</version> <version>2.0.15</version>
<build> <name>UltimateModeration</name>
<defaultGoal>clean install</defaultGoal> <description>Take complete control over your server with punishment templates via a simplified yet powerful moderation system</description>
<finalName>UltimateModeration-${project.version}</finalName> <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>
<plugins> <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> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId> <artifactId>maven-shade-plugin</artifactId>
<version>3.3.0</version> <version>3.4.1</version>
<executions> <executions>
<execution> <execution>
<id>shaded</id>
<phase>package</phase> <phase>package</phase>
<goals> <goals>
<goal>shade</goal> <goal>shade</goal>
</goals> </goals>
<configuration> <configuration>
<shadedArtifactAttached>false</shadedArtifactAttached> <finalName>${project.name}-${project.version}</finalName>
<createDependencyReducedPom>false</createDependencyReducedPom>
<artifactSet> <shadedArtifactAttached>false</shadedArtifactAttached>
<includes> <useDependencyReducedPomInJar>true</useDependencyReducedPomInJar>
<include>com.songoda:SongodaCore</include> <minimizeJar>true</minimizeJar>
</includes>
</artifactSet> <relocations>
<relocation>
<pattern>com.craftaro.core</pattern>
<shadedPattern>com.songoda.ultimatemoderation.core</shadedPattern>
</relocation>
</relocations>
<filters> <filters>
<filter> <filter>
<artifact>*:*</artifact> <artifact>*:*</artifact>
<excludes> <excludes>
<exclude>META-INF/*.SF</exclude> <exclude>META-INF/**</exclude>
<exclude>META-INF/*.DSA</exclude> <exclude>LICENSE</exclude>
<exclude>META-INF/*.RSA</exclude> <exclude>LICENSE.**</exclude>
</excludes> </excludes>
</filter> </filter>
</filters>
<relocations> <filter>
<relocation> <artifact>com.craftaro:CraftaroCore</artifact>
<pattern>com.songoda.core</pattern> <excludeDefaults>false</excludeDefaults>
<shadedPattern>${project.groupId}.ultimatemoderation.core</shadedPattern> <includes>
</relocation> <include>**/nms/v*/**</include>
</relocations> </includes>
</filter>
</filters>
</configuration> </configuration>
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
</plugins> </plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build> </build>
<repositories> <repositories>
<repository> <repository>
<id>songoda-public</id> <id>craftaro-minecraft-plugins</id>
<url>https://repo.songoda.com/repository/public/</url> <url>https://repo.craftaro.com/repository/minecraft-plugins/</url>
</repository> </repository>
<repository> <repository>
<id>spigotmc-repo</id> <id>SpigotMC</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url> <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository> </repository>
@ -106,13 +106,18 @@
<id>jitpack.io</id> <id>jitpack.io</id>
<url>https://jitpack.io/</url> <url>https://jitpack.io/</url>
</repository> </repository>
<repository>
<id>songoda-public</id>
<url>https://repo.craftaro.com/repository/public/</url>
</repository>
</repositories> </repositories>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.songoda</groupId> <groupId>com.craftaro</groupId>
<artifactId>SongodaCore</artifactId> <artifactId>CraftaroCore</artifactId>
<version>2.6.19</version> <version>3.0.0-SNAPSHOT</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>

View File

@ -1,20 +1,47 @@
package com.songoda.ultimatemoderation; package com.songoda.ultimatemoderation;
import com.songoda.core.SongodaCore; import com.craftaro.core.SongodaCore;
import com.songoda.core.SongodaPlugin; import com.craftaro.core.SongodaPlugin;
import com.songoda.core.commands.CommandManager; import com.craftaro.core.commands.CommandManager;
import com.songoda.core.compatibility.CompatibleMaterial; import com.craftaro.core.compatibility.ServerVersion;
import com.songoda.core.compatibility.ServerVersion; import com.craftaro.core.configuration.Config;
import com.songoda.core.configuration.Config; import com.craftaro.core.database.DataMigrationManager;
import com.songoda.core.database.DataMigrationManager; import com.craftaro.core.database.DatabaseConnector;
import com.songoda.core.database.DatabaseConnector; import com.craftaro.core.database.MySQLConnector;
import com.songoda.core.database.MySQLConnector; import com.craftaro.core.database.SQLiteConnector;
import com.songoda.core.database.SQLiteConnector; import com.craftaro.core.gui.GuiManager;
import com.songoda.core.gui.GuiManager; import com.craftaro.core.third_party.com.cryptomorin.xseries.XMaterial;
import com.songoda.ultimatemoderation.commands.*; import com.songoda.ultimatemoderation.commands.CommandBan;
import com.songoda.ultimatemoderation.commands.CommandClearChat;
import com.songoda.ultimatemoderation.commands.CommandHelp;
import com.songoda.ultimatemoderation.commands.CommandKick;
import com.songoda.ultimatemoderation.commands.CommandMute;
import com.songoda.ultimatemoderation.commands.CommandRandomPlayer;
import com.songoda.ultimatemoderation.commands.CommandReload;
import com.songoda.ultimatemoderation.commands.CommandRunTemplate;
import com.songoda.ultimatemoderation.commands.CommandSettings;
import com.songoda.ultimatemoderation.commands.CommandSlowMode;
import com.songoda.ultimatemoderation.commands.CommandStaffChat;
import com.songoda.ultimatemoderation.commands.CommandTicket;
import com.songoda.ultimatemoderation.commands.CommandToggleChat;
import com.songoda.ultimatemoderation.commands.CommandUltimateModeration;
import com.songoda.ultimatemoderation.commands.CommandUnBan;
import com.songoda.ultimatemoderation.commands.CommandUnMute;
import com.songoda.ultimatemoderation.commands.CommandVanish;
import com.songoda.ultimatemoderation.commands.CommandWarn;
import com.songoda.ultimatemoderation.database.DataManager; import com.songoda.ultimatemoderation.database.DataManager;
import com.songoda.ultimatemoderation.database.migrations._1_InitialMigration; import com.songoda.ultimatemoderation.database.migrations._1_InitialMigration;
import com.songoda.ultimatemoderation.listeners.*; import com.songoda.ultimatemoderation.listeners.BlockListener;
import com.songoda.ultimatemoderation.listeners.ChatListener;
import com.songoda.ultimatemoderation.listeners.CommandListener;
import com.songoda.ultimatemoderation.listeners.DeathListener;
import com.songoda.ultimatemoderation.listeners.DropListener;
import com.songoda.ultimatemoderation.listeners.InventoryListener;
import com.songoda.ultimatemoderation.listeners.LoginListener;
import com.songoda.ultimatemoderation.listeners.MobTargetLister;
import com.songoda.ultimatemoderation.listeners.MoveListener;
import com.songoda.ultimatemoderation.listeners.SkyBlockListener;
import com.songoda.ultimatemoderation.listeners.SpyingDismountListener;
import com.songoda.ultimatemoderation.moderate.ModerationManager; import com.songoda.ultimatemoderation.moderate.ModerationManager;
import com.songoda.ultimatemoderation.punish.AppliedPunishment; import com.songoda.ultimatemoderation.punish.AppliedPunishment;
import com.songoda.ultimatemoderation.punish.PunishmentNote; import com.songoda.ultimatemoderation.punish.PunishmentNote;
@ -28,12 +55,11 @@ import com.songoda.ultimatemoderation.tickets.Ticket;
import com.songoda.ultimatemoderation.tickets.TicketManager; import com.songoda.ultimatemoderation.tickets.TicketManager;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.List; import java.util.List;
public class UltimateModeration extends SongodaPlugin { public class UltimateModeration extends SongodaPlugin {
private static UltimateModeration INSTANCE;
private final GuiManager guiManager = new GuiManager(this); private final GuiManager guiManager = new GuiManager(this);
private TicketManager ticketManager; private TicketManager ticketManager;
private TemplateManager templateManager; private TemplateManager templateManager;
@ -45,13 +71,16 @@ public class UltimateModeration extends SongodaPlugin {
private DatabaseConnector databaseConnector; private DatabaseConnector databaseConnector;
private DataManager dataManager; private DataManager dataManager;
/**
* @deprecated Use {@link JavaPlugin#getPlugin(Class)} instead.
*/
@Deprecated
public static UltimateModeration getInstance() { public static UltimateModeration getInstance() {
return INSTANCE; return getPlugin(UltimateModeration.class);
} }
@Override @Override
public void onPluginLoad() { public void onPluginLoad() {
INSTANCE = this;
} }
@Override @Override
@ -61,7 +90,7 @@ public class UltimateModeration extends SongodaPlugin {
@Override @Override
public void onPluginEnable() { public void onPluginEnable() {
// Run Songoda Updater // Run Songoda Updater
SongodaCore.registerPlugin(this, 29, CompatibleMaterial.DIAMOND_CHESTPLATE); SongodaCore.registerPlugin(this, 29, XMaterial.DIAMOND_CHESTPLATE);
// Setup Config // Setup Config
Settings.setupConfig(); Settings.setupConfig();
@ -72,7 +101,7 @@ public class UltimateModeration extends SongodaPlugin {
this.commandManager.addCommand(new CommandUltimateModeration(this)) this.commandManager.addCommand(new CommandUltimateModeration(this))
.addSubCommands( .addSubCommands(
new CommandReload(this), new CommandReload(this),
new CommandSettings(this, guiManager), new CommandSettings(this, this.guiManager),
new CommandHelp(this) new CommandHelp(this)
); );
this.commandManager.addCommand(new CommandBan(this)); this.commandManager.addCommand(new CommandBan(this));
@ -83,7 +112,7 @@ public class UltimateModeration extends SongodaPlugin {
this.commandManager.addCommand(new CommandRunTemplate(this)); this.commandManager.addCommand(new CommandRunTemplate(this));
this.commandManager.addCommand(new CommandSlowMode(this)); this.commandManager.addCommand(new CommandSlowMode(this));
this.commandManager.addCommand(new CommandStaffChat(this)); this.commandManager.addCommand(new CommandStaffChat(this));
this.commandManager.addCommand(new CommandTicket(this, guiManager)); this.commandManager.addCommand(new CommandTicket(this, this.guiManager));
this.commandManager.addCommand(new CommandToggleChat(this)); this.commandManager.addCommand(new CommandToggleChat(this));
this.commandManager.addCommand(new CommandUnBan(this)); this.commandManager.addCommand(new CommandUnBan(this));
this.commandManager.addCommand(new CommandUnMute(this)); this.commandManager.addCommand(new CommandUnMute(this));
@ -116,8 +145,7 @@ public class UltimateModeration extends SongodaPlugin {
} }
this.dataManager = new DataManager(this.databaseConnector, this); this.dataManager = new DataManager(this.databaseConnector, this);
DataMigrationManager dataMigrationManager = new DataMigrationManager(this.databaseConnector, this.dataManager, DataMigrationManager dataMigrationManager = new DataMigrationManager(this.databaseConnector, this.dataManager, new _1_InitialMigration(this));
new _1_InitialMigration());
dataMigrationManager.runMigrations(); dataMigrationManager.runMigrations();
} catch (Exception ex) { } catch (Exception ex) {
@ -128,10 +156,10 @@ public class UltimateModeration extends SongodaPlugin {
} }
// Register Listeners // Register Listeners
guiManager.init(); this.guiManager.init();
PluginManager pluginManager = Bukkit.getPluginManager(); PluginManager pluginManager = Bukkit.getPluginManager();
pluginManager.registerEvents(new CommandListener(this), this); pluginManager.registerEvents(new CommandListener(this), this);
pluginManager.registerEvents(new DeathListener(this), this); pluginManager.registerEvents(new DeathListener(), this);
pluginManager.registerEvents(new MoveListener(this), this); pluginManager.registerEvents(new MoveListener(this), this);
pluginManager.registerEvents(new DropListener(this), this); pluginManager.registerEvents(new DropListener(this), this);
pluginManager.registerEvents(new InventoryListener(this), this); pluginManager.registerEvents(new InventoryListener(this), this);
@ -139,11 +167,13 @@ public class UltimateModeration extends SongodaPlugin {
pluginManager.registerEvents(new LoginListener(this), this); pluginManager.registerEvents(new LoginListener(this), this);
pluginManager.registerEvents(new MobTargetLister(), this); pluginManager.registerEvents(new MobTargetLister(), this);
pluginManager.registerEvents(new BlockListener(this), this); pluginManager.registerEvents(new BlockListener(this), this);
if (pluginManager.isPluginEnabled("FabledSkyBlock")) if (pluginManager.isPluginEnabled("FabledSkyBlock")) {
pluginManager.registerEvents(new SkyBlockListener(this), this); pluginManager.registerEvents(new SkyBlockListener(), this);
}
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) {
pluginManager.registerEvents(new SpyingDismountListener(), this); pluginManager.registerEvents(new SpyingDismountListener(this), this);
}
// Start tasks // Start tasks
SlowModeTask.startTask(this); SlowModeTask.startTask(this);
@ -159,16 +189,19 @@ public class UltimateModeration extends SongodaPlugin {
} }
}); });
this.dataManager.getAppliedPunishments((appliedPunishments) -> { this.dataManager.getAppliedPunishments((appliedPunishments) -> {
for (AppliedPunishment punishment : appliedPunishments) for (AppliedPunishment punishment : appliedPunishments) {
this.punishmentManager.getPlayer(punishment.getVictim()).addPunishment(punishment); this.punishmentManager.getPlayer(punishment.getVictim()).addPunishment(punishment);
}
}); });
this.dataManager.getNotes((notes) -> { this.dataManager.getNotes((notes) -> {
for (PunishmentNote note : notes) for (PunishmentNote note : notes) {
this.punishmentManager.getPlayer(note.getSubject()).addNotes(note); this.punishmentManager.getPlayer(note.getSubject()).addNotes(note);
}
}); });
this.dataManager.getTickets((tickets) -> { this.dataManager.getTickets((tickets) -> {
for (Ticket ticket : tickets.values()) for (Ticket ticket : tickets.values()) {
this.ticketManager.addTicket(ticket); this.ticketManager.addTicket(ticket);
}
}); });
}); });
} }
@ -185,38 +218,38 @@ public class UltimateModeration extends SongodaPlugin {
} }
public CommandManager getCommandManager() { public CommandManager getCommandManager() {
return commandManager; return this.commandManager;
} }
public TemplateManager getTemplateManager() { public TemplateManager getTemplateManager() {
return templateManager; return this.templateManager;
} }
public PunishmentManager getPunishmentManager() { public PunishmentManager getPunishmentManager() {
return punishmentManager; return this.punishmentManager;
} }
public TicketManager getTicketManager() { public TicketManager getTicketManager() {
return ticketManager; return this.ticketManager;
} }
public StaffChatManager getStaffChatManager() { public StaffChatManager getStaffChatManager() {
return staffChatManager; return this.staffChatManager;
} }
public DataManager getDataManager() { public DataManager getDataManager() {
return dataManager; return this.dataManager;
} }
public DatabaseConnector getDatabaseConnector() { public DatabaseConnector getDatabaseConnector() {
return databaseConnector; return this.databaseConnector;
} }
public GuiManager getGuiManager() { public GuiManager getGuiManager() {
return guiManager; return this.guiManager;
} }
public ModerationManager getModerationManager() { public ModerationManager getModerationManager() {
return moderationManager; return this.moderationManager;
} }
} }

View File

@ -1,10 +1,10 @@
package com.songoda.ultimatemoderation.commands; package com.songoda.ultimatemoderation.commands;
import com.songoda.core.commands.AbstractCommand; import com.craftaro.core.commands.AbstractCommand;
import com.craftaro.core.utils.TimeUtils;
import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.UltimateModeration;
import com.songoda.ultimatemoderation.punish.Punishment; import com.songoda.ultimatemoderation.punish.Punishment;
import com.songoda.ultimatemoderation.punish.PunishmentType; import com.songoda.ultimatemoderation.punish.PunishmentType;
import com.songoda.ultimatemoderation.utils.Methods;
import com.songoda.ultimatemoderation.utils.VaultPermissions; import com.songoda.ultimatemoderation.utils.VaultPermissions;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
@ -17,7 +17,6 @@ import java.util.Collections;
import java.util.List; import java.util.List;
public class CommandBan extends AbstractCommand { public class CommandBan extends AbstractCommand {
private final UltimateModeration plugin; private final UltimateModeration plugin;
public CommandBan(UltimateModeration plugin) { public CommandBan(UltimateModeration plugin) {
@ -27,21 +26,23 @@ public class CommandBan extends AbstractCommand {
@Override @Override
protected ReturnType runCommand(CommandSender sender, String... args) { protected ReturnType runCommand(CommandSender sender, String... args) {
if (args.length < 1) if (args.length < 1) {
return ReturnType.SYNTAX_ERROR; 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". // they can't ban someone for the reason "Stole me 2h sword"
long duration = 0; long duration = 0;
StringBuilder reasonBuilder = new StringBuilder(); StringBuilder reasonBuilder = new StringBuilder();
if (args.length > 1) { if (args.length > 1) {
for (int i = 1; i < args.length; i++) { for (int i = 1; i < args.length; i++) {
String line = args[i]; String line = args[i];
long time = Methods.parseTime(line); long time = TimeUtils.parseTime(line);
if (time != 0) if (time != 0) {
duration += time; duration += time;
else } else {
reasonBuilder.append(line).append(" "); reasonBuilder.append(line).append(" ");
}
} }
} }
@ -49,21 +50,21 @@ public class CommandBan extends AbstractCommand {
OfflinePlayer player = Bukkit.getOfflinePlayer(args[0]); 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)) { .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; return ReturnType.FAILURE;
} }
if (duration == 0 && !sender.hasPermission("um.ban.permanent")) { 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; return ReturnType.FAILURE;
} }
long durationFinal = duration; long durationFinal = duration;
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> {
if (sender instanceof Player && VaultPermissions.hasPermission(player, "um.ban.exempt")) { 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; return;
} }

View File

@ -1,6 +1,6 @@
package com.songoda.ultimatemoderation.commands; package com.songoda.ultimatemoderation.commands;
import com.songoda.core.commands.AbstractCommand; import com.craftaro.core.commands.AbstractCommand;
import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.UltimateModeration;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -11,7 +11,6 @@ import java.util.Collections;
import java.util.List; import java.util.List;
public class CommandClearChat extends AbstractCommand { public class CommandClearChat extends AbstractCommand {
private final UltimateModeration plugin; private final UltimateModeration plugin;
public CommandClearChat(UltimateModeration plugin) { public CommandClearChat(UltimateModeration plugin) {
@ -21,9 +20,9 @@ public class CommandClearChat extends AbstractCommand {
@Override @Override
protected ReturnType runCommand(CommandSender sender, String... args) { 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; return ReturnType.SYNTAX_ERROR;
}
for (Player player : Bukkit.getOnlinePlayers()) { for (Player player : Bukkit.getOnlinePlayers()) {
if (!player.hasPermission("um.clearchat.bypass") || isForced(args)) { if (!player.hasPermission("um.clearchat.bypass") || isForced(args)) {
@ -32,13 +31,14 @@ public class CommandClearChat extends AbstractCommand {
player.sendMessage(toSend); player.sendMessage(toSend);
} }
plugin.getLocale().getMessage("command.clearchat.cleared") this.plugin.getLocale().getMessage("command.clearchat.cleared")
.processPlaceholder("player", sender.getName()).sendPrefixedMessage(player); .processPlaceholder("player", sender.getName()).sendPrefixedMessage(player);
if (player.hasPermission("um.clearchat.bypass") && !isForced(args)) { 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; return ReturnType.SUCCESS;
} }

View File

@ -1,14 +1,13 @@
package com.songoda.ultimatemoderation.commands; package com.songoda.ultimatemoderation.commands;
import com.songoda.core.commands.AbstractCommand; import com.craftaro.core.commands.AbstractCommand;
import com.craftaro.core.utils.TextUtils;
import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.UltimateModeration;
import com.songoda.ultimatemoderation.utils.Methods;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import java.util.List; import java.util.List;
public class CommandHelp extends AbstractCommand { public class CommandHelp extends AbstractCommand {
private final UltimateModeration plugin; private final UltimateModeration plugin;
public CommandHelp(UltimateModeration plugin) { public CommandHelp(UltimateModeration plugin) {
@ -19,15 +18,15 @@ public class CommandHelp extends AbstractCommand {
@Override @Override
protected ReturnType runCommand(CommandSender sender, String... args) { protected ReturnType runCommand(CommandSender sender, String... args) {
sender.sendMessage(""); 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); .sendPrefixedMessage(sender);
sender.sendMessage(""); 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("");
sender.sendMessage(Methods.formatText("&6Commands:")); sender.sendMessage(TextUtils.formatText("&6Commands:"));
for (AbstractCommand command : plugin.getCommandManager().getAllCommands()) { for (AbstractCommand command : this.plugin.getCommandManager().getAllCommands()) {
if (command.getPermissionNode() == null || sender.hasPermission(command.getPermissionNode())) { 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(""); sender.sendMessage("");

View File

@ -1,6 +1,6 @@
package com.songoda.ultimatemoderation.commands; package com.songoda.ultimatemoderation.commands;
import com.songoda.core.commands.AbstractCommand; import com.craftaro.core.commands.AbstractCommand;
import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.UltimateModeration;
import com.songoda.ultimatemoderation.punish.Punishment; import com.songoda.ultimatemoderation.punish.Punishment;
import com.songoda.ultimatemoderation.punish.PunishmentType; import com.songoda.ultimatemoderation.punish.PunishmentType;
@ -14,7 +14,6 @@ import java.util.Collections;
import java.util.List; import java.util.List;
public class CommandKick extends AbstractCommand { public class CommandKick extends AbstractCommand {
private final UltimateModeration plugin; private final UltimateModeration plugin;
public CommandKick(UltimateModeration plugin) { public CommandKick(UltimateModeration plugin) {
@ -24,8 +23,9 @@ public class CommandKick extends AbstractCommand {
@Override @Override
protected ReturnType runCommand(CommandSender sender, String... args) { protected ReturnType runCommand(CommandSender sender, String... args) {
if (args.length < 1) if (args.length < 1) {
return ReturnType.SYNTAX_ERROR; return ReturnType.SYNTAX_ERROR;
}
StringBuilder reasonBuilder = new StringBuilder(); StringBuilder reasonBuilder = new StringBuilder();
if (args.length > 1) { if (args.length > 1) {
@ -40,7 +40,7 @@ public class CommandKick extends AbstractCommand {
OfflinePlayer player = Bukkit.getPlayer(args[0]); OfflinePlayer player = Bukkit.getPlayer(args[0]);
if (sender instanceof Player && player.getPlayer().hasPermission("um.kick.exempt")) { 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; return ReturnType.FAILURE;
} }

View File

@ -1,10 +1,10 @@
package com.songoda.ultimatemoderation.commands; package com.songoda.ultimatemoderation.commands;
import com.songoda.core.commands.AbstractCommand; import com.craftaro.core.commands.AbstractCommand;
import com.craftaro.core.utils.TimeUtils;
import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.UltimateModeration;
import com.songoda.ultimatemoderation.punish.Punishment; import com.songoda.ultimatemoderation.punish.Punishment;
import com.songoda.ultimatemoderation.punish.PunishmentType; import com.songoda.ultimatemoderation.punish.PunishmentType;
import com.songoda.ultimatemoderation.utils.Methods;
import com.songoda.ultimatemoderation.utils.VaultPermissions; import com.songoda.ultimatemoderation.utils.VaultPermissions;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
@ -17,7 +17,6 @@ import java.util.Collections;
import java.util.List; import java.util.List;
public class CommandMute extends AbstractCommand { public class CommandMute extends AbstractCommand {
private final UltimateModeration plugin; private final UltimateModeration plugin;
public CommandMute(UltimateModeration plugin) { public CommandMute(UltimateModeration plugin) {
@ -27,21 +26,23 @@ public class CommandMute extends AbstractCommand {
@Override @Override
protected ReturnType runCommand(CommandSender sender, String... args) { protected ReturnType runCommand(CommandSender sender, String... args) {
if (args.length < 1) if (args.length < 1) {
return ReturnType.SYNTAX_ERROR; 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". // they can't ban someone for the reason "Stole me 2h sword".
long duration = 0; long duration = 0;
StringBuilder reasonBuilder = new StringBuilder(); StringBuilder reasonBuilder = new StringBuilder();
if (args.length > 1) { if (args.length > 1) {
for (int i = 1; i < args.length; i++) { for (int i = 1; i < args.length; i++) {
String line = args[i]; String line = args[i];
long time = Methods.parseTime(line); long time = TimeUtils.parseTime(line);
if (time != 0) if (time != 0) {
duration += time; duration += time;
else } else {
reasonBuilder.append(line).append(" "); reasonBuilder.append(line).append(" ");
}
} }
} }
@ -50,13 +51,13 @@ public class CommandMute extends AbstractCommand {
OfflinePlayer player = Bukkit.getOfflinePlayer(args[0]); OfflinePlayer player = Bukkit.getOfflinePlayer(args[0]);
if (sender instanceof Player && VaultPermissions.hasPermission(player, "um.mute.exempt")) { 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; return ReturnType.FAILURE;
} }
if (plugin.getPunishmentManager().getPlayer(player).getActivePunishments() if (this.plugin.getPunishmentManager().getPlayer(player).getActivePunishments()
.stream().anyMatch(appliedPunishment -> appliedPunishment.getPunishmentType() == PunishmentType.MUTE)) { .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; return ReturnType.FAILURE;
} }

View File

@ -1,6 +1,6 @@
package com.songoda.ultimatemoderation.commands; package com.songoda.ultimatemoderation.commands;
import com.songoda.core.commands.AbstractCommand; import com.craftaro.core.commands.AbstractCommand;
import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.UltimateModeration;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -11,7 +11,6 @@ import java.util.Collections;
import java.util.List; import java.util.List;
public class CommandRandomPlayer extends AbstractCommand { public class CommandRandomPlayer extends AbstractCommand {
private final UltimateModeration plugin; private final UltimateModeration plugin;
public CommandRandomPlayer(UltimateModeration plugin) { public CommandRandomPlayer(UltimateModeration plugin) {
@ -26,7 +25,7 @@ public class CommandRandomPlayer extends AbstractCommand {
players.remove(sender); players.remove(sender);
if (players.size() == 0) { 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; return ReturnType.FAILURE;
} }

View File

@ -1,13 +1,12 @@
package com.songoda.ultimatemoderation.commands; package com.songoda.ultimatemoderation.commands;
import com.songoda.core.commands.AbstractCommand; import com.craftaro.core.commands.AbstractCommand;
import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.UltimateModeration;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import java.util.List; import java.util.List;
public class CommandReload extends AbstractCommand { public class CommandReload extends AbstractCommand {
private final UltimateModeration plugin; private final UltimateModeration plugin;
public CommandReload(UltimateModeration plugin) { public CommandReload(UltimateModeration plugin) {
@ -17,8 +16,8 @@ public class CommandReload extends AbstractCommand {
@Override @Override
protected ReturnType runCommand(CommandSender sender, String... args) { protected ReturnType runCommand(CommandSender sender, String... args) {
plugin.reloadConfig(); this.plugin.reloadConfig();
plugin.getLocale().newMessage("&7Configuration and Language files reloaded.").sendPrefixedMessage(sender); this.plugin.getLocale().newMessage("&7Configuration and Language files reloaded.").sendPrefixedMessage(sender);
return ReturnType.SUCCESS; return ReturnType.SUCCESS;
} }

View File

@ -1,6 +1,6 @@
package com.songoda.ultimatemoderation.commands; package com.songoda.ultimatemoderation.commands;
import com.songoda.core.commands.AbstractCommand; import com.craftaro.core.commands.AbstractCommand;
import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.UltimateModeration;
import com.songoda.ultimatemoderation.punish.template.Template; import com.songoda.ultimatemoderation.punish.template.Template;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -12,7 +12,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
public class CommandRunTemplate extends AbstractCommand { public class CommandRunTemplate extends AbstractCommand {
private final UltimateModeration plugin; private final UltimateModeration plugin;
public CommandRunTemplate(UltimateModeration plugin) { public CommandRunTemplate(UltimateModeration plugin) {
@ -34,7 +33,7 @@ public class CommandRunTemplate extends AbstractCommand {
} }
String templateStr = templateBuilder.toString().trim(); String templateStr = templateBuilder.toString().trim();
Template template = plugin.getTemplateManager().getTemplate(templateStr); Template template = this.plugin.getTemplateManager().getTemplate(templateStr);
if (template == null) { if (template == null) {
sender.sendMessage("That template does not exist..."); sender.sendMessage("That template does not exist...");
@ -56,7 +55,7 @@ public class CommandRunTemplate extends AbstractCommand {
return players; return players;
} else if (args.length == 2) { } else if (args.length == 2) {
List<String> lines = new ArrayList<>(); List<String> lines = new ArrayList<>();
for (Template template : plugin.getTemplateManager().getTemplates()) { for (Template template : this.plugin.getTemplateManager().getTemplates()) {
lines.add(template.getName()); lines.add(template.getName());
} }
} }

View File

@ -1,8 +1,8 @@
package com.songoda.ultimatemoderation.commands; package com.songoda.ultimatemoderation.commands;
import com.songoda.core.commands.AbstractCommand; import com.craftaro.core.commands.AbstractCommand;
import com.songoda.core.configuration.editor.PluginConfigGui; import com.craftaro.core.configuration.editor.PluginConfigGui;
import com.songoda.core.gui.GuiManager; import com.craftaro.core.gui.GuiManager;
import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.UltimateModeration;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -10,7 +10,6 @@ import org.bukkit.entity.Player;
import java.util.List; import java.util.List;
public class CommandSettings extends AbstractCommand { public class CommandSettings extends AbstractCommand {
private final UltimateModeration plugin; private final UltimateModeration plugin;
private final GuiManager guiManager; private final GuiManager guiManager;
@ -22,8 +21,7 @@ public class CommandSettings extends AbstractCommand {
@Override @Override
protected ReturnType runCommand(CommandSender sender, String... args) { protected ReturnType runCommand(CommandSender sender, String... args) {
Player player = (Player) sender; this.guiManager.showGUI((Player) sender, new PluginConfigGui(this.plugin));
guiManager.showGUI((Player) sender, new PluginConfigGui(plugin));
return ReturnType.SUCCESS; return ReturnType.SUCCESS;
} }

View File

@ -1,9 +1,9 @@
package com.songoda.ultimatemoderation.commands; package com.songoda.ultimatemoderation.commands;
import com.songoda.core.commands.AbstractCommand; import com.craftaro.core.commands.AbstractCommand;
import com.craftaro.core.utils.TimeUtils;
import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.UltimateModeration;
import com.songoda.ultimatemoderation.listeners.ChatListener; import com.songoda.ultimatemoderation.listeners.ChatListener;
import com.songoda.ultimatemoderation.utils.Methods;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -12,7 +12,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
public class CommandSlowMode extends AbstractCommand { public class CommandSlowMode extends AbstractCommand {
private final UltimateModeration plugin; private final UltimateModeration plugin;
public CommandSlowMode(UltimateModeration plugin) { public CommandSlowMode(UltimateModeration plugin) {
@ -24,18 +23,19 @@ public class CommandSlowMode extends AbstractCommand {
protected ReturnType runCommand(CommandSender sender, String... args) { protected ReturnType runCommand(CommandSender sender, String... args) {
if (args.length == 0) { if (args.length == 0) {
ChatListener.setSlowModeOverride(0); ChatListener.setSlowModeOverride(0);
plugin.getLocale().getMessage("event.slowmode.disabled").sendPrefixedMessage(sender); this.plugin.getLocale().getMessage("event.slowmode.disabled").sendPrefixedMessage(sender);
return ReturnType.SUCCESS; return ReturnType.SUCCESS;
} else if (args.length != 1) } else if (args.length != 1) {
return ReturnType.SYNTAX_ERROR; return ReturnType.SYNTAX_ERROR;
}
long delay = Methods.parseTime(args[0]); long delay = TimeUtils.parseTime(args[0]);
ChatListener.setSlowModeOverride(delay); ChatListener.setSlowModeOverride(delay);
Bukkit.getOnlinePlayers().forEach(player -> Bukkit.getOnlinePlayers().forEach(player ->
plugin.getLocale().getMessage("event.slowmode.enabled") this.plugin.getLocale().getMessage("event.slowmode.enabled")
.processPlaceholder("delay", Methods.makeReadable(delay)).sendPrefixedMessage(player)); .processPlaceholder("delay", TimeUtils.makeReadable(delay)).sendPrefixedMessage(player));
return ReturnType.SUCCESS; return ReturnType.SUCCESS;
} }

View File

@ -1,6 +1,6 @@
package com.songoda.ultimatemoderation.commands; package com.songoda.ultimatemoderation.commands;
import com.songoda.core.commands.AbstractCommand; import com.craftaro.core.commands.AbstractCommand;
import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.UltimateModeration;
import com.songoda.ultimatemoderation.staffchat.StaffChannel; import com.songoda.ultimatemoderation.staffchat.StaffChannel;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -10,7 +10,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
public class CommandStaffChat extends AbstractCommand { public class CommandStaffChat extends AbstractCommand {
private final UltimateModeration plugin; private final UltimateModeration plugin;
public CommandStaffChat(UltimateModeration plugin) { public CommandStaffChat(UltimateModeration plugin) {
@ -20,33 +19,36 @@ public class CommandStaffChat extends AbstractCommand {
@Override @Override
protected ReturnType runCommand(CommandSender sender, String... args) { protected ReturnType runCommand(CommandSender sender, String... args) {
if (args.length != 1) if (args.length != 1) {
return ReturnType.SYNTAX_ERROR; return ReturnType.SYNTAX_ERROR;
}
String channelName = args[0]; String channelName = args[0];
Player player = (Player) sender; Player player = (Player) sender;
if (channelName.trim().equalsIgnoreCase("leave")) { if (channelName.trim().equalsIgnoreCase("leave")) {
for (StaffChannel channel : plugin.getStaffChatManager().getChats().values()) { for (StaffChannel channel : this.plugin.getStaffChatManager().getChats().values()) {
if (!channel.listMembers().contains(player.getUniqueId())) continue; if (!channel.listMembers().contains(player.getUniqueId())) {
continue;
}
channel.removeMember(player); channel.removeMember(player);
plugin.getLocale().getMessage("event.staffchat.leave") this.plugin.getLocale().getMessage("event.staffchat.leave")
.processPlaceholder("channel", channel.getChannelName()).sendPrefixedMessage(player); .processPlaceholder("channel", channel.getChannelName()).sendPrefixedMessage(player);
return ReturnType.SUCCESS; return ReturnType.SUCCESS;
} }
plugin.getLocale().getMessage("event.staffchat.nochannels").sendPrefixedMessage(player); this.plugin.getLocale().getMessage("event.staffchat.nochannels").sendPrefixedMessage(player);
return ReturnType.FAILURE; return ReturnType.FAILURE;
} }
plugin.getLocale().getMessage("event.staffchat.join") this.plugin.getLocale().getMessage("event.staffchat.join")
.processPlaceholder("channel", channelName).sendPrefixedMessage(player); .processPlaceholder("channel", channelName).sendPrefixedMessage(player);
plugin.getStaffChatManager().getChat(channelName).addMember(player); this.plugin.getStaffChatManager().getChat(channelName).addMember(player);
return ReturnType.SUCCESS; return ReturnType.SUCCESS;
} }
@Override @Override
protected List<String> onTab(CommandSender sender, String... args) { protected List<String> onTab(CommandSender sender, String... args) {
return new ArrayList<>(plugin.getStaffChatManager().getChats().keySet()); return new ArrayList<>(this.plugin.getStaffChatManager().getChats().keySet());
} }
@Override @Override

View File

@ -1,7 +1,7 @@
package com.songoda.ultimatemoderation.commands; package com.songoda.ultimatemoderation.commands;
import com.songoda.core.commands.AbstractCommand; import com.craftaro.core.commands.AbstractCommand;
import com.songoda.core.gui.GuiManager; import com.craftaro.core.gui.GuiManager;
import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.UltimateModeration;
import com.songoda.ultimatemoderation.gui.TicketManagerGui; import com.songoda.ultimatemoderation.gui.TicketManagerGui;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -10,7 +10,6 @@ import org.bukkit.entity.Player;
import java.util.List; import java.util.List;
public class CommandTicket extends AbstractCommand { public class CommandTicket extends AbstractCommand {
private final UltimateModeration plugin; private final UltimateModeration plugin;
private final GuiManager guiManager; private final GuiManager guiManager;
@ -23,7 +22,7 @@ public class CommandTicket extends AbstractCommand {
@Override @Override
protected ReturnType runCommand(CommandSender sender, String... args) { protected ReturnType runCommand(CommandSender sender, String... args) {
Player senderP = ((Player) sender); 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; return ReturnType.SUCCESS;
} }
@ -46,5 +45,4 @@ public class CommandTicket extends AbstractCommand {
public String getDescription() { public String getDescription() {
return "Opens the ticket interface."; return "Opens the ticket interface.";
} }
} }

View File

@ -1,7 +1,7 @@
package com.songoda.ultimatemoderation.commands; package com.songoda.ultimatemoderation.commands;
import com.songoda.core.commands.AbstractCommand; import com.craftaro.core.commands.AbstractCommand;
import com.songoda.core.locale.Message; import com.craftaro.core.locale.Message;
import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.UltimateModeration;
import com.songoda.ultimatemoderation.listeners.ChatListener; import com.songoda.ultimatemoderation.listeners.ChatListener;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -11,7 +11,6 @@ import org.bukkit.entity.Player;
import java.util.List; import java.util.List;
public class CommandToggleChat extends AbstractCommand { public class CommandToggleChat extends AbstractCommand {
private final UltimateModeration plugin; private final UltimateModeration plugin;
/* /*
@ -26,25 +25,25 @@ public class CommandToggleChat extends AbstractCommand {
@Override @Override
protected ReturnType runCommand(CommandSender sender, String... args) { protected ReturnType runCommand(CommandSender sender, String... args) {
toggled = !toggled; this.toggled = !this.toggled;
Message message = toggled ? plugin.getLocale().getMessage("command.togglechat.toggledOn") Message message = this.toggled ? this.plugin.getLocale().getMessage("command.togglechat.toggledOn")
: plugin.getLocale().getMessage("command.togglechat.toggledOff"); : this.plugin.getLocale().getMessage("command.togglechat.toggledOff");
ChatListener.setChatToggled(toggled); ChatListener.setChatToggled(this.toggled);
for (Player player : Bukkit.getOnlinePlayers()) { for (Player player : Bukkit.getOnlinePlayers()) {
message.sendPrefixedMessage(player); message.sendPrefixedMessage(player);
if (!player.hasPermission(getPermissionNode() + ".bypass")) if (!player.hasPermission(getPermissionNode() + ".bypass")) {
continue; 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); message.sendPrefixedMessage(sender);
}
return ReturnType.SUCCESS; return ReturnType.SUCCESS;
} }

View File

@ -1,6 +1,6 @@
package com.songoda.ultimatemoderation.commands; package com.songoda.ultimatemoderation.commands;
import com.songoda.core.commands.AbstractCommand; import com.craftaro.core.commands.AbstractCommand;
import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.UltimateModeration;
import com.songoda.ultimatemoderation.gui.MainGui; import com.songoda.ultimatemoderation.gui.MainGui;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -9,7 +9,6 @@ import org.bukkit.entity.Player;
import java.util.List; import java.util.List;
public class CommandUltimateModeration extends AbstractCommand { public class CommandUltimateModeration extends AbstractCommand {
private final UltimateModeration plugin; private final UltimateModeration plugin;
public CommandUltimateModeration(UltimateModeration plugin) { public CommandUltimateModeration(UltimateModeration plugin) {
@ -19,7 +18,7 @@ public class CommandUltimateModeration extends AbstractCommand {
@Override @Override
protected ReturnType runCommand(CommandSender sender, String... args) { 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; return ReturnType.SUCCESS;
} }

View File

@ -1,6 +1,6 @@
package com.songoda.ultimatemoderation.commands; package com.songoda.ultimatemoderation.commands;
import com.songoda.core.commands.AbstractCommand; import com.craftaro.core.commands.AbstractCommand;
import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.UltimateModeration;
import com.songoda.ultimatemoderation.punish.PunishmentType; import com.songoda.ultimatemoderation.punish.PunishmentType;
import com.songoda.ultimatemoderation.punish.player.PlayerPunishData; import com.songoda.ultimatemoderation.punish.player.PlayerPunishData;
@ -13,7 +13,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
public class CommandUnBan extends AbstractCommand { public class CommandUnBan extends AbstractCommand {
private final UltimateModeration plugin; private final UltimateModeration plugin;
public CommandUnBan(UltimateModeration plugin) { public CommandUnBan(UltimateModeration plugin) {
@ -23,22 +22,23 @@ public class CommandUnBan extends AbstractCommand {
@Override @Override
protected ReturnType runCommand(CommandSender sender, String... args) { protected ReturnType runCommand(CommandSender sender, String... args) {
if (args.length != 1) if (args.length != 1) {
return ReturnType.SYNTAX_ERROR; return ReturnType.SYNTAX_ERROR;
}
OfflinePlayer player = Bukkit.getOfflinePlayer(args[0]); 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)) { .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; return ReturnType.FAILURE;
} }
PlayerPunishData playerPunishData = plugin.getPunishmentManager().getPlayer(player); PlayerPunishData playerPunishData = this.plugin.getPunishmentManager().getPlayer(player);
playerPunishData.expirePunishments(PunishmentType.BAN); playerPunishData.expirePunishments(PunishmentType.BAN);
plugin.getLocale().getMessage("event.unban.success") this.plugin.getLocale().getMessage("event.unban.success")
.processPlaceholder("player", player.getName()).sendPrefixedMessage(sender); .processPlaceholder("player", player.getName()).sendPrefixedMessage(sender);
return ReturnType.SUCCESS; return ReturnType.SUCCESS;
} }

View File

@ -1,6 +1,6 @@
package com.songoda.ultimatemoderation.commands; package com.songoda.ultimatemoderation.commands;
import com.songoda.core.commands.AbstractCommand; import com.craftaro.core.commands.AbstractCommand;
import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.UltimateModeration;
import com.songoda.ultimatemoderation.punish.PunishmentType; import com.songoda.ultimatemoderation.punish.PunishmentType;
import com.songoda.ultimatemoderation.punish.player.PlayerPunishData; import com.songoda.ultimatemoderation.punish.player.PlayerPunishData;
@ -13,7 +13,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
public class CommandUnMute extends AbstractCommand { public class CommandUnMute extends AbstractCommand {
private final UltimateModeration plugin; private final UltimateModeration plugin;
public CommandUnMute(UltimateModeration plugin) { public CommandUnMute(UltimateModeration plugin) {
@ -28,17 +27,17 @@ public class CommandUnMute extends AbstractCommand {
OfflinePlayer player = Bukkit.getOfflinePlayer(args[0]); 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)) { .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; return ReturnType.FAILURE;
} }
PlayerPunishData playerPunishData = plugin.getPunishmentManager().getPlayer(player); PlayerPunishData playerPunishData = this.plugin.getPunishmentManager().getPlayer(player);
playerPunishData.expirePunishments(PunishmentType.MUTE); playerPunishData.expirePunishments(PunishmentType.MUTE);
plugin.getLocale().newMessage(plugin.getLocale().getMessage("event.unmute.success") this.plugin.getLocale().newMessage(this.plugin.getLocale().getMessage("event.unmute.success")
.processPlaceholder("player", player.getName()).getMessage()).sendPrefixedMessage(sender); .processPlaceholder("player", player.getName()).getMessage()).sendPrefixedMessage(sender);
return ReturnType.SUCCESS; return ReturnType.SUCCESS;
} }

View File

@ -1,12 +1,12 @@
package com.songoda.ultimatemoderation.commands; package com.songoda.ultimatemoderation.commands;
import com.songoda.core.commands.AbstractCommand; import com.craftaro.core.commands.AbstractCommand;
import com.songoda.core.compatibility.ServerVersion; import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.core.third_party.com.cryptomorin.xseries.XSound;
import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.UltimateModeration;
import com.songoda.ultimatemoderation.settings.Settings; import com.songoda.ultimatemoderation.settings.Settings;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Particle; import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
@ -18,7 +18,6 @@ import java.util.List;
import java.util.UUID; import java.util.UUID;
public class CommandVanish extends AbstractCommand { public class CommandVanish extends AbstractCommand {
private static final List<UUID> inVanish = new ArrayList<>(); private static final List<UUID> inVanish = new ArrayList<>();
public CommandVanish() { public CommandVanish() {
@ -28,7 +27,9 @@ public class CommandVanish extends AbstractCommand {
public static void registerVanishedPlayers(Player player) { public static void registerVanishedPlayers(Player player) {
for (UUID uuid : inVanish) { for (UUID uuid : inVanish) {
Player vanished = Bukkit.getPlayer(uuid); Player vanished = Bukkit.getPlayer(uuid);
if (vanished == null) continue; if (vanished == null) {
continue;
}
if (player.hasPermission("um.vanish.bypass")) { if (player.hasPermission("um.vanish.bypass")) {
player.showPlayer(vanished); player.showPlayer(vanished);
} else { } else {
@ -44,20 +45,22 @@ public class CommandVanish extends AbstractCommand {
if (inVanish.contains(uuid)) { if (inVanish.contains(uuid)) {
inVanish.remove(uuid); inVanish.remove(uuid);
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) {
player.setInvulnerable(false); player.setInvulnerable(false);
}
player.setCanPickupItems(true); player.setCanPickupItems(true);
instance.getLocale().getMessage("command.vanish.toggledOff").sendPrefixedMessage(player); instance.getLocale().getMessage("command.vanish.toggledOff").sendPrefixedMessage(player);
} else { } else {
inVanish.add(uuid); inVanish.add(uuid);
player.setCanPickupItems(false); player.setCanPickupItems(false);
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) {
player.setInvulnerable(true); player.setInvulnerable(true);
}
instance.getLocale().getMessage("command.vanish.toggledOn").sendPrefixedMessage(player); instance.getLocale().getMessage("command.vanish.toggledOn").sendPrefixedMessage(player);
} }
if (Settings.VANISH_EFFECTS.getBoolean()) { 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()) { if (Settings.VANISH_BATS.getBoolean()) {
List<Entity> entities = new ArrayList<>(); List<Entity> entities = new ArrayList<>();
@ -74,15 +77,17 @@ public class CommandVanish extends AbstractCommand {
float xx = (float) (0 + (Math.random() * 1)); float xx = (float) (0 + (Math.random() * 1));
float yy = (float) (0 + (Math.random() * 2)); float yy = (float) (0 + (Math.random() * 2));
float zz = (float) (0 + (Math.random() * 1)); 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); 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()) { for (Player p : Bukkit.getOnlinePlayers()) {
if (inVanish.contains(uuid)) if (inVanish.contains(uuid)) {
registerVanishedPlayers(p); registerVanishedPlayers(p);
else } else {
p.showPlayer(player); p.showPlayer(player);
}
} }
for (Entity e : player.getNearbyEntities(30, 30, 30)) { for (Entity e : player.getNearbyEntities(30, 30, 30)) {
if (e instanceof Monster) { if (e instanceof Monster) {

View File

@ -1,10 +1,10 @@
package com.songoda.ultimatemoderation.commands; package com.songoda.ultimatemoderation.commands;
import com.songoda.core.commands.AbstractCommand; import com.craftaro.core.commands.AbstractCommand;
import com.craftaro.core.utils.TimeUtils;
import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.UltimateModeration;
import com.songoda.ultimatemoderation.punish.Punishment; import com.songoda.ultimatemoderation.punish.Punishment;
import com.songoda.ultimatemoderation.punish.PunishmentType; import com.songoda.ultimatemoderation.punish.PunishmentType;
import com.songoda.ultimatemoderation.utils.Methods;
import com.songoda.ultimatemoderation.utils.VaultPermissions; import com.songoda.ultimatemoderation.utils.VaultPermissions;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
@ -17,7 +17,6 @@ import java.util.Collections;
import java.util.List; import java.util.List;
public class CommandWarn extends AbstractCommand { public class CommandWarn extends AbstractCommand {
private final UltimateModeration plugin; private final UltimateModeration plugin;
public CommandWarn(UltimateModeration plugin) { public CommandWarn(UltimateModeration plugin) {
@ -27,21 +26,23 @@ public class CommandWarn extends AbstractCommand {
@Override @Override
protected ReturnType runCommand(CommandSender sender, String... args) { protected ReturnType runCommand(CommandSender sender, String... args) {
if (args.length < 1) if (args.length < 1) {
return ReturnType.SYNTAX_ERROR; 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". // they can't ban someone for the reason "Stole me 2h sword".
long duration = 0; long duration = 0;
StringBuilder reasonBuilder = new StringBuilder(); StringBuilder reasonBuilder = new StringBuilder();
if (args.length > 1) { if (args.length > 1) {
for (int i = 1; i < args.length; i++) { for (int i = 1; i < args.length; i++) {
String line = args[i]; String line = args[i];
long time = Methods.parseTime(line); long time = TimeUtils.parseTime(line);
if (time != 0) if (time != 0) {
duration += time; duration += time;
else } else {
reasonBuilder.append(line).append(" "); reasonBuilder.append(line).append(" ");
}
} }
} }
@ -50,7 +51,7 @@ public class CommandWarn extends AbstractCommand {
OfflinePlayer player = Bukkit.getOfflinePlayer(args[0]); OfflinePlayer player = Bukkit.getOfflinePlayer(args[0]);
if (sender instanceof Player && VaultPermissions.hasPermission(player, "um.warning.exempt")) { 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; return ReturnType.FAILURE;
} }

View File

@ -1,7 +1,7 @@
package com.songoda.ultimatemoderation.database; package com.songoda.ultimatemoderation.database;
import com.songoda.core.database.DataManagerAbstract; import com.craftaro.core.database.DataManagerAbstract;
import com.songoda.core.database.DatabaseConnector; import com.craftaro.core.database.DatabaseConnector;
import com.songoda.ultimatemoderation.punish.AppliedPunishment; import com.songoda.ultimatemoderation.punish.AppliedPunishment;
import com.songoda.ultimatemoderation.punish.PunishmentNote; import com.songoda.ultimatemoderation.punish.PunishmentNote;
import com.songoda.ultimatemoderation.punish.PunishmentType; import com.songoda.ultimatemoderation.punish.PunishmentType;
@ -25,7 +25,6 @@ import java.util.UUID;
import java.util.function.Consumer; import java.util.function.Consumer;
public class DataManager extends DataManagerAbstract { public class DataManager extends DataManagerAbstract {
public DataManager(DatabaseConnector databaseConnector, Plugin plugin) { public DataManager(DatabaseConnector databaseConnector, Plugin plugin) {
super(databaseConnector, plugin); super(databaseConnector, plugin);
} }

View File

@ -1,7 +1,7 @@
package com.songoda.ultimatemoderation.database.migrations; package com.songoda.ultimatemoderation.database.migrations;
import com.songoda.core.database.DataMigration; import com.craftaro.core.database.DataMigration;
import com.songoda.core.database.MySQLConnector; import com.craftaro.core.database.MySQLConnector;
import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.UltimateModeration;
import java.sql.Connection; import java.sql.Connection;
@ -9,14 +9,16 @@ import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
public class _1_InitialMigration extends DataMigration { public class _1_InitialMigration extends DataMigration {
private final UltimateModeration plugin;
public _1_InitialMigration() { public _1_InitialMigration(UltimateModeration plugin) {
super(1); super(1);
this.plugin = plugin;
} }
@Override @Override
public void migrate(Connection connection, String tablePrefix) throws SQLException { public void migrate(Connection connection, String tablePrefix) throws SQLException {
String autoIncrement = UltimateModeration.getInstance().getDatabaseConnector() instanceof MySQLConnector ? " AUTO_INCREMENT" : ""; String autoIncrement = this.plugin.getDatabaseConnector() instanceof MySQLConnector ? " AUTO_INCREMENT" : "";
// Create templates table // Create templates table
try (Statement statement = connection.createStatement()) { try (Statement statement = connection.createStatement()) {

View File

@ -1,11 +1,11 @@
package com.songoda.ultimatemoderation.gui; package com.songoda.ultimatemoderation.gui;
import com.songoda.core.compatibility.CompatibleMaterial; import com.craftaro.core.gui.AnvilGui;
import com.songoda.core.gui.AnvilGui; import com.craftaro.core.gui.Gui;
import com.songoda.core.gui.Gui; import com.craftaro.core.gui.GuiUtils;
import com.songoda.core.gui.GuiUtils; import com.craftaro.core.third_party.com.cryptomorin.xseries.XMaterial;
import com.songoda.core.utils.ItemUtils; import com.craftaro.core.utils.ItemUtils;
import com.songoda.core.utils.TextUtils; import com.craftaro.core.utils.TextUtils;
import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.UltimateModeration;
import com.songoda.ultimatemoderation.punish.PunishmentType; import com.songoda.ultimatemoderation.punish.PunishmentType;
import com.songoda.ultimatemoderation.punish.player.PlayerPunishData; import com.songoda.ultimatemoderation.punish.player.PlayerPunishData;
@ -24,7 +24,6 @@ import java.util.UUID;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class MainGui extends Gui { public class MainGui extends Gui {
private final UltimateModeration plugin; private final UltimateModeration plugin;
private Online currentOnline = Online.ONLINE; private Online currentOnline = Online.ONLINE;
@ -38,11 +37,14 @@ public class MainGui extends Gui {
setDefaultItem(null); setDefaultItem(null);
this.viewer = viewer; this.viewer = viewer;
for (Player player : Bukkit.getOnlinePlayers()) for (Player player : Bukkit.getOnlinePlayers()) {
players.add(player.getUniqueId()); this.players.add(player.getUniqueId());
}
for (UUID uuid : plugin.getPunishmentManager().getPunishments().keySet()) { for (UUID uuid : plugin.getPunishmentManager().getPunishments().keySet()) {
if (Bukkit.getOfflinePlayer(uuid).isOnline()) continue; if (Bukkit.getOfflinePlayer(uuid).isOnline()) {
players.add(uuid); continue;
}
this.players.add(uuid);
} }
setTitle(plugin.getLocale().getMessage("gui.players.title").getMessage()); setTitle(plugin.getLocale().getMessage("gui.players.title").getMessage());
@ -51,13 +53,14 @@ public class MainGui extends Gui {
} }
private void showPage() { private void showPage() {
if (inventory != null) if (this.inventory != null) {
inventory.clear(); this.inventory.clear();
}
setActionForRange(0, 53, null); setActionForRange(0, 53, null);
// decorate the edges // decorate the edges
ItemStack glass2 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_2.getMaterial(CompatibleMaterial.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(CompatibleMaterial.LIGHT_BLUE_STAINED_GLASS_PANE)); ItemStack glass3 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_3.getMaterial(XMaterial.LIGHT_BLUE_STAINED_GLASS_PANE));
// edges will be type 3 // edges will be type 3
mirrorFill(0, 2, true, true, glass3); mirrorFill(0, 2, true, true, glass3);
@ -68,15 +71,17 @@ public class MainGui extends Gui {
mirrorFill(1, 0, true, true, glass2); mirrorFill(1, 0, true, true, glass2);
mirrorFill(0, 1, true, true, glass2); mirrorFill(0, 1, true, true, glass2);
setButton(5, 2, GuiUtils.createButtonItem(CompatibleMaterial.ENDER_PEARL, setButton(5, 2, GuiUtils.createButtonItem(XMaterial.ENDER_PEARL,
plugin.getLocale().getMessage("gui.players.search").getMessage()), this.plugin.getLocale().getMessage("gui.players.search").getMessage()),
(event) -> { (event) -> {
AnvilGui gui = new AnvilGui(event.player, this); AnvilGui gui = new AnvilGui(event.player, this);
gui.setAction(event2 -> { gui.setAction(event2 -> {
List<UUID> players = new ArrayList<>(plugin.getPunishmentManager().getPunishments().keySet()); List<UUID> players = new ArrayList<>(this.plugin.getPunishmentManager().getPunishments().keySet());
for (Player p : Bukkit.getOnlinePlayers()) { for (Player p : Bukkit.getOnlinePlayers()) {
if (players.contains(p.getUniqueId())) continue; if (players.contains(p.getUniqueId())) {
continue;
}
players.add(p.getUniqueId()); players.add(p.getUniqueId());
} }
@ -87,115 +92,118 @@ public class MainGui extends Gui {
this.players.addAll(found); this.players.addAll(found);
showPage(); showPage();
} else { } else {
plugin.getLocale().getMessage("gui.players.nonefound").sendMessage(event.player); this.plugin.getLocale().getMessage("gui.players.nonefound").sendMessage(event.player);
} }
event2.player.closeInventory(); event2.player.closeInventory();
}); });
ItemStack item = new ItemStack(Material.PAPER); ItemStack item = new ItemStack(Material.PAPER);
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
meta.setDisplayName(plugin.getLocale().getMessage("gui.players.name").getMessage()); meta.setDisplayName(this.plugin.getLocale().getMessage("gui.players.name").getMessage());
item.setItemMeta(meta); item.setItemMeta(meta);
gui.setInput(item); gui.setInput(item);
guiManager.showGUI(event.player, gui); this.guiManager.showGUI(event.player, gui);
}); });
setButton(5, 3, GuiUtils.createButtonItem(CompatibleMaterial.HOPPER, TextUtils.formatText("&6" + currentOnline.getTranslation())), setButton(5, 3, GuiUtils.createButtonItem(XMaterial.HOPPER, TextUtils.formatText("&6" + this.currentOnline.getTranslation())),
(event) -> { (event) -> {
this.currentOnline = currentOnline.next(); this.currentOnline = this.currentOnline.next();
this.page = 1; this.page = 1;
showPage(); showPage();
}); });
if (viewer.hasPermission("um.tickets")) if (this.viewer.hasPermission("um.tickets")) {
setButton(5, 5, GuiUtils.createButtonItem(CompatibleMaterial.CHEST, setButton(5, 5, GuiUtils.createButtonItem(XMaterial.CHEST,
plugin.getLocale().getMessage("gui.players.button.tickets").getMessage()), this.plugin.getLocale().getMessage("gui.players.button.tickets").getMessage()),
(event) -> guiManager.showGUI(event.player, new TicketManagerGui(plugin, null, viewer))); (event) -> this.guiManager.showGUI(event.player, new TicketManagerGui(this.plugin, null, this.viewer)));
}
if (viewer.hasPermission("um.templates")) if (this.viewer.hasPermission("um.templates")) {
setButton(5, 6, GuiUtils.createButtonItem(CompatibleMaterial.MAP, setButton(5, 6, GuiUtils.createButtonItem(XMaterial.MAP,
plugin.getLocale().getMessage("gui.players.button.templatemanager").getMessage()), this.plugin.getLocale().getMessage("gui.players.button.templatemanager").getMessage()),
(events) -> guiManager.showGUI(events.player, new TemplateManagerGui(plugin, viewer))); (events) -> this.guiManager.showGUI(events.player, new TemplateManagerGui(this.plugin, this.viewer)));
}
List<UUID> toUse = players.stream() List<UUID> toUse = this.players.stream()
.filter(u -> currentOnline == Online.BOTH .filter(u -> this.currentOnline == Online.BOTH
|| currentOnline == Online.ONLINE && Bukkit.getOfflinePlayer(u).isOnline() || this.currentOnline == Online.ONLINE && Bukkit.getOfflinePlayer(u).isOnline()
|| currentOnline == Online.OFFLINE && !Bukkit.getOfflinePlayer(u).isOnline()).collect(Collectors.toList()); || this.currentOnline == Online.OFFLINE && !Bukkit.getOfflinePlayer(u).isOnline()).collect(Collectors.toList());
this.pages = (int) Math.max(1, Math.ceil(toUse.size() / ((double) 28))); 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()); final List<UUID> toUseFinal = toUse.stream().skip((this.page - 1) * 28).limit(28).collect(Collectors.toList());
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> {
int num = 11; int num = 11;
for (UUID uuid : toUseFinal) { for (UUID uuid : toUseFinal) {
if (num == 16 || num == 36) if (num == 16 || num == 36) {
num = num + 2; num = num + 2;
}
OfflinePlayer pl = Bukkit.getOfflinePlayer(uuid); OfflinePlayer pl = Bukkit.getOfflinePlayer(uuid);
ItemStack skull = ItemUtils.getPlayerSkull(pl); ItemStack skull = ItemUtils.getPlayerSkull(pl);
setItem(num, skull); setItem(num, skull);
PlayerPunishData playerPunishData = plugin.getPunishmentManager().getPlayer(pl); PlayerPunishData playerPunishData = this.plugin.getPunishmentManager().getPlayer(pl);
ArrayList<String> lore = new ArrayList<>(); ArrayList<String> lore = new ArrayList<>();
lore.add(plugin.getLocale().getMessage("gui.players.click").getMessage()); lore.add(this.plugin.getLocale().getMessage("gui.players.click").getMessage());
lore.add(""); lore.add("");
int ticketAmt = (int) plugin.getTicketManager().getTicketsAbout(pl).stream() int ticketAmt = (int) this.plugin.getTicketManager().getTicketsAbout(pl).stream()
.filter(t -> t.getStatus() == TicketStatus.OPEN).count(); .filter(t -> t.getStatus() == TicketStatus.OPEN).count();
if (ticketAmt == 0) if (ticketAmt == 0) {
lore.add(plugin.getLocale().getMessage("gui.players.notickets").getMessage()); lore.add(this.plugin.getLocale().getMessage("gui.players.notickets").getMessage());
else { } else {
if (ticketAmt == 1) if (ticketAmt == 1) {
lore.add(plugin.getLocale().getMessage("gui.players.ticketsone").getMessage()); lore.add(this.plugin.getLocale().getMessage("gui.players.ticketsone").getMessage());
else } else {
lore.add(plugin.getLocale().getMessage("gui.players.tickets") lore.add(this.plugin.getLocale().getMessage("gui.players.tickets")
.processPlaceholder("amount", ticketAmt).getMessage()); .processPlaceholder("amount", ticketAmt).getMessage());
}
} }
int warningAmt = playerPunishData.getActivePunishments(PunishmentType.WARNING).size(); int warningAmt = playerPunishData.getActivePunishments(PunishmentType.WARNING).size();
if (warningAmt == 0) if (warningAmt == 0) {
lore.add(plugin.getLocale().getMessage("gui.players.nowarnings").getMessage()); lore.add(this.plugin.getLocale().getMessage("gui.players.nowarnings").getMessage());
else { } else {
if (warningAmt == 1) if (warningAmt == 1) {
lore.add(plugin.getLocale().getMessage("gui.players.warningsone").getMessage()); lore.add(this.plugin.getLocale().getMessage("gui.players.warningsone").getMessage());
else } else {
lore.add(plugin.getLocale().getMessage("gui.players.warnings") lore.add(this.plugin.getLocale().getMessage("gui.players.warnings")
.processPlaceholder("amount", warningAmt).getMessage()); .processPlaceholder("amount", warningAmt).getMessage());
}
} }
setButton(num, GuiUtils.createButtonItem(skull, TextUtils.formatText("&7&l" + pl.getName()), lore), setButton(num, GuiUtils.createButtonItem(skull, TextUtils.formatText("&7&l" + pl.getName()), lore),
(event) -> guiManager.showGUI(event.player, new PlayerGui(plugin, pl, viewer))); (event) -> this.guiManager.showGUI(event.player, new PlayerGui(this.plugin, pl, this.viewer)));
num++; num++;
} }
}); });
// enable page events // enable page events
setNextPage(4, 7, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, plugin.getLocale().getMessage("gui.general.next").getMessage())); setNextPage(4, 7, GuiUtils.createButtonItem(XMaterial.ARROW, this.plugin.getLocale().getMessage("gui.general.next").getMessage()));
setPrevPage(4, 1, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, plugin.getLocale().getMessage("gui.general.back").getMessage())); setPrevPage(4, 1, GuiUtils.createButtonItem(XMaterial.ARROW, this.plugin.getLocale().getMessage("gui.general.back").getMessage()));
setOnPage((event) -> showPage()); setOnPage((event) -> showPage());
} }
private enum Online { private enum Online {
ONLINE, OFFLINE, BOTH; ONLINE, OFFLINE, BOTH;
private static Online[] vals = values();
public Online next() { public Online 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() { public String getTranslation() {
return UltimateModeration.getInstance().getLocale() return UltimateModeration.getPlugin(UltimateModeration.class)
.getMessage("gui.players.online." + this.name().toLowerCase()).getMessage(); .getLocale()
.getMessage("gui.players.online." + this.name().toLowerCase())
.getMessage();
} }
} }
} }

View File

@ -1,9 +1,9 @@
package com.songoda.ultimatemoderation.gui; package com.songoda.ultimatemoderation.gui;
import com.songoda.core.compatibility.CompatibleMaterial; import com.craftaro.core.gui.Gui;
import com.songoda.core.gui.Gui; import com.craftaro.core.gui.GuiUtils;
import com.songoda.core.gui.GuiUtils; import com.craftaro.core.third_party.com.cryptomorin.xseries.XMaterial;
import com.songoda.core.utils.TextUtils; import com.craftaro.core.utils.TextUtils;
import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.UltimateModeration;
import com.songoda.ultimatemoderation.moderate.AbstractModeration; import com.songoda.ultimatemoderation.moderate.AbstractModeration;
import com.songoda.ultimatemoderation.settings.Settings; import com.songoda.ultimatemoderation.settings.Settings;
@ -15,7 +15,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
public class ModerateGui extends Gui { public class ModerateGui extends Gui {
public ModerateGui(UltimateModeration plugin, OfflinePlayer toModerate, Player player) { public ModerateGui(UltimateModeration plugin, OfflinePlayer toModerate, Player player) {
super(5); super(5);
setDefaultItem(null); setDefaultItem(null);
@ -24,8 +23,8 @@ public class ModerateGui extends Gui {
.processPlaceholder("toModerate", toModerate.getName()).getMessage()); .processPlaceholder("toModerate", toModerate.getName()).getMessage());
// decorate the edges // decorate the edges
ItemStack glass2 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_2.getMaterial(CompatibleMaterial.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(CompatibleMaterial.LIGHT_BLUE_STAINED_GLASS_PANE)); ItemStack glass3 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_3.getMaterial(XMaterial.LIGHT_BLUE_STAINED_GLASS_PANE));
// edges will be type 3 // edges will be type 3
mirrorFill(0, 2, true, true, glass3); mirrorFill(0, 2, true, true, glass3);
@ -37,9 +36,9 @@ public class ModerateGui extends Gui {
mirrorFill(2, 0, false, true, glass2); mirrorFill(2, 0, false, true, glass2);
mirrorFill(0, 1, true, true, glass2); mirrorFill(0, 1, true, true, glass2);
setButton(8, GuiUtils.createButtonItem(CompatibleMaterial.OAK_DOOR, setButton(8, GuiUtils.createButtonItem(XMaterial.OAK_DOOR,
plugin.getLocale().getMessage("gui.general.back").getMessage()), plugin.getLocale().getMessage("gui.general.back").getMessage()),
(event) -> guiManager.showGUI(event.player, new PlayerGui(plugin, toModerate, event.player))); (event) -> this.guiManager.showGUI(event.player, new PlayerGui(plugin, toModerate, event.player)));
int[] slots = new int[]{11, 13, 15, 29, 31, 33}; int[] slots = new int[]{11, 13, 15, 29, 31, 33};
@ -47,11 +46,14 @@ public class ModerateGui extends Gui {
int i = 0; int i = 0;
for (AbstractModeration moderation : moderations) { for (AbstractModeration moderation : moderations) {
if (!moderation.hasPermission(player) || moderation.isExempt(toModerate)) continue; if (!moderation.hasPermission(player) || moderation.isExempt(toModerate)) {
continue;
}
int slot = slots[i]; int slot = slots[i];
setButton(slot, GuiUtils.createButtonItem(moderation.getIcon(), setButton(slot, GuiUtils.createButtonItem(moderation.getIcon(),
TextUtils.formatText("&6&l" + moderation.getProper()), TextUtils.formatText("&6&l" + moderation.getProper()),
TextUtils.formatText("&7" + moderation.getDescription())), TextUtils.formatText("&7" + moderation.getDescription())),
(event) -> moderation.runPreModeration(player, toModerate)); (event) -> moderation.runPreModeration(player, toModerate));
i++; i++;
} }

View File

@ -1,10 +1,10 @@
package com.songoda.ultimatemoderation.gui; package com.songoda.ultimatemoderation.gui;
import com.songoda.core.compatibility.CompatibleMaterial; import com.craftaro.core.gui.Gui;
import com.songoda.core.gui.Gui; import com.craftaro.core.gui.GuiUtils;
import com.songoda.core.gui.GuiUtils; import com.craftaro.core.input.ChatPrompt;
import com.songoda.core.input.ChatPrompt; import com.craftaro.core.third_party.com.cryptomorin.xseries.XMaterial;
import com.songoda.core.utils.TextUtils; import com.craftaro.core.utils.TextUtils;
import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.UltimateModeration;
import com.songoda.ultimatemoderation.punish.PunishmentNote; import com.songoda.ultimatemoderation.punish.PunishmentNote;
import com.songoda.ultimatemoderation.settings.Settings; import com.songoda.ultimatemoderation.settings.Settings;
@ -20,7 +20,6 @@ import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class NotesManagerGui extends Gui { public class NotesManagerGui extends Gui {
private final UltimateModeration plugin; private final UltimateModeration plugin;
private final OfflinePlayer toModerate; private final OfflinePlayer toModerate;
@ -42,24 +41,25 @@ public class NotesManagerGui extends Gui {
} }
private void showPage() { private void showPage() {
if (inventory != null) if (this.inventory != null) {
inventory.clear(); this.inventory.clear();
}
setActionForRange(0, 53, null); setActionForRange(0, 53, null);
int numNotes = plugin.getPunishmentManager().getPlayer(toModerate).getNotes().size(); int numNotes = this.plugin.getPunishmentManager().getPlayer(this.toModerate).getNotes().size();
this.pages = (int) Math.max(1, Math.ceil(numNotes / ((double) 28))); this.pages = (int) Math.max(1, Math.ceil(numNotes / ((double) 28)));
List<PunishmentNote> notes = plugin.getPunishmentManager().getPlayer(toModerate).getNotes().stream() List<PunishmentNote> notes = this.plugin.getPunishmentManager().getPlayer(this.toModerate).getNotes().stream()
.skip((page - 1) * 28).limit(28).collect(Collectors.toList()); .skip((this.page - 1) * 28).limit(28).collect(Collectors.toList());
// enable page events // enable page events
setNextPage(0, 1, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, plugin.getLocale().getMessage("gui.general.next").getMessage())); setNextPage(0, 1, GuiUtils.createButtonItem(XMaterial.ARROW, this.plugin.getLocale().getMessage("gui.general.next").getMessage()));
setPrevPage(0, 3, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, plugin.getLocale().getMessage("gui.general.back").getMessage())); setPrevPage(0, 3, GuiUtils.createButtonItem(XMaterial.ARROW, this.plugin.getLocale().getMessage("gui.general.back").getMessage()));
setOnPage((event) -> showPage()); setOnPage((event) -> showPage());
// decorate the edges // decorate the edges
ItemStack glass2 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_2.getMaterial(CompatibleMaterial.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(CompatibleMaterial.LIGHT_BLUE_STAINED_GLASS_PANE)); ItemStack glass3 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_3.getMaterial(XMaterial.LIGHT_BLUE_STAINED_GLASS_PANE));
// edges will be type 3 // edges will be type 3
mirrorFill(0, 2, true, true, glass3); mirrorFill(0, 2, true, true, glass3);
@ -70,38 +70,41 @@ public class NotesManagerGui extends Gui {
mirrorFill(1, 0, true, true, glass2); mirrorFill(1, 0, true, true, glass2);
mirrorFill(0, 1, true, true, glass2); mirrorFill(0, 1, true, true, glass2);
setButton(5, 5, GuiUtils.createButtonItem(CompatibleMaterial.OAK_DOOR, setButton(5, 5, GuiUtils.createButtonItem(XMaterial.OAK_DOOR,
plugin.getLocale().getMessage("gui.general.back").getMessage()), this.plugin.getLocale().getMessage("gui.general.back").getMessage()),
(event) -> guiManager.showGUI(event.player, new PlayerGui(plugin, toModerate, event.player))); (event) -> this.guiManager.showGUI(event.player, new PlayerGui(this.plugin, this.toModerate, event.player)));
if (create) if (this.create) {
setButton(5, 3, GuiUtils.createButtonItem(CompatibleMaterial.REDSTONE, setButton(5, 3, GuiUtils.createButtonItem(XMaterial.REDSTONE,
plugin.getLocale().getMessage("gui.notes.create").getMessage()), this.plugin.getLocale().getMessage("gui.notes.create").getMessage()),
(event) -> { (event) -> {
ChatPrompt.showPrompt(plugin, event.player, ChatPrompt.showPrompt(this.plugin, event.player,
plugin.getLocale().getMessage("gui.notes.type").getMessage(), this.plugin.getLocale().getMessage("gui.notes.type").getMessage(),
(response) -> { (response) -> {
PunishmentNote note = new PunishmentNote(response.getMessage(), PunishmentNote note = new PunishmentNote(response.getMessage(),
event.player.getUniqueId(), toModerate.getUniqueId(), event.player.getUniqueId(), this.toModerate.getUniqueId(),
System.currentTimeMillis()); System.currentTimeMillis());
plugin.getPunishmentManager().getPlayer(toModerate).addNotes(note); this.plugin.getPunishmentManager().getPlayer(this.toModerate).addNotes(note);
plugin.getDataManager().createNote(note); this.plugin.getDataManager().createNote(note);
showPage(); showPage();
}).setOnClose(() -> guiManager.showGUI(event.player, new NotesManagerGui(plugin, toModerate, event.player))); }).setOnClose(() -> this.guiManager.showGUI(event.player, new NotesManagerGui(this.plugin, this.toModerate, event.player)));
}); });
}
int num = 11; int num = 11;
for (PunishmentNote note : notes) { for (PunishmentNote note : notes) {
if (num == 16 || num == 36) if (num == 16 || num == 36) {
num = num + 2; num = num + 2;
}
String noteStr = note.getNote(); String noteStr = note.getNote();
ArrayList<String> lore = new ArrayList<>(); ArrayList<String> lore = new ArrayList<>();
int lastIndex = 0; int lastIndex = 0;
for (int n = 0; n < noteStr.length(); n++) { for (int n = 0; n < noteStr.length(); n++) {
if (n - lastIndex < 20) if (n - lastIndex < 20) {
continue; continue;
}
if (noteStr.charAt(n) == ' ') { if (noteStr.charAt(n) == ' ') {
lore.add("&6" + noteStr.substring(lastIndex, n).trim()); lore.add("&6" + noteStr.substring(lastIndex, n).trim());
@ -109,8 +112,9 @@ public class NotesManagerGui extends Gui {
} }
} }
if (lastIndex - noteStr.length() < 20) if (lastIndex - noteStr.length() < 20) {
lore.add("&6" + noteStr.substring(lastIndex).trim()); lore.add("&6" + noteStr.substring(lastIndex).trim());
}
String name = lore.get(0); String name = lore.get(0);
lore.remove(0); lore.remove(0);
@ -119,25 +123,26 @@ public class NotesManagerGui extends Gui {
SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy"); SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy");
lore.add(plugin.getLocale().getMessage("gui.notes.createdby") lore.add(this.plugin.getLocale().getMessage("gui.notes.createdby")
.processPlaceholder("player", Bukkit.getOfflinePlayer(note.getAuthor()).getName()) .processPlaceholder("player", Bukkit.getOfflinePlayer(note.getAuthor()).getName())
.getMessage()); .getMessage());
lore.add(plugin.getLocale().getMessage("gui.notes.createdon") lore.add(this.plugin.getLocale().getMessage("gui.notes.createdon")
.processPlaceholder("sent", format.format(new Date(note.getCreationDate()))) .processPlaceholder("sent", format.format(new Date(note.getCreationDate())))
.getMessage()); .getMessage());
if (delete) lore.add(plugin.getLocale().getMessage("gui.notes.remove").getMessage()); if (this.delete) {
lore.add(this.plugin.getLocale().getMessage("gui.notes.remove").getMessage());
}
setButton(num, GuiUtils.createButtonItem(CompatibleMaterial.MAP, TextUtils.formatText(name), TextUtils.formatText(lore)), setButton(num, GuiUtils.createButtonItem(XMaterial.MAP, TextUtils.formatText(name), TextUtils.formatText(lore)),
(event) -> { (event) -> {
if (delete) { if (this.delete) {
plugin.getPunishmentManager().getPlayer(toModerate).removeNotes(note); this.plugin.getPunishmentManager().getPlayer(this.toModerate).removeNotes(note);
plugin.getDataManager().deleteNote(note); this.plugin.getDataManager().deleteNote(note);
showPage(); showPage();
} }
}); });
num++; num++;
} }
} }
} }

View File

@ -1,10 +1,10 @@
package com.songoda.ultimatemoderation.gui; package com.songoda.ultimatemoderation.gui;
import com.songoda.core.compatibility.CompatibleMaterial; import com.craftaro.core.gui.Gui;
import com.songoda.core.gui.Gui; import com.craftaro.core.gui.GuiUtils;
import com.songoda.core.gui.GuiUtils; import com.craftaro.core.third_party.com.cryptomorin.xseries.XMaterial;
import com.songoda.core.utils.ItemUtils; import com.craftaro.core.utils.ItemUtils;
import com.songoda.core.utils.TextUtils; import com.craftaro.core.utils.TextUtils;
import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.UltimateModeration;
import com.songoda.ultimatemoderation.settings.Settings; import com.songoda.ultimatemoderation.settings.Settings;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
@ -12,7 +12,6 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
public class PlayerGui extends Gui { public class PlayerGui extends Gui {
public PlayerGui(UltimateModeration plugin, OfflinePlayer toModerate, Player player) { public PlayerGui(UltimateModeration plugin, OfflinePlayer toModerate, Player player) {
super(6); super(6);
setDefaultItem(null); setDefaultItem(null);
@ -28,8 +27,8 @@ public class PlayerGui extends Gui {
.processPlaceholder("toModerate", toModerate.getName()).getMessage()); .processPlaceholder("toModerate", toModerate.getName()).getMessage());
// decorate the edges // decorate the edges
ItemStack glass2 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_2.getMaterial(CompatibleMaterial.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(CompatibleMaterial.LIGHT_BLUE_STAINED_GLASS_PANE)); ItemStack glass3 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_3.getMaterial(XMaterial.LIGHT_BLUE_STAINED_GLASS_PANE));
// edges will be type 3 // edges will be type 3
mirrorFill(0, 2, true, true, glass3); mirrorFill(0, 2, true, true, glass3);
@ -47,36 +46,41 @@ public class PlayerGui extends Gui {
+ plugin.getLocale().getMessage("gui.players.online.online").getMessage() + plugin.getLocale().getMessage("gui.players.online.online").getMessage()
: "&c" + plugin.getLocale().getMessage("gui.players.online.offline").getMessage()))); : "&c" + plugin.getLocale().getMessage("gui.players.online.offline").getMessage())));
setButton(8, GuiUtils.createButtonItem(CompatibleMaterial.OAK_DOOR, setButton(8, GuiUtils.createButtonItem(XMaterial.OAK_DOOR,
plugin.getLocale().getMessage("gui.general.back").getMessage()), plugin.getLocale().getMessage("gui.general.back").getMessage()),
(event) -> guiManager.showGUI(event.player, new MainGui(plugin, event.player))); (event) -> this.guiManager.showGUI(event.player, new MainGui(plugin, event.player)));
if (punish) if (punish) {
setButton(38, GuiUtils.createButtonItem(CompatibleMaterial.ANVIL, setButton(38, GuiUtils.createButtonItem(XMaterial.ANVIL,
plugin.getLocale().getMessage("gui.player.punish").getMessage()), plugin.getLocale().getMessage("gui.player.punish").getMessage()),
(event) -> plugin.getGuiManager().showGUI(player, (event) -> plugin.getGuiManager().showGUI(player,
new PunishGui(plugin, toModerate, null, event.player))); new PunishGui(plugin, toModerate, null, event.player)));
}
if (tickets) if (tickets) {
setButton(30, GuiUtils.createButtonItem(CompatibleMaterial.CHEST, setButton(30, GuiUtils.createButtonItem(XMaterial.CHEST,
plugin.getLocale().getMessage("gui.player.tickets").getMessage()), plugin.getLocale().getMessage("gui.player.tickets").getMessage()),
(event) -> plugin.getGuiManager().showGUI(player, (event) -> plugin.getGuiManager().showGUI(player,
new TicketManagerGui(plugin, toModerate, event.player))); new TicketManagerGui(plugin, toModerate, event.player)));
}
if (toModerate.isOnline() && punishments) if (toModerate.isOnline() && punishments) {
setButton(32, GuiUtils.createButtonItem(CompatibleMaterial.DIAMOND_SWORD, setButton(32, GuiUtils.createButtonItem(XMaterial.DIAMOND_SWORD,
plugin.getLocale().getMessage("gui.player.punishments").getMessage()), plugin.getLocale().getMessage("gui.player.punishments").getMessage()),
(event) -> plugin.getGuiManager().showGUI(player, new PunishmentsGui(plugin, toModerate))); (event) -> plugin.getGuiManager().showGUI(player, new PunishmentsGui(plugin, toModerate)));
}
if (notes) if (notes) {
setButton(42, GuiUtils.createButtonItem(CompatibleMaterial.MAP, setButton(42, GuiUtils.createButtonItem(XMaterial.MAP,
plugin.getLocale().getMessage("gui.player.notes").getMessage()), plugin.getLocale().getMessage("gui.player.notes").getMessage()),
(event) -> plugin.getGuiManager().showGUI(player, (event) -> plugin.getGuiManager().showGUI(player,
new NotesManagerGui(plugin, toModerate, event.player))); new NotesManagerGui(plugin, toModerate, event.player)));
}
if (moderate) if (moderate) {
setButton(40, GuiUtils.createButtonItem(CompatibleMaterial.DIAMOND_CHESTPLATE, setButton(40, GuiUtils.createButtonItem(XMaterial.DIAMOND_CHESTPLATE,
plugin.getLocale().getMessage("gui.player.moderate").getMessage()), plugin.getLocale().getMessage("gui.player.moderate").getMessage()),
(event) -> guiManager.showGUI(player, new ModerateGui(plugin, toModerate, event.player))); (event) -> this.guiManager.showGUI(player, new ModerateGui(plugin, toModerate, event.player)));
}
} }
} }

View File

@ -1,17 +1,17 @@
package com.songoda.ultimatemoderation.gui; package com.songoda.ultimatemoderation.gui;
import com.songoda.core.compatibility.CompatibleMaterial; import com.craftaro.core.gui.AnvilGui;
import com.songoda.core.gui.AnvilGui; import com.craftaro.core.gui.Gui;
import com.songoda.core.gui.Gui; import com.craftaro.core.gui.GuiUtils;
import com.songoda.core.gui.GuiUtils; import com.craftaro.core.third_party.com.cryptomorin.xseries.XMaterial;
import com.songoda.core.utils.ItemUtils; import com.craftaro.core.utils.ItemUtils;
import com.songoda.core.utils.TextUtils; import com.craftaro.core.utils.TextUtils;
import com.craftaro.core.utils.TimeUtils;
import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.UltimateModeration;
import com.songoda.ultimatemoderation.punish.Punishment; import com.songoda.ultimatemoderation.punish.Punishment;
import com.songoda.ultimatemoderation.punish.PunishmentType; import com.songoda.ultimatemoderation.punish.PunishmentType;
import com.songoda.ultimatemoderation.punish.template.Template; import com.songoda.ultimatemoderation.punish.template.Template;
import com.songoda.ultimatemoderation.settings.Settings; import com.songoda.ultimatemoderation.settings.Settings;
import com.songoda.ultimatemoderation.utils.Methods;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
@ -23,7 +23,6 @@ import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList; import java.util.ArrayList;
public class PunishGui extends Gui { public class PunishGui extends Gui {
private final UltimateModeration plugin; private final UltimateModeration plugin;
private final Player player; private final Player player;
private final OfflinePlayer toModerate; private final OfflinePlayer toModerate;
@ -56,20 +55,23 @@ public class PunishGui extends Gui {
setTitle(toModerate == null ? plugin.getLocale().getMessage("gui.punish.title.template").getMessage() setTitle(toModerate == null ? plugin.getLocale().getMessage("gui.punish.title.template").getMessage()
: plugin.getLocale().getMessage("gui.punish.title") : plugin.getLocale().getMessage("gui.punish.title")
.processPlaceholder("toModerate", toModerate.getName()).getMessage()); .processPlaceholder("toModerate", toModerate.getName()).getMessage());
if (toModerate != null) runTask(); if (toModerate != null) {
runTask();
}
setOnClose((event) -> Bukkit.getScheduler().cancelTask(task)); setOnClose((event) -> Bukkit.getScheduler().cancelTask(this.task));
paint(); paint();
} }
public void paint() { public void paint() {
if (inventory != null) if (this.inventory != null) {
inventory.clear(); this.inventory.clear();
}
setActionForRange(0, 53, null); setActionForRange(0, 53, null);
// decorate the edges // decorate the edges
ItemStack glass2 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_2.getMaterial(CompatibleMaterial.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(CompatibleMaterial.LIGHT_BLUE_STAINED_GLASS_PANE)); ItemStack glass3 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_3.getMaterial(XMaterial.LIGHT_BLUE_STAINED_GLASS_PANE));
// edges will be type 3 // edges will be type 3
mirrorFill(0, 2, true, true, glass3); mirrorFill(0, 2, true, true, glass3);
@ -81,180 +83,197 @@ public class PunishGui extends Gui {
mirrorFill(2, 0, false, true, glass2); mirrorFill(2, 0, false, true, glass2);
mirrorFill(0, 1, true, true, glass2); mirrorFill(0, 1, true, true, glass2);
if (toModerate != null) if (this.toModerate != null) {
setItem(13, GuiUtils.createButtonItem(ItemUtils.getPlayerSkull(toModerate), setItem(13, GuiUtils.createButtonItem(ItemUtils.getPlayerSkull(this.toModerate),
TextUtils.formatText("&6&l" + toModerate.getName()))); TextUtils.formatText("&6&l" + this.toModerate.getName())));
}
if (player.hasPermission("um." + type.toString().toLowerCase())) if (this.player.hasPermission("um." + this.type.toString().toLowerCase())) {
setButton(22, GuiUtils.createButtonItem(CompatibleMaterial.EMERALD_BLOCK, setButton(22, GuiUtils.createButtonItem(XMaterial.EMERALD_BLOCK,
plugin.getLocale().getMessage("gui.punish.submit").getMessage()), this.plugin.getLocale().getMessage("gui.punish.submit").getMessage()),
(event) -> { (event) -> {
if (!player.hasPermission("um." + type.toString().toLowerCase())) return; if (!this.player.hasPermission("um." + this.type.toString().toLowerCase())) {
if (duration == -1 && type == PunishmentType.BAN && !player.hasPermission("um.ban.permanent"))
return; return;
}
if (this.duration == -1 && this.type == PunishmentType.BAN && !this.player.hasPermission("um.ban.permanent")) {
return;
}
if (toModerate == null) { if (this.toModerate == null) {
if (reason == null || templateName == null) return; if (this.reason == null || this.templateName == null) {
return;
}
if (template == null) if (this.template == null) {
finishTemplate(); finishTemplate();
else } else {
updateTemplate(); updateTemplate();
}
return; return;
} }
switch (type) { switch (this.type) {
case BAN: case BAN:
case MUTE: case MUTE:
case WARNING: case WARNING:
new Punishment(type, duration, reason).execute(player, toModerate); new Punishment(this.type, this.duration, this.reason).execute(this.player, this.toModerate);
break; break;
case KICK: case KICK:
new Punishment(type, reason).execute(player, toModerate); new Punishment(this.type, this.reason).execute(this.player, this.toModerate);
break; break;
} }
player.closeInventory(); this.player.closeInventory();
}); });
}
setButton(8, GuiUtils.createButtonItem(CompatibleMaterial.OAK_DOOR, setButton(8, GuiUtils.createButtonItem(XMaterial.OAK_DOOR,
plugin.getLocale().getMessage("gui.general.back").getMessage()), this.plugin.getLocale().getMessage("gui.general.back").getMessage()),
(event) -> { (event) -> {
if (toModerate != null) if (this.toModerate != null) {
guiManager.showGUI(player, new PlayerGui(plugin, toModerate, player)); this.guiManager.showGUI(this.player, new PlayerGui(this.plugin, this.toModerate, this.player));
else } else {
guiManager.showGUI(player, new TemplateManagerGui(plugin, player)); this.guiManager.showGUI(this.player, new TemplateManagerGui(this.plugin, this.player));
}
}); });
setButton(28, GuiUtils.createButtonItem(CompatibleMaterial.ANVIL, setButton(28, GuiUtils.createButtonItem(XMaterial.ANVIL,
plugin.getLocale().getMessage("gui.punish.type.punishment").getMessage(), this.plugin.getLocale().getMessage("gui.punish.type.punishment").getMessage(),
TextUtils.formatText("&7" + type.getTranslation()), TextUtils.formatText("&7" + this.type.getTranslation()),
"", "",
plugin.getLocale().getMessage("gui.punish.type.punishment.click").getMessage()), this.plugin.getLocale().getMessage("gui.punish.type.punishment.click").getMessage()),
(event) -> { (event) -> {
this.type = this.type.next(); this.type = this.type.next();
justSaved = false; this.justSaved = false;
paint(); paint();
}); });
ItemStack templateItem = toModerate != null ? GuiUtils.createButtonItem(CompatibleMaterial.MAP, ItemStack templateItem = this.toModerate != null ? GuiUtils.createButtonItem(XMaterial.MAP,
plugin.getLocale().getMessage("gui.punish.type.template").getMessage(), this.plugin.getLocale().getMessage("gui.punish.type.template").getMessage(),
plugin.getLocale().getMessage("gui.punish.type.template.current") this.plugin.getLocale().getMessage("gui.punish.type.template.current")
.processPlaceholder("template", .processPlaceholder("template",
template == null this.template == null
? plugin.getLocale().getMessage("gui.general.none").getMessage() ? this.plugin.getLocale().getMessage("gui.general.none").getMessage()
: template.getName()).getMessage(), : this.template.getName()).getMessage(),
"", "",
plugin.getLocale().getMessage(plugin.getTemplateManager().getTemplates().size() == 0 this.plugin.getLocale().getMessage(this.plugin.getTemplateManager().getTemplates().size() == 0
? "gui.punish.type.template.none" ? "gui.punish.type.template.none"
: "gui.punish.type.template.click").getMessage()) : "gui.punish.type.template.click").getMessage())
: GuiUtils.createButtonItem(CompatibleMaterial.MAP, : GuiUtils.createButtonItem(XMaterial.MAP,
plugin.getLocale().getMessage("gui.punish.type.name").getMessage(), this.plugin.getLocale().getMessage("gui.punish.type.name").getMessage(),
plugin.getLocale().getMessage("gui.punish.type.name.current") this.plugin.getLocale().getMessage("gui.punish.type.name.current")
.processPlaceholder("name", .processPlaceholder("name",
templateName == null this.templateName == null
? plugin.getLocale().getMessage("gui.punish.type.name.current").getMessage() ? this.plugin.getLocale().getMessage("gui.punish.type.name.current").getMessage()
: templateName).getMessage(), : this.templateName).getMessage(),
"", "",
plugin.getLocale().getMessage("gui.punish.type.name.current.click").getMessage()); this.plugin.getLocale().getMessage("gui.punish.type.name.current.click").getMessage());
setButton(30, templateItem, (event) -> { setButton(30, templateItem, (event) -> {
if (toModerate == null) { if (this.toModerate == null) {
nameTemplate(); nameTemplate();
return; return;
} }
if (plugin.getTemplateManager().getTemplates().size() == 0) return; if (this.plugin.getTemplateManager().getTemplates().size() == 0) {
return;
}
if (player.hasPermission("um.templates.use")) if (this.player.hasPermission("um.templates.use")) {
guiManager.showGUI(player, new TemplateSelectorGui(plugin, this, player)); this.guiManager.showGUI(this.player, new TemplateSelectorGui(this.plugin, this, this.player));
}
}); });
if (type != PunishmentType.KICK) { if (this.type != PunishmentType.KICK) {
setButton(32, GuiUtils.createButtonItem(CompatibleMaterial.CLOCK, setButton(32, GuiUtils.createButtonItem(XMaterial.CLOCK,
plugin.getLocale().getMessage("gui.punish.type.duration").getMessage(), this.plugin.getLocale().getMessage("gui.punish.type.duration").getMessage(),
plugin.getLocale().getMessage("gui.punish.type.duration.leftclick").getMessage(), this.plugin.getLocale().getMessage("gui.punish.type.duration.leftclick").getMessage(),
plugin.getLocale().getMessage("gui.punish.type.duration.rightclick").getMessage(), this.plugin.getLocale().getMessage("gui.punish.type.duration.rightclick").getMessage(),
"", "",
plugin.getLocale().getMessage("gui.punish.type.duration.current").getMessage(), this.plugin.getLocale().getMessage("gui.punish.type.duration.current").getMessage(),
TextUtils.formatText("&6" + (duration == -1 ? plugin.getLocale().getMessage("gui.general.permanent").getMessage() TextUtils.formatText("&6" + (this.duration == -1 ? this.plugin.getLocale().getMessage("gui.general.permanent").getMessage()
: Methods.makeReadable(duration)))), : TimeUtils.makeReadable(this.duration)))),
(event) -> { (event) -> {
if (this.type == PunishmentType.KICK) return; if (this.type == PunishmentType.KICK) {
return;
}
if (event.clickType == ClickType.LEFT) { if (event.clickType == ClickType.LEFT) {
AnvilGui gui = new AnvilGui(player, this); AnvilGui gui = new AnvilGui(this.player, this);
gui.setAction(evt -> { gui.setAction(evt -> {
this.duration = Methods.parseTime(gui.getInputText()); this.duration = TimeUtils.parseTime(gui.getInputText());
justSaved = false; this.justSaved = false;
guiManager.showGUI(player, this); this.guiManager.showGUI(this.player, this);
paint(); paint();
}); });
ItemStack item = new ItemStack(Material.PAPER); ItemStack item = new ItemStack(Material.PAPER);
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
meta.setDisplayName(duration == -1 || duration == 0 ? "1d 1h 1m" : Methods.makeReadable(duration)); meta.setDisplayName(this.duration == -1 || this.duration == 0 ? "1d 1h 1m" : TimeUtils.makeReadable(this.duration));
item.setItemMeta(meta); item.setItemMeta(meta);
gui.setInput(item); gui.setInput(item);
guiManager.showGUI(player, gui); this.guiManager.showGUI(this.player, gui);
} else { } else {
duration = -1; this.duration = -1;
paint(); paint();
} }
}); });
} }
setButton(34, GuiUtils.createButtonItem(CompatibleMaterial.PAPER, setButton(34, GuiUtils.createButtonItem(XMaterial.PAPER,
plugin.getLocale().getMessage("gui.punish.type.reason").getMessage(), this.plugin.getLocale().getMessage("gui.punish.type.reason").getMessage(),
plugin.getLocale().getMessage("gui.punish.type.reason.click").getMessage(), this.plugin.getLocale().getMessage("gui.punish.type.reason.click").getMessage(),
"", "",
plugin.getLocale().getMessage("gui.punish.type.reason.current").getMessage(), this.plugin.getLocale().getMessage("gui.punish.type.reason.current").getMessage(),
TextUtils.formatText("&6" + reason)), (event) -> { TextUtils.formatText("&6" + this.reason)), (event) -> {
AnvilGui gui = new AnvilGui(player, this); AnvilGui gui = new AnvilGui(this.player, this);
gui.setAction(evnt -> { gui.setAction(evnt -> {
this.reason = gui.getInputText(); this.reason = gui.getInputText();
justSaved = false; this.justSaved = false;
guiManager.showGUI(player, this); this.guiManager.showGUI(this.player, this);
paint(); paint();
}); });
ItemStack item = GuiUtils.createButtonItem(CompatibleMaterial.PAPER, ItemStack item = GuiUtils.createButtonItem(XMaterial.PAPER,
reason == null ? plugin.getLocale().getMessage("gui.general.reason").getMessage() : reason); this.reason == null ? this.plugin.getLocale().getMessage("gui.general.reason").getMessage() : this.reason);
gui.setInput(item); gui.setInput(item);
guiManager.showGUI(player, gui); this.guiManager.showGUI(this.player, gui);
}); });
} }
private void notifyTemplate() { private void notifyTemplate() {
if (reason == null || (justSaved && template != null)) { if (this.reason == null || (this.justSaved && this.template != null)) {
inventory.setItem(4, null); this.inventory.setItem(4, null);
return; return;
} }
CompatibleMaterial material = CompatibleMaterial.WHITE_WOOL; XMaterial material = XMaterial.WHITE_WOOL;
String name = plugin.getLocale().getMessage("gui.punish.template.create").getMessage(); String name = this.plugin.getLocale().getMessage("gui.punish.template.create").getMessage();
ArrayList<String> lore = new ArrayList<>(); ArrayList<String> lore = new ArrayList<>();
lore.add(plugin.getLocale().getMessage("gui.punish.template.create2").getMessage()); lore.add(this.plugin.getLocale().getMessage("gui.punish.template.create2").getMessage());
if (!justSaved && template != null) { if (!this.justSaved && this.template != null) {
name = plugin.getLocale().getMessage("gui.punish.template.leftclick").getMessage(); name = this.plugin.getLocale().getMessage("gui.punish.template.leftclick").getMessage();
lore.clear(); lore.clear();
lore.add(plugin.getLocale().getMessage("gui.punish.template.leftclick2") lore.add(this.plugin.getLocale().getMessage("gui.punish.template.leftclick2")
.processPlaceholder("template", template.getName()).getMessage()); .processPlaceholder("template", this.template.getName()).getMessage());
lore.add(""); lore.add("");
lore.add(plugin.getLocale().getMessage("gui.punish.template.rightclick").getMessage()); lore.add(this.plugin.getLocale().getMessage("gui.punish.template.rightclick").getMessage());
} }
if (getItem(4) != null && CompatibleMaterial.getMaterial(getItem(4)) == CompatibleMaterial.WHITE_WOOL) if (getItem(4) != null && XMaterial.WHITE_WOOL.isSimilar(getItem(4))) {
material = CompatibleMaterial.YELLOW_WOOL; material = XMaterial.YELLOW_WOOL;
}
setButton(4, GuiUtils.createButtonItem(material, name, lore), (event) -> { setButton(4, GuiUtils.createButtonItem(material, name, lore), (event) -> {
if (reason == null || duration == 0) return; if (this.reason == null || this.duration == 0) {
return;
}
if (template != null && event.clickType == ClickType.LEFT) { if (this.template != null && event.clickType == ClickType.LEFT) {
updateTemplate(); updateTemplate();
return; return;
} }
@ -263,51 +282,54 @@ public class PunishGui extends Gui {
} }
public void runTask() { public void runTask() {
task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, this::notifyTemplate, 10L, 10L); this.task = Bukkit.getScheduler().scheduleSyncRepeatingTask(this.plugin, this::notifyTemplate, 10L, 10L);
} }
private void nameTemplate() { private void nameTemplate() {
AnvilGui gui = new AnvilGui(player, this); AnvilGui gui = new AnvilGui(this.player, this);
gui.setAction(event -> { gui.setAction(event -> {
this.templateName = gui.getInputText(); this.templateName = gui.getInputText();
if (reason != null && templateName != null) { if (this.reason != null && this.templateName != null) {
if (template == null) if (this.template == null) {
finishTemplate(); finishTemplate();
else } else {
updateTemplate(); updateTemplate();
}
} }
justSaved = true; this.justSaved = true;
guiManager.showGUI(player, this); this.guiManager.showGUI(this.player, this);
paint(); paint();
}); });
ItemStack item = GuiUtils.createButtonItem(CompatibleMaterial.PAPER, ItemStack item = GuiUtils.createButtonItem(XMaterial.PAPER,
template == null ? plugin.getLocale().getMessage("gui.general.templatename").getMessage() : template.getName()); this.template == null ? this.plugin.getLocale().getMessage("gui.general.templatename").getMessage() : this.template.getName());
gui.setInput(item); gui.setInput(item);
guiManager.showGUI(player, gui); this.guiManager.showGUI(this.player, gui);
} }
private void updateTemplate() { private void updateTemplate() {
Template template = new Template(this.type, this.duration, this.reason, this.template.getCreator(), this.templateName); Template template = new Template(this.type, this.duration, this.reason, this.template.getCreator(), this.templateName);
plugin.getTemplateManager().removeTemplate(this.template); this.plugin.getTemplateManager().removeTemplate(this.template);
plugin.getTemplateManager().addTemplate(template); this.plugin.getTemplateManager().addTemplate(template);
plugin.getDataManager().deleteTemplate(this.template); this.plugin.getDataManager().deleteTemplate(this.template);
plugin.getDataManager().createTemplate(template); this.plugin.getDataManager().createTemplate(template);
justSaved = true; this.justSaved = true;
if (toModerate == null) if (this.toModerate == null) {
guiManager.showGUI(player, new TemplateManagerGui(plugin, player)); this.guiManager.showGUI(this.player, new TemplateManagerGui(this.plugin, this.player));
}
} }
private void finishTemplate() { private void finishTemplate() {
Template template = new Template(this.type, this.duration, this.reason, player, templateName); Template template = new Template(this.type, this.duration, this.reason, this.player, this.templateName);
plugin.getTemplateManager().addTemplate(template); this.plugin.getTemplateManager().addTemplate(template);
plugin.getDataManager().createTemplate(template); this.plugin.getDataManager().createTemplate(template);
this.template = template; this.template = template;
if (toModerate == null) if (this.toModerate == null) {
guiManager.showGUI(player, new TemplateManagerGui(plugin, player)); this.guiManager.showGUI(this.player, new TemplateManagerGui(this.plugin, this.player));
}
} }
public void setTemplate(Template template) { public void setTemplate(Template template) {

View File

@ -1,15 +1,15 @@
package com.songoda.ultimatemoderation.gui; package com.songoda.ultimatemoderation.gui;
import com.songoda.core.compatibility.CompatibleMaterial; import com.craftaro.core.gui.Gui;
import com.songoda.core.gui.Gui; import com.craftaro.core.gui.GuiUtils;
import com.songoda.core.gui.GuiUtils; import com.craftaro.core.third_party.com.cryptomorin.xseries.XMaterial;
import com.songoda.core.utils.TextUtils; import com.craftaro.core.utils.TextUtils;
import com.craftaro.core.utils.TimeUtils;
import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.UltimateModeration;
import com.songoda.ultimatemoderation.punish.AppliedPunishment; import com.songoda.ultimatemoderation.punish.AppliedPunishment;
import com.songoda.ultimatemoderation.punish.PunishmentType; import com.songoda.ultimatemoderation.punish.PunishmentType;
import com.songoda.ultimatemoderation.punish.player.PlayerPunishData; import com.songoda.ultimatemoderation.punish.player.PlayerPunishData;
import com.songoda.ultimatemoderation.settings.Settings; import com.songoda.ultimatemoderation.settings.Settings;
import com.songoda.ultimatemoderation.utils.Methods;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -19,7 +19,6 @@ import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class PunishmentsGui extends Gui { public class PunishmentsGui extends Gui {
private final UltimateModeration plugin; private final UltimateModeration plugin;
private final OfflinePlayer toModerate; private final OfflinePlayer toModerate;
@ -39,18 +38,19 @@ public class PunishmentsGui extends Gui {
} }
protected void showPage() { protected void showPage() {
if (inventory != null) if (this.inventory != null) {
inventory.clear(); this.inventory.clear();
}
setActionForRange(0, 53, null); setActionForRange(0, 53, null);
setNextPage(0, 5, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, plugin.getLocale().getMessage("gui.general.next").getMessage())); setNextPage(0, 5, GuiUtils.createButtonItem(XMaterial.ARROW, this.plugin.getLocale().getMessage("gui.general.next").getMessage()));
setPrevPage(0, 1, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, plugin.getLocale().getMessage("gui.general.back").getMessage())); setPrevPage(0, 1, GuiUtils.createButtonItem(XMaterial.ARROW, this.plugin.getLocale().getMessage("gui.general.back").getMessage()));
setOnPage((event) -> showPage()); setOnPage((event) -> showPage());
// decorate the edges // decorate the edges
ItemStack glass2 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_2.getMaterial(CompatibleMaterial.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(CompatibleMaterial.LIGHT_BLUE_STAINED_GLASS_PANE)); ItemStack glass3 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_3.getMaterial(XMaterial.LIGHT_BLUE_STAINED_GLASS_PANE));
// edges will be type 3 // edges will be type 3
mirrorFill(0, 2, true, true, glass3); mirrorFill(0, 2, true, true, glass3);
@ -61,25 +61,27 @@ public class PunishmentsGui extends Gui {
mirrorFill(1, 0, true, true, glass2); mirrorFill(1, 0, true, true, glass2);
mirrorFill(0, 1, 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<>(); 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()) { for (AppliedPunishment punishment : playerPunishData.getActivePunishments()) {
if (punishmentType != PunishmentType.ALL) { if (this.punishmentType != PunishmentType.ALL) {
if (punishment.getPunishmentType() != punishmentType) if (punishment.getPunishmentType() != this.punishmentType) {
continue; continue;
}
} }
punishments.add(new PunishmentHolder(Activity.ACTIVE, punishment)); 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()) { for (AppliedPunishment punishment : playerPunishData.getExpiredPunishments()) {
if (punishmentType != PunishmentType.ALL) { if (this.punishmentType != PunishmentType.ALL) {
if (punishment.getPunishmentType() != punishmentType) if (punishment.getPunishmentType() != this.punishmentType) {
continue; continue;
}
} }
punishments.add(new PunishmentHolder(Activity.EXPIRED, punishment)); punishments.add(new PunishmentHolder(Activity.EXPIRED, punishment));
} }
@ -88,78 +90,76 @@ public class PunishmentsGui extends Gui {
int numNotes = punishments.size(); int numNotes = punishments.size();
this.pages = (int) Math.floor(numNotes / 28.0); 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()); .collect(Collectors.toList());
setButton(5, 4, GuiUtils.createButtonItem(CompatibleMaterial.OAK_DOOR, setButton(5, 4, GuiUtils.createButtonItem(XMaterial.OAK_DOOR,
plugin.getLocale().getMessage("gui.general.back").getMessage()), this.plugin.getLocale().getMessage("gui.general.back").getMessage()),
(event) -> guiManager.showGUI(event.player, new PlayerGui(plugin, toModerate, event.player))); (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) -> { (event) -> {
this.currentActivity = currentActivity.next(); this.currentActivity = this.currentActivity.next();
this.page = 1; this.page = 1;
showPage(); 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) -> { (event) -> {
this.punishmentType = punishmentType.nextFilter(); this.punishmentType = this.punishmentType.nextFilter();
this.page = 1; this.page = 1;
showPage(); showPage();
}); });
int num = 11; int num = 11;
for (PunishmentHolder punishmentHolder : punishments) { for (PunishmentHolder punishmentHolder : punishments) {
if (num == 16 || num == 36) if (num == 16 || num == 36) {
num = num + 2; num = num + 2;
}
AppliedPunishment appliedPunishment = punishmentHolder.getAppliedPunishment(); AppliedPunishment appliedPunishment = punishmentHolder.getAppliedPunishment();
Activity activity = punishmentHolder.getActivity(); Activity activity = punishmentHolder.getActivity();
ArrayList<String> lore = new ArrayList<>(); ArrayList<String> lore = new ArrayList<>();
lore.add(""); lore.add("");
lore.add(plugin.getLocale().getMessage("gui.punishments.reason").getMessage()); lore.add(this.plugin.getLocale().getMessage("gui.punishments.reason").getMessage());
lore.add("&7" + appliedPunishment.getReason()); lore.add("&7" + appliedPunishment.getReason());
if (appliedPunishment.getPunishmentType() != PunishmentType.KICK) { if (appliedPunishment.getPunishmentType() != PunishmentType.KICK) {
lore.add(""); lore.add("");
lore.add(plugin.getLocale().getMessage("gui.punishments.duration").getMessage()); lore.add(this.plugin.getLocale().getMessage("gui.punishments.duration").getMessage());
lore.add("&7" + (appliedPunishment.getDuration() != -1 lore.add("&7" + (appliedPunishment.getDuration() != -1
? Methods.makeReadable(appliedPunishment.getDuration()) ? TimeUtils.makeReadable(appliedPunishment.getDuration())
: plugin.getLocale().getMessage("gui.general.permanent").getMessage())); : this.plugin.getLocale().getMessage("gui.general.permanent").getMessage()));
lore.add(""); lore.add("");
lore.add(plugin.getLocale().getMessage("gui.punishments.punisher").getMessage()); lore.add(this.plugin.getLocale().getMessage("gui.punishments.punisher").getMessage());
lore.add("&7" + (appliedPunishment.getPunisher() == null ? "Console" : Bukkit.getOfflinePlayer(appliedPunishment.getPunisher()).getName())); lore.add("&7" + (appliedPunishment.getPunisher() == null ? "Console" : Bukkit.getOfflinePlayer(appliedPunishment.getPunisher()).getName()));
if (activity == Activity.ACTIVE) { if (activity == Activity.ACTIVE) {
lore.add(""); lore.add("");
if (appliedPunishment.getDuration() != -1) { if (appliedPunishment.getDuration() != -1) {
lore.add(plugin.getLocale().getMessage("gui.punishments.remaining").getMessage()); lore.add(this.plugin.getLocale().getMessage("gui.punishments.remaining").getMessage());
lore.add("&7" + Methods.makeReadable(appliedPunishment.getTimeRemaining())); lore.add("&7" + TimeUtils.makeReadable(appliedPunishment.getTimeRemaining()));
lore.add(""); lore.add("");
} }
lore.add(plugin.getLocale().getMessage("gui.punishments.click").getMessage()); lore.add(this.plugin.getLocale().getMessage("gui.punishments.click").getMessage());
} }
} }
lore.add(""); lore.add("");
setButton(num, GuiUtils.createButtonItem(CompatibleMaterial.MAP, setButton(num, GuiUtils.createButtonItem(XMaterial.MAP,
TextUtils.formatText("&6&l" + appliedPunishment.getPunishmentType().getTranslation() + " - &7&l" + activity.getTranslation()), TextUtils.formatText("&6&l" + appliedPunishment.getPunishmentType().getTranslation() + " - &7&l" + activity.getTranslation()),
TextUtils.formatText(lore)), TextUtils.formatText(lore)),
(event) -> { (event) -> {
if (appliedPunishment.getPunishmentType() != PunishmentType.KICK if (appliedPunishment.getPunishmentType() != PunishmentType.KICK
&& activity == Activity.ACTIVE) { && activity == Activity.ACTIVE) {
appliedPunishment.expire(); appliedPunishment.expire();
plugin.getDataManager().updateAppliedPunishment(appliedPunishment); this.plugin.getDataManager().updateAppliedPunishment(appliedPunishment);
showPage(); showPage();
} }
}); });
num++; num++;
} }
} }
private static class PunishmentHolder {
private class PunishmentHolder {
private final Activity activity; private final Activity activity;
private final AppliedPunishment appliedPunishment; private final AppliedPunishment appliedPunishment;
@ -169,26 +169,26 @@ public class PunishmentsGui extends Gui {
} }
public Activity getActivity() { public Activity getActivity() {
return activity; return this.activity;
} }
public AppliedPunishment getAppliedPunishment() { public AppliedPunishment getAppliedPunishment() {
return appliedPunishment; return this.appliedPunishment;
} }
} }
private enum Activity { private enum Activity {
BOTH, ACTIVE, EXPIRED; BOTH, ACTIVE, EXPIRED;
private static Activity[] vals = values();
public Activity next() { 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() { 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())
.getMessage();
} }
} }
} }

View File

@ -1,14 +1,13 @@
package com.songoda.ultimatemoderation.gui; package com.songoda.ultimatemoderation.gui;
import com.songoda.core.compatibility.CompatibleMaterial; import com.craftaro.core.gui.Gui;
import com.songoda.core.gui.Gui; import com.craftaro.core.gui.GuiUtils;
import com.songoda.core.gui.GuiUtils; import com.craftaro.core.third_party.com.cryptomorin.xseries.XMaterial;
import com.songoda.core.utils.TextUtils; import com.craftaro.core.utils.TextUtils;
import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.UltimateModeration;
import com.songoda.ultimatemoderation.punish.PunishmentType; import com.songoda.ultimatemoderation.punish.PunishmentType;
import com.songoda.ultimatemoderation.punish.template.Template; import com.songoda.ultimatemoderation.punish.template.Template;
import com.songoda.ultimatemoderation.settings.Settings; import com.songoda.ultimatemoderation.settings.Settings;
import com.songoda.ultimatemoderation.utils.Methods;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType; import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -17,7 +16,6 @@ import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class TemplateManagerGui extends Gui { public class TemplateManagerGui extends Gui {
private final UltimateModeration plugin; private final UltimateModeration plugin;
private PunishmentType punishmentType = PunishmentType.ALL; private PunishmentType punishmentType = PunishmentType.ALL;
@ -52,18 +50,18 @@ public class TemplateManagerGui extends Gui {
} }
private void toCurrentPage() { private void toCurrentPage() {
if (inventory != null) { if (this.inventory != null) {
inventory.clear(); this.inventory.clear();
} }
setActionForRange(0, 53, null); setActionForRange(0, 53, null);
int numTemplates = plugin.getTemplateManager().getTemplates().size(); int numTemplates = this.plugin.getTemplateManager().getTemplates().size();
this.pages = (int) Math.floor(numTemplates / 28.0); this.pages = (int) Math.floor(numTemplates / 28.0);
// decorate the edges // decorate the edges
ItemStack glass2 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_2.getMaterial(CompatibleMaterial.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(CompatibleMaterial.LIGHT_BLUE_STAINED_GLASS_PANE)); ItemStack glass3 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_3.getMaterial(XMaterial.LIGHT_BLUE_STAINED_GLASS_PANE));
// edges will be type 3 // edges will be type 3
mirrorFill(0, 2, true, true, glass3); mirrorFill(0, 2, true, true, glass3);
@ -74,21 +72,21 @@ public class TemplateManagerGui extends Gui {
mirrorFill(1, 0, true, true, glass2); mirrorFill(1, 0, true, true, glass2);
mirrorFill(0, 1, true, true, glass2); mirrorFill(0, 1, true, true, glass2);
setButton(5, 3, GuiUtils.createButtonItem(CompatibleMaterial.DIAMOND_SWORD, Methods.formatText("&6" + punishmentType.name())), setButton(5, 3, GuiUtils.createButtonItem(XMaterial.DIAMOND_SWORD, TextUtils.formatText("&6" + this.punishmentType.name())),
(event) -> { (event) -> {
this.punishmentType = punishmentType.nextFilter(); this.punishmentType = this.punishmentType.nextFilter();
this.page = 1; this.page = 1;
toCurrentPage(); toCurrentPage();
}); });
setButton(5, 4, GuiUtils.createButtonItem(CompatibleMaterial.OAK_DOOR, setButton(5, 4, GuiUtils.createButtonItem(XMaterial.OAK_DOOR,
plugin.getLocale().getMessage("gui.general.back").getMessage()), this.plugin.getLocale().getMessage("gui.general.back").getMessage()),
(event) -> guiManager.showGUI(event.player, new MainGui(plugin, event.player))); (event) -> this.guiManager.showGUI(event.player, new MainGui(this.plugin, event.player)));
if (player.hasPermission("um.templates.create")) { if (this.player.hasPermission("um.templates.create")) {
setButton(5, 5, GuiUtils.createButtonItem(CompatibleMaterial.REDSTONE, setButton(5, 5, GuiUtils.createButtonItem(XMaterial.REDSTONE,
plugin.getLocale().getMessage("gui.templatemanager.create").getMessage()), this.plugin.getLocale().getMessage("gui.templatemanager.create").getMessage()),
(event) -> guiManager.showGUI(event.player, new PunishGui(plugin, null, null, player))); (event) -> this.guiManager.showGUI(event.player, new PunishGui(this.plugin, null, null, this.player)));
} }
List<Template> templates = findTemplates(this.page, this.punishmentType); List<Template> templates = findTemplates(this.page, this.punishmentType);
@ -99,17 +97,17 @@ public class TemplateManagerGui extends Gui {
num = num + 2; num = num + 2;
} }
setButton(num, GuiUtils.createButtonItem(CompatibleMaterial.MAP, TextUtils.formatText("&6&l" + template.getName()), setButton(num, GuiUtils.createButtonItem(XMaterial.MAP, TextUtils.formatText("&6&l" + template.getName()),
plugin.getLocale().getMessage("gui.templatemanager.leftclick").getMessage(), this.plugin.getLocale().getMessage("gui.templatemanager.leftclick").getMessage(),
plugin.getLocale().getMessage("gui.templatemanager.rightclick").getMessage()), this.plugin.getLocale().getMessage("gui.templatemanager.rightclick").getMessage()),
(event) -> { (event) -> {
if (event.clickType == ClickType.LEFT) { if (event.clickType == ClickType.LEFT) {
if (player.hasPermission("um.templates.edit")) if (this.player.hasPermission("um.templates.edit"))
guiManager.showGUI(player, new PunishGui(plugin, null, template, player)); this.guiManager.showGUI(this.player, new PunishGui(this.plugin, null, template, this.player));
} else if (event.clickType == ClickType.RIGHT) { } else if (event.clickType == ClickType.RIGHT) {
if (player.hasPermission("um.templates.destroy")) { if (this.player.hasPermission("um.templates.destroy")) {
plugin.getTemplateManager().removeTemplate(template); this.plugin.getTemplateManager().removeTemplate(template);
plugin.getDataManager().deleteTemplate(template); this.plugin.getDataManager().deleteTemplate(template);
} }
toCurrentPage(); toCurrentPage();
@ -119,12 +117,12 @@ public class TemplateManagerGui extends Gui {
++num; ++num;
} }
setButton(0, 3, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, plugin.getLocale().getMessage("gui.general.back").getMessage()), (event) -> toPrevPage()); setButton(0, 3, GuiUtils.createButtonItem(XMaterial.ARROW, this.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()); 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) { private List<Template> findTemplates(int page, PunishmentType punishmentType) {
return plugin.getTemplateManager().getTemplates().stream() return this.plugin.getTemplateManager().getTemplates().stream()
.filter(template -> punishmentType == PunishmentType.ALL || template.getPunishmentType() == punishmentType) .filter(template -> punishmentType == PunishmentType.ALL || template.getPunishmentType() == punishmentType)
.skip((page - 1) * 28L) .skip((page - 1) * 28L)
.limit(28) .limit(28)

View File

@ -1,9 +1,9 @@
package com.songoda.ultimatemoderation.gui; package com.songoda.ultimatemoderation.gui;
import com.songoda.core.compatibility.CompatibleMaterial; import com.craftaro.core.gui.Gui;
import com.songoda.core.gui.Gui; import com.craftaro.core.gui.GuiUtils;
import com.songoda.core.gui.GuiUtils; import com.craftaro.core.third_party.com.cryptomorin.xseries.XMaterial;
import com.songoda.core.utils.TextUtils; import com.craftaro.core.utils.TextUtils;
import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.UltimateModeration;
import com.songoda.ultimatemoderation.punish.template.Template; import com.songoda.ultimatemoderation.punish.template.Template;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -11,7 +11,6 @@ import org.bukkit.entity.Player;
import java.util.ArrayList; import java.util.ArrayList;
public class TemplateSelectorGui extends Gui { public class TemplateSelectorGui extends Gui {
private final UltimateModeration plugin; private final UltimateModeration plugin;
private final PunishGui punish; private final PunishGui punish;
@ -26,28 +25,27 @@ public class TemplateSelectorGui extends Gui {
} }
private void paint() { private void paint() {
setButton(8, GuiUtils.createButtonItem(CompatibleMaterial.OAK_DOOR, setButton(8, GuiUtils.createButtonItem(XMaterial.OAK_DOOR,
plugin.getLocale().getMessage("gui.general.back").getMessage()), this.plugin.getLocale().getMessage("gui.general.back").getMessage()),
(event) -> { (event) -> {
guiManager.showGUI(event.player, punish); this.guiManager.showGUI(event.player, this.punish);
punish.runTask(); this.punish.runTask();
}); });
ArrayList<Template> templates = new ArrayList<>(plugin.getTemplateManager().getTemplates()); ArrayList<Template> templates = new ArrayList<>(this.plugin.getTemplateManager().getTemplates());
for (int i = 0; i < templates.size(); i++) { for (int i = 0; i < templates.size(); i++) {
Template template = templates.get(i); Template template = templates.get(i);
setButton(18 + i, GuiUtils.createButtonItem(CompatibleMaterial.MAP, TextUtils.formatText("&6&l" + template.getName()), setButton(18 + i, GuiUtils.createButtonItem(XMaterial.MAP, TextUtils.formatText("&6&l" + template.getName()),
plugin.getLocale().getMessage("gui.templateselector.click").getMessage()), this.plugin.getLocale().getMessage("gui.templateselector.click").getMessage()),
(event) -> { (event) -> {
punish.setType(template.getPunishmentType()); this.punish.setType(template.getPunishmentType());
punish.setDuration(template.getDuration()); this.punish.setDuration(template.getDuration());
punish.setReason(template.getReason()); this.punish.setReason(template.getReason());
punish.setTemplate(template); this.punish.setTemplate(template);
punish.runTask(); this.punish.runTask();
punish.paint(); this.punish.paint();
guiManager.showGUI(event.player, punish); this.guiManager.showGUI(event.player, this.punish);
}); });
} }
} }
} }

View File

@ -1,10 +1,10 @@
package com.songoda.ultimatemoderation.gui; package com.songoda.ultimatemoderation.gui;
import com.songoda.core.compatibility.CompatibleMaterial; import com.craftaro.core.gui.Gui;
import com.songoda.core.gui.Gui; import com.craftaro.core.gui.GuiUtils;
import com.songoda.core.gui.GuiUtils; import com.craftaro.core.input.ChatPrompt;
import com.songoda.core.input.ChatPrompt; import com.craftaro.core.third_party.com.cryptomorin.xseries.XMaterial;
import com.songoda.core.utils.TextUtils; import com.craftaro.core.utils.TextUtils;
import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.UltimateModeration;
import com.songoda.ultimatemoderation.settings.Settings; import com.songoda.ultimatemoderation.settings.Settings;
import com.songoda.ultimatemoderation.staffchat.StaffChatManager; import com.songoda.ultimatemoderation.staffchat.StaffChatManager;
@ -23,9 +23,8 @@ import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class TicketGui extends Gui { public class TicketGui extends Gui {
private final UltimateModeration plugin; private final UltimateModeration plugin;
private final StaffChatManager chatManager = UltimateModeration.getInstance().getStaffChatManager(); private final StaffChatManager chatManager;
private final Ticket ticket; private final Ticket ticket;
@ -38,6 +37,7 @@ public class TicketGui extends Gui {
setDefaultItem(null); setDefaultItem(null);
this.ticket = ticket; this.ticket = ticket;
this.plugin = plugin; this.plugin = plugin;
this.chatManager = plugin.getStaffChatManager();
this.player = player; this.player = player;
this.toModerate = toModerate; this.toModerate = toModerate;
@ -49,19 +49,20 @@ public class TicketGui extends Gui {
} }
private void showPage() { private void showPage() {
if (inventory != null) if (this.inventory != null) {
inventory.clear(); this.inventory.clear();
}
setActionForRange(0, 53, null); setActionForRange(0, 53, null);
int numNotes = ticket.getResponses().size(); int numNotes = this.ticket.getResponses().size();
this.pages = (int) Math.floor(numNotes / 28.0); this.pages = (int) Math.floor(numNotes / 28.0);
List<TicketResponse> responses = ticket.getResponses().stream().skip((page - 1) * 28).limit(28) List<TicketResponse> responses = this.ticket.getResponses().stream().skip((this.page - 1) * 28).limit(28)
.collect(Collectors.toList()); .collect(Collectors.toList());
// decorate the edges // decorate the edges
ItemStack glass2 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_2.getMaterial(CompatibleMaterial.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(CompatibleMaterial.LIGHT_BLUE_STAINED_GLASS_PANE)); ItemStack glass3 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_3.getMaterial(XMaterial.LIGHT_BLUE_STAINED_GLASS_PANE));
// edges will be type 3 // edges will be type 3
mirrorFill(0, 2, true, true, glass3); mirrorFill(0, 2, true, true, glass3);
@ -73,56 +74,61 @@ public class TicketGui extends Gui {
mirrorFill(0, 1, true, true, glass2); mirrorFill(0, 1, true, true, glass2);
// enable page event // enable page event
setNextPage(4, 7, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, plugin.getLocale().getMessage("gui.general.next").getMessage())); setNextPage(4, 7, GuiUtils.createButtonItem(XMaterial.ARROW, this.plugin.getLocale().getMessage("gui.general.next").getMessage()));
setPrevPage(4, 1, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, plugin.getLocale().getMessage("gui.general.back").getMessage())); setPrevPage(4, 1, GuiUtils.createButtonItem(XMaterial.ARROW, this.plugin.getLocale().getMessage("gui.general.back").getMessage()));
setOnPage((event) -> showPage()); setOnPage((event) -> showPage());
if (player.hasPermission("um.tickets.openclose")) if (this.player.hasPermission("um.tickets.openclose")) {
setButton(5, 3, GuiUtils.createButtonItem(CompatibleMaterial.LEVER, TextUtils.formatText("&6" + ticket.getStatus().getStatus())), setButton(5, 3, GuiUtils.createButtonItem(XMaterial.LEVER, TextUtils.formatText("&6" + this.ticket.getStatus().getStatus())),
(event) -> { (event) -> {
ticket.setStatus(ticket.getStatus() == TicketStatus.OPEN ? TicketStatus.CLOSED : TicketStatus.OPEN); this.ticket.setStatus(this.ticket.getStatus() == TicketStatus.OPEN ? TicketStatus.CLOSED : TicketStatus.OPEN);
plugin.getDataManager().updateTicket(ticket); this.plugin.getDataManager().updateTicket(this.ticket);
// Notify staff of ticket status // 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())); this.chatManager.getChat("ticket").messageAll(this.plugin.getLocale().getMessage("notify.ticket.status").getMessage().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(); showPage();
}); });
}
setButton(4, GuiUtils.createButtonItem(CompatibleMaterial.OAK_DOOR, setButton(4, GuiUtils.createButtonItem(XMaterial.OAK_DOOR,
plugin.getLocale().getMessage("gui.general.back").getMessage()), this.plugin.getLocale().getMessage("gui.general.back").getMessage()),
(event) -> { (event) -> {
plugin.getGuiManager().showGUI(event.player, new TicketManagerGui(plugin, toModerate, event.player)); this.plugin.getGuiManager().showGUI(event.player, new TicketManagerGui(this.plugin, this.toModerate, event.player));
}); });
if (player.hasPermission("um.ticket.clicktotele") && ticket.getLocation() != null) if (this.player.hasPermission("um.ticket.clicktotele") && this.ticket.getLocation() != null) {
setButton(5, 5, GuiUtils.createButtonItem(CompatibleMaterial.ENDER_PEARL, setButton(5, 5, GuiUtils.createButtonItem(XMaterial.ENDER_PEARL,
plugin.getLocale().getMessage("gui.ticket.clicktotele").getMessage()), this.plugin.getLocale().getMessage("gui.ticket.clicktotele").getMessage()),
(event) -> player.teleport(ticket.getLocation())); (event) -> this.player.teleport(this.ticket.getLocation()));
}
if (player.hasPermission("um.tickets.respond")) if (this.player.hasPermission("um.tickets.respond")) {
setButton(5, 4, GuiUtils.createButtonItem(CompatibleMaterial.WRITABLE_BOOK, plugin.getLocale().getMessage("gui.ticket.respond").getMessage()), setButton(5, 4, GuiUtils.createButtonItem(XMaterial.WRITABLE_BOOK, this.plugin.getLocale().getMessage("gui.ticket.respond").getMessage()),
(event) -> { (event) -> {
ChatPrompt.showPrompt(plugin, player, plugin.getLocale().getMessage("gui.ticket.what").getMessage(), (evnt) -> { ChatPrompt.showPrompt(this.plugin, this.player, this.plugin.getLocale().getMessage("gui.ticket.what").getMessage(), (evnt) -> {
TicketResponse response = ticket.addResponse(new TicketResponse(player, evnt.getMessage(), System.currentTimeMillis())); TicketResponse response = this.ticket.addResponse(new TicketResponse(this.player, evnt.getMessage(), System.currentTimeMillis()));
plugin.getDataManager().createTicketResponse(response); this.plugin.getDataManager().createTicketResponse(response);
// Notify staff of ticket 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())); this.chatManager.getChat("ticket").messageAll(this.plugin.getLocale().getMessage("notify.ticket.response").getMessage().replace("%tid%", "" + this.ticket.getId()).replace("%type%", this.ticket.getType()).replace("%player%", Bukkit.getPlayer(this.ticket.getVictim()).getDisplayName()));
showPage(); showPage();
}).setOnClose(() -> guiManager.showGUI(event.player, this)); }).setOnClose(() -> this.guiManager.showGUI(event.player, this));
}); });
}
int num = 11; int num = 11;
for (TicketResponse ticketResponse : responses) { for (TicketResponse ticketResponse : responses) {
if (num == 16 || num == 36) if (num == 16 || num == 36) {
num = num + 2; num = num + 2;
}
String subjectStr = ticketResponse.getMessage(); String subjectStr = ticketResponse.getMessage();
ArrayList<String> lore = new ArrayList<>(); ArrayList<String> lore = new ArrayList<>();
int lastIndex = 0; int lastIndex = 0;
for (int n = 0; n < subjectStr.length(); n++) { for (int n = 0; n < subjectStr.length(); n++) {
if (n - lastIndex < 20) if (n - lastIndex < 20) {
continue; continue;
}
if (subjectStr.charAt(n) == ' ') { if (subjectStr.charAt(n) == ' ') {
lore.add(TextUtils.formatText("&6" + subjectStr.substring(lastIndex, n).trim())); lore.add(TextUtils.formatText("&6" + subjectStr.substring(lastIndex, n).trim()));
@ -130,8 +136,9 @@ public class TicketGui extends Gui {
} }
} }
if (lastIndex - subjectStr.length() < 20) if (lastIndex - subjectStr.length() < 20) {
lore.add(TextUtils.formatText("&6" + subjectStr.substring(lastIndex).trim())); lore.add(TextUtils.formatText("&6" + subjectStr.substring(lastIndex).trim()));
}
String name = lore.get(0); String name = lore.get(0);
lore.remove(0); lore.remove(0);
@ -141,12 +148,12 @@ public class TicketGui extends Gui {
SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy"); SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy");
lore.add(plugin.getLocale().getMessage("gui.ticket.postedby") lore.add(this.plugin.getLocale().getMessage("gui.ticket.postedby")
.processPlaceholder("player", Bukkit.getOfflinePlayer(ticketResponse.getAuthor()).getName()).getMessage()); .processPlaceholder("player", Bukkit.getOfflinePlayer(ticketResponse.getAuthor()).getName()).getMessage());
lore.add(plugin.getLocale().getMessage("gui.ticket.createdon") lore.add(this.plugin.getLocale().getMessage("gui.ticket.createdon")
.processPlaceholder("sent", format.format(new Date(ticketResponse.getPostedDate()))).getMessage()); .processPlaceholder("sent", format.format(new Date(ticketResponse.getPostedDate()))).getMessage());
setItem(num, GuiUtils.createButtonItem(CompatibleMaterial.MAP, TextUtils.formatText(name), lore)); setItem(num, GuiUtils.createButtonItem(XMaterial.MAP, TextUtils.formatText(name), lore));
num++; num++;
} }
} }

View File

@ -1,10 +1,10 @@
package com.songoda.ultimatemoderation.gui; package com.songoda.ultimatemoderation.gui;
import com.songoda.core.compatibility.CompatibleMaterial; import com.craftaro.core.gui.AnvilGui;
import com.songoda.core.gui.AnvilGui; import com.craftaro.core.gui.Gui;
import com.songoda.core.gui.Gui; import com.craftaro.core.gui.GuiUtils;
import com.songoda.core.gui.GuiUtils; import com.craftaro.core.third_party.com.cryptomorin.xseries.XMaterial;
import com.songoda.core.utils.TextUtils; import com.craftaro.core.utils.TextUtils;
import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.UltimateModeration;
import com.songoda.ultimatemoderation.settings.Settings; import com.songoda.ultimatemoderation.settings.Settings;
import com.songoda.ultimatemoderation.tickets.Ticket; import com.songoda.ultimatemoderation.tickets.Ticket;
@ -22,7 +22,6 @@ import java.util.stream.Collectors;
// FIXME: Pagination not working (probably in other GUIs too) (copy own one from TemplateManagerGui) // FIXME: Pagination not working (probably in other GUIs too) (copy own one from TemplateManagerGui)
public class TicketManagerGui extends Gui { public class TicketManagerGui extends Gui {
private final UltimateModeration plugin; private final UltimateModeration plugin;
private final OfflinePlayer toModerate; private final OfflinePlayer toModerate;
@ -44,22 +43,23 @@ public class TicketManagerGui extends Gui {
} }
private void showPage() { private void showPage() {
if (inventory != null) if (this.inventory != null) {
inventory.clear(); this.inventory.clear();
}
setActionForRange(0, 53, null); setActionForRange(0, 53, null);
List<Ticket> tickets = toModerate != null List<Ticket> tickets = this.toModerate != null
? plugin.getTicketManager().getTicketsAbout(toModerate, status) ? this.plugin.getTicketManager().getTicketsAbout(this.toModerate, this.status)
: plugin.getTicketManager().getTickets(status); : this.plugin.getTicketManager().getTickets(this.status);
int numTickets = tickets.size(); int numTickets = tickets.size();
this.pages = (int) Math.floor(numTickets / 28.0); this.pages = (int) Math.floor(numTickets / 28.0);
tickets = tickets.stream().skip((page - 1) * 28).limit(28).collect(Collectors.toList()); tickets = tickets.stream().skip((this.page - 1) * 28).limit(28).collect(Collectors.toList());
// decorate the edges // decorate the edges
ItemStack glass2 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_2.getMaterial(CompatibleMaterial.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(CompatibleMaterial.LIGHT_BLUE_STAINED_GLASS_PANE)); ItemStack glass3 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_3.getMaterial(XMaterial.LIGHT_BLUE_STAINED_GLASS_PANE));
// edges will be type 3 // edges will be type 3
mirrorFill(0, 2, true, true, glass3); mirrorFill(0, 2, true, true, glass3);
@ -71,44 +71,49 @@ public class TicketManagerGui extends Gui {
mirrorFill(0, 1, true, true, glass2); mirrorFill(0, 1, true, true, glass2);
// enable page event // enable page event
setNextPage(4, 7, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, plugin.getLocale().getMessage("gui.general.next").getMessage())); setNextPage(4, 7, GuiUtils.createButtonItem(XMaterial.ARROW, this.plugin.getLocale().getMessage("gui.general.next").getMessage()));
setPrevPage(4, 1, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, plugin.getLocale().getMessage("gui.general.back").getMessage())); setPrevPage(4, 1, GuiUtils.createButtonItem(XMaterial.ARROW, this.plugin.getLocale().getMessage("gui.general.back").getMessage()));
setOnPage((event) -> showPage()); setOnPage((event) -> showPage());
setButton(5, 3, GuiUtils.createButtonItem(CompatibleMaterial.LEVER, TextUtils.formatText("&6" + status.getStatus())), setButton(5, 3, GuiUtils.createButtonItem(XMaterial.LEVER, TextUtils.formatText("&6" + this.status.getStatus())),
(event) -> { (event) -> {
this.status = status == TicketStatus.OPEN ? TicketStatus.CLOSED : TicketStatus.OPEN; this.status = this.status == TicketStatus.OPEN ? TicketStatus.CLOSED : TicketStatus.OPEN;
this.page = 1; this.page = 1;
showPage(); showPage();
}); });
if (toModerate != null && player.hasPermission("um.tickets.create")) if (this.toModerate != null && this.player.hasPermission("um.tickets.create")) {
setButton(5, 5, GuiUtils.createButtonItem(CompatibleMaterial.REDSTONE, setButton(5, 5, GuiUtils.createButtonItem(XMaterial.REDSTONE,
plugin.getLocale().getMessage("gui.tickets.create").getMessage()), this.plugin.getLocale().getMessage("gui.tickets.create").getMessage()),
(event) -> createNew(player, toModerate)); (event) -> createNew(this.player, this.toModerate));
}
if (player.hasPermission("um.ticket")) if (this.player.hasPermission("um.ticket")) {
setButton(5, 4, GuiUtils.createButtonItem(CompatibleMaterial.OAK_DOOR, setButton(5, 4, GuiUtils.createButtonItem(XMaterial.OAK_DOOR,
plugin.getLocale().getMessage("gui.general.back").getMessage()), this.plugin.getLocale().getMessage("gui.general.back").getMessage()),
(event) -> { (event) -> {
if (toModerate == null) if (this.toModerate == null) {
plugin.getGuiManager().showGUI(player, new MainGui(plugin, player)); this.plugin.getGuiManager().showGUI(this.player, new MainGui(this.plugin, this.player));
else } else {
plugin.getGuiManager().showGUI(event.player, new PlayerGui(plugin, toModerate, event.player)); this.plugin.getGuiManager().showGUI(event.player, new PlayerGui(this.plugin, this.toModerate, event.player));
}
}); });
}
int num = 11; int num = 11;
for (Ticket ticket : tickets) { for (Ticket ticket : tickets) {
if (num == 16 || num == 36) if (num == 16 || num == 36) {
num = num + 2; num = num + 2;
}
String subjectStr = ticket.getSubject(); String subjectStr = ticket.getSubject();
ArrayList<String> lore = new ArrayList<>(); ArrayList<String> lore = new ArrayList<>();
int lastIndex = 0; int lastIndex = 0;
for (int n = 0; n < subjectStr.length(); n++) { for (int n = 0; n < subjectStr.length(); n++) {
if (n - lastIndex < 20) if (n - lastIndex < 20) {
continue; continue;
}
if (subjectStr.charAt(n) == ' ') { if (subjectStr.charAt(n) == ' ') {
lore.add("&6" + subjectStr.substring(lastIndex, n).trim()); lore.add("&6" + subjectStr.substring(lastIndex, n).trim());
@ -116,8 +121,9 @@ public class TicketManagerGui extends Gui {
} }
} }
if (lastIndex - subjectStr.length() < 20) if (lastIndex - subjectStr.length() < 20) {
lore.add("&6" + subjectStr.substring(lastIndex).trim() + " &7- " + ticket.getId()); lore.add("&6" + subjectStr.substring(lastIndex).trim() + " &7- " + ticket.getId());
}
String name = lore.get(0); String name = lore.get(0);
lore.remove(0); lore.remove(0);
@ -126,27 +132,28 @@ public class TicketManagerGui extends Gui {
SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy"); SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy");
lore.add(plugin.getLocale().getMessage("gui.ticket.status") lore.add(this.plugin.getLocale().getMessage("gui.ticket.status")
.processPlaceholder("status", ticket.getStatus().getStatus()).getMessage()); .processPlaceholder("status", ticket.getStatus().getStatus()).getMessage());
if (toModerate != null) if (this.toModerate != null) {
lore.add(plugin.getLocale().getMessage("gui.tickets.player") lore.add(this.plugin.getLocale().getMessage("gui.tickets.player")
.processPlaceholder("player", Bukkit.getOfflinePlayer(ticket.getVictim()).getName()).getMessage()); .processPlaceholder("player", Bukkit.getOfflinePlayer(ticket.getVictim()).getName()).getMessage());
lore.add(plugin.getLocale().getMessage("gui.ticket.type") }
lore.add(this.plugin.getLocale().getMessage("gui.ticket.type")
.processPlaceholder("type", ticket.getType()).getMessage()); .processPlaceholder("type", ticket.getType()).getMessage());
lore.add(plugin.getLocale().getMessage("gui.ticket.createdon") lore.add(this.plugin.getLocale().getMessage("gui.ticket.createdon")
.processPlaceholder("sent", format.format(new Date(ticket.getCreationDate()))).getMessage()); .processPlaceholder("sent", format.format(new Date(ticket.getCreationDate()))).getMessage());
lore.add(plugin.getLocale().getMessage("gui.tickets.click").getMessage()); lore.add(this.plugin.getLocale().getMessage("gui.tickets.click").getMessage());
setButton(num, GuiUtils.createButtonItem(CompatibleMaterial.MAP, setButton(num, GuiUtils.createButtonItem(XMaterial.MAP,
TextUtils.formatText(name), TextUtils.formatText(lore)), TextUtils.formatText(name), TextUtils.formatText(lore)),
(event) -> guiManager.showGUI(player, new TicketGui(plugin, ticket, toModerate, player))); (event) -> this.guiManager.showGUI(this.player, new TicketGui(this.plugin, ticket, this.toModerate, this.player)));
num++; num++;
} }
} }
public static void createNew(Player player, OfflinePlayer toModerate) { public static void createNew(Player player, OfflinePlayer toModerate) {
UltimateModeration plugin = UltimateModeration.getInstance(); UltimateModeration plugin = UltimateModeration.getPlugin(UltimateModeration.class);
AnvilGui gui = new AnvilGui(player); AnvilGui gui = new AnvilGui(player);
gui.setAction((event) -> gui.setAction((event) ->
@ -154,7 +161,7 @@ public class TicketManagerGui extends Gui {
plugin.getGuiManager().showGUI(player, plugin.getGuiManager().showGUI(player,
new TicketTypeGui(plugin, toModerate, player, gui.getInputText())), 1L)); new TicketTypeGui(plugin, toModerate, player, gui.getInputText())), 1L));
ItemStack item = GuiUtils.createButtonItem(CompatibleMaterial.PAPER, ItemStack item = GuiUtils.createButtonItem(XMaterial.PAPER,
plugin.getLocale().getMessage("gui.tickets.subject").getMessage()); plugin.getLocale().getMessage("gui.tickets.subject").getMessage());
gui.setInput(item); gui.setInput(item);

View File

@ -1,9 +1,9 @@
package com.songoda.ultimatemoderation.gui; package com.songoda.ultimatemoderation.gui;
import com.songoda.core.compatibility.CompatibleMaterial; import com.craftaro.core.gui.Gui;
import com.songoda.core.gui.Gui; import com.craftaro.core.gui.GuiUtils;
import com.songoda.core.gui.GuiUtils; import com.craftaro.core.input.ChatPrompt;
import com.songoda.core.input.ChatPrompt; import com.craftaro.core.third_party.com.cryptomorin.xseries.XMaterial;
import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.UltimateModeration;
import com.songoda.ultimatemoderation.settings.Settings; import com.songoda.ultimatemoderation.settings.Settings;
import com.songoda.ultimatemoderation.staffchat.StaffChatManager; import com.songoda.ultimatemoderation.staffchat.StaffChatManager;
@ -16,21 +16,20 @@ import org.bukkit.entity.Player;
import java.util.List; import java.util.List;
public class TicketTypeGui extends Gui { public class TicketTypeGui extends Gui {
private final StaffChatManager chatManager;
private final StaffChatManager chatManager = UltimateModeration.getInstance().getStaffChatManager();
public TicketTypeGui(UltimateModeration plugin, OfflinePlayer toModerate, Player player, String subject) { public TicketTypeGui(UltimateModeration plugin, OfflinePlayer toModerate, Player player, String subject) {
super(3); super(3);
this.chatManager = plugin.getStaffChatManager();
setDefaultItem(null); setDefaultItem(null);
setTitle(plugin.getLocale().getMessage("gui.ticket.picktype").getMessage()); setTitle(plugin.getLocale().getMessage("gui.ticket.picktype").getMessage());
List<String> types = Settings.TICKET_TYPES.getStringList(); List<String> types = Settings.TICKET_TYPES.getStringList();
for (int i = 0; i < types.size(); i++) { for (int i = 0; i < types.size(); i++) {
final int fi = i; final int fi = i;
setButton(i, GuiUtils.createButtonItem(CompatibleMaterial.PAPER, types.get(i)), setButton(i, GuiUtils.createButtonItem(XMaterial.PAPER, types.get(i)),
(event) -> { (event) -> {
Ticket ticket = new Ticket(toModerate, subject, types.get(fi)); Ticket ticket = new Ticket(toModerate, subject, types.get(fi));
ChatPrompt.showPrompt(plugin, ChatPrompt.showPrompt(plugin,
@ -39,13 +38,14 @@ public class TicketTypeGui extends Gui {
plugin.getTicketManager().addTicket(ticket); plugin.getTicketManager().addTicket(ticket);
// Notify staff // 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())); this.chatManager.getChat("ticket").messageAll(plugin.getLocale().getMessage("notify.ticket.created").getMessage().replace("%tid%", String.valueOf(ticket.getId())).replace("%type%", ticket.getType()).replace("%player%", Bukkit.getPlayer(ticket.getVictim()).getDisplayName()));
if (player == toModerate) if (player == toModerate) {
ticket.setLocation(player.getLocation()); ticket.setLocation(player.getLocation());
}
ticket.addResponse(new TicketResponse(player, event2.getMessage(), System.currentTimeMillis())); ticket.addResponse(new TicketResponse(player, event2.getMessage(), System.currentTimeMillis()));
plugin.getDataManager().createTicket(ticket); plugin.getDataManager().createTicket(ticket);
}).setOnClose(() -> }).setOnClose(() ->
guiManager.showGUI(event.player, new TicketGui(plugin, ticket, toModerate, player))); this.guiManager.showGUI(event.player, new TicketGui(plugin, ticket, toModerate, player)));
}); });
} }
} }

View File

@ -13,29 +13,35 @@ import org.bukkit.event.block.BlockBreakEvent;
import java.util.List; import java.util.List;
public class BlockListener implements Listener { public class BlockListener implements Listener {
private final UltimateModeration instance;
private UltimateModeration instance; private final StaffChatManager chat;
private StaffChatManager chat = UltimateModeration.getInstance().getStaffChatManager();
public BlockListener(UltimateModeration ultimateModeration) { public BlockListener(UltimateModeration ultimateModeration) {
this.instance = ultimateModeration; this.instance = ultimateModeration;
this.chat = ultimateModeration.getStaffChatManager();
} }
@EventHandler @EventHandler
public void onBlockBreak(BlockBreakEvent event) { public void onBlockBreak(BlockBreakEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
Block block = event.getBlock(); Block block = event.getBlock();
Material material = block.getType(); Material material = block.getType();
List<String> blocks = instance.getConfig().getStringList("Main.Notify Blocks List"); List<String> blocks = this.instance.getConfig().getStringList("Main.Notify Blocks List");
for (String broken : blocks) { for (String broken : blocks) {
if (!broken.equalsIgnoreCase(material.name())) continue; if (!broken.equalsIgnoreCase(material.name())) {
continue;
}
if (player.hasPermission("um.trackblockbreaks") && instance.getConfig().getBoolean("Main.Notify Blocks")) { if (player.hasPermission("um.trackblockbreaks") && this.instance.getConfig().getBoolean("Main.Notify Blocks")) {
chat.getChat("notify").messageAll("&7[UM] &a" + Bukkit.getPlayer(player.getUniqueId()).getDisplayName() this.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!"); + this.instance
.getLocale()
.getMessage("notify.block.main")
.getMessage()
.replace("%material%", material.name())
+ "(" + block.getX() + ", " + block.getY() + ", " + block.getZ() + ")&a!");
} }
} }
} }

View File

@ -1,11 +1,11 @@
package com.songoda.ultimatemoderation.listeners; package com.songoda.ultimatemoderation.listeners;
import com.craftaro.core.utils.TimeUtils;
import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.UltimateModeration;
import com.songoda.ultimatemoderation.punish.AppliedPunishment; import com.songoda.ultimatemoderation.punish.AppliedPunishment;
import com.songoda.ultimatemoderation.punish.PunishmentType; import com.songoda.ultimatemoderation.punish.PunishmentType;
import com.songoda.ultimatemoderation.settings.Settings; import com.songoda.ultimatemoderation.settings.Settings;
import com.songoda.ultimatemoderation.staffchat.StaffChannel; import com.songoda.ultimatemoderation.staffchat.StaffChannel;
import com.songoda.ultimatemoderation.utils.Methods;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -18,7 +18,6 @@ import java.util.UUID;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class ChatListener implements Listener { public class ChatListener implements Listener {
private static long slowModeOverride = 0; private static long slowModeOverride = 0;
private static boolean isChatToggled = true; // true means people can talk, false means muted private static boolean isChatToggled = true; // true means people can talk, false means muted
@ -32,7 +31,7 @@ public class ChatListener implements Listener {
isChatToggled = toggled; isChatToggled = toggled;
} }
private static List<Log> chatLog = new ArrayList<>(); private static final List<Log> chatLog = new ArrayList<>();
public static long getSlowModeOverride() { public static long getSlowModeOverride() {
return slowModeOverride; return slowModeOverride;
@ -41,14 +40,15 @@ public class ChatListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onChat(AsyncPlayerChatEvent event) { public void onChat(AsyncPlayerChatEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (!onChat(player, event.getMessage())) if (!onChat(player, event.getMessage())) {
event.setCancelled(true); event.setCancelled(true);
}
} }
public static boolean onChat(Player player, String message) { public static boolean onChat(Player player, String message) {
UltimateModeration instance = UltimateModeration.getInstance(); 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) { if (!player.hasPermission("um.slowmode.bypass") && slowmode != 0) {
List<Log> chats = chatLog.stream().filter(log -> log.player == player.getUniqueId()).collect(Collectors.toList()); 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; boolean isCancelled = false;
for (StaffChannel channel : instance.getStaffChatManager().getChats().values()) { for (StaffChannel channel : instance.getStaffChatManager().getChats().values()) {
if (!channel.listMembers().contains(player.getUniqueId())) continue; if (!channel.listMembers().contains(player.getUniqueId())) {
continue;
}
isCancelled = true; isCancelled = true;
channel.processMessage(message, player); channel.processMessage(message, player);
} }
@ -95,10 +97,9 @@ public class ChatListener implements Listener {
} }
public static class Log { public static class Log {
private final UUID player;
private UUID player; private final long sent;
private long sent; private final String message;
private String message;
Log(UUID player, long sent, String message) { Log(UUID player, long sent, String message) {
this.player = player; this.player = player;
@ -107,16 +108,15 @@ public class ChatListener implements Listener {
} }
public UUID getPlayer() { public UUID getPlayer() {
return player; return this.player;
} }
public long getSent() { public long getSent() {
return sent; return this.sent;
} }
public String getMessage() { public String getMessage() {
return message; return this.message;
} }
} }
} }

View File

@ -14,8 +14,7 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import java.util.List; import java.util.List;
public class CommandListener implements Listener { public class CommandListener implements Listener {
private final UltimateModeration instance;
private UltimateModeration instance;
public CommandListener(UltimateModeration ultimateModeration) { public CommandListener(UltimateModeration ultimateModeration) {
this.instance = ultimateModeration; this.instance = ultimateModeration;
@ -24,36 +23,34 @@ public class CommandListener implements Listener {
@EventHandler @EventHandler
public void onCommand(PlayerCommandPreprocessEvent event) { public void onCommand(PlayerCommandPreprocessEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
String command = event.getMessage(); 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 (!appliedPunishments.isEmpty()) {
if (Settings.MUTE_DISABLED_COMMANDS.getStringList().stream() if (Settings.MUTE_DISABLED_COMMANDS.getStringList().stream().anyMatch(s -> command.toUpperCase().startsWith("/" + s.toUpperCase()))) {
.anyMatch(s -> command.toUpperCase().startsWith("/" + s.toUpperCase())))
event.setCancelled(true); event.setCancelled(true);
}
} }
List<String> blockedCommands = Settings.BLOCKED_COMMANDS.getStringList(); List<String> blockedCommands = Settings.BLOCKED_COMMANDS.getStringList();
for (String cmd : blockedCommands) { for (String cmd : blockedCommands) {
if (command.toUpperCase().startsWith("/" + cmd.toUpperCase()) if (command.toUpperCase().startsWith("/" + cmd.toUpperCase())
&& (command.toUpperCase().endsWith(cmd.toUpperCase()) || (command.contains(" ") && command.split(" ")[0].toUpperCase().endsWith(cmd.toUpperCase()))) && (command.toUpperCase().endsWith(cmd.toUpperCase()) || (command.contains(" ") && command.split(" ")[0].toUpperCase().endsWith(cmd.toUpperCase())))
&& !player.hasPermission("um.commandblock.bypass")) { && !player.hasPermission("um.commandblock.bypass")) {
event.setCancelled(true); event.setCancelled(true);
event.setMessage("-"); 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")) { if (!player.hasPermission("um.commandspy.immune")) {
for (Player pl : Bukkit.getOnlinePlayers()) { for (Player pl : Bukkit.getOnlinePlayers()) {
if (pl != player && pl.hasPermission("um.commandspy") && SpyModeration.isSpying(pl)) if (pl != player && pl.hasPermission("um.commandspy") && SpyModeration.isSpying(pl)) {
instance.getLocale().getMessage("command.commandspy.deny") this.instance.getLocale().getMessage("command.commandspy.deny")
.processPlaceholder("player", player.getName()) .processPlaceholder("player", player.getName())
.processPlaceholder("command", command) .processPlaceholder("command", command)
.sendPrefixedMessage(pl); .sendPrefixedMessage(pl);
}
} }
} }
} }

View File

@ -1,6 +1,5 @@
package com.songoda.ultimatemoderation.listeners; package com.songoda.ultimatemoderation.listeners;
import com.songoda.ultimatemoderation.UltimateModeration;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
@ -13,14 +12,7 @@ import java.util.Map;
import java.util.UUID; import java.util.UUID;
public class DeathListener implements Listener { public class DeathListener implements Listener {
private static final Map<UUID, List<ItemStack>> playerDrops = new HashMap<>();
private static Map<UUID, List<ItemStack>> playerDrops = new HashMap<>();
private UltimateModeration instance;
public DeathListener(UltimateModeration ultimateModeration) {
this.instance = ultimateModeration;
}
public static List<ItemStack> getLastDrop(Player player) { public static List<ItemStack> getLastDrop(Player player) {
return playerDrops.get(player.getUniqueId()); return playerDrops.get(player.getUniqueId());

View File

@ -8,8 +8,7 @@ import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerDropItemEvent;
public class DropListener implements Listener { public class DropListener implements Listener {
private final UltimateModeration instance;
private UltimateModeration instance;
public DropListener(UltimateModeration ultimateModeration) { public DropListener(UltimateModeration ultimateModeration) {
this.instance = ultimateModeration; this.instance = ultimateModeration;
@ -20,7 +19,7 @@ public class DropListener implements Listener {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (FreezeModeration.isFrozen(player)) { if (FreezeModeration.isFrozen(player)) {
event.setCancelled(true); event.setCancelled(true);
instance.getLocale().getMessage("command.freeze.nope").sendPrefixedMessage(player); this.instance.getLocale().getMessage("command.freeze.nope").sendPrefixedMessage(player);
} }
} }
} }

View File

@ -8,8 +8,7 @@ import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
public class InventoryListener implements Listener { public class InventoryListener implements Listener {
private final UltimateModeration plugin;
private UltimateModeration plugin;
public InventoryListener(UltimateModeration ultimateModeration) { public InventoryListener(UltimateModeration ultimateModeration) {
this.plugin = ultimateModeration; this.plugin = ultimateModeration;
@ -17,11 +16,14 @@ public class InventoryListener implements Listener {
@EventHandler @EventHandler
public void onMove(InventoryClickEvent event) { public void onMove(InventoryClickEvent event) {
if (!(event.getWhoClicked() instanceof Player)) return; if (!(event.getWhoClicked() instanceof Player)) {
return;
}
Player player = (Player) event.getWhoClicked(); Player player = (Player) event.getWhoClicked();
if (FreezeModeration.isFrozen(player)) { if (FreezeModeration.isFrozen(player)) {
event.setCancelled(true); event.setCancelled(true);
plugin.getLocale().getMessage("command.freeze.nope").sendPrefixedMessage(player); this.plugin.getLocale().getMessage("command.freeze.nope").sendPrefixedMessage(player);
} }
} }
} }

View File

@ -1,11 +1,11 @@
package com.songoda.ultimatemoderation.listeners; package com.songoda.ultimatemoderation.listeners;
import com.craftaro.core.utils.TimeUtils;
import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.UltimateModeration;
import com.songoda.ultimatemoderation.commands.CommandVanish; import com.songoda.ultimatemoderation.commands.CommandVanish;
import com.songoda.ultimatemoderation.punish.AppliedPunishment; import com.songoda.ultimatemoderation.punish.AppliedPunishment;
import com.songoda.ultimatemoderation.punish.PunishmentType; import com.songoda.ultimatemoderation.punish.PunishmentType;
import com.songoda.ultimatemoderation.punish.player.PlayerPunishData; import com.songoda.ultimatemoderation.punish.player.PlayerPunishData;
import com.songoda.ultimatemoderation.utils.Methods;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
@ -15,8 +15,7 @@ import org.bukkit.event.player.PlayerLoginEvent;
import java.util.List; import java.util.List;
public class LoginListener implements Listener { public class LoginListener implements Listener {
private final UltimateModeration instance;
private UltimateModeration instance;
public LoginListener(UltimateModeration ultimateModeration) { public LoginListener(UltimateModeration ultimateModeration) {
this.instance = ultimateModeration; this.instance = ultimateModeration;
@ -24,17 +23,19 @@ public class LoginListener implements Listener {
@EventHandler @EventHandler
public void onPreLogin(AsyncPlayerPreLoginEvent event) { 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); List<AppliedPunishment> appliedPunishments = playerPunishData.getActivePunishments(PunishmentType.BAN);
if (appliedPunishments.isEmpty()) return; if (appliedPunishments.isEmpty()) {
return;
}
AppliedPunishment appliedPunishment = playerPunishData.getActivePunishments(PunishmentType.BAN).get(0); 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("reason", appliedPunishment.getReason() == null ? "" : appliedPunishment.getReason())
.processPlaceholder("duration", Methods.makeReadable(appliedPunishment.getTimeRemaining())).getMessage()); .processPlaceholder("duration", TimeUtils.makeReadable(appliedPunishment.getTimeRemaining())).getMessage());
event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_BANNED); event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_BANNED);

View File

@ -9,15 +9,17 @@ import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityTargetLivingEntityEvent; import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
public class MobTargetLister implements Listener { public class MobTargetLister implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onMobTagetEvent(EntityTargetLivingEntityEvent e) { public void onMobTagetEvent(EntityTargetLivingEntityEvent e) {
if (!(e.getTarget() instanceof Player)) return; if (!(e.getTarget() instanceof Player)) {
if (!(e.getEntity() instanceof Monster)) return; return;
}
if (!(e.getEntity() instanceof Monster)) {
return;
}
if (CommandVanish.isVanished(((Player) e.getTarget()).getPlayer())) { if (CommandVanish.isVanished(((Player) e.getTarget()).getPlayer())) {
e.setCancelled(true); e.setCancelled(true);
} }
} }
} }

View File

@ -8,8 +8,7 @@ import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
public class MoveListener implements Listener { public class MoveListener implements Listener {
private final UltimateModeration instance;
private UltimateModeration instance;
public MoveListener(UltimateModeration ultimateModeration) { public MoveListener(UltimateModeration ultimateModeration) {
this.instance = ultimateModeration; this.instance = ultimateModeration;
@ -20,7 +19,7 @@ public class MoveListener implements Listener {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (FreezeModeration.isFrozen(player)) { if (FreezeModeration.isFrozen(player)) {
event.setCancelled(true); event.setCancelled(true);
instance.getLocale().getMessage("command.freeze.nope").sendPrefixedMessage(player); this.instance.getLocale().getMessage("command.freeze.nope").sendPrefixedMessage(player);
} }
} }
} }

View File

@ -1,22 +1,14 @@
package com.songoda.ultimatemoderation.listeners; package com.songoda.ultimatemoderation.listeners;
import com.songoda.skyblock.api.event.player.PlayerIslandChatEvent; import com.songoda.skyblock.api.event.player.PlayerIslandChatEvent;
import com.songoda.ultimatemoderation.UltimateModeration;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
public class SkyBlockListener implements Listener { public class SkyBlockListener implements Listener {
private UltimateModeration instance;
public SkyBlockListener(UltimateModeration ultimateModeration) {
this.instance = ultimateModeration;
}
@EventHandler @EventHandler
public void onIslandChat(PlayerIslandChatEvent event) { public void onIslandChat(PlayerIslandChatEvent event) {
if (!ChatListener.onChat(event.getPlayer(), event.getMessage())) if (!ChatListener.onChat(event.getPlayer(), event.getMessage())) {
event.setCancelled(true); event.setCancelled(true);
}
} }
} }

View File

@ -17,21 +17,31 @@ import java.util.Map;
import java.util.UUID; import java.util.UUID;
public class SpyingDismountListener implements Listener { 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) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntityDismountEvent(EntityDismountEvent event) { public void onEntityDismountEvent(EntityDismountEvent event) {
if (!(event.getDismounted() instanceof Player)) return; if (!(event.getDismounted() instanceof Player)) {
if (!(event.getEntity() instanceof Player)) return; return;
}
if (!(event.getEntity() instanceof Player)) {
return;
}
if (SpyModeration.isSpying((((Player) event.getEntity()).getPlayer()))) { if (SpyModeration.isSpying((((Player) event.getEntity()).getPlayer()))) {
Player player = (Player) event.getEntity(); Player player = (Player) event.getEntity();
gamemodes.put(player.getUniqueId(), player.getGameMode()); gamemodes.put(player.getUniqueId(), player.getGameMode());
player.setGameMode(GameMode.SPECTATOR); player.setGameMode(GameMode.SPECTATOR);
Bukkit.getScheduler().scheduleSyncDelayedTask(UltimateModeration.getInstance(), () -> { Bukkit.getScheduler().scheduleSyncDelayedTask(this.plugin, () -> {
if (player.getGameMode() == GameMode.SPECTATOR) {
if (player.getGameMode() == GameMode.SPECTATOR)
player.setSpectatorTarget(event.getDismounted()); player.setSpectatorTarget(event.getDismounted());
}
}, 5L); }, 5L);
} }
} }
@ -39,8 +49,10 @@ public class SpyingDismountListener implements Listener {
@EventHandler @EventHandler
public void onSneak(PlayerToggleSneakEvent event) { public void onSneak(PlayerToggleSneakEvent event) {
Player player = event.getPlayer(); 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; return;
}
SpyModeration.spy(null, player); SpyModeration.spy(null, player);
} }

View File

@ -1,6 +1,6 @@
package com.songoda.ultimatemoderation.moderate; package com.songoda.ultimatemoderation.moderate;
import com.songoda.core.compatibility.CompatibleMaterial; import com.craftaro.core.third_party.com.cryptomorin.xseries.XMaterial;
import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.UltimateModeration;
import com.songoda.ultimatemoderation.utils.VaultPermissions; import com.songoda.ultimatemoderation.utils.VaultPermissions;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
@ -8,7 +8,6 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public abstract class AbstractModeration { public abstract class AbstractModeration {
protected final UltimateModeration plugin; protected final UltimateModeration plugin;
private final boolean requireOnline, allowConsole; private final boolean requireOnline, allowConsole;
@ -20,7 +19,7 @@ public abstract class AbstractModeration {
public abstract ModerationType getType(); public abstract ModerationType getType();
public abstract CompatibleMaterial getIcon(); public abstract XMaterial getIcon();
public abstract String getProper(); public abstract String getProper();
@ -43,12 +42,12 @@ public abstract class AbstractModeration {
} }
public boolean runPreModeration(CommandSender runner, OfflinePlayer toModerate) { public boolean runPreModeration(CommandSender runner, OfflinePlayer toModerate) {
if (requireOnline && !toModerate.isOnline()) { if (this.requireOnline && !toModerate.isOnline()) {
plugin.getLocale().newMessage(toModerate.getName() + " must be online for this moderation.").sendPrefixedMessage(runner); this.plugin.getLocale().newMessage(toModerate.getName() + " must be online for this moderation.").sendPrefixedMessage(runner);
} }
if (isExempt(toModerate)) { 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; return false;
} }
@ -58,10 +57,10 @@ public abstract class AbstractModeration {
protected abstract boolean runModeration(CommandSender runner, OfflinePlayer toModerate); protected abstract boolean runModeration(CommandSender runner, OfflinePlayer toModerate);
public boolean isRequireOnline() { public boolean isRequireOnline() {
return requireOnline; return this.requireOnline;
} }
public boolean isAllowConsole() { public boolean isAllowConsole() {
return allowConsole; return this.allowConsole;
} }
} }

View File

@ -1,6 +1,6 @@
package com.songoda.ultimatemoderation.moderate; package com.songoda.ultimatemoderation.moderate;
import com.songoda.core.commands.AbstractCommand; import com.craftaro.core.commands.AbstractCommand;
import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.UltimateModeration;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
@ -11,7 +11,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
public class GenericModerationCommand extends AbstractCommand { public class GenericModerationCommand extends AbstractCommand {
private final UltimateModeration plugin; private final UltimateModeration plugin;
private final AbstractModeration moderation; private final AbstractModeration moderation;
@ -23,17 +22,18 @@ public class GenericModerationCommand extends AbstractCommand {
@Override @Override
protected ReturnType runCommand(CommandSender sender, String... args) { protected ReturnType runCommand(CommandSender sender, String... args) {
if (args.length != 1) if (args.length != 1) {
return ReturnType.SYNTAX_ERROR; return ReturnType.SYNTAX_ERROR;
}
OfflinePlayer player = Bukkit.getOfflinePlayer(args[0]); OfflinePlayer player = Bukkit.getOfflinePlayer(args[0]);
if (!player.hasPlayedBefore()) { 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; return ReturnType.FAILURE;
} }
moderation.runPreModeration(sender, player); this.moderation.runPreModeration(sender, player);
return ReturnType.SUCCESS; return ReturnType.SUCCESS;
} }
@ -52,16 +52,16 @@ public class GenericModerationCommand extends AbstractCommand {
@Override @Override
public String getPermissionNode() { public String getPermissionNode() {
return moderation.getPermission(); return this.moderation.getPermission();
} }
@Override @Override
public String getSyntax() { public String getSyntax() {
return "/" + moderation.getProper() + " <player>"; return "/" + this.moderation.getProper() + " <player>";
} }
@Override @Override
public String getDescription() { public String getDescription() {
return moderation.getDescription(); return this.moderation.getDescription();
} }
} }

View File

@ -12,7 +12,6 @@ import java.util.Map;
import java.util.TreeMap; import java.util.TreeMap;
public class ModerationManager { public class ModerationManager {
private static final Map<ModerationType, AbstractModeration> moderations = new TreeMap<>(); private static final Map<ModerationType, AbstractModeration> moderations = new TreeMap<>();
public ModerationManager(UltimateModeration plugin) { public ModerationManager(UltimateModeration plugin) {

View File

@ -1,7 +1,5 @@
package com.songoda.ultimatemoderation.moderate; package com.songoda.ultimatemoderation.moderate;
public enum ModerationType { public enum ModerationType {
FREEZE, SPY, INV_SEE, ENDER_VIEW, REVIVE FREEZE, SPY, INV_SEE, ENDER_VIEW, REVIVE
} }

View File

@ -1,6 +1,6 @@
package com.songoda.ultimatemoderation.moderate.moderations; package com.songoda.ultimatemoderation.moderate.moderations;
import com.songoda.core.compatibility.CompatibleMaterial; import com.craftaro.core.third_party.com.cryptomorin.xseries.XMaterial;
import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.UltimateModeration;
import com.songoda.ultimatemoderation.moderate.AbstractModeration; import com.songoda.ultimatemoderation.moderate.AbstractModeration;
import com.songoda.ultimatemoderation.moderate.ModerationType; import com.songoda.ultimatemoderation.moderate.ModerationType;
@ -12,7 +12,6 @@ import java.util.List;
import java.util.UUID; import java.util.UUID;
public class FreezeModeration extends AbstractModeration { public class FreezeModeration extends AbstractModeration {
private static final List<UUID> frozen = new ArrayList<>(); private static final List<UUID> frozen = new ArrayList<>();
public FreezeModeration(UltimateModeration plugin) { public FreezeModeration(UltimateModeration plugin) {
@ -26,8 +25,8 @@ public class FreezeModeration extends AbstractModeration {
} }
@Override @Override
public CompatibleMaterial getIcon() { public XMaterial getIcon() {
return CompatibleMaterial.BLUE_ICE; return XMaterial.BLUE_ICE;
} }
@Override @Override
@ -44,16 +43,18 @@ public class FreezeModeration extends AbstractModeration {
protected boolean runModeration(CommandSender runner, OfflinePlayer toModerate) { protected boolean runModeration(CommandSender runner, OfflinePlayer toModerate) {
if (frozen.contains(toModerate.getUniqueId())) { if (frozen.contains(toModerate.getUniqueId())) {
frozen.remove(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); .processPlaceholder("player", toModerate.getPlayer().getDisplayName()).sendPrefixedMessage(runner);
if (toModerate.isOnline()) if (toModerate.isOnline()) {
plugin.getLocale().getMessage("command.freeze.alertremove").sendPrefixedMessage(toModerate.getPlayer()); this.plugin.getLocale().getMessage("command.freeze.alertremove").sendPrefixedMessage(toModerate.getPlayer());
}
} else { } else {
frozen.add(toModerate.getUniqueId()); frozen.add(toModerate.getUniqueId());
plugin.getLocale().getMessage("command.freeze.add") this.plugin.getLocale().getMessage("command.freeze.add")
.processPlaceholder("player", toModerate.getPlayer().getDisplayName()).sendPrefixedMessage(runner); .processPlaceholder("player", toModerate.getPlayer().getDisplayName()).sendPrefixedMessage(runner);
if (toModerate.isOnline()) if (toModerate.isOnline()) {
plugin.getLocale().getMessage("command.freeze.alertadd").sendPrefixedMessage(toModerate.getPlayer()); this.plugin.getLocale().getMessage("command.freeze.alertadd").sendPrefixedMessage(toModerate.getPlayer());
}
} }
return true; return true;
} }

View File

@ -1,6 +1,6 @@
package com.songoda.ultimatemoderation.moderate.moderations; package com.songoda.ultimatemoderation.moderate.moderations;
import com.songoda.core.compatibility.CompatibleMaterial; import com.craftaro.core.third_party.com.cryptomorin.xseries.XMaterial;
import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.UltimateModeration;
import com.songoda.ultimatemoderation.moderate.AbstractModeration; import com.songoda.ultimatemoderation.moderate.AbstractModeration;
import com.songoda.ultimatemoderation.moderate.ModerationType; import com.songoda.ultimatemoderation.moderate.ModerationType;
@ -9,7 +9,6 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class InvSeeModeration extends AbstractModeration { public class InvSeeModeration extends AbstractModeration {
public InvSeeModeration(UltimateModeration plugin) { public InvSeeModeration(UltimateModeration plugin) {
super(plugin, true, false); super(plugin, true, false);
registerCommand(plugin); registerCommand(plugin);
@ -21,8 +20,8 @@ public class InvSeeModeration extends AbstractModeration {
} }
@Override @Override
public CompatibleMaterial getIcon() { public XMaterial getIcon() {
return CompatibleMaterial.CHEST; return XMaterial.CHEST;
} }
@Override @Override

View File

@ -1,7 +1,7 @@
package com.songoda.ultimatemoderation.moderate.moderations; package com.songoda.ultimatemoderation.moderate.moderations;
import com.songoda.core.compatibility.CompatibleMaterial; import com.craftaro.core.third_party.com.cryptomorin.xseries.XMaterial;
import com.songoda.core.utils.PlayerUtils; import com.craftaro.core.utils.PlayerUtils;
import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.UltimateModeration;
import com.songoda.ultimatemoderation.listeners.DeathListener; import com.songoda.ultimatemoderation.listeners.DeathListener;
import com.songoda.ultimatemoderation.moderate.AbstractModeration; import com.songoda.ultimatemoderation.moderate.AbstractModeration;
@ -14,9 +14,12 @@ import org.bukkit.inventory.ItemStack;
import java.util.List; import java.util.List;
public class ReviveModeration extends AbstractModeration { public class ReviveModeration extends AbstractModeration {
private final UltimateModeration plugin;
public ReviveModeration(UltimateModeration plugin) { public ReviveModeration(UltimateModeration plugin) {
super(plugin, true, true); super(plugin, true, true);
this.plugin = plugin;
registerCommand(plugin); registerCommand(plugin);
} }
@ -26,8 +29,8 @@ public class ReviveModeration extends AbstractModeration {
} }
@Override @Override
public CompatibleMaterial getIcon() { public XMaterial getIcon() {
return CompatibleMaterial.POTION; return XMaterial.POTION;
} }
@Override @Override
@ -43,11 +46,10 @@ public class ReviveModeration extends AbstractModeration {
@Override @Override
protected boolean runModeration(CommandSender runner, OfflinePlayer toModerate) { protected boolean runModeration(CommandSender runner, OfflinePlayer toModerate) {
Player toModeratePlayer = (Player) toModerate; Player toModeratePlayer = (Player) toModerate;
UltimateModeration instance = UltimateModeration.getInstance();
List<ItemStack> drops = DeathListener.getLastDrop(toModeratePlayer); List<ItemStack> drops = DeathListener.getLastDrop(toModeratePlayer);
if (drops == null) { if (drops == null) {
instance.getLocale().getMessage("command.revive.noloot").sendPrefixedMessage(runner); this.plugin.getLocale().getMessage("command.revive.noloot").sendPrefixedMessage(runner);
return false; return false;
} }
@ -56,8 +58,8 @@ public class ReviveModeration extends AbstractModeration {
PlayerUtils.giveItem(toModeratePlayer, dropArr); PlayerUtils.giveItem(toModeratePlayer, dropArr);
instance.getLocale().getMessage("command.revive.revived").sendPrefixedMessage(toModeratePlayer); this.plugin.getLocale().getMessage("command.revive.revived").sendPrefixedMessage(toModeratePlayer);
instance.getLocale().getMessage("command.revive.success") this.plugin.getLocale().getMessage("command.revive.success")
.processPlaceholder("player", toModerate.getName()).sendPrefixedMessage(runner); .processPlaceholder("player", toModerate.getName()).sendPrefixedMessage(runner);
return true; return true;
} }

View File

@ -1,7 +1,7 @@
package com.songoda.ultimatemoderation.moderate.moderations; package com.songoda.ultimatemoderation.moderate.moderations;
import com.songoda.core.compatibility.CompatibleMaterial; import com.craftaro.core.compatibility.ServerVersion;
import com.songoda.core.compatibility.ServerVersion; import com.craftaro.core.third_party.com.cryptomorin.xseries.XMaterial;
import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.UltimateModeration;
import com.songoda.ultimatemoderation.commands.CommandVanish; import com.songoda.ultimatemoderation.commands.CommandVanish;
import com.songoda.ultimatemoderation.listeners.SpyingDismountListener; import com.songoda.ultimatemoderation.listeners.SpyingDismountListener;
@ -17,8 +17,7 @@ import java.util.Map;
import java.util.UUID; import java.util.UUID;
public class SpyModeration extends AbstractModeration { public class SpyModeration extends AbstractModeration {
private static final Map<UUID, Spy> spying = new HashMap<>();
private static Map<UUID, Spy> spying = new HashMap<>();
public SpyModeration(UltimateModeration plugin) { public SpyModeration(UltimateModeration plugin) {
super(plugin, true, false); super(plugin, true, false);
@ -31,8 +30,8 @@ public class SpyModeration extends AbstractModeration {
} }
@Override @Override
public CompatibleMaterial getIcon() { public XMaterial getIcon() {
return CompatibleMaterial.ENDER_EYE; return XMaterial.ENDER_EYE;
} }
@Override @Override
@ -53,10 +52,11 @@ public class SpyModeration extends AbstractModeration {
if (spying.containsKey(runnerPlayer.getUniqueId())) { if (spying.containsKey(runnerPlayer.getUniqueId())) {
Spy spyingEntry = spying.remove(runnerPlayer.getUniqueId()); Spy spyingEntry = spying.remove(runnerPlayer.getUniqueId());
runnerPlayer.teleport(spyingEntry.getLastLocation()); runnerPlayer.teleport(spyingEntry.getLastLocation());
if (spyingEntry.isVanishApplied() && CommandVanish.isVanished(runnerPlayer)) if (spyingEntry.isVanishApplied() && CommandVanish.isVanished(runnerPlayer)) {
CommandVanish.vanish(runnerPlayer); CommandVanish.vanish(runnerPlayer);
}
plugin.getLocale().getMessage("command.spy.returned").sendPrefixedMessage(runner); this.plugin.getLocale().getMessage("command.spy.returned").sendPrefixedMessage(runner);
return true; return true;
} }
@ -74,8 +74,9 @@ public class SpyModeration extends AbstractModeration {
if (spying.containsKey(senderP) && oPlayer == null) { if (spying.containsKey(senderP) && oPlayer == null) {
Spy spyingEntry = spying.remove(senderP.getUniqueId()); Spy spyingEntry = spying.remove(senderP.getUniqueId());
senderP.teleport(spyingEntry.getLastLocation()); senderP.teleport(spyingEntry.getLastLocation());
if (spyingEntry.isVanishApplied() && CommandVanish.isVanished(senderP)) if (spyingEntry.isVanishApplied() && CommandVanish.isVanished(senderP)) {
CommandVanish.vanish(senderP); CommandVanish.vanish(senderP);
}
senderP.setGameMode(SpyingDismountListener.getGamemodes().get(senderP.getUniqueId())); senderP.setGameMode(SpyingDismountListener.getGamemodes().get(senderP.getUniqueId()));
UltimateModeration.getInstance().getLocale().getMessage("command.spy.returned").sendPrefixedMessage(senderP); UltimateModeration.getInstance().getLocale().getMessage("command.spy.returned").sendPrefixedMessage(senderP);
@ -114,8 +115,8 @@ public class SpyModeration extends AbstractModeration {
} }
public static class Spy { public static class Spy {
private Location lastLocation; private final Location lastLocation;
private boolean vanishApplied; private final boolean vanishApplied;
public Spy(Location lastLocation, boolean vanishApplied) { public Spy(Location lastLocation, boolean vanishApplied) {
this.lastLocation = lastLocation; this.lastLocation = lastLocation;
@ -123,11 +124,11 @@ public class SpyModeration extends AbstractModeration {
} }
public Location getLastLocation() { public Location getLastLocation() {
return lastLocation; return this.lastLocation;
} }
public boolean isVanishApplied() { public boolean isVanishApplied() {
return vanishApplied; return this.vanishApplied;
} }
} }
} }

View File

@ -1,6 +1,6 @@
package com.songoda.ultimatemoderation.moderate.moderations; package com.songoda.ultimatemoderation.moderate.moderations;
import com.songoda.core.compatibility.CompatibleMaterial; import com.craftaro.core.third_party.com.cryptomorin.xseries.XMaterial;
import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.UltimateModeration;
import com.songoda.ultimatemoderation.moderate.AbstractModeration; import com.songoda.ultimatemoderation.moderate.AbstractModeration;
import com.songoda.ultimatemoderation.moderate.ModerationType; import com.songoda.ultimatemoderation.moderate.ModerationType;
@ -9,7 +9,6 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class ViewEnderChestModeration extends AbstractModeration { public class ViewEnderChestModeration extends AbstractModeration {
public ViewEnderChestModeration(UltimateModeration plugin) { public ViewEnderChestModeration(UltimateModeration plugin) {
super(plugin, true, false); super(plugin, true, false);
registerCommand(plugin); registerCommand(plugin);
@ -21,8 +20,8 @@ public class ViewEnderChestModeration extends AbstractModeration {
} }
@Override @Override
public CompatibleMaterial getIcon() { public XMaterial getIcon() {
return CompatibleMaterial.ENDER_CHEST; return XMaterial.ENDER_CHEST;
} }
@Override @Override

View File

@ -3,7 +3,6 @@ package com.songoda.ultimatemoderation.punish;
import java.util.UUID; import java.util.UUID;
public class AppliedPunishment extends Punishment { public class AppliedPunishment extends Punishment {
private final UUID victim; private final UUID victim;
private final UUID punisher; private final UUID punisher;
private long expiration; private long expiration;
@ -30,15 +29,15 @@ public class AppliedPunishment extends Punishment {
} }
public UUID getVictim() { public UUID getVictim() {
return victim; return this.victim;
} }
public UUID getPunisher() { public UUID getPunisher() {
return punisher; return this.punisher;
} }
public long getExpiration() { public long getExpiration() {
return expiration; return this.expiration;
} }
public void expire() { public void expire() {
@ -46,6 +45,6 @@ public class AppliedPunishment extends Punishment {
} }
public long getTimeRemaining() { public long getTimeRemaining() {
return expiration - System.currentTimeMillis(); return this.expiration - System.currentTimeMillis();
} }
} }

View File

@ -1,15 +1,15 @@
package com.songoda.ultimatemoderation.punish; package com.songoda.ultimatemoderation.punish;
import com.craftaro.core.utils.TextUtils;
import com.craftaro.core.utils.TimeUtils;
import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.UltimateModeration;
import com.songoda.ultimatemoderation.punish.player.PlayerPunishData; import com.songoda.ultimatemoderation.punish.player.PlayerPunishData;
import com.songoda.ultimatemoderation.utils.Methods;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class Punishment { public class Punishment {
private int id; private int id;
private final PunishmentType punishmentType; private final PunishmentType punishmentType;
@ -44,23 +44,24 @@ public class Punishment {
public void execute(CommandSender punisher, OfflinePlayer victim) { public void execute(CommandSender punisher, OfflinePlayer victim) {
UltimateModeration plugin = UltimateModeration.getInstance(); UltimateModeration plugin = UltimateModeration.getInstance();
if (!punisher.hasPermission("Um." + punishmentType)) { if (!punisher.hasPermission("Um." + this.punishmentType)) {
plugin.getLocale().getMessage("event.general.nopermission").sendPrefixedMessage(punisher); plugin.getLocale().getMessage("event.general.nopermission").sendPrefixedMessage(punisher);
return; return;
} }
PlayerPunishData playerPunishData = plugin.getPunishmentManager().getPlayer(victim); PlayerPunishData playerPunishData = plugin.getPunishmentManager().getPlayer(victim);
switch (punishmentType) { switch (this.punishmentType) {
case BAN: case BAN:
if (!playerPunishData.getActivePunishments(PunishmentType.BAN).isEmpty()) { if (!playerPunishData.getActivePunishments(PunishmentType.BAN).isEmpty()) {
plugin.getLocale().getMessage("event.ban.already").sendPrefixedMessage(punisher); plugin.getLocale().getMessage("event.ban.already").sendPrefixedMessage(punisher);
return; return;
} }
if (victim.isOnline()) if (victim.isOnline()) {
Bukkit.getScheduler().runTask(plugin, () -> victim.getPlayer().kickPlayer(plugin.getLocale() Bukkit.getScheduler().runTask(plugin, () -> victim.getPlayer().kickPlayer(plugin.getLocale()
.getMessage("event.ban.message") .getMessage("event.ban.message")
.processPlaceholder("reason", reason == null ? "" : reason) .processPlaceholder("reason", this.reason == null ? "" : this.reason)
.processPlaceholder("duration", Methods.makeReadable(duration)).getMessage())); .processPlaceholder("duration", TimeUtils.makeReadable(this.duration)).getMessage()));
}
break; break;
case MUTE: case MUTE:
if (!playerPunishData.getActivePunishments(PunishmentType.MUTE).isEmpty()) { if (!playerPunishData.getActivePunishments(PunishmentType.MUTE).isEmpty()) {
@ -70,10 +71,11 @@ public class Punishment {
sendMessage(victim); sendMessage(victim);
break; break;
case KICK: case KICK:
if (victim.isOnline()) if (victim.isOnline()) {
Bukkit.getScheduler().runTask(plugin, () -> victim.getPlayer().kickPlayer(plugin.getLocale() Bukkit.getScheduler().runTask(plugin, () -> victim.getPlayer().kickPlayer(plugin.getLocale()
.getMessage("event.kick.message") .getMessage("event.kick.message")
.processPlaceholder("reason", reason == null ? "" : reason).getMessage())); .processPlaceholder("reason", this.reason == null ? "" : this.reason).getMessage()));
}
break; break;
case WARNING: case WARNING:
sendMessage(victim); sendMessage(victim);
@ -81,22 +83,24 @@ public class Punishment {
} }
String punishSuccess = plugin.getLocale() String punishSuccess = plugin.getLocale()
.getMessage("event." + punishmentType.name().toLowerCase() + ".success") .getMessage("event." + this.punishmentType.name().toLowerCase() + ".success")
.processPlaceholder("player", victim.getName()) .processPlaceholder("player", victim.getName())
.getPrefixedMessage(); .getPrefixedMessage();
if (reason != null) if (this.reason != null) {
punishSuccess += plugin.getLocale().getMessage("event.punish.reason") 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") 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); AppliedPunishment appliedPunishment = apply(victim, punisher);
if (duration != 0) { if (this.duration != 0) {
playerPunishData.addPunishment(appliedPunishment); playerPunishData.addPunishment(appliedPunishment);
} else { } else {
appliedPunishment.expire(); appliedPunishment.expire();
@ -106,26 +110,30 @@ public class Punishment {
} }
public void sendMessage(OfflinePlayer offlineVictim) { public void sendMessage(OfflinePlayer offlineVictim) {
if (!offlineVictim.isOnline()) return; if (!offlineVictim.isOnline()) {
return;
}
Player victim = offlineVictim.getPlayer(); Player victim = offlineVictim.getPlayer();
UltimateModeration plugin = UltimateModeration.getInstance(); UltimateModeration plugin = UltimateModeration.getInstance();
String punishSuccess = plugin.getLocale() String punishSuccess = plugin.getLocale()
.getMessage("event." + punishmentType.name().toLowerCase() + ".message").getPrefixedMessage(); .getMessage("event." + this.punishmentType.name().toLowerCase() + ".message").getPrefixedMessage();
if (reason != null) if (this.reason != null) {
punishSuccess += plugin.getLocale().getMessage("event.punish.reason") 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") 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() { public int getId() {
return id; return this.id;
} }
public void setId(int id) { public void setId(int id) {

View File

@ -3,7 +3,6 @@ package com.songoda.ultimatemoderation.punish;
import java.util.UUID; import java.util.UUID;
public class PunishmentNote { public class PunishmentNote {
private int id; private int id;
private final String note; private final String note;
@ -27,7 +26,7 @@ public class PunishmentNote {
} }
public int getId() { public int getId() {
return id; return this.id;
} }
public void setId(int id) { public void setId(int id) {
@ -35,18 +34,18 @@ public class PunishmentNote {
} }
public String getNote() { public String getNote() {
return note; return this.note;
} }
public UUID getAuthor() { public UUID getAuthor() {
return author; return this.author;
} }
public UUID getSubject() { public UUID getSubject() {
return subject; return this.subject;
} }
public long getCreationDate() { public long getCreationDate() {
return creationDate; return this.creationDate;
} }
} }

View File

@ -3,25 +3,26 @@ package com.songoda.ultimatemoderation.punish;
import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.UltimateModeration;
public enum PunishmentType { public enum PunishmentType {
ALL, BAN, KICK, WARNING, MUTE; ALL, BAN, KICK, WARNING, MUTE;
private static PunishmentType[] vals = values();
public PunishmentType next() { public PunishmentType next() {
PunishmentType next = vals[(this.ordinal() != vals.length - 1 ? this.ordinal() + 1 : 0)]; PunishmentType next = values()[(this.ordinal() != values().length - 1 ? this.ordinal() + 1 : 0)];
if (next == ALL) if (next == ALL) {
next = next.next(); next = next.next();
}
return next; return next;
} }
public PunishmentType nextFilter() { public PunishmentType nextFilter() {
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() { public String getTranslation() {
return UltimateModeration.getInstance().getLocale().getMessage("gui.punishmenttypes." + this.name().toLowerCase()).getMessage(); return UltimateModeration.getPlugin(UltimateModeration.class)
.getLocale()
.getMessage("gui.punishmenttypes." + this.name().toLowerCase())
.getMessage();
} }
} }

View File

@ -12,7 +12,6 @@ import java.util.UUID;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class PlayerPunishData { public class PlayerPunishData {
private final UUID player; private final UUID player;
private final List<AppliedPunishment> activePunishments = new ArrayList<>(); private final List<AppliedPunishment> activePunishments = new ArrayList<>();
@ -30,27 +29,27 @@ public class PlayerPunishData {
} }
public UUID getPlayer() { public UUID getPlayer() {
return player; return this.player;
} }
public List<AppliedPunishment> getActivePunishments() { public List<AppliedPunishment> getActivePunishments() {
audit(); audit();
return new ArrayList<>(activePunishments); return new ArrayList<>(this.activePunishments);
} }
public List<AppliedPunishment> getActivePunishments(PunishmentType type) { public List<AppliedPunishment> getActivePunishments(PunishmentType type) {
audit(); 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() { public List<AppliedPunishment> getExpiredPunishments() {
audit(); audit();
return new ArrayList<>(expiredPunishments); return new ArrayList<>(this.expiredPunishments);
} }
public List<AppliedPunishment> getExpiredPunishments(PunishmentType type) { public List<AppliedPunishment> getExpiredPunishments(PunishmentType type) {
audit(); 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) { public AppliedPunishment[] addPunishment(AppliedPunishment... appliedPunishments) {
@ -74,7 +73,7 @@ public class PlayerPunishData {
} }
public List<PunishmentNote> getNotes() { public List<PunishmentNote> getNotes() {
return new ArrayList<>(punishmentNotes); return new ArrayList<>(this.punishmentNotes);
} }
public PunishmentNote[] addNotes(PunishmentNote... notes) { public PunishmentNote[] addNotes(PunishmentNote... notes) {
@ -92,7 +91,7 @@ public class PlayerPunishData {
} }
private void audit(boolean forced, PunishmentType punishmentType) { 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.getDuration() != -1 || forced || appliedPunishment.getExpiration() == -1)
&& (appliedPunishment.getPunishmentType() == punishmentType || punishmentType == PunishmentType.ALL) && (appliedPunishment.getPunishmentType() == punishmentType || punishmentType == PunishmentType.ALL)
&& appliedPunishment.getExpiration() <= System.currentTimeMillis()).collect(Collectors.toList()); && appliedPunishment.getExpiration() <= System.currentTimeMillis()).collect(Collectors.toList());
@ -103,7 +102,7 @@ public class PlayerPunishData {
public void expirePunishments(PunishmentType type) { public void expirePunishments(PunishmentType type) {
List<AppliedPunishment> toAudit = new ArrayList<>(); List<AppliedPunishment> toAudit = new ArrayList<>();
activePunishments.stream().filter(appliedPunishment -> this.activePunishments.stream().filter(appliedPunishment ->
type == appliedPunishment.getPunishmentType()).forEach(appliedPunishment -> { type == appliedPunishment.getPunishmentType()).forEach(appliedPunishment -> {
appliedPunishment.expire(); appliedPunishment.expire();
UltimateModeration.getInstance().getDataManager().updateAppliedPunishment(appliedPunishment); UltimateModeration.getInstance().getDataManager().updateAppliedPunishment(appliedPunishment);

View File

@ -8,11 +8,10 @@ import java.util.Map;
import java.util.UUID; import java.util.UUID;
public class PunishmentManager { public class PunishmentManager {
private final Map<UUID, PlayerPunishData> punishments = new HashMap<>();
private Map<UUID, PlayerPunishData> punishments = new HashMap<>();
public Map<UUID, PlayerPunishData> getPunishments() { public Map<UUID, PlayerPunishData> getPunishments() {
return Collections.unmodifiableMap(punishments); return Collections.unmodifiableMap(this.punishments);
} }
public PlayerPunishData getPlayer(OfflinePlayer player) { public PlayerPunishData getPlayer(OfflinePlayer player) {
@ -20,6 +19,6 @@ public class PunishmentManager {
} }
public PlayerPunishData getPlayer(UUID player) { public PlayerPunishData getPlayer(UUID player) {
return punishments.computeIfAbsent(player, PlayerPunishData::new); return this.punishments.computeIfAbsent(player, PlayerPunishData::new);
} }
} }

View File

@ -7,7 +7,6 @@ import org.bukkit.entity.Player;
import java.util.UUID; import java.util.UUID;
public class Template extends Punishment { public class Template extends Punishment {
private final String templateName; private final String templateName;
private final UUID creator; private final UUID creator;
@ -30,10 +29,10 @@ public class Template extends Punishment {
} }
public String getName() { public String getName() {
return templateName; return this.templateName;
} }
public UUID getCreator() { public UUID getCreator() {
return creator; return this.creator;
} }
} }

View File

@ -1,19 +1,17 @@
package com.songoda.ultimatemoderation.punish.template; package com.songoda.ultimatemoderation.punish.template;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map;
public class TemplateManager { public class TemplateManager {
private static final List<Template> templates = new LinkedList<>(); private static final List<Template> templates = new LinkedList<>();
public Template getTemplate(String name) { public Template getTemplate(String name) {
for (Template template : templates) { for (Template template : templates) {
if (formatName(template.getName()).equals(formatName(name))) if (formatName(template.getName()).equals(formatName(name))) {
return template; return template;
}
} }
return null; return null;
} }
@ -33,7 +31,9 @@ public class TemplateManager {
} }
private String formatName(String name) { private String formatName(String name) {
if (name == null) return null; if (name == null) {
return null;
}
name = name.toUpperCase().trim(); name = name.toUpperCase().trim();
name = name.replace(" ", "_"); name = name.replace(" ", "_");
return name; return name;

View File

@ -1,87 +1,86 @@
package com.songoda.ultimatemoderation.settings; package com.songoda.ultimatemoderation.settings;
import com.songoda.core.compatibility.CompatibleMaterial; import com.craftaro.core.compatibility.CompatibleMaterial;
import com.songoda.core.configuration.Config; import com.craftaro.core.configuration.Config;
import com.songoda.core.configuration.ConfigSetting; import com.craftaro.core.configuration.ConfigSetting;
import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.UltimateModeration;
import java.util.Arrays; import java.util.Arrays;
public class Settings { public class Settings {
static final Config CONFIG = UltimateModeration.getPlugin(UltimateModeration.class).getCoreConfig();
static final Config config = UltimateModeration.getInstance().getCoreConfig(); public static final ConfigSetting VANISH_EFFECTS = new ConfigSetting(CONFIG, "Main.Enable Vanish Effects", true,
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."); "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", public static final ConfigSetting VANISH_SOUND = new ConfigSetting(CONFIG, "Main.Vanish Sound", "ENTITY_GENERIC_EXPLODE",
"Sound to be played when going into vanish."); "Sound to be played when going into vanish.");
public static final ConfigSetting VANISH_BATS = new ConfigSetting(config, "Main.Release Bats On Vanish", true, public static final ConfigSetting VANISH_BATS = new ConfigSetting(CONFIG, "Main.Release Bats On Vanish", true,
"Shows bats when entering vanish."); "Shows bats when entering vanish.");
public static final ConfigSetting VANISH_PARTICLE = new ConfigSetting(config, "Main.Vanish Particle", "EXPLOSION_NORMAL", public static final ConfigSetting VANISH_PARTICLE = new ConfigSetting(CONFIG, "Main.Vanish Particle", "EXPLOSION_NORMAL",
"Show particles when entering vanish."); "Show particles when entering vanish.");
public static final ConfigSetting SLOW_MODE = new ConfigSetting(config, "Main.SLOW_MODE", "0s", 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."); "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"), 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."); "Prevents players from running the specified commands.");
public static final ConfigSetting AUTOSAVE = new ConfigSetting(config, "Main.Auto Save Interval In Seconds", 15, public static final ConfigSetting AUTOSAVE = new ConfigSetting(CONFIG, "Main.Auto Save Interval In Seconds", 15,
"The amount of time in between saving to file.", "The amount of time in between saving to file.",
"This is purely a safety function to prevent against unplanned crashes or", "This is purely a safety function to prevent against unplanned crashes or",
"restarts. With that said it is advised to keep this enabled.", "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."); "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', public static final ConfigSetting STAFFCHAT_COLOR_CODE = new ConfigSetting(CONFIG, "Main.Staff Chat Color Code", 'b',
"Color of messages sent in staff chat."); "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"), 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."); "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"), 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."); "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_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_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 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", public static final ConfigSetting LANGUGE_MODE = new ConfigSetting(CONFIG, "System.Language Mode", "en_US",
"The enabled language file.", "The enabled language file.",
"More language files (if available) can be found in the plugins data folder."); "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 = 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"), 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."); "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_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_HOSTNAME = new ConfigSetting(CONFIG, "MySQL.Hostname", "localhost");
public static final ConfigSetting MYSQL_PORT = new ConfigSetting(config, "MySQL.Port", 3306); 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_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_USERNAME = new ConfigSetting(CONFIG, "MySQL.Username", "user");
public static final ConfigSetting MYSQL_PASSWORD = new ConfigSetting(config, "MySQL.Password", "pass"); 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_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 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() { public static void setupConfig() {
config.load(); CONFIG.load();
config.setAutoremove(true).setAutosave(true); CONFIG.setAutoremove(true).setAutosave(true);
// convert glass pane settings // convert glass pane settings
int color; int color;
if ((color = GLASS_TYPE_1.getInt(-1)) != -1) { if ((color = GLASS_TYPE_1.getInt(-1)) != -1) {
config.set(GLASS_TYPE_1.getKey(), CompatibleMaterial.getGlassPaneColor(color).name()); CONFIG.set(GLASS_TYPE_1.getKey(), CompatibleMaterial.getGlassPaneForColor(color).name());
} }
if ((color = GLASS_TYPE_2.getInt(-1)) != -1) { if ((color = GLASS_TYPE_2.getInt(-1)) != -1) {
config.set(GLASS_TYPE_2.getKey(), CompatibleMaterial.getGlassPaneColor(color).name()); CONFIG.set(GLASS_TYPE_2.getKey(), CompatibleMaterial.getGlassPaneForColor(color).name());
} }
if ((color = GLASS_TYPE_3.getInt(-1)) != -1) { if ((color = GLASS_TYPE_3.getInt(-1)) != -1) {
config.set(GLASS_TYPE_3.getKey(), CompatibleMaterial.getGlassPaneColor(color).name()); CONFIG.set(GLASS_TYPE_3.getKey(), CompatibleMaterial.getGlassPaneForColor(color).name());
} }
config.saveChanges(); CONFIG.saveChanges();
} }
} }

View File

@ -1,8 +1,8 @@
package com.songoda.ultimatemoderation.staffchat; package com.songoda.ultimatemoderation.staffchat;
import com.craftaro.core.utils.TextUtils;
import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.UltimateModeration;
import com.songoda.ultimatemoderation.settings.Settings; import com.songoda.ultimatemoderation.settings.Settings;
import com.songoda.ultimatemoderation.utils.Methods;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -11,7 +11,6 @@ import java.util.List;
import java.util.UUID; import java.util.UUID;
public class StaffChannel { public class StaffChannel {
private final String channelName; private final String channelName;
private char chatChar = Settings.STAFFCHAT_COLOR_CODE.getChar(); private char chatChar = Settings.STAFFCHAT_COLOR_CODE.getChar();
private final List<UUID> members = new ArrayList<>(); private final List<UUID> members = new ArrayList<>();
@ -22,28 +21,35 @@ public class StaffChannel {
} }
public List<UUID> listMembers() { public List<UUID> listMembers() {
return new ArrayList<>(members); return new ArrayList<>(this.members);
} }
public void addMember(Player player) { public void addMember(Player player) {
if (members.contains(player.getUniqueId())) return; if (this.members.contains(player.getUniqueId())) {
return;
}
messageAll(UltimateModeration.getInstance().getLocale() messageAll(UltimateModeration.getInstance().getLocale()
.getMessage("event.staffchat.alljoin") .getMessage("event.staffchat.alljoin")
.processPlaceholder("player", player.getName()).getMessage(), player); .processPlaceholder("player", player.getName()).getMessage(), player);
UltimateModeration.getInstance().getStaffChatManager().getChats().values().stream().forEach(members1 -> { UltimateModeration.getInstance()
.getStaffChatManager()
.getChats()
.values()
.stream()
.forEach(members1 -> {
if (members1.listMembers().contains(player.getUniqueId())) { if (members1.listMembers().contains(player.getUniqueId())) {
members1.removeMember(player); members1.removeMember(player);
} }
}); });
members.add(player.getUniqueId()); this.members.add(player.getUniqueId());
if (chatLog.size() > 5) { if (this.chatLog.size() > 5) {
chatLog.stream().skip(chatLog.size() - 3).forEach(message -> player.sendMessage(Methods.formatText(message))); this.chatLog.stream().skip(this.chatLog.size() - 3).forEach(message -> player.sendMessage(TextUtils.formatText(message)));
} }
} }
public void removeMember(Player player) { public void removeMember(Player player) {
members.remove(player.getUniqueId()); this.members.remove(player.getUniqueId());
messageAll(UltimateModeration.getInstance().getLocale() messageAll(UltimateModeration.getInstance().getLocale()
.getMessage("event.staffchat.allleave") .getMessage("event.staffchat.allleave")
.processPlaceholder("player", player.getName()).getMessage(), player); .processPlaceholder("player", player.getName()).getMessage(), player);
@ -52,8 +58,8 @@ public class StaffChannel {
public void processMessage(String message, Player player) { public void processMessage(String message, Player player) {
messageAll(UltimateModeration.getInstance().getLocale() messageAll(UltimateModeration.getInstance().getLocale()
.getMessage("event.staffchat.format") .getMessage("event.staffchat.format")
.processPlaceholder("color", chatChar) .processPlaceholder("color", this.chatChar)
.processPlaceholder("channel", channelName) .processPlaceholder("channel", this.channelName)
.processPlaceholder("player", player.getDisplayName()) .processPlaceholder("player", player.getDisplayName())
.processPlaceholder("message", message).getMessage()); .processPlaceholder("message", message).getMessage());
} }
@ -63,20 +69,24 @@ public class StaffChannel {
} }
public void messageAll(String message, Player exempt) { public void messageAll(String message, Player exempt) {
chatLog.add(message); this.chatLog.add(message);
for (Player player : Bukkit.getOnlinePlayers()) { for (Player player : Bukkit.getOnlinePlayers()) {
if (exempt != null && player == exempt) continue; if (exempt != null && player == exempt) {
if (!members.contains(player.getUniqueId()) && !player.hasPermission("um.staffchat.spy")) continue; continue;
player.sendMessage(Methods.formatText(message)); }
if (!this.members.contains(player.getUniqueId()) && !player.hasPermission("um.staffchat.spy")) {
continue;
}
player.sendMessage(TextUtils.formatText(message));
} }
} }
public String getChannelName() { public String getChannelName() {
return channelName; return this.channelName;
} }
public char getChatChar() { public char getChatChar() {
return chatChar; return this.chatChar;
} }
public void setChatChar(char chatChar) { public void setChatChar(char chatChar) {

View File

@ -5,23 +5,24 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
public class StaffChatManager { public class StaffChatManager {
private final Map<String, StaffChannel> chats = new HashMap<>(); private final Map<String, StaffChannel> chats = new HashMap<>();
public Map<String, StaffChannel> getChats() { public Map<String, StaffChannel> getChats() {
return Collections.unmodifiableMap(chats); return Collections.unmodifiableMap(this.chats);
} }
public StaffChannel getChat(String channel) { 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) { public void removeChat(String channel) {
chats.remove(formatName(channel)); this.chats.remove(formatName(channel));
} }
private String formatName(String name) { private String formatName(String name) {
if (name == null) return null; if (name == null) {
return null;
}
name = name.toUpperCase().trim(); name = name.toUpperCase().trim();
name = name.replace(" ", "_"); name = name.replace(" ", "_");
return name; return name;

View File

@ -1,10 +1,10 @@
package com.songoda.ultimatemoderation.tasks; package com.songoda.ultimatemoderation.tasks;
import com.songoda.core.compatibility.ServerVersion; import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.core.utils.TimeUtils;
import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.UltimateModeration;
import com.songoda.ultimatemoderation.listeners.ChatListener; import com.songoda.ultimatemoderation.listeners.ChatListener;
import com.songoda.ultimatemoderation.settings.Settings; import com.songoda.ultimatemoderation.settings.Settings;
import com.songoda.ultimatemoderation.utils.Methods;
import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -14,7 +14,6 @@ import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class SlowModeTask extends BukkitRunnable { public class SlowModeTask extends BukkitRunnable {
private static SlowModeTask instance; private static SlowModeTask instance;
private static UltimateModeration plugin; private static UltimateModeration plugin;
@ -34,29 +33,33 @@ public class SlowModeTask extends BukkitRunnable {
@Override @Override
public void run() { 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(); List<ChatListener.Log> logs = ChatListener.getLogs();
Bukkit.getOnlinePlayers().forEach(player -> { 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()); 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); ChatListener.Log last = chats.get(chats.size() - 1);
if ((System.currentTimeMillis() - last.getSent()) < (slowmode + 1000)) { if ((System.currentTimeMillis() - last.getSent()) < (slowmode + 1000)) {
int remaining = (int) ((slowmode / 1000) - (System.currentTimeMillis() - last.getSent()) / 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 player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(remaining == 0
? plugin.getLocale().getMessage("event.slowmode.done").getMessage() ? plugin.getLocale().getMessage("event.slowmode.done").getMessage()
: plugin.getLocale().getMessage("event.slowmode.wait").processPlaceholder("delay", remaining).getMessage())); : plugin.getLocale().getMessage("event.slowmode.wait").processPlaceholder("delay", remaining).getMessage()));
}
} }
}); });
} }
}
}

View File

@ -8,7 +8,6 @@ import java.util.List;
import java.util.UUID; import java.util.UUID;
public class Ticket { public class Ticket {
private int id; private int id;
private TicketStatus status = TicketStatus.OPEN; private TicketStatus status = TicketStatus.OPEN;

View File

@ -9,7 +9,6 @@ import java.util.UUID;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class TicketManager { public class TicketManager {
private final TreeMap<Integer, Ticket> registeredTickets = new TreeMap<>(); private final TreeMap<Integer, Ticket> registeredTickets = new TreeMap<>();
public Ticket addTicket(Ticket ticket) { public Ticket addTicket(Ticket ticket) {

View File

@ -5,7 +5,6 @@ import org.bukkit.OfflinePlayer;
import java.util.UUID; import java.util.UUID;
public class TicketResponse { public class TicketResponse {
private int ticketId; private int ticketId;
private final UUID author; private final UUID author;

View File

@ -1,7 +1,6 @@
package com.songoda.ultimatemoderation.tickets; package com.songoda.ultimatemoderation.tickets;
public enum TicketStatus { public enum TicketStatus {
OPEN("Open"), OPEN("Open"),
CLOSED("Closed"); CLOSED("Closed");

View File

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

View File

@ -6,20 +6,18 @@ import org.bukkit.OfflinePlayer;
import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.RegisteredServiceProvider;
public class VaultPermissions { public class VaultPermissions {
// Vault
private static Permission vaultPermission = null; private static Permission vaultPermission = null;
static { static {
if (Bukkit.getServer().getPluginManager().getPlugin("Vault") != null) { if (Bukkit.getServer().getPluginManager().getPlugin("Vault") != null) {
RegisteredServiceProvider<Permission> permissionRsp = Bukkit.getServer().getServicesManager().getRegistration(Permission.class); 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) { public static boolean hasPermission(OfflinePlayer offlinePlayer, String perm) {
if (vaultPermission != null) return vaultPermission != null && vaultPermission.playerHas(Bukkit.getWorlds().get(0).getName(), offlinePlayer, perm);
return vaultPermission.playerHas(Bukkit.getWorlds().get(0).getName(), offlinePlayer, perm);
return false;
} }
} }

View File

@ -1,96 +1,121 @@
name: UltimateModeration name: ${project.name}
description: UltimateModeration description: ${project.description}
main: com.songoda.ultimatemoderation.UltimateModeration version: ${project.version}
version: maven-version-number
author: Songoda
api-version: 1.13 api-version: 1.13
softdepend: [Vault, FabledSkyBlock]
main: com.songoda.ultimatemoderation.UltimateModeration
softdepend:
- Vault
- FabledSkyBlock
author: Craftaro
website: ${project.url}
commands: commands:
UltimateModeration: UltimateModeration:
description: View information on this plugin. description: View information on this plugin.
default: true default: true
aliases: [um, p] aliases: [ um, p ]
usage: /um usage: /um
ClearChat: ClearChat:
description: Clear the chat description: Clear the chat
default: false default: false
aliases: [cc] aliases: [ cc ]
usage: /cc usage: /cc
ToggleChat: ToggleChat:
description: Toggle chat description: Toggle chat
default: false default: false
aliases: [tc] aliases: [ tc ]
usage: /tc usage: /tc
RandomPlayer: RandomPlayer:
description: Random Player description: Random Player
default: false default: false
aliases: [rp] aliases: [ rp ]
usage: /rp usage: /rp
Vanish: Vanish:
description: Vanish description: Vanish
default: false default: false
aliases: [v] aliases: [ v ]
usage: /v usage: /v
Spy: Spy:
description: Spy description: Spy
default: false default: false
usage: /spy usage: /spy
Revive: Revive:
description: Revive description: Revive
default: false default: false
usage: /revive usage: /revive
InvSee: InvSee:
description: InvSee description: InvSee
default: false default: false
usage: /invsee usage: /invsee
Freeze: Freeze:
description: Freeze description: Freeze
default: false default: false
usage: /freeze usage: /freeze
ViewEnderChest: ViewEnderChest:
description: ViewEnderChest description: ViewEnderChest
default: false default: false
usage: /ViewEnderChest usage: /ViewEnderChest
Ban: Ban:
description: Ban description: Ban
default: false default: false
usage: /ban usage: /ban
Unban: Unban:
description: Unban description: Unban
default: false default: false
usage: /unban usage: /unban
Kick: Kick:
description: Kick description: Kick
default: false default: false
usage: /kick usage: /kick
Mute: Mute:
description: Mute description: Mute
default: false default: false
usage: /mute usage: /mute
Unmute: Unmute:
description: Unmute description: Unmute
default: false default: false
usage: /unmute usage: /unmute
Warn: Warn:
description: Warn description: Warn
default: false default: false
usage: /warn usage: /warn
RunTemplate: RunTemplate:
description: RunTemplate description: RunTemplate
default: false default: false
usage: /runtemplate usage: /runtemplate
Ticket: Ticket:
description: Ticket description: Ticket
default: false default: false
aliases: [tickets] aliases: [ tickets ]
usage: /ticket usage: /ticket
StaffChat: StaffChat:
description: StaffChat description: StaffChat
default: false default: false
aliases: [sc] aliases: [ sc ]
usage: /staffchat usage: /staffchat
SlowMode: SlowMode:
description: SlowMode description: SlowMode
default: false default: false
aliases: [sm] aliases: [ sm ]
ussage: /slowmode ussage: /slowmode