mirror of
https://github.com/plexusorg/Plex.git
synced 2025-07-01 23:56:40 +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:
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user