mirror of
https://github.com/plexusorg/Plex.git
synced 2024-12-22 17:17:37 +00:00
Begin work on 1.18.2
- Add update checking - World generation is broken - Won't compile unless 1.18.2 is in your local Maven repository - No longer need MiniMessage bundled in Plex - Customizable namehistory - Set comments in config.yml if they're missing
This commit is contained in:
parent
22a26edd79
commit
0b5425b8d2
10
build.gradle
10
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,13 +32,9 @@ 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"
|
||||
|
@ -20,6 +20,7 @@ import dev.plex.storage.SQLConnection;
|
||||
import dev.plex.storage.StorageType;
|
||||
import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.UpdateChecker;
|
||||
import dev.plex.world.CustomWorld;
|
||||
import java.util.UUID;
|
||||
import lombok.Getter;
|
||||
@ -52,6 +53,8 @@ public class Plex extends JavaPlugin
|
||||
|
||||
private AdminList adminList;
|
||||
|
||||
private UpdateChecker updateChecker;
|
||||
|
||||
private String system;
|
||||
|
||||
public static Plex get()
|
||||
@ -91,6 +94,9 @@ public class Plex extends JavaPlugin
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
updateChecker = new UpdateChecker();
|
||||
PlexLog.log("Update checking enabled");
|
||||
|
||||
// https://bstats.org/plugin/bukkit/Plex/14143
|
||||
Metrics metrics = new Metrics(this, 14143);
|
||||
PlexLog.log("Enabled Metrics");
|
||||
@ -117,7 +123,6 @@ public class Plex extends JavaPlugin
|
||||
new ListenerHandler();
|
||||
new CommandHandler();
|
||||
|
||||
|
||||
rankManager = new RankManager();
|
||||
rankManager.generateDefaultRanks();
|
||||
rankManager.importDefaultRanks();
|
||||
@ -126,14 +131,12 @@ public class Plex extends JavaPlugin
|
||||
|
||||
punishmentManager = new PunishmentManager();
|
||||
punishmentManager.mergeIndefiniteBans();
|
||||
// banManager = new BanManager();
|
||||
PlexLog.log("Punishment System initialized");
|
||||
|
||||
generateWorlds();
|
||||
|
||||
serviceManager = new ServiceManager();
|
||||
PlexLog.log("Service Manager initialized");
|
||||
|
||||
serviceManager.startServices();
|
||||
PlexLog.log("Started " + serviceManager.serviceCount() + " services.");
|
||||
|
||||
|
@ -516,7 +516,7 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
||||
*/
|
||||
protected Component mmString(String s)
|
||||
{
|
||||
return MiniMessage.miniMessage().parse(s);
|
||||
return MiniMessage.miniMessage().deserialize(s);
|
||||
}
|
||||
|
||||
public Rank getLevel()
|
||||
|
@ -49,7 +49,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;
|
||||
}
|
||||
|
||||
|
@ -49,11 +49,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 +60,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;
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ public class SurvivalCMD extends PlexCommand
|
||||
throw new CommandFailException(PlexUtils.messageString("consoleMustDefinePlayer"));
|
||||
}
|
||||
Bukkit.getServer().getPluginManager().callEvent(new GameModeUpdateEvent(sender, playerSender, GameMode.SURVIVAL));
|
||||
return null;
|
||||
}
|
||||
|
||||
if (checkRank(sender, Rank.ADMIN, "plex.gamemode.survival.others"))
|
||||
|
@ -68,6 +68,7 @@ public class Config extends YamlConfiguration
|
||||
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;
|
||||
@ -77,6 +78,7 @@ public class Config extends YamlConfiguration
|
||||
{
|
||||
externalYamlConfig.save(file);
|
||||
PlexLog.log("Saving new file...");
|
||||
added = false;
|
||||
}
|
||||
super.load(file);
|
||||
}
|
||||
|
@ -58,11 +58,11 @@ public class PunishmentManager extends PlexBase
|
||||
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) into the indefinite banned list", 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.bannedUUIDs.size(), this.bannedIPs.size(), this.bannedUsernames.size());
|
||||
|
||||
if (Plex.get().getRedisConnection().isEnabled())
|
||||
{
|
||||
PlexLog.log("Resetting redis indefinite bans lists and asynchronously uploading from configuration");
|
||||
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));
|
||||
|
@ -2,5 +2,5 @@ package dev.plex.punishment;
|
||||
|
||||
public enum PunishmentType
|
||||
{
|
||||
MUTE, FREEZE, BAN, KICK;
|
||||
MUTE, FREEZE, BAN, KICK
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package dev.plex.services;
|
||||
|
||||
public abstract class AbstractService implements IService
|
||||
import dev.plex.PlexBase;
|
||||
|
||||
public abstract class AbstractService extends PlexBase implements IService
|
||||
{
|
||||
private boolean asynchronous;
|
||||
private boolean repeating;
|
||||
|
@ -2,7 +2,9 @@ package dev.plex.services;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.services.impl.BanService;
|
||||
import dev.plex.services.impl.GameRuleService;
|
||||
import dev.plex.services.impl.UpdateCheckerService;
|
||||
import java.util.List;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
@ -12,7 +14,9 @@ public class ServiceManager
|
||||
|
||||
public ServiceManager()
|
||||
{
|
||||
registerService(new BanService());
|
||||
registerService(new GameRuleService());
|
||||
registerService(new UpdateCheckerService());
|
||||
}
|
||||
|
||||
public void startServices()
|
||||
|
@ -22,8 +22,6 @@ public class BanService extends AbstractService
|
||||
if (LocalDateTime.now().isAfter(punishment.getEndDate()))
|
||||
{
|
||||
Plex.get().getPunishmentManager().unban(punishment);
|
||||
// Plex.get().getBanManager().unban(ban.getId());
|
||||
// Bukkit.broadcastMessage("Plex - Unbanned " + Bukkit.getOfflinePlayer(ban.getUuid()).getName());
|
||||
Bukkit.broadcast(Component.text("Plex - Unbanned " + Bukkit.getOfflinePlayer(punishment.getPunished()).getName()));
|
||||
}
|
||||
}
|
||||
@ -32,6 +30,7 @@ public class BanService extends AbstractService
|
||||
@Override
|
||||
public int repeatInSeconds()
|
||||
{
|
||||
return 1;
|
||||
// Every 5 minutes
|
||||
return 300;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,32 @@
|
||||
package dev.plex.services.impl;
|
||||
|
||||
import dev.plex.services.AbstractService;
|
||||
|
||||
public class UpdateCheckerService extends AbstractService
|
||||
{
|
||||
public UpdateCheckerService()
|
||||
{
|
||||
super(true, true);
|
||||
}
|
||||
|
||||
private boolean newVersion = false;
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (!newVersion)
|
||||
{
|
||||
if (plugin.getUpdateChecker().check())
|
||||
{
|
||||
newVersion = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int repeatInSeconds()
|
||||
{
|
||||
// Every 30 minutes
|
||||
return 1800;
|
||||
}
|
||||
}
|
@ -6,14 +6,13 @@ 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;
|
||||
|
||||
public class MongoConnection
|
||||
public class MongoConnection extends PlexBase
|
||||
{
|
||||
// USE MORPHIA API FOR MONGO <3
|
||||
|
||||
private final Plex plugin = Plex.get();
|
||||
|
||||
public Datastore getDatastore()
|
||||
{
|
||||
if (!plugin.config.getString("data.central.storage").equalsIgnoreCase("mongodb"))
|
||||
|
@ -131,7 +131,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)
|
||||
|
47
src/main/java/dev/plex/util/UpdateChecker.java
Normal file
47
src/main/java/dev/plex/util/UpdateChecker.java
Normal file
@ -0,0 +1,47 @@
|
||||
package dev.plex.util;
|
||||
|
||||
import dev.plex.PlexBase;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
public class UpdateChecker extends PlexBase
|
||||
{
|
||||
private final String currentVersion = plugin.getDescription().getVersion();
|
||||
|
||||
public boolean check()
|
||||
{
|
||||
try
|
||||
{
|
||||
String versionLink = "https://plex.us.org/updater/check/";
|
||||
URL url = new URL(versionLink);
|
||||
URLConnection con = url.openConnection();
|
||||
InputStreamReader isr = new InputStreamReader(con.getInputStream());
|
||||
BufferedReader reader = new BufferedReader(isr);
|
||||
if (!reader.ready())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
String newVersion = reader.readLine();
|
||||
reader.close();
|
||||
|
||||
if (!newVersion.equals(currentVersion))
|
||||
{
|
||||
PlexLog.log(ChatColor.RED + "There is a new version of Plex available: " + newVersion);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
PlexLog.error("There was an error checking for updates!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -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,10 +112,10 @@ 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."
|
||||
adminChatFormat: '&8[&9AdminChat&8] &4<v> &7» &6<v>'
|
||||
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."
|
||||
otherPrefixCleared: "<aqua>You have cleared <v>'s prefix."
|
||||
|
Loading…
Reference in New Issue
Block a user