This commit is contained in:
2020-11-05 19:29:38 -06:00
parent ce76aa9ce1
commit e4cf18db38
49 changed files with 309 additions and 187 deletions

View File

@ -1,6 +1,9 @@
package me.totalfreedom.plex.command.impl;
import com.google.common.collect.ImmutableList;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import me.totalfreedom.plex.cache.DataUtils;
import me.totalfreedom.plex.command.PlexCommand;
import me.totalfreedom.plex.command.annotation.CommandParameters;
@ -16,15 +19,12 @@ import me.totalfreedom.plex.util.PlexUtils;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = RequiredCommandSource.CONSOLE)
@CommandParameters(usage = "/<command> <add | remove | setrank | list> [player] [rank]", aliases = "adminconfig,adminmanage", description = "Manages all admins")
public class AdminCMD extends PlexCommand
{
public AdminCMD() {
public AdminCMD()
{
super("admin");
}
@ -133,11 +133,13 @@ public class AdminCMD extends PlexCommand
}
@Override
public List<String> onTabComplete(CommandSource sender, String[] args) {
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"))
}
else if (args.length == 2 && !args[0].equalsIgnoreCase("list"))
{
return PlexUtils.getPlayerNameList();
}

View File

@ -1,6 +1,11 @@
package me.totalfreedom.plex.command.impl;
import com.google.common.collect.ImmutableList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import me.totalfreedom.plex.cache.PlayerCache;
import me.totalfreedom.plex.command.PlexCommand;
import me.totalfreedom.plex.command.annotation.CommandParameters;
@ -12,12 +17,16 @@ import me.totalfreedom.plex.command.source.RequiredCommandSource;
import me.totalfreedom.plex.util.PlexUtils;
import me.totalfreedom.plex.world.BlockMapChunkGenerator;
import me.totalfreedom.plex.world.CustomWorld;
import org.bukkit.*;
import org.bukkit.entity.*;
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;
import java.util.*;
import static me.totalfreedom.plex.util.PlexUtils.tl;
@CommandParameters(description = "Subliminal message.")
@ -36,9 +45,13 @@ public class FionnCMD extends PlexCommand
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);
@ -47,11 +60,11 @@ public class FionnCMD extends PlexCommand
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);
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);
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);
@ -108,7 +121,9 @@ public class FionnCMD extends PlexCommand
p.setInvisible(false);
Location location = LOCATION_CACHE.get(p);
if (location != null)
{
p.teleport(location);
}
PlayerCache.getPunishedPlayer(p.getUniqueId()).setFrozen(false);
}
LOCATION_CACHE.clear();

View File

@ -1,6 +1,7 @@
package me.totalfreedom.plex.command.impl;
import com.google.common.collect.ImmutableList;
import java.util.List;
import me.totalfreedom.plex.cache.PlayerCache;
import me.totalfreedom.plex.command.PlexCommand;
import me.totalfreedom.plex.command.annotation.CommandParameters;
@ -11,9 +12,6 @@ import me.totalfreedom.plex.player.PunishedPlayer;
import me.totalfreedom.plex.rank.enums.Rank;
import me.totalfreedom.plex.util.PlexUtils;
import org.bukkit.entity.Player;
import java.util.List;
import static me.totalfreedom.plex.util.PlexUtils.tl;
@CommandParameters(description = "Freeze/unfreeze a player on the server", usage = "/<command> <player>")
@ -29,7 +27,9 @@ public class FreezeCMD extends PlexCommand
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());
punishedPlayer.setFrozen(!punishedPlayer.isFrozen());

View File

@ -1,6 +1,10 @@
package me.totalfreedom.plex.command.impl;
import com.google.common.collect.ImmutableList;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Comparator;
import java.util.List;
import me.totalfreedom.plex.command.PlexCommand;
import me.totalfreedom.plex.command.annotation.CommandParameters;
import me.totalfreedom.plex.command.annotation.CommandPermissions;
@ -11,12 +15,6 @@ import me.totalfreedom.plex.util.PlexUtils;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.ParseException;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Comparator;
import java.util.List;
import static me.totalfreedom.plex.util.PlexUtils.tl;
@CommandParameters(description = "Get the name history of a player", usage = "/<command> <player>", aliases = "nh")
@ -34,14 +32,16 @@ public class NameHistoryCMD extends PlexCommand
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");
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)
{
@ -56,14 +56,18 @@ public class NameHistoryCMD extends PlexCommand
.append("\n");
for (Object o : array)
{
JSONObject object = (JSONObject) o;
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");
.append("\n");
}
send(result.toString());
}

View File

@ -1,6 +1,7 @@
package me.totalfreedom.plex.command.impl;
import com.google.common.collect.ImmutableList;
import java.util.List;
import me.totalfreedom.plex.command.PlexCommand;
import me.totalfreedom.plex.command.annotation.CommandParameters;
import me.totalfreedom.plex.command.annotation.CommandPermissions;
@ -9,9 +10,6 @@ import me.totalfreedom.plex.rank.enums.Rank;
import me.totalfreedom.plex.util.PlexUtils;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import java.util.List;
import static me.totalfreedom.plex.util.PlexUtils.tl;
@CommandParameters(description = "Op everyone on the server", aliases = "opa")
@ -27,12 +25,15 @@ public class OpAllCMD extends PlexCommand
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) {
public List<String> onTabComplete(CommandSource sender, String[] args)
{
return ImmutableList.of();
}
}

