mirror of
https://github.com/plexusorg/Plex.git
synced 2024-12-28 19:14:15 +00:00
Many, many bug fixes
- Fix permission checks - Fix unban command - getOfflinePlexPlayer no longer uses cache - Register worlds before trying to load gamerules - Customizable ban messages
This commit is contained in:
parent
bb978f2ab4
commit
d4761d4386
12 changed files with 74 additions and 50 deletions
|
@ -105,7 +105,7 @@ public class Plex extends JavaPlugin
|
|||
sqlPlayerData = new SQLPlayerData();
|
||||
}
|
||||
|
||||
new ListenerHandler(); // this doesn't need a variable.
|
||||
new ListenerHandler();
|
||||
new CommandHandler();
|
||||
|
||||
|
||||
|
@ -119,14 +119,14 @@ public class Plex extends JavaPlugin
|
|||
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.");
|
||||
|
||||
generateWorlds();
|
||||
|
||||
reloadPlayers();
|
||||
}
|
||||
|
||||
|
|
|
@ -167,6 +167,16 @@ public abstract class PlexCommand extends Command
|
|||
audience.sendMessage(component);
|
||||
}
|
||||
|
||||
protected boolean checkRank(CommandSender sender, Rank rank, String permission)
|
||||
{
|
||||
if (!isConsole(sender))
|
||||
{
|
||||
checkRank((Player)sender, rank, permission);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean checkRank(Player player, Rank rank, String permission)
|
||||
{
|
||||
PlexPlayer plexPlayer = getPlexPlayer(player);
|
||||
|
@ -174,16 +184,14 @@ public abstract class PlexCommand extends Command
|
|||
{
|
||||
if (!plexPlayer.getRank().equals(rank.toString()))
|
||||
{
|
||||
send(player, tl("noPermissionRank", rank.toString()));
|
||||
return true;
|
||||
throw new CommandFailException(PlexUtils.tl("noPermissionRank", ChatColor.stripColor(rank.getLoginMSG())));
|
||||
}
|
||||
}
|
||||
else if (plugin.getRanksOrPermissions().equalsIgnoreCase("permissions"))
|
||||
{
|
||||
if (!player.hasPermission(permission))
|
||||
{
|
||||
send(player, tl("noPermissionNode", permission));
|
||||
return true;
|
||||
throw new CommandFailException(PlexUtils.tl("noPermissionNode", permission));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -268,7 +276,7 @@ public abstract class PlexCommand extends Command
|
|||
|
||||
protected PlexPlayer getOfflinePlexPlayer(UUID uuid)
|
||||
{
|
||||
PlexPlayer plexPlayer = PlayerCache.getPlexPlayer(uuid);
|
||||
PlexPlayer plexPlayer = DataUtils.getPlayer(uuid);
|
||||
if (plexPlayer == null)
|
||||
{
|
||||
throw new PlayerNotFoundException();
|
||||
|
|
|
@ -64,11 +64,10 @@ public class BanCMD extends PlexCommand
|
|||
punishment.setType(PunishmentType.BAN);
|
||||
punishment.setReason("");
|
||||
punishment.setPunishedUsername(plexPlayer.getName());
|
||||
//TODO: Debug End date
|
||||
punishment.setEndDate(new Date(Instant.now().plusSeconds(10/*PlexUtils.secondsToHours(24)*/).getEpochSecond()));
|
||||
punishment.setEndDate(new Date(Instant.now().plusSeconds(PlexUtils.hoursToSeconds(24)).getEpochSecond()));
|
||||
punishment.setCustomTime(false);
|
||||
plugin.getPunishmentManager().doPunishment(punishedPlayer, punishment);
|
||||
PlexUtils.broadcast(tl("unbanningPlayer", sender.getName(), plexPlayer.getName()));
|
||||
PlexUtils.broadcast(tl("banningPlayer", sender.getName(), plexPlayer.getName()));
|
||||
if (Bukkit.getPlayer(targetUUID) != null)
|
||||
{
|
||||
Bukkit.getPlayer(targetUUID).kick(componentFromString("&cYou've been banned."));
|
||||
|
@ -82,5 +81,4 @@ public class BanCMD extends PlexCommand
|
|||
{
|
||||
return args.length == 1 && isAdmin(sender) ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,17 +17,20 @@ import org.jetbrains.annotations.NotNull;
|
|||
|
||||
@CommandPermissions(level = Rank.OP, permission = "plex.plex", source = RequiredCommandSource.ANY)
|
||||
@CommandParameters(name = "plex", usage = "/<command> [reload]", aliases = "plexhelp", description = "Show information about Plex or reload it")
|
||||
public class PlexCMD extends PlexCommand {
|
||||
public class PlexCMD extends PlexCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public Component execute(CommandSender sender, String[] args) {
|
||||
if (args.length == 0) {
|
||||
public Component execute(CommandSender sender, String[] args)
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
send(sender, ChatColor.LIGHT_PURPLE + "Plex. The long awaited TotalFreedomMod rewrite starts here...");
|
||||
return componentFromString(ChatColor.LIGHT_PURPLE + "Plugin version: " + ChatColor.GOLD + "1.0");
|
||||
}
|
||||
if (args[0].equals("reload"))
|
||||
{
|
||||
checkRank((Player)sender, Rank.SENIOR_ADMIN, "plex.reload");
|
||||
checkRank(sender, Rank.SENIOR_ADMIN, "plex.reload");
|
||||
Plex.get().config.load();
|
||||
send(sender, "Reloaded config file");
|
||||
Plex.get().messages.load();
|
||||
|
@ -35,7 +38,9 @@ public class PlexCMD extends PlexCommand {
|
|||
Plex.get().getRankManager().importDefaultRanks();
|
||||
send(sender, "Imported ranks");
|
||||
send(sender, "Plex successfully reloaded.");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new CommandArgumentException();
|
||||
}
|
||||
return null;
|
||||
|
@ -46,5 +51,4 @@ public class PlexCMD extends PlexCommand {
|
|||
{
|
||||
return ImmutableList.of("reload");
|
||||
}
|
||||
|
||||
}
|
|
@ -8,11 +8,14 @@ import dev.plex.command.annotation.CommandPermissions;
|
|||
import dev.plex.command.exception.PlayerNotBannedException;
|
||||
import dev.plex.command.exception.PlayerNotFoundException;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
@ -33,9 +36,9 @@ public class UnbanCMD extends PlexCommand
|
|||
if (args.length == 1)
|
||||
{
|
||||
UUID targetUUID = PlexUtils.getFromName(args[0]);
|
||||
Player player = getNonNullPlayer(args[0]);
|
||||
PlexPlayer plexPlayer = getOfflinePlexPlayer(targetUUID);
|
||||
|
||||
if (targetUUID == null || !DataUtils.hasPlayedBefore(targetUUID))
|
||||
if (!DataUtils.hasPlayedBefore(targetUUID))
|
||||
{
|
||||
throw new PlayerNotFoundException();
|
||||
}
|
||||
|
@ -46,7 +49,7 @@ public class UnbanCMD extends PlexCommand
|
|||
}
|
||||
|
||||
plugin.getBanManager().unban(targetUUID);
|
||||
PlexUtils.broadcast(tl("unbanningPlayer", sender.getName(), player.getName()));
|
||||
PlexUtils.broadcast(tl("unbanningPlayer", sender.getName(), plexPlayer.getName()));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ public class CommandHandler extends PlexBase
|
|||
commands.add(new DeopCMD());
|
||||
commands.add(new OpAllCMD());
|
||||
commands.add(new OpCMD());
|
||||
commands.add(new RankCMD());
|
||||
}
|
||||
commands.add(new AdminworldCMD());
|
||||
commands.add(new AdventureCMD());
|
||||
|
@ -31,7 +32,6 @@ public class CommandHandler extends PlexBase
|
|||
commands.add(new NameHistoryCMD());
|
||||
commands.add(new PlexCMD());
|
||||
commands.add(new PunishmentsCMD());
|
||||
commands.add(new RankCMD());
|
||||
commands.add(new SpectatorCMD());
|
||||
commands.add(new SurvivalCMD());
|
||||
commands.add(new UnbanCMD());
|
||||
|
|
|
@ -28,22 +28,13 @@ public class ChatListener extends PlexListener
|
|||
{
|
||||
renderer.hasPrefix = true;
|
||||
renderer.prefix = plexPlayer.getPrefix();
|
||||
} else if (Plex.get().getRankManager().isAdmin(plexPlayer))
|
||||
}
|
||||
else if (Plex.get().getRankManager().isAdmin(plexPlayer))
|
||||
{
|
||||
renderer.hasPrefix = true;
|
||||
renderer.prefix = plexPlayer.getRankFromString().getPrefix();
|
||||
}
|
||||
event.renderer(renderer);
|
||||
/*if (!plexPlayer.getPrefix().isEmpty())
|
||||
{
|
||||
event.setFormat(String.format("%s %s §7» %s", plexPlayer.getPrefix(), ChatColor.RESET + plexPlayer.displayName(), event.getMessage()));
|
||||
} else if (Plex.get().getRankManager().isAdmin(plexPlayer))
|
||||
{
|
||||
event.setFormat(String.format("%s %s §7» %s", plexPlayer.getRankFromString().getPrefix(), ChatColor.RESET + plexPlayer.displayName(), event.getMessage()));
|
||||
} else
|
||||
{
|
||||
event.setFormat(String.format("%s §7» %s", ChatColor.RESET + plexPlayer.displayName(), event.getMessage()));
|
||||
}*/
|
||||
}
|
||||
|
||||
public static class PlexChatRenderer implements ChatRenderer
|
||||
|
|
|
@ -1,21 +1,25 @@
|
|||
package dev.plex.listener.impl;
|
||||
|
||||
import dev.plex.listener.PlexListener;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class LoginListener extends PlexListener
|
||||
{
|
||||
//TODO: Customizable MSGS
|
||||
private final String banMessage = plugin.config.getString("banning.message");
|
||||
|
||||
@EventHandler
|
||||
public void onPreLogin(AsyncPlayerPreLoginEvent event)
|
||||
{
|
||||
// PlexLog.log(String.valueOf(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://forum.telesphoreo.me");
|
||||
event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED,
|
||||
LegacyComponentSerializer.legacyAmpersand().deserialize(banMessage));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,31 +7,42 @@ import dev.plex.services.impl.GameRuleService;
|
|||
import java.util.List;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class ServiceManager {
|
||||
public class ServiceManager
|
||||
{
|
||||
private final List<AbstractService> services = Lists.newArrayList();
|
||||
|
||||
public ServiceManager() {
|
||||
registerService(new BanService());
|
||||
public ServiceManager()
|
||||
{
|
||||
//registerService(new BanService());
|
||||
registerService(new GameRuleService());
|
||||
}
|
||||
|
||||
public void startServices() {
|
||||
for (AbstractService service : services) {
|
||||
if (!service.isRepeating()) {
|
||||
public void startServices()
|
||||
{
|
||||
for (AbstractService service : services)
|
||||
{
|
||||
if (!service.isRepeating())
|
||||
{
|
||||
Bukkit.getScheduler().runTask(Plex.get(), service::run);
|
||||
} else if (service.isRepeating() && service.isAsynchronous()) {
|
||||
}
|
||||
else if (service.isRepeating() && service.isAsynchronous())
|
||||
{
|
||||
Bukkit.getScheduler().runTaskTimerAsynchronously(Plex.get(), service::run, 0, 20 * service.repeatInSeconds());
|
||||
} else if (service.isRepeating() && !service.isAsynchronous()) {
|
||||
}
|
||||
else if (service.isRepeating() && !service.isAsynchronous())
|
||||
{
|
||||
Bukkit.getScheduler().runTaskTimer(Plex.get(), service::run, 0, 20 * service.repeatInSeconds());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void registerService(AbstractService service) {
|
||||
private void registerService(AbstractService service)
|
||||
{
|
||||
services.add(service);
|
||||
}
|
||||
|
||||
public int serviceCount() {
|
||||
public int serviceCount()
|
||||
{
|
||||
return services.size();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -251,7 +251,7 @@ public class PlexUtils extends PlexBase
|
|||
|
||||
public static long hoursToSeconds(long hours)
|
||||
{
|
||||
return hours * 60 * 60;
|
||||
return hours * 3600;
|
||||
}
|
||||
|
||||
public static long minutesToSeconds(long minutes)
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
# Plex Configuration File
|
||||
|
||||
server:
|
||||
name: "ExampleFreedom"
|
||||
name: "Plexus"
|
||||
motd: "%servername% - Minecraft %mcversion%"
|
||||
colorize_motd: true
|
||||
|
||||
# Ban message is customized here. Additional messages can be configured in messages.yml
|
||||
banning:
|
||||
message: "&cYou are banned! Please appeal on the forums at https://forum.plex.us.org/"
|
||||
|
||||
|
||||
# Settings for commands relating to Plex
|
||||
commands:
|
||||
# Should Plex use a "true op" system with ranks or only permission nodes
|
||||
|
|
|
@ -42,7 +42,7 @@ frozePlayer: "<b><v> - Froze <v>"
|
|||
unfrozePlayer: "<b><v> - Unfroze <v>"
|
||||
noPermission: "<e>You cannot use this command!"
|
||||
# 1: the login message (uncolored) of the rank required to use the command
|
||||
noPermissionRank: "<e>You must be at least <v> rank to use this command!"
|
||||
noPermissionRank: "<e>You must be at least <v> to use this command!"
|
||||
noPermissionNode: "<e>You must have the permission: <v> to use this command!"
|
||||
noPermissionInGame: "<e>You must be in console to use this command!"
|
||||
noPermissionConsole: "<e>You must be in-game to use this command!"
|
||||
|
|
Loading…
Reference in a new issue