mirror of
https://github.com/plexusorg/Plex.git
synced 2024-12-23 01:27:37 +00:00
I can't believe we didn't have an unban command
This commit is contained in:
parent
0a1df0fddb
commit
a95ea3557e
@ -13,5 +13,5 @@ public @interface CommandPermissions
|
|||||||
|
|
||||||
RequiredCommandSource source() default RequiredCommandSource.ANY;
|
RequiredCommandSource source() default RequiredCommandSource.ANY;
|
||||||
|
|
||||||
String permission() default "plex.donotgivethispermission"; // No idea what to put here
|
String permission() default ""; // No idea what to put here
|
||||||
}
|
}
|
@ -25,11 +25,10 @@ import org.bukkit.entity.Player;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@CommandParameters(name = "ban", usage = "/<command> <player> [reason]", aliases = "offlineban,gtfo", description = "Bans a player, offline or online")
|
@CommandParameters(name = "ban", usage = "/<command> <player> [reason]", aliases = "offlineban,gtfo", description = "Bans a player, offline or online")
|
||||||
@CommandPermissions(level = Rank.ADMIN, source = RequiredCommandSource.ANY)
|
@CommandPermissions(level = Rank.ADMIN, permission = "plex.ban", source = RequiredCommandSource.ANY)
|
||||||
|
|
||||||
public class BanCMD extends PlexCommand
|
public class BanCMD extends PlexCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Component execute(CommandSender sender, String[] args)
|
public Component execute(CommandSender sender, String[] args)
|
||||||
{
|
{
|
||||||
@ -69,7 +68,7 @@ public class BanCMD extends PlexCommand
|
|||||||
punishment.setEndDate(new Date(Instant.now().plusSeconds(10/*PlexUtils.secondsToHours(24)*/).getEpochSecond()));
|
punishment.setEndDate(new Date(Instant.now().plusSeconds(10/*PlexUtils.secondsToHours(24)*/).getEpochSecond()));
|
||||||
punishment.setCustomTime(false);
|
punishment.setCustomTime(false);
|
||||||
plugin.getPunishmentManager().doPunishment(punishedPlayer, punishment);
|
plugin.getPunishmentManager().doPunishment(punishedPlayer, punishment);
|
||||||
Bukkit.broadcast(componentFromString(sender.getName() + " - Banning " + plexPlayer.getName()));
|
PlexUtils.broadcast(tl("unbanningPlayer", sender.getName(), plexPlayer.getName()));
|
||||||
if (Bukkit.getPlayer(targetUUID) != null)
|
if (Bukkit.getPlayer(targetUUID) != null)
|
||||||
{
|
{
|
||||||
Bukkit.getPlayer(targetUUID).kick(componentFromString("&cYou've been banned."));
|
Bukkit.getPlayer(targetUUID).kick(componentFromString("&cYou've been banned."));
|
||||||
|
38
src/main/java/dev/plex/command/impl/DeopCMD.java
Normal file
38
src/main/java/dev/plex/command/impl/DeopCMD.java
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
package dev.plex.command.impl;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import dev.plex.command.PlexCommand;
|
||||||
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
|
import dev.plex.command.exception.CommandArgumentException;
|
||||||
|
import dev.plex.rank.enums.Rank;
|
||||||
|
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;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
@CommandParameters(name = "deop", description = "Deop a player on the server", usage = "/<command> <player>")
|
||||||
|
@CommandPermissions(level = Rank.ADMIN, permission = "plex.deop")
|
||||||
|
public class DeopCMD extends PlexCommand
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public Component execute(CommandSender sender, String[] args)
|
||||||
|
{
|
||||||
|
if (args.length != 1)
|
||||||
|
{
|
||||||
|
throw new CommandArgumentException();
|
||||||
|
}
|
||||||
|
Player player = getNonNullPlayer(args[0]);
|
||||||
|
player.setOp(false);
|
||||||
|
PlexUtils.broadcast(tl("oppedPlayer", sender.getName(), player.getName()));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||||
|
{
|
||||||
|
return args.length == 1 ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||||
|
}
|
||||||
|
}
|
@ -11,7 +11,7 @@ import org.bukkit.Location;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.ADMIN, source = RequiredCommandSource.IN_GAME)
|
@CommandPermissions(level = Rank.OP, permission = "plex.flatlands", source = RequiredCommandSource.IN_GAME)
|
||||||
@CommandParameters(name = "flatlands", description = "Teleport to the flatlands")
|
@CommandParameters(name = "flatlands", description = "Teleport to the flatlands")
|
||||||
public class FlatlandsCMD extends PlexCommand
|
public class FlatlandsCMD extends PlexCommand
|
||||||
{
|
{
|
||||||
|
@ -21,10 +21,9 @@ import org.bukkit.entity.Player;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@CommandParameters(name = "freeze", description = "Freeze a player on the server", usage = "/<command> <player>")
|
@CommandParameters(name = "freeze", description = "Freeze a player on the server", usage = "/<command> <player>")
|
||||||
@CommandPermissions(level = Rank.ADMIN)
|
@CommandPermissions(level = Rank.ADMIN, permission = "plex.freeze")
|
||||||
public class FreezeCMD extends PlexCommand
|
public class FreezeCMD extends PlexCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Component execute(CommandSender sender, String[] args)
|
public Component execute(CommandSender sender, String[] args)
|
||||||
{
|
{
|
||||||
|
@ -13,7 +13,7 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandParameters(name = "list", description = "Show a list of all online players", usage = "/<command> <player>")
|
@CommandParameters(name = "list", description = "Show a list of all online players", usage = "/<command> <player>")
|
||||||
@CommandPermissions(level = Rank.OP)
|
@CommandPermissions(level = Rank.OP, permission = "plex.list")
|
||||||
public class ListCMD extends PlexCommand
|
public class ListCMD extends PlexCommand
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
@ -11,7 +11,7 @@ import org.bukkit.Location;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.ADMIN, source = RequiredCommandSource.IN_GAME)
|
@CommandPermissions(level = Rank.OP, permission = "plex.masterbuilderworld", source = RequiredCommandSource.IN_GAME)
|
||||||
@CommandParameters(name = "masterbuilderworld", aliases = "mbw", description = "Teleport to the Master Builder world")
|
@CommandParameters(name = "masterbuilderworld", aliases = "mbw", description = "Teleport to the Master Builder world")
|
||||||
public class MasterbuilderworldCMD extends PlexCommand
|
public class MasterbuilderworldCMD extends PlexCommand
|
||||||
{
|
{
|
||||||
|
@ -24,7 +24,7 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@CommandParameters(name = "namehistory", description = "Get the name history of a player", usage = "/<command> <player>", aliases = "nh")
|
@CommandParameters(name = "namehistory", description = "Get the name history of a player", usage = "/<command> <player>", aliases = "nh")
|
||||||
@CommandPermissions(level = Rank.OP)
|
@CommandPermissions(level = Rank.OP, permission = "plex.namehistory")
|
||||||
public class NameHistoryCMD extends PlexCommand
|
public class NameHistoryCMD extends PlexCommand
|
||||||
{
|
{
|
||||||
private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter.ofPattern("MM/dd/yyyy 'at' HH:mm:ss");
|
private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter.ofPattern("MM/dd/yyyy 'at' HH:mm:ss");
|
||||||
|
@ -17,7 +17,6 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
@CommandPermissions(level = Rank.OP)
|
@CommandPermissions(level = Rank.OP)
|
||||||
public class OpCMD extends PlexCommand
|
public class OpCMD extends PlexCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Component execute(CommandSender sender, String[] args)
|
public Component execute(CommandSender sender, String[] args)
|
||||||
{
|
{
|
||||||
|
@ -15,7 +15,7 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.OP, source = RequiredCommandSource.ANY)
|
@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")
|
@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 {
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@CommandParameters(name = "punishments", usage = "/<command> [player]", description = "Opens the Punishments GUI", aliases = "punishlist,punishes")
|
@CommandParameters(name = "punishments", usage = "/<command> [player]", description = "Opens the Punishments GUI", aliases = "punishlist,punishes")
|
||||||
@CommandPermissions(level = Rank.ADMIN, source = RequiredCommandSource.IN_GAME)
|
@CommandPermissions(level = Rank.ADMIN, permission = "plex.punishments", source = RequiredCommandSource.IN_GAME)
|
||||||
public class PunishmentsCMD extends PlexCommand
|
public class PunishmentsCMD extends PlexCommand
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
@ -11,7 +11,7 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
// TODO: See ranks of other players
|
// TODO: See ranks of other players
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.OP, source = RequiredCommandSource.IN_GAME)
|
@CommandPermissions(level = Rank.OP, permission = "plex.rank", source = RequiredCommandSource.IN_GAME)
|
||||||
@CommandParameters(name = "rank", description = "Displays your rank")
|
@CommandParameters(name = "rank", description = "Displays your rank")
|
||||||
public class RankCMD extends PlexCommand
|
public class RankCMD extends PlexCommand
|
||||||
{
|
{
|
||||||
|
61
src/main/java/dev/plex/command/impl/UnbanCMD.java
Normal file
61
src/main/java/dev/plex/command/impl/UnbanCMD.java
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
package dev.plex.command.impl;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import dev.plex.cache.DataUtils;
|
||||||
|
import dev.plex.cache.PlayerCache;
|
||||||
|
import dev.plex.command.PlexCommand;
|
||||||
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
|
import dev.plex.command.exception.PlayerNotFoundException;
|
||||||
|
import dev.plex.command.source.RequiredCommandSource;
|
||||||
|
import dev.plex.player.PlexPlayer;
|
||||||
|
import dev.plex.player.PunishedPlayer;
|
||||||
|
import dev.plex.punishment.Punishment;
|
||||||
|
import dev.plex.punishment.PunishmentType;
|
||||||
|
import dev.plex.rank.enums.Rank;
|
||||||
|
import dev.plex.util.PlexUtils;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
@CommandParameters(name = "unban", usage = "/<command> <player>", description = "Unbans a player, offline or online")
|
||||||
|
@CommandPermissions(level = Rank.ADMIN, permission = "plex.ban", source = RequiredCommandSource.ANY)
|
||||||
|
|
||||||
|
public class UnbanCMD extends PlexCommand
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public Component execute(CommandSender sender, String[] args)
|
||||||
|
{
|
||||||
|
if (args.length == 0)
|
||||||
|
{
|
||||||
|
return usage(getUsage());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length == 1)
|
||||||
|
{
|
||||||
|
UUID targetUUID = PlexUtils.getFromName(args[0]);
|
||||||
|
PlexPlayer plexPlayer = DataUtils.getPlayer(targetUUID);
|
||||||
|
|
||||||
|
if (targetUUID == null || !DataUtils.hasPlayedBefore(targetUUID))
|
||||||
|
{
|
||||||
|
throw new PlayerNotFoundException();
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin.getBanManager().unban(targetUUID);
|
||||||
|
PlexUtils.broadcast(tl("unbanningPlayer", sender.getName(), plexPlayer.getName()));
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||||
|
{
|
||||||
|
return args.length == 1 && isAdmin(sender) ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||||
|
}
|
||||||
|
}
|
@ -17,7 +17,7 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.OP, source = RequiredCommandSource.IN_GAME)
|
@CommandPermissions(level = Rank.OP, permission = "plex.world", source = RequiredCommandSource.IN_GAME)
|
||||||
@CommandParameters(name = "world", description = "Teleport to a world.", usage = "/<command> <world>")
|
@CommandParameters(name = "world", description = "Teleport to a world.", usage = "/<command> <world>")
|
||||||
public class WorldCMD extends PlexCommand
|
public class WorldCMD extends PlexCommand
|
||||||
{
|
{
|
||||||
|
@ -1,47 +1,34 @@
|
|||||||
package dev.plex.handlers;
|
package dev.plex.handlers;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
import dev.plex.PlexBase;
|
||||||
import dev.plex.command.PlexCommand;
|
import dev.plex.command.PlexCommand;
|
||||||
import dev.plex.command.impl.AdminCMD;
|
import dev.plex.command.impl.*;
|
||||||
import dev.plex.command.impl.AdminworldCMD;
|
|
||||||
import dev.plex.command.impl.AdventureCMD;
|
|
||||||
import dev.plex.command.impl.BanCMD;
|
|
||||||
import dev.plex.command.impl.CreativeCMD;
|
|
||||||
import dev.plex.command.impl.DeopAllCMD;
|
|
||||||
import dev.plex.command.impl.FlatlandsCMD;
|
|
||||||
import dev.plex.command.impl.FreezeCMD;
|
|
||||||
import dev.plex.command.impl.ListCMD;
|
|
||||||
import dev.plex.command.impl.MasterbuilderworldCMD;
|
|
||||||
import dev.plex.command.impl.NameHistoryCMD;
|
|
||||||
import dev.plex.command.impl.OpAllCMD;
|
|
||||||
import dev.plex.command.impl.OpCMD;
|
|
||||||
import dev.plex.command.impl.PlexCMD;
|
|
||||||
import dev.plex.command.impl.PunishmentsCMD;
|
|
||||||
import dev.plex.command.impl.RankCMD;
|
|
||||||
import dev.plex.command.impl.SpectatorCMD;
|
|
||||||
import dev.plex.command.impl.SurvivalCMD;
|
|
||||||
import dev.plex.command.impl.WorldCMD;
|
|
||||||
import dev.plex.util.PlexLog;
|
import dev.plex.util.PlexLog;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class CommandHandler
|
public class CommandHandler extends PlexBase
|
||||||
{
|
{
|
||||||
public CommandHandler()
|
public CommandHandler()
|
||||||
{
|
{
|
||||||
List<PlexCommand> commands = Lists.newArrayList();
|
List<PlexCommand> commands = Lists.newArrayList();
|
||||||
commands.add(new AdminCMD());
|
if (plugin.getRanksOrPermissions().equalsIgnoreCase("ranks"))
|
||||||
|
{
|
||||||
|
commands.add(new AdminCMD());
|
||||||
|
commands.add(new DeopAllCMD());
|
||||||
|
commands.add(new DeopCMD());
|
||||||
|
commands.add(new OpAllCMD());
|
||||||
|
commands.add(new OpCMD());
|
||||||
|
}
|
||||||
commands.add(new AdminworldCMD());
|
commands.add(new AdminworldCMD());
|
||||||
commands.add(new AdventureCMD());
|
commands.add(new AdventureCMD());
|
||||||
commands.add(new BanCMD());
|
commands.add(new BanCMD());
|
||||||
commands.add(new CreativeCMD());
|
commands.add(new CreativeCMD());
|
||||||
commands.add(new DeopAllCMD());
|
|
||||||
commands.add(new FlatlandsCMD());
|
commands.add(new FlatlandsCMD());
|
||||||
commands.add(new FreezeCMD());
|
commands.add(new FreezeCMD());
|
||||||
commands.add(new ListCMD());
|
commands.add(new ListCMD());
|
||||||
commands.add(new MasterbuilderworldCMD());
|
commands.add(new MasterbuilderworldCMD());
|
||||||
commands.add(new NameHistoryCMD());
|
commands.add(new NameHistoryCMD());
|
||||||
commands.add(new OpAllCMD());
|
|
||||||
commands.add(new OpCMD());
|
|
||||||
commands.add(new PlexCMD());
|
commands.add(new PlexCMD());
|
||||||
commands.add(new PunishmentsCMD());
|
commands.add(new PunishmentsCMD());
|
||||||
commands.add(new RankCMD());
|
commands.add(new RankCMD());
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package dev.plex.services.impl;
|
package dev.plex.services.impl;
|
||||||
|
|
||||||
import dev.plex.Plex;
|
import dev.plex.Plex;
|
||||||
|
import dev.plex.PlexBase;
|
||||||
import dev.plex.banning.Ban;
|
import dev.plex.banning.Ban;
|
||||||
import dev.plex.services.AbstractService;
|
import dev.plex.services.AbstractService;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@ -58,13 +58,15 @@ setOtherPlayerGameModeTo: "You set <v>'s gamemode to <v>."
|
|||||||
playerSetOtherGameMode: "<v> set your gamemode to <v>."
|
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: "<e><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>."
|
teleportedToWorld: "<b>You have been teleported to the <v>."
|
||||||
higherRankThanYou: "<b>This player is an admin and a higher rank than you."
|
higherRankThanYou: "<e>This player is an admin and a higher rank than you."
|
||||||
playerNotAdmin: "<b>That player is not an admin."
|
playerNotAdmin: "<e>That player is not an admin."
|
||||||
playerIsAdmin: "<b>That player is already an admin."
|
playerIsAdmin: "<e>That player is already an admin."
|
||||||
rankNotFound: "<b>The rank you entered was not found."
|
rankNotFound: "<e>The rank you entered was not found."
|
||||||
rankMustBeHigherThanAdmin: "<b>The rank you entered must be higher than Admin."
|
rankMustBeHigherThanAdmin: "<e>The rank you entered must be higher than Admin."
|
||||||
consoleOnly: "<b>This command can only be executed by the console."
|
consoleOnly: "<e>This command can only be executed by the console."
|
||||||
yourRank: "<b>Your rank is: <v>"
|
yourRank: "<b>Your rank is: <v>"
|
||||||
|
banningPlayer: "<e><v> - Banning <v>"
|
||||||
|
unbanningPlayer: "<b><v> - Unbanning <v>"
|
Loading…
Reference in New Issue
Block a user