mirror of
https://github.com/plexusorg/Plex.git
synced 2026-06-03 21:16:55 +00:00
Uplift Paper version to 26.1.2
Upgraded Gradle to 9.5.1 Updated deprecated functions General code clean up
This commit is contained in:
+13
-13
@@ -4,7 +4,7 @@ import java.util.*
|
||||
|
||||
plugins {
|
||||
id("net.kyori.indra.git") version "4.0.0"
|
||||
id("de.eldoria.plugin-yml.paper") version "0.8.0"
|
||||
id("de.eldoria.plugin-yml.paper") version "0.9.0"
|
||||
}
|
||||
|
||||
repositories {
|
||||
@@ -13,24 +13,24 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
library("org.projectlombok:lombok:1.18.42")
|
||||
library("org.projectlombok:lombok:1.18.46")
|
||||
library("org.json:json:20251224")
|
||||
library("commons-io:commons-io:2.21.0")
|
||||
library("redis.clients:jedis:7.2.0")
|
||||
library("org.mariadb.jdbc:mariadb-java-client:3.5.7")
|
||||
library("commons-io:commons-io:2.22.0")
|
||||
library("redis.clients:jedis:7.5.0")
|
||||
library("org.mariadb.jdbc:mariadb-java-client:3.5.8")
|
||||
library("com.zaxxer:HikariCP:7.0.2")
|
||||
library("org.apache.maven.resolver:maven-resolver-transport-http:1.9.25")
|
||||
library("org.jetbrains:annotations:26.0.2")
|
||||
compileOnly("io.papermc.paper:paper-api:1.21.11-R0.1-SNAPSHOT")
|
||||
library("org.apache.maven.resolver:maven-resolver-transport-http:1.9.27")
|
||||
library("org.jetbrains:annotations:26.1.0")
|
||||
compileOnly("io.papermc.paper:paper-api:26.1.2.build.+")
|
||||
compileOnly("com.github.MilkBowl:VaultAPI:1.7.1") {
|
||||
exclude("org.bukkit", "bukkit")
|
||||
}
|
||||
compileOnly("net.coreprotect:coreprotect:23.1")
|
||||
compileOnly("net.coreprotect:coreprotect:23.2")
|
||||
compileOnly("network.darkhelmet.prism:Prism-Api:1.0.0")
|
||||
compileOnly("com.github.LeonMangler:SuperVanish:6.2.19")
|
||||
implementation("org.bstats:bstats-base:3.1.0")
|
||||
implementation("org.bstats:bstats-bukkit:3.1.0")
|
||||
annotationProcessor("org.projectlombok:lombok:1.18.42")
|
||||
implementation("org.bstats:bstats-base:3.2.1")
|
||||
implementation("org.bstats:bstats-bukkit:3.2.1")
|
||||
annotationProcessor("org.projectlombok:lombok:1.18.46")
|
||||
}
|
||||
|
||||
group = rootProject.group
|
||||
@@ -45,7 +45,7 @@ paper {
|
||||
loader = "dev.plex.PlexLibraryManager"
|
||||
website = "https://plex.us.org"
|
||||
authors = listOf("Telesphoreo", "taahanis", "supernt")
|
||||
apiVersion = "1.21.11"
|
||||
apiVersion = "26.1.2"
|
||||
foliaSupported = true
|
||||
generateLibrariesJson = true
|
||||
// Load BukkitTelnet and LibsDisguises before Plex so the modules register properly
|
||||
|
||||
@@ -24,7 +24,9 @@ import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.UpdateChecker;
|
||||
import dev.plex.util.redis.MessageUtil;
|
||||
import dev.plex.world.CustomWorld;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.milkbowl.vault.chat.Chat;
|
||||
@@ -152,7 +154,9 @@ public class Plex extends JavaPlugin
|
||||
if (PlexUtils.hasVanishPlugin())
|
||||
{
|
||||
PlexLog.log("Hooked into SuperVanish / PremiumVanish!");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
PlexLog.debug("Not hooking into SuperVanish / PremiumVanish");
|
||||
}
|
||||
|
||||
@@ -246,14 +250,20 @@ public class Plex extends JavaPlugin
|
||||
private Permission setupPermissions()
|
||||
{
|
||||
RegisteredServiceProvider<Permission> rsp = Bukkit.getServicesManager().getRegistration(Permission.class);
|
||||
permissions = rsp.getProvider();
|
||||
if (rsp != null)
|
||||
{
|
||||
permissions = rsp.getProvider();
|
||||
}
|
||||
return permissions;
|
||||
}
|
||||
|
||||
private Chat setupChat()
|
||||
{
|
||||
RegisteredServiceProvider<Chat> rsp = Bukkit.getServicesManager().getRegistration(Chat.class);
|
||||
chat = rsp.getProvider();
|
||||
if (rsp != null)
|
||||
{
|
||||
chat = rsp.getProvider();
|
||||
}
|
||||
return chat;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import org.eclipse.aether.graph.Dependency;
|
||||
import org.eclipse.aether.repository.RemoteRepository;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@SuppressWarnings("UnstableApiUsage")
|
||||
public class PlexLibraryManager implements PluginLoader
|
||||
{
|
||||
@Override
|
||||
@@ -41,8 +42,7 @@ public class PlexLibraryManager implements PluginLoader
|
||||
{
|
||||
try (var in = getClass().getResourceAsStream("/paper-libraries.json"))
|
||||
{
|
||||
PluginLibraries libraries = new Gson().fromJson(new InputStreamReader(in, StandardCharsets.UTF_8), PluginLibraries.class);
|
||||
return libraries;
|
||||
return new Gson().fromJson(new InputStreamReader(in, StandardCharsets.UTF_8), PluginLibraries.class);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
|
||||
+2
-6
@@ -2,6 +2,7 @@ package dev.plex.cache;
|
||||
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -56,12 +57,7 @@ public class DataUtils
|
||||
public static PlexPlayer getPlayer(String username, boolean loadExtraData)
|
||||
{
|
||||
Optional<PlexPlayer> plexPlayer = Plex.get().getPlayerCache().getPlexPlayerMap().values().stream().filter(player -> player.getName().equalsIgnoreCase(username)).findFirst();
|
||||
if (plexPlayer.isPresent())
|
||||
{
|
||||
return plexPlayer.get();
|
||||
}
|
||||
|
||||
return Plex.get().getSqlPlayerData().getByName(username, loadExtraData);
|
||||
return plexPlayer.orElseGet(() -> Plex.get().getSqlPlayerData().getByName(username, loadExtraData));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-18
@@ -2,6 +2,7 @@ package dev.plex.cache;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -16,29 +17,11 @@ public class PlayerCache
|
||||
*/
|
||||
private static final Map<UUID, PlexPlayer> plexPlayerMap = Maps.newHashMap();
|
||||
|
||||
/**
|
||||
* A key/value pair where the key is the unique ID of the Punished Player
|
||||
*/
|
||||
// private static final Map<UUID, PunishedPlayer> punishedPlayerMap = Maps.newHashMap();
|
||||
|
||||
// public static Map<UUID, PunishedPlayer> getPunishedPlayerMap()
|
||||
// {
|
||||
// return punishedPlayerMap;
|
||||
// }
|
||||
public Map<UUID, PlexPlayer> getPlexPlayerMap()
|
||||
{
|
||||
return plexPlayerMap;
|
||||
}
|
||||
|
||||
/*public static PunishedPlayer getPunishedPlayer(UUID uuid)
|
||||
{
|
||||
if (!getPunishedPlayerMap().containsKey(uuid))
|
||||
{
|
||||
getPunishedPlayerMap().put(uuid, new PunishedPlayer(uuid));
|
||||
}
|
||||
return getPunishedPlayerMap().get(uuid);
|
||||
}
|
||||
*/
|
||||
public PlexPlayer getPlexPlayer(UUID uuid)
|
||||
{
|
||||
return getPlexPlayerMap().get(uuid);
|
||||
|
||||
@@ -14,9 +14,11 @@ import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.PlexUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
@@ -80,16 +82,10 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
||||
|
||||
if (register)
|
||||
{
|
||||
if (getMap().getKnownCommands().containsKey(this.getName().toLowerCase()))
|
||||
{
|
||||
getMap().getKnownCommands().remove(this.getName().toLowerCase());
|
||||
}
|
||||
getMap().getKnownCommands().remove(this.getName().toLowerCase());
|
||||
this.getAliases().forEach(s ->
|
||||
{
|
||||
if (getMap().getKnownCommands().containsKey(s.toLowerCase()))
|
||||
{
|
||||
getMap().getKnownCommands().remove(s.toLowerCase());
|
||||
}
|
||||
getMap().getKnownCommands().remove(s.toLowerCase());
|
||||
});
|
||||
getMap().register("plex", this);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package dev.plex.command.annotation;
|
||||
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
|
||||
@@ -10,9 +10,11 @@ import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.minimessage.SafeMiniMessage;
|
||||
import dev.plex.util.redis.MessageUtil;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@@ -4,8 +4,10 @@ import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
|
||||
@@ -8,7 +8,9 @@ import dev.plex.command.exception.CommandFailException;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.event.GameModeUpdateEvent;
|
||||
import dev.plex.util.PlexUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
|
||||
@@ -13,10 +13,12 @@ import dev.plex.util.BungeeUtil;
|
||||
import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.TimeUtils;
|
||||
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -74,7 +76,7 @@ public class BanCMD extends PlexCommand
|
||||
punishment.setEndDate(date.plusDays(1));
|
||||
punishment.setCustomTime(false);
|
||||
punishment.setActive(true);
|
||||
punishment.setIp(player != null ? player.getAddress().getAddress().getHostAddress().trim() : plexPlayer.getIps().get(plexPlayer.getIps().size() - 1));
|
||||
punishment.setIp(player != null ? player.getAddress().getAddress().getHostAddress().trim() : plexPlayer.getIps().getLast());
|
||||
plugin.getPunishmentManager().punish(plexPlayer, punishment);
|
||||
PlexUtils.broadcast(messageComponent("banningPlayer", sender.getName(), plexPlayer.getName()));
|
||||
Bukkit.getGlobalRegionScheduler().execute(plugin, () ->
|
||||
|
||||
@@ -5,8 +5,10 @@ import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.punishment.Punishment;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@@ -10,7 +10,9 @@ import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.meta.PlayerMeta;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
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;
|
||||
|
||||
@@ -5,10 +5,12 @@ import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.listener.impl.BlockListener;
|
||||
import dev.plex.util.PlexUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@@ -6,8 +6,10 @@ import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -5,8 +5,10 @@ import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.util.PlexUtils;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@@ -8,7 +8,9 @@ import dev.plex.command.exception.CommandFailException;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.event.GameModeUpdateEvent;
|
||||
import dev.plex.util.PlexUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
|
||||
@@ -8,9 +8,11 @@ import dev.plex.menu.impl.MaterialMenu;
|
||||
import dev.plex.util.GameRuleUtil;
|
||||
import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.PlexUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
|
||||
@@ -6,12 +6,14 @@ import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.PlexUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
@@ -33,7 +35,7 @@ public class EntityWipeCMD extends PlexCommand
|
||||
|
||||
List<String> entityWhitelist = new LinkedList<>(Arrays.asList(args));
|
||||
|
||||
boolean radiusSpecified = !entityWhitelist.isEmpty() && isNumeric(entityWhitelist.get(entityWhitelist.size() - 1)); // try and detect if the last argument of the command is a number
|
||||
boolean radiusSpecified = !entityWhitelist.isEmpty() && isNumeric(entityWhitelist.getLast()); // try and detect if the last argument of the command is a number
|
||||
boolean useBlacklist = args.length == 0 || (args.length == 1 && radiusSpecified); // if there are no arguments or the one argument is a number
|
||||
int radius = 0;
|
||||
|
||||
@@ -42,9 +44,9 @@ public class EntityWipeCMD extends PlexCommand
|
||||
|
||||
if (radiusSpecified)
|
||||
{
|
||||
radius = parseInt(sender, args[entityWhitelist.size() - 1]); // get the args length as the size of the list
|
||||
radius = parseInt(sender, entityWhitelist.getLast()); // get the args length as the size of the list
|
||||
radius *= radius;
|
||||
entityWhitelist.remove(entityWhitelist.size() - 1); // remove the radius from the list
|
||||
entityWhitelist.removeLast(); // remove the radius from the list
|
||||
}
|
||||
|
||||
PlexLog.debug("radius: " + radius);
|
||||
|
||||
@@ -4,8 +4,10 @@ import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
|
||||
@@ -9,9 +9,11 @@ import dev.plex.punishment.Punishment;
|
||||
import dev.plex.punishment.PunishmentType;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.TimeUtils;
|
||||
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -7,9 +7,11 @@ import dev.plex.command.exception.CommandFailException;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.event.GameModeUpdateEvent;
|
||||
import dev.plex.util.PlexUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
|
||||
@@ -13,9 +13,11 @@ import dev.plex.punishment.PunishmentType;
|
||||
import dev.plex.util.BungeeUtil;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.TimeUtils;
|
||||
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
@@ -7,8 +7,10 @@ import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.hook.VaultHook;
|
||||
import dev.plex.meta.PlayerMeta;
|
||||
import dev.plex.util.PlexUtils;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
@@ -4,8 +4,10 @@ import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -6,7 +6,9 @@ import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
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;
|
||||
|
||||
@@ -4,8 +4,10 @@ import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
|
||||
@@ -5,9 +5,11 @@ import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.util.PlexUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
@@ -26,7 +28,7 @@ public class MobLimitCMD extends PlexCommand
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
Chunk chunk = playerSender != null ? playerSender.getLocation().getChunk() : Bukkit.getWorlds().get(0).getChunkAt(0, 0);
|
||||
Chunk chunk = playerSender != null ? playerSender.getLocation().getChunk() : Bukkit.getWorlds().getFirst().getChunkAt(0, 0);
|
||||
|
||||
int currentLimit = plugin.config.getInt("entity_limit.max_mobs_per_chunk");
|
||||
int currentMobCount = (int) Arrays.stream(chunk.getEntities())
|
||||
@@ -50,10 +52,16 @@ public class MobLimitCMD extends PlexCommand
|
||||
case "setmax":
|
||||
try
|
||||
{
|
||||
if (args.length != 2) return usage();
|
||||
if (args.length != 2)
|
||||
{
|
||||
return usage();
|
||||
}
|
||||
|
||||
int newLimit = Integer.parseInt(args[1]);
|
||||
if (newLimit < 0) throw new NumberFormatException();
|
||||
if (newLimit < 0)
|
||||
{
|
||||
throw new NumberFormatException();
|
||||
}
|
||||
|
||||
int limitCeiling = plugin.config.getInt("entity_limit.mob_limit_ceiling");
|
||||
if (newLimit > limitCeiling)
|
||||
|
||||
@@ -6,10 +6,12 @@ import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.PlexUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
@@ -9,9 +9,11 @@ import dev.plex.punishment.Punishment;
|
||||
import dev.plex.punishment.PunishmentType;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.TimeUtils;
|
||||
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -8,12 +8,14 @@ import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.punishment.extra.Note;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.TimeUtils;
|
||||
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -47,7 +49,7 @@ public class NotesCMD extends PlexCommand
|
||||
{
|
||||
plugin.getSqlNotes().getNotes(plexPlayer.getUuid()).whenComplete((notes, ex) ->
|
||||
{
|
||||
if (notes.size() == 0)
|
||||
if (notes.isEmpty())
|
||||
{
|
||||
send(sender, messageComponent("noNotes"));
|
||||
return;
|
||||
|
||||
@@ -10,10 +10,12 @@ import dev.plex.module.PlexModuleFile;
|
||||
import dev.plex.util.BuildInfo;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.TimeUtils;
|
||||
|
||||
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.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -34,7 +36,7 @@ public class PlexCMD extends PlexCommand
|
||||
if (args.length == 0)
|
||||
{
|
||||
send(sender, mmString("<light_purple>Plex - A new freedom plugin."));
|
||||
send(sender, mmString("<light_purple>Plugin version: <gold>" + plugin.getDescription().getVersion() + " #" + BuildInfo.getNumber() + " <light_purple>Git: <gold>" + BuildInfo.getCommit()));
|
||||
send(sender, mmString("<light_purple>Plugin version: <gold>" + plugin.getPluginMeta().getVersion() + " #" + BuildInfo.getNumber() + " <light_purple>Git: <gold>" + BuildInfo.getCommit()));
|
||||
send(sender, mmString("<light_purple>Authors: <gold>Telesphoreo, Taahh"));
|
||||
send(sender, mmString("<light_purple>Built by: <gold>" + BuildInfo.getAuthor() + " <light_purple>on <gold>" + BuildInfo.getDate()));
|
||||
send(sender, mmString("<light_purple>Run <gold>/plex modules <light_purple>to see a list of modules."));
|
||||
|
||||
@@ -11,7 +11,9 @@ import dev.plex.menu.impl.PunishedPlayerMenu;
|
||||
import dev.plex.menu.impl.PunishmentMenu;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.util.PlexUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
@@ -5,8 +5,10 @@ import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.util.PlexUtils;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@@ -8,7 +8,9 @@ import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
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;
|
||||
|
||||
@@ -5,8 +5,10 @@ import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.util.PlexUtils;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@@ -10,7 +10,9 @@ import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.PlexUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@@ -9,10 +9,12 @@ import dev.plex.punishment.Punishment;
|
||||
import dev.plex.punishment.PunishmentType;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.TimeUtils;
|
||||
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.title.Title;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
@@ -39,17 +41,13 @@ public class SmiteCMD extends PlexCommand
|
||||
|
||||
String reason = null;
|
||||
boolean silent = false;
|
||||
boolean clearinv = false;
|
||||
boolean clearInv = false;
|
||||
|
||||
if (args.length >= 2)
|
||||
{
|
||||
if (args[args.length - 1].equalsIgnoreCase("-q"))
|
||||
{
|
||||
if (args[args.length - 1].equalsIgnoreCase("-q"))
|
||||
{
|
||||
silent = true;
|
||||
}
|
||||
|
||||
silent = true;
|
||||
if (args.length >= 3)
|
||||
{
|
||||
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " ");
|
||||
@@ -57,11 +55,7 @@ public class SmiteCMD extends PlexCommand
|
||||
}
|
||||
else if (args[args.length - 1].equalsIgnoreCase("-ci"))
|
||||
{
|
||||
if (args[args.length - 1].equalsIgnoreCase("-ci"))
|
||||
{
|
||||
clearinv = true;
|
||||
}
|
||||
|
||||
clearInv = true;
|
||||
if (args.length >= 3)
|
||||
{
|
||||
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " ");
|
||||
@@ -92,7 +86,7 @@ public class SmiteCMD extends PlexCommand
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
|
||||
// Clear inventory
|
||||
if (clearinv)
|
||||
if (clearInv)
|
||||
{
|
||||
player.getInventory().clear();
|
||||
}
|
||||
|
||||
@@ -8,7 +8,9 @@ import dev.plex.command.exception.CommandFailException;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.event.GameModeUpdateEvent;
|
||||
import dev.plex.util.PlexUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
@@ -34,7 +36,7 @@ public class SpectatorCMD extends PlexCommand
|
||||
return null;
|
||||
}
|
||||
|
||||
if (checkPermission(sender,"plex.gamemode.spectator.others"))
|
||||
if (checkPermission(sender, "plex.gamemode.spectator.others"))
|
||||
{
|
||||
if (args[0].equals("-a"))
|
||||
{
|
||||
@@ -56,7 +58,7 @@ public class SpectatorCMD extends PlexCommand
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
if (silentCheckPermission(sender,"plex.gamemode.spectator.others"))
|
||||
if (silentCheckPermission(sender, "plex.gamemode.spectator.others"))
|
||||
{
|
||||
return PlexUtils.getPlayerNameList();
|
||||
}
|
||||
|
||||
@@ -8,7 +8,9 @@ import dev.plex.command.exception.CommandFailException;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.event.GameModeUpdateEvent;
|
||||
import dev.plex.util.PlexUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
@@ -34,7 +36,7 @@ public class SurvivalCMD extends PlexCommand
|
||||
return null;
|
||||
}
|
||||
|
||||
if (checkPermission(sender,"plex.gamemode.survival.others"))
|
||||
if (checkPermission(sender, "plex.gamemode.survival.others"))
|
||||
{
|
||||
if (args[0].equals("-a"))
|
||||
{
|
||||
@@ -57,7 +59,7 @@ public class SurvivalCMD extends PlexCommand
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
if (silentCheckPermission(sender,"plex.gamemode.survival.others"))
|
||||
if (silentCheckPermission(sender, "plex.gamemode.survival.others"))
|
||||
{
|
||||
return PlexUtils.getPlayerNameList();
|
||||
}
|
||||
|
||||
@@ -7,9 +7,11 @@ import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.util.PlexUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||
|
||||
@@ -14,8 +14,10 @@ import dev.plex.util.BungeeUtil;
|
||||
import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.TimeUtils;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
@@ -9,9 +9,11 @@ import dev.plex.punishment.Punishment;
|
||||
import dev.plex.punishment.PunishmentType;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.TimeUtils;
|
||||
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -7,7 +7,9 @@ import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.menu.impl.ToggleMenu;
|
||||
import dev.plex.util.PlexUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@@ -10,7 +10,9 @@ import dev.plex.command.exception.PlayerNotFoundException;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
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;
|
||||
|
||||
@@ -10,7 +10,9 @@ import dev.plex.command.exception.PlayerNotFoundException;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.punishment.PunishmentType;
|
||||
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;
|
||||
@@ -39,7 +41,8 @@ public class UnfreezeCMD extends PlexCommand
|
||||
throw new CommandFailException(PlexUtils.messageString("playerNotFrozen"));
|
||||
}
|
||||
punishedPlayer.setFrozen(false);
|
||||
punishedPlayer.getPunishments().stream().filter(punishment -> punishment.getType() == PunishmentType.FREEZE && punishment.isActive()).forEach(punishment -> {
|
||||
punishedPlayer.getPunishments().stream().filter(punishment -> punishment.getType() == PunishmentType.FREEZE && punishment.isActive()).forEach(punishment ->
|
||||
{
|
||||
punishment.setActive(false);
|
||||
plugin.getSqlPunishment().updatePunishment(punishment.getType(), false, punishment.getPunished());
|
||||
});
|
||||
|
||||
@@ -10,7 +10,9 @@ import dev.plex.command.exception.PlayerNotFoundException;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.punishment.PunishmentType;
|
||||
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;
|
||||
@@ -39,7 +41,8 @@ public class UnmuteCMD extends PlexCommand
|
||||
throw new CommandFailException(PlexUtils.messageString("playerNotMuted"));
|
||||
}
|
||||
punishedPlayer.setMuted(false);
|
||||
punishedPlayer.getPunishments().stream().filter(punishment -> punishment.getType() == PunishmentType.MUTE && punishment.isActive()).forEach(punishment -> {
|
||||
punishedPlayer.getPunishments().stream().filter(punishment -> punishment.getType() == PunishmentType.MUTE && punishment.isActive()).forEach(punishment ->
|
||||
{
|
||||
punishment.setActive(false);
|
||||
plugin.getSqlPunishment().updatePunishment(punishment.getType(), false, punishment.getPunished());
|
||||
});
|
||||
|
||||
@@ -4,9 +4,11 @@ import com.google.common.collect.ImmutableList;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.JoinConfiguration;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
@@ -44,7 +46,8 @@ public class WhoHasCMD extends PlexCommand
|
||||
}
|
||||
|
||||
List<TextComponent> players = Bukkit.getOnlinePlayers().stream().filter(player ->
|
||||
player.getInventory().contains(material)).map(player -> {
|
||||
player.getInventory().contains(material)).map(player ->
|
||||
{
|
||||
if (clearInventory)
|
||||
{
|
||||
player.getInventory().remove(material);
|
||||
|
||||
@@ -6,9 +6,11 @@ import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
|
||||
@@ -2,9 +2,11 @@ package dev.plex.config;
|
||||
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.util.PlexLog;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package dev.plex.config;
|
||||
|
||||
import dev.plex.module.PlexModule;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
|
||||
@@ -41,7 +41,8 @@ public class CoreProtectHook
|
||||
this.coreProtectAPI.testAPI();
|
||||
}
|
||||
|
||||
public boolean hasCoreProtect() {
|
||||
public boolean hasCoreProtect()
|
||||
{
|
||||
return hasApi;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ public class PrismHook
|
||||
Plugin plugin = plex.getServer().getPluginManager().getPlugin("Prism");
|
||||
|
||||
// Check that Prism is loaded
|
||||
if (!plugin.isEnabled())
|
||||
if (plugin != null && !plugin.isEnabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -22,7 +22,8 @@ public class PrismHook
|
||||
this.prismApi = (PrismApi) plugin;
|
||||
}
|
||||
|
||||
public boolean hasPrism() {
|
||||
public boolean hasPrism()
|
||||
{
|
||||
return prismApi != null;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,9 @@ import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.minimessage.SafeMiniMessage;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.milkbowl.vault.chat.Chat;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
@@ -74,11 +76,13 @@ public class VaultHook
|
||||
return PlexUtils.mmDeserialize("<dark_gray>[<dark_purple>Developer<dark_gray>]");
|
||||
}
|
||||
String group = VaultHook.getPermission().getPrimaryGroup(null, player);
|
||||
if (group == null || group.isEmpty()) {
|
||||
if (group == null || group.isEmpty())
|
||||
{
|
||||
return Component.empty();
|
||||
}
|
||||
String vaultPrefix = VaultHook.getChat().getGroupPrefix((String) null, group);
|
||||
if (vaultPrefix == null || vaultPrefix.isEmpty()) {
|
||||
if (vaultPrefix == null || vaultPrefix.isEmpty())
|
||||
{
|
||||
return Component.empty();
|
||||
}
|
||||
PlexLog.debug("prefix: {0}", SafeMiniMessage.mmSerializeWithoutEvents(PlexUtils.stringToComponent(vaultPrefix)).replace("<", "\\<"));
|
||||
|
||||
@@ -3,7 +3,9 @@ package dev.plex.listener.impl;
|
||||
import dev.plex.listener.PlexListener;
|
||||
import dev.plex.services.impl.TimingService;
|
||||
import dev.plex.util.PlexUtils;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
|
||||
@@ -4,7 +4,9 @@ import dev.plex.listener.PlexListener;
|
||||
import dev.plex.services.impl.TimingService;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
|
||||
@@ -7,8 +7,6 @@ import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.punishment.Punishment;
|
||||
import dev.plex.punishment.PunishmentManager;
|
||||
import dev.plex.punishment.PunishmentType;
|
||||
import dev.plex.util.PlexLog;
|
||||
import it.unimi.dsi.fastutil.Pair;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
|
||||
|
||||
@@ -2,13 +2,16 @@ package dev.plex.listener.impl;
|
||||
|
||||
import dev.plex.listener.PlexListener;
|
||||
import dev.plex.util.PlexUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.block.sign.Side;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
@@ -59,15 +62,26 @@ public class BlockListener extends PlexListener
|
||||
{
|
||||
Sign sign = (Sign) block.getState();
|
||||
boolean anythingChanged = false;
|
||||
for (int i = 0; i < sign.lines().size(); i++)
|
||||
for (int i = 0; i < sign.getSide(Side.FRONT).lines().size(); i++)
|
||||
{
|
||||
Component line = sign.line(i);
|
||||
Component line = sign.getSide(Side.FRONT).line(i);
|
||||
if (line.clickEvent() != null)
|
||||
{
|
||||
anythingChanged = true;
|
||||
sign.line(i, line.clickEvent(null));
|
||||
sign.getSide(Side.FRONT).line(i, line.clickEvent(null));
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < sign.getSide(Side.BACK).lines().size(); i++)
|
||||
{
|
||||
Component line = sign.getSide(Side.BACK).line(i);
|
||||
if (line.clickEvent() != null)
|
||||
{
|
||||
anythingChanged = true;
|
||||
sign.getSide(Side.BACK).line(i, line.clickEvent(null));
|
||||
}
|
||||
}
|
||||
|
||||
if (anythingChanged)
|
||||
{
|
||||
sign.update(true);
|
||||
@@ -79,7 +93,7 @@ public class BlockListener extends PlexListener
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onBlockBreak(BlockBreakEvent event)
|
||||
{
|
||||
if (blockedPlayers.size() == 0)
|
||||
if (blockedPlayers.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -19,14 +19,14 @@ import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextReplacementConfig;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@Toggleable("chat.enabled")
|
||||
public class ChatListener extends PlexListener {
|
||||
public class ChatListener extends PlexListener
|
||||
{
|
||||
public static final TextReplacementConfig URL_REPLACEMENT_CONFIG = TextReplacementConfig
|
||||
.builder()
|
||||
.match("(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]")
|
||||
@@ -41,9 +41,11 @@ public class ChatListener extends PlexListener {
|
||||
private static final Component format = SafeMiniMessage.mmDeserialize(plugin.config.getString("chat.format"));
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onChat(AsyncChatEvent event) {
|
||||
public void onChat(AsyncChatEvent event)
|
||||
{
|
||||
PlexPlayer plexPlayer = plugin.getPlayerCache().getPlexPlayerMap().get(event.getPlayer().getUniqueId());
|
||||
if (plexPlayer.isStaffChat()) {
|
||||
if (plexPlayer.isStaffChat())
|
||||
{
|
||||
String prefix = PlexUtils.mmSerialize(VaultHook.getPrefix(event.getPlayer())); // Don't use PlexPlayer#getPrefix because that returns their custom set prefix and not their group's
|
||||
MessageUtil.sendStaffChat(event.getPlayer(), event.message(), PlexUtils.adminChat(event.getPlayer().getName(), prefix, SafeMiniMessage.mmSerialize(event.message())).toArray(UUID[]::new));
|
||||
plugin.getServer().getConsoleSender().sendMessage(PlexUtils.messageComponent("adminChatFormat", event.getPlayer().getName(), prefix, SafeMiniMessage.mmSerialize(event.message().replaceText(URL_REPLACEMENT_CONFIG))));
|
||||
@@ -52,10 +54,13 @@ public class ChatListener extends PlexListener {
|
||||
}
|
||||
Component prefix = PlayerMeta.getPrefix(plexPlayer);
|
||||
|
||||
if (prefix != null && !prefix.equals(Component.empty()) && !prefix.equals(Component.space())) {
|
||||
if (prefix != null && !prefix.equals(Component.empty()) && !prefix.equals(Component.space()))
|
||||
{
|
||||
renderer.hasPrefix = true;
|
||||
renderer.prefix = prefix;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
renderer.hasPrefix = false;
|
||||
renderer.prefix = null;
|
||||
}
|
||||
@@ -65,21 +70,25 @@ public class ChatListener extends PlexListener {
|
||||
event.renderer(renderer);
|
||||
}
|
||||
|
||||
public static class PlexChatRenderer implements ChatRenderer {
|
||||
public static class PlexChatRenderer implements ChatRenderer
|
||||
{
|
||||
public boolean hasPrefix;
|
||||
public Component prefix;
|
||||
public Supplier<Component> before = null;
|
||||
|
||||
@Override
|
||||
public @NotNull Component render(@NotNull Player source, @NotNull Component sourceDisplayName, @NotNull Component message, @NotNull Audience viewer) {
|
||||
public @NotNull Component render(@NotNull Player source, @NotNull Component sourceDisplayName, @NotNull Component message, @NotNull Audience viewer)
|
||||
{
|
||||
Component component = format;
|
||||
|
||||
if (before != null) {
|
||||
if (before != null)
|
||||
{
|
||||
component = component.append(before.get());
|
||||
}
|
||||
|
||||
// Substitute the prefix from the config
|
||||
if (hasPrefix) {
|
||||
if (hasPrefix)
|
||||
{
|
||||
component = component.replaceText(TextReplacementConfig.builder().matchLiteral("{prefix}").replacement(prefix).build());
|
||||
}
|
||||
|
||||
@@ -97,7 +106,8 @@ public class ChatListener extends PlexListener {
|
||||
}
|
||||
}
|
||||
|
||||
private static void defaultChatProcessing(AsyncChatEvent event, PlexPlayer plexPlayer) {
|
||||
private static void defaultChatProcessing(AsyncChatEvent event, PlexPlayer plexPlayer)
|
||||
{
|
||||
String text = PlexUtils.getTextFromComponent(event.message());
|
||||
event.message(PlexUtils.stringToComponent(text));
|
||||
}
|
||||
|
||||
@@ -4,7 +4,9 @@ import dev.plex.listener.PlexListener;
|
||||
import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
@@ -6,7 +6,9 @@ import dev.plex.meta.PlayerMeta;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.PlexUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
@@ -5,9 +5,11 @@ import com.destroystokyo.paper.event.server.PaperServerListPingEvent.ListedPlaye
|
||||
import dev.plex.listener.PlexListener;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.RandomUtil;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -20,7 +22,17 @@ public class ServerListener extends PlexListener
|
||||
String baseMotd = plugin.config.getString("server.motd");
|
||||
baseMotd = baseMotd.replace("\\n", "\n");
|
||||
baseMotd = baseMotd.replace("%servername%", plugin.config.getString("server.name"));
|
||||
baseMotd = baseMotd.replace("%mcversion%", Bukkit.getBukkitVersion().split("-")[0]);
|
||||
|
||||
String version = Bukkit.getBukkitVersion();
|
||||
if (version.contains("build"))
|
||||
{
|
||||
baseMotd = baseMotd.replace("%mcversion%", version.split(".build")[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
baseMotd = baseMotd.replace("%mcversion%", version.split("-")[0]);
|
||||
}
|
||||
|
||||
if (plugin.config.getBoolean("server.colorize_motd"))
|
||||
{
|
||||
AtomicReference<Component> motd = new AtomicReference<>(Component.empty());
|
||||
@@ -43,7 +55,7 @@ public class ServerListener extends PlexListener
|
||||
{
|
||||
event.getListedPlayers().clear();
|
||||
event.getListedPlayers().addAll(samples.stream().map(string -> string.replace("&", "§"))
|
||||
.map(str -> new ListedPlayerInfo(str, UUID.randomUUID())).toList());
|
||||
.map(str -> new ListedPlayerInfo(str, UUID.randomUUID())).toList());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,9 @@ import dev.plex.listener.PlexListener;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||
import io.papermc.paper.event.player.PrePlayerAttackEntityEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -141,8 +143,8 @@ public class TogglesListener extends PlexListener
|
||||
if (shooter instanceof Player)
|
||||
{
|
||||
ThrownPotion potion = event.getPotion();
|
||||
if (potion.getEffects().stream().anyMatch(effect -> effect.getType().getName().startsWith("HARM") ||
|
||||
effect.getType().getName().startsWith("POISON")) &&
|
||||
if (potion.getEffects().stream().anyMatch(effect -> effect.getType().getKey().getKey().startsWith("HARM") ||
|
||||
effect.getType().getKey().getKey().startsWith("POISON")) &&
|
||||
event.getAffectedEntities().stream().anyMatch(entity -> entity instanceof Player))
|
||||
{
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package dev.plex.listener.impl;
|
||||
|
||||
import dev.plex.listener.PlexListener;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
@@ -48,7 +50,10 @@ public class WorldListener extends PlexListener
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onInteractWorld(PlayerInteractEvent event)
|
||||
{
|
||||
if (event.getInteractionPoint() != null && event.getInteractionPoint().getBlock().getBlockData() instanceof Openable) return;
|
||||
if (event.getInteractionPoint() != null && event.getInteractionPoint().getBlock().getBlockData() instanceof Openable)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!canModifyWorld(event.getPlayer(), true))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
@@ -76,7 +81,10 @@ public class WorldListener extends PlexListener
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onInteractWorld(EntityDamageByEntityEvent event)
|
||||
{
|
||||
if (!(event.getDamager() instanceof Player player)) return;
|
||||
if (!(event.getDamager() instanceof Player player))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!canModifyWorld(player, true))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
|
||||
@@ -2,7 +2,9 @@ package dev.plex.menu;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import dev.plex.util.minimessage.SafeMiniMessage;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.experimental.Accessors;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
@@ -3,8 +3,10 @@ package dev.plex.menu.impl;
|
||||
import dev.plex.menu.AbstractMenu;
|
||||
import dev.plex.menu.pagination.PageableMenu;
|
||||
import dev.plex.util.item.ItemBuilder;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
@@ -7,13 +7,16 @@ import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.punishment.Punishment;
|
||||
import dev.plex.util.TimeUtils;
|
||||
import dev.plex.util.item.ItemBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class PunishedPlayerMenu extends PageableMenu<Punishment>
|
||||
{
|
||||
private final PlexPlayer punishedPlayer;
|
||||
|
||||
public PunishedPlayerMenu(PlexPlayer player)
|
||||
{
|
||||
super("<red><bold>Punishments - " + player.getName(), AbstractMenu.Rows.SIX);
|
||||
|
||||
@@ -6,7 +6,9 @@ import dev.plex.menu.pagination.PageableMenu;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.item.ItemBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -24,7 +26,10 @@ public class PunishmentMenu extends PageableMenu<Player>
|
||||
PlexLog.debug("list: {0}", list().size());
|
||||
onClick((inventoryView, itemStacks, player, itemStack) ->
|
||||
{
|
||||
if (itemStack.getType() != Material.PLAYER_HEAD) return true;
|
||||
if (itemStack.getType() != Material.PLAYER_HEAD)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
final SkullMeta meta = (SkullMeta) itemStack.getItemMeta();
|
||||
if (meta.getOwningPlayer() == null)
|
||||
{
|
||||
|
||||
@@ -3,7 +3,9 @@ package dev.plex.menu.impl;
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.menu.AbstractMenu;
|
||||
import dev.plex.util.PlexUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
@@ -6,8 +6,10 @@ import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.function.ConditionalQuadConsumer;
|
||||
import dev.plex.util.item.ItemBuilder;
|
||||
import dev.plex.util.minimessage.SafeMiniMessage;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@@ -4,6 +4,7 @@ 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;
|
||||
@@ -14,6 +15,7 @@ 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;
|
||||
|
||||
@@ -5,6 +5,7 @@ import dev.plex.Plex;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.listener.PlexListener;
|
||||
import dev.plex.util.PlexLog;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -13,6 +14,7 @@ import java.net.URLConnection;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@@ -22,13 +24,13 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@Getter
|
||||
@Setter(AccessLevel.MODULE)
|
||||
@Setter(AccessLevel.PACKAGE)
|
||||
public abstract class PlexModule
|
||||
{
|
||||
@Getter(AccessLevel.MODULE)
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private final List<PlexCommand> commands = Lists.newArrayList();
|
||||
|
||||
@Getter(AccessLevel.MODULE)
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private final List<PlexListener> listeners = Lists.newArrayList();
|
||||
|
||||
private Plex plex;
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package dev.plex.module;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
|
||||
@@ -11,9 +11,11 @@ import dev.plex.storage.annotation.PrimaryKey;
|
||||
import dev.plex.storage.annotation.SQLTable;
|
||||
import dev.plex.storage.annotation.VarcharLimit;
|
||||
import dev.plex.util.adapter.ZonedDateTimeAdapter;
|
||||
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@@ -79,7 +81,7 @@ public class PlexPlayer
|
||||
{
|
||||
this.loadPunishments();
|
||||
this.checkMutesAndFreeze();
|
||||
// this.permissions.addAll(Plex.get().getSqlPermissions().getPermissions(this.uuid));
|
||||
// this.permissions.addAll(Plex.get().getSqlPermissions().getPermissions(this.uuid));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,7 +95,8 @@ public class PlexPlayer
|
||||
return PlainTextComponentSerializer.plainText().serialize(getPlayer().displayName());
|
||||
}
|
||||
|
||||
public void checkMutesAndFreeze() {
|
||||
public void checkMutesAndFreeze()
|
||||
{
|
||||
final ZonedDateTime now = ZonedDateTime.now();
|
||||
this.muted = this.punishments.stream().filter(punishment -> punishment.getType() == PunishmentType.MUTE).anyMatch(punishment -> punishment.isActive() && now.isBefore(punishment.getEndDate()));
|
||||
this.frozen = this.punishments.stream().filter(punishment -> punishment.getType() == PunishmentType.FREEZE).anyMatch(punishment -> punishment.isActive() && now.isBefore(punishment.getEndDate()));
|
||||
|
||||
@@ -7,8 +7,10 @@ import dev.plex.storage.annotation.SQLTable;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.TimeUtils;
|
||||
import dev.plex.util.adapter.ZonedDateTimeAdapter;
|
||||
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@@ -32,12 +34,6 @@ public class Punishment
|
||||
private boolean active; // Field is only for bans
|
||||
private ZonedDateTime endDate;
|
||||
|
||||
public Punishment()
|
||||
{
|
||||
this.punished = null;
|
||||
this.punisher = null;
|
||||
}
|
||||
|
||||
public Punishment(UUID punished, UUID punisher)
|
||||
{
|
||||
this.punished = punished;
|
||||
|
||||
@@ -10,6 +10,7 @@ import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.TimeUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@@ -20,6 +21,7 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
@@ -4,8 +4,10 @@ import com.google.gson.GsonBuilder;
|
||||
import dev.plex.storage.annotation.NoLimit;
|
||||
import dev.plex.storage.annotation.SQLTable;
|
||||
import dev.plex.util.adapter.ZonedDateTimeAdapter;
|
||||
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
|
||||
@@ -7,8 +7,10 @@ import dev.plex.services.impl.BanService;
|
||||
import dev.plex.services.impl.GameRuleService;
|
||||
import dev.plex.services.impl.TimingService;
|
||||
import dev.plex.services.impl.UpdateCheckerService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class ServiceManager
|
||||
|
||||
@@ -3,7 +3,9 @@ package dev.plex.services.impl;
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.services.AbstractService;
|
||||
import io.papermc.paper.threadedregions.scheduler.ScheduledTask;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
@@ -5,8 +5,10 @@ import dev.plex.services.AbstractService;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.TimeUtils;
|
||||
import io.papermc.paper.threadedregions.scheduler.ScheduledTask;
|
||||
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class BanService extends AbstractService
|
||||
|
||||
@@ -4,7 +4,9 @@ import dev.plex.services.AbstractService;
|
||||
import dev.plex.util.GameRuleUtil;
|
||||
import dev.plex.util.PlexLog;
|
||||
import io.papermc.paper.threadedregions.scheduler.ScheduledTask;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
|
||||
|
||||
@@ -8,9 +8,11 @@ import dev.plex.services.AbstractService;
|
||||
import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.TimeUtils;
|
||||
import io.papermc.paper.threadedregions.scheduler.ScheduledTask;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import dev.plex.Plex;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.storage.StorageType;
|
||||
import dev.plex.util.PlexLog;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.google.common.collect.Lists;
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.punishment.extra.Note;
|
||||
import dev.plex.util.TimeUtils;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
|
||||
@@ -6,6 +6,7 @@ import dev.plex.punishment.Punishment;
|
||||
import dev.plex.punishment.PunishmentType;
|
||||
import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.TimeUtils;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
@@ -84,6 +85,7 @@ public class SQLPunishment
|
||||
}
|
||||
return punishments;
|
||||
}
|
||||
|
||||
public List<Punishment> getPunishments(String ip)
|
||||
{
|
||||
List<Punishment> punishments = Lists.newArrayList();
|
||||
|
||||
@@ -8,14 +8,14 @@ public class BlockUtils
|
||||
public static Location relative(Location origin, BlockFace face)
|
||||
{
|
||||
return switch (face)
|
||||
{
|
||||
case UP -> origin.add(0, 1, 0);
|
||||
case DOWN -> origin.subtract(0, 1, 0);
|
||||
case NORTH -> origin.subtract(0, 0, 1);
|
||||
case SOUTH -> origin.add(0, 0, 1);
|
||||
case WEST -> origin.subtract(1, 0, 0);
|
||||
case EAST -> origin.add(1, 0, 0);
|
||||
default -> origin.add(face.getModX(), face.getModY(), face.getModZ());
|
||||
};
|
||||
{
|
||||
case UP -> origin.add(0, 1, 0);
|
||||
case DOWN -> origin.subtract(0, 1, 0);
|
||||
case NORTH -> origin.subtract(0, 0, 1);
|
||||
case SOUTH -> origin.add(0, 0, 1);
|
||||
case WEST -> origin.subtract(1, 0, 0);
|
||||
case EAST -> origin.add(1, 0, 0);
|
||||
default -> origin.add(face.getModX(), face.getModY(), face.getModZ());
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package dev.plex.util;
|
||||
|
||||
import dev.plex.Plex;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
public class BuildInfo
|
||||
|
||||
@@ -13,7 +13,10 @@ public class PlexLog
|
||||
{
|
||||
for (int i = 0; i < strings.length; i++)
|
||||
{
|
||||
if (strings[i] == null) continue;
|
||||
if (strings[i] == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (message.contains("{" + i + "}"))
|
||||
{
|
||||
message = message.replace("{" + i + "}", strings[i].toString());
|
||||
@@ -31,7 +34,10 @@ public class PlexLog
|
||||
{
|
||||
for (int i = 0; i < strings.length; i++)
|
||||
{
|
||||
if (strings[i] == null) continue;
|
||||
if (strings[i] == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (message.contains("{" + i + "}"))
|
||||
{
|
||||
message = message.replace("{" + i + "}", strings[i].toString());
|
||||
@@ -44,7 +50,10 @@ public class PlexLog
|
||||
{
|
||||
for (int i = 0; i < strings.length; i++)
|
||||
{
|
||||
if (strings[i] == null) continue;
|
||||
if (strings[i] == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (message.contains("{" + i + "}"))
|
||||
{
|
||||
message = message.replace("{" + i + "}", strings[i].toString());
|
||||
@@ -59,7 +68,10 @@ public class PlexLog
|
||||
{
|
||||
for (int i = 0; i < strings.length; i++)
|
||||
{
|
||||
if (strings[i] == null) continue;
|
||||
if (strings[i] == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (message.contains("{" + i + "}"))
|
||||
{
|
||||
message = message.replace("{" + i + "}", strings[i].toString());
|
||||
|
||||
@@ -7,6 +7,7 @@ import dev.plex.PlexBase;
|
||||
import dev.plex.listener.impl.ChatListener;
|
||||
import dev.plex.storage.StorageType;
|
||||
import dev.plex.util.minimessage.SafeMiniMessage;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.time.Month;
|
||||
@@ -18,6 +19,7 @@ import java.util.Stack;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
@@ -133,7 +135,7 @@ public class PlexUtils implements PlexBase
|
||||
List<Command> cmds = PluginCommandYamlParser.parse(plugin);
|
||||
for (Command pluginCmd : cmds)
|
||||
{
|
||||
List<String> cmdAliases = pluginCmd.getAliases().size() > 0 ? pluginCmd.getAliases().stream().map(String::toLowerCase).toList() : null;
|
||||
List<String> cmdAliases = !pluginCmd.getAliases().isEmpty() ? pluginCmd.getAliases().stream().map(String::toLowerCase).toList() : null;
|
||||
if (pluginCmd.getName().equalsIgnoreCase(cmd) || (cmdAliases != null && cmdAliases.contains(cmd.toLowerCase())))
|
||||
{
|
||||
return true;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package dev.plex.util;
|
||||
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
|
||||
public class RandomUtil
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.reflect.ClassPath;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import dev.plex.Plex;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package dev.plex.util;
|
||||
|
||||
import dev.plex.Plex;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
@@ -10,6 +11,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
|
||||
public class TimeUtils
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
package dev.plex.util;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import dev.plex.PlexBase;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URI;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import lombok.NonNull;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
@@ -44,11 +45,11 @@ public class UpdateChecker implements PlexBase
|
||||
private int distance = -4;
|
||||
|
||||
// Adapted from Paper
|
||||
private int fetchDistanceFromGitHub(@Nonnull String repo, @Nonnull String branch, @Nonnull String hash)
|
||||
private int fetchDistanceFromGitHub(@NonNull String repo, @NonNull String branch, @NonNull String hash)
|
||||
{
|
||||
try
|
||||
{
|
||||
HttpURLConnection connection = (HttpURLConnection) new URL("https://api.github.com/repos/" + repo + "/compare/" + branch + "..." + hash).openConnection();
|
||||
HttpURLConnection connection = (HttpURLConnection) URI.create("https://api.github.com/repos/" + repo + "/compare/" + branch + "..." + hash).toURL().openConnection();
|
||||
connection.connect();
|
||||
if (connection.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND)
|
||||
{
|
||||
@@ -58,16 +59,16 @@ public class UpdateChecker implements PlexBase
|
||||
{
|
||||
return -3; // Rate limited likely
|
||||
}
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), Charsets.UTF_8)))
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8)))
|
||||
{
|
||||
JsonObject obj = new Gson().fromJson(reader, JsonObject.class);
|
||||
String status = obj.get("status").getAsString();
|
||||
return switch (status)
|
||||
{
|
||||
case "identical" -> 0;
|
||||
case "behind" -> obj.get("behind_by").getAsInt();
|
||||
default -> -1;
|
||||
};
|
||||
{
|
||||
case "identical" -> 0;
|
||||
case "behind" -> obj.get("behind_by").getAsInt();
|
||||
default -> -1;
|
||||
};
|
||||
}
|
||||
catch (JsonSyntaxException | NumberFormatException e)
|
||||
{
|
||||
@@ -186,7 +187,7 @@ public class UpdateChecker implements PlexBase
|
||||
try
|
||||
{
|
||||
FileUtils.copyURLToFile(
|
||||
new URL(url + "/lastSuccessfulBuild/artifact/build/libs/" + jarFile),
|
||||
URI.create(url + "/lastSuccessfulBuild/artifact/build/libs/" + jarFile).toURL(),
|
||||
copyTo
|
||||
);
|
||||
sender.sendMessage(PlexUtils.mmDeserialize("<green>New JAR file downloaded successfully."));
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.google.gson.JsonPrimitive;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
import dev.plex.Plex;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneId;
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package dev.plex.util.item;
|
||||
|
||||
import dev.plex.util.minimessage.SafeMiniMessage;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package dev.plex.util.minimessage;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.Context;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
|
||||
@@ -7,7 +7,9 @@ import dev.plex.hook.VaultHook;
|
||||
import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.minimessage.SafeMiniMessage;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -15,6 +17,7 @@ import org.bukkit.entity.Player;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import redis.clients.jedis.JedisPubSub;
|
||||
|
||||
import static dev.plex.util.PlexUtils.messageComponent;
|
||||
|
||||
public class MessageUtil
|
||||
|
||||
@@ -11,6 +11,7 @@ import dev.plex.storage.annotation.SQLTable;
|
||||
import dev.plex.storage.annotation.VarcharLimit;
|
||||
import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.ReflectionsUtil;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.time.ZonedDateTime;
|
||||
@@ -20,6 +21,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import lombok.experimental.Accessors;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package dev.plex.util.sql;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Map;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package dev.plex.world;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user