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

View File

@ -27,7 +27,7 @@
<dependency>
<groupId>com.destroystokyo.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.16.3-R0.1-SNAPSHOT</version>
<version>1.16.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
@ -35,7 +35,7 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.12</version>
<version>1.18.16</version>
<scope>compile</scope>
</dependency>
<dependency>

View File

@ -18,8 +18,6 @@ import me.totalfreedom.plex.util.PlexUtils;
import me.totalfreedom.plex.world.CustomWorld;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
@Getter
@Setter
public class Plex extends JavaPlugin
@ -118,7 +116,9 @@ public class Plex extends JavaPlugin
{
PlexLog.log("Generating any worlds if needed...");
for (String key : config.getConfigurationSection("worlds").getKeys(false))
{
CustomWorld.generateConfigFlatWorld(key);
}
PlexLog.log("Finished with world generation!");
}
}

View File

@ -1,12 +1,11 @@
package me.totalfreedom.plex.admin;
import java.util.UUID;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import me.totalfreedom.plex.rank.enums.Rank;
import java.util.UUID;
@Getter
@Setter
public class Admin
@ -26,6 +25,4 @@ public class Admin
}
}

View File

@ -4,13 +4,7 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import dev.morphia.Datastore;
import dev.morphia.query.Query;
import dev.morphia.query.experimental.filters.Filters;
import dev.morphia.query.internal.MorphiaCursor;
import me.totalfreedom.plex.Plex;
import me.totalfreedom.plex.player.PlexPlayer;
import me.totalfreedom.plex.rank.enums.Rank;
import me.totalfreedom.plex.storage.StorageType;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@ -18,6 +12,10 @@ import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import me.totalfreedom.plex.Plex;
import me.totalfreedom.plex.player.PlexPlayer;
import me.totalfreedom.plex.rank.enums.Rank;
import me.totalfreedom.plex.storage.StorageType;
public class AdminList
{
@ -51,7 +49,9 @@ public class AdminList
admins.add(player.getName());
}
}
} else {
}
else
{
try (Connection con = Plex.get().getSqlConnection().getCon())
{
PreparedStatement statement = con.prepareStatement("SELECT * FROM `players` WHERE rank IN(?, ?, ?)");
@ -65,7 +65,9 @@ public class AdminList
admins.add(set.getString("name"));
}
} catch (SQLException throwables) {
}
catch (SQLException throwables)
{
throwables.printStackTrace();
}
}

View File

@ -1,11 +1,10 @@
package me.totalfreedom.plex.cache;
import java.util.UUID;
import me.totalfreedom.plex.Plex;
import me.totalfreedom.plex.player.PlexPlayer;
import me.totalfreedom.plex.storage.StorageType;
import java.util.UUID;
public class DataUtils
{
@ -14,7 +13,9 @@ public class DataUtils
if (Plex.get().getStorageType() == StorageType.MONGO)
{
return Plex.get().getMongoPlayerData().exists(uuid);
} else {
}
else
{
return Plex.get().getSqlPlayerData().exists(uuid);
}
}
@ -29,7 +30,9 @@ public class DataUtils
if (Plex.get().getStorageType() == StorageType.MONGO)
{
return Plex.get().getMongoPlayerData().getByUUID(uuid);
} else {
}
else
{
return Plex.get().getSqlPlayerData().getByUUID(uuid);
}
}
@ -39,7 +42,9 @@ public class DataUtils
if (Plex.get().getStorageType() == StorageType.MONGO)
{
Plex.get().getMongoPlayerData().update(plexPlayer);
} else {
}
else
{
Plex.get().getSqlPlayerData().update(plexPlayer);
}
}

View File

