Some updates

This commit is contained in:
Telesphoreo 2021-06-20 03:02:07 -05:00
parent 5bafa1122c
commit f4aa3bd3b9
16 changed files with 209 additions and 34 deletions

24
pom.xml
View File

@ -27,21 +27,27 @@
<dependency> <dependency>
<groupId>com.destroystokyo.paper</groupId> <groupId>com.destroystokyo.paper</groupId>
<artifactId>paper-api</artifactId> <artifactId>paper-api</artifactId>
<version>1.16.4-R0.1-SNAPSHOT</version> <version>1.16.5-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>io.papermc</groupId>
<artifactId>paperlib</artifactId>
<version>1.0.6</version>
<scope>compile</scope>
</dependency>
<!-- UTILITIES --> <!-- UTILITIES -->
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
<version>1.18.16</version> <version>1.18.20</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.json</groupId> <groupId>org.json</groupId>
<artifactId>json</artifactId> <artifactId>json</artifactId>
<version>20201115</version> <version>20210307</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
@ -56,19 +62,19 @@
<dependency> <dependency>
<groupId>dev.morphia.morphia</groupId> <groupId>dev.morphia.morphia</groupId>
<artifactId>morphia-core</artifactId> <artifactId>morphia-core</artifactId>
<version>2.1.3</version> <version>2.1.7</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>redis.clients</groupId> <groupId>redis.clients</groupId>
<artifactId>jedis</artifactId> <artifactId>jedis</artifactId>
<version>3.4.1</version> <version>3.6.1</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.mariadb.jdbc</groupId> <groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId> <artifactId>mariadb-java-client</artifactId>
<version>2.7.1</version> <version>2.7.3</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
</dependencies> </dependencies>
@ -86,14 +92,14 @@
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version> <version>3.8.1</version>
<configuration> <configuration>
<source>11</source> <source>16</source>
<target>11</target> <target>16</target>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId> <artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version> <version>3.3.0-SNAPSHOT</version>
<executions> <executions>
<execution> <execution>
<phase>package</phase> <phase>package</phase>

View File

@ -0,0 +1,11 @@
package dev.plex.command.exception;
import static dev.plex.util.PlexUtils.tl;
public class ConsoleOnlyException extends RuntimeException
{
public ConsoleOnlyException()
{
super(tl("consoleOnly"));
}
}

View File

@ -3,6 +3,7 @@ package dev.plex.command.impl;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import dev.plex.command.annotation.CommandParameters; import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions; import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.exception.ConsoleOnlyException;
import dev.plex.command.exception.PlayerNotFoundException; import dev.plex.command.exception.PlayerNotFoundException;
import dev.plex.command.source.CommandSource; import dev.plex.command.source.CommandSource;
import dev.plex.command.source.RequiredCommandSource; import dev.plex.command.source.RequiredCommandSource;
@ -50,8 +51,7 @@ public class AdminCMD extends PlexCommand
if (!sender.isConsoleSender()) if (!sender.isConsoleSender())
{ {
sender.send("Console only"); throw new ConsoleOnlyException();
return;
} }
UUID targetUUID = PlexUtils.getFromName(args[1]); UUID targetUUID = PlexUtils.getFromName(args[1]);
@ -64,7 +64,7 @@ public class AdminCMD extends PlexCommand
if (isAdmin(plexPlayer)) if (isAdmin(plexPlayer))
{ {
sender.send("Player is an admin"); sender.send(tl("playerIsAdmin"));
return; return;
} }
@ -83,8 +83,7 @@ public class AdminCMD extends PlexCommand
if (!sender.isConsoleSender()) if (!sender.isConsoleSender())
{ {
sender.send("Console only"); throw new ConsoleOnlyException();
return;
} }
UUID targetUUID = PlexUtils.getFromName(args[1]); UUID targetUUID = PlexUtils.getFromName(args[1]);
@ -97,7 +96,7 @@ public class AdminCMD extends PlexCommand
if (!isAdmin(plexPlayer)) if (!isAdmin(plexPlayer))
{ {
sender.send("Player is not an admin"); sender.send(tl("playerNotAdmin"));
return; return;
} }
@ -117,8 +116,7 @@ public class AdminCMD extends PlexCommand
if (!sender.isConsoleSender()) if (!sender.isConsoleSender())
{ {
sender.send("Console only"); throw new ConsoleOnlyException();
return;
} }
UUID targetUUID = PlexUtils.getFromName(args[1]); UUID targetUUID = PlexUtils.getFromName(args[1]);
@ -130,7 +128,7 @@ public class AdminCMD extends PlexCommand
if (!rankExists(args[2])) if (!rankExists(args[2]))
{ {
sender.send("Rank not found"); sender.send(tl("rankNotFound"));
return; return;
} }
@ -138,7 +136,7 @@ public class AdminCMD extends PlexCommand
if (!rank.isAtLeast(Rank.ADMIN)) if (!rank.isAtLeast(Rank.ADMIN))
{ {
sender.send("Must be admin+"); sender.send(tl("rankMustBeHigherThanAdmin"));
return; return;
} }
@ -146,7 +144,7 @@ public class AdminCMD extends PlexCommand
if (!isAdmin(plexPlayer)) if (!isAdmin(plexPlayer))
{ {
sender.send("Player is not an admin"); sender.send(tl("playerNotAdmin"));
return; return;
} }