View File

@ -1,6 +1,7 @@
package me.totalfreedom.plex.command.impl;
import com.google.common.collect.ImmutableList;
import java.util.List;
import me.totalfreedom.plex.command.PlexCommand;
import me.totalfreedom.plex.command.annotation.CommandParameters;
import me.totalfreedom.plex.command.annotation.CommandPermissions;
@ -9,9 +10,6 @@ import me.totalfreedom.plex.command.source.CommandSource;
import me.totalfreedom.plex.rank.enums.Rank;
import me.totalfreedom.plex.util.PlexUtils;
import org.bukkit.entity.Player;
import java.util.List;
import static me.totalfreedom.plex.util.PlexUtils.tl;
@CommandParameters(description = "Op a player on the server", usage = "/<command> <player>")
@ -27,7 +25,9 @@ public class OpCMD extends PlexCommand
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()));

View File

@ -1,5 +1,7 @@
package me.totalfreedom.plex.command.impl;
import java.util.Arrays;
import java.util.List;
import me.totalfreedom.plex.command.PlexCommand;
import me.totalfreedom.plex.command.annotation.CommandParameters;
import me.totalfreedom.plex.command.annotation.CommandPermissions;
@ -7,14 +9,12 @@ import me.totalfreedom.plex.command.source.CommandSource;
import me.totalfreedom.plex.command.source.RequiredCommandSource;
import me.totalfreedom.plex.rank.enums.Rank;
import java.util.Arrays;
import java.util.List;
@CommandPermissions(level = Rank.OP, source = RequiredCommandSource.ANY)
@CommandParameters(aliases = "plexhelp", description = "Help with plex")
public class PlexCMD extends PlexCommand
{
public PlexCMD() {
public PlexCMD()
{
super("plex");
}
@ -25,7 +25,8 @@ public class PlexCMD extends PlexCommand
}
@Override
public List<String> onTabComplete(CommandSource sender, String[] args) {
public List<String> onTabComplete(CommandSource sender, String[] args)
{
return Arrays.asList("Telesphoreo", "super", "Taahh");
}
}

View File

@ -1,23 +1,22 @@
package me.totalfreedom.plex.command.impl;
import com.google.common.collect.ImmutableList;
import java.util.Arrays;
import java.util.List;
import me.totalfreedom.plex.command.PlexCommand;
import me.totalfreedom.plex.command.annotation.CommandParameters;
import me.totalfreedom.plex.command.annotation.CommandPermissions;
import me.totalfreedom.plex.command.PlexCommand;
import me.totalfreedom.plex.command.source.CommandSource;
import me.totalfreedom.plex.command.source.RequiredCommandSource;
import me.totalfreedom.plex.rank.enums.Rank;
import java.util.Arrays;
import java.util.List;
import static me.totalfreedom.plex.util.PlexUtils.tl;
@CommandPermissions(level = Rank.OP, source = RequiredCommandSource.ANY)
@CommandParameters(aliases = "tst,tast", description = "HELLO")
public class TestCMD extends PlexCommand
{
public TestCMD() {
public TestCMD()
{
super("test");
}
@ -28,7 +27,8 @@ public class TestCMD extends PlexCommand
}
@Override
public List<String> onTabComplete(CommandSource sender, String[] args) {
public List<String> onTabComplete(CommandSource sender, String[] args)
{
if (args.length == 1)
{
return Arrays.asList("WHATTHEFAWK", "LUL");

View File

@ -1,6 +1,8 @@
package me.totalfreedom.plex.command.impl;
import com.google.common.collect.ImmutableList;
import java.util.ArrayList;
import java.util.List;
import me.totalfreedom.plex.command.PlexCommand;
import me.totalfreedom.plex.command.annotation.CommandParameters;
import me.totalfreedom.plex.command.annotation.CommandPermissions;
@ -11,17 +13,14 @@ import me.totalfreedom.plex.rank.enums.Rank;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import java.util.ArrayList;
import java.util.List;
import static me.totalfreedom.plex.util.PlexUtils.tl;
@CommandPermissions(level = Rank.OP, source = RequiredCommandSource.IN_GAME)
@CommandParameters(description = "Teleport to a world.", usage = "/<command> <world>")
public class WorldCMD extends PlexCommand
{
public WorldCMD() {
public WorldCMD()
{
super("world");
}
@ -29,7 +28,9 @@ public class WorldCMD extends PlexCommand
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()));
@ -40,9 +41,13 @@ public class WorldCMD extends PlexCommand
{
List<String> worlds = new ArrayList<>();
for (World world : Bukkit.getWorlds())
{
worlds.add(world.getName());
}
if (args.length == 1)
{
return worlds;
}
return ImmutableList.of();
}