mirror of
https://github.com/plexusorg/Plex.git
synced 2025-07-01 07:36:42 +00:00
tttt
This commit is contained in:
199
src/main/java/dev/plex/command/impl/AdminCMD.java
Normal file
199
src/main/java/dev/plex/command/impl/AdminCMD.java
Normal file
@ -0,0 +1,199 @@
|
||||
package dev.plex.command.impl;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.exception.PlayerNotFoundException;
|
||||
import dev.plex.command.source.CommandSource;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import dev.plex.cache.DataUtils;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.event.AdminAddEvent;
|
||||
import dev.plex.event.AdminRemoveEvent;
|
||||
import dev.plex.event.AdminSetRankEvent;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = RequiredCommandSource.ANY)
|
||||
@CommandParameters(usage = "/<command> <add | remove | setrank | list> [player] [rank]", aliases = "saconfig,slconfig,adminconfig,adminmanage", description = "Manage all admins")
|
||||
public class AdminCMD extends PlexCommand
|
||||
{
|
||||
//TODO: Better return messages
|
||||
|
||||
public AdminCMD()
|
||||
{
|
||||
super("admin");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSource sender, String[] args)
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
sender.send(usage(getUsage()));
|
||||
return;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("add"))
|
||||
{
|
||||
if (args.length != 2)
|
||||
{
|
||||
sender.send(usage("/admin add <player>"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!sender.isConsoleSender())
|
||||
{
|
||||
sender.send("Console only");
|
||||
return;
|
||||
}
|
||||
|
||||
UUID targetUUID = PlexUtils.getFromName(args[1]);
|
||||
|
||||
if (targetUUID == null || !DataUtils.hasPlayedBefore(targetUUID))
|
||||
{
|
||||
throw new PlayerNotFoundException();
|
||||
}
|
||||
PlexPlayer plexPlayer = DataUtils.getPlayer(targetUUID);
|
||||
|
||||
if (isAdmin(plexPlayer))
|
||||
{
|
||||
sender.send("Player is an admin");
|
||||
return;
|
||||
}
|
||||
|
||||
plexPlayer.setRank(Rank.ADMIN.name());
|
||||
DataUtils.update(plexPlayer);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new AdminAddEvent(sender, plexPlayer));
|
||||
return;
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("remove"))
|
||||
{
|
||||
if (args.length != 2)
|
||||
{
|
||||
sender.send(usage("/admin remove <player>"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!sender.isConsoleSender())
|
||||
{
|
||||
sender.send("Console only");
|
||||
return;
|
||||
}
|
||||
|
||||
UUID targetUUID = PlexUtils.getFromName(args[1]);
|
||||
|
||||
if (targetUUID == null || !DataUtils.hasPlayedBefore(targetUUID))
|
||||
{
|
||||
throw new PlayerNotFoundException();
|
||||
}
|
||||
PlexPlayer plexPlayer = DataUtils.getPlayer(targetUUID);
|
||||
|
||||
if (!isAdmin(plexPlayer))
|
||||
{
|
||||
sender.send("Player is not an admin");
|
||||
return;
|
||||
}
|
||||
|
||||
plexPlayer.setRank("");
|
||||
DataUtils.update(plexPlayer);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new AdminRemoveEvent(sender, plexPlayer));
|
||||
return;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("setrank"))
|
||||
{
|
||||
if (args.length != 3)
|
||||
{
|
||||
sender.send(usage("/admin setrank <player> <rank>"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!sender.isConsoleSender())
|
||||
{
|
||||
sender.send("Console only");
|
||||
return;
|
||||
}
|
||||
|
||||
UUID targetUUID = PlexUtils.getFromName(args[1]);
|
||||
|
||||
if (targetUUID == null || !DataUtils.hasPlayedBefore(targetUUID))
|
||||
{
|
||||
throw new PlayerNotFoundException();
|
||||
}
|
||||
|
||||
if (!rankExists(args[2]))
|
||||
{
|
||||
sender.send("Rank not found");
|
||||
return;
|
||||
}
|
||||
|
||||
Rank rank = Rank.valueOf(args[2].toUpperCase());
|
||||
|
||||
if (!rank.isAtLeast(Rank.ADMIN))
|
||||
{
|
||||
sender.send("Must be admin+");
|
||||
return;
|
||||
}
|
||||
|
||||
PlexPlayer plexPlayer = DataUtils.getPlayer(targetUUID);
|
||||
|
||||
if (!isAdmin(plexPlayer))
|
||||
{
|
||||
sender.send("Player is not an admin");
|
||||
return;
|
||||
}
|
||||
|
||||
plexPlayer.setRank(rank.name().toLowerCase());
|
||||
DataUtils.update(plexPlayer);
|
||||
|
||||
Bukkit.getServer().getPluginManager().callEvent(new AdminSetRankEvent(sender, plexPlayer, rank));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("list"))
|
||||
{
|
||||
if (args.length != 1)
|
||||
{
|
||||
sender.send(usage("/admin list"));
|
||||
return;
|
||||
}
|
||||
|
||||
sender.send("Admins: " + StringUtils.join(plugin.getAdminList().getAllAdmins(), ", "));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSource sender, String[] args)
|
||||
{
|
||||
if (args.length == 1)
|
||||
{
|
||||
return Arrays.asList("add", "remove", "setrank", "list");
|
||||
}
|
||||
else if (args.length == 2 && !args[0].equalsIgnoreCase("list"))
|
||||
{
|
||||
return PlexUtils.getPlayerNameList();
|
||||
}
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
private boolean rankExists(String rank)
|
||||
{
|
||||
for (Rank ranks : Rank.values())
|
||||
{
|
||||
if (ranks.name().equalsIgnoreCase(rank))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
72
src/main/java/dev/plex/command/impl/AdventureCMD.java
Normal file
72
src/main/java/dev/plex/command/impl/AdventureCMD.java
Normal file
@ -0,0 +1,72 @@
|
||||
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 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.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = RequiredCommandSource.ANY)
|
||||
@CommandParameters(aliases = "gma", description = "Set your own or another player's gamemode to adventure mode")
|
||||
public class AdventureCMD extends PlexCommand
|
||||
{
|
||||
public AdventureCMD()
|
||||
{
|
||||
super("adventure");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSource sender, String[] args)
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
// doesn't work
|
||||
if (sender.isConsoleSender())
|
||||
{
|
||||
throw new CommandFailException("You must define a player when using the console!");
|
||||
}
|
||||
|
||||
sender.getPlayer().setGameMode(GameMode.ADVENTURE);
|
||||
send(tl("gameModeSetTo", "adventure"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (isAdmin(sender.getPlexPlayer()))
|
||||
{
|
||||
if (args[0].equals("-a"))
|
||||
{
|
||||
for (Player targetPlayer : Bukkit.getServer().getOnlinePlayers())
|
||||
{
|
||||
targetPlayer.setGameMode(GameMode.ADVENTURE);
|
||||
}
|
||||
send(tl("gameModeSetTo", "adventure"));
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = getNonNullPlayer(args[0]);
|
||||
send(tl("setOtherPlayerGameModeTo", player.getName(), "adventure"));
|
||||
// use send
|
||||
player.sendMessage(tl("playerSetOtherGameMode", sender.getName(), "adventure"));
|
||||
player.setGameMode(GameMode.ADVENTURE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSource sender, String[] args)
|
||||
{
|
||||
if (isAdmin(sender.getPlexPlayer()))
|
||||
{
|
||||
return PlexUtils.getPlayerNameList();
|
||||
}
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
86
src/main/java/dev/plex/command/impl/BanCMD.java
Normal file
86
src/main/java/dev/plex/command/impl/BanCMD.java
Normal file
@ -0,0 +1,86 @@
|
||||
package dev.plex.command.impl;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.exception.PlayerNotFoundException;
|
||||
import dev.plex.command.source.CommandSource;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.punishment.Punishment;
|
||||
import dev.plex.punishment.PunishmentType;
|
||||
import dev.plex.cache.DataUtils;
|
||||
import dev.plex.cache.PlayerCache;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.player.PunishedPlayer;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandParameters(usage = "/<command> <player> [reason]", aliases = "offlineban,gtfo", description = "Bans a player, offline or online")
|
||||
@CommandPermissions(level = Rank.ADMIN, source = RequiredCommandSource.ANY)
|
||||
|
||||
public class BanCMD extends PlexCommand
|
||||
{
|
||||
public BanCMD() {
|
||||
super("ban");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSource sender, String[] args)
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
sender.send(usage(getUsage()));
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.length == 1)
|
||||
{
|
||||
UUID targetUUID = PlexUtils.getFromName(args[0]);
|
||||
|
||||
if (targetUUID == null || !DataUtils.hasPlayedBefore(targetUUID))
|
||||
{
|
||||
throw new PlayerNotFoundException();
|
||||
}
|
||||
PlexPlayer plexPlayer = DataUtils.getPlayer(targetUUID);
|
||||
|
||||
if (isAdmin(plexPlayer))
|
||||
{
|
||||
if (!sender.isConsoleSender())
|
||||
{
|
||||
PlexPlayer plexPlayer1 = sender.getPlexPlayer();
|
||||
if (!plexPlayer1.getRankFromString().isAtLeast(plexPlayer.getRankFromString()))
|
||||
{
|
||||
sender.send("This player is an admin and a higher rank than you.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PunishedPlayer punishedPlayer = PlayerCache.getPunishedPlayer(targetUUID) == null ? new PunishedPlayer(targetUUID) : PlayerCache.getPunishedPlayer(targetUUID);
|
||||
Punishment punishment = new Punishment(targetUUID, !sender.isConsoleSender() ? sender.getPlayer().getUniqueId() : null);
|
||||
punishment.setType(PunishmentType.BAN);
|
||||
punishment.setReason("");
|
||||
punishment.setPunishedUsername(plexPlayer.getName());
|
||||
punishment.setEndDate(new Date(Instant.now().plusSeconds(10/*PlexUtils.secondsToHours(24)*/).getEpochSecond()));
|
||||
punishment.setCustomTime(false);
|
||||
plugin.getPunishmentManager().doPunishment(punishedPlayer, punishment);
|
||||
Bukkit.broadcastMessage(sender.getName() + " - Banning " + plexPlayer.getName());
|
||||
if (Bukkit.getPlayer(targetUUID) != null)
|
||||
{
|
||||
Bukkit.getPlayer(targetUUID).kickPlayer("§cYou've been banned.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSource sender, String[] args) {
|
||||
return args.length == 1 ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
}
|
||||
}
|
71
src/main/java/dev/plex/command/impl/CreativeCMD.java
Normal file
71
src/main/java/dev/plex/command/impl/CreativeCMD.java
Normal file
@ -0,0 +1,71 @@
|
||||
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 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.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = RequiredCommandSource.ANY)
|
||||
@CommandParameters(aliases = "gmc", description = "Set your own or another player's gamemode to creative mode")
|
||||
public class CreativeCMD extends PlexCommand
|
||||
{
|
||||
public CreativeCMD()
|
||||
{
|
||||
super("creative");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSource sender, String[] args)
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
// doesn't work
|
||||
if (sender.isConsoleSender())
|
||||
{
|
||||
throw new CommandFailException("You must define a player when using the console!");
|
||||
}
|
||||
|
||||
sender.getPlayer().setGameMode(GameMode.CREATIVE);
|
||||
send(tl("gameModeSetTo", "creative"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (isAdmin(sender.getPlexPlayer()))
|
||||
{
|
||||
if (args[0].equals("-a"))
|
||||
{
|
||||
for (Player targetPlayer : Bukkit.getServer().getOnlinePlayers())
|
||||
{
|
||||
targetPlayer.setGameMode(GameMode.CREATIVE);
|
||||
}
|
||||
send(tl("gameModeSetTo", "creative"));
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = getNonNullPlayer(args[0]);
|
||||
send(tl("setOtherPlayerGameModeTo", player.getName(), "creative"));
|
||||
player.sendMessage(tl("playerSetOtherGameMode", sender.getName(), "creative"));
|
||||
player.setGameMode(GameMode.CREATIVE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSource sender, String[] args)
|
||||
{
|
||||
if (isAdmin(sender.getPlexPlayer()))
|
||||
{
|
||||
return PlexUtils.getPlayerNameList();
|
||||
}
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
150
src/main/java/dev/plex/command/impl/FionnCMD.java
Normal file
150
src/main/java/dev/plex/command/impl/FionnCMD.java
Normal file
@ -0,0 +1,150 @@
|
||||
package dev.plex.command.impl;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.exception.CommandArgumentException;
|
||||
import dev.plex.command.exception.CommandFailException;
|
||||
import dev.plex.command.source.CommandSource;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import dev.plex.cache.PlayerCache;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.world.BlockMapChunkGenerator;
|
||||
import dev.plex.world.CustomWorld;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Enderman;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Strider;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
@CommandParameters(description = "Subliminal message.")
|
||||
@CommandPermissions(source = RequiredCommandSource.IN_GAME)
|
||||
public class FionnCMD extends PlexCommand
|
||||
{
|
||||
public static boolean ENABLED = false;
|
||||
public static Map<Player, Location> LOCATION_CACHE = new HashMap<>();
|
||||
|
||||
public FionnCMD()
|
||||
{
|
||||
super("fionn");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSource sender, String[] args)
|
||||
{
|
||||
if (!sender.getPlayer().getUniqueId().equals(UUID.fromString("9aa3eda6-c271-440a-a578-a952ee9aee2f")))
|
||||
{
|
||||
throw new CommandFailException(tl("noPermission"));
|
||||
}
|
||||
if (args.length != 0)
|
||||
{
|
||||
throw new CommandArgumentException();
|
||||
}
|
||||
String name = "fionn";
|
||||
LinkedHashMap<Material, Integer> map = new LinkedHashMap<>();
|
||||
map.put(Material.CRIMSON_NYLIUM, 1);
|
||||
map.put(Material.BEDROCK, 1);
|
||||
World fionnWorld = new CustomWorld(name, new BlockMapChunkGenerator(map)).generate();
|
||||
ENABLED = true;
|
||||
fionnWorld.setTime(0);
|
||||
fionnWorld.getBlockAt(0, 5, 0).setType(Material.BARRIER);
|
||||
Strider fionn = (Strider)fionnWorld.spawnEntity(new Location(fionnWorld, 12, 6, 6, -180, -3), EntityType.STRIDER);
|
||||
fionn.setCustomNameVisible(true);
|
||||
fionn.setCustomName(ChatColor.GREEN + "fionn");
|
||||
fionn.setAI(false);
|
||||
Enderman elmon = (Enderman)fionnWorld.spawnEntity(new Location(fionnWorld, 12, 6, 0, 0, 18), EntityType.ENDERMAN);
|
||||
elmon.setCustomNameVisible(true);
|
||||
elmon.setCustomName(ChatColor.RED + "elmon");
|
||||
elmon.setInvulnerable(true);
|
||||
elmon.setAware(false);
|
||||
elmon.setGravity(true);
|
||||
// platforms in cage
|
||||
PlexUtils.setBlocks(new Location(fionnWorld, 10, 5, -2), new Location(fionnWorld, 14, 5, 2), Material.SMOOTH_STONE);
|
||||
PlexUtils.setBlocks(new Location(fionnWorld, 10, 9, -2), new Location(fionnWorld, 14, 9, 2), Material.SMOOTH_STONE_SLAB);
|
||||
// iron bars of cage
|
||||
PlexUtils.setBlocks(new Location(fionnWorld, 10, 8, -2), new Location(fionnWorld, 10, 6, 2), Material.IRON_BARS);
|
||||
PlexUtils.setBlocks(new Location(fionnWorld, 14, 8, 2), new Location(fionnWorld, 10, 6, 2), Material.IRON_BARS);
|
||||
PlexUtils.setBlocks(new Location(fionnWorld, 14, 8, 2), new Location(fionnWorld, 14, 6, -2), Material.IRON_BARS);
|
||||
PlexUtils.setBlocks(new Location(fionnWorld, 10, 8, -2), new Location(fionnWorld, 14, 6, -2), Material.IRON_BARS);
|
||||
// lava
|
||||
PlexUtils.setBlocks(new Location(fionnWorld, 10, 1, -2), new Location(fionnWorld, 14, 0, 2), Material.LAVA);
|
||||
|
||||
// iron bars of platform
|
||||
PlexUtils.setBlocks(new Location(fionnWorld, 12, 2, 6), new Location(fionnWorld, 12, 5, 6), Material.IRON_BARS);
|
||||
// platform
|
||||
PlexUtils.setBlocks(new Location(fionnWorld, 11, 6, 7), new Location(fionnWorld, 13, 6, 5), Material.SMOOTH_STONE_SLAB);
|
||||
for (Player p : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
p.setInvisible(true);
|
||||
LOCATION_CACHE.put(p, p.getLocation());
|
||||
p.teleport(new Location(fionnWorld, 0, 5, 0, -90, 0));
|
||||
PlayerCache.getPunishedPlayer(p.getUniqueId()).setFrozen(true);
|
||||
}
|
||||
lateFakeChat("elmon", "fionn! i'm sorry for not being your sex slave...", ChatColor.RED, 20);
|
||||
lateFakeChat("fionn", "it's too late for that now...", ChatColor.GREEN, 60);
|
||||
new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
PlexUtils.setBlocks(new Location(fionnWorld, 13, 5, -1), new Location(fionnWorld, 11, 5, 1), Material.AIR);
|
||||
}
|
||||
}.runTaskLater(plugin, 100);
|
||||
new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
fionn.teleport(new Location(fionnWorld, 2.5, 5.5, 0, 90, -10));
|
||||
}
|
||||
}.runTaskLater(plugin, 160);
|
||||
new BukkitRunnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
fionn.remove();
|
||||
elmon.remove();
|
||||
for (Player p : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
p.setInvisible(false);
|
||||
Location location = LOCATION_CACHE.get(p);
|
||||
if (location != null)
|
||||
{
|
||||
p.teleport(location);
|
||||
}
|
||||
PlayerCache.getPunishedPlayer(p.getUniqueId()).setFrozen(false);
|
||||
}
|
||||
LOCATION_CACHE.clear();
|
||||
ENABLED = false;
|
||||
}
|
||||
}.runTaskLater(plugin, 200);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSource sender, String[] args)
|
||||
{
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
public static void lateFakeChat(String name, String message, ChatColor color, int delay)
|
||||
{
|
||||
new BukkitRunnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
Bukkit.broadcastMessage(color + name + ChatColor.GRAY + ": " + ChatColor.WHITE + message);
|
||||
}
|
||||
}.runTaskLater(plugin, delay);
|
||||
}
|
||||
}
|
57
src/main/java/dev/plex/command/impl/FreezeCMD.java
Normal file
57
src/main/java/dev/plex/command/impl/FreezeCMD.java
Normal file
@ -0,0 +1,57 @@
|
||||
package dev.plex.command.impl;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.exception.CommandArgumentException;
|
||||
import dev.plex.command.source.CommandSource;
|
||||
import dev.plex.punishment.Punishment;
|
||||
import dev.plex.punishment.PunishmentType;
|
||||
import java.time.Instant;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import dev.plex.cache.PlayerCache;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.player.PunishedPlayer;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandParameters(description = "Freeze a player on the server", usage = "/<command> <player>")
|
||||
@CommandPermissions(level = Rank.ADMIN)
|
||||
public class FreezeCMD extends PlexCommand
|
||||
{
|
||||
public FreezeCMD()
|
||||
{
|
||||
super("freeze");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSource sender, String[] args)
|
||||
{
|
||||
if (args.length != 1)
|
||||
{
|
||||
throw new CommandArgumentException();
|
||||
}
|
||||
Player player = getNonNullPlayer(args[0]);
|
||||
PunishedPlayer punishedPlayer = PlayerCache.getPunishedPlayer(player.getUniqueId());
|
||||
Punishment punishment = new Punishment(UUID.fromString(punishedPlayer.getUuid()), sender.isConsoleSender() ? null : sender.getPlayer().getUniqueId());
|
||||
punishment.setCustomTime(false);
|
||||
punishment.setEndDate(new Date(Instant.now().plusSeconds(10).toEpochMilli()));
|
||||
punishment.setType(PunishmentType.FREEZE);
|
||||
punishment.setPunishedUsername(player.getName());
|
||||
punishment.setReason("");
|
||||
|
||||
plugin.getPunishmentManager().doPunishment(punishedPlayer, punishment);
|
||||
PlexUtils.broadcast(tl("frozePlayer", sender.getName(), player.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSource sender, String[] args)
|
||||
{
|
||||
return args.length == 1 ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
}
|
||||
}
|
79
src/main/java/dev/plex/command/impl/NameHistoryCMD.java
Normal file
79
src/main/java/dev/plex/command/impl/NameHistoryCMD.java
Normal file
@ -0,0 +1,79 @@
|
||||
package dev.plex.command.impl;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.exception.CommandArgumentException;
|
||||
import dev.plex.command.source.CommandSource;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
@CommandParameters(description = "Get the name history of a player", usage = "/<command> <player>", aliases = "nh")
|
||||
@CommandPermissions(level = Rank.OP)
|
||||
public class NameHistoryCMD extends PlexCommand
|
||||
{
|
||||
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("MM/dd/yyyy 'at' HH:mm:ss");
|
||||
|
||||
public NameHistoryCMD()
|
||||
{
|
||||
super("namehistory");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSource sender, String[] args)
|
||||
{
|
||||
if (args.length != 1)
|
||||
{
|
||||
throw new CommandArgumentException();
|
||||
}
|
||||
String username = args[0];
|
||||
JSONArray array;
|
||||
try
|
||||
{
|
||||
JSONObject profile = (JSONObject)PlexUtils.simpleGET("https://api.mojang.com/users/profiles/minecraft/" + username);
|
||||
String uuid = (String)profile.get("id");
|
||||
array = (JSONArray)PlexUtils.simpleGET("https://api.mojang.com/user/profiles/" + uuid + "/names");
|
||||
}
|
||||
catch (ParseException | IOException ex)
|
||||
{
|
||||
send(tl("nameHistoryFail", username));
|
||||
return;
|
||||
}
|
||||
|
||||
array.sort(Comparator.reverseOrder());
|
||||
|
||||
StringBuilder result = new StringBuilder()
|
||||
.append(tl("nameHistoryTitle", username))
|
||||
.append("\n");
|
||||
for (Object o : array)
|
||||
{
|
||||
JSONObject object = (JSONObject)o;
|
||||
Object changedToAt = object.get("changedToAt");
|
||||
if (changedToAt == null)
|
||||
{
|
||||
changedToAt = "O";
|
||||
}
|
||||
else
|
||||
{
|
||||
changedToAt = DATE_FORMAT.format(changedToAt);
|
||||
}
|
||||
result.append(tl("nameHistoryBody", object.get("name"), changedToAt))
|
||||
.append("\n");
|
||||
}
|
||||
send(result.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSource sender, String[] args)
|
||||
{
|
||||
return args.length == 1 ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
}
|
||||
}
|
38
src/main/java/dev/plex/command/impl/OpAllCMD.java
Normal file
38
src/main/java/dev/plex/command/impl/OpAllCMD.java
Normal file
@ -0,0 +1,38 @@
|
||||
package dev.plex.command.impl;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.source.CommandSource;
|
||||
import java.util.List;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandParameters(description = "Op everyone on the server", aliases = "opa")
|
||||
@CommandPermissions(level = Rank.ADMIN)
|
||||
public class OpAllCMD extends PlexCommand
|
||||
{
|
||||
public OpAllCMD()
|
||||
{
|
||||
super("opall");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSource sender, String[] args)
|
||||
{
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
player.setOp(true);
|
||||
}
|
||||
PlexUtils.broadcast(tl("oppedAllPlayers", sender.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSource sender, String[] args)
|
||||
{
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
40
src/main/java/dev/plex/command/impl/OpCMD.java
Normal file
40
src/main/java/dev/plex/command/impl/OpCMD.java
Normal file
@ -0,0 +1,40 @@
|
||||
package dev.plex.command.impl;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.exception.CommandArgumentException;
|
||||
import dev.plex.command.source.CommandSource;
|
||||
import java.util.List;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandParameters(description = "Op a player on the server", usage = "/<command> <player>")
|
||||
@CommandPermissions(level = Rank.OP)
|
||||
public class OpCMD extends PlexCommand
|
||||
{
|
||||
public OpCMD()
|
||||
{
|
||||
super("op");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSource sender, String[] args)
|
||||
{
|
||||
if (args.length != 1)
|
||||
{
|
||||
throw new CommandArgumentException();
|
||||
}
|
||||
Player player = getNonNullPlayer(args[0]);
|
||||
player.setOp(true);
|
||||
PlexUtils.broadcast(tl("oppedPlayer", sender.getName(), player.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSource sender, String[] args)
|
||||
{
|
||||
return args.length == 1 ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
}
|
||||
}
|
32
src/main/java/dev/plex/command/impl/PlexCMD.java
Normal file
32
src/main/java/dev/plex/command/impl/PlexCMD.java
Normal file
@ -0,0 +1,32 @@
|
||||
package dev.plex.command.impl;
|
||||
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.source.CommandSource;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = RequiredCommandSource.ANY)
|
||||
@CommandParameters(aliases = "plexhelp", description = "Help with plex")
|
||||
public class PlexCMD extends PlexCommand
|
||||
{
|
||||
public PlexCMD()
|
||||
{
|
||||
super("plex");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSource sender, String[] args)
|
||||
{
|
||||
send("HI");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSource sender, String[] args)
|
||||
{
|
||||
return Arrays.asList("Telesphoreo", "super", "Taahh");
|
||||
}
|
||||
}
|
36
src/main/java/dev/plex/command/impl/PunishmentsCMD.java
Normal file
36
src/main/java/dev/plex/command/impl/PunishmentsCMD.java
Normal file
@ -0,0 +1,36 @@
|
||||
package dev.plex.command.impl;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.source.CommandSource;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.menu.PunishmentMenu;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@CommandParameters(usage = "/<command> [player]", description = "Opens the Punishments GUI", aliases = "punishlist,punishes")
|
||||
@CommandPermissions(level = Rank.ADMIN, source = RequiredCommandSource.IN_GAME)
|
||||
public class PunishmentsCMD extends PlexCommand
|
||||
{
|
||||
|
||||
public PunishmentsCMD() {
|
||||
super("punishments");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSource sender, String[] args)
|
||||
{
|
||||
Player player = sender.getPlayer();
|
||||
new PunishmentMenu().openInv(player, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSource sender, String[] args) {
|
||||
return args.length == 1 ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
}
|
||||
}
|
68
src/main/java/dev/plex/command/impl/SpectatorCMD.java
Normal file
68
src/main/java/dev/plex/command/impl/SpectatorCMD.java
Normal file
@ -0,0 +1,68 @@
|
||||
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 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.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = RequiredCommandSource.ANY)
|
||||
@CommandParameters(aliases = "gmsp", description = "Set your own or another player's gamemode to spectator mode")
|
||||
public class SpectatorCMD extends PlexCommand
|
||||
{
|
||||
public SpectatorCMD()
|
||||
{
|
||||
super("spectator");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSource sender, String[] args)
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
// doesn't work
|
||||
if (sender.isConsoleSender())
|
||||
{
|
||||
throw new CommandFailException("You must define a player when using the console!");
|
||||
}
|
||||
|
||||
sender.getPlayer().setGameMode(GameMode.SPECTATOR);
|
||||
send(tl("gameModeSetTo", "spectator"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (args[0].equals("-a"))
|
||||
{
|
||||
for (Player targetPlayer : Bukkit.getServer().getOnlinePlayers())
|
||||
{
|
||||
targetPlayer.setGameMode(GameMode.SPECTATOR);
|
||||
}
|
||||
send(tl("gameModeSetTo", "spectator"));
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = getNonNullPlayer(args[0]);
|
||||
send(tl("setOtherPlayerGameModeTo", player.getName(), "spectator"));
|
||||
player.sendMessage(tl("playerSetOtherGameMode", sender.getName(), "spectator"));
|
||||
player.setGameMode(GameMode.SPECTATOR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSource sender, String[] args)
|
||||
{
|
||||
if (isAdmin(sender.getPlexPlayer()))
|
||||
{
|
||||
return PlexUtils.getPlayerNameList();
|
||||
}
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
71
src/main/java/dev/plex/command/impl/SurvivalCMD.java
Normal file
71
src/main/java/dev/plex/command/impl/SurvivalCMD.java
Normal file
@ -0,0 +1,71 @@
|
||||
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 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.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = RequiredCommandSource.ANY)
|
||||
@CommandParameters(aliases = "gms", description = "Set your own or another player's gamemode to survival mode")
|
||||
public class SurvivalCMD extends PlexCommand
|
||||
{
|
||||
public SurvivalCMD()
|
||||
{
|
||||
super("survival");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSource sender, String[] args)
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
// doesn't work
|
||||
if (sender.isConsoleSender())
|
||||
{
|
||||
throw new CommandFailException("You must define a player when using the console!");
|
||||
}
|
||||
|
||||
sender.getPlayer().setGameMode(GameMode.SURVIVAL);
|
||||
send(tl("gameModeSetTo", "survival"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (isAdmin(sender.getPlexPlayer()))
|
||||
{
|
||||
if (args[0].equals("-a"))
|
||||
{
|
||||
for (Player targetPlayer : Bukkit.getServer().getOnlinePlayers())
|
||||
{
|
||||
targetPlayer.setGameMode(GameMode.SURVIVAL);
|
||||
}
|
||||
send(tl("gameModeSetTo", "survival"));
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = getNonNullPlayer(args[0]);
|
||||
send(tl("setOtherPlayerGameModeTo", player.getName(), "survival"));
|
||||
player.sendMessage(tl("playerSetOtherGameMode", sender.getName(), "survival"));
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSource sender, String[] args)
|
||||
{
|
||||
if (isAdmin(sender.getPlexPlayer()))
|
||||
{
|
||||
return PlexUtils.getPlayerNameList();
|
||||
}
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
37
src/main/java/dev/plex/command/impl/TestCMD.java
Normal file
37
src/main/java/dev/plex/command/impl/TestCMD.java
Normal file
@ -0,0 +1,37 @@
|
||||
package dev.plex.command.impl;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.source.CommandSource;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = RequiredCommandSource.ANY)
|
||||
@CommandParameters(aliases = "tst,tast", description = "HELLO")
|
||||
public class TestCMD extends PlexCommand
|
||||
{
|
||||
public TestCMD()
|
||||
{
|
||||
super("test");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSource sender, String[] args)
|
||||
{
|
||||
send(tl("variableTest", sender.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSource sender, String[] args)
|
||||
{
|
||||
if (args.length == 1)
|
||||
{
|
||||
return Arrays.asList("WHATTHEFAWK", "LUL");
|
||||
}
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
53
src/main/java/dev/plex/command/impl/WorldCMD.java
Normal file
53
src/main/java/dev/plex/command/impl/WorldCMD.java
Normal file
@ -0,0 +1,53 @@
|
||||
package dev.plex.command.impl;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.exception.CommandArgumentException;
|
||||
import dev.plex.command.source.CommandSource;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = RequiredCommandSource.IN_GAME)
|
||||
@CommandParameters(description = "Teleport to a world.", usage = "/<command> <world>")
|
||||
public class WorldCMD extends PlexCommand
|
||||
{
|
||||
public WorldCMD()
|
||||
{
|
||||
super("world");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSource sender, String[] args)
|
||||
{
|
||||
if (args.length != 1)
|
||||
{
|
||||
throw new CommandArgumentException();
|
||||
}
|
||||
World world = getNonNullWorld(args[0]);
|
||||
sender.getPlayer().teleport(new Location(world, 0, world.getHighestBlockYAt(0, 0) + 1, 0, 0, 0));
|
||||
send(tl("playerWorldTeleport", world.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSource sender, String[] args)
|
||||
{
|
||||
List<String> worlds = new ArrayList<>();
|
||||
for (World world : Bukkit.getWorlds())
|
||||
{
|
||||
worlds.add(world.getName());
|
||||
}
|
||||
if (args.length == 1)
|
||||
{
|
||||
return worlds;
|
||||
}
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user