View File

@ -0,0 +1,48 @@
package dev.plex.command.impl;
import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.exception.CommandFailException;
import dev.plex.command.source.CommandSource;
import dev.plex.command.source.RequiredCommandSource;
import io.papermc.lib.PaperLib;
import java.util.Collections;
import java.util.List;
import com.google.common.collect.ImmutableList;
import dev.plex.command.PlexCommand;
import dev.plex.rank.enums.Rank;
import dev.plex.util.PlexUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.ADMIN, source = RequiredCommandSource.IN_GAME)
@CommandParameters(aliases = "aw", description = "Teleport to the adminworld")
public class AdminworldCMD extends PlexCommand
{
public AdminworldCMD()
{
super("adminworld");
}
@Override
public void execute(CommandSource sender, String[] args)
{
// TODO: Add adminworld settings
if (args.length == 0)
{
Location loc = new Location(Bukkit.getWorld("adminworld"), 0, 50, 0);
PaperLib.teleportAsync(sender.getPlayer(), loc);
send(tl("teleportedToWorld", "adminworld"));
}
}
@Override
public List<String> onTabComplete(CommandSource sender, String[] args)
{
return Collections.emptyList();
}
}

View File

@ -57,7 +57,7 @@ public class BanCMD extends PlexCommand
PlexPlayer plexPlayer1 = sender.getPlexPlayer(); PlexPlayer plexPlayer1 = sender.getPlexPlayer();
if (!plexPlayer1.getRankFromString().isAtLeast(plexPlayer.getRankFromString())) if (!plexPlayer1.getRankFromString().isAtLeast(plexPlayer.getRankFromString()))
{ {
sender.send("This player is an admin and a higher rank than you."); sender.send(tl("higherRankThanYou"));
return; return;
} }
} }

View File

@ -0,0 +1,47 @@
package dev.plex.command.impl;
import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.exception.CommandFailException;
import dev.plex.command.source.CommandSource;
import dev.plex.command.source.RequiredCommandSource;
import io.papermc.lib.PaperLib;
import java.util.Collections;
import java.util.List;
import com.google.common.collect.ImmutableList;
import dev.plex.command.PlexCommand;
import dev.plex.rank.enums.Rank;
import dev.plex.util.PlexUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.ADMIN, source = RequiredCommandSource.IN_GAME)
@CommandParameters(description = "Teleport to the flatlands")
public class FlatlandsCMD extends PlexCommand
{
public FlatlandsCMD()
{
super("flatlands");
}
@Override
public void execute(CommandSource sender, String[] args)
{
if (args.length == 0)
{
Location loc = new Location(Bukkit.getWorld("flatlands"), 0, 50, 0);
PaperLib.teleportAsync(sender.getPlayer(), loc);
send(tl("teleportedToWorld", "flatlands"));
}
}
@Override
public List<String> onTabComplete(CommandSource sender, String[] args)
{
return Collections.emptyList();
}
}

View File

@ -0,0 +1,48 @@
package dev.plex.command.impl;
import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.exception.CommandFailException;
import dev.plex.command.source.CommandSource;
import dev.plex.command.source.RequiredCommandSource;
import io.papermc.lib.PaperLib;
import java.util.Collections;
import java.util.List;
import com.google.common.collect.ImmutableList;
import dev.plex.command.PlexCommand;
import dev.plex.rank.enums.Rank;
import dev.plex.util.PlexUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.ADMIN, source = RequiredCommandSource.IN_GAME)
@CommandParameters(aliases = "mbw", description = "Teleport to the Master Builder world")
public class MasterbuilderworldCMD extends PlexCommand
{
public MasterbuilderworldCMD()
{
super("masterbuilderworld");
}
@Override
public void execute(CommandSource sender, String[] args)
{
// TODO: Add adminworld settings
if (args.length == 0)
{
Location loc = new Location(Bukkit.getWorld("masterbuilderworld"), 0, 50, 0);
PaperLib.teleportAsync(sender.getPlayer(), loc);
send(tl("teleportedToWorld", "Master Builder world"));
}
}
@Override
public List<String> onTabComplete(CommandSource sender, String[] args)
{
return Collections.emptyList();
}
}

