mirror of
https://github.com/plexusorg/Plex.git
synced 2025-07-04 08:46:41 +00:00
Compare commits
29 Commits
Author | SHA1 | Date | |
---|---|---|---|
17aec8736f | |||
1b7511e817 | |||
159ed046cb | |||
d669da9f28 | |||
172080576c | |||
cc97612101 | |||
6a569bb638 | |||
d8c6c3b4a8 | |||
d7cbbc8d52 | |||
06e51926be | |||
3c0b79ba06 | |||
8f7fed5835 | |||
aa3aa7cb0e | |||
8e9acec1ff | |||
afd793cdba | |||
1d9662acde | |||
89199eb580 | |||
0aa9669f5f | |||
46d8debd18 | |||
69541a20b8 | |||
87ddf355b5 | |||
2804f6bc41 | |||
aa5e184a56 | |||
0a3594370a | |||
2cdd3a0e78 | |||
14fb24a380 | |||
e258e27814 | |||
41f4029877 | |||
0b5425b8d2 |
12
build.gradle
12
build.gradle
@ -19,10 +19,6 @@ repositories {
|
||||
url = uri("https://repo.maven.apache.org/maven2/")
|
||||
}
|
||||
|
||||
maven {
|
||||
name = "sonatype-oss-snapshots"
|
||||
url = uri("https://oss.sonatype.org/content/repositories/snapshots/")
|
||||
}
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
@ -36,17 +32,13 @@ dependencies {
|
||||
library "org.mariadb.jdbc:mariadb-java-client:3.0.3"
|
||||
library "org.apache.httpcomponents:httpclient:4.5.13"
|
||||
library "org.apache.commons:commons-lang3:3.12.0"
|
||||
compileOnly "io.papermc.paper:paper-api:1.18.1-R0.1-SNAPSHOT"
|
||||
compileOnly "io.papermc.paper:paper-api:1.18.2-R0.1-SNAPSHOT"
|
||||
implementation "org.bstats:bstats-base:3.0.0"
|
||||
implementation "org.bstats:bstats-bukkit:3.0.0"
|
||||
implementation("net.kyori:adventure-text-minimessage:4.2.0-SNAPSHOT") {
|
||||
exclude group: "net.kyori", module: "adventure-api"
|
||||
exclude group: "org.jetbrains", module: "annotations"
|
||||
}
|
||||
}
|
||||
|
||||
group = "dev.plex"
|
||||
version = "0.7"
|
||||
version = "0.9"
|
||||
description = "Plex"
|
||||
|
||||
shadowJar {
|
||||
|
@ -9,6 +9,7 @@ import dev.plex.cache.SQLPlayerData;
|
||||
import dev.plex.config.Config;
|
||||
import dev.plex.handlers.CommandHandler;
|
||||
import dev.plex.handlers.ListenerHandler;
|
||||
import dev.plex.module.ModuleManager;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.player.PunishedPlayer;
|
||||
import dev.plex.punishment.PunishmentManager;
|
||||
@ -22,6 +23,7 @@ import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.UpdateChecker;
|
||||
import dev.plex.world.CustomWorld;
|
||||
import java.io.File;
|
||||
import java.util.UUID;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@ -37,6 +39,9 @@ public class Plex extends JavaPlugin
|
||||
public Config config;
|
||||
public Config messages;
|
||||
public Config indefBans;
|
||||
|
||||
public File modulesFolder;
|
||||
|
||||
private StorageType storageType = StorageType.SQLITE;
|
||||
|
||||
private SQLConnection sqlConnection;
|
||||
@ -46,6 +51,7 @@ public class Plex extends JavaPlugin
|
||||
private MongoPlayerData mongoPlayerData;
|
||||
private SQLPlayerData sqlPlayerData;
|
||||
|
||||
private ModuleManager moduleManager;
|
||||
private RankManager rankManager;
|
||||
private ServiceManager serviceManager;
|
||||
|
||||
@ -70,9 +76,19 @@ public class Plex extends JavaPlugin
|
||||
messages = new Config(this, "messages.yml");
|
||||
indefBans = new Config(this, "indefbans.yml");
|
||||
|
||||
modulesFolder = new File(this.getDataFolder() + File.separator + "modules");
|
||||
if (!modulesFolder.exists())
|
||||
{
|
||||
modulesFolder.mkdir();
|
||||
}
|
||||
|
||||
sqlConnection = new SQLConnection();
|
||||
mongoConnection = new MongoConnection();
|
||||
redisConnection = new RedisConnection();
|
||||
|
||||
moduleManager = new ModuleManager();
|
||||
moduleManager.loadAllModules();
|
||||
moduleManager.loadModules();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -80,7 +96,11 @@ public class Plex extends JavaPlugin
|
||||
{
|
||||
config.load();
|
||||
messages.load();
|
||||
indefBans.load();
|
||||
// Don't add default entries to indefinite ban file
|
||||
indefBans.load(false);
|
||||
|
||||
moduleManager.enableModules();
|
||||
|
||||
system = config.getString("commands.permissions");
|
||||
|
||||
try
|
||||
@ -123,7 +143,6 @@ public class Plex extends JavaPlugin
|
||||
new ListenerHandler();
|
||||
new CommandHandler();
|
||||
|
||||
|
||||
rankManager = new RankManager();
|
||||
rankManager.generateDefaultRanks();
|
||||
rankManager.importDefaultRanks();
|
||||
@ -170,6 +189,8 @@ public class Plex extends JavaPlugin
|
||||
PlexLog.log("Disabling Redis/Jedis. No memory leaks in this Anarchy server!");
|
||||
redisConnection.getJedis().close();
|
||||
}
|
||||
|
||||
moduleManager.disableModules();
|
||||
}
|
||||
|
||||
private void generateWorlds()
|
||||
|
@ -29,19 +29,19 @@ public class Admin
|
||||
/**
|
||||
* Returns if the admin has command spy or not
|
||||
* <br>
|
||||
* Contains a #isCommandSpy and #setCommandSpy by lombok
|
||||
* Contains a #isCommandSpy and #setCommandSpy by Lombok
|
||||
*/
|
||||
private boolean commandSpy = true;
|
||||
private boolean commandSpy = false;
|
||||
|
||||
/**
|
||||
* Returns if the admin has staff chat toggled or not
|
||||
* Returns if the admin has admin chat toggled or not
|
||||
* <br>
|
||||
* Contains a #isStaffChat and #setStaffChat by lombok
|
||||
* Contains a #isAdminChat and #setAdminChat by Lombok
|
||||
*/
|
||||
private boolean staffChat = false;
|
||||
private boolean adminChat = false;
|
||||
|
||||
/**
|
||||
* Creates an admin with the startig ADMIN rank
|
||||
* Creates an admin with the ADMIN rank as the default rank
|
||||
*
|
||||
* @param uuid
|
||||
* @see UUID
|
||||
@ -52,6 +52,4 @@ public class Admin
|
||||
this.uuid = uuid;
|
||||
this.rank = Rank.ADMIN;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import dev.morphia.Datastore;
|
||||
import dev.morphia.query.Query;
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.PlexBase;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.storage.StorageType;
|
||||
@ -23,7 +23,7 @@ import java.util.stream.Collectors;
|
||||
* @see Admin
|
||||
*/
|
||||
|
||||
public class AdminList
|
||||
public class AdminList extends PlexBase
|
||||
{
|
||||
/**
|
||||
* Key/Value storage, where the key is the unique ID of the admin
|
||||
@ -59,15 +59,15 @@ public class AdminList
|
||||
public List<String> getAllAdmins()
|
||||
{
|
||||
List<String> admins = Lists.newArrayList();
|
||||
if (Plex.get().getStorageType() == StorageType.MONGODB)
|
||||
if (plugin.getStorageType() == StorageType.MONGODB)
|
||||
{
|
||||
Datastore store = Plex.get().getMongoConnection().getDatastore();
|
||||
Datastore store = plugin.getMongoConnection().getDatastore();
|
||||
Query<PlexPlayer> query = store.find(PlexPlayer.class);
|
||||
admins.addAll(query.stream().filter(plexPlayer -> plexPlayer.getRankFromString().isAtLeast(Rank.ADMIN)).map(PlexPlayer::getName).collect(Collectors.toList()));
|
||||
}
|
||||
else
|
||||
{
|
||||
try (Connection con = Plex.get().getSqlConnection().getCon())
|
||||
try (Connection con = plugin.getSqlConnection().getCon())
|
||||
{
|
||||
PreparedStatement statement = con.prepareStatement("SELECT * FROM `players` WHERE rank IN(?, ?, ?)");
|
||||
statement.setString(1, Rank.ADMIN.name().toLowerCase());
|
||||
@ -79,7 +79,6 @@ public class AdminList
|
||||
{
|
||||
admins.add(set.getString("name"));
|
||||
}
|
||||
|
||||
}
|
||||
catch (SQLException throwables)
|
||||
{
|
||||
@ -88,5 +87,4 @@ public class AdminList
|
||||
}
|
||||
return admins;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ import java.util.Arrays;
|
||||
import java.util.UUID;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -90,9 +91,8 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
||||
* Executes the command
|
||||
*
|
||||
* @param sender The sender of the command
|
||||
* @param playerSender The player who executed the command (null if command source is console or if command source is any but console executed)
|
||||
* @param playerSender The player who executed the command (null if CommandSource is console or if CommandSource is any but console executed)
|
||||
* @param args A Kyori Component to send to the sender (can be null)
|
||||
* @return
|
||||
*/
|
||||
protected abstract Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, @NotNull String[] args);
|
||||
|
||||
@ -165,9 +165,9 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the string given is a command string
|
||||
* Checks if the String given is a matching command
|
||||
*
|
||||
* @param label The string to check
|
||||
* @param label The String to check
|
||||
* @return true if the string is a command name or alias
|
||||
*/
|
||||
private boolean matches(String label)
|
||||
@ -202,9 +202,9 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a message to an audience
|
||||
* Sends a message to an Audience
|
||||
*
|
||||
* @param audience The audience to send the message to
|
||||
* @param audience The Audience to send the message to
|
||||
* @param s The message to send
|
||||
*/
|
||||
protected void send(Audience audience, String s)
|
||||
@ -213,10 +213,10 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a message to an audience
|
||||
* Sends a message to an Audience
|
||||
*
|
||||
* @param audience The audience to send the message to
|
||||
* @param component The component to send
|
||||
* @param audience The Audience to send the message to
|
||||
* @param component The Component to send
|
||||
*/
|
||||
protected void send(Audience audience, Component component)
|
||||
{
|
||||
@ -226,7 +226,7 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
||||
/**
|
||||
* Checks whether a sender has enough permissions or is high enough a rank
|
||||
*
|
||||
* @param sender A command sender
|
||||
* @param sender A CommandSender
|
||||
* @param rank The rank to check (if the server is using ranks)
|
||||
* @param permission The permission to check (if the server is using permissions)
|
||||
* @return true if the sender has enough permissions
|
||||
@ -415,7 +415,7 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
||||
*
|
||||
* @param s The message entry
|
||||
* @param objects Any objects to replace in order
|
||||
* @return A Kyori component
|
||||
* @return A Kyori Component
|
||||
*/
|
||||
protected Component messageComponent(String s, Object... objects)
|
||||
{
|
||||
@ -435,25 +435,25 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts usage to a component
|
||||
* Converts usage to a Component
|
||||
*
|
||||
* @return A Kyori component stating the usage
|
||||
* @return A Kyori Component stating the usage
|
||||
*/
|
||||
protected Component usage()
|
||||
{
|
||||
return componentFromString(ChatColor.YELLOW + "Correct Usage: " + ChatColor.GRAY + this.getUsage());
|
||||
return Component.text("Correct Usage: ").color(NamedTextColor.YELLOW).append(componentFromString(this.getUsage()).color(NamedTextColor.GRAY));
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts usage to a component
|
||||
* Converts usage to a Component
|
||||
* <p>
|
||||
* s The usage to convert
|
||||
*
|
||||
* @return A Kyori component stating the usage
|
||||
* @return A Kyori Component stating the usage
|
||||
*/
|
||||
protected Component usage(String s)
|
||||
{
|
||||
return componentFromString(ChatColor.YELLOW + "Correct Usage: " + ChatColor.GRAY + s);
|
||||
return Component.text("Correct Usage: ").color(NamedTextColor.YELLOW).append(componentFromString(s).color(NamedTextColor.GRAY));
|
||||
}
|
||||
|
||||
protected Player getNonNullPlayer(String name)
|
||||
@ -498,25 +498,30 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a string to a legacy Kyori component
|
||||
* Converts a String to a legacy Kyori Component
|
||||
*
|
||||
* @param s The string to convert
|
||||
* @param s The String to convert
|
||||
* @return A Kyori component
|
||||
*/
|
||||
protected Component componentFromString(String s)
|
||||
{
|
||||
return LegacyComponentSerializer.legacyAmpersand().deserialize(s).colorIfAbsent(NamedTextColor.GRAY);
|
||||
}
|
||||
|
||||
protected Component noColorComponentFromString(String s)
|
||||
{
|
||||
return LegacyComponentSerializer.legacyAmpersand().deserialize(s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a string to a mini message kyori component
|
||||
* Converts a String to a MiniMessage Component
|
||||
*
|
||||
* @param s The string to convert
|
||||
* @return A Kyori component
|
||||
* @param s The String to convert
|
||||
* @return A Kyori Component
|
||||
*/
|
||||
protected Component mmString(String s)
|
||||
{
|
||||
return MiniMessage.miniMessage().parse(s);
|
||||
return MiniMessage.miniMessage().deserialize(s);
|
||||
}
|
||||
|
||||
public Rank getLevel()
|
||||
|
8
src/main/java/dev/plex/command/annotation/System.java
Normal file
8
src/main/java/dev/plex/command/annotation/System.java
Normal file
@ -0,0 +1,8 @@
|
||||
package dev.plex.command.annotation;
|
||||
|
||||
public @interface System
|
||||
{
|
||||
String value() default "";
|
||||
|
||||
boolean debug() default false;
|
||||
}
|
@ -5,6 +5,7 @@ import dev.plex.cache.DataUtils;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.annotation.System;
|
||||
import dev.plex.command.exception.ConsoleOnlyException;
|
||||
import dev.plex.command.exception.PlayerNotFoundException;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
@ -26,7 +27,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = RequiredCommandSource.ANY)
|
||||
@CommandParameters(name = "admin", usage = "/<command> <add | remove | setrank | list> [player] [rank]", aliases = "saconfig,slconfig,adminconfig,adminmanage", description = "Manage all admins")
|
||||
@CommandParameters(name = "admin", usage = "/<command> <add <player> | remove <player> | setrank <player> <rank> | list>", aliases = "saconfig,slconfig,adminconfig,adminmanage", description = "Manage all admins")
|
||||
@System("ranks")
|
||||
public class AdminCMD extends PlexCommand
|
||||
{
|
||||
//TODO: Better return messages
|
||||
|
@ -1,13 +1,16 @@
|
||||
package dev.plex.command.impl;
|
||||
|
||||
import dev.plex.cache.PlayerCache;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.listener.impl.ChatListener;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -25,7 +28,30 @@ public class AdminChatCMD extends PlexCommand
|
||||
return usage();
|
||||
}
|
||||
|
||||
ChatListener.adminChat(sender, StringUtils.join(args, " "));
|
||||
adminChat(sender, StringUtils.join(args, " "));
|
||||
return null;
|
||||
}
|
||||
|
||||
private void adminChat(CommandSender sender, String message)
|
||||
{
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
if (plugin.getSystem().equalsIgnoreCase("ranks"))
|
||||
{
|
||||
PlexPlayer plexPlayer = PlayerCache.getPlexPlayerMap().get(player.getUniqueId());
|
||||
if (plexPlayer.getRankFromString().isAtLeast(Rank.ADMIN))
|
||||
{
|
||||
player.sendMessage(PlexUtils.messageComponent("adminChatFormat", sender.getName(), message));
|
||||
}
|
||||
}
|
||||
else if (plugin.getSystem().equalsIgnoreCase("permissions"))
|
||||
{
|
||||
if (player.hasPermission("plex.adminchat"))
|
||||
{
|
||||
player.sendMessage(PlexUtils.messageComponent("adminChatFormat", sender.getName(), message));
|
||||
}
|
||||
}
|
||||
}
|
||||
plugin.getServer().getConsoleSender().sendMessage(PlexUtils.messageComponent("adminChatFormat", sender.getName(), message));
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.google.common.collect.ImmutableList;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.annotation.System;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.PlexUtils;
|
||||
@ -17,8 +18,9 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@CommandParameters(name = "debug", description = "Debug command", usage = "/<command> <redis-reset | gamerules> [player]")
|
||||
@CommandParameters(name = "pdebug", description = "Plex's debug command", usage = "/<command> <redis-reset <player> | gamerules>")
|
||||
@CommandPermissions(level = Rank.EXECUTIVE, permission = "plex.debug")
|
||||
@System(debug = true)
|
||||
public class DebugCMD extends PlexCommand
|
||||
{
|
||||
@Override
|
||||
|
@ -3,6 +3,7 @@ package dev.plex.command.impl;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.annotation.System;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@ -14,6 +15,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@CommandParameters(name = "deopall", description = "Deop everyone on the server", aliases = "deopa")
|
||||
@CommandPermissions(level = Rank.ADMIN)
|
||||
@System("ranks")
|
||||
public class DeopAllCMD extends PlexCommand
|
||||
{
|
||||
@Override
|
||||
|
@ -4,6 +4,7 @@ import com.google.common.collect.ImmutableList;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.annotation.System;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import java.util.List;
|
||||
@ -15,6 +16,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@CommandParameters(name = "deop", description = "Deop a player on the server", usage = "/<command> <player>")
|
||||
@CommandPermissions(level = Rank.ADMIN, permission = "plex.deop")
|
||||
@System("ranks")
|
||||
public class DeopCMD extends PlexCommand
|
||||
{
|
||||
@Override
|
||||
|
@ -4,11 +4,11 @@ import com.google.common.collect.Lists;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.annotation.System;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import java.util.List;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -17,13 +17,15 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@CommandParameters(name = "list", description = "Show a list of all online players")
|
||||
@CommandPermissions(level = Rank.OP, permission = "plex.list")
|
||||
@System("ranks")
|
||||
public class ListCMD extends PlexCommand
|
||||
{
|
||||
@Override
|
||||
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
|
||||
{
|
||||
List<Player> players = Lists.newArrayList(Bukkit.getOnlinePlayers());
|
||||
Component component = Component.text("There " + (players.size() == 1 ? "is" : "are") + " currently").color(NamedTextColor.GRAY)
|
||||
Component list = Component.empty();
|
||||
Component header = Component.text("There " + (players.size() == 1 ? "is" : "are") + " currently").color(NamedTextColor.GRAY)
|
||||
.append(Component.space())
|
||||
.append(Component.text(players.size()).color(NamedTextColor.YELLOW))
|
||||
.append(Component.space())
|
||||
@ -33,18 +35,17 @@ public class ListCMD extends PlexCommand
|
||||
.append(Component.space())
|
||||
.append(Component.text(Bukkit.getMaxPlayers()).color(NamedTextColor.YELLOW))
|
||||
.append(Component.space())
|
||||
.append(Component.text(Bukkit.getMaxPlayers() == 1 ? "player." : "players.").color(NamedTextColor.GRAY))
|
||||
.append(Component.newline());
|
||||
.append(Component.text(Bukkit.getMaxPlayers() == 1 ? "player." : "players.").color(NamedTextColor.GRAY));
|
||||
send(sender, header);
|
||||
for (int i = 0; i < players.size(); i++)
|
||||
{
|
||||
Player player = players.get(i);
|
||||
component = component.append(LegacyComponentSerializer.legacyAmpersand().deserialize(getPlexPlayer(player).getRankFromString().getPrefix())).append(Component.space()).append(Component.text(player.getName()).color(NamedTextColor.WHITE));
|
||||
list = list.append(getPlexPlayer(player).getRankFromString().getPrefix()).append(Component.space()).append(Component.text(player.getName()).color(NamedTextColor.WHITE));
|
||||
if (i != players.size() - 1)
|
||||
{
|
||||
component = component.append(Component.text(",")).append(Component.space());
|
||||
list = list.append(Component.text(",")).append(Component.space());
|
||||
}
|
||||
}
|
||||
|
||||
return component;
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
@ -7,20 +7,15 @@ import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.player.PunishedPlayer;
|
||||
import dev.plex.punishment.Punishment;
|
||||
import dev.plex.punishment.PunishmentType;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import java.util.List;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandParameters(name = "lockup", description = "Lockup a player on the server", usage = "/<command> <player>")
|
||||
@CommandPermissions(level = Rank.ADMIN, permission = "plex.lockup")
|
||||
public class LockupCMD extends PlexCommand
|
||||
@ -49,7 +44,7 @@ public class LockupCMD extends PlexCommand
|
||||
}
|
||||
|
||||
punishedPlayer.setLockedUp(!punishedPlayer.isLockedUp());
|
||||
PlexUtils.broadcast(messageComponent(punishedPlayer.isLockedUp() ? "lockedUpPlayer" : "unlockedUpPlayer", sender.getName(), player.getName()));
|
||||
PlexUtils.broadcast(messageComponent(punishedPlayer.isLockedUp() ? "lockedUpPlayer" : "unlockedPlayer", sender.getName(), player.getName()));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,6 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -49,11 +48,9 @@ public class NameHistoryCMD extends PlexCommand
|
||||
if (history.getLocalDateTime() != null)
|
||||
{
|
||||
historyList.add(
|
||||
Component.text(history.getUsername()).color(NamedTextColor.GOLD)
|
||||
.append(Component.space())
|
||||
.append(Component.text("-").color(NamedTextColor.DARK_GRAY))
|
||||
.append(Component.space())
|
||||
.append(Component.text(DATE_FORMAT.format(history.getLocalDateTime())).color(NamedTextColor.GOLD)));
|
||||
messageComponent("nameHistoryBody",
|
||||
history.getUsername(),
|
||||
DATE_FORMAT.format(history.getLocalDateTime())));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -62,8 +59,8 @@ public class NameHistoryCMD extends PlexCommand
|
||||
.append(Component.space()));
|
||||
}
|
||||
});
|
||||
send(sender, Component.text("Name History (" + username + ")").color(NamedTextColor.GOLD));
|
||||
send(sender, Component.text("-----------------------------").color(NamedTextColor.GOLD).decoration(TextDecoration.STRIKETHROUGH, true));
|
||||
send(sender, messageComponent("nameHistoryTitle", username));
|
||||
send(sender, messageComponent("nameHistorySeparator"));
|
||||
historyList.forEach(component -> send(sender, component));
|
||||
return null;
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package dev.plex.command.impl;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.annotation.System;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@ -14,6 +15,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@CommandParameters(name = "opall", description = "Op everyone on the server", aliases = "opa")
|
||||
@CommandPermissions(level = Rank.ADMIN)
|
||||
@System("ranks")
|
||||
public class OpAllCMD extends PlexCommand
|
||||
{
|
||||
@Override
|
||||
@ -26,5 +28,4 @@ public class OpAllCMD extends PlexCommand
|
||||
PlexUtils.broadcast(messageComponent("oppedAllPlayers", sender.getName()));
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -4,6 +4,7 @@ import com.google.common.collect.ImmutableList;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.annotation.System;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import java.util.List;
|
||||
@ -15,6 +16,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@CommandParameters(name = "op", description = "Op a player on the server", usage = "/<command> <player>")
|
||||
@CommandPermissions(level = Rank.OP)
|
||||
@System("ranks")
|
||||
public class OpCMD extends PlexCommand
|
||||
{
|
||||
@Override
|
||||
|
@ -1,23 +1,26 @@
|
||||
package dev.plex.command.impl;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.exception.CommandFailException;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.module.PlexModule;
|
||||
import dev.plex.module.PlexModuleFile;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, permission = "plex.plex", source = RequiredCommandSource.ANY)
|
||||
@CommandParameters(name = "plex", usage = "/<command> [reload | redis]", aliases = "plexhelp", description = "Show information about Plex or reload it")
|
||||
@CommandParameters(name = "plex", usage = "/<command> [reload | redis | modules [reload]]", description = "Show information about Plex or reload it")
|
||||
public class PlexCMD extends PlexCommand
|
||||
{
|
||||
// Don't modify this command
|
||||
@ -26,9 +29,11 @@ public class PlexCMD extends PlexCommand
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
send(sender, ChatColor.LIGHT_PURPLE + "Plex - A new freedom plugin.");
|
||||
send(sender, ChatColor.LIGHT_PURPLE + "Plugin version: " + plugin.getDescription().getVersion());
|
||||
return componentFromString(ChatColor.LIGHT_PURPLE + "Authors: " + ChatColor.GOLD + "Telesphoreo, Taahh");
|
||||
send(sender, mmString("<light_purple>Plex - A new freedom plugin."));
|
||||
send(sender, mmString("<light_purple>Plugin version: <gold>" + plugin.getDescription().getVersion()));
|
||||
send(sender, mmString("<light_purple>Authors: <gold>Telesphoreo, Taahh"));
|
||||
send(sender, mmString("<light_purple>Run <gold>/plex modules <light_purple>to see a list of modules."));
|
||||
return null;
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("reload"))
|
||||
{
|
||||
@ -37,12 +42,13 @@ public class PlexCMD extends PlexCommand
|
||||
send(sender, "Reloaded config file");
|
||||
plugin.messages.load();
|
||||
send(sender, "Reloaded messages file");
|
||||
plugin.indefBans.load();
|
||||
plugin.indefBans.load(false);
|
||||
plugin.getPunishmentManager().mergeIndefiniteBans();
|
||||
send(sender, "Reloaded indefinite bans");
|
||||
plugin.getRankManager().importDefaultRanks();
|
||||
send(sender, "Imported ranks");
|
||||
send(sender, "Plex successfully reloaded.");
|
||||
return null;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("redis"))
|
||||
{
|
||||
@ -55,6 +61,23 @@ public class PlexCMD extends PlexCommand
|
||||
send(sender, "Set test to 123. Now outputting key test...");
|
||||
send(sender, plugin.getRedisConnection().getJedis().get("test"));
|
||||
plugin.getRedisConnection().getJedis().close();
|
||||
return null;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("modules"))
|
||||
{
|
||||
if (args.length == 1)
|
||||
{
|
||||
return mmString("<gold>Modules (" + plugin.getModuleManager().getModules().size() + "): <yellow>" + StringUtils.join(plugin.getModuleManager().getModules().stream().map(PlexModule::getPlexModuleFile).map(PlexModuleFile::getName).collect(Collectors.toList()), ", "));
|
||||
}
|
||||
if (args[1].equalsIgnoreCase("reload"))
|
||||
{
|
||||
checkRank(sender, Rank.SENIOR_ADMIN, "plex.modules.reload");
|
||||
plugin.getModuleManager().unloadModules();
|
||||
plugin.getModuleManager().loadAllModules();
|
||||
plugin.getModuleManager().loadModules();
|
||||
plugin.getModuleManager().enableModules();
|
||||
return componentFromString("All modules reloaded!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -66,6 +89,14 @@ public class PlexCMD extends PlexCommand
|
||||
@Override
|
||||
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
return ImmutableList.of("reload", "redis");
|
||||
if (args.length == 1)
|
||||
{
|
||||
return Arrays.asList("reload", "redis", "modules");
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("modules"))
|
||||
{
|
||||
return List.of("reload");
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
@ -22,7 +22,7 @@ public class PunishmentsCMD extends PlexCommand
|
||||
@Override
|
||||
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
|
||||
{
|
||||
new PunishmentMenu().openInv(((Player)sender), 0);
|
||||
new PunishmentMenu().openInv(playerSender, 0);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,8 @@ package dev.plex.command.impl;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.annotation.System;
|
||||
import dev.plex.command.exception.CommandFailException;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@ -11,8 +13,9 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, permission = "plex.rank", source = RequiredCommandSource.IN_GAME)
|
||||
@CommandPermissions(level = Rank.OP, permission = "plex.rank", source = RequiredCommandSource.ANY)
|
||||
@CommandParameters(name = "rank", description = "Displays your rank")
|
||||
@System("ranks")
|
||||
public class RankCMD extends PlexCommand
|
||||
{
|
||||
@Override
|
||||
@ -20,6 +23,10 @@ public class RankCMD extends PlexCommand
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
if (isConsole(sender))
|
||||
{
|
||||
throw new CommandFailException("<red>When using the console, you must specify a player's rank.");
|
||||
}
|
||||
if (!(playerSender == null))
|
||||
{
|
||||
Rank rank = getPlexPlayer(playerSender).getRankFromString();
|
||||
|
@ -19,7 +19,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, permission = "plex.tag", source = RequiredCommandSource.ANY)
|
||||
@CommandParameters(name = "tag", aliases = "prefix", description = "Manages your prefix", usage = "/<command> <set | clear> <prefix | player>")
|
||||
@CommandParameters(name = "tag", aliases = "prefix", description = "Set or clear your prefix", usage = "/<command> <set <prefix> | clear <player>>")
|
||||
public class TagCMD extends PlexCommand
|
||||
{
|
||||
@Override
|
||||
@ -47,8 +47,7 @@ public class TagCMD extends PlexCommand
|
||||
return usage("/tag set <prefix>");
|
||||
}
|
||||
String prefix = StringUtils.join(args, " ", 1, args.length);
|
||||
|
||||
Component convertedComponent = removeEvents(componentFromString(prefix));
|
||||
Component convertedComponent = removeEvents(noColorComponentFromString(prefix));
|
||||
convertedComponent = removeEvents(MiniMessage.miniMessage().deserialize(LegacyComponentSerializer.legacySection().serialize(convertedComponent)));
|
||||
|
||||
if (PlainTextComponentSerializer.plainText().serialize(convertedComponent).length() > plugin.config.getInt("chat.max-tag-length", 16))
|
||||
|
@ -50,35 +50,43 @@ public class Config extends YamlConfiguration
|
||||
}
|
||||
}
|
||||
|
||||
public void load()
|
||||
{
|
||||
this.load(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the configuration file
|
||||
*/
|
||||
public void load()
|
||||
public void load(boolean loadFromFile)
|
||||
{
|
||||
try
|
||||
{
|
||||
YamlConfiguration externalYamlConfig = YamlConfiguration.loadConfiguration(file);
|
||||
InputStreamReader internalConfigFileStream = new InputStreamReader(Plex.get().getResource(name), StandardCharsets.UTF_8);
|
||||
YamlConfiguration internalYamlConfig = YamlConfiguration.loadConfiguration(internalConfigFileStream);
|
||||
if (loadFromFile)
|
||||
{
|
||||
YamlConfiguration externalYamlConfig = YamlConfiguration.loadConfiguration(file);
|
||||
InputStreamReader internalConfigFileStream = new InputStreamReader(Plex.get().getResource(name), StandardCharsets.UTF_8);
|
||||
YamlConfiguration internalYamlConfig = YamlConfiguration.loadConfiguration(internalConfigFileStream);
|
||||
|
||||
// Gets all the keys inside the internal file and iterates through all of it's key pairs
|
||||
for (String string : internalYamlConfig.getKeys(true))
|
||||
{
|
||||
// Checks if the external file contains the key already.
|
||||
if (!externalYamlConfig.contains(string))
|
||||
// Gets all the keys inside the internal file and iterates through all of it's key pairs
|
||||
for (String string : internalYamlConfig.getKeys(true))
|
||||
{
|
||||
// If it doesn't contain the key, we set the key based off what was found inside the plugin jar
|
||||
externalYamlConfig.setComments(string, internalYamlConfig.getComments(string));
|
||||
externalYamlConfig.set(string, internalYamlConfig.get(string));
|
||||
PlexLog.log("Setting key: " + string + " in " + this.name + " to the default value(s) since it does not exist!");
|
||||
added = true;
|
||||
// Checks if the external file contains the key already.
|
||||
if (!externalYamlConfig.contains(string))
|
||||
{
|
||||
// If it doesn't contain the key, we set the key based off what was found inside the plugin jar
|
||||
externalYamlConfig.setComments(string, internalYamlConfig.getComments(string));
|
||||
externalYamlConfig.set(string, internalYamlConfig.get(string));
|
||||
PlexLog.log("Setting key: " + string + " in " + this.name + " to the default value(s) since it does not exist!");
|
||||
added = true;
|
||||
}
|
||||
}
|
||||
if (added)
|
||||
{
|
||||
externalYamlConfig.save(file);
|
||||
PlexLog.log("Saving new file...");
|
||||
added = false;
|
||||
}
|
||||
}
|
||||
if (added)
|
||||
{
|
||||
externalYamlConfig.save(file);
|
||||
PlexLog.log("Saving new file...");
|
||||
added = false;
|
||||
}
|
||||
super.load(file);
|
||||
}
|
||||
|
@ -3,56 +3,49 @@ package dev.plex.handlers;
|
||||
import com.google.common.collect.Lists;
|
||||
import dev.plex.PlexBase;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.impl.*;
|
||||
import dev.plex.command.annotation.System;
|
||||
import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
//TODO: Switch to Reflections API
|
||||
public class CommandHandler extends PlexBase
|
||||
{
|
||||
public CommandHandler()
|
||||
{
|
||||
Set<Class<? extends PlexCommand>> commandSet = PlexUtils.getClassesBySubType("dev.plex.command.impl", PlexCommand.class);
|
||||
List<PlexCommand> commands = Lists.newArrayList();
|
||||
if (plugin.getSystem().equalsIgnoreCase("ranks"))
|
||||
{
|
||||
commands.add(new AdminCMD());
|
||||
commands.add(new DeopAllCMD());
|
||||
commands.add(new DeopCMD());
|
||||
commands.add(new OpAllCMD());
|
||||
commands.add(new OpCMD());
|
||||
commands.add(new RankCMD());
|
||||
}
|
||||
if (plugin.config.getBoolean("debug"))
|
||||
{
|
||||
commands.add(new DebugCMD());
|
||||
}
|
||||
|
||||
commands.add(new AdminChatCMD());
|
||||
commands.add(new AdminworldCMD());
|
||||
commands.add(new AdventureCMD());
|
||||
commands.add(new BanCMD());
|
||||
commands.add(new CommandSpyCMD());
|
||||
commands.add(new CreativeCMD());
|
||||
commands.add(new FlatlandsCMD());
|
||||
commands.add(new FreezeCMD());
|
||||
commands.add(new KickCMD());
|
||||
commands.add(new ListCMD());
|
||||
commands.add(new LocalSpawnCMD());
|
||||
commands.add(new LockupCMD());
|
||||
commands.add(new MasterbuilderworldCMD());
|
||||
commands.add(new MuteCMD());
|
||||
commands.add(new NameHistoryCMD());
|
||||
commands.add(new PlexCMD());
|
||||
commands.add(new PunishmentsCMD());
|
||||
commands.add(new RawSayCMD());
|
||||
commands.add(new SpectatorCMD());
|
||||
commands.add(new SurvivalCMD());
|
||||
commands.add(new TagCMD());
|
||||
commands.add(new TempbanCMD());
|
||||
commands.add(new UnbanCMD());
|
||||
commands.add(new UnfreezeCMD());
|
||||
commands.add(new UnmuteCMD());
|
||||
commands.add(new WorldCMD());
|
||||
PlexLog.log(String.format("Registered %s commands!", commands.size()));
|
||||
commandSet.forEach(clazz ->
|
||||
{
|
||||
try
|
||||
{
|
||||
System annotation = clazz.getDeclaredAnnotation(System.class);
|
||||
if (annotation != null)
|
||||
{
|
||||
if (annotation.value().equalsIgnoreCase(plugin.getSystem()))
|
||||
{
|
||||
commands.add(clazz.getConstructor().newInstance());
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.config.getBoolean("debug") && annotation.debug())
|
||||
{
|
||||
commands.add(clazz.getConstructor().newInstance());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
commands.add(clazz.getConstructor().newInstance());
|
||||
}
|
||||
}
|
||||
catch (InvocationTargetException | InstantiationException | IllegalAccessException | NoSuchMethodException ex)
|
||||
{
|
||||
PlexLog.error("Failed to register " + clazz.getSimpleName() + " as a command!");
|
||||
}
|
||||
});
|
||||
|
||||
PlexLog.log(String.format("Registered %s commands from %s classes!", commands.size(), commandSet.size()));
|
||||
}
|
||||
}
|
||||
|
@ -1,34 +1,44 @@
|
||||
package dev.plex.handlers;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import dev.plex.PlexBase;
|
||||
import dev.plex.listener.PlexListener;
|
||||
import dev.plex.listener.impl.AdminListener;
|
||||
import dev.plex.listener.impl.BanListener;
|
||||
import dev.plex.listener.impl.ChatListener;
|
||||
import dev.plex.listener.impl.CommandListener;
|
||||
import dev.plex.listener.impl.FreezeListener;
|
||||
import dev.plex.listener.impl.GameModeListener;
|
||||
import dev.plex.listener.impl.PlayerListener;
|
||||
import dev.plex.listener.impl.ServerListener;
|
||||
import dev.plex.listener.impl.WorldListener;
|
||||
import dev.plex.listener.annotation.Toggled;
|
||||
import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
//TODO: Switch to Reflections API
|
||||
public class ListenerHandler
|
||||
public class ListenerHandler extends PlexBase
|
||||
{
|
||||
public ListenerHandler()
|
||||
{
|
||||
Set<Class<? extends PlexListener>> listenerSet = PlexUtils.getClassesBySubType("dev.plex.listener.impl", PlexListener.class);
|
||||
List<PlexListener> listeners = Lists.newArrayList();
|
||||
listeners.add(new AdminListener());
|
||||
listeners.add(new BanListener());
|
||||
listeners.add(new ChatListener());
|
||||
listeners.add(new CommandListener());
|
||||
listeners.add(new FreezeListener());
|
||||
listeners.add(new GameModeListener());
|
||||
listeners.add(new PlayerListener());
|
||||
listeners.add(new ServerListener());
|
||||
listeners.add(new WorldListener());
|
||||
PlexLog.log(String.format("Registered %s listeners!", listeners.size()));
|
||||
|
||||
listenerSet.forEach(clazz ->
|
||||
{
|
||||
try
|
||||
{
|
||||
Toggled annotation = clazz.getDeclaredAnnotation(Toggled.class);
|
||||
if (annotation != null)
|
||||
{
|
||||
if (plugin.config.getBoolean("chat.enabled") && annotation.enabled())
|
||||
{
|
||||
listeners.add(clazz.getConstructor().newInstance());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
listeners.add(clazz.getConstructor().newInstance());
|
||||
}
|
||||
}
|
||||
catch (InvocationTargetException | InstantiationException | IllegalAccessException | NoSuchMethodException ex)
|
||||
{
|
||||
PlexLog.error("Failed to register " + clazz.getSimpleName() + " as a listener!");
|
||||
}
|
||||
});
|
||||
PlexLog.log(String.format("Registered %s listeners from %s classes!", listeners.size(), listenerSet.size()));
|
||||
}
|
||||
}
|
||||
|
6
src/main/java/dev/plex/listener/annotation/Toggled.java
Normal file
6
src/main/java/dev/plex/listener/annotation/Toggled.java
Normal file
@ -0,0 +1,6 @@
|
||||
package dev.plex.listener.annotation;
|
||||
|
||||
public @interface Toggled
|
||||
{
|
||||
boolean enabled() default false;
|
||||
}
|
@ -2,49 +2,24 @@ package dev.plex.listener.impl;
|
||||
|
||||
import dev.plex.cache.PlayerCache;
|
||||
import dev.plex.listener.PlexListener;
|
||||
import dev.plex.listener.annotation.Toggled;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import io.papermc.paper.chat.ChatRenderer;
|
||||
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@Toggled(enabled = true)
|
||||
public class ChatListener extends PlexListener
|
||||
{
|
||||
private final PlexChatRenderer renderer = new PlexChatRenderer();
|
||||
|
||||
public static void adminChat(CommandSender sender, String message)
|
||||
{
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
if (plugin.getSystem().equalsIgnoreCase("ranks"))
|
||||
{
|
||||
PlexPlayer plexPlayer = PlayerCache.getPlexPlayerMap().get(player.getUniqueId());
|
||||
if (plexPlayer.getRankFromString().isAtLeast(Rank.ADMIN))
|
||||
{
|
||||
player.sendMessage(PlexUtils.messageComponent("adminChatFormat", sender.getName(), message));
|
||||
}
|
||||
}
|
||||
else if (plugin.getSystem().equalsIgnoreCase("permissions"))
|
||||
{
|
||||
if (player.hasPermission("plex.adminchat"))
|
||||
{
|
||||
player.sendMessage(PlexUtils.messageComponent("adminChatFormat", sender.getName(), message));
|
||||
}
|
||||
}
|
||||
}
|
||||
plugin.getServer().getConsoleSender().sendMessage(PlexUtils.messageComponent("adminChatFormat", sender.getName(), message));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onChat(AsyncChatEvent event)
|
||||
{
|
||||
@ -56,8 +31,8 @@ public class ChatListener extends PlexListener
|
||||
return;
|
||||
}
|
||||
|
||||
String prefix = plugin.getRankManager().getPrefix(plexPlayer);
|
||||
if (!prefix.isEmpty())
|
||||
Component prefix = plugin.getRankManager().getPrefix(plexPlayer);
|
||||
if (prefix != null)
|
||||
{
|
||||
renderer.hasPrefix = true;
|
||||
renderer.prefix = prefix;
|
||||
@ -73,14 +48,15 @@ public class ChatListener extends PlexListener
|
||||
public static class PlexChatRenderer implements ChatRenderer
|
||||
{
|
||||
public boolean hasPrefix;
|
||||
public String prefix;
|
||||
public Component prefix;
|
||||
|
||||
@Override
|
||||
public @NotNull Component render(@NotNull Player source, @NotNull Component sourceDisplayName, @NotNull Component message, @NotNull Audience viewer)
|
||||
{
|
||||
if (hasPrefix)
|
||||
{
|
||||
return Component.empty().append(MiniMessage.miniMessage().deserialize(prefix))
|
||||
return Component.empty()
|
||||
.append(prefix)
|
||||
.append(Component.space())
|
||||
.append(LegacyComponentSerializer.legacyAmpersand().deserialize("&" + plugin.config.getString("chat.name-color") + LegacyComponentSerializer.legacyAmpersand().serialize(sourceDisplayName)))
|
||||
.append(Component.space())
|
||||
@ -89,7 +65,7 @@ public class ChatListener extends PlexListener
|
||||
.append(message);
|
||||
}
|
||||
return Component.empty()
|
||||
.append(sourceDisplayName)
|
||||
.append(LegacyComponentSerializer.legacyAmpersand().deserialize("&" + plugin.config.getString("chat.name-color") + LegacyComponentSerializer.legacyAmpersand().serialize(sourceDisplayName)))
|
||||
.append(Component.space())
|
||||
.append(Component.text("»").color(NamedTextColor.GRAY))
|
||||
.append(Component.space())
|
||||
|
@ -11,11 +11,8 @@ import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import java.util.Collections;
|
||||
import java.util.UUID;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -50,9 +47,9 @@ public class PlayerListener extends PlexListener
|
||||
if (!DataUtils.hasPlayedBefore(player.getUniqueId()))
|
||||
{
|
||||
PlexLog.log("A player with this name has not joined the server before, creating new entry.");
|
||||
plexPlayer = new PlexPlayer(player.getUniqueId()); //it doesn't! okay so now create the object
|
||||
plexPlayer.setName(player.getName()); //set the name of the player
|
||||
plexPlayer.setIps(Collections.singletonList(player.getAddress().getAddress().getHostAddress().trim())); //set the arraylist of ips
|
||||
plexPlayer = new PlexPlayer(player.getUniqueId()); // it doesn't! okay so now create the object
|
||||
plexPlayer.setName(player.getName()); // set the name of the player
|
||||
plexPlayer.setIps(Collections.singletonList(player.getAddress().getAddress().getHostAddress().trim())); // set the arraylist of ips
|
||||
DataUtils.insert(plexPlayer); // insert data in some wack db
|
||||
}
|
||||
else
|
||||
@ -69,14 +66,10 @@ public class PlayerListener extends PlexListener
|
||||
}
|
||||
|
||||
assert plexPlayer != null;
|
||||
|
||||
String loginMessage = plugin.getRankManager().getLoginMessage(plexPlayer);
|
||||
|
||||
if (!loginMessage.isEmpty())
|
||||
{
|
||||
PlexUtils.broadcast(
|
||||
Component.text(ChatColor.AQUA + player.getName() + " is ").color(NamedTextColor.AQUA)
|
||||
.append(LegacyComponentSerializer.legacyAmpersand().deserialize(loginMessage)));
|
||||
PlexUtils.broadcast(MiniMessage.miniMessage().deserialize("<aqua>" + player.getName() + " is " + loginMessage));
|
||||
}
|
||||
}
|
||||
|
||||
|
48
src/main/java/dev/plex/listener/impl/TabListener.java
Normal file
48
src/main/java/dev/plex/listener/impl/TabListener.java
Normal file
@ -0,0 +1,48 @@
|
||||
package dev.plex.listener.impl;
|
||||
|
||||
import dev.plex.cache.DataUtils;
|
||||
import dev.plex.event.AdminAddEvent;
|
||||
import dev.plex.event.AdminRemoveEvent;
|
||||
import dev.plex.event.AdminSetRankEvent;
|
||||
import dev.plex.listener.PlexListener;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
public class TabListener extends PlexListener
|
||||
{
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
PlexPlayer plexPlayer = DataUtils.getPlayer(player.getUniqueId());
|
||||
player.playerListName(Component.text(player.getName()).color(plugin.getRankManager().getColor(plexPlayer)));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onAdminAdd(AdminAddEvent event)
|
||||
{
|
||||
PlexPlayer plexPlayer = event.getPlexPlayer();
|
||||
Player player = event.getPlexPlayer().getPlayer();
|
||||
player.playerListName(Component.text(player.getName()).color(plugin.getRankManager().getColor(plexPlayer)));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onAdminRemove(AdminRemoveEvent event)
|
||||
{
|
||||
PlexPlayer plexPlayer = event.getPlexPlayer();
|
||||
Player player = event.getPlexPlayer().getPlayer();
|
||||
player.playerListName(Component.text(player.getName()).color(plugin.getRankManager().getColor(plexPlayer)));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onAdminSetRank(AdminSetRankEvent event)
|
||||
{
|
||||
PlexPlayer plexPlayer = event.getPlexPlayer();
|
||||
Player player = event.getPlexPlayer().getPlayer();
|
||||
player.playerListName(Component.text(player.getName()).color(plugin.getRankManager().getColor(plexPlayer)));
|
||||
}
|
||||
}
|
133
src/main/java/dev/plex/module/ModuleManager.java
Normal file
133
src/main/java/dev/plex/module/ModuleManager.java
Normal file
@ -0,0 +1,133 @@
|
||||
package dev.plex.module;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.module.exception.ModuleLoadException;
|
||||
import dev.plex.util.PlexLog;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import lombok.Getter;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
@Getter
|
||||
public class ModuleManager
|
||||
{
|
||||
|
||||
private final List<PlexModule> modules = Lists.newArrayList();
|
||||
|
||||
public void loadAllModules()
|
||||
{
|
||||
this.modules.clear();
|
||||
PlexLog.debug(String.valueOf(Plex.get().getModulesFolder().listFiles().length));
|
||||
Arrays.stream(Plex.get().getModulesFolder().listFiles()).forEach(file ->
|
||||
{
|
||||
if (file.getName().endsWith(".jar"))
|
||||
{
|
||||
try
|
||||
{
|
||||
URLClassLoader loader = new URLClassLoader(
|
||||
new URL[]{file.toURI().toURL()},
|
||||
Plex.class.getClassLoader()
|
||||
);
|
||||
|
||||
InputStreamReader internalModuleFile = new InputStreamReader(loader.getResourceAsStream("module.yml"), StandardCharsets.UTF_8);
|
||||
YamlConfiguration internalModuleConfig = YamlConfiguration.loadConfiguration(internalModuleFile);
|
||||
|
||||
String name = internalModuleConfig.getString("name");
|
||||
if (name == null)
|
||||
{
|
||||
throw new ModuleLoadException("Plex module name can't be null!");
|
||||
}
|
||||
|
||||
String main = internalModuleConfig.getString("main");
|
||||
if (main == null)
|
||||
{
|
||||
throw new ModuleLoadException("Plex module main class can't be null!");
|
||||
}
|
||||
|
||||
String description = internalModuleConfig.getString("description", "A Plex module");
|
||||
String version = internalModuleConfig.getString("version", "1.0");
|
||||
|
||||
PlexModuleFile plexModuleFile = new PlexModuleFile(name, main, description, version);
|
||||
Class<? extends PlexModule> module = (Class<? extends PlexModule>)Class.forName(main, true, loader);
|
||||
|
||||
PlexModule plexModule = module.getConstructor().newInstance();
|
||||
plexModule.setPlex(Plex.get());
|
||||
plexModule.setPlexModuleFile(plexModuleFile);
|
||||
|
||||
plexModule.setDataFolder(new File(Plex.get().getModulesFolder() + File.separator + plexModuleFile.getName()));
|
||||
if (!plexModule.getDataFolder().exists())
|
||||
{
|
||||
plexModule.getDataFolder().mkdir();
|
||||
}
|
||||
|
||||
plexModule.setLogger(LogManager.getLogger(plexModuleFile.getName()));
|
||||
modules.add(plexModule);
|
||||
}
|
||||
catch (MalformedURLException | ClassNotFoundException | InvocationTargetException | InstantiationException | IllegalAccessException | NoSuchMethodException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void loadModules()
|
||||
{
|
||||
this.modules.forEach(module ->
|
||||
{
|
||||
PlexLog.log("Loading module " + module.getPlexModuleFile().getName() + " with version " + module.getPlexModuleFile().getVersion());
|
||||
module.load();
|
||||
});
|
||||
}
|
||||
|
||||
public void enableModules()
|
||||
{
|
||||
this.modules.forEach(module ->
|
||||
{
|
||||
PlexLog.log("Enabling module " + module.getPlexModuleFile().getName() + " with version " + module.getPlexModuleFile().getVersion());
|
||||
module.enable();
|
||||
});
|
||||
}
|
||||
|
||||
public void disableModules()
|
||||
{
|
||||
this.modules.forEach(module ->
|
||||
{
|
||||
PlexLog.log("Disabling module " + module.getPlexModuleFile().getName() + " with version " + module.getPlexModuleFile().getVersion());
|
||||
module.getCommands().stream().toList().forEach(plexCommand ->
|
||||
{
|
||||
module.unregisterCommand(plexCommand);
|
||||
Plex.get().getServer().getCommandMap().getKnownCommands().remove(plexCommand.getName());
|
||||
plexCommand.getAliases().forEach(alias -> Plex.get().getServer().getCommandMap().getKnownCommands().remove(alias));
|
||||
});
|
||||
module.getListeners().stream().toList().forEach(module::unregisterListener);
|
||||
module.disable();
|
||||
});
|
||||
}
|
||||
|
||||
public void unloadModules()
|
||||
{
|
||||
this.disableModules();
|
||||
this.modules.forEach(module ->
|
||||
{
|
||||
try
|
||||
{
|
||||
((URLClassLoader)module.getClass().getClassLoader()).close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
68
src/main/java/dev/plex/module/PlexModule.java
Normal file
68
src/main/java/dev/plex/module/PlexModule.java
Normal file
@ -0,0 +1,68 @@
|
||||
package dev.plex.module;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.listener.PlexListener;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
@Getter
|
||||
@Setter(AccessLevel.MODULE)
|
||||
public abstract class PlexModule
|
||||
{
|
||||
@Getter(AccessLevel.MODULE)
|
||||
private final List<PlexCommand> commands = Lists.newArrayList();
|
||||
|
||||
@Getter(AccessLevel.MODULE)
|
||||
private final List<PlexListener> listeners = Lists.newArrayList();
|
||||
|
||||
private Plex plex;
|
||||
private PlexModuleFile plexModuleFile;
|
||||
private File dataFolder;
|
||||
private Logger logger;
|
||||
|
||||
public void load()
|
||||
{
|
||||
}
|
||||
|
||||
public void enable()
|
||||
{
|
||||
}
|
||||
|
||||
public void disable()
|
||||
{
|
||||
}
|
||||
|
||||
public void registerListener(PlexListener listener)
|
||||
{
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
public void unregisterListener(PlexListener listener)
|
||||
{
|
||||
listeners.remove(listener);
|
||||
HandlerList.unregisterAll(listener);
|
||||
}
|
||||
|
||||
public void registerCommand(PlexCommand command)
|
||||
{
|
||||
commands.add(command);
|
||||
}
|
||||
|
||||
public void unregisterCommand(PlexCommand command)
|
||||
{
|
||||
commands.remove(command);
|
||||
}
|
||||
|
||||
public PlexCommand getCommand(String name)
|
||||
{
|
||||
return commands.stream().filter(plexCommand -> plexCommand.getName().equalsIgnoreCase(name) || plexCommand.getAliases().stream().map(String::toLowerCase).toList().contains(name.toLowerCase(Locale.ROOT))).findFirst().orElse(null);
|
||||
}
|
||||
}
|
12
src/main/java/dev/plex/module/PlexModuleFile.java
Normal file
12
src/main/java/dev/plex/module/PlexModuleFile.java
Normal file
@ -0,0 +1,12 @@
|
||||
package dev.plex.module;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PlexModuleFile
|
||||
{
|
||||
private final String name;
|
||||
private final String main;
|
||||
private final String description;
|
||||
private final String version;
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package dev.plex.module.exception;
|
||||
|
||||
public class ModuleLoadException extends RuntimeException
|
||||
{
|
||||
public ModuleLoadException(String s)
|
||||
{
|
||||
super(s);
|
||||
}
|
||||
|
||||
}
|
@ -11,6 +11,7 @@ import java.util.UUID;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
@ -30,6 +30,7 @@ public class Punishment
|
||||
private boolean customTime;
|
||||
private boolean active; // Field is only for bans
|
||||
private LocalDateTime endDate;
|
||||
|
||||
public Punishment(UUID punished, UUID punisher)
|
||||
{
|
||||
this.punished = punished;
|
||||
|
@ -7,7 +7,6 @@ import com.google.gson.Gson;
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.PlexBase;
|
||||
import dev.plex.cache.PlayerCache;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.player.PunishedPlayer;
|
||||
import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.PlexUtils;
|
||||
@ -15,17 +14,17 @@ import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.json.JSONObject;
|
||||
import org.json.JSONTokener;
|
||||
@ -33,43 +32,28 @@ import redis.clients.jedis.Jedis;
|
||||
|
||||
public class PunishmentManager extends PlexBase
|
||||
{
|
||||
private final List<String> bannedIPs = Lists.newArrayList();
|
||||
private final List<String> bannedUsernames = Lists.newArrayList();
|
||||
private final List<UUID> bannedUUIDs = Lists.newArrayList();
|
||||
private final List<IndefiniteBan> indefiniteBans = Lists.newArrayList();
|
||||
|
||||
public void mergeIndefiniteBans()
|
||||
{
|
||||
this.bannedUsernames.clear();
|
||||
this.bannedIPs.clear();
|
||||
this.bannedUUIDs.clear();
|
||||
|
||||
this.bannedUUIDs.addAll(Plex.get().indefBans.getStringList("uuids").stream().filter(string ->
|
||||
this.indefiniteBans.clear();
|
||||
Plex.get().indefBans.getKeys(false).forEach(key ->
|
||||
{
|
||||
try
|
||||
{
|
||||
UUID uuid = UUID.fromString(string);
|
||||
return true;
|
||||
} catch (IllegalArgumentException e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}).map(UUID::fromString).toList());
|
||||
IndefiniteBan ban = new IndefiniteBan();
|
||||
ban.ips.addAll(Plex.get().getIndefBans().getStringList(key + ".ips"));
|
||||
ban.usernames.addAll(Plex.get().getIndefBans().getStringList(key + ".users"));
|
||||
ban.uuids.addAll(Plex.get().getIndefBans().getStringList(key + ".uuids").stream().map(UUID::fromString).toList());
|
||||
this.indefiniteBans.add(ban);
|
||||
});
|
||||
|
||||
this.bannedIPs.addAll(Plex.get().indefBans.getStringList("ips"));
|
||||
this.bannedUsernames.addAll(Plex.get().indefBans.getStringList("usernames"));
|
||||
|
||||
PlexLog.log("Loaded {0} UUID(s), {1} IP(s), and {2} username(s) as indefinitely banned", this.bannedUUIDs.size(), this.bannedIPs.size(), this.bannedUsernames.size());
|
||||
PlexLog.log("Loaded {0} UUID(s), {1} IP(s), and {2} username(s) as indefinitely banned", this.indefiniteBans.stream().map(IndefiniteBan::getUuids).mapToLong(Collection::size).sum(), this.indefiniteBans.stream().map(IndefiniteBan::getIps).mapToLong(Collection::size).sum(), this.indefiniteBans.stream().map(IndefiniteBan::getUsernames).mapToLong(Collection::size).sum());
|
||||
|
||||
if (Plex.get().getRedisConnection().isEnabled())
|
||||
{
|
||||
PlexLog.log("Asynchronously uploading all indefinite bans to Redis");
|
||||
Plex.get().getRedisConnection().runAsync(jedis -> {
|
||||
jedis.set("indefbanned-uuids", new Gson().toJson(this.bannedUUIDs));
|
||||
jedis.set("indefbanned-ips", new Gson().toJson(this.bannedIPs));
|
||||
jedis.set("indefbanned-users", new Gson().toJson(this.bannedUsernames));
|
||||
this.bannedIPs.clear();
|
||||
this.bannedUsernames.clear();
|
||||
this.bannedUUIDs.clear();
|
||||
Plex.get().getRedisConnection().runAsync(jedis ->
|
||||
{
|
||||
jedis.set("indefbans", new Gson().toJson(indefiniteBans));
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -78,30 +62,39 @@ public class PunishmentManager extends PlexBase
|
||||
{
|
||||
if (Plex.get().getRedisConnection().isEnabled())
|
||||
{
|
||||
List<UUID> uuids = new Gson().fromJson(Plex.get().getRedisConnection().getJedis().get("indefbanned-uuids"), new TypeToken<List<UUID>>(){}.getType());
|
||||
return uuids.contains(uuid);
|
||||
PlexLog.debug("Checking if UUID is banned in Redis");
|
||||
List<IndefiniteBan> bans = new Gson().fromJson(Plex.get().getRedisConnection().getJedis().get("indefbans"), new TypeToken<List<IndefiniteBan>>()
|
||||
{
|
||||
}.getType());
|
||||
return bans.stream().anyMatch(indefiniteBan -> indefiniteBan.getUuids().contains(uuid));
|
||||
}
|
||||
return this.bannedUUIDs.contains(uuid);
|
||||
return this.indefiniteBans.stream().anyMatch(indefiniteBan -> indefiniteBan.getUuids().contains(uuid));
|
||||
}
|
||||
|
||||
public boolean isIndefIPBanned(String ip)
|
||||
{
|
||||
if (Plex.get().getRedisConnection().isEnabled())
|
||||
{
|
||||
List<String> ips = new Gson().fromJson(Plex.get().getRedisConnection().getJedis().get("indefbanned-ips"), new TypeToken<List<String>>(){}.getType());
|
||||
return ips.contains(ip);
|
||||
PlexLog.debug("Checking if IP is banned in Redis");
|
||||
List<IndefiniteBan> bans = new Gson().fromJson(Plex.get().getRedisConnection().getJedis().get("indefbans"), new TypeToken<List<IndefiniteBan>>()
|
||||
{
|
||||
}.getType());
|
||||
return bans.stream().anyMatch(indefiniteBan -> indefiniteBan.getIps().contains(ip));
|
||||
}
|
||||
return this.bannedIPs.contains(ip);
|
||||
return this.indefiniteBans.stream().anyMatch(indefiniteBan -> indefiniteBan.getIps().contains(ip));
|
||||
}
|
||||
|
||||
public boolean isIndefUserBanned(String username)
|
||||
{
|
||||
if (Plex.get().getRedisConnection().isEnabled())
|
||||
{
|
||||
List<String> users = new Gson().fromJson(Plex.get().getRedisConnection().getJedis().get("indefbanned-users"), new TypeToken<List<String>>(){}.getType());
|
||||
return users.contains(username);
|
||||
PlexLog.debug("Checking if username is banned in Redis");
|
||||
List<IndefiniteBan> bans = new Gson().fromJson(Plex.get().getRedisConnection().getJedis().get("indefbans"), new TypeToken<List<IndefiniteBan>>()
|
||||
{
|
||||
}.getType());
|
||||
return bans.stream().anyMatch(indefiniteBan -> indefiniteBan.getUsernames().contains(username));
|
||||
}
|
||||
return this.bannedUsernames.contains(username);
|
||||
return this.indefiniteBans.stream().anyMatch(indefiniteBan -> indefiniteBan.getUsernames().contains(username));
|
||||
}
|
||||
|
||||
public void insertPunishment(PunishedPlayer player, Punishment punishment)
|
||||
@ -182,28 +175,31 @@ public class PunishmentManager extends PlexBase
|
||||
public List<Punishment> getActiveBans()
|
||||
{
|
||||
List<Punishment> punishments = Lists.newArrayList();
|
||||
Jedis jedis = Plex.get().getRedisConnection().getJedis();
|
||||
jedis.keys("*").forEach(key ->
|
||||
{
|
||||
try
|
||||
{
|
||||
UUID uuid = UUID.fromString(key);
|
||||
String jsonPunishmentString = jedis.get(uuid.toString());
|
||||
JSONObject object = new JSONObject(jsonPunishmentString);
|
||||
object.getJSONObject(uuid.toString()).getJSONArray("punishments").forEach(json ->
|
||||
{
|
||||
Punishment punishment = Punishment.fromJson(json.toString());
|
||||
if (punishment.isActive() && punishment.getType() == PunishmentType.BAN)
|
||||
{
|
||||
punishments.add(punishment);
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (IllegalArgumentException ignored)
|
||||
{
|
||||
|
||||
}
|
||||
});
|
||||
if (Plex.get().getRedisConnection().isEnabled())
|
||||
{
|
||||
Jedis jedis = Plex.get().getRedisConnection().getJedis();
|
||||
jedis.keys("*").forEach(key ->
|
||||
{
|
||||
try
|
||||
{
|
||||
UUID uuid = UUID.fromString(key);
|
||||
String jsonPunishmentString = jedis.get(uuid.toString());
|
||||
JSONObject object = new JSONObject(jsonPunishmentString);
|
||||
object.getJSONObject(uuid.toString()).getJSONArray("punishments").forEach(json ->
|
||||
{
|
||||
Punishment punishment = Punishment.fromJson(json.toString());
|
||||
if (punishment.isActive() && punishment.getType() == PunishmentType.BAN)
|
||||
{
|
||||
punishments.add(punishment);
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (IllegalArgumentException ignored)
|
||||
{
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return punishments;
|
||||
}
|
||||
@ -320,4 +316,12 @@ public class PunishmentManager extends PlexBase
|
||||
issuePunishment(player, punishment);
|
||||
insertPunishment(player, punishment);
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class IndefiniteBan
|
||||
{
|
||||
private final List<String> usernames = Lists.newArrayList();
|
||||
private final List<UUID> uuids = Lists.newArrayList();
|
||||
private final List<String> ips = Lists.newArrayList();
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import dev.plex.Plex;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.rank.enums.Title;
|
||||
import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@ -12,6 +13,9 @@ import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.SneakyThrows;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.json.JSONTokener;
|
||||
@ -88,11 +92,11 @@ public class RankManager
|
||||
}
|
||||
}
|
||||
|
||||
public String getPrefix(PlexPlayer player)
|
||||
public Component getPrefix(PlexPlayer player)
|
||||
{
|
||||
if (!player.getPrefix().isEmpty())
|
||||
if (!player.getPrefix().equals(""))
|
||||
{
|
||||
return player.getPrefix();
|
||||
return MiniMessage.miniMessage().deserialize(player.getPrefix());
|
||||
}
|
||||
if (Plex.get().config.contains("titles.owners") && Plex.get().config.getStringList("titles.owners").contains(player.getName()))
|
||||
{
|
||||
@ -110,7 +114,7 @@ public class RankManager
|
||||
{
|
||||
return player.getRankFromString().getPrefix();
|
||||
}
|
||||
return "";
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getLoginMessage(PlexPlayer player)
|
||||
@ -138,6 +142,27 @@ public class RankManager
|
||||
return "";
|
||||
}
|
||||
|
||||
public NamedTextColor getColor(PlexPlayer player)
|
||||
{
|
||||
if (Plex.get().config.contains("titles.owners") && Plex.get().config.getStringList("titles.owners").contains(player.getName()))
|
||||
{
|
||||
return Title.OWNER.getColor();
|
||||
}
|
||||
if (PlexUtils.DEVELOPERS.contains(player.getUuid())) // don't remove or we will front door ur mother
|
||||
{
|
||||
return Title.DEV.getColor();
|
||||
}
|
||||
if (Plex.get().config.contains("titles.masterbuilders") && Plex.get().config.getStringList("titles.masterbuilders").contains(player.getName()))
|
||||
{
|
||||
return Title.MASTER_BUILDER.getColor();
|
||||
}
|
||||
if (Plex.get().getSystem().equalsIgnoreCase("ranks") && isAdmin(player))
|
||||
{
|
||||
return player.getRankFromString().getColor();
|
||||
}
|
||||
return NamedTextColor.WHITE;
|
||||
}
|
||||
|
||||
public boolean isAdmin(PlexPlayer plexPlayer)
|
||||
{
|
||||
return !plexPlayer.getRank().isEmpty() && plexPlayer.getRankFromString().isAtLeast(Rank.ADMIN);
|
||||
|
@ -2,20 +2,20 @@ package dev.plex.rank.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.json.JSONObject;
|
||||
|
||||
@Getter
|
||||
public enum Rank
|
||||
{
|
||||
IMPOSTOR(-1, ChatColor.AQUA + "an " + ChatColor.YELLOW + "Impostor", "Impostor", "&8[&eImp&8]"),
|
||||
NONOP(0, "a " + ChatColor.WHITE + "Non-Op", "Non-Op", ""),
|
||||
OP(1, "an " + ChatColor.GREEN + "Operator", "Operator", "&8[&aOP&8]"),
|
||||
ADMIN(2, "an " + ChatColor.DARK_GREEN + "Admin", "Admin", "&8[&2Admin&8]"),
|
||||
SENIOR_ADMIN(3, "a " + ChatColor.GOLD + "Senior Admin", "Senior Admin", "&8[&6SrA&8]"),
|
||||
EXECUTIVE(4, "an " + ChatColor.RED + "Executive", "Executive", "&8[&cExec&8]");
|
||||
IMPOSTOR(-1, "<aqua>an <yellow>Impostor", "Impostor", "<dark_gray>[<yellow>Imp<dark_gray>]", NamedTextColor.YELLOW),
|
||||
NONOP(0, "a <white>Non-Op", "Non-Op", "", NamedTextColor.WHITE),
|
||||
OP(1, "an <green>Op", "Operator", "<dark_gray>[<green>OP<dark_gray>]", NamedTextColor.GREEN),
|
||||
ADMIN(2, "an <dark_green>Admin", "Admin", "<dark_gray>[<green>Admin<dark_gray>]", NamedTextColor.DARK_GREEN),
|
||||
SENIOR_ADMIN(3, "a <gold>Senior Admin", "Senior Admin", "<dark_gray>[<gold>SrA<dark_gray>]", NamedTextColor.GOLD),
|
||||
EXECUTIVE(4, "an <red>Executive", "Executive", "<dark_gray>[<red>Exec<dark_gray>]", NamedTextColor.RED);
|
||||
|
||||
private final int level;
|
||||
|
||||
@ -28,12 +28,16 @@ public enum Rank
|
||||
@Setter
|
||||
private String prefix;
|
||||
|
||||
Rank(int level, String loginMessage, String readable, String prefix)
|
||||
@Getter
|
||||
private NamedTextColor color;
|
||||
|
||||
Rank(int level, String loginMessage, String readable, String prefix, NamedTextColor color)
|
||||
{
|
||||
this.level = level;
|
||||
this.loginMessage = loginMessage;
|
||||
this.readable = readable;
|
||||
this.prefix = prefix;
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public boolean isAtLeast(Rank rank)
|
||||
@ -41,9 +45,9 @@ public enum Rank
|
||||
return this.level >= rank.getLevel();
|
||||
}
|
||||
|
||||
public String getPrefix()
|
||||
public Component getPrefix()
|
||||
{
|
||||
return MiniMessage.miniMessage().serialize(LegacyComponentSerializer.legacyAmpersand().deserialize(this.prefix));
|
||||
return MiniMessage.miniMessage().deserialize(this.prefix);
|
||||
}
|
||||
|
||||
public JSONObject toJSON()
|
||||
|
@ -2,17 +2,17 @@ package dev.plex.rank.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.json.JSONObject;
|
||||
|
||||
@Getter
|
||||
public enum Title
|
||||
{
|
||||
MASTER_BUILDER(0, ChatColor.AQUA + "a " + ChatColor.DARK_AQUA + "Master Builder", "Master Builder", "&8[&3Master Builder&8]"),
|
||||
DEV(1, ChatColor.AQUA + "a " + ChatColor.DARK_PURPLE + "Developer", "Developer", "&8[&5Developer&8]"),
|
||||
OWNER(2, ChatColor.AQUA + "an " + ChatColor.BLUE + "Owner", "Owner", "&8[&9Owner&8]");
|
||||
MASTER_BUILDER(0, "<aqua>a <dark_aqua>Master Builder", "Master Builder", "<dark_gray>[<dark_aqua>Master Builder<dark_gray>]", NamedTextColor.DARK_AQUA),
|
||||
DEV(1, "<aqua>a <dark_purple>Developer", "Developer", "<dark_gray>[<dark_purple>Developer<dark_gray>]", NamedTextColor.DARK_PURPLE),
|
||||
OWNER(2, "<aqua>an <blue>Owner", "Owner", "<dark_gray>[<blue>Owner<dark_gray>]", NamedTextColor.BLUE);
|
||||
|
||||
private final int level;
|
||||
|
||||
@ -25,17 +25,21 @@ public enum Title
|
||||
@Setter
|
||||
private String prefix;
|
||||
|
||||
Title(int level, String loginMessage, String readable, String prefix)
|
||||
@Getter
|
||||
private NamedTextColor color;
|
||||
|
||||
Title(int level, String loginMessage, String readable, String prefix, NamedTextColor color)
|
||||
{
|
||||
this.level = level;
|
||||
this.loginMessage = loginMessage;
|
||||
this.readable = readable;
|
||||
this.prefix = prefix;
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public String getPrefix()
|
||||
public Component getPrefix()
|
||||
{
|
||||
return MiniMessage.miniMessage().serialize(LegacyComponentSerializer.legacyAmpersand().deserialize(this.prefix));
|
||||
return MiniMessage.miniMessage().deserialize(this.prefix);
|
||||
}
|
||||
|
||||
public JSONObject toJSON()
|
||||
|
@ -4,13 +4,13 @@ import dev.plex.services.AbstractService;
|
||||
|
||||
public class UpdateCheckerService extends AbstractService
|
||||
{
|
||||
private boolean newVersion = false;
|
||||
|
||||
public UpdateCheckerService()
|
||||
{
|
||||
super(true, true);
|
||||
}
|
||||
|
||||
private boolean newVersion = false;
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
@ -29,4 +29,4 @@ public class UpdateCheckerService extends AbstractService
|
||||
// Every 30 minutes
|
||||
return 1800;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import com.mongodb.client.MongoClients;
|
||||
import dev.morphia.Datastore;
|
||||
import dev.morphia.Morphia;
|
||||
import dev.morphia.mapping.MapperOptions;
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.PlexBase;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
|
||||
|
@ -2,9 +2,8 @@ package dev.plex.storage;
|
||||
|
||||
import dev.plex.PlexBase;
|
||||
import dev.plex.util.PlexLog;
|
||||
import redis.clients.jedis.Jedis;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import redis.clients.jedis.Jedis;
|
||||
|
||||
public class RedisConnection extends PlexBase
|
||||
{
|
||||
@ -32,7 +31,8 @@ public class RedisConnection extends PlexBase
|
||||
|
||||
public void runAsync(Consumer<Jedis> jedisConsumer)
|
||||
{
|
||||
new Thread(() -> {
|
||||
new Thread(() ->
|
||||
{
|
||||
try (Jedis jedis = getJedis())
|
||||
{
|
||||
jedisConsumer.accept(jedis);
|
||||
|
@ -1,13 +1,11 @@
|
||||
package dev.plex.util;
|
||||
|
||||
import dev.plex.PlexBase;
|
||||
import dev.plex.Plex;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
public class PlexLog extends PlexBase
|
||||
public class PlexLog
|
||||
{
|
||||
private static final boolean debugEnabled = plugin.config.getBoolean("debug");
|
||||
|
||||
public static void log(String message, Object... strings)
|
||||
{
|
||||
for (int i = 0; i < strings.length; i++)
|
||||
@ -41,7 +39,7 @@ public class PlexLog extends PlexBase
|
||||
message = message.replace("{" + i + "}", strings[i].toString());
|
||||
}
|
||||
}
|
||||
if (debugEnabled)
|
||||
if (Plex.get().config.getBoolean("debug"))
|
||||
{
|
||||
Bukkit.getConsoleSender().sendMessage(String.format(ChatColor.DARK_PURPLE + "[Plex Debug] " + ChatColor.GOLD + "%s", message));
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package dev.plex.util;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.reflect.ClassPath;
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.PlexBase;
|
||||
import dev.plex.config.Config;
|
||||
@ -15,12 +17,15 @@ import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.stream.Collectors;
|
||||
@ -131,7 +136,7 @@ public class PlexUtils extends PlexBase
|
||||
|
||||
public static Component messageComponent(String entry, Object... objects)
|
||||
{
|
||||
return MiniMessage.miniMessage().parse(LegacyComponentSerializer.legacySection().serialize(LegacyComponentSerializer.legacyAmpersand().deserialize(messageString(entry, objects))));
|
||||
return MiniMessage.miniMessage().deserialize(LegacyComponentSerializer.legacySection().serialize(LegacyComponentSerializer.legacyAmpersand().deserialize(messageString(entry, objects))));
|
||||
}
|
||||
|
||||
public static String messageString(String entry, Object... objects)
|
||||
@ -320,6 +325,50 @@ public class PlexUtils extends PlexBase
|
||||
return UUID.fromString(uuidString);
|
||||
}
|
||||
|
||||
@SuppressWarnings("UnstableApiUsage")
|
||||
public static Set<Class<?>> getClassesFrom(String packageName)
|
||||
{
|
||||
Set<Class<?>> classes = new HashSet<>();
|
||||
try
|
||||
{
|
||||
ClassPath path = ClassPath.from(Plex.class.getClassLoader());
|
||||
ImmutableSet<ClassPath.ClassInfo> infoSet = path.getTopLevelClasses(packageName);
|
||||
infoSet.forEach(info ->
|
||||
{
|
||||
try
|
||||
{
|
||||
Class<?> clazz = Class.forName(info.getName());
|
||||
classes.add(clazz);
|
||||
}
|
||||
catch (ClassNotFoundException ex)
|
||||
{
|
||||
PlexLog.error("Unable to find class " + info.getName() + " in " + packageName);
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
PlexLog.error("Something went wrong while fetching classes from " + packageName);
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
return Collections.unmodifiableSet(classes);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> Set<Class<? extends T>> getClassesBySubType(String packageName, Class<T> subType)
|
||||
{
|
||||
Set<Class<?>> loadedClasses = getClassesFrom(packageName);
|
||||
Set<Class<? extends T>> classes = new HashSet<>();
|
||||
loadedClasses.forEach(clazz ->
|
||||
{
|
||||
if (clazz.getSuperclass() == subType || Arrays.asList(clazz.getInterfaces()).contains(subType))
|
||||
{
|
||||
classes.add((Class<? extends T>)clazz);
|
||||
}
|
||||
});
|
||||
return Collections.unmodifiableSet(classes);
|
||||
}
|
||||
|
||||
public static int randomNum()
|
||||
{
|
||||
return ThreadLocalRandom.current().nextInt();
|
||||
|
@ -14,6 +14,11 @@ public class UpdateChecker extends PlexBase
|
||||
|
||||
public boolean check()
|
||||
{
|
||||
if (currentVersion.contains("-SNAPSHOT"))
|
||||
{
|
||||
PlexLog.log("Snapshot version detected, not checking for updates.");
|
||||
return true;
|
||||
}
|
||||
try
|
||||
{
|
||||
String versionLink = "https://plex.us.org/updater/check/";
|
||||
@ -44,4 +49,4 @@ public class UpdateChecker extends PlexBase
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,6 @@ import java.time.ZoneId;
|
||||
|
||||
public class LocalDateTimeDeserializer implements JsonDeserializer<LocalDateTime>
|
||||
{
|
||||
|
||||
@Override
|
||||
public LocalDateTime deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
|
||||
{
|
||||
|
@ -17,6 +17,7 @@ public abstract class CustomChunkGenerator extends ChunkGenerator
|
||||
this.populators = Arrays.asList(populators);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlockPopulator> getDefaultPopulators(World world)
|
||||
{
|
||||
return populators;
|
||||
|
@ -38,14 +38,14 @@ public class CustomWorld extends WorldCreator
|
||||
{
|
||||
boolean existed = new File(name).exists();
|
||||
World world = super.generate();
|
||||
|
||||
if (!existed)
|
||||
{
|
||||
Block block = world.getBlockAt(0, world.getHighestBlockYAt(0, 0) + 1, 0);
|
||||
block.setType(Material.OAK_SIGN);
|
||||
BlockState state = block.getState();
|
||||
if (state instanceof Sign)
|
||||
if (state instanceof Sign sign)
|
||||
{
|
||||
Sign sign = (Sign)state;
|
||||
sign.line(1, Component.text(
|
||||
Objects.requireNonNull(plugin.config.getString("worlds." + name + ".name"))));
|
||||
sign.line(2, Component.text("- 0, 0 -"));
|
||||
|
@ -3,6 +3,8 @@ package dev.plex.world;
|
||||
import java.util.Random;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import org.bukkit.generator.WorldInfo;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class FlatChunkGenerator extends CustomChunkGenerator
|
||||
{
|
||||
@ -12,9 +14,8 @@ public abstract class FlatChunkGenerator extends CustomChunkGenerator
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkData generateChunkData(World world, Random random, int x, int z, BiomeGrid biome)
|
||||
public void generateSurface(WorldInfo worldInfo, Random random, int x, int z, ChunkData chunk)
|
||||
{
|
||||
ChunkData chunk = this.createChunkData(world);
|
||||
for (int xx = 0; xx < 16; xx++)
|
||||
{
|
||||
for (int zz = 0; zz < 16; zz++)
|
||||
@ -22,7 +23,6 @@ public abstract class FlatChunkGenerator extends CustomChunkGenerator
|
||||
createLoopChunkData(xx, height, zz, chunk);
|
||||
}
|
||||
}
|
||||
return chunk;
|
||||
}
|
||||
|
||||
public abstract void createLoopChunkData(int x, int y, int z, ChunkData chunk);
|
||||
|
@ -3,7 +3,9 @@ package dev.plex.world;
|
||||
import java.util.Random;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import org.bukkit.generator.WorldInfo;
|
||||
import org.bukkit.util.noise.PerlinNoiseGenerator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class NoiseChunkGenerator extends CustomChunkGenerator
|
||||
{
|
||||
@ -16,10 +18,9 @@ public abstract class NoiseChunkGenerator extends CustomChunkGenerator
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkData generateChunkData(World world, Random random, int x, int z, BiomeGrid biome)
|
||||
public void generateNoise(WorldInfo worldInfo, Random random, int x, int z, ChunkData chunk)
|
||||
{
|
||||
ChunkData chunk = this.createChunkData(world);
|
||||
PerlinNoiseGenerator generator = new PerlinNoiseGenerator(new Random(world.getSeed()));
|
||||
PerlinNoiseGenerator generator = new PerlinNoiseGenerator(new Random(worldInfo.getSeed()));
|
||||
for (int xx = 0; xx < 16; xx++)
|
||||
{
|
||||
for (int zz = 0; zz < 16; zz++)
|
||||
@ -28,7 +29,6 @@ public abstract class NoiseChunkGenerator extends CustomChunkGenerator
|
||||
createLoopChunkData(xx, height, zz, chunk);
|
||||
}
|
||||
}
|
||||
return chunk;
|
||||
}
|
||||
|
||||
public abstract void createLoopChunkData(int x, int y, int z, ChunkData chunk);
|
||||
|
@ -3,7 +3,9 @@ package dev.plex.world;
|
||||
import java.util.Random;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import org.bukkit.generator.WorldInfo;
|
||||
import org.bukkit.util.noise.PerlinOctaveGenerator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class OctaveChunkGenerator extends CustomChunkGenerator
|
||||
{
|
||||
@ -16,10 +18,9 @@ public abstract class OctaveChunkGenerator extends CustomChunkGenerator
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkData generateChunkData(World world, Random random, int x, int z, BiomeGrid biome)
|
||||
public void generateNoise(@NotNull WorldInfo worldInfo, @NotNull Random random, int x, int z, @NotNull ChunkData chunk)
|
||||
{
|
||||
ChunkData chunk = this.createChunkData(world);
|
||||
PerlinOctaveGenerator generator = new PerlinOctaveGenerator(new Random(world.getSeed()), options.getOctaves());
|
||||
PerlinOctaveGenerator generator = new PerlinOctaveGenerator(new Random(worldInfo.getSeed()), options.getOctaves());
|
||||
for (int xx = 0; xx < 16; xx++)
|
||||
{
|
||||
for (int zz = 0; zz < 16; zz++)
|
||||
@ -28,7 +29,6 @@ public abstract class OctaveChunkGenerator extends CustomChunkGenerator
|
||||
createLoopChunkData(xx, height, zz, chunk);
|
||||
}
|
||||
}
|
||||
return chunk;
|
||||
}
|
||||
|
||||
public abstract void createLoopChunkData(int x, int y, int z, ChunkData chunk);
|
||||
|
@ -18,6 +18,10 @@ banning:
|
||||
ban_url: "https://forum.plex.us.org"
|
||||
|
||||
chat:
|
||||
# Should the server use Plex's chat system? It is recommended to keep this on if you are using ranks.
|
||||
# If you are using permissions, you should turn this off and use Vault to handle prefixes with a different chat plugin
|
||||
enabled: true
|
||||
# The maximum amount of characters a player can have for their tag
|
||||
max-tag-length: 16
|
||||
# Color code for name color
|
||||
name-color: 'f'
|
||||
|
@ -1,16 +1,21 @@
|
||||
# Plex Indefinite Bans File
|
||||
# Players with their UUID / IP / Usernames in here will be indefinitely banned until removed
|
||||
|
||||
# List of permanently banned UUIDs
|
||||
# If you want to get someone's UUID, use https://api.ashcon.app/mojang/v2/user/<username>
|
||||
uuids:
|
||||
- 1dac0e92-f565-4479-afd5-38c7df5f9732 # badplayer123
|
||||
griefers:
|
||||
users:
|
||||
- "badplayer123"
|
||||
- "badplayer321"
|
||||
uuids:
|
||||
- 1dac0e92-f565-4479-afd5-38c7df5f9732 # badplayer123
|
||||
ips:
|
||||
- 123.123.123.123
|
||||
|
||||
# List of permanently banned IP addresses
|
||||
ips:
|
||||
- 169.254.69.69
|
||||
|
||||
# List of permanently banned UUIDs
|
||||
# If you want to get someone's username, use https://api.ashcon.app/mojang/v2/user/<uuid>, or just remember it
|
||||
usernames:
|
||||
- badplayer123
|
||||
# Note that these keys can be anything, they are simply to help you keep things organized.
|
||||
# They are not used within the plugin. Duplicate keys are not allowed, and will not work.
|
||||
bypassers:
|
||||
users:
|
||||
- "bypasser1"
|
||||
ips:
|
||||
- 321.321.321.321
|
||||
- 169.254.1.2
|
@ -15,14 +15,13 @@
|
||||
# 3. Expiry
|
||||
# 4. Punisher
|
||||
banMessage: "<red>You have been banned! You may appeal at <gold><v>.\n<red>Reason: <gold><v>\n<red>End date: <gold><v>\n<red>Banned by: <gold><v>"
|
||||
indefBanMessage: "<red>Your <v> is currently banned! You may appeal at <gold><v>."
|
||||
test: "this is a test message!"
|
||||
# 1. The command sender's username
|
||||
variableTest: "variable test with <v>!"
|
||||
playerNotFound: "Player not found!"
|
||||
worldNotFound: "World not found!"
|
||||
# The type of indefinite ban
|
||||
# Appeal URL
|
||||
indefBanMessage: "<red>Your <v> is indefinitely banned! You may appeal at <gold><v>."
|
||||
playerNotFound: "<red>Player not found!"
|
||||
worldNotFound: "<red>World not found!"
|
||||
# 1. The world you have been teleported to
|
||||
playerWorldTeleport: "You have been teleported to <v>."
|
||||
playerWorldTeleport: "<aqua>You have been teleported to <v>."
|
||||
# 1. The sender who opped everyone
|
||||
oppedAllPlayers: "<aqua><v> - Opped all players on the server"
|
||||
# 1. The sender who de-opped everyone
|
||||
@ -50,8 +49,7 @@ unmutedPlayer: "<aqua><v> - Unmuted <v>"
|
||||
lockedUpPlayer: "<aqua><v> - Locking up <v>"
|
||||
# 1. The person who is unlocking
|
||||
# 2. The person who has been unlocked
|
||||
unlockedUpPlayer: "<aqua><v> - Unlocking <v>"
|
||||
noPermission: "<red>You cannot use this command!"
|
||||
unlockedPlayer: "<aqua><v> - Unlocking <v>"
|
||||
# 1. The rank required to use the command
|
||||
noPermissionRank: "<red>You must be at least <v> to use this command!"
|
||||
# 1. The permission node required to use the command
|
||||
@ -59,25 +57,23 @@ noPermissionNode: "<red>You must have the permission: <v> to use this command!"
|
||||
noPermissionInGame: "<red>You must be in console to use this command!"
|
||||
noPermissionConsole: "<red>You must be in-game to use this command!"
|
||||
# 1. The username of the name history
|
||||
nameHistoryTitle: "Name History of <v>"
|
||||
# 1. A username of the found user
|
||||
# 2. When the user changed to that username
|
||||
nameHistoryBody: " - <v> (<v>)"
|
||||
# 1. The username that failed
|
||||
nameHistoryFail: "<red>Something went wrong while trying to retrieve name history of <v>! Try again later!"
|
||||
nameHistoryDoesntExist: "<red>Couldn't find this user! Please check if your spelling was correct and this player exists"
|
||||
nameHistoryTitle: "<gold>Name History of <v>"
|
||||
nameHistorySeparator: "<gold><strikethrough>-----------------------------"
|
||||
# 1. The name
|
||||
# 2. The date and time of the name change
|
||||
nameHistoryBody: "<gold><v> <dark_gray>- <gold><v>"
|
||||
# 1. The gamemode
|
||||
gameModeSetTo: "Your gamemode has been set to <v>."
|
||||
gameModeSetTo: "<gray>Your gamemode has been set to <v>."
|
||||
# 1. The player's name
|
||||
# 2. The gamemode
|
||||
setOtherPlayerGameModeTo: "You set <v>'s gamemode to <v>."
|
||||
setOtherPlayerGameModeTo: "<gray>You set <v>'s gamemode to <v>."
|
||||
# 1. The command sender
|
||||
# 2. The gamemode
|
||||
playerSetOtherGameMode: "<v> set your gamemode to <v>."
|
||||
playerSetOtherGameMode: "<gray><v> set your gamemode to <v>."
|
||||
# 1. The command sender
|
||||
# 2. The gamemode
|
||||
setEveryoneGameMode: "<aqua><v> - Changing everyone's gamemode to <v>"
|
||||
consoleMustDefinePlayer: "You must define a player since you are running this command from console."
|
||||
consoleMustDefinePlayer: "<red>You must define a player since you are running this command from console."
|
||||
# 1. The command sender
|
||||
# 2. The player
|
||||
newAdminAdded: "<aqua><v> - Adding <v> to the admin list"
|
||||
@ -116,9 +112,9 @@ playerLockedUp: "<red>That player is already locked up!"
|
||||
muted: "<red>You are currently muted - STFU!"
|
||||
kickedPlayer: "<red><v> - Kicking <v>"
|
||||
teleportedToWorldSpawn: "<aqua>Teleporting to the local spawn"
|
||||
toggleCommandSpy: "CommandSpy has been"
|
||||
enabled: "enabled."
|
||||
disabled: "disabled."
|
||||
toggleCommandSpy: "<gray>CommandSpy has been"
|
||||
enabled: "<gray>enabled."
|
||||
disabled: "<gray>disabled."
|
||||
adminChatFormat: '<dark_gray>[<blue>AdminChat<dark_gray>] <dark_red><v> <gray>» <gold><v>'
|
||||
maximumPrefixLength: "<red>The maximum length for a tag may only be <v>."
|
||||
prefixCleared: "<aqua>Your prefix has been cleared."
|
||||
|
Reference in New Issue
Block a user