@ -5,11 +5,10 @@ import dev.morphia.query.Query;
import dev.morphia.query.Update;
import dev.morphia.query.experimental.filters.Filters;
import dev.morphia.query.experimental.updates.UpdateOperators;
import java.util.UUID;
import me.totalfreedom.plex.Plex;
import me.totalfreedom.plex.player.PlexPlayer;
import java.util.UUID;
public class MongoPlayerData
{
private final Datastore datastore;

View File

@ -1,11 +1,10 @@
package me.totalfreedom.plex.cache;
import com.google.common.collect.Maps;
import me.totalfreedom.plex.player.PlexPlayer;
import me.totalfreedom.plex.player.PunishedPlayer;
import java.util.Map;
import java.util.UUID;
import me.totalfreedom.plex.player.PlexPlayer;
import me.totalfreedom.plex.player.PunishedPlayer;
public class PlayerCache
{

View File

@ -2,15 +2,14 @@ package me.totalfreedom.plex.cache;
import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import me.totalfreedom.plex.Plex;
import me.totalfreedom.plex.player.PlexPlayer;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import java.util.UUID;
import me.totalfreedom.plex.Plex;
import me.totalfreedom.plex.player.PlexPlayer;
public class SQLPlayerData
{

View File

@ -1,13 +1,13 @@
package me.totalfreedom.plex.command;
import me.totalfreedom.plex.command.source.CommandSource;
import java.util.List;
import me.totalfreedom.plex.command.source.CommandSource;
public interface IPlexCommand
{
void execute(CommandSource sender, String[] args);
List<String> onTabComplete(CommandSource sender, String[] args);
}

View File

@ -1,6 +1,9 @@
package me.totalfreedom.plex.command;
import com.google.common.collect.ImmutableList;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import me.totalfreedom.plex.Plex;
import me.totalfreedom.plex.cache.PlayerCache;
import me.totalfreedom.plex.command.annotation.CommandParameters;
@ -16,13 +19,12 @@ import me.totalfreedom.plex.util.PlexLog;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.World;
import org.bukkit.command.*;
import org.bukkit.command.Command;
import org.bukkit.command.CommandMap;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import static me.totalfreedom.plex.util.PlexUtils.tl;
public abstract class PlexCommand extends Command implements TabExecutor, IPlexCommand
@ -67,9 +69,14 @@ public abstract class PlexCommand extends Command implements TabExecutor, IPlexC
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
{
if (!matches(label)) return false;
if (!matches(label))
{
return false;
}
if (this.sender == null)
{
this.sender = new CommandSource(sender);
}
PlexLog.log(this.sender.getSender().getName());
if (commandSource == RequiredCommandSource.CONSOLE && sender instanceof Player)
{
@ -109,9 +116,14 @@ public abstract class PlexCommand extends Command implements TabExecutor, IPlexC
@Override
public List<String> tabComplete(CommandSender sender, String alias, String[] args)
{
if (!matches(alias)) return ImmutableList.of();
if (!matches(alias))
{
return ImmutableList.of();
}
if (this.sender == null)
{
this.sender = new CommandSource(sender);
}
if (sender instanceof Player)
{
Player player = (Player)sender;
@ -119,10 +131,14 @@ public abstract class PlexCommand extends Command implements TabExecutor, IPlexC
if (plexPlayer.getRankFromString().isAtLeast(getLevel()))
{
return onTabComplete(this.sender, args);
} else {
}
else
{
return ImmutableList.of();
}
} else {
}
else
{
return onTabComplete(this.sender, args);
}
}
@ -144,7 +160,8 @@ public abstract class PlexCommand extends Command implements TabExecutor, IPlexC
return true;
}
}
} else if (params.aliases().split(",").length < 1)
}
else if (params.aliases().split(",").length < 1)
{
return getName().equalsIgnoreCase(label);
}
@ -169,7 +186,9 @@ public abstract class PlexCommand extends Command implements TabExecutor, IPlexC
protected void send(String s)
{
if (sender == null)
{
return;
}
send(s, sender);
}
@ -177,7 +196,9 @@ public abstract class PlexCommand extends Command implements TabExecutor, IPlexC
{
Player player = Bukkit.getPlayer(name);
if (player == null)
{
throw new PlayerNotFoundException();
}
return player;
}
@ -186,7 +207,9 @@ public abstract class PlexCommand extends Command implements TabExecutor, IPlexC
Player player = getNonNullPlayer(name);
PlexPlayer plexPlayer = PlayerCache.getPlexPlayer(player.getUniqueId());
if (plexPlayer == null)
{
throw new PlayerNotFoundException();
}
return plexPlayer;
}
@ -194,7 +217,9 @@ public abstract class PlexCommand extends Command implements TabExecutor, IPlexC
{
PlexPlayer plexPlayer = PlayerCache.getPlexPlayer(uuid);
if (plexPlayer == null)
{
throw new PlayerNotFoundException();
}
return plexPlayer;
}
@ -202,7 +227,9 @@ public abstract class PlexCommand extends Command implements TabExecutor, IPlexC
{
World world = Bukkit.getWorld(name);
if (world == null)
{
throw new CommandFailException(tl("worldNotFound"));
}
return world;
}

View File

@ -7,6 +7,8 @@ import java.lang.annotation.RetentionPolicy;
public @interface CommandParameters
{
String description() default "";
String usage() default "/<command>";
String aliases() default "";
}