View File

@ -1,5 +1,6 @@
package dev.plex.command.impl; package dev.plex.command.impl;
import dev.plex.Plex;
import dev.plex.command.annotation.CommandParameters; import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions; import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.source.CommandSource; import dev.plex.command.source.CommandSource;
@ -8,6 +9,7 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import dev.plex.command.PlexCommand; import dev.plex.command.PlexCommand;
import dev.plex.rank.enums.Rank; import dev.plex.rank.enums.Rank;
import org.bukkit.ChatColor;
@CommandPermissions(level = Rank.OP, source = RequiredCommandSource.ANY) @CommandPermissions(level = Rank.OP, source = RequiredCommandSource.ANY)
@CommandParameters(aliases = "plexhelp", description = "Help with plex") @CommandParameters(aliases = "plexhelp", description = "Help with plex")
@ -21,7 +23,8 @@ public class PlexCMD extends PlexCommand
@Override @Override
public void execute(CommandSource sender, String[] args) public void execute(CommandSource sender, String[] args)
{ {
send("HI"); send(ChatColor.LIGHT_PURPLE + "Plex. The long awaited TotalFreedomMod rewrite starts here...");
send(ChatColor.LIGHT_PURPLE + "Plugin version: " + ChatColor.GOLD + "1.0");
} }
@Override @Override

View File

@ -2,11 +2,14 @@ package dev.plex.handlers;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import dev.plex.command.impl.AdminCMD; import dev.plex.command.impl.AdminCMD;
import dev.plex.command.impl.AdminworldCMD;
import dev.plex.command.impl.AdventureCMD; import dev.plex.command.impl.AdventureCMD;
import dev.plex.command.impl.BanCMD; import dev.plex.command.impl.BanCMD;
import dev.plex.command.impl.CreativeCMD; import dev.plex.command.impl.CreativeCMD;
import dev.plex.command.impl.FionnCMD; import dev.plex.command.impl.FionnCMD;
import dev.plex.command.impl.FlatlandsCMD;
import dev.plex.command.impl.FreezeCMD; import dev.plex.command.impl.FreezeCMD;
import dev.plex.command.impl.MasterbuilderworldCMD;
import dev.plex.command.impl.NameHistoryCMD; import dev.plex.command.impl.NameHistoryCMD;
import dev.plex.command.impl.OpAllCMD; import dev.plex.command.impl.OpAllCMD;
import dev.plex.command.impl.OpCMD; import dev.plex.command.impl.OpCMD;
@ -22,10 +25,9 @@ import dev.plex.util.PlexLog;
public class CommandHandler public class CommandHandler
{ {
private List<PlexCommand> commands = Lists.newArrayList();
public CommandHandler() public CommandHandler()
{ {
List<PlexCommand> commands = Lists.newArrayList();
commands.add(new TestCMD()); commands.add(new TestCMD());
commands.add(new PlexCMD()); commands.add(new PlexCMD());
commands.add(new FionnCMD()); commands.add(new FionnCMD());
@ -41,6 +43,9 @@ public class CommandHandler
commands.add(new SpectatorCMD()); commands.add(new SpectatorCMD());
commands.add(new BanCMD()); commands.add(new BanCMD());
commands.add(new PunishmentsCMD()); commands.add(new PunishmentsCMD());
commands.add(new FlatlandsCMD());
commands.add(new AdminworldCMD());
commands.add(new MasterbuilderworldCMD());
PlexLog.log(String.format("Registered %s commands!", commands.size())); PlexLog.log(String.format("Registered %s commands!", commands.size()));
} }
} }

View File

@ -14,9 +14,9 @@ import dev.plex.util.PlexLog;
public class ListenerHandler public class ListenerHandler
{ {
List<PlexListener> listeners = Lists.newArrayList();
public ListenerHandler() public ListenerHandler()
{ {
List<PlexListener> listeners = Lists.newArrayList();
listeners.add(new ServerListener()); listeners.add(new ServerListener());
listeners.add(new ChatListener()); listeners.add(new ChatListener());
listeners.add(new PlayerListener()); listeners.add(new PlayerListener());

View File

@ -7,6 +7,7 @@ import dev.plex.listener.PlexListener;
import dev.plex.player.PlexPlayer; import dev.plex.player.PlexPlayer;
import dev.plex.rank.enums.Rank; import dev.plex.rank.enums.Rank;
import static dev.plex.util.PlexUtils.tl; import static dev.plex.util.PlexUtils.tl;
import dev.plex.util.PlexUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -18,7 +19,7 @@ public class AdminListener extends PlexListener
String userSender = event.getSender().getName(); String userSender = event.getSender().getName();
PlexPlayer target = event.getPlexPlayer(); PlexPlayer target = event.getPlexPlayer();
Bukkit.broadcastMessage(tl("newAdminAdded", userSender, target.getName())); PlexUtils.broadcast(tl("newAdminAdded", userSender, target.getName()));
} }
@EventHandler @EventHandler
@ -27,7 +28,7 @@ public class AdminListener extends PlexListener
String userSender = event.getSender().getName(); String userSender = event.getSender().getName();
PlexPlayer target = event.getPlexPlayer(); PlexPlayer target = event.getPlexPlayer();
Bukkit.broadcastMessage(tl("adminRemoved", userSender, target.getName())); PlexUtils.broadcast(tl("adminRemoved", userSender, target.getName()));
} }
@EventHandler @EventHandler
@ -37,6 +38,6 @@ public class AdminListener extends PlexListener
PlexPlayer target = event.getPlexPlayer(); PlexPlayer target = event.getPlexPlayer();
Rank newRank = event.getRank(); Rank newRank = event.getRank();
Bukkit.broadcastMessage(tl("adminSetRank", userSender, target.getName(), newRank.name().toUpperCase())); PlexUtils.broadcast(tl("adminSetRank", userSender, target.getName(), newRank.name().toUpperCase()));
} }
} }

View File

@ -23,6 +23,9 @@ public class ChatListener extends PlexListener
{ {
event.setFormat(String.format("%s %s §7» %s", plexPlayer.getRankFromString().getPrefix(), ChatColor.RESET + plexPlayer.getName(), event.getMessage())); event.setFormat(String.format("%s %s §7» %s", plexPlayer.getRankFromString().getPrefix(), ChatColor.RESET + plexPlayer.getName(), event.getMessage()));
} }
else
{
event.setFormat(String.format("%s §7» %s", ChatColor.RESET + plexPlayer.getName(), event.getMessage()));
}
} }
} }

View File

@ -17,5 +17,4 @@ public class FreezeListener extends PlexListener
e.setCancelled(true); e.setCancelled(true);
} }
} }
} }

View File

@ -7,7 +7,6 @@ import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
public class LoginListener extends PlexListener public class LoginListener extends PlexListener
{ {
//TODO: Customizable MSGS //TODO: Customizable MSGS
@EventHandler @EventHandler
@ -16,7 +15,7 @@ public class LoginListener extends PlexListener
PlexLog.log(String.valueOf(plugin.getBanManager().isBanned(event.getUniqueId()))); PlexLog.log(String.valueOf(plugin.getBanManager().isBanned(event.getUniqueId())));
if (plugin.getBanManager().isBanned(event.getUniqueId())) if (plugin.getBanManager().isBanned(event.getUniqueId()))
{ {
event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED, "§cYou're currently banned from this server.\n§cPlease appeal at §6https://forums.telesphoreo.me"); event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED, "§cYou're currently banned from this server.\n§cPlease appeal at §6https://forum.telesphoreo.me");
} }
} }

View File

@ -29,7 +29,7 @@ public class PlexUtils
{ {
public static Map<String, ChatColor> CHAT_COLOR_NAMES; public static Map<String, ChatColor> CHAT_COLOR_NAMES;
public static List<ChatColor> CHAT_COLOR_POOL; public static List<ChatColor> CHAT_COLOR_POOL;
private static Random RANDOM; private static final Random RANDOM;
static static
{ {

View File

@ -57,4 +57,11 @@ playerSetOtherGameMode: <v> set your gamemode to <v>.
consoleMustDefinePlayer: You must define a player since you are running this command from console. consoleMustDefinePlayer: You must define a player since you are running this command from console.
newAdminAdded: <b><v> - Adding <v> to the admin list newAdminAdded: <b><v> - Adding <v> to the admin list
adminRemoved: <c><v> - Removing <v> from the admin list adminRemoved: <c><v> - Removing <v> from the admin list
adminSetRank: <b><v> - Setting <v>'s rank to <v> adminSetRank: <b><v> - Setting <v>'s rank to <v>
teleportedToWorld: <b>You have been teleported to the <v>.
higherRankThanYou: <b>This player is an admin and a higher rank than you.
playerNotAdmin: <b>That player is not an admin.
playerIsAdmin: <b>That player is already an admin.
rankNotFound: <b>The rank you entered was not found.
rankMustBeHigherThanAdmin: <b>The rank you entered must be higher than Admin.
consoleOnly: <b>This command can only be executed by the console.