View File

@ -1,14 +1,14 @@
package me.totalfreedom.plex.command.annotation;
import me.totalfreedom.plex.command.source.RequiredCommandSource;
import me.totalfreedom.plex.rank.enums.Rank;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import me.totalfreedom.plex.command.source.RequiredCommandSource;
import me.totalfreedom.plex.rank.enums.Rank;
@Retention(RetentionPolicy.RUNTIME)
public @interface CommandPermissions
{
Rank level() default Rank.IMPOSTOR;
RequiredCommandSource source() default RequiredCommandSource.ANY;
}

View File

@ -1,3 +1,5 @@
package me.totalfreedom.plex.command.exception;
public class CommandArgumentException extends RuntimeException {} // lolololol
public class CommandArgumentException extends RuntimeException
{
} // lolololol

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);
@ -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,7 +32,9 @@ 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
@ -59,9 +59,13 @@ public class NameHistoryCMD extends PlexCommand
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");
}

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();
}

View File

@ -21,7 +21,8 @@ public class AdminAddEvent extends Event
return handlers;
}
public PlexPlayer getPlexPlayer() {
public PlexPlayer getPlexPlayer()
{
return plexPlayer;
}
}

View File

@ -21,7 +21,8 @@ public class AdminRemoveEvent extends Event
return handlers;
}
public PlexPlayer getPlexPlayer() {
public PlexPlayer getPlexPlayer()
{
return plexPlayer;
}
}

View File

@ -24,11 +24,13 @@ public class AdminSetRankEvent extends Event
return handlers;
}
public PlexPlayer getPlexPlayer() {
public PlexPlayer getPlexPlayer()
{
return plexPlayer;
}
public Rank getRank() {
public Rank getRank()
{
return rank;
}
}

View File

@ -1,5 +1,6 @@
package me.totalfreedom.plex.event;
import java.util.UUID;
import lombok.Getter;
import lombok.Setter;
import me.totalfreedom.plex.player.PunishedPlayer;
@ -7,8 +8,6 @@ import org.bukkit.Bukkit;
import org.bukkit.event.Cancellable;
import org.bukkit.event.player.PlayerEvent;
import java.util.UUID;
@Getter
public abstract class PunishedPlayerEvent extends PlayerEvent implements Cancellable
{

View File

@ -4,6 +4,7 @@ import lombok.Getter;
import me.totalfreedom.plex.player.PunishedPlayer;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
@Getter
public class PunishedPlayerFreezeEvent extends PunishedPlayerEvent implements Cancellable
{

View File

@ -1,11 +1,18 @@
package me.totalfreedom.plex.handlers;
import com.google.common.collect.Lists;
import me.totalfreedom.plex.command.PlexCommand;
import me.totalfreedom.plex.command.impl.*;
import me.totalfreedom.plex.util.PlexLog;
import java.util.List;
import me.totalfreedom.plex.command.PlexCommand;
import me.totalfreedom.plex.command.impl.AdminCMD;
import me.totalfreedom.plex.command.impl.FionnCMD;
import me.totalfreedom.plex.command.impl.FreezeCMD;
import me.totalfreedom.plex.command.impl.NameHistoryCMD;
import me.totalfreedom.plex.command.impl.OpAllCMD;
import me.totalfreedom.plex.command.impl.OpCMD;
import me.totalfreedom.plex.command.impl.PlexCMD;
import me.totalfreedom.plex.command.impl.TestCMD;
import me.totalfreedom.plex.command.impl.WorldCMD;
import me.totalfreedom.plex.util.PlexLog;
public class CommandHandler
{

View File

@ -1,11 +1,13 @@
package me.totalfreedom.plex.handlers;
import com.google.common.collect.Lists;
import me.totalfreedom.plex.listener.PlexListener;
import me.totalfreedom.plex.listener.impl.*;
import me.totalfreedom.plex.util.PlexLog;
import java.util.List;
import me.totalfreedom.plex.listener.PlexListener;
import me.totalfreedom.plex.listener.impl.ChatListener;
import me.totalfreedom.plex.listener.impl.FreezeListener;
import me.totalfreedom.plex.listener.impl.PlayerListener;
import me.totalfreedom.plex.listener.impl.WorldListener;
import me.totalfreedom.plex.util.PlexLog;
public class ListenerHandler
{

View File

@ -6,7 +6,6 @@ import me.totalfreedom.plex.listener.PlexListener;
import me.totalfreedom.plex.player.PlexPlayer;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
public class ChatListener extends PlexListener
@ -19,7 +18,8 @@ public class ChatListener extends PlexListener
if (!plexPlayer.getPrefix().isEmpty())
{
event.setFormat(String.format("%s %s §7» %s", plexPlayer.getPrefix(), ChatColor.RESET + plexPlayer.getName(), event.getMessage()));
} else if (Plex.get().getRankManager().isAdmin(plexPlayer))
}
else if (Plex.get().getRankManager().isAdmin(plexPlayer))
{
event.setFormat(String.format("%s %s §7» %s", plexPlayer.getRankFromString().getPrefix(), ChatColor.RESET + plexPlayer.getName(), event.getMessage()));
}

View File

@ -13,6 +13,8 @@ public class FreezeListener extends PlexListener
{
PunishedPlayer player = PlayerCache.getPunishedPlayer(e.getPlayer().getUniqueId());
if (player.isFrozen())
{
e.setCancelled(true);
}
}
}

View File

@ -2,8 +2,6 @@ package me.totalfreedom.plex.listener.impl;
import java.util.Arrays;
import java.util.UUID;
import me.totalfreedom.plex.Plex;
import me.totalfreedom.plex.admin.Admin;
import me.totalfreedom.plex.cache.MongoPlayerData;
import me.totalfreedom.plex.cache.PlayerCache;
@ -18,7 +16,6 @@ import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
@ -84,7 +81,9 @@ public class PlayerListener extends PlexListener
if (!plexPlayer.getLoginMSG().isEmpty())
{
event.setJoinMessage(ChatColor.AQUA + player.getName() + " is " + plexPlayer.getLoginMSG());
} else {
}
else
{
event.setJoinMessage(ChatColor.AQUA + player.getName() + " is " + plexPlayer.getRankFromString().getLoginMSG());
}
@ -112,7 +111,9 @@ public class PlayerListener extends PlexListener
}
if (FionnCMD.ENABLED)
{
PlayerCache.getPunishedPlayer(event.getPlayer().getUniqueId()).setFrozen(false);
}
PlayerCache.getPlexPlayerMap().remove(event.getPlayer().getUniqueId()); //remove them from cache
PlayerCache.getPunishedPlayerMap().remove(event.getPlayer().getUniqueId());
@ -130,7 +131,9 @@ public class PlayerListener extends PlexListener
player.setInvisible(false);
Location location = FionnCMD.LOCATION_CACHE.get(player);
if (location != null)
{
player.teleport(location);
}
}
}
}

View File

@ -10,7 +10,6 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntitySpawnEvent;
import static me.totalfreedom.plex.util.PlexUtils.tl;
public class WorldListener extends PlexListener
@ -26,7 +25,9 @@ public class WorldListener extends PlexListener
case "adminworld":
{
if (plexPlayer.getRankFromString().isAtLeast(Rank.ADMIN))
{
return;
}
e.setCancelled(true);
player.sendMessage(tl("noAdminWorldBlockPlace"));
break;
@ -38,9 +39,13 @@ public class WorldListener extends PlexListener
public void onEntitySpawn(EntitySpawnEvent e)
{
if (!e.getLocation().getWorld().getName().equals("fionn"))
{
return;
}
if (e.getEntityType() != EntityType.SLIME)
{
return;
}
e.setCancelled(true);
}
}

View File

@ -39,7 +39,9 @@ public class PlexPlayer
private List<String> ips;
public PlexPlayer() {}
public PlexPlayer()
{
}
public PlexPlayer(UUID playerUUID)
{
@ -67,10 +69,14 @@ public class PlexPlayer
if (player.isOp())
{
return Rank.OP;
} else {
}
else
{
return Rank.NONOP;
}
} else {
}
else
{
return Rank.valueOf(rank.toUpperCase());
}
}

View File

@ -29,6 +29,8 @@ public class PunishedPlayer
PunishedPlayerFreezeEvent e = new PunishedPlayerFreezeEvent(this, this.frozen);
Bukkit.getServer().getPluginManager().callEvent(e);
if (!e.isCancelled())
{
this.frozen = frozen;
}
}
}

View File

@ -1,19 +1,18 @@
package me.totalfreedom.plex.rank;
import com.google.common.collect.Maps;
import me.totalfreedom.plex.Plex;
import me.totalfreedom.plex.player.PlexPlayer;
import me.totalfreedom.plex.rank.enums.Rank;
import me.totalfreedom.plex.util.PlexLog;
import org.json.JSONObject;
import org.json.JSONTokener;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Map;
import java.util.stream.Collectors;
import me.totalfreedom.plex.Plex;
import me.totalfreedom.plex.player.PlexPlayer;
import me.totalfreedom.plex.rank.enums.Rank;
import me.totalfreedom.plex.util.PlexLog;
import org.json.JSONObject;
import org.json.JSONTokener;
public class RankManager
{
@ -79,7 +78,10 @@ public class RankManager
JSONObject rankObj = object.getJSONObject("ranks");
for (Rank rank : Rank.values())
{
if (rankObj.isNull(rank.name().toUpperCase())) continue;
if (rankObj.isNull(rank.name().toUpperCase()))
{
continue;
}
rank.setLoginMessage(rankObj.getJSONObject(rank.name().toUpperCase()).getString("loginMSG"));
rank.setPrefix(rankObj.getJSONObject(rank.name().toUpperCase()).getString("prefix")); //should i even be doing this
rank.setPermissions(rankObj.getJSONObject(rank.name().toUpperCase()).getJSONArray("permissions").toList().stream().map(Object::toString).collect(Collectors.toList()));

View File

@ -1,9 +1,8 @@
package me.totalfreedom.plex.rank.enums;
import com.google.common.collect.Lists;
import org.bukkit.ChatColor;
import java.util.List;
import org.bukkit.ChatColor;
public enum Rank
{
@ -37,7 +36,8 @@ public enum Rank
return ChatColor.translateAlternateColorCodes('&', loginMessage);
}
public int getLevel() {
public int getLevel()
{
return level;
}
@ -46,7 +46,8 @@ public enum Rank
this.loginMessage = msg;
}
public void setPrefix(String prefix) {
public void setPrefix(String prefix)
{
this.prefix = prefix;
}
@ -55,11 +56,13 @@ public enum Rank
return getLevel() >= rank.getLevel();
}
public List<String> getPermissions() {
public List<String> getPermissions()
{
return permissions;
}
public void setPermissions(List<String> permissions) {
public void setPermissions(List<String> permissions)
{
this.permissions = permissions;
}
}

View File

@ -2,6 +2,5 @@ package me.totalfreedom.plex.storage;
public enum StorageType
{
MONGO, SQL, SQLITE;
MONGO, SQL, SQLITE
}

View File

@ -10,11 +10,14 @@ import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
import me.totalfreedom.plex.Plex;
import me.totalfreedom.plex.config.Config;
import me.totalfreedom.plex.storage.StorageType;
import org.bukkit.*;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.PluginCommandYamlParser;
import org.bukkit.entity.Player;
@ -81,12 +84,18 @@ public class PlexUtils
{
Plex plugin = Plex.get();
if (s.equals("baseColor") || s.equals("errorColor") || s.equals("broadcastColor"))
{
return getChatColorFromConfig(plugin.messages, ChatColor.WHITE, s).toString();
}
String f = plugin.messages.getString(s);
if (f == null)
{
return ChatColor.RED + "No message";
}
for (Object object : objects)
{
f = f.replaceFirst("<v>", String.valueOf(object));
}
ChatColor base = getChatColorFromConfig(plugin.messages, ChatColor.GRAY, "baseColor");
ChatColor broadcast = getChatColorFromConfig(plugin.messages, ChatColor.AQUA, "broadcastColor");
ChatColor error = getChatColorFromConfig(plugin.messages, ChatColor.RED, "errorColor");
@ -101,18 +110,26 @@ public class PlexUtils
{
ChatColor color;
if (config.getString(path) == null)
{
color = def;
}
else if (ChatColor.getByChar(config.getString(path)) == null)
{
color = def;
}
else
{
color = ChatColor.getByChar(config.getString(path));
}
return color;
}
public static void setBlocks(Location c1, Location c2, Material material)
{
if (!c1.getWorld().getName().equals(c1.getWorld().getName()))
{
return;
}
int sy = Math.min(c1.getBlockY(), c2.getBlockY()),
ey = Math.max(c1.getBlockY(), c2.getBlockY()),
sx = Math.min(c1.getBlockX(), c2.getBlockX()),
@ -136,7 +153,9 @@ public class PlexUtils
{
List<String> names = new ArrayList<>();
for (Player player : Bukkit.getOnlinePlayers())
{
names.add(player.getName());
}
return names;
}
@ -154,7 +173,9 @@ public class PlexUtils
String line;
StringBuilder content = new StringBuilder();
while ((line = in.readLine()) != null)
{
content.append(line);
}
in.close();
connection.disconnect();
return new JSONParser().parse(content.toString());
@ -163,9 +184,12 @@ public class PlexUtils
public static UUID getFromName(String name)
{
JSONObject profile;
try {
try
{
profile = (JSONObject)PlexUtils.simpleGET("https://api.ashcon.app/mojang/v2/user/" + name);
} catch (IOException | ParseException e) {
}
catch (IOException | ParseException e)
{
e.printStackTrace();
return null;
}

View File

@ -1,11 +1,10 @@
package me.totalfreedom.plex.world;
import me.totalfreedom.plex.Plex;
import org.bukkit.Material;
import org.bukkit.generator.BlockPopulator;
import java.util.LinkedHashMap;
import java.util.Map;
import me.totalfreedom.plex.Plex;
import org.bukkit.Material;
import org.bukkit.generator.BlockPopulator;
public class BlockMapChunkGenerator extends FlatChunkGenerator
{
@ -24,11 +23,15 @@ public class BlockMapChunkGenerator extends FlatChunkGenerator
{
int height = -1;
for (int i : blockMap.values())
{
height += i;
}
for (Map.Entry<Material, Integer> entry : blockMap.entrySet())
{
for (int i = 0; i < entry.getValue(); i++, height--)
{
chunk.setBlock(x, height, z, entry.getKey());
}
}
}
}

View File

@ -1,11 +1,10 @@
package me.totalfreedom.plex.world;
import java.util.LinkedHashMap;
import me.totalfreedom.plex.Plex;
import org.bukkit.Material;
import org.bukkit.generator.BlockPopulator;
import java.util.LinkedHashMap;
public class ConfigurationChunkGenerator extends BlockMapChunkGenerator
{
private static Plex plugin = Plex.get();
@ -21,7 +20,10 @@ public class ConfigurationChunkGenerator extends BlockMapChunkGenerator
for (String key : plugin.config.getConfigurationSection("worlds." + worldName + ".parameters").getKeys(false))
{
Material material = Material.getMaterial(key.toUpperCase());
if (material == null) continue;
if (material == null)
{
continue;
}
int count = plugin.config.getInt("worlds." + worldName + ".parameters." + key);
blockMap.put(material, count);
}

View File

@ -1,11 +1,10 @@
package me.totalfreedom.plex.world;
import org.bukkit.World;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.ChunkGenerator;
import java.util.Arrays;
import java.util.List;
import org.bukkit.World;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.ChunkGenerator;
public abstract class CustomChunkGenerator extends ChunkGenerator
{

View File

@ -1,5 +1,7 @@
package me.totalfreedom.plex.world;
import java.io.File;
import java.util.Objects;
import me.totalfreedom.plex.Plex;
import org.bukkit.Material;
import org.bukkit.World;
@ -9,9 +11,6 @@ import org.bukkit.block.BlockState;
import org.bukkit.block.Sign;
import org.bukkit.generator.ChunkGenerator;
import java.io.File;
import java.util.Objects;
public class CustomWorld extends WorldCreator
{
private static Plex plugin = Plex.get();
@ -39,7 +38,9 @@ public class CustomWorld extends WorldCreator
public static World generateConfigFlatWorld(String name)
{
if (!plugin.config.contains("worlds." + name))
{
return null;
}
CustomWorld customWorld = new CustomWorld(name, new ConfigurationChunkGenerator(name))
{
@Override

View File

@ -1,8 +1,8 @@
package me.totalfreedom.plex.world;
import java.util.Random;
import org.bukkit.World;
import org.bukkit.generator.BlockPopulator;
import java.util.Random;
public abstract class FlatChunkGenerator extends CustomChunkGenerator
{

View File

@ -1,11 +1,10 @@
package me.totalfreedom.plex.world;
import java.util.Random;
import org.bukkit.World;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.util.noise.PerlinNoiseGenerator;
import java.util.Random;
public abstract class NoiseChunkGenerator extends CustomChunkGenerator
{
private final NoiseOptions options;

View File

@ -1,11 +1,10 @@
package me.totalfreedom.plex.world;
import java.util.Random;
import org.bukkit.World;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.util.noise.PerlinOctaveGenerator;
import java.util.Random;
public abstract class OctaveChunkGenerator extends CustomChunkGenerator
{
private OctaveOptions options;

View File

@ -35,7 +35,7 @@ worlds:
stone: 16
bedrock: 1
masterbuilderworld:
name: "MB World"
name: "MasterBuilder World"
parameters:
grass_block: 1
dirt: 32