added files.
This commit is contained in:
commit
f93cc6b887
1166 files changed
+142532
No files matched your search
@@ -0,0 +1,178 @@
|
||||
package me.creaxx.api;
|
||||
|
||||
import me.creaxx.api.nms.INMSImpl;
|
||||
import me.creaxx.api.nms.ITeleportImpl;
|
||||
import me.creaxx.api.nms.impl.LegacyTeleportImpl;
|
||||
import me.creaxx.api.nms.impl.ModernTeleportImpl;
|
||||
import me.creaxx.api.nms.impl.v1_12_R1;
|
||||
import me.creaxx.api.nms.impl.v1_16_R3;
|
||||
import me.creaxx.api.nms.impl.v1_18_R2;
|
||||
import me.creaxx.api.nms.impl.v1_19_R3;
|
||||
import me.creaxx.api.nms.impl.v1_20_R3;
|
||||
import me.creaxx.api.nms.impl.v1_21_R1;
|
||||
import me.creaxx.api.nms.impl.v1_21_R10;
|
||||
import me.creaxx.api.nms.impl.v1_7_R4;
|
||||
import me.creaxx.api.nms.impl.v1_8_R3;
|
||||
import me.creaxx.api.nms.impl.v_1_20_R4;
|
||||
import me.creaxx.api.particle.ParticleAPI;
|
||||
import me.creaxx.api.title.ITitleAPI;
|
||||
import me.creaxx.api.utils.VersionUtil;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import xyz.refinedev.lib.folialib.FoliaLib;
|
||||
import xyz.refinedev.lib.particlenativeapi.api.ParticleNativeAPI;
|
||||
import xyz.refinedev.lib.particlenativeapi.core.ParticleNativeCore;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class NMSHandler {
|
||||
|
||||
public static NMSHandler instance;
|
||||
|
||||
private final JavaPlugin plugin;
|
||||
|
||||
private INMSImpl API;
|
||||
|
||||
private ITeleportImpl teleportAPI;
|
||||
|
||||
private ITitleAPI titleAPI;
|
||||
|
||||
private ParticleAPI particleAPI;
|
||||
|
||||
private boolean registered = false;
|
||||
|
||||
public NMSHandler(JavaPlugin javaPlugin) {
|
||||
instance = this;
|
||||
this.plugin = javaPlugin;
|
||||
}
|
||||
|
||||
public boolean init() {
|
||||
FoliaLib foliaLib = new FoliaLib(this.plugin);
|
||||
String text;
|
||||
try {
|
||||
String text2;
|
||||
Integer.parseInt(
|
||||
(text =
|
||||
(text2 = Bukkit.getServer().getClass().getPackage().getName())
|
||||
.length()
|
||||
< 4
|
||||
? text2.split("\\.")[2]
|
||||
: text2.split("\\.")[3])
|
||||
.split("_")[1]);
|
||||
} catch (Exception exception) {
|
||||
text =
|
||||
"v"
|
||||
+ Bukkit.getServer()
|
||||
.getBukkitVersion()
|
||||
.replace("-SNAPSHOT", "")
|
||||
.replace("-R0.", "_R")
|
||||
.replace(".", "_");
|
||||
}
|
||||
if (!VersionUtil.canHex() || !foliaLib.isFolia() && !foliaLib.isPaper()) {
|
||||
this.teleportAPI = new LegacyTeleportImpl();
|
||||
} else {
|
||||
this.teleportAPI = new ModernTeleportImpl();
|
||||
}
|
||||
this.plugin.getLogger().log(Level.INFO, "Loading NMS Implementation...");
|
||||
try {
|
||||
this.setupNMS(text);
|
||||
this.plugin.getLogger().log(Level.INFO, "Detected version " + text + "!");
|
||||
try {
|
||||
this.setupParticleAPI();
|
||||
} catch (Exception exception2) {
|
||||
this.plugin
|
||||
.getLogger()
|
||||
.log(Level.SEVERE, "ParticleAPI is not supported on this version.");
|
||||
}
|
||||
this.registered = true;
|
||||
return true;
|
||||
} catch (IllegalArgumentException illegalArgumentException) {
|
||||
this.plugin
|
||||
.getLogger()
|
||||
.log(Level.INFO, "This version is not fully supported (" + text + ")!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void setupNMS(String text) throws IllegalArgumentException {
|
||||
switch (text) {
|
||||
case "v1_7_R4":
|
||||
this.API = new v1_7_R4();
|
||||
break;
|
||||
case "v1_8_R3":
|
||||
this.API = new v1_8_R3();
|
||||
break;
|
||||
case "v1_12_R1":
|
||||
this.API = new v1_12_R1();
|
||||
break;
|
||||
case "v1_16_R3":
|
||||
this.API = new v1_16_R3();
|
||||
break;
|
||||
case "v1_18_R2":
|
||||
this.API = new v1_18_R2();
|
||||
break;
|
||||
case "v1_19_R3":
|
||||
this.API = new v1_19_R3();
|
||||
break;
|
||||
case "v1_20_R3":
|
||||
this.API = new v1_20_R3();
|
||||
break;
|
||||
case "v1_20_6_R1":
|
||||
this.API = new v_1_20_R4();
|
||||
break;
|
||||
case "v1_21_11_R1":
|
||||
case "v1_21_10_R1":
|
||||
this.API = new v1_21_R10();
|
||||
break;
|
||||
case "v1_21_9_R1":
|
||||
case "v1_21_8_R1":
|
||||
case "v1_21_7_R1":
|
||||
case "v1_21_6_R1":
|
||||
case "v1_21_5_R1":
|
||||
case "v1_21_4_R1":
|
||||
case "v1_21_3_R1":
|
||||
case "v1_21_2_R1":
|
||||
case "v1_21_1_R1":
|
||||
case "v1_21_R1":
|
||||
this.API = new v1_21_R1();
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unsupported Version!");
|
||||
}
|
||||
}
|
||||
|
||||
public void setupParticleAPI() {
|
||||
ParticleNativeAPI particleNativeAPI = ParticleNativeCore.loadAPI(this.plugin);
|
||||
this.particleAPI = new ParticleAPI(particleNativeAPI);
|
||||
}
|
||||
|
||||
public JavaPlugin getPlugin() {
|
||||
return this.plugin;
|
||||
}
|
||||
|
||||
public INMSImpl getAPI() {
|
||||
return this.API;
|
||||
}
|
||||
|
||||
public ITeleportImpl getTeleportAPI() {
|
||||
return this.teleportAPI;
|
||||
}
|
||||
|
||||
public ITitleAPI getTitleAPI() {
|
||||
return this.titleAPI;
|
||||
}
|
||||
|
||||
public ParticleAPI getParticleAPI() {
|
||||
return this.particleAPI;
|
||||
}
|
||||
|
||||
public boolean isRegistered() {
|
||||
return this.registered;
|
||||
}
|
||||
|
||||
public static NMSHandler getInstance() {
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package me.creaxx.api.nms;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.profile.disguise.ISkin;
|
||||
|
||||
public interface INMSImpl {
|
||||
|
||||
void disguise(IProfile profile, boolean matches);
|
||||
|
||||
void undisguise(IProfile profile);
|
||||
|
||||
void updateSkin(Player player, ISkin skin, boolean matches);
|
||||
|
||||
void updateHeaderFooter(Player player, String text, String text2);
|
||||
|
||||
ISkin getPlayerSkin(Player player);
|
||||
|
||||
ItemStack itemWithBase64(ItemStack itemStack, String text);
|
||||
|
||||
void sitPlayer(Player player);
|
||||
|
||||
void unsitPlayer(Player player);
|
||||
|
||||
void removePlayerFromTeam(String text, Team team);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package me.creaxx.api.nms;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface ITeleportImpl {
|
||||
|
||||
void teleport(Player player, Location location);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package me.creaxx.api.nms.impl;
|
||||
|
||||
import me.creaxx.api.nms.ITeleportImpl;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class LegacyTeleportImpl implements ITeleportImpl {
|
||||
|
||||
@Override
|
||||
public void teleport(Player player, Location location) {
|
||||
player.teleport(location);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package me.creaxx.api.nms.impl;
|
||||
|
||||
import me.creaxx.api.nms.ITeleportImpl;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ModernTeleportImpl implements ITeleportImpl {
|
||||
|
||||
@Override
|
||||
public void teleport(Player player, Location location) {
|
||||
player.teleportAsync(location);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package me.creaxx.api.particle;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.lib.particlenativeapi.api.ParticleNativeAPI;
|
||||
import xyz.refinedev.lib.particlenativeapi.api.packet.ParticlePacket;
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.handler.IProfileHandler;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ParticleAPI {
|
||||
|
||||
private final ParticleNativeAPI particleAPI;
|
||||
|
||||
public void sendParticlePacket(
|
||||
ParticleEffect.ParticlePacket particlePacket, Location location, Player player) {
|
||||
particlePacket.toNativePacket(this.particleAPI, location).sendTo(player);
|
||||
}
|
||||
|
||||
public void sendParticlePacket(
|
||||
Player player,
|
||||
ParticleEffect.ParticlePacket particlePacket,
|
||||
Location location,
|
||||
List<Player> values) {
|
||||
ParticlePacket particlePacket2 = particlePacket.toNativePacket(this.particleAPI, location);
|
||||
for (Player player2 : values) {
|
||||
if (player == null || player2.canSee(player)) {
|
||||
particlePacket2.sendTo(player2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void sendParticlePacket(
|
||||
Player player,
|
||||
ParticleEffect.ParticlePacket particlePacket,
|
||||
Location location,
|
||||
double value) {
|
||||
ParticlePacket particlePacket2 = particlePacket.toNativePacket(this.particleAPI, location);
|
||||
String name = location.getWorld().getName();
|
||||
double value2 = value * value;
|
||||
IProfileHandler profileHandler = Phoenix.getInstance().getProfileHandler();
|
||||
for (Player player2 : Bukkit.getOnlinePlayers()) {
|
||||
if ((player == null || player2.canSee(player))
|
||||
&& player2.getWorld().getName().equals(name)
|
||||
&& !(player2.getLocation().distanceSquared(location) > value2)
|
||||
&& profileHandler.getProfile(player2.getUniqueId()).isSetting("particles")) {
|
||||
particlePacket2.sendTo(player2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ParticleAPI(ParticleNativeAPI particleNativeAPI) {
|
||||
this.particleAPI = particleNativeAPI;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,10 @@
|
||||
package me.creaxx.api.title;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface ITitleAPI {
|
||||
|
||||
void sendTitle(Player player, String text, String text2, int value, int value2, int value3);
|
||||
|
||||
void clearTitle(Player player);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package me.creaxx.api.utils;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class VersionUtil {
|
||||
|
||||
public static String VERSION;
|
||||
|
||||
public static int MINOR_VERSION;
|
||||
|
||||
public static boolean canHex() {
|
||||
return MINOR_VERSION >= 16;
|
||||
}
|
||||
|
||||
static {
|
||||
try {
|
||||
String text;
|
||||
VERSION =
|
||||
(text = Bukkit.getServer().getClass().getPackage().getName()).length() < 4
|
||||
? text.split("\\.")[2]
|
||||
: text.split("\\.")[3];
|
||||
MINOR_VERSION = Integer.parseInt(VERSION.split("_")[1]);
|
||||
} catch (Exception exception) {
|
||||
VERSION =
|
||||
"v"
|
||||
+ Bukkit.getServer()
|
||||
.getBukkitVersion()
|
||||
.replace("-SNAPSHOT", "")
|
||||
.replace("-R0.", "_R")
|
||||
.replace(".", "_");
|
||||
MINOR_VERSION = Integer.parseInt(VERSION.split("_")[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,374 @@
|
||||
package xyz.refinedev.phoenix;
|
||||
|
||||
import me.creaxx.api.NMSHandler;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
import xyz.refinedev.lib.jetbrains.NotNull;
|
||||
import xyz.refinedev.lib.jetbrains.Nullable;
|
||||
import xyz.refinedev.phoenix.chat.api.ChatChannelType;
|
||||
import xyz.refinedev.phoenix.config.GlobalConfig;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.config.SettingsConfig;
|
||||
import xyz.refinedev.phoenix.packet.impl.profile.ChatChannelMessagePacket;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.profile.tag.ITag;
|
||||
import xyz.refinedev.phoenix.rank.IRank;
|
||||
import xyz.refinedev.phoenix.server.IServerData;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.DateUtils;
|
||||
import xyz.refinedev.phoenix.utils.Duration;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
import xyz.refinedev.phoenix.utils.events.player.PlayerChatInChannelEvent;
|
||||
import xyz.refinedev.phoenix.utils.general.Tasks;
|
||||
import xyz.refinedev.phoenix.whitelist.WhitelistAccess;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Function;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public final class BukkitAPI {
|
||||
|
||||
public static CommonPlatform api = Phoenix.getInstance();
|
||||
|
||||
public static Pattern UUID_PATTERN =
|
||||
Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}");
|
||||
|
||||
public static final Pattern VALID_NAME_PATTERN = Pattern.compile("^[a-zA-Z0-9_$]{1,16}$");
|
||||
|
||||
public static final Pattern DISGUISE_VALID_NAME_PATTERN =
|
||||
Pattern.compile("^[a-zA-Z0-9_$]{3,16}$");
|
||||
|
||||
public static boolean isUuid(String text) {
|
||||
return UUID_PATTERN.matcher(text).find();
|
||||
}
|
||||
|
||||
public static boolean isDisguiseValidName(String text) {
|
||||
return text != null
|
||||
&& !text.isEmpty()
|
||||
&& DISGUISE_VALID_NAME_PATTERN.matcher(text).matches();
|
||||
}
|
||||
|
||||
public static boolean isValidName(String text) {
|
||||
return text != null
|
||||
&& !text.isEmpty()
|
||||
&& VALID_NAME_PATTERN.matcher(text.replace("*", "").replace(".", "")).matches();
|
||||
}
|
||||
|
||||
public static void sendAdminAlert(Player player, String text) {
|
||||
IProfile cachedProfile = api.getProfileHandler().getCachedProfile(player.getUniqueId());
|
||||
Iterator iterator2 = Bukkit.getOnlinePlayers().iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
Player player2;
|
||||
IProfile profile;
|
||||
if (!(player2 = (Player) iterator2.next()).getName().equals(player.getName())
|
||||
&& player2.hasPermission("core.admin")
|
||||
&& (profile =
|
||||
Phoenix.getInstance()
|
||||
.getProfileHandler()
|
||||
.getCachedProfile(player2.getUniqueId()))
|
||||
!= null
|
||||
&& profile.isSetting("admin-alerts")) {
|
||||
player2.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(player2, MessageConfig.STAFF.ADMIN_ALERT)
|
||||
.replace(
|
||||
"<player>",
|
||||
cachedProfile.getNameWithColorNoDisguise())
|
||||
.replace("<action>", text)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void broadcastToStaff(String text) {
|
||||
Iterator iterator2 = Bukkit.getOnlinePlayers().iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
Player player;
|
||||
if ((player = (Player) iterator2.next()).hasPermission("core.admin")
|
||||
&& api.getProfileHandler()
|
||||
.getCachedProfile(player.getUniqueId())
|
||||
.isSetting("admin-alerts")) {
|
||||
player.sendMessage(Color.translate(text));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void broadcastToStaff(Function<Player, String> function) {
|
||||
Iterator iterator2 = Bukkit.getOnlinePlayers().iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
Player player;
|
||||
if ((player = (Player) iterator2.next()).hasPermission("core.admin")
|
||||
&& api.getProfileHandler()
|
||||
.getCachedProfile(player.getUniqueId())
|
||||
.isSetting("admin-alerts")) {
|
||||
player.sendMessage((String) function.apply(player));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isInModMode(Player player) {
|
||||
return player.hasMetadata("ModMode");
|
||||
}
|
||||
|
||||
public static long parseDuration(String text) {
|
||||
if (!text.equalsIgnoreCase("perm") && !text.equalsIgnoreCase("permanent")) {
|
||||
try {
|
||||
return getDuration(text);
|
||||
} catch (Exception exception) {
|
||||
}
|
||||
}
|
||||
return -5L;
|
||||
}
|
||||
|
||||
public static long parseDurationPunishment(String text) {
|
||||
Duration duration;
|
||||
return (duration = Duration.of(text)) == null ? -3L : duration.getTimeTime();
|
||||
}
|
||||
|
||||
public static long getDuration(String text) {
|
||||
return DateUtils.getDuration(text);
|
||||
}
|
||||
|
||||
public static void callEvent(Event event) {
|
||||
if (event.isAsynchronous()) {
|
||||
if (Bukkit.isPrimaryThread()) {
|
||||
Tasks.runAsync(() -> Bukkit.getPluginManager().callEvent(event));
|
||||
} else {
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
}
|
||||
} else if (Bukkit.isPrimaryThread()) {
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
} else {
|
||||
Tasks.run(() -> Bukkit.getPluginManager().callEvent(event));
|
||||
}
|
||||
}
|
||||
|
||||
public static String getKickMessage(List<String> values) {
|
||||
if (values.isEmpty()) {
|
||||
return "Empty";
|
||||
}
|
||||
int value = 0;
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (String text : values) {
|
||||
value++;
|
||||
stringBuilder.append(text);
|
||||
if (value < values.size()) {
|
||||
stringBuilder.append("\n");
|
||||
}
|
||||
}
|
||||
return Color.translate(stringBuilder.toString());
|
||||
}
|
||||
|
||||
public static String getUntranslatedStringFromList(List<String> values) {
|
||||
if (values.isEmpty()) {
|
||||
return "Empty";
|
||||
}
|
||||
int value = 0;
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (String text : values) {
|
||||
value++;
|
||||
stringBuilder.append(text);
|
||||
if (value < values.size()) {
|
||||
stringBuilder.append("\n");
|
||||
}
|
||||
}
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getTagPrefix(IProfile profile) {
|
||||
ITag tag;
|
||||
if ((tag = profile.getTag()) != null
|
||||
&& (hasTag(profile, tag) || profile.getCustomTag() != null)) {
|
||||
return !tag.isScheduleActive()
|
||||
? ""
|
||||
: Color.translate(
|
||||
SettingsConfig.FORMATS
|
||||
.TAGS_FORMAT
|
||||
.replace("<color>", tag.getColor())
|
||||
.replace("<tag>", tag.getPrefix()));
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getTagPrefix(Player player) {
|
||||
IProfile profile;
|
||||
ITag tag;
|
||||
if ((tag =
|
||||
(profile =
|
||||
api.getProfileHandler()
|
||||
.getCachedProfile(player.getUniqueId()))
|
||||
.getTag())
|
||||
!= null
|
||||
&& (hasTag(player, tag) || profile.getCustomTag() != null)) {
|
||||
return !tag.isScheduleActive()
|
||||
? ""
|
||||
: Color.translate(
|
||||
SettingsConfig.FORMATS
|
||||
.TAGS_FORMAT
|
||||
.replace("<color>", tag.getColor())
|
||||
.replace("<tag>", tag.getPrefix()));
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean hasTag(IProfile profile, ITag tag) {
|
||||
return profile.checkPermission("core.tags." + tag.getName(), false)
|
||||
|| profile.checkPermission("core.tags.*", false);
|
||||
}
|
||||
|
||||
public static boolean hasTag(Player player, ITag tag) {
|
||||
return player.hasPermission("core.tags." + tag.getName())
|
||||
|| player.hasPermission("core.tags.*");
|
||||
}
|
||||
|
||||
public static void sendSomeStaffMessage(
|
||||
IProfile profile, ChatChannelType chatChannelType, String text) {
|
||||
if (!chatChannelType.canSendMessage(Bukkit.getPlayer(profile.getUniqueId()))) {
|
||||
profile.updateMetadata("channel", "Default", true);
|
||||
} else {
|
||||
callEvent(new PlayerChatInChannelEvent(chatChannelType, profile, text));
|
||||
api.getPacketHandler()
|
||||
.send(
|
||||
new ChatChannelMessagePacket(
|
||||
profile.getUuid(),
|
||||
chatChannelType.getName(),
|
||||
profile.getNameWithColorNoDisguise(),
|
||||
GlobalConfig.SERVER.DISPLAYNAME,
|
||||
text));
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendGlobalChatChannel(
|
||||
IProfile profile, ChatChannelType chatChannelType, String text) {
|
||||
if (!chatChannelType.canSendMessage(Bukkit.getPlayer(profile.getUniqueId()))) {
|
||||
profile.updateMetadata("channel", "Default", true);
|
||||
} else {
|
||||
callEvent(new PlayerChatInChannelEvent(chatChannelType, profile, text));
|
||||
api.getPacketHandler()
|
||||
.send(
|
||||
new ChatChannelMessagePacket(
|
||||
profile.getUuid(),
|
||||
chatChannelType.getName(),
|
||||
profile.getNameWithColorNoDisguise(),
|
||||
GlobalConfig.SERVER.DISPLAYNAME,
|
||||
text));
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendSomeStaffMessageConsole(ChatChannelType chatChannelType, String text) {
|
||||
api.getPacketHandler()
|
||||
.send(
|
||||
new ChatChannelMessagePacket(
|
||||
IProfile.getConsoleUuid(),
|
||||
chatChannelType.getName(),
|
||||
GlobalConfig.SERVER.CONSOLE_NAME,
|
||||
GlobalConfig.SERVER.DISPLAYNAME,
|
||||
text));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static IProfile getProfileByName(String text) {
|
||||
IProfile profile;
|
||||
String text2;
|
||||
if ((profile = api.getProfileHandler().getLocalProfileByName(text)) == null
|
||||
&& (text2 = Phoenix.getInstance().getDisguiseHandler().getUuidByFakeName(text))
|
||||
!= null) {
|
||||
UUID uUID = UUID.fromString(text2);
|
||||
profile = api.getProfileHandler().getProfile(uUID);
|
||||
}
|
||||
if (profile == null) {
|
||||
UUID uUID2;
|
||||
if ((uUID2 = api.getUuidCache().getUuidNoMojang(text)) != null) {
|
||||
profile = api.getProfileHandler().getProfile(uUID2);
|
||||
} else {
|
||||
UUID uUID3;
|
||||
if ((uUID3 = api.getProfileHandler().getUuidFromName(text)) != null) {
|
||||
profile = api.getProfileHandler().getProfile(uUID3);
|
||||
}
|
||||
}
|
||||
}
|
||||
return profile;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static IProfile getProfileByNameNoDisguise(String text) {
|
||||
IProfile profile;
|
||||
if ((profile = api.getProfileHandler().getLocalProfileByName(text)) == null) {
|
||||
UUID uUID;
|
||||
if ((uUID = api.getUuidCache().getUuidNoMojang(text)) != null) {
|
||||
profile = api.getProfileHandler().getProfile(uUID);
|
||||
} else if ((uUID = api.getProfileHandler().getUuidFromName(text)) != null) {
|
||||
profile = api.getProfileHandler().getProfile(uUID);
|
||||
}
|
||||
}
|
||||
return profile;
|
||||
}
|
||||
|
||||
public static void kickUnwhitelistedUsers() {
|
||||
if (api.getWhitelistHandler().isWhitelisted()) {
|
||||
IRank rank = api.getRankHandler().getRank("WhitelistBypass");
|
||||
Set<WhitelistAccess> accessTypes = api.getWhitelistHandler().getAccessTypes();
|
||||
IServerData serverByName =
|
||||
api.getNetworkHandler().getServerByName(GlobalConfig.SERVER.NAME);
|
||||
IRank whitelistRank = api.getWhitelistHandler().getWhitelistRank();
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
IProfile profile;
|
||||
if ((profile = api.getProfileHandler().getCachedProfile(player.getUniqueId()))
|
||||
!= null
|
||||
&& (rank == null || !profile.hasRank(rank))) {
|
||||
boolean matches = false;
|
||||
WhitelistAccess whitelistAccess = null;
|
||||
WhitelistAccess[] whitelistAccesss;
|
||||
int value = (whitelistAccesss = WhitelistAccess.values()).length;
|
||||
for (int index = 0; index < value; index++) {
|
||||
WhitelistAccess whitelistAccess2 = whitelistAccesss[index];
|
||||
if (accessTypes.contains(whitelistAccess2)) {
|
||||
if (whitelistAccess2.getFunction().apply(profile, serverByName)) {
|
||||
matches = true;
|
||||
break;
|
||||
}
|
||||
whitelistAccess = whitelistAccess2;
|
||||
}
|
||||
}
|
||||
if (!matches) {
|
||||
List<String> values2 =
|
||||
whitelistAccess == WhitelistAccess.RANK
|
||||
? MessageConfig.WHITELIST.RANK_KICK_MESSAGE
|
||||
: MessageConfig.WHITELIST.UUID_KICK_MESSAGE;
|
||||
player.kickPlayer(
|
||||
Color.translate(
|
||||
getKickMessage(values2)
|
||||
.replace(
|
||||
"<rank>",
|
||||
whitelistRank != null
|
||||
? whitelistRank.getDisplayName()
|
||||
: "")));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void teleport(Player player, Location location) {
|
||||
NMSHandler.getInstance().getTeleportAPI().teleport(player, location);
|
||||
}
|
||||
|
||||
public static void teleport(Player player, Player player2) {
|
||||
teleport(player, player2.getLocation());
|
||||
}
|
||||
|
||||
private BukkitAPI() {
|
||||
throw new UnsupportedOperationException(
|
||||
"This is a utility class and cannot be instantiated");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,233 @@
|
||||
package xyz.refinedev.phoenix;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import xyz.refinedev.lib.config.ConfigHandler;
|
||||
import xyz.refinedev.phoenix.cache.api.IUUIDCache;
|
||||
import xyz.refinedev.phoenix.handler.IAddressStatsHandler;
|
||||
import xyz.refinedev.phoenix.handler.IAltHandler;
|
||||
import xyz.refinedev.phoenix.handler.IAnalyticsHandler;
|
||||
import xyz.refinedev.phoenix.handler.IAntiVPNHandler;
|
||||
import xyz.refinedev.phoenix.handler.IChatLogHandler;
|
||||
import xyz.refinedev.phoenix.handler.IChatSnapshotHandler;
|
||||
import xyz.refinedev.phoenix.handler.ICommandLogHandler;
|
||||
import xyz.refinedev.phoenix.handler.ICooldownHandler;
|
||||
import xyz.refinedev.phoenix.handler.ICustomTagHandler;
|
||||
import xyz.refinedev.phoenix.handler.IDatabaseHandler;
|
||||
import xyz.refinedev.phoenix.handler.IFilterHandler;
|
||||
import xyz.refinedev.phoenix.handler.IGrantHandler;
|
||||
import xyz.refinedev.phoenix.handler.IHashHandler;
|
||||
import xyz.refinedev.phoenix.handler.ILoginHandler;
|
||||
import xyz.refinedev.phoenix.handler.IMetricsHandler;
|
||||
import xyz.refinedev.phoenix.handler.INetworkHandler;
|
||||
import xyz.refinedev.phoenix.handler.INotificationHandler;
|
||||
import xyz.refinedev.phoenix.handler.IPlaceholderHandler;
|
||||
import xyz.refinedev.phoenix.handler.IProfileHandler;
|
||||
import xyz.refinedev.phoenix.handler.IPunishmentHandler;
|
||||
import xyz.refinedev.phoenix.handler.IPunishmentLadderHandler;
|
||||
import xyz.refinedev.phoenix.handler.IRankHandler;
|
||||
import xyz.refinedev.phoenix.handler.IReportCategoryHandler;
|
||||
import xyz.refinedev.phoenix.handler.IReportHandler;
|
||||
import xyz.refinedev.phoenix.handler.ISecurityHandler;
|
||||
import xyz.refinedev.phoenix.handler.IServerHopHandler;
|
||||
import xyz.refinedev.phoenix.handler.ITagHandler;
|
||||
import xyz.refinedev.phoenix.handler.IWhitelistHandler;
|
||||
import xyz.refinedev.phoenix.hook.ICosmeticsHook;
|
||||
import xyz.refinedev.phoenix.hook.ILevelHook;
|
||||
import xyz.refinedev.phoenix.hook.IModUtilsHook;
|
||||
import xyz.refinedev.phoenix.packet.api.IPacketHandler;
|
||||
import xyz.refinedev.phoenix.utils.ExecuteOnMainThread;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public interface CommonPlatform {
|
||||
|
||||
boolean start(Logger logger);
|
||||
|
||||
boolean isMainThread(Thread thread);
|
||||
|
||||
void shutdown();
|
||||
|
||||
boolean isMongoDB();
|
||||
|
||||
Gson getGson();
|
||||
|
||||
Logger getLogger();
|
||||
|
||||
IDatabaseHandler getDatabaseHandler();
|
||||
|
||||
IProfileHandler getProfileHandler();
|
||||
|
||||
IRankHandler getRankHandler();
|
||||
|
||||
IHashHandler getHashHandler();
|
||||
|
||||
INetworkHandler getNetworkHandler();
|
||||
|
||||
IWhitelistHandler getWhitelistHandler();
|
||||
|
||||
IFilterHandler getFilterHandler();
|
||||
|
||||
ITagHandler getTagHandler();
|
||||
|
||||
IGrantHandler getGrantHandler();
|
||||
|
||||
IPunishmentHandler getPunishmentHandler();
|
||||
|
||||
ICooldownHandler getCooldownHandler();
|
||||
|
||||
ICommandLogHandler getCommandLogHandler();
|
||||
|
||||
INotificationHandler getNotificationHandler();
|
||||
|
||||
IChatSnapshotHandler getChatSnapshotHandler();
|
||||
|
||||
IPunishmentLadderHandler getPunishmentLadderHandler();
|
||||
|
||||
ISecurityHandler getSecurityHandler();
|
||||
|
||||
IReportHandler getReportHandler();
|
||||
|
||||
IReportCategoryHandler getReportCategoryHandler();
|
||||
|
||||
IPlaceholderHandler getPlaceholderHandler();
|
||||
|
||||
ILoginHandler getLoginHandler();
|
||||
|
||||
IAddressStatsHandler getAddressStatsHandler();
|
||||
|
||||
IAltHandler getAltHandler();
|
||||
|
||||
IServerHopHandler getServerHopHandler();
|
||||
|
||||
IChatLogHandler getChatLogHandler();
|
||||
|
||||
ICustomTagHandler getCustomTagHandler();
|
||||
|
||||
IAnalyticsHandler getAnalyticsHandler();
|
||||
|
||||
IAntiVPNHandler getAntiVPNHandler();
|
||||
|
||||
IMetricsHandler getMetricsHandler();
|
||||
|
||||
IPacketHandler getPacketHandler();
|
||||
|
||||
ConfigHandler getConfigHandler();
|
||||
|
||||
IUUIDCache getUuidCache();
|
||||
|
||||
long getStartedAt();
|
||||
|
||||
long getStoppedAt();
|
||||
|
||||
Map<String, String> getMetaData();
|
||||
|
||||
IModUtilsHook getModUtilsHook();
|
||||
|
||||
ILevelHook getLevelHook();
|
||||
|
||||
ICosmeticsHook getCosmeticsHook();
|
||||
|
||||
ExecuteOnMainThread getExecuteOnMainThread();
|
||||
|
||||
boolean isApiEnabled();
|
||||
|
||||
boolean isDebugMode();
|
||||
|
||||
boolean isUseModernPrefixes();
|
||||
|
||||
boolean isUsingMongoDB();
|
||||
|
||||
Thread getMainThread();
|
||||
|
||||
void setGson(Gson gson);
|
||||
|
||||
void setLogger(Logger logger);
|
||||
|
||||
void setPacketHandler(IPacketHandler packetHandler);
|
||||
|
||||
void setDatabaseHandler(IDatabaseHandler databaseHandler);
|
||||
|
||||
void setProfileHandler(IProfileHandler profileHandler);
|
||||
|
||||
void setRankHandler(IRankHandler rankHandler);
|
||||
|
||||
void setHashHandler(IHashHandler hashHandler);
|
||||
|
||||
void setNetworkHandler(INetworkHandler networkHandler);
|
||||
|
||||
void setWhitelistHandler(IWhitelistHandler whitelistHandler);
|
||||
|
||||
void setFilterHandler(IFilterHandler filterHandler);
|
||||
|
||||
void setTagHandler(ITagHandler tagHandler);
|
||||
|
||||
void setGrantHandler(IGrantHandler grantHandler);
|
||||
|
||||
void setPunishmentHandler(IPunishmentHandler punishmentHandler);
|
||||
|
||||
void setCooldownHandler(ICooldownHandler cooldownHandler);
|
||||
|
||||
void setCommandLogHandler(ICommandLogHandler commandLogHandler);
|
||||
|
||||
void setNotificationHandler(INotificationHandler notificationHandler);
|
||||
|
||||
void setChatSnapshotHandler(IChatSnapshotHandler chatSnapshotHandler);
|
||||
|
||||
void setPunishmentLadderHandler(IPunishmentLadderHandler punishmentLadderHandler);
|
||||
|
||||
void setSecurityHandler(ISecurityHandler securityHandler);
|
||||
|
||||
void setPlaceholderHandler(IPlaceholderHandler placeholderHandler);
|
||||
|
||||
void setLoginHandler(ILoginHandler loginHandler);
|
||||
|
||||
void setAddressStatsHandler(IAddressStatsHandler addressStatsHandler);
|
||||
|
||||
void setAltHandler(IAltHandler altHandler);
|
||||
|
||||
void setServerHopHandler(IServerHopHandler serverHopHandler);
|
||||
|
||||
void setChatLogHandler(IChatLogHandler chatLogHandler);
|
||||
|
||||
void setCustomTagHandler(ICustomTagHandler customTagHandler);
|
||||
|
||||
void setAnalyticsHandler(IAnalyticsHandler analyticsHandler);
|
||||
|
||||
void setAntiVPNHandler(IAntiVPNHandler antiVPNHandler);
|
||||
|
||||
void setMetricsHandler(IMetricsHandler metricsHandler);
|
||||
|
||||
void setConfigHandler(ConfigHandler configHandler);
|
||||
|
||||
void setUuidCache(IUUIDCache uUIDCache);
|
||||
|
||||
void setStartedAt(long value);
|
||||
|
||||
void setStoppedAt(long value);
|
||||
|
||||
void setMetaData(Map<String, String> entries);
|
||||
|
||||
void setModUtilsHook(IModUtilsHook modUtilsHook);
|
||||
|
||||
void setLevelHook(ILevelHook levelHook);
|
||||
|
||||
void setCosmeticsHook(ICosmeticsHook cosmeticsHook);
|
||||
|
||||
void setExecuteOnMainThread(ExecuteOnMainThread executeOnMainThread);
|
||||
|
||||
void setApiEnabled(boolean matches);
|
||||
|
||||
void setDebugMode(boolean matches);
|
||||
|
||||
void setUseModernPrefixes(boolean matches);
|
||||
|
||||
void setMainThread(Thread thread);
|
||||
|
||||
default boolean isFeatureFlag(String text) {
|
||||
return true;
|
||||
}
|
||||
|
||||
default void trackMetric(String text, double value) {}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,899 @@
|
||||
package xyz.refinedev.phoenix;
|
||||
|
||||
import com.google.gson.ExclusionStrategy;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.LongSerializationPolicy;
|
||||
|
||||
import xyz.refinedev.lib.config.ConfigHandler;
|
||||
import xyz.refinedev.phoenix.alt.AddressDensityBackfill;
|
||||
import xyz.refinedev.phoenix.alt.AltSignal;
|
||||
import xyz.refinedev.phoenix.alt.ClientFingerprint;
|
||||
import xyz.refinedev.phoenix.alt.IAltSignal;
|
||||
import xyz.refinedev.phoenix.alt.IClientFingerprint;
|
||||
import xyz.refinedev.phoenix.cache.api.IUUIDCache;
|
||||
import xyz.refinedev.phoenix.config.GlobalConfig;
|
||||
import xyz.refinedev.phoenix.handler.AnalyticsHandler;
|
||||
import xyz.refinedev.phoenix.handler.ChatLogHandler;
|
||||
import xyz.refinedev.phoenix.handler.ChatSnapshotHandler;
|
||||
import xyz.refinedev.phoenix.handler.CommandLogHandler;
|
||||
import xyz.refinedev.phoenix.handler.CooldownHandler;
|
||||
import xyz.refinedev.phoenix.handler.CustomTagHandler;
|
||||
import xyz.refinedev.phoenix.handler.FilterHandler;
|
||||
import xyz.refinedev.phoenix.handler.GrantHandler;
|
||||
import xyz.refinedev.phoenix.handler.HashHandler;
|
||||
import xyz.refinedev.phoenix.handler.IAddressStatsHandler;
|
||||
import xyz.refinedev.phoenix.handler.IAltHandler;
|
||||
import xyz.refinedev.phoenix.handler.IAnalyticsHandler;
|
||||
import xyz.refinedev.phoenix.handler.IAntiVPNHandler;
|
||||
import xyz.refinedev.phoenix.handler.IChatLogHandler;
|
||||
import xyz.refinedev.phoenix.handler.IChatSnapshotHandler;
|
||||
import xyz.refinedev.phoenix.handler.ICommandLogHandler;
|
||||
import xyz.refinedev.phoenix.handler.ICooldownHandler;
|
||||
import xyz.refinedev.phoenix.handler.ICustomTagHandler;
|
||||
import xyz.refinedev.phoenix.handler.IDatabaseHandler;
|
||||
import xyz.refinedev.phoenix.handler.IFilterHandler;
|
||||
import xyz.refinedev.phoenix.handler.IGrantHandler;
|
||||
import xyz.refinedev.phoenix.handler.IHashHandler;
|
||||
import xyz.refinedev.phoenix.handler.ILoginHandler;
|
||||
import xyz.refinedev.phoenix.handler.IMetricsHandler;
|
||||
import xyz.refinedev.phoenix.handler.INetworkHandler;
|
||||
import xyz.refinedev.phoenix.handler.INotificationHandler;
|
||||
import xyz.refinedev.phoenix.handler.IPlaceholderHandler;
|
||||
import xyz.refinedev.phoenix.handler.IProfileHandler;
|
||||
import xyz.refinedev.phoenix.handler.IPunishmentHandler;
|
||||
import xyz.refinedev.phoenix.handler.IPunishmentLadderHandler;
|
||||
import xyz.refinedev.phoenix.handler.IRankHandler;
|
||||
import xyz.refinedev.phoenix.handler.IReportCategoryHandler;
|
||||
import xyz.refinedev.phoenix.handler.IReportHandler;
|
||||
import xyz.refinedev.phoenix.handler.ISecurityHandler;
|
||||
import xyz.refinedev.phoenix.handler.IServerHopHandler;
|
||||
import xyz.refinedev.phoenix.handler.ITagHandler;
|
||||
import xyz.refinedev.phoenix.handler.IWhitelistHandler;
|
||||
import xyz.refinedev.phoenix.handler.LoginHandler;
|
||||
import xyz.refinedev.phoenix.handler.MetricsHandler;
|
||||
import xyz.refinedev.phoenix.handler.MongoAddressStatsHandler;
|
||||
import xyz.refinedev.phoenix.handler.MongoAltHandler;
|
||||
import xyz.refinedev.phoenix.handler.PlaceholderHandler;
|
||||
import xyz.refinedev.phoenix.handler.ProfileHandler;
|
||||
import xyz.refinedev.phoenix.handler.PunishmentHandler;
|
||||
import xyz.refinedev.phoenix.handler.PunishmentLadderHandler;
|
||||
import xyz.refinedev.phoenix.handler.RankHandler;
|
||||
import xyz.refinedev.phoenix.handler.RedisAntiVPNHandler;
|
||||
import xyz.refinedev.phoenix.handler.RedisNetworkHandler;
|
||||
import xyz.refinedev.phoenix.handler.RedisNotificationHandler;
|
||||
import xyz.refinedev.phoenix.handler.ReportCategoryHandler;
|
||||
import xyz.refinedev.phoenix.handler.ReportHandler;
|
||||
import xyz.refinedev.phoenix.handler.SecurityHandler;
|
||||
import xyz.refinedev.phoenix.handler.ServerHopHandler;
|
||||
import xyz.refinedev.phoenix.handler.TagHandler;
|
||||
import xyz.refinedev.phoenix.handler.WhitelistHandler;
|
||||
import xyz.refinedev.phoenix.handler.database.MongoDatabaseHandler;
|
||||
import xyz.refinedev.phoenix.handler.database.MySQLDatabaseHandler;
|
||||
import xyz.refinedev.phoenix.handler.database.local.LocalRedis;
|
||||
import xyz.refinedev.phoenix.hook.ICosmeticsHook;
|
||||
import xyz.refinedev.phoenix.hook.ILevelHook;
|
||||
import xyz.refinedev.phoenix.hook.IModUtilsHook;
|
||||
import xyz.refinedev.phoenix.hook.impl.CosmeticsHook;
|
||||
import xyz.refinedev.phoenix.hook.impl.LevelHook;
|
||||
import xyz.refinedev.phoenix.hook.impl.ModUtilsHook;
|
||||
import xyz.refinedev.phoenix.notification.INotification;
|
||||
import xyz.refinedev.phoenix.notification.Notification;
|
||||
import xyz.refinedev.phoenix.packet.api.IPacketHandler;
|
||||
import xyz.refinedev.phoenix.packet.api.PacketHandler;
|
||||
import xyz.refinedev.phoenix.profile.INameChange;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.profile.NameChange;
|
||||
import xyz.refinedev.phoenix.profile.RedisProfile;
|
||||
import xyz.refinedev.phoenix.profile.antivpn.AntiVPNData;
|
||||
import xyz.refinedev.phoenix.profile.antivpn.IAntiVPNData;
|
||||
import xyz.refinedev.phoenix.profile.chatsnapshot.ChatEntry;
|
||||
import xyz.refinedev.phoenix.profile.chatsnapshot.ChatLog;
|
||||
import xyz.refinedev.phoenix.profile.chatsnapshot.ChatSnapshot;
|
||||
import xyz.refinedev.phoenix.profile.chatsnapshot.IChatEntry;
|
||||
import xyz.refinedev.phoenix.profile.chatsnapshot.IChatLog;
|
||||
import xyz.refinedev.phoenix.profile.chatsnapshot.IChatSnapshot;
|
||||
import xyz.refinedev.phoenix.profile.commandlog.CommandLog;
|
||||
import xyz.refinedev.phoenix.profile.commandlog.ICommandLog;
|
||||
import xyz.refinedev.phoenix.profile.cooldown.Cooldown;
|
||||
import xyz.refinedev.phoenix.profile.cooldown.ICooldown;
|
||||
import xyz.refinedev.phoenix.profile.disguise.DisguiseData;
|
||||
import xyz.refinedev.phoenix.profile.disguise.DisguiseHistory;
|
||||
import xyz.refinedev.phoenix.profile.disguise.IDisguiseData;
|
||||
import xyz.refinedev.phoenix.profile.disguise.IDisguiseHistory;
|
||||
import xyz.refinedev.phoenix.profile.disguise.ISkin;
|
||||
import xyz.refinedev.phoenix.profile.disguise.Skin;
|
||||
import xyz.refinedev.phoenix.profile.filter.Filter;
|
||||
import xyz.refinedev.phoenix.profile.filter.IFilter;
|
||||
import xyz.refinedev.phoenix.profile.grant.Grant;
|
||||
import xyz.refinedev.phoenix.profile.grant.IGrant;
|
||||
import xyz.refinedev.phoenix.profile.hop.IServerHop;
|
||||
import xyz.refinedev.phoenix.profile.hop.ServerHop;
|
||||
import xyz.refinedev.phoenix.profile.login.ILogin;
|
||||
import xyz.refinedev.phoenix.profile.login.Login;
|
||||
import xyz.refinedev.phoenix.profile.notes.INote;
|
||||
import xyz.refinedev.phoenix.profile.notes.Note;
|
||||
import xyz.refinedev.phoenix.profile.permission.IProfilePermission;
|
||||
import xyz.refinedev.phoenix.profile.permission.ProfilePermission;
|
||||
import xyz.refinedev.phoenix.profile.punishment.IProof;
|
||||
import xyz.refinedev.phoenix.profile.punishment.IPunishment;
|
||||
import xyz.refinedev.phoenix.profile.punishment.Proof;
|
||||
import xyz.refinedev.phoenix.profile.punishment.Punishment;
|
||||
import xyz.refinedev.phoenix.profile.punishment.banwave.BanWave;
|
||||
import xyz.refinedev.phoenix.profile.punishment.banwave.BanWaveEntry;
|
||||
import xyz.refinedev.phoenix.profile.punishment.banwave.IBanWave;
|
||||
import xyz.refinedev.phoenix.profile.punishment.banwave.IBanWaveEntry;
|
||||
import xyz.refinedev.phoenix.profile.punishment.ladder.IPunishmentLadder;
|
||||
import xyz.refinedev.phoenix.profile.punishment.ladder.IPunishmentLadderType;
|
||||
import xyz.refinedev.phoenix.profile.punishment.ladder.PunishmentLadder;
|
||||
import xyz.refinedev.phoenix.profile.punishment.ladder.PunishmentLadderType;
|
||||
import xyz.refinedev.phoenix.profile.security.ISecurityUser;
|
||||
import xyz.refinedev.phoenix.profile.security.SecurityUser;
|
||||
import xyz.refinedev.phoenix.profile.tag.CustomTag;
|
||||
import xyz.refinedev.phoenix.profile.tag.ICustomTag;
|
||||
import xyz.refinedev.phoenix.profile.tag.ITag;
|
||||
import xyz.refinedev.phoenix.profile.tag.ITagCategory;
|
||||
import xyz.refinedev.phoenix.profile.tag.Tag;
|
||||
import xyz.refinedev.phoenix.profile.tag.TagCategory;
|
||||
import xyz.refinedev.phoenix.rank.IRank;
|
||||
import xyz.refinedev.phoenix.rank.Rank;
|
||||
import xyz.refinedev.phoenix.rank.permission.IPermission;
|
||||
import xyz.refinedev.phoenix.rank.permission.Permission;
|
||||
import xyz.refinedev.phoenix.report.IReport;
|
||||
import xyz.refinedev.phoenix.report.IReportCategory;
|
||||
import xyz.refinedev.phoenix.report.Report;
|
||||
import xyz.refinedev.phoenix.report.ReportCategory;
|
||||
import xyz.refinedev.phoenix.repository.impl.RedisUUIDCache;
|
||||
import xyz.refinedev.phoenix.scope.IScope;
|
||||
import xyz.refinedev.phoenix.scope.Scope;
|
||||
import xyz.refinedev.phoenix.server.IServerData;
|
||||
import xyz.refinedev.phoenix.server.IWhitelistInfo;
|
||||
import xyz.refinedev.phoenix.server.ServerData;
|
||||
import xyz.refinedev.phoenix.server.WhitelistInfo;
|
||||
import xyz.refinedev.phoenix.utils.DateUtils;
|
||||
import xyz.refinedev.phoenix.utils.ExecuteOnMainThread;
|
||||
import xyz.refinedev.phoenix.utils.GsonExclusionStrategy;
|
||||
import xyz.refinedev.phoenix.utils.gson.EnumTypeAdapterFactory;
|
||||
import xyz.refinedev.phoenix.utils.gson.OptionalTypeAdapterFactory;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Map;
|
||||
import java.util.TimeZone;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class PhoenixPlatform implements CommonPlatform {
|
||||
|
||||
public static CommonPlatform platform;
|
||||
|
||||
private Gson gson;
|
||||
|
||||
private Logger logger;
|
||||
|
||||
private IDatabaseHandler databaseHandler;
|
||||
|
||||
private ConfigHandler configHandler;
|
||||
|
||||
private IProfileHandler profileHandler;
|
||||
|
||||
private IRankHandler rankHandler;
|
||||
|
||||
private IHashHandler hashHandler;
|
||||
|
||||
private INetworkHandler networkHandler;
|
||||
|
||||
private IWhitelistHandler whitelistHandler;
|
||||
|
||||
private IFilterHandler filterHandler;
|
||||
|
||||
private ITagHandler tagHandler;
|
||||
|
||||
private IGrantHandler grantHandler;
|
||||
|
||||
private IPunishmentHandler punishmentHandler;
|
||||
|
||||
private ICooldownHandler cooldownHandler;
|
||||
|
||||
private ICommandLogHandler commandLogHandler;
|
||||
|
||||
private INotificationHandler notificationHandler;
|
||||
|
||||
private IChatSnapshotHandler chatSnapshotHandler;
|
||||
|
||||
private IPunishmentLadderHandler punishmentLadderHandler;
|
||||
|
||||
private IReportHandler reportHandler;
|
||||
|
||||
private IReportCategoryHandler reportCategoryHandler;
|
||||
|
||||
private ISecurityHandler securityHandler;
|
||||
|
||||
private IPlaceholderHandler placeholderHandler;
|
||||
|
||||
private ILoginHandler loginHandler;
|
||||
|
||||
private IAddressStatsHandler addressStatsHandler;
|
||||
|
||||
private IAltHandler altHandler;
|
||||
|
||||
private IServerHopHandler serverHopHandler;
|
||||
|
||||
private IChatLogHandler chatLogHandler;
|
||||
|
||||
private ICustomTagHandler customTagHandler;
|
||||
|
||||
private IAnalyticsHandler analyticsHandler;
|
||||
|
||||
private IAntiVPNHandler antiVPNHandler;
|
||||
|
||||
private IMetricsHandler metricsHandler;
|
||||
|
||||
private IPacketHandler packetHandler;
|
||||
|
||||
private IUUIDCache uuidCache;
|
||||
|
||||
private long startedAt = 0L;
|
||||
|
||||
private long stoppedAt = 0L;
|
||||
|
||||
private Map<String, String> metaData = new ConcurrentHashMap<>();
|
||||
|
||||
private IModUtilsHook modUtilsHook = new ModUtilsHook();
|
||||
|
||||
private ILevelHook levelHook = new LevelHook();
|
||||
|
||||
private ICosmeticsHook cosmeticsHook = new CosmeticsHook();
|
||||
|
||||
private ExecuteOnMainThread executeOnMainThread;
|
||||
|
||||
public boolean apiEnabled = false;
|
||||
|
||||
public boolean debugMode = false;
|
||||
|
||||
public boolean useModernPrefixes = false;
|
||||
|
||||
public boolean mongoDB = true;
|
||||
|
||||
private Thread mainThread;
|
||||
|
||||
@Override
|
||||
public boolean start(Logger logger2) {
|
||||
if (this.executeOnMainThread == null) {
|
||||
logger2.severe("Execute on main thread is null.");
|
||||
System.exit(0);
|
||||
return false;
|
||||
}
|
||||
this.logger = logger2;
|
||||
platform = this;
|
||||
PlatformGetter.instance = this;
|
||||
this.configHandler = new ConfigHandler(logger2);
|
||||
new GlobalConfig(this.configHandler).load();
|
||||
this.gson =
|
||||
new GsonBuilder()
|
||||
.setPrettyPrinting()
|
||||
.serializeNulls()
|
||||
.setExclusionStrategies(
|
||||
new ExclusionStrategy[] {new GsonExclusionStrategy()})
|
||||
.setLongSerializationPolicy(LongSerializationPolicy.STRING)
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(INotification.class, Notification.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(IAntiVPNData.class, AntiVPNData.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(IChatEntry.class, ChatEntry.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(IChatLog.class, ChatLog.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(IChatSnapshot.class, ChatSnapshot.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(ICommandLog.class, CommandLog.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(ICooldown.class, Cooldown.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(IDisguiseData.class, DisguiseData.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(
|
||||
IDisguiseHistory.class, DisguiseHistory.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(ISkin.class, Skin.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(IFilter.class, Filter.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(IGrant.class, Grant.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(ILogin.class, Login.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(IServerHop.class, ServerHop.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(INote.class, Note.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(INameChange.class, NameChange.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(
|
||||
IProfilePermission.class, ProfilePermission.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(
|
||||
IPunishmentLadder.class, PunishmentLadder.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(
|
||||
IPunishmentLadderType.class, PunishmentLadderType.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(IProof.class, Proof.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(IBanWave.class, BanWave.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(IBanWaveEntry.class, BanWaveEntry.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(IPunishment.class, Punishment.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(IReport.class, Report.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(
|
||||
IReportCategory.class, ReportCategory.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(ISecurityUser.class, SecurityUser.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(ICustomTag.class, CustomTag.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(ITag.class, Tag.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(ITagCategory.class, TagCategory.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(IProfile.class, RedisProfile.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(IScope.class, Scope.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(IRank.class, Rank.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(IPermission.class, Permission.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(
|
||||
IWhitelistInfo.class, WhitelistInfo.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(IServerData.class, ServerData.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(IAltSignal.class, AltSignal.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(
|
||||
IClientFingerprint.class, ClientFingerprint.class))
|
||||
.registerTypeAdapterFactory(new OptionalTypeAdapterFactory())
|
||||
.create();
|
||||
if (GlobalConfig.DATABASE.DATABASE_TYPE.equalsIgnoreCase("MySQL")) {
|
||||
this.databaseHandler = new MySQLDatabaseHandler(this);
|
||||
this.mongoDB = false;
|
||||
} else {
|
||||
this.databaseHandler = new MongoDatabaseHandler(this);
|
||||
this.mongoDB = true;
|
||||
}
|
||||
if (LocalRedis.matchesEnabled(logger2, "the REST API")) {
|
||||
return false;
|
||||
}
|
||||
if (!this.databaseHandler.enable()) {
|
||||
logger2.severe("There was an issue with the database! Disabling...");
|
||||
return false;
|
||||
}
|
||||
this.packetHandler = new PacketHandler(this);
|
||||
this.packetHandler.enable();
|
||||
this.useModernPrefixes = GlobalConfig.SERVER.USE_MODERN_RANK_PREFIX;
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(GlobalConfig.SERVER.DATE_FORMAT);
|
||||
try {
|
||||
simpleDateFormat.setTimeZone(TimeZone.getTimeZone(GlobalConfig.SERVER.TIMEZONE));
|
||||
logger2.info("TimeZone in use: " + GlobalConfig.SERVER.TIMEZONE);
|
||||
} catch (Exception exception) {
|
||||
logger2.severe("Failed to set TimeZone to: " + GlobalConfig.SERVER.TIMEZONE);
|
||||
}
|
||||
DateUtils.setDateFormat(simpleDateFormat);
|
||||
this.analyticsHandler = new AnalyticsHandler(this);
|
||||
this.whitelistHandler = new WhitelistHandler(this);
|
||||
this.rankHandler = new RankHandler(this);
|
||||
this.profileHandler = new ProfileHandler(this);
|
||||
this.networkHandler = new RedisNetworkHandler(this);
|
||||
this.analyticsHandler.cleanUp();
|
||||
this.hashHandler = new HashHandler();
|
||||
this.filterHandler = new FilterHandler(this);
|
||||
this.tagHandler = new TagHandler(this);
|
||||
this.grantHandler = new GrantHandler(this);
|
||||
this.punishmentHandler = new PunishmentHandler(this);
|
||||
this.loginHandler = new LoginHandler(this);
|
||||
this.addressStatsHandler = new MongoAddressStatsHandler(this);
|
||||
this.altHandler = new MongoAltHandler(this);
|
||||
new AddressDensityBackfill(this).initialize();
|
||||
this.serverHopHandler = new ServerHopHandler(this);
|
||||
this.cooldownHandler = new CooldownHandler();
|
||||
this.commandLogHandler = new CommandLogHandler(this);
|
||||
this.notificationHandler = new RedisNotificationHandler(this);
|
||||
this.chatSnapshotHandler = new ChatSnapshotHandler(this);
|
||||
this.punishmentLadderHandler = new PunishmentLadderHandler(this);
|
||||
this.reportCategoryHandler = new ReportCategoryHandler(this);
|
||||
this.reportHandler = new ReportHandler(this);
|
||||
this.securityHandler = new SecurityHandler(this);
|
||||
this.chatLogHandler = new ChatLogHandler(this);
|
||||
this.placeholderHandler = new PlaceholderHandler();
|
||||
this.customTagHandler = new CustomTagHandler(this);
|
||||
this.antiVPNHandler = new RedisAntiVPNHandler(this);
|
||||
this.antiVPNHandler.fetchAntiVpnBypass();
|
||||
this.metricsHandler = new MetricsHandler(this);
|
||||
this.metricsHandler.start();
|
||||
this.uuidCache = new RedisUUIDCache(this);
|
||||
this.uuidCache.loadFromCache();
|
||||
Calendar calendar;
|
||||
if ((calendar = Calendar.getInstance()).get(5) == 25 && calendar.get(2) == 11) {
|
||||
logger2.info("We at the Refine Development team wish you a merry christmas!");
|
||||
}
|
||||
this.apiEnabled = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMainThread(Thread thread) {
|
||||
return this.mainThread == null ? false : thread == this.mainThread;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
this.networkHandler.saveMetadata();
|
||||
if (this.metricsHandler != null) {
|
||||
this.metricsHandler.stop();
|
||||
}
|
||||
this.packetHandler.disable();
|
||||
this.databaseHandler.disable();
|
||||
this.apiEnabled = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMongoDB() {
|
||||
return this.mongoDB;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Gson getGson() {
|
||||
return this.gson;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Logger getLogger() {
|
||||
return this.logger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDatabaseHandler getDatabaseHandler() {
|
||||
return this.databaseHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigHandler getConfigHandler() {
|
||||
return this.configHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IProfileHandler getProfileHandler() {
|
||||
return this.profileHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRankHandler getRankHandler() {
|
||||
return this.rankHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IHashHandler getHashHandler() {
|
||||
return this.hashHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public INetworkHandler getNetworkHandler() {
|
||||
return this.networkHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWhitelistHandler getWhitelistHandler() {
|
||||
return this.whitelistHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFilterHandler getFilterHandler() {
|
||||
return this.filterHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITagHandler getTagHandler() {
|
||||
return this.tagHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGrantHandler getGrantHandler() {
|
||||
return this.grantHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPunishmentHandler getPunishmentHandler() {
|
||||
return this.punishmentHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICooldownHandler getCooldownHandler() {
|
||||
return this.cooldownHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICommandLogHandler getCommandLogHandler() {
|
||||
return this.commandLogHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public INotificationHandler getNotificationHandler() {
|
||||
return this.notificationHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IChatSnapshotHandler getChatSnapshotHandler() {
|
||||
return this.chatSnapshotHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPunishmentLadderHandler getPunishmentLadderHandler() {
|
||||
return this.punishmentLadderHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IReportHandler getReportHandler() {
|
||||
return this.reportHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IReportCategoryHandler getReportCategoryHandler() {
|
||||
return this.reportCategoryHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISecurityHandler getSecurityHandler() {
|
||||
return this.securityHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPlaceholderHandler getPlaceholderHandler() {
|
||||
return this.placeholderHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILoginHandler getLoginHandler() {
|
||||
return this.loginHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAddressStatsHandler getAddressStatsHandler() {
|
||||
return this.addressStatsHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAltHandler getAltHandler() {
|
||||
return this.altHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IServerHopHandler getServerHopHandler() {
|
||||
return this.serverHopHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IChatLogHandler getChatLogHandler() {
|
||||
return this.chatLogHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICustomTagHandler getCustomTagHandler() {
|
||||
return this.customTagHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAnalyticsHandler getAnalyticsHandler() {
|
||||
return this.analyticsHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAntiVPNHandler getAntiVPNHandler() {
|
||||
return this.antiVPNHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMetricsHandler getMetricsHandler() {
|
||||
return this.metricsHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPacketHandler getPacketHandler() {
|
||||
return this.packetHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IUUIDCache getUuidCache() {
|
||||
return this.uuidCache;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getStartedAt() {
|
||||
return this.startedAt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getStoppedAt() {
|
||||
return this.stoppedAt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getMetaData() {
|
||||
return this.metaData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IModUtilsHook getModUtilsHook() {
|
||||
return this.modUtilsHook;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILevelHook getLevelHook() {
|
||||
return this.levelHook;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICosmeticsHook getCosmeticsHook() {
|
||||
return this.cosmeticsHook;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExecuteOnMainThread getExecuteOnMainThread() {
|
||||
return this.executeOnMainThread;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isApiEnabled() {
|
||||
return this.apiEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDebugMode() {
|
||||
return this.debugMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseModernPrefixes() {
|
||||
return this.useModernPrefixes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUsingMongoDB() {
|
||||
return this.mongoDB;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Thread getMainThread() {
|
||||
return this.mainThread;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGson(Gson gson2) {
|
||||
this.gson = gson2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLogger(Logger logger2) {
|
||||
this.logger = logger2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDatabaseHandler(IDatabaseHandler databaseHandler2) {
|
||||
this.databaseHandler = databaseHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConfigHandler(ConfigHandler configHandler2) {
|
||||
this.configHandler = configHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProfileHandler(IProfileHandler profileHandler2) {
|
||||
this.profileHandler = profileHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRankHandler(IRankHandler rankHandler2) {
|
||||
this.rankHandler = rankHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHashHandler(IHashHandler hashHandler2) {
|
||||
this.hashHandler = hashHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNetworkHandler(INetworkHandler networkHandler2) {
|
||||
this.networkHandler = networkHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWhitelistHandler(IWhitelistHandler whitelistHandler2) {
|
||||
this.whitelistHandler = whitelistHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFilterHandler(IFilterHandler filterHandler2) {
|
||||
this.filterHandler = filterHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTagHandler(ITagHandler tagHandler2) {
|
||||
this.tagHandler = tagHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGrantHandler(IGrantHandler grantHandler2) {
|
||||
this.grantHandler = grantHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPunishmentHandler(IPunishmentHandler punishmentHandler2) {
|
||||
this.punishmentHandler = punishmentHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCooldownHandler(ICooldownHandler cooldownHandler2) {
|
||||
this.cooldownHandler = cooldownHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCommandLogHandler(ICommandLogHandler commandLogHandler2) {
|
||||
this.commandLogHandler = commandLogHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNotificationHandler(INotificationHandler notificationHandler2) {
|
||||
this.notificationHandler = notificationHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChatSnapshotHandler(IChatSnapshotHandler chatSnapshotHandler2) {
|
||||
this.chatSnapshotHandler = chatSnapshotHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPunishmentLadderHandler(IPunishmentLadderHandler punishmentLadderHandler2) {
|
||||
this.punishmentLadderHandler = punishmentLadderHandler2;
|
||||
}
|
||||
|
||||
public void setReportHandler(IReportHandler reportHandler2) {
|
||||
this.reportHandler = reportHandler2;
|
||||
}
|
||||
|
||||
public void setReportCategoryHandler(IReportCategoryHandler reportCategoryHandler2) {
|
||||
this.reportCategoryHandler = reportCategoryHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSecurityHandler(ISecurityHandler securityHandler2) {
|
||||
this.securityHandler = securityHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlaceholderHandler(IPlaceholderHandler placeholderHandler2) {
|
||||
this.placeholderHandler = placeholderHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLoginHandler(ILoginHandler loginHandler2) {
|
||||
this.loginHandler = loginHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAddressStatsHandler(IAddressStatsHandler addressStatsHandler2) {
|
||||
this.addressStatsHandler = addressStatsHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAltHandler(IAltHandler altHandler2) {
|
||||
this.altHandler = altHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setServerHopHandler(IServerHopHandler serverHopHandler2) {
|
||||
this.serverHopHandler = serverHopHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChatLogHandler(IChatLogHandler chatLogHandler2) {
|
||||
this.chatLogHandler = chatLogHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomTagHandler(ICustomTagHandler customTagHandler2) {
|
||||
this.customTagHandler = customTagHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAnalyticsHandler(IAnalyticsHandler analyticsHandler2) {
|
||||
this.analyticsHandler = analyticsHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAntiVPNHandler(IAntiVPNHandler antiVPNHandler2) {
|
||||
this.antiVPNHandler = antiVPNHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMetricsHandler(IMetricsHandler metricsHandler2) {
|
||||
this.metricsHandler = metricsHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPacketHandler(IPacketHandler packetHandler2) {
|
||||
this.packetHandler = packetHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUuidCache(IUUIDCache uUIDCache) {
|
||||
this.uuidCache = uUIDCache;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStartedAt(long startedAt) {
|
||||
this.startedAt = startedAt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStoppedAt(long stoppedAt) {
|
||||
this.stoppedAt = stoppedAt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMetaData(Map<String, String> entries) {
|
||||
this.metaData = entries;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setModUtilsHook(IModUtilsHook modUtilsHook2) {
|
||||
this.modUtilsHook = modUtilsHook2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLevelHook(ILevelHook levelHook2) {
|
||||
this.levelHook = levelHook2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCosmeticsHook(ICosmeticsHook cosmeticsHook2) {
|
||||
this.cosmeticsHook = cosmeticsHook2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExecuteOnMainThread(ExecuteOnMainThread executeOnMainThread2) {
|
||||
this.executeOnMainThread = executeOnMainThread2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setApiEnabled(boolean apiEnabled) {
|
||||
this.apiEnabled = apiEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDebugMode(boolean debugMode) {
|
||||
this.debugMode = debugMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUseModernPrefixes(boolean useModernPrefixes) {
|
||||
this.useModernPrefixes = useModernPrefixes;
|
||||
}
|
||||
|
||||
public void setMongoDB(boolean mongoDB) {
|
||||
this.mongoDB = mongoDB;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMainThread(Thread thread) {
|
||||
this.mainThread = thread;
|
||||
}
|
||||
|
||||
public static CommonPlatform getPlatform() {
|
||||
return platform;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package xyz.refinedev.phoenix;
|
||||
|
||||
public class PlatformGetter {
|
||||
|
||||
public static CommonPlatform instance;
|
||||
|
||||
public static CommonPlatform getInstance() {
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package xyz.refinedev.phoenix.alt;
|
||||
|
||||
public enum AddressClassification {
|
||||
UNKNOWN,
|
||||
HOUSEHOLD,
|
||||
SHARED,
|
||||
FORCED_SHARED,
|
||||
FORCED_TRUSTED
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package xyz.refinedev.phoenix.alt;
|
||||
|
||||
public class AddressDensity {
|
||||
|
||||
private final String text;
|
||||
|
||||
private final String textString;
|
||||
|
||||
private final int count;
|
||||
|
||||
private final int countCount;
|
||||
|
||||
private final int count2;
|
||||
|
||||
private final long time;
|
||||
|
||||
private boolean enabled;
|
||||
|
||||
private boolean enabledEnabled;
|
||||
|
||||
private AddressClassification addressClassification = AddressClassification.UNKNOWN;
|
||||
|
||||
public String getText() {
|
||||
return this.text;
|
||||
}
|
||||
|
||||
public String getTextString() {
|
||||
return this.textString;
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return this.count;
|
||||
}
|
||||
|
||||
public int getCountCount() {
|
||||
return this.countCount;
|
||||
}
|
||||
|
||||
public int getCount2() {
|
||||
return this.count2;
|
||||
}
|
||||
|
||||
public long getTime() {
|
||||
return this.time;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
public boolean isEnabledEnabled() {
|
||||
return this.enabledEnabled;
|
||||
}
|
||||
|
||||
public AddressClassification getAddressClassification() {
|
||||
return this.addressClassification;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public void setEnabledEnabled(boolean enabledEnabled) {
|
||||
this.enabledEnabled = enabledEnabled;
|
||||
}
|
||||
|
||||
public void setAddressClassification(AddressClassification addressClassification2) {
|
||||
this.addressClassification = addressClassification2;
|
||||
}
|
||||
|
||||
public AddressDensity(
|
||||
String text, String textString, int count, int countCount, int count2, long time) {
|
||||
this.text = text;
|
||||
this.textString = textString;
|
||||
this.count = count;
|
||||
this.countCount = countCount;
|
||||
this.count2 = count2;
|
||||
this.time = time;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
package xyz.refinedev.phoenix.alt;
|
||||
|
||||
import xyz.refinedev.lib.bson.Document;
|
||||
import xyz.refinedev.lib.mongodb.client.MongoCollection;
|
||||
import xyz.refinedev.lib.mongodb.client.MongoCursor;
|
||||
import xyz.refinedev.phoenix.CommonPlatform;
|
||||
import xyz.refinedev.phoenix.config.GlobalConfig;
|
||||
import xyz.refinedev.phoenix.handler.MongoAddressStatsHandler;
|
||||
import xyz.refinedev.phoenix.handler.database.AbstractDatabaseHandler;
|
||||
import xyz.refinedev.phoenix.handler.database.MongoDatabaseHandler;
|
||||
import xyz.refinedev.phoenix.handler.database.MySQLDatabaseHandler;
|
||||
import xyz.refinedev.phoenix.repository.IAddressStatsRepository;
|
||||
import xyz.refinedev.phoenix.utils.mysql.SQLBuilder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class AddressDensityBackfill {
|
||||
|
||||
public static final String text = "__backfill_marker__";
|
||||
|
||||
private final CommonPlatform platform;
|
||||
|
||||
public AddressDensityBackfill(CommonPlatform commonPlatform) {
|
||||
this.platform = commonPlatform;
|
||||
}
|
||||
|
||||
public void initialize() {
|
||||
if (GlobalConfig.SERVER.ALTS.ENABLED) {
|
||||
if (GlobalConfig.SERVER.ALTS.SHARED_ADDRESS.BACKFILL_ON_STARTUP) {
|
||||
if (!this.platform
|
||||
.getAddressStatsHandler()
|
||||
.getRepository()
|
||||
.fetchSync("__backfill_marker__")
|
||||
.isPresent()) {
|
||||
AddressDensityBackfill addressDensityBackfill = this;
|
||||
CompletableFuture.runAsync(
|
||||
addressDensityBackfill::initializeByPlatform,
|
||||
AbstractDatabaseHandler.DB_EXECUTOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void initializeByPlatform() {
|
||||
long now = System.currentTimeMillis();
|
||||
this.platform
|
||||
.getLogger()
|
||||
.info(
|
||||
"(Alts) Backfilling address density from login history. On a large database this runs once and may take a while.");
|
||||
try {
|
||||
int value = this.platform.isMongoDB() ? this.getLogins() : this.getCount();
|
||||
AddressStats addressStats;
|
||||
(addressStats = new AddressStats("__backfill_marker__")).setAccounts(value);
|
||||
this.platform
|
||||
.getAddressStatsHandler()
|
||||
.getRepository()
|
||||
.saveSync("__backfill_marker__", addressStats);
|
||||
this.platform
|
||||
.getLogger()
|
||||
.info(
|
||||
"(Alts) Address density backfill complete: "
|
||||
+ value
|
||||
+ " addresses and subnets in "
|
||||
+ (System.currentTimeMillis() - now)
|
||||
+ "ms.");
|
||||
} catch (Exception exception) {
|
||||
this.platform
|
||||
.getLogger()
|
||||
.log(
|
||||
Level.SEVERE,
|
||||
"(Alts) Address density backfill failed - it will retry on next startup.",
|
||||
exception);
|
||||
}
|
||||
}
|
||||
|
||||
private int getLogins() {
|
||||
MongoCollection logins = this.getDatabaseHandler().getLogins();
|
||||
return this.calculateCount(this.findMap(logins, "ip"))
|
||||
+ this.calculateCount(this.findMap(logins, "subnet"));
|
||||
}
|
||||
|
||||
private Map<String, Integer> findMap(MongoCollection<Document> mongoCollection, String text) {
|
||||
List<Document> values =
|
||||
Arrays.asList(
|
||||
new Document("$match", new Document(text, new Document("$ne", null))),
|
||||
new Document(
|
||||
"$group",
|
||||
new Document(
|
||||
"_id",
|
||||
new Document("a", "$" + text).append("t", "$target"))),
|
||||
new Document(
|
||||
"$group",
|
||||
new Document("_id", "$_id.a")
|
||||
.append("count", new Document("$sum", 1))));
|
||||
HashMap<String, Integer> entries = new HashMap<>();
|
||||
MongoCursor mongoCursor = mongoCollection.aggregate(values).allowDiskUse(true).iterator();
|
||||
while (mongoCursor.hasNext()) {
|
||||
Document document;
|
||||
Object result;
|
||||
if ((result = (document = (Document) mongoCursor.next()).get("_id"))
|
||||
instanceof String) {
|
||||
entries.put((String) result, document.getInteger("count", 0));
|
||||
}
|
||||
}
|
||||
return entries;
|
||||
}
|
||||
|
||||
private int getCount() throws Exception {
|
||||
String name = this.getDatabaseHandlerByPlatform().getLogins().getName();
|
||||
return this.calculateCount(this.findMap(name, "ip"))
|
||||
+ this.calculateCount(this.findMap(name, "subnet"));
|
||||
}
|
||||
|
||||
private Map<String, Integer> findMap(String text, String text2) throws Exception {
|
||||
HashMap<String, Integer> entries = new HashMap<>();
|
||||
SQLBuilder sQLBuilder = new SQLBuilder();
|
||||
try {
|
||||
sQLBuilder.setStatement(
|
||||
"SELECT JSON_UNQUOTE(JSON_EXTRACT(data, '$."
|
||||
+ text2
|
||||
+ "')) AS addr, COUNT(DISTINCT JSON_UNQUOTE(JSON_EXTRACT(data, '$.target'))) AS accounts FROM "
|
||||
+ text
|
||||
+ " GROUP BY addr HAVING addr IS NOT NULL");
|
||||
sQLBuilder.executeQuery();
|
||||
while (sQLBuilder.next()) {
|
||||
Object object = sQLBuilder.getObject(1);
|
||||
Object object2 = sQLBuilder.getObject(2);
|
||||
if (object instanceof String && object2 instanceof Number) {
|
||||
entries.put((String) object, ((Number) object2).intValue());
|
||||
}
|
||||
}
|
||||
} catch (Throwable throwable) {
|
||||
try {
|
||||
sQLBuilder.close();
|
||||
} catch (Throwable throwable2) {
|
||||
throwable.addSuppressed(throwable2);
|
||||
}
|
||||
throw throwable;
|
||||
}
|
||||
sQLBuilder.close();
|
||||
return entries;
|
||||
}
|
||||
|
||||
private int calculateCount(Map<String, Integer> entries) {
|
||||
IAddressStatsRepository repository = this.platform.getAddressStatsHandler().getRepository();
|
||||
int value = Math.max(100, GlobalConfig.SERVER.ALTS.SHARED_ADDRESS.BACKFILL_CHUNK_SIZE);
|
||||
int value2 = GlobalConfig.SERVER.ALTS.SHARED_ADDRESS.AUTO_CLASSIFY_AT;
|
||||
int value3 = GlobalConfig.SERVER.ALTS.SCORE.HOUSEHOLD_SIZE;
|
||||
ArrayList values = new ArrayList(entries.keySet());
|
||||
int value4 = 0;
|
||||
for (int index = 0; index < values.size(); index += value) {
|
||||
List<String> values2 = values.subList(index, Math.min(values.size(), index + value));
|
||||
Map entries2 = this.platform.getAddressStatsHandler().fetch(new HashSet<>(values2));
|
||||
for (String text : values2) {
|
||||
IAddressStats addressStats;
|
||||
if ((addressStats = (IAddressStats) entries2.get(text)) == null) {
|
||||
addressStats = new AddressStats(text);
|
||||
}
|
||||
addressStats.setAccounts((Integer) entries.get(text));
|
||||
addressStats.setClassification(
|
||||
MongoAddressStatsHandler.findAddressClassification(
|
||||
addressStats, value2, value3));
|
||||
repository.saveSync(text, addressStats);
|
||||
}
|
||||
value4 += values2.size();
|
||||
this.platform
|
||||
.getLogger()
|
||||
.info("(Alts) Backfill progress: " + value4 + "/" + values.size());
|
||||
}
|
||||
return value4;
|
||||
}
|
||||
|
||||
private MongoDatabaseHandler getDatabaseHandler() {
|
||||
return (MongoDatabaseHandler) this.platform.getDatabaseHandler();
|
||||
}
|
||||
|
||||
private MySQLDatabaseHandler getDatabaseHandlerByPlatform() {
|
||||
return (MySQLDatabaseHandler) this.platform.getDatabaseHandler();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package xyz.refinedev.phoenix.alt;
|
||||
|
||||
public final class AddressNormalizer {
|
||||
|
||||
public static final String UNKNOWN_TEXT = "unknown";
|
||||
|
||||
private AddressNormalizer() {}
|
||||
|
||||
public static String formatString(String text) {
|
||||
if (text == null || text.isEmpty()) {
|
||||
return "unknown";
|
||||
}
|
||||
if (text.indexOf(58) >= 0) {
|
||||
return formatStringByString(text);
|
||||
}
|
||||
int value;
|
||||
return (value = text.lastIndexOf(46)) <= 0 ? text : text.substring(0, value);
|
||||
}
|
||||
|
||||
private static String formatStringByString(String text) {
|
||||
int value;
|
||||
if ((value = text.indexOf("::")) >= 0) {
|
||||
String[] texts;
|
||||
String text2;
|
||||
return (texts =
|
||||
(text2 = text.substring(0, value)).isEmpty()
|
||||
? new String[0]
|
||||
: text2.split(":"))
|
||||
.length
|
||||
>= 4
|
||||
? formatString(texts, 4)
|
||||
: text2 + "::";
|
||||
} else {
|
||||
String[] texts2;
|
||||
return (texts2 = text.split(":")).length < 4 ? text : formatString(texts2, 4);
|
||||
}
|
||||
}
|
||||
|
||||
private static String formatString(String[] texts, int value) {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (int index = 0; index < value && index < texts.length; index++) {
|
||||
if (index > 0) {
|
||||
stringBuilder.append(':');
|
||||
}
|
||||
stringBuilder.append(texts[index]);
|
||||
}
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
package xyz.refinedev.phoenix.alt;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import xyz.refinedev.phoenix.profile.TrackedEntity;
|
||||
|
||||
public class AddressStats extends TrackedEntity implements IAddressStats {
|
||||
|
||||
@SerializedName("_id")
|
||||
private final String id;
|
||||
|
||||
@SerializedName("accounts")
|
||||
private int accounts;
|
||||
|
||||
@SerializedName("firstSeen")
|
||||
private long firstSeen = System.currentTimeMillis();
|
||||
|
||||
@SerializedName("lastSeen")
|
||||
private long lastSeen = System.currentTimeMillis();
|
||||
|
||||
@SerializedName("classification")
|
||||
private AddressClassification classification = AddressClassification.UNKNOWN;
|
||||
|
||||
@SerializedName("asn")
|
||||
private String asn;
|
||||
|
||||
@SerializedName("isp")
|
||||
private String isp;
|
||||
|
||||
@SerializedName("country")
|
||||
private String country;
|
||||
|
||||
@SerializedName("vpn")
|
||||
private boolean vpn;
|
||||
|
||||
@SerializedName("mobile")
|
||||
private boolean mobile;
|
||||
|
||||
public AddressStats(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAccounts() {
|
||||
return this.accounts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getFirstSeen() {
|
||||
return this.firstSeen;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLastSeen() {
|
||||
return this.lastSeen;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AddressClassification getClassification() {
|
||||
return this.classification;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAsn() {
|
||||
return this.asn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIsp() {
|
||||
return this.isp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCountry() {
|
||||
return this.country;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVpn() {
|
||||
return this.vpn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMobile() {
|
||||
return this.mobile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAccounts(int accounts) {
|
||||
this.accounts = accounts;
|
||||
}
|
||||
|
||||
public void setFirstSeen(long firstSeen) {
|
||||
this.firstSeen = firstSeen;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLastSeen(long lastSeen) {
|
||||
this.lastSeen = lastSeen;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClassification(AddressClassification addressClassification) {
|
||||
this.classification = addressClassification;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAsn(String asn) {
|
||||
this.asn = asn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsp(String isp) {
|
||||
this.isp = isp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCountry(String country) {
|
||||
this.country = country;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVpn(boolean vpn) {
|
||||
this.vpn = vpn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMobile(boolean mobile) {
|
||||
this.mobile = mobile;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,196 @@
|
||||
package xyz.refinedev.phoenix.alt;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AltEvidenceAccumulator {
|
||||
|
||||
private List<AddressDensity> addressDensities = new ArrayList<>();
|
||||
|
||||
private AddressDensity addressDensity;
|
||||
|
||||
private int count;
|
||||
|
||||
private int countCount;
|
||||
|
||||
private int count2;
|
||||
|
||||
private long time;
|
||||
|
||||
private int count3;
|
||||
|
||||
private int count4;
|
||||
|
||||
private int count5;
|
||||
|
||||
private int count6;
|
||||
|
||||
private double value;
|
||||
|
||||
private double valueValue;
|
||||
|
||||
private boolean enabled;
|
||||
|
||||
private int count7;
|
||||
|
||||
private boolean enabledEnabled;
|
||||
|
||||
private long timeTime;
|
||||
|
||||
private int count8;
|
||||
|
||||
private int count9;
|
||||
|
||||
private static final long time2 = -1L;
|
||||
|
||||
public AltEvidenceAccumulator() {
|
||||
this.time = time2;
|
||||
this.count6 = Integer.MAX_VALUE;
|
||||
this.count7 = Integer.MAX_VALUE;
|
||||
this.count9 = Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
public List<AddressDensity> getAddressDensities() {
|
||||
return this.addressDensities;
|
||||
}
|
||||
|
||||
public AddressDensity getAddressDensity() {
|
||||
return this.addressDensity;
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return this.count;
|
||||
}
|
||||
|
||||
public int getCountCount() {
|
||||
return this.countCount;
|
||||
}
|
||||
|
||||
public int getCount2() {
|
||||
return this.count2;
|
||||
}
|
||||
|
||||
public long getTime() {
|
||||
return this.time;
|
||||
}
|
||||
|
||||
public int getCount3() {
|
||||
return this.count3;
|
||||
}
|
||||
|
||||
public int getCount4() {
|
||||
return this.count4;
|
||||
}
|
||||
|
||||
public int getCount5() {
|
||||
return this.count5;
|
||||
}
|
||||
|
||||
public int getCount6() {
|
||||
return this.count6;
|
||||
}
|
||||
|
||||
public double getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public double getValueValue() {
|
||||
return this.valueValue;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
public int getCount7() {
|
||||
return this.count7;
|
||||
}
|
||||
|
||||
public boolean isEnabledEnabled() {
|
||||
return this.enabledEnabled;
|
||||
}
|
||||
|
||||
public long getTimeTime() {
|
||||
return this.timeTime;
|
||||
}
|
||||
|
||||
public int getCount8() {
|
||||
return this.count8;
|
||||
}
|
||||
|
||||
public int getCount9() {
|
||||
return this.count9;
|
||||
}
|
||||
|
||||
public void setAddressDensities(List<AddressDensity> addressDensities) {
|
||||
this.addressDensities = addressDensities;
|
||||
}
|
||||
|
||||
public void setAddressDensity(AddressDensity addressDensity2) {
|
||||
this.addressDensity = addressDensity2;
|
||||
}
|
||||
|
||||
public void setCount(int count) {
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
public void setCountCount(int countCount) {
|
||||
this.countCount = countCount;
|
||||
}
|
||||
|
||||
public void setCount2(int count2) {
|
||||
this.count2 = count2;
|
||||
}
|
||||
|
||||
public void setTime(long time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public void setCount3(int count3) {
|
||||
this.count3 = count3;
|
||||
}
|
||||
|
||||
public void setCount4(int count4) {
|
||||
this.count4 = count4;
|
||||
}
|
||||
|
||||
public void setCount5(int count5) {
|
||||
this.count5 = count5;
|
||||
}
|
||||
|
||||
public void setCount6(int count6) {
|
||||
this.count6 = count6;
|
||||
}
|
||||
|
||||
public void setValue(double value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public void setValueValue(double valueValue) {
|
||||
this.valueValue = valueValue;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public void setCount7(int count7) {
|
||||
this.count7 = count7;
|
||||
}
|
||||
|
||||
public void setEnabledEnabled(boolean enabledEnabled) {
|
||||
this.enabledEnabled = enabledEnabled;
|
||||
}
|
||||
|
||||
public void setTimeTime(long timeTime) {
|
||||
this.timeTime = timeTime;
|
||||
}
|
||||
|
||||
public void setCount8(int count8) {
|
||||
this.count8 = count8;
|
||||
}
|
||||
|
||||
public void setCount9(int count9) {
|
||||
this.count9 = count9;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,250 @@
|
||||
package xyz.refinedev.phoenix.alt;
|
||||
|
||||
import xyz.refinedev.phoenix.profile.login.ILogin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public final class AltEvidenceEvaluator {
|
||||
|
||||
private static final long time = 24L;
|
||||
|
||||
private AltEvidenceEvaluator() {}
|
||||
|
||||
public static int calculateCount(List<ILogin> values, List<ILogin> values2, long value) {
|
||||
return calculateCountByCount(values, values2, value)
|
||||
+ calculateCountByCount(values2, values, value);
|
||||
}
|
||||
|
||||
private static int calculateCountByCount(
|
||||
List<ILogin> values, List<ILogin> values2, long value) {
|
||||
long[] values3 = new long[values.size()];
|
||||
int value2 = 0;
|
||||
Iterator<ILogin> iterator2 = values.iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
ILogin login;
|
||||
if ((login = (ILogin) iterator2.next()).hasLoggedOut()) {
|
||||
values3[value2++] = login.getLogout();
|
||||
}
|
||||
}
|
||||
long[] values4 = new long[values2.size()];
|
||||
for (int index = 0; index < values2.size(); index++) {
|
||||
values4[index] = ((ILogin) values2.get(index)).getLogin();
|
||||
}
|
||||
Arrays.sort(values3, 0, value2);
|
||||
Arrays.sort(values4);
|
||||
int value3 = 0;
|
||||
int value4 = 0;
|
||||
for (int index2 = 0; index2 < value2; index2++) {
|
||||
while (value4 < values4.length && values4[value4] < values3[index2]) {
|
||||
value4++;
|
||||
}
|
||||
if (value4 < values4.length && values4[value4] - values3[index2] <= value) {
|
||||
value3++;
|
||||
}
|
||||
}
|
||||
return value3;
|
||||
}
|
||||
|
||||
public static int calculateCountByList(List<ILogin> values, List<ILogin> values2, long value) {
|
||||
long[] values3 = new long[values2.size()];
|
||||
long[] values4 = new long[values2.size()];
|
||||
for (int index = 0; index < values2.size(); index++) {
|
||||
ILogin login = (ILogin) values2.get(index);
|
||||
values3[index] = login.getLogin();
|
||||
values4[index] = login.hasLoggedOut() ? login.getLogout() : value;
|
||||
}
|
||||
Arrays.sort(values3);
|
||||
Arrays.sort(values4);
|
||||
int value2 = 0;
|
||||
Iterator<ILogin> iterator2 = values.iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
ILogin login2;
|
||||
long login3 = (login2 = (ILogin) iterator2.next()).getLogin();
|
||||
long value3 = login2.hasLoggedOut() ? login2.getLogout() : value;
|
||||
value2 += calculateCount(values3, value3) - calculateCountByCount(values4, login3);
|
||||
}
|
||||
return value2;
|
||||
}
|
||||
|
||||
private static int calculateCount(long[] values, long value) {
|
||||
int value2 = 0;
|
||||
int value3 = values.length;
|
||||
while (value2 < value3) {
|
||||
int value4 = value2 + value3 >>> 1;
|
||||
if (values[value4] < value) {
|
||||
value2 = value4 + 1;
|
||||
} else {
|
||||
value3 = value4;
|
||||
}
|
||||
}
|
||||
return value2;
|
||||
}
|
||||
|
||||
private static int calculateCountByCount(long[] values, long value) {
|
||||
int value2 = 0;
|
||||
int value3 = values.length;
|
||||
while (value2 < value3) {
|
||||
int value4 = value2 + value3 >>> 1;
|
||||
if (values[value4] <= value) {
|
||||
value2 = value4 + 1;
|
||||
} else {
|
||||
value3 = value4;
|
||||
}
|
||||
}
|
||||
return value2;
|
||||
}
|
||||
|
||||
public static double calculateValue(List<ILogin> values, List<ILogin> values2) {
|
||||
double[] values3 = findValueArray(values);
|
||||
double[] values4 = findValueArray(values2);
|
||||
return calculateValue(values3, values4);
|
||||
}
|
||||
|
||||
private static double[] findValueArray(List<ILogin> values) {
|
||||
double[] values2 = new double[24];
|
||||
Iterator<ILogin> iterator2 = values.iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
int value;
|
||||
if ((value =
|
||||
(int)
|
||||
(((ILogin) iterator2.next()).getLogin()
|
||||
/ TimeUnit.HOURS.toMillis(1L)
|
||||
% time))
|
||||
< 0) {
|
||||
value += 24;
|
||||
}
|
||||
values2[value]++;
|
||||
}
|
||||
return values2;
|
||||
}
|
||||
|
||||
private static double calculateValue(double[] values, double[] values2) {
|
||||
int value;
|
||||
if ((value = Math.min(values.length, values2.length)) == 0) {
|
||||
return 0.0;
|
||||
}
|
||||
double value2 = calculateValue(values);
|
||||
double value3 = calculateValue(values2);
|
||||
double value4 = 0.0;
|
||||
double value5 = 0.0;
|
||||
double value6 = 0.0;
|
||||
for (int index = 0; index < value; index++) {
|
||||
double value7 = values[index] - value2;
|
||||
double value8 = values2[index] - value3;
|
||||
value4 += value7 * value8;
|
||||
value5 += value7 * value7;
|
||||
value6 += value8 * value8;
|
||||
}
|
||||
return !(value5 <= 0.0) && !(value6 <= 0.0) ? value4 / Math.sqrt(value5 * value6) : 0.0;
|
||||
}
|
||||
|
||||
private static double calculateValue(double[] values) {
|
||||
double value = 0.0;
|
||||
double[] values2 = values;
|
||||
int value2 = values.length;
|
||||
for (int index = 0; index < value2; index++) {
|
||||
double value3 = values2[index];
|
||||
value += value3;
|
||||
}
|
||||
return values.length == 0 ? 0.0 : value / values.length;
|
||||
}
|
||||
|
||||
public static int calculateCount(List<Integer> values) {
|
||||
if (values != null && !values.isEmpty()) {
|
||||
ArrayList values2;
|
||||
Collections.sort(values2 = new ArrayList(values));
|
||||
return (Integer) values2.get(values2.size() / 2);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static double calculateValue(String text, String text2) {
|
||||
if (text != null && text2 != null) {
|
||||
String text3 = formatString(text.toLowerCase());
|
||||
String text4 = formatString(text2.toLowerCase());
|
||||
if (text3.isEmpty() || text4.isEmpty()) {
|
||||
return 0.0;
|
||||
} else if (text3.equals(text4)) {
|
||||
return 1.0;
|
||||
} else {
|
||||
double value = max(text3, text4);
|
||||
int value2;
|
||||
if ((value2 = calculateCountByCount(text3, text4)) >= 4) {
|
||||
double value3 = (double) value2 / Math.min(text3.length(), text4.length());
|
||||
return Math.max(value, value3);
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
private static String formatString(String text) {
|
||||
int value = 0;
|
||||
while (value < text.length()
|
||||
&& !Character.isLetterOrDigit(text.charAt(value))
|
||||
&& text.charAt(value) != '_') {
|
||||
value++;
|
||||
}
|
||||
return value == 0 ? text : text.substring(value);
|
||||
}
|
||||
|
||||
private static double max(String text, String text2) {
|
||||
int value;
|
||||
return (value = Math.max(text.length(), text2.length())) == 0
|
||||
? 1.0
|
||||
: 1.0 - (double) calculateCount(text, text2) / value;
|
||||
}
|
||||
|
||||
private static int calculateCount(String text, String text2) {
|
||||
int[] values = new int[text2.length() + 1];
|
||||
int[] values2 = new int[text2.length() + 1];
|
||||
int value = 0;
|
||||
while (value <= text2.length()) {
|
||||
values[value] = value++;
|
||||
}
|
||||
for (int index = 1; index <= text.length(); index++) {
|
||||
values2[0] = index;
|
||||
for (int index2 = 1; index2 <= text2.length(); index2++) {
|
||||
int value2 =
|
||||
values[index2 - 1]
|
||||
+ (text.charAt(index - 1) == text2.charAt(index2 - 1) ? 0 : 1);
|
||||
values2[index2] =
|
||||
Math.min(Math.min(values2[index2 - 1] + 1, values[index2] + 1), value2);
|
||||
}
|
||||
int[] values3 = values;
|
||||
values = values2;
|
||||
values2 = values3;
|
||||
}
|
||||
return values[text2.length()];
|
||||
}
|
||||
|
||||
private static int calculateCountByCount(String text, String text2) {
|
||||
int[] values = new int[text2.length() + 1];
|
||||
int[] values2 = new int[text2.length() + 1];
|
||||
int value = 0;
|
||||
for (int index = 1; index <= text.length(); index++) {
|
||||
for (int index2 = 1; index2 <= text2.length(); index2++) {
|
||||
if (text.charAt(index - 1) == text2.charAt(index2 - 1)) {
|
||||
values2[index2] = values[index2 - 1] + 1;
|
||||
value = Math.max(value, values2[index2]);
|
||||
} else {
|
||||
values2[index2] = 0;
|
||||
}
|
||||
}
|
||||
int[] values3 = values;
|
||||
values = values2;
|
||||
values2 = values3;
|
||||
Arrays.fill(values3, 0);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package xyz.refinedev.phoenix.alt;
|
||||
|
||||
public final class AltEvidenceTypes {
|
||||
|
||||
private AltEvidenceTypes() {}
|
||||
|
||||
public static boolean matchesEnabled(int value, AltLinkStatus altLinkStatus, int value2) {
|
||||
return altLinkStatus != AltLinkStatus.ACTIVE ? false : value >= value2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
package xyz.refinedev.phoenix.alt;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import xyz.refinedev.phoenix.profile.TrackedEntity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class AltLink extends TrackedEntity implements IAltLink {
|
||||
|
||||
@SerializedName("_id")
|
||||
private final String id;
|
||||
|
||||
@SerializedName("a")
|
||||
private final UUID a;
|
||||
|
||||
@SerializedName("b")
|
||||
private final UUID b;
|
||||
|
||||
@SerializedName("score")
|
||||
private int score;
|
||||
|
||||
@SerializedName("signals")
|
||||
private List<IAltSignal> signals = new ArrayList<>();
|
||||
|
||||
@SerializedName("sharedAddresses")
|
||||
private int sharedAddresses;
|
||||
|
||||
@SerializedName("independentSubnets")
|
||||
private int independentSubnets;
|
||||
|
||||
@SerializedName("lastSharedLogin")
|
||||
private long lastSharedLogin;
|
||||
|
||||
@SerializedName("firstLinked")
|
||||
private long firstLinked = System.currentTimeMillis();
|
||||
|
||||
@SerializedName("lastEvaluated")
|
||||
private long lastEvaluated = System.currentTimeMillis();
|
||||
|
||||
@SerializedName("status")
|
||||
private AltLinkStatus status = AltLinkStatus.ACTIVE;
|
||||
|
||||
public AltLink(UUID uUID, UUID uUID2) {
|
||||
boolean matches = uUID.toString().compareTo(uUID2.toString()) <= 0;
|
||||
this.a = matches ? uUID : uUID2;
|
||||
this.b = matches ? uUID2 : uUID;
|
||||
this.id = formatString(uUID, uUID2);
|
||||
}
|
||||
|
||||
public static String formatString(UUID uUID, UUID uUID2) {
|
||||
String text = uUID.toString();
|
||||
String text2 = uUID2.toString();
|
||||
return text.compareTo(text2) <= 0 ? text + ":" + text2 : text2 + ":" + text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID other(UUID uUID) {
|
||||
return this.a.equals(uUID) ? this.b : this.a;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean involves(UUID uUID) {
|
||||
return this.a.equals(uUID) || this.b.equals(uUID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getA() {
|
||||
return this.a;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getB() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getScore() {
|
||||
return this.score;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IAltSignal> getSignals() {
|
||||
return this.signals;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSharedAddresses() {
|
||||
return this.sharedAddresses;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIndependentSubnets() {
|
||||
return this.independentSubnets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLastSharedLogin() {
|
||||
return this.lastSharedLogin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getFirstLinked() {
|
||||
return this.firstLinked;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLastEvaluated() {
|
||||
return this.lastEvaluated;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AltLinkStatus getStatus() {
|
||||
return this.status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setScore(int score) {
|
||||
this.score = score;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSignals(List<IAltSignal> signals) {
|
||||
this.signals = signals;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSharedAddresses(int sharedAddresses) {
|
||||
this.sharedAddresses = sharedAddresses;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIndependentSubnets(int independentSubnets) {
|
||||
this.independentSubnets = independentSubnets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLastSharedLogin(long lastSharedLogin) {
|
||||
this.lastSharedLogin = lastSharedLogin;
|
||||
}
|
||||
|
||||
public void setFirstLinked(long firstLinked) {
|
||||
this.firstLinked = firstLinked;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLastEvaluated(long lastEvaluated) {
|
||||
this.lastEvaluated = lastEvaluated;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStatus(AltLinkStatus altLinkStatus) {
|
||||
this.status = altLinkStatus;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package xyz.refinedev.phoenix.alt;
|
||||
|
||||
public enum AltLinkStatus {
|
||||
ACTIVE,
|
||||
SUPPRESSED,
|
||||
TRUSTED
|
||||
}
|
||||
@@ -0,0 +1,383 @@
|
||||
package xyz.refinedev.phoenix.alt;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class AltScoreCalculator {
|
||||
|
||||
private static final long timeTime = 3600000L;
|
||||
|
||||
public ScoreResult create(
|
||||
AltEvidenceAccumulator altEvidenceAccumulator, AltScoringWeights altScoringWeights) {
|
||||
ArrayList<xyz.refinedev.phoenix.alt.IAltSignal> values = new ArrayList<>();
|
||||
double value = this.calculateValue(altEvidenceAccumulator, altScoringWeights, values);
|
||||
double value2 =
|
||||
this.calculateValueByTimeTime(altEvidenceAccumulator, altScoringWeights, values);
|
||||
double value3;
|
||||
if ((value3 = Math.min(altScoringWeights.getValue9(), value2)) < value2) {
|
||||
values.add(
|
||||
new AltSignal(
|
||||
"non-ip-cap",
|
||||
value3 - value2,
|
||||
"capped at "
|
||||
+ (int) altScoringWeights.getValue9()
|
||||
+ " - non-IP evidence alone cannot reach the enforce threshold"));
|
||||
}
|
||||
value =
|
||||
value
|
||||
+ value3
|
||||
- this.calculateValueByValue(
|
||||
altEvidenceAccumulator, altScoringWeights, values);
|
||||
int value4 = (int) Math.round(Math.max(0.0, Math.min(100.0, value)));
|
||||
return new ScoreResult(value4, values);
|
||||
}
|
||||
|
||||
public ScoreResult findScoreResult(
|
||||
List<AddressDensity> values,
|
||||
AddressDensity addressDensity,
|
||||
AltScoringWeights altScoringWeights) {
|
||||
AltEvidenceAccumulator altEvidenceAccumulator;
|
||||
(altEvidenceAccumulator = new AltEvidenceAccumulator()).setAddressDensities(values);
|
||||
altEvidenceAccumulator.setAddressDensity(addressDensity);
|
||||
return this.create(altEvidenceAccumulator, altScoringWeights);
|
||||
}
|
||||
|
||||
private double calculateValue(
|
||||
AltEvidenceAccumulator altEvidenceAccumulator,
|
||||
AltScoringWeights altScoringWeights,
|
||||
List<IAltSignal> values2) {
|
||||
List<xyz.refinedev.phoenix.alt.AddressDensity> addressDensities =
|
||||
altEvidenceAccumulator.getAddressDensities();
|
||||
AddressDensity addressDensity = altEvidenceAccumulator.getAddressDensity();
|
||||
double value = 0.0;
|
||||
Map<String, List<xyz.refinedev.phoenix.alt.AddressDensity>> entries = new LinkedHashMap();
|
||||
for (AddressDensity addressDensity2 : addressDensities) {
|
||||
entries.computeIfAbsent(addressDensity2.getTextString(), result -> new ArrayList<>())
|
||||
.add(addressDensity2);
|
||||
}
|
||||
double value2 = Math.max(0.0, Math.min(1.0, altScoringWeights.getValue2()));
|
||||
Iterator iterator2 = entries.values().iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
List<AddressDensity> values3;
|
||||
List values4 = values3 = (List) iterator2.next();
|
||||
values4.sort(
|
||||
Comparator.<AddressDensity>comparingDouble(
|
||||
result2 -> this.calculateValue(result2, altScoringWeights))
|
||||
.reversed());
|
||||
double value3 = 1.0;
|
||||
double value4 = 0.0;
|
||||
for (AddressDensity addressDensity3 : values3) {
|
||||
double value5 = this.calculateValue(addressDensity3, altScoringWeights) * value3;
|
||||
value4 += value5;
|
||||
values2.add(
|
||||
new AltSignal(
|
||||
"shared-address",
|
||||
value5,
|
||||
addressDensity3.getCount()
|
||||
+ " accounts seen there (x"
|
||||
+ String.format(
|
||||
"%.2f",
|
||||
this.max(addressDensity3, altScoringWeights))
|
||||
+ ")"
|
||||
+ (value3 < 1.0 ? " (pooled)" : "")));
|
||||
value3 *= value2;
|
||||
}
|
||||
if (value4 > altScoringWeights.getValue()) {
|
||||
values2.add(
|
||||
new AltSignal(
|
||||
"subnet-cap",
|
||||
altScoringWeights.getValue() - value4,
|
||||
"one subnet cannot outweigh a single clean address match"));
|
||||
value4 = altScoringWeights.getValue();
|
||||
}
|
||||
value += value4;
|
||||
}
|
||||
if (!addressDensities.isEmpty()) {
|
||||
int value6;
|
||||
if ((value6 = entries.size() - 1) > 0) {
|
||||
double value7 = altScoringWeights.getValueValue() * value6;
|
||||
value += value7;
|
||||
values2.add(
|
||||
new AltSignal(
|
||||
"multi-subnet",
|
||||
value7,
|
||||
entries.size() + " independent subnets shared"));
|
||||
}
|
||||
} else if (addressDensity != null) {
|
||||
double value8 =
|
||||
altScoringWeights.getValue3()
|
||||
* this.max(addressDensity, altScoringWeights)
|
||||
* this.maxByValue(addressDensity, altScoringWeights);
|
||||
value += value8;
|
||||
values2.add(new AltSignal("subnet-only", value8, "same subnet, no shared address"));
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
private double calculateValue(
|
||||
AddressDensity addressDensity, AltScoringWeights altScoringWeights) {
|
||||
return altScoringWeights.getValue()
|
||||
* this.max(addressDensity, altScoringWeights)
|
||||
* this.maxByValue(addressDensity, altScoringWeights)
|
||||
* this.calculateValueByValue(addressDensity, altScoringWeights);
|
||||
}
|
||||
|
||||
double max(int value, int value2) {
|
||||
int value3;
|
||||
return (double) (value3 = Math.max(1, value2)) / Math.max(value3, value);
|
||||
}
|
||||
|
||||
private double calculateValueByTimeTime(
|
||||
AltEvidenceAccumulator altEvidenceAccumulator,
|
||||
AltScoringWeights altScoringWeights,
|
||||
List<IAltSignal> values) {
|
||||
return 0.0
|
||||
+ this.calculateValue(
|
||||
values,
|
||||
"alternation",
|
||||
this.calculateValue(altEvidenceAccumulator, altScoringWeights),
|
||||
altEvidenceAccumulator.getCount() + " login handoffs")
|
||||
+ this.calculateValue(
|
||||
values,
|
||||
"ban-appearance",
|
||||
this.max(altEvidenceAccumulator, altScoringWeights),
|
||||
"first login "
|
||||
+ altEvidenceAccumulator.getTime() / timeTime
|
||||
+ "h after the other account was banned")
|
||||
+ this.calculateValue(
|
||||
values,
|
||||
"client-fingerprint",
|
||||
this.calculateValueByValue(altEvidenceAccumulator, altScoringWeights),
|
||||
altEvidenceAccumulator.getCount4()
|
||||
+ "/"
|
||||
+ altEvidenceAccumulator.getCount5()
|
||||
+ " client attributes"
|
||||
+ (altEvidenceAccumulator.getCount6() == 2147483647
|
||||
? ""
|
||||
: ", shared by "
|
||||
+ altEvidenceAccumulator.getCount6()
|
||||
+ " accounts"))
|
||||
+ this.calculateValue(
|
||||
values,
|
||||
"name-similarity",
|
||||
this.calculateValueByAltEvidenceAccumulator(
|
||||
altEvidenceAccumulator, altScoringWeights),
|
||||
String.format(
|
||||
"%.0f%% name similarity",
|
||||
altEvidenceAccumulator.getValue() * 100.0))
|
||||
+ this.calculateValue(
|
||||
values,
|
||||
"playtime-rhythm",
|
||||
this.calculateValueByAltScoringWeights(
|
||||
altEvidenceAccumulator, altScoringWeights),
|
||||
String.format(
|
||||
"%.2f play-hour correlation",
|
||||
altEvidenceAccumulator.getValueValue()))
|
||||
+ this.calculateValue(
|
||||
values,
|
||||
"skin",
|
||||
this.calculateValue2(altEvidenceAccumulator, altScoringWeights),
|
||||
"same skin, used by " + altEvidenceAccumulator.getCount7() + " accounts")
|
||||
+ this.calculateValue(
|
||||
values,
|
||||
"latency",
|
||||
this.calculateValue3(altEvidenceAccumulator, altScoringWeights),
|
||||
altEvidenceAccumulator.getTimeTime() + "ms median ping difference")
|
||||
+ this.calculateValue(
|
||||
values,
|
||||
"logout-location",
|
||||
this.calculateValue4(altEvidenceAccumulator, altScoringWeights),
|
||||
altEvidenceAccumulator.getCount8()
|
||||
+ " shared logout areas, used by "
|
||||
+ altEvidenceAccumulator.getCount9()
|
||||
+ " accounts");
|
||||
}
|
||||
|
||||
private double calculateValue(
|
||||
List<IAltSignal> values, String text, double value, String text2) {
|
||||
if (value <= 0.0) {
|
||||
return 0.0;
|
||||
}
|
||||
if (value >= 0.05) {
|
||||
values.add(new AltSignal(text, value, text2));
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
double calculateValue(
|
||||
AltEvidenceAccumulator altEvidenceAccumulator, AltScoringWeights altScoringWeights) {
|
||||
if (altEvidenceAccumulator.getCount() <= 0) {
|
||||
return 0.0;
|
||||
}
|
||||
int value = Math.max(1, altScoringWeights.getCount2());
|
||||
double value2 =
|
||||
altScoringWeights.getValue10()
|
||||
* Math.min(1.0, (double) altEvidenceAccumulator.getCount() / value);
|
||||
int value3;
|
||||
if ((value3 =
|
||||
Math.min(
|
||||
altEvidenceAccumulator.getCountCount(),
|
||||
altEvidenceAccumulator.getCount2()))
|
||||
> 0) {
|
||||
double value4 = (double) altEvidenceAccumulator.getCount() / value3;
|
||||
value2 *= Math.min(1.0, value4 / Math.max(0.01, altScoringWeights.getValue11()));
|
||||
}
|
||||
return value2;
|
||||
}
|
||||
|
||||
double max(AltEvidenceAccumulator altEvidenceAccumulator, AltScoringWeights altScoringWeights) {
|
||||
long value;
|
||||
if ((value = altEvidenceAccumulator.getTime()) < 0L) {
|
||||
return 0.0;
|
||||
}
|
||||
long value2 = Math.max(1L, altScoringWeights.getTime4());
|
||||
return value >= value2
|
||||
? 0.0
|
||||
: altScoringWeights.getValue12() * (1.0 - (double) value / value2);
|
||||
}
|
||||
|
||||
double calculateValueByValue(
|
||||
AltEvidenceAccumulator altEvidenceAccumulator,
|
||||
AltScoringWeights altScoringWeights,
|
||||
List<IAltSignal> values) {
|
||||
if (altEvidenceAccumulator.getCount3() <= 0) {
|
||||
return 0.0;
|
||||
} else if (altScoringWeights.isEnabled()
|
||||
&& altEvidenceAccumulator.getAddressDensities() != null
|
||||
&& !altEvidenceAccumulator.getAddressDensities().isEmpty()) {
|
||||
values.add(
|
||||
new AltSignal(
|
||||
"concurrent-sessions",
|
||||
0.0,
|
||||
altEvidenceAccumulator.getCount3()
|
||||
+ " overlapping sessions - not penalised, both are on a shared address"));
|
||||
return 0.0;
|
||||
} else {
|
||||
int value = Math.max(1, altScoringWeights.getCount3());
|
||||
double value2 =
|
||||
altScoringWeights.getValue13()
|
||||
* Math.min(1.0, (double) altEvidenceAccumulator.getCount3() / value);
|
||||
values.add(
|
||||
new AltSignal(
|
||||
"concurrent-sessions",
|
||||
-value2,
|
||||
altEvidenceAccumulator.getCount3()
|
||||
+ " overlapping sessions - suggests two people"));
|
||||
return value2;
|
||||
}
|
||||
}
|
||||
|
||||
double calculateValueByValue(
|
||||
AltEvidenceAccumulator altEvidenceAccumulator, AltScoringWeights altScoringWeights) {
|
||||
if (altEvidenceAccumulator.getCount5() <= 0) {
|
||||
return 0.0;
|
||||
}
|
||||
if (altEvidenceAccumulator.getCount4() <= 0) {
|
||||
return 0.0;
|
||||
}
|
||||
double value =
|
||||
(double) altEvidenceAccumulator.getCount4() / altEvidenceAccumulator.getCount5();
|
||||
return altScoringWeights.getValue14()
|
||||
* value
|
||||
* this.max(altEvidenceAccumulator.getCount6(), altScoringWeights.getCount4());
|
||||
}
|
||||
|
||||
double calculateValueByAltEvidenceAccumulator(
|
||||
AltEvidenceAccumulator altEvidenceAccumulator, AltScoringWeights altScoringWeights) {
|
||||
return this.calculateValue(
|
||||
altEvidenceAccumulator.getValue(), altScoringWeights.getValue16())
|
||||
* altScoringWeights.getValue15();
|
||||
}
|
||||
|
||||
double calculateValueByAltScoringWeights(
|
||||
AltEvidenceAccumulator altEvidenceAccumulator, AltScoringWeights altScoringWeights) {
|
||||
return this.calculateValue(
|
||||
altEvidenceAccumulator.getValueValue(), altScoringWeights.getValue18())
|
||||
* altScoringWeights.getValue17();
|
||||
}
|
||||
|
||||
double calculateValue2(
|
||||
AltEvidenceAccumulator altEvidenceAccumulator, AltScoringWeights altScoringWeights) {
|
||||
return !altEvidenceAccumulator.isEnabled()
|
||||
? 0.0
|
||||
: altScoringWeights.getValue19()
|
||||
* this.max(
|
||||
altEvidenceAccumulator.getCount7(), altScoringWeights.getCount5());
|
||||
}
|
||||
|
||||
double calculateValue3(
|
||||
AltEvidenceAccumulator altEvidenceAccumulator, AltScoringWeights altScoringWeights) {
|
||||
if (!altEvidenceAccumulator.isEnabledEnabled()) {
|
||||
return 0.0;
|
||||
}
|
||||
long value = Math.max(1L, altScoringWeights.getTime5());
|
||||
double value2 = 1.0 - (double) Math.abs(altEvidenceAccumulator.getTimeTime()) / value;
|
||||
return altScoringWeights.getValue20() * Math.max(0.0, value2);
|
||||
}
|
||||
|
||||
double calculateValue4(
|
||||
AltEvidenceAccumulator altEvidenceAccumulator, AltScoringWeights altScoringWeights) {
|
||||
if (altEvidenceAccumulator.getCount8() <= 0) {
|
||||
return 0.0;
|
||||
}
|
||||
int value = Math.max(1, altScoringWeights.getCount7());
|
||||
double value2 = Math.min(1.0, (double) altEvidenceAccumulator.getCount8() / value);
|
||||
return altScoringWeights.getValue21()
|
||||
* value2
|
||||
* this.max(altEvidenceAccumulator.getCount9(), altScoringWeights.getCount6());
|
||||
}
|
||||
|
||||
private double calculateValue(double value, double value2) {
|
||||
if (value <= value2) {
|
||||
return 0.0;
|
||||
} else {
|
||||
return value2 >= 1.0 ? 0.0 : (value - value2) / (1.0 - value2);
|
||||
}
|
||||
}
|
||||
|
||||
double max(AddressDensity addressDensity, AltScoringWeights altScoringWeights) {
|
||||
if (addressDensity.getAddressClassification() == AddressClassification.FORCED_TRUSTED) {
|
||||
return 1.0;
|
||||
}
|
||||
if (addressDensity.getAddressClassification() == AddressClassification.FORCED_SHARED) {
|
||||
return altScoringWeights.getValue6();
|
||||
}
|
||||
int value;
|
||||
double value2 =
|
||||
(double) (value = Math.max(1, altScoringWeights.getCount()))
|
||||
/ Math.max(value, addressDensity.getCount());
|
||||
if (addressDensity.isEnabled()) {
|
||||
value2 *= altScoringWeights.getValue4();
|
||||
}
|
||||
if (addressDensity.isEnabledEnabled()) {
|
||||
value2 *= altScoringWeights.getValue5();
|
||||
}
|
||||
return value2;
|
||||
}
|
||||
|
||||
double maxByValue(AddressDensity addressDensity, AltScoringWeights altScoringWeights) {
|
||||
long value = Math.max(0L, addressDensity.getTime());
|
||||
long time = altScoringWeights.getTime();
|
||||
long timeTime = altScoringWeights.getTimeTime();
|
||||
if (value <= time) {
|
||||
return 1.0;
|
||||
} else if (value < timeTime && timeTime > time) {
|
||||
double value2 = (double) (value - time) / (timeTime - time);
|
||||
return 1.0 - value2 * (1.0 - altScoringWeights.getValue7());
|
||||
} else {
|
||||
return altScoringWeights.getValue7();
|
||||
}
|
||||
}
|
||||
|
||||
double calculateValueByValue(
|
||||
AddressDensity addressDensity, AltScoringWeights altScoringWeights) {
|
||||
int value = Math.min(addressDensity.getCountCount(), addressDensity.getCount2());
|
||||
int value2 = Math.max(1, altScoringWeights.getCountCount());
|
||||
double value3 = Math.min(1.0, (double) value / value2);
|
||||
return 1.0 - (1.0 - value3) * (1.0 - this.max(addressDensity, altScoringWeights));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,386 @@
|
||||
package xyz.refinedev.phoenix.alt;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class AltScoringWeights {
|
||||
|
||||
private int count = 4;
|
||||
|
||||
private double value = 85.0;
|
||||
|
||||
private double valueValue = 25.0;
|
||||
|
||||
private double value2 = 0.5;
|
||||
|
||||
private double value3 = 15.0;
|
||||
|
||||
private double value4 = 0.05;
|
||||
|
||||
private double value5 = 0.5;
|
||||
|
||||
private double value6 = 0.02;
|
||||
|
||||
private long time = TimeUnit.DAYS.toMillis(7L);
|
||||
|
||||
private long timeTime = TimeUnit.DAYS.toMillis(90L);
|
||||
|
||||
private double value7 = 0.15;
|
||||
|
||||
private int countCount = 5;
|
||||
|
||||
private boolean enabled;
|
||||
|
||||
private long time2 = TimeUnit.HOURS.toMillis(12L);
|
||||
|
||||
private boolean enabledEnabled;
|
||||
|
||||
private double value8 = 0.6;
|
||||
|
||||
private double value9 = 60.0;
|
||||
|
||||
private double value10 = 35.0;
|
||||
|
||||
private int count2 = 5;
|
||||
|
||||
private double value11 = 0.25;
|
||||
|
||||
private long time3 = TimeUnit.MINUTES.toMillis(5L);
|
||||
|
||||
private double value12 = 20.0;
|
||||
|
||||
private long time4 = TimeUnit.DAYS.toMillis(7L);
|
||||
|
||||
private double value13 = 20.0;
|
||||
|
||||
private int count3 = 5;
|
||||
|
||||
private double value14 = 25.0;
|
||||
|
||||
private int count4 = 4;
|
||||
|
||||
private double value15 = 20.0;
|
||||
|
||||
private double value16 = 0.6;
|
||||
|
||||
private double value17 = 10.0;
|
||||
|
||||
private double value18 = 0.85;
|
||||
|
||||
private double value19 = 20.0;
|
||||
|
||||
private int count5 = 3;
|
||||
|
||||
private double value20 = 8.0;
|
||||
|
||||
private long time5 = 15L;
|
||||
|
||||
private double value21 = 25.0;
|
||||
|
||||
private int count6 = 3;
|
||||
|
||||
private int count7 = 2;
|
||||
|
||||
public int getCount() {
|
||||
return this.count;
|
||||
}
|
||||
|
||||
public double getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public double getValueValue() {
|
||||
return this.valueValue;
|
||||
}
|
||||
|
||||
public double getValue2() {
|
||||
return this.value2;
|
||||
}
|
||||
|
||||
public double getValue3() {
|
||||
return this.value3;
|
||||
}
|
||||
|
||||
public double getValue4() {
|
||||
return this.value4;
|
||||
}
|
||||
|
||||
public double getValue5() {
|
||||
return this.value5;
|
||||
}
|
||||
|
||||
public double getValue6() {
|
||||
return this.value6;
|
||||
}
|
||||
|
||||
public long getTime() {
|
||||
return this.time;
|
||||
}
|
||||
|
||||
public long getTimeTime() {
|
||||
return this.timeTime;
|
||||
}
|
||||
|
||||
public double getValue7() {
|
||||
return this.value7;
|
||||
}
|
||||
|
||||
public int getCountCount() {
|
||||
return this.countCount;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
public long getTime2() {
|
||||
return this.time2;
|
||||
}
|
||||
|
||||
public boolean isEnabledEnabled() {
|
||||
return this.enabledEnabled;
|
||||
}
|
||||
|
||||
public double getValue8() {
|
||||
return this.value8;
|
||||
}
|
||||
|
||||
public double getValue9() {
|
||||
return this.value9;
|
||||
}
|
||||
|
||||
public double getValue10() {
|
||||
return this.value10;
|
||||
}
|
||||
|
||||
public int getCount2() {
|
||||
return this.count2;
|
||||
}
|
||||
|
||||
public double getValue11() {
|
||||
return this.value11;
|
||||
}
|
||||
|
||||
public long getTime3() {
|
||||
return this.time3;
|
||||
}
|
||||
|
||||
public double getValue12() {
|
||||
return this.value12;
|
||||
}
|
||||
|
||||
public long getTime4() {
|
||||
return this.time4;
|
||||
}
|
||||
|
||||
public double getValue13() {
|
||||
return this.value13;
|
||||
}
|
||||
|
||||
public int getCount3() {
|
||||
return this.count3;
|
||||
}
|
||||
|
||||
public double getValue14() {
|
||||
return this.value14;
|
||||
}
|
||||
|
||||
public int getCount4() {
|
||||
return this.count4;
|
||||
}
|
||||
|
||||
public double getValue15() {
|
||||
return this.value15;
|
||||
}
|
||||
|
||||
public double getValue16() {
|
||||
return this.value16;
|
||||
}
|
||||
|
||||
public double getValue17() {
|
||||
return this.value17;
|
||||
}
|
||||
|
||||
public double getValue18() {
|
||||
return this.value18;
|
||||
}
|
||||
|
||||
public double getValue19() {
|
||||
return this.value19;
|
||||
}
|
||||
|
||||
public int getCount5() {
|
||||
return this.count5;
|
||||
}
|
||||
|
||||
public double getValue20() {
|
||||
return this.value20;
|
||||
}
|
||||
|
||||
public long getTime5() {
|
||||
return this.time5;
|
||||
}
|
||||
|
||||
public double getValue21() {
|
||||
return this.value21;
|
||||
}
|
||||
|
||||
public int getCount6() {
|
||||
return this.count6;
|
||||
}
|
||||
|
||||
public int getCount7() {
|
||||
return this.count7;
|
||||
}
|
||||
|
||||
public void setCount(int count) {
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
public void setValue(double value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public void setValueValue(double valueValue) {
|
||||
this.valueValue = valueValue;
|
||||
}
|
||||
|
||||
public void setValue2(double value2) {
|
||||
this.value2 = value2;
|
||||
}
|
||||
|
||||
public void setValue3(double value3) {
|
||||
this.value3 = value3;
|
||||
}
|
||||
|
||||
public void setValue4(double value4) {
|
||||
this.value4 = value4;
|
||||
}
|
||||
|
||||
public void setValue5(double value5) {
|
||||
this.value5 = value5;
|
||||
}
|
||||
|
||||
public void setValue6(double value6) {
|
||||
this.value6 = value6;
|
||||
}
|
||||
|
||||
public void setTime(long time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public void setTimeTime(long timeTime) {
|
||||
this.timeTime = timeTime;
|
||||
}
|
||||
|
||||
public void setValue7(double value7) {
|
||||
this.value7 = value7;
|
||||
}
|
||||
|
||||
public void setCountCount(int countCount) {
|
||||
this.countCount = countCount;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public void setTime2(long time2) {
|
||||
this.time2 = time2;
|
||||
}
|
||||
|
||||
public void setEnabledEnabled(boolean enabledEnabled) {
|
||||
this.enabledEnabled = enabledEnabled;
|
||||
}
|
||||
|
||||
public void setValue8(double value8) {
|
||||
this.value8 = value8;
|
||||
}
|
||||
|
||||
public void setValue9(double value9) {
|
||||
this.value9 = value9;
|
||||
}
|
||||
|
||||
public void setValue10(double value10) {
|
||||
this.value10 = value10;
|
||||
}
|
||||
|
||||
public void setCount2(int count2) {
|
||||
this.count2 = count2;
|
||||
}
|
||||
|
||||
public void setValue11(double value11) {
|
||||
this.value11 = value11;
|
||||
}
|
||||
|
||||
public void setTime3(long time3) {
|
||||
this.time3 = time3;
|
||||
}
|
||||
|
||||
public void setValue12(double value12) {
|
||||
this.value12 = value12;
|
||||
}
|
||||
|
||||
public void setTime4(long time4) {
|
||||
this.time4 = time4;
|
||||
}
|
||||
|
||||
public void setValue13(double value13) {
|
||||
this.value13 = value13;
|
||||
}
|
||||
|
||||
public void setCount3(int count3) {
|
||||
this.count3 = count3;
|
||||
}
|
||||
|
||||
public void setValue14(double value14) {
|
||||
this.value14 = value14;
|
||||
}
|
||||
|
||||
public void setCount4(int count4) {
|
||||
this.count4 = count4;
|
||||
}
|
||||
|
||||
public void setValue15(double value15) {
|
||||
this.value15 = value15;
|
||||
}
|
||||
|
||||
public void setValue16(double value16) {
|
||||
this.value16 = value16;
|
||||
}
|
||||
|
||||
public void setValue17(double value17) {
|
||||
this.value17 = value17;
|
||||
}
|
||||
|
||||
public void setValue18(double value18) {
|
||||
this.value18 = value18;
|
||||
}
|
||||
|
||||
public void setValue19(double value19) {
|
||||
this.value19 = value19;
|
||||
}
|
||||
|
||||
public void setCount5(int count5) {
|
||||
this.count5 = count5;
|
||||
}
|
||||
|
||||
public void setValue20(double value20) {
|
||||
this.value20 = value20;
|
||||
}
|
||||
|
||||
public void setTime5(long time5) {
|
||||
this.time5 = time5;
|
||||
}
|
||||
|
||||
public void setValue21(double value21) {
|
||||
this.value21 = value21;
|
||||
}
|
||||
|
||||
public void setCount6(int count6) {
|
||||
this.count6 = count6;
|
||||
}
|
||||
|
||||
public void setCount7(int count7) {
|
||||
this.count7 = count7;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package xyz.refinedev.phoenix.alt;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class AltSignal implements IAltSignal {
|
||||
|
||||
@SerializedName("name")
|
||||
private final String name;
|
||||
|
||||
@SerializedName("points")
|
||||
private final double points;
|
||||
|
||||
@SerializedName("detail")
|
||||
private final String detail;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getPoints() {
|
||||
return this.points;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDetail() {
|
||||
return this.detail;
|
||||
}
|
||||
|
||||
public AltSignal(String name, double points, String detail) {
|
||||
this.name = name;
|
||||
this.points = points;
|
||||
this.detail = detail;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package xyz.refinedev.phoenix.alt;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public final class AltSignals {
|
||||
|
||||
private AltSignals() {}
|
||||
|
||||
public static List<AddressDensity> findList(
|
||||
List<AddressDensity> values, long value, boolean matches, String text, String text2) {
|
||||
ArrayList<AddressDensity> values2 = new ArrayList<>();
|
||||
if (values != null && !values.isEmpty()) {
|
||||
if (!matches || !isEmpty(text) && !isEmpty(text2)) {
|
||||
long value2 = Math.max(0L, value);
|
||||
Iterator<xyz.refinedev.phoenix.alt.AddressDensity> iterator2 = values.iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
AddressDensity addressDensity;
|
||||
if ((addressDensity = (AddressDensity) iterator2.next()).getTime() <= value2
|
||||
&& (!matches
|
||||
|| addressDensity.getText().equals(text)
|
||||
&& addressDensity.getText().equals(text2))) {
|
||||
values2.add(addressDensity);
|
||||
}
|
||||
}
|
||||
return values2;
|
||||
} else {
|
||||
return values2;
|
||||
}
|
||||
} else {
|
||||
return values2;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isEmpty(String text) {
|
||||
return text == null || text.isEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,248 @@
|
||||
package xyz.refinedev.phoenix.alt;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ClientFingerprint implements IClientFingerprint {
|
||||
|
||||
@SerializedName("locale")
|
||||
private String locale;
|
||||
|
||||
@SerializedName("viewDistance")
|
||||
private int viewDistance = -1;
|
||||
|
||||
@SerializedName("chatVisibility")
|
||||
private int chatVisibility = -1;
|
||||
|
||||
@SerializedName("skinParts")
|
||||
private int skinParts = -1;
|
||||
|
||||
@SerializedName("mainHand")
|
||||
private int mainHand = -1;
|
||||
|
||||
@SerializedName("brand")
|
||||
private String brand;
|
||||
|
||||
@SerializedName("protocolVersion")
|
||||
private int protocolVersion = -1;
|
||||
|
||||
@SerializedName("channels")
|
||||
private List<String> channels;
|
||||
|
||||
@SerializedName("capturedAt")
|
||||
private long capturedAt = System.currentTimeMillis();
|
||||
|
||||
@Override
|
||||
public String signature() {
|
||||
return this.formatString(this.locale)
|
||||
+ "|"
|
||||
+ this.viewDistance
|
||||
+ "|"
|
||||
+ this.chatVisibility
|
||||
+ "|"
|
||||
+ this.skinParts
|
||||
+ "|"
|
||||
+ this.mainHand
|
||||
+ "|"
|
||||
+ this.formatString(this.brand)
|
||||
+ "|"
|
||||
+ this.protocolVersion
|
||||
+ "|"
|
||||
+ (this.channels == null ? "" : String.join(",", this.channels));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int comparedCount(IClientFingerprint clientFingerprint) {
|
||||
if (clientFingerprint == null) {
|
||||
return 0;
|
||||
}
|
||||
int value = 0;
|
||||
if (this.isEmpty(this.locale, clientFingerprint.getLocale())) {
|
||||
value++;
|
||||
}
|
||||
if (this.matchesEnabled(this.viewDistance, clientFingerprint.getViewDistance())) {
|
||||
value++;
|
||||
}
|
||||
if (this.matchesEnabled(this.chatVisibility, clientFingerprint.getChatVisibility())) {
|
||||
value++;
|
||||
}
|
||||
if (this.matchesEnabled(this.skinParts, clientFingerprint.getSkinParts())) {
|
||||
value++;
|
||||
}
|
||||
if (this.matchesEnabled(this.mainHand, clientFingerprint.getMainHand())) {
|
||||
value++;
|
||||
}
|
||||
if (this.isEmpty(this.brand, clientFingerprint.getBrand())) {
|
||||
value++;
|
||||
}
|
||||
if (this.matchesEnabled(this.protocolVersion, clientFingerprint.getProtocolVersion())) {
|
||||
value++;
|
||||
}
|
||||
if (this.isEmpty(this.channels, clientFingerprint.getChannels())) {
|
||||
value++;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int matchCount(IClientFingerprint clientFingerprint) {
|
||||
if (clientFingerprint == null) {
|
||||
return 0;
|
||||
}
|
||||
int value = 0;
|
||||
if (this.isEmpty(this.locale, clientFingerprint.getLocale())
|
||||
&& this.formatString(this.locale)
|
||||
.equals(this.formatString(clientFingerprint.getLocale()))) {
|
||||
value++;
|
||||
}
|
||||
if (this.matchesEnabled(this.viewDistance, clientFingerprint.getViewDistance())
|
||||
&& this.viewDistance == clientFingerprint.getViewDistance()) {
|
||||
value++;
|
||||
}
|
||||
if (this.matchesEnabled(this.chatVisibility, clientFingerprint.getChatVisibility())
|
||||
&& this.chatVisibility == clientFingerprint.getChatVisibility()) {
|
||||
value++;
|
||||
}
|
||||
if (this.matchesEnabled(this.skinParts, clientFingerprint.getSkinParts())
|
||||
&& this.skinParts == clientFingerprint.getSkinParts()) {
|
||||
value++;
|
||||
}
|
||||
if (this.matchesEnabled(this.mainHand, clientFingerprint.getMainHand())
|
||||
&& this.mainHand == clientFingerprint.getMainHand()) {
|
||||
value++;
|
||||
}
|
||||
if (this.isEmpty(this.brand, clientFingerprint.getBrand())
|
||||
&& this.formatString(this.brand)
|
||||
.equals(this.formatString(clientFingerprint.getBrand()))) {
|
||||
value++;
|
||||
}
|
||||
if (this.matchesEnabled(this.protocolVersion, clientFingerprint.getProtocolVersion())
|
||||
&& this.protocolVersion == clientFingerprint.getProtocolVersion()) {
|
||||
value++;
|
||||
}
|
||||
if (this.isEmpty(this.channels, clientFingerprint.getChannels())
|
||||
&& this.channels.equals(clientFingerprint.getChannels())) {
|
||||
value++;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return this.locale == null
|
||||
&& this.brand == null
|
||||
&& this.viewDistance == -1
|
||||
&& this.chatVisibility == -1
|
||||
&& this.skinParts == -1
|
||||
&& this.mainHand == -1
|
||||
&& this.protocolVersion == -1
|
||||
&& (this.channels == null || this.channels.isEmpty());
|
||||
}
|
||||
|
||||
private boolean isEmpty(String text, String text2) {
|
||||
return text != null && !text.isEmpty() && text2 != null && !text2.isEmpty();
|
||||
}
|
||||
|
||||
private boolean isEmpty(List<String> values, List<String> values2) {
|
||||
return values != null && !values.isEmpty() && values2 != null && !values2.isEmpty();
|
||||
}
|
||||
|
||||
private boolean matchesEnabled(int value, int value2) {
|
||||
return value != -1 && value2 != -1;
|
||||
}
|
||||
|
||||
private String formatString(String text) {
|
||||
return text == null ? "" : text.toLowerCase().trim();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLocale() {
|
||||
return this.locale;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getViewDistance() {
|
||||
return this.viewDistance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getChatVisibility() {
|
||||
return this.chatVisibility;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSkinParts() {
|
||||
return this.skinParts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMainHand() {
|
||||
return this.mainHand;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBrand() {
|
||||
return this.brand;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProtocolVersion() {
|
||||
return this.protocolVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getChannels() {
|
||||
return this.channels;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCapturedAt() {
|
||||
return this.capturedAt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocale(String locale) {
|
||||
this.locale = locale;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setViewDistance(int viewDistance) {
|
||||
this.viewDistance = viewDistance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChatVisibility(int chatVisibility) {
|
||||
this.chatVisibility = chatVisibility;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSkinParts(int skinParts) {
|
||||
this.skinParts = skinParts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMainHand(int mainHand) {
|
||||
this.mainHand = mainHand;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBrand(String brand) {
|
||||
this.brand = brand;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProtocolVersion(int protocolVersion) {
|
||||
this.protocolVersion = protocolVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChannels(List<String> channels) {
|
||||
this.channels = channels;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCapturedAt(long capturedAt) {
|
||||
this.capturedAt = capturedAt;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package xyz.refinedev.phoenix.alt;
|
||||
|
||||
public interface IAddressStats {
|
||||
|
||||
String getId();
|
||||
|
||||
int getAccounts();
|
||||
|
||||
void setAccounts(int value);
|
||||
|
||||
long getFirstSeen();
|
||||
|
||||
long getLastSeen();
|
||||
|
||||
void setLastSeen(long value);
|
||||
|
||||
AddressClassification getClassification();
|
||||
|
||||
void setClassification(AddressClassification addressClassification);
|
||||
|
||||
String getAsn();
|
||||
|
||||
void setAsn(String text);
|
||||
|
||||
String getIsp();
|
||||
|
||||
void setIsp(String text);
|
||||
|
||||
String getCountry();
|
||||
|
||||
void setCountry(String text);
|
||||
|
||||
boolean isVpn();
|
||||
|
||||
void setVpn(boolean matches);
|
||||
|
||||
boolean isMobile();
|
||||
|
||||
void setMobile(boolean matches);
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package xyz.refinedev.phoenix.alt;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface IAltLink {
|
||||
|
||||
String getId();
|
||||
|
||||
UUID getA();
|
||||
|
||||
UUID getB();
|
||||
|
||||
int getScore();
|
||||
|
||||
void setScore(int value);
|
||||
|
||||
List<IAltSignal> getSignals();
|
||||
|
||||
void setSignals(List<IAltSignal> values);
|
||||
|
||||
int getSharedAddresses();
|
||||
|
||||
void setSharedAddresses(int value);
|
||||
|
||||
int getIndependentSubnets();
|
||||
|
||||
void setIndependentSubnets(int value);
|
||||
|
||||
long getLastSharedLogin();
|
||||
|
||||
void setLastSharedLogin(long value);
|
||||
|
||||
long getFirstLinked();
|
||||
|
||||
long getLastEvaluated();
|
||||
|
||||
void setLastEvaluated(long value);
|
||||
|
||||
AltLinkStatus getStatus();
|
||||
|
||||
void setStatus(AltLinkStatus altLinkStatus);
|
||||
|
||||
UUID other(UUID uUID);
|
||||
|
||||
boolean involves(UUID uUID);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package xyz.refinedev.phoenix.alt;
|
||||
|
||||
public interface IAltSignal {
|
||||
|
||||
String getName();
|
||||
|
||||
double getPoints();
|
||||
|
||||
String getDetail();
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package xyz.refinedev.phoenix.alt;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IClientFingerprint {
|
||||
|
||||
int UNSET = -1;
|
||||
|
||||
String getLocale();
|
||||
|
||||
void setLocale(String text);
|
||||
|
||||
int getViewDistance();
|
||||
|
||||
void setViewDistance(int value);
|
||||
|
||||
int getChatVisibility();
|
||||
|
||||
void setChatVisibility(int value);
|
||||
|
||||
int getSkinParts();
|
||||
|
||||
void setSkinParts(int value);
|
||||
|
||||
int getMainHand();
|
||||
|
||||
void setMainHand(int value);
|
||||
|
||||
String getBrand();
|
||||
|
||||
void setBrand(String text);
|
||||
|
||||
int getProtocolVersion();
|
||||
|
||||
void setProtocolVersion(int value);
|
||||
|
||||
long getCapturedAt();
|
||||
|
||||
void setCapturedAt(long value);
|
||||
|
||||
List<String> getChannels();
|
||||
|
||||
void setChannels(List<String> values);
|
||||
|
||||
String signature();
|
||||
|
||||
int comparedCount(IClientFingerprint clientFingerprint);
|
||||
|
||||
int matchCount(IClientFingerprint clientFingerprint);
|
||||
|
||||
boolean isEmpty();
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package xyz.refinedev.phoenix.alt;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IScoreResult {
|
||||
|
||||
int getScore();
|
||||
|
||||
List<IAltSignal> getSignals();
|
||||
}
|
||||
@@ -0,0 +1,207 @@
|
||||
package xyz.refinedev.phoenix.alt;
|
||||
|
||||
import xyz.refinedev.phoenix.CommonPlatform;
|
||||
import xyz.refinedev.phoenix.PlatformGetter;
|
||||
import xyz.refinedev.phoenix.handler.database.MySQLDatabaseHandler;
|
||||
import xyz.refinedev.phoenix.profile.login.ILogin;
|
||||
import xyz.refinedev.phoenix.profile.login.Login;
|
||||
import xyz.refinedev.phoenix.utils.mysql.SQLBuilder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class LoginIndexMigration {
|
||||
|
||||
private final CommonPlatform platform;
|
||||
|
||||
private volatile boolean enabled;
|
||||
|
||||
public LoginIndexMigration(CommonPlatform commonPlatform) {
|
||||
this.platform = commonPlatform;
|
||||
}
|
||||
|
||||
public void initialize() {
|
||||
String name = this.getDatabaseHandler().getLogins().getName();
|
||||
String name2 = this.getDatabaseHandler().getAltLinks().getName();
|
||||
try {
|
||||
if (!this.matchesEnabled(name, "ip")) {
|
||||
this.platform
|
||||
.getLogger()
|
||||
.info(
|
||||
"(Alts) Adding indexed login columns to "
|
||||
+ name
|
||||
+ ". On a large table this runs once and may take a while.");
|
||||
SQLBuilder sQLBuilder = new SQLBuilder();
|
||||
try {
|
||||
sQLBuilder.setStatement(
|
||||
"ALTER TABLE "
|
||||
+ name
|
||||
+ " ADD COLUMN ip VARCHAR(96) GENERATED ALWAYS AS (JSON_UNQUOTE(JSON_EXTRACT(data, '$.ip'))) VIRTUAL, ADD COLUMN target VARCHAR(64) GENERATED ALWAYS AS (JSON_UNQUOTE(JSON_EXTRACT(data, '$.target'))) VIRTUAL, ADD INDEX pxlogins_ip (ip), ADD INDEX pxlogins_target (target)");
|
||||
sQLBuilder.executeUpdate();
|
||||
} catch (Throwable throwable) {
|
||||
try {
|
||||
sQLBuilder.close();
|
||||
} catch (Throwable throwable2) {
|
||||
throwable.addSuppressed(throwable2);
|
||||
}
|
||||
throw throwable;
|
||||
}
|
||||
sQLBuilder.close();
|
||||
this.platform.getLogger().info("(Alts) Indexed login columns ready.");
|
||||
}
|
||||
if (!this.matchesEnabled(name2, "a")) {
|
||||
SQLBuilder sQLBuilder2 = new SQLBuilder();
|
||||
try {
|
||||
sQLBuilder2.setStatement(
|
||||
"ALTER TABLE "
|
||||
+ name2
|
||||
+ " ADD COLUMN a VARCHAR(36) GENERATED ALWAYS AS (JSON_UNQUOTE(JSON_EXTRACT(data, '$.a'))) VIRTUAL, ADD COLUMN b VARCHAR(36) GENERATED ALWAYS AS (JSON_UNQUOTE(JSON_EXTRACT(data, '$.b'))) VIRTUAL, ADD INDEX pxaltLinks_a (a), ADD INDEX pxaltLinks_b (b)");
|
||||
sQLBuilder2.executeUpdate();
|
||||
} catch (Throwable throwable3) {
|
||||
try {
|
||||
sQLBuilder2.close();
|
||||
} catch (Throwable throwable4) {
|
||||
throwable3.addSuppressed(throwable4);
|
||||
}
|
||||
throw throwable3;
|
||||
}
|
||||
sQLBuilder2.close();
|
||||
}
|
||||
this.enabled = true;
|
||||
} catch (Exception exception) {
|
||||
this.platform
|
||||
.getLogger()
|
||||
.log(
|
||||
Level.WARNING,
|
||||
"(Alts) Could not add indexed columns - alt queries will run unindexed.",
|
||||
exception);
|
||||
}
|
||||
}
|
||||
|
||||
public List<ILogin> findList(String text, Collection<String> values) {
|
||||
if (this.enabled && !values.isEmpty()) {
|
||||
String name = this.getDatabaseHandler().getLogins().getName();
|
||||
try {
|
||||
SQLBuilder sQLBuilder = new SQLBuilder();
|
||||
ArrayList<ILogin> values2;
|
||||
try {
|
||||
sQLBuilder.setStatement(
|
||||
"SELECT data FROM "
|
||||
+ name
|
||||
+ " WHERE "
|
||||
+ text
|
||||
+ " IN ("
|
||||
+ this.append(values.size())
|
||||
+ ")");
|
||||
sQLBuilder.executeQuery(values.toArray());
|
||||
ArrayList<ILogin> values3 = new ArrayList<>();
|
||||
while (sQLBuilder.next()) {
|
||||
ILogin login;
|
||||
if ((login = this.findObject(sQLBuilder, Login.class)) != null) {
|
||||
values3.add(login);
|
||||
}
|
||||
}
|
||||
values2 = values3;
|
||||
} catch (Throwable throwable) {
|
||||
try {
|
||||
sQLBuilder.close();
|
||||
} catch (Throwable throwable2) {
|
||||
throwable.addSuppressed(throwable2);
|
||||
}
|
||||
throw throwable;
|
||||
}
|
||||
sQLBuilder.close();
|
||||
return values2;
|
||||
} catch (Exception exception) {
|
||||
this.platform
|
||||
.getLogger()
|
||||
.log(
|
||||
Level.WARNING,
|
||||
"(Alts) Indexed login query failed, falling back to filters.",
|
||||
exception);
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public List<IAltLink> findList(UUID uUID) {
|
||||
if (!this.enabled) {
|
||||
return null;
|
||||
}
|
||||
String name = this.getDatabaseHandler().getAltLinks().getName();
|
||||
try {
|
||||
SQLBuilder sQLBuilder = new SQLBuilder();
|
||||
ArrayList<IAltLink> values;
|
||||
try {
|
||||
sQLBuilder.setStatement("SELECT data FROM " + name + " WHERE a = ? OR b = ?");
|
||||
sQLBuilder.executeQuery(uUID.toString(), uUID.toString());
|
||||
ArrayList<xyz.refinedev.phoenix.alt.IAltLink> values2 = new ArrayList<>();
|
||||
while (sQLBuilder.next()) {
|
||||
IAltLink altLink;
|
||||
if ((altLink = this.findObject(sQLBuilder, AltLink.class)) != null) {
|
||||
values2.add(altLink);
|
||||
}
|
||||
}
|
||||
values = values2;
|
||||
} catch (Throwable throwable) {
|
||||
try {
|
||||
sQLBuilder.close();
|
||||
} catch (Throwable throwable2) {
|
||||
throwable.addSuppressed(throwable2);
|
||||
}
|
||||
throw throwable;
|
||||
}
|
||||
sQLBuilder.close();
|
||||
return values;
|
||||
} catch (Exception exception) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private <T> T findObject(SQLBuilder sQLBuilder, Class<T> classValue) throws Exception {
|
||||
return (T)
|
||||
PlatformGetter.getInstance()
|
||||
.getGson()
|
||||
.fromJson(String.valueOf(sQLBuilder.getObject(1)), classValue);
|
||||
}
|
||||
|
||||
private String append(int value) {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (int index = 0; index < value; index++) {
|
||||
if (index > 0) {
|
||||
stringBuilder.append(',');
|
||||
}
|
||||
stringBuilder.append('?');
|
||||
}
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
private boolean matchesEnabled(String text, String text2) throws Exception {
|
||||
SQLBuilder sQLBuilder = new SQLBuilder();
|
||||
boolean matches;
|
||||
try {
|
||||
sQLBuilder.setStatement(
|
||||
"SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = ? AND COLUMN_NAME = ?");
|
||||
sQLBuilder.executeQuery(text, text2);
|
||||
matches = sQLBuilder.next() && ((Number) sQLBuilder.getObject(1)).intValue() > 0;
|
||||
} catch (Throwable throwable) {
|
||||
try {
|
||||
sQLBuilder.close();
|
||||
} catch (Throwable throwable2) {
|
||||
throwable.addSuppressed(throwable2);
|
||||
}
|
||||
throw throwable;
|
||||
}
|
||||
sQLBuilder.close();
|
||||
return matches;
|
||||
}
|
||||
|
||||
private MySQLDatabaseHandler getDatabaseHandler() {
|
||||
return (MySQLDatabaseHandler) this.platform.getDatabaseHandler();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package xyz.refinedev.phoenix.alt;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ScoreResult implements IScoreResult {
|
||||
|
||||
private final int score;
|
||||
|
||||
private final List<IAltSignal> signals;
|
||||
|
||||
@Override
|
||||
public int getScore() {
|
||||
return this.score;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IAltSignal> getSignals() {
|
||||
return this.signals;
|
||||
}
|
||||
|
||||
public ScoreResult(int score, List<IAltSignal> signals) {
|
||||
this.score = score;
|
||||
this.signals = signals;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package xyz.refinedev.phoenix.antivpn.api;
|
||||
|
||||
import xyz.refinedev.lib.jetbrains.Nullable;
|
||||
import xyz.refinedev.phoenix.profile.antivpn.IAntiVPNData;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public interface IAntiVPNProvider {
|
||||
|
||||
@Nullable
|
||||
IAntiVPNData check(UUID uUID, String text);
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package xyz.refinedev.phoenix.antivpn.api.impl;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import xyz.refinedev.phoenix.CommonPlatform;
|
||||
import xyz.refinedev.phoenix.antivpn.api.IAntiVPNProvider;
|
||||
import xyz.refinedev.phoenix.profile.antivpn.AntiVPNData;
|
||||
import xyz.refinedev.phoenix.profile.antivpn.IAntiVPNData;
|
||||
import xyz.refinedev.phoenix.utils.HttpUtils;
|
||||
import xyz.refinedev.phoenix.utils.JsonParser;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class AntiVPNProvider implements IAntiVPNProvider {
|
||||
|
||||
private final CommonPlatform platform;
|
||||
|
||||
private final String text;
|
||||
|
||||
@Override
|
||||
public IAntiVPNData check(UUID uUID, String text2) {
|
||||
String text3 = this.platform.getHashHandler().hash(text2);
|
||||
String text4;
|
||||
if ((text4 =
|
||||
HttpUtils.get(
|
||||
"https://proxycheck.io/v2/"
|
||||
+ text2
|
||||
+ "?key="
|
||||
+ this.text
|
||||
+ "&vpn=1&asn=1"))
|
||||
== null) {
|
||||
return null;
|
||||
}
|
||||
JsonObject jsonObject;
|
||||
boolean matches =
|
||||
(jsonObject =
|
||||
JsonParser.findJsonElement(text4)
|
||||
.getAsJsonObject()
|
||||
.getAsJsonObject(text2))
|
||||
.get("proxy")
|
||||
.getAsString()
|
||||
.equalsIgnoreCase("yes")
|
||||
|| jsonObject.get("type").getAsString().equalsIgnoreCase("VPN");
|
||||
AntiVPNData antiVPNData;
|
||||
(antiVPNData = new AntiVPNData(uUID, text3)).setCity(jsonObject.get("city").getAsString());
|
||||
antiVPNData.setIsp(jsonObject.get("provider").getAsString());
|
||||
antiVPNData.setCountry(jsonObject.get("country").getAsString());
|
||||
antiVPNData.setRegion(jsonObject.get("continent").getAsString());
|
||||
antiVPNData.setVpn(matches);
|
||||
antiVPNData.setMobile(
|
||||
jsonObject.has("type")
|
||||
&& jsonObject.get("type").getAsString().equalsIgnoreCase("Mobile"));
|
||||
return antiVPNData;
|
||||
}
|
||||
|
||||
public AntiVPNProvider(CommonPlatform commonPlatform, String text) {
|
||||
this.platform = commonPlatform;
|
||||
this.text = text;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package xyz.refinedev.phoenix.antivpn.provider;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import xyz.refinedev.phoenix.CommonPlatform;
|
||||
import xyz.refinedev.phoenix.antivpn.api.IAntiVPNProvider;
|
||||
import xyz.refinedev.phoenix.profile.antivpn.AntiVPNData;
|
||||
import xyz.refinedev.phoenix.profile.antivpn.IAntiVPNData;
|
||||
import xyz.refinedev.phoenix.utils.HttpUtils;
|
||||
import xyz.refinedev.phoenix.utils.JsonParser;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class IpRiskProvider implements IAntiVPNProvider {
|
||||
|
||||
private final CommonPlatform platform;
|
||||
|
||||
@Override
|
||||
public IAntiVPNData check(UUID uUID, String text) {
|
||||
String text2 = this.platform.getHashHandler().hash(text);
|
||||
String text3;
|
||||
if ((text3 = HttpUtils.get("https://beta.iprisk.info/v1/" + text)) == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
JsonObject jsonObject;
|
||||
boolean matches =
|
||||
(jsonObject = JsonParser.findJsonElement(text3).getAsJsonObject())
|
||||
.get("data_center")
|
||||
.getAsBoolean()
|
||||
|| jsonObject.get("public_proxy").getAsBoolean()
|
||||
|| jsonObject.get("tor_exit_relay").getAsBoolean();
|
||||
AntiVPNData antiVPNData;
|
||||
(antiVPNData = new AntiVPNData(uUID, text2))
|
||||
.setCity(
|
||||
jsonObject.get("city_name") != null
|
||||
? jsonObject.get("city_name").getAsString()
|
||||
: "N/A");
|
||||
antiVPNData.setIsp(
|
||||
jsonObject.get("autonomous_system_organization") != null
|
||||
? jsonObject.get("autonomous_system_organization").getAsString()
|
||||
: "N/A");
|
||||
antiVPNData.setCountry(
|
||||
jsonObject.get("country_name") != null
|
||||
? jsonObject.get("country_name").getAsString()
|
||||
: "N/A");
|
||||
antiVPNData.setRegion(
|
||||
jsonObject.get("region_name") != null
|
||||
? jsonObject.get("region_name").getAsString()
|
||||
: "N/A");
|
||||
antiVPNData.setVpn(matches);
|
||||
return antiVPNData;
|
||||
} catch (Exception exception) {
|
||||
this.platform
|
||||
.getLogger()
|
||||
.log(
|
||||
Level.SEVERE,
|
||||
"There was an error while performing the AntiVPN Check: ",
|
||||
exception);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public IpRiskProvider(CommonPlatform commonPlatform) {
|
||||
this.platform = commonPlatform;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package xyz.refinedev.phoenix.cache.api;
|
||||
|
||||
import xyz.refinedev.lib.jetbrains.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface IUUIDCache {
|
||||
|
||||
Map<String, UUID> nameToUuid = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
||||
|
||||
Map<UUID, String> uuidToName = new HashMap<>();
|
||||
|
||||
void loadFromCache();
|
||||
|
||||
@Nullable
|
||||
default UUID getUuidNoMojang(String text) {
|
||||
return nameToUuid.get(text);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
default String getName(UUID uUID) {
|
||||
return uuidToName.get(uUID);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
default String getNameFromString(String text) {
|
||||
try {
|
||||
return this.getName(UUID.fromString(text));
|
||||
} catch (Exception exception) {
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
default UUID getUuid(String text) {
|
||||
return text.toLowerCase().contains("uuid") ? nameToUuid.get(text) : null;
|
||||
}
|
||||
|
||||
void addToCache(UUID uUID, String text, boolean matches);
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package xyz.refinedev.phoenix.chat;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Named;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Optional;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Text;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.phoenix.BukkitAPI;
|
||||
import xyz.refinedev.phoenix.CommonPlatform;
|
||||
import xyz.refinedev.phoenix.chat.api.ChatChannelType;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
|
||||
public class ChatChannelUtils {
|
||||
|
||||
private final CommonPlatform platform;
|
||||
|
||||
private final ChatChannelType chatChannelType;
|
||||
|
||||
@Command(name = "")
|
||||
public void execute(@Sender Player player, @Optional @Named("message") @Text String text) {
|
||||
IProfile cachedProfile =
|
||||
this.platform.getProfileHandler().getCachedProfile(player.getUniqueId());
|
||||
if (text == null) {
|
||||
if (cachedProfile
|
||||
.getSetting("channel", "Default")
|
||||
.equalsIgnoreCase(this.chatChannelType.getName())) {
|
||||
cachedProfile.updateMetadata("channel", "Default", true);
|
||||
} else {
|
||||
cachedProfile.updateMetadata("channel", this.chatChannelType.getName(), true);
|
||||
}
|
||||
player.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(player, MessageConfig.GENERAL.CHANNEL_SWITCHED)
|
||||
.replace(
|
||||
"<channel>",
|
||||
cachedProfile.getSetting("channel", "Default"))));
|
||||
} else {
|
||||
BukkitAPI.sendGlobalChatChannel(cachedProfile, this.chatChannelType, text);
|
||||
}
|
||||
}
|
||||
|
||||
public ChatChannelUtils(CommonPlatform commonPlatform, ChatChannelType chatChannelType2) {
|
||||
this.platform = commonPlatform;
|
||||
this.chatChannelType = chatChannelType2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package xyz.refinedev.phoenix.chat.api;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public abstract class ChatChannelType {
|
||||
|
||||
public abstract String getName();
|
||||
|
||||
public abstract boolean canSendMessage(Player player);
|
||||
|
||||
public abstract int getPriority();
|
||||
|
||||
public abstract String getFormat();
|
||||
|
||||
public abstract boolean canReceiveMessage(UUID uUID, Player player);
|
||||
|
||||
public boolean isGlobal() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isStaff() {
|
||||
return this.isGlobal();
|
||||
}
|
||||
|
||||
public String getPermission() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getQuickAccessPrefix() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package xyz.refinedev.phoenix.chat.api;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
public class ChatLimitation {
|
||||
|
||||
private final String name;
|
||||
|
||||
private final int priority;
|
||||
|
||||
private final BiFunction<Player, String, Boolean> function;
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public int getPriority() {
|
||||
return this.priority;
|
||||
}
|
||||
|
||||
public BiFunction<Player, String, Boolean> getFunction() {
|
||||
return this.function;
|
||||
}
|
||||
|
||||
public ChatLimitation(
|
||||
String name, int priority, BiFunction<Player, String, Boolean> biFunction) {
|
||||
this.name = name;
|
||||
this.priority = priority;
|
||||
this.function = biFunction;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package xyz.refinedev.phoenix.chat.channel;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.chat.api.ChatChannelType;
|
||||
import xyz.refinedev.phoenix.config.SettingsConfig;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class AdminChatChannel extends ChatChannelType {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Admin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSendMessage(Player player) {
|
||||
return !Phoenix.getInstance()
|
||||
.getProfileHandler()
|
||||
.getCachedProfile(player.getUniqueId())
|
||||
.isSetting("staff-messages")
|
||||
? false
|
||||
: player.hasPermission("core.adminchat");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return 30;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFormat() {
|
||||
return Color.translate(SettingsConfig.FORMATS.ADMIN_CHAT_FORMAT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceiveMessage(UUID uUID, Player player) {
|
||||
return !Phoenix.getInstance()
|
||||
.getProfileHandler()
|
||||
.getCachedProfile(player.getUniqueId())
|
||||
.isSetting("staff-messages")
|
||||
? false
|
||||
: player.hasPermission("core.adminchat");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGlobal() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "core.adminchat";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQuickAccessPrefix() {
|
||||
return SettingsConfig.QUICK_ACCESS_PREFIXES.ADMIN_CHAT;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package xyz.refinedev.phoenix.chat.channel;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.chat.api.ChatChannelType;
|
||||
import xyz.refinedev.phoenix.config.SettingsConfig;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class BuilderChatChannel extends ChatChannelType {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Builder";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSendMessage(Player player) {
|
||||
return !Phoenix.getInstance()
|
||||
.getProfileHandler()
|
||||
.getCachedProfile(player.getUniqueId())
|
||||
.isSetting("staff-messages")
|
||||
? false
|
||||
: player.hasPermission("core.builderchat");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFormat() {
|
||||
return Color.translate(SettingsConfig.FORMATS.BUILDER_CHAT_FORMAT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceiveMessage(UUID uUID, Player player) {
|
||||
return !Phoenix.getInstance()
|
||||
.getProfileHandler()
|
||||
.getCachedProfile(player.getUniqueId())
|
||||
.isSetting("staff-messages")
|
||||
? false
|
||||
: player.hasPermission("core.builderchat");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGlobal() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "core.builderchat";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQuickAccessPrefix() {
|
||||
return SettingsConfig.QUICK_ACCESS_PREFIXES.BUILD_CHAT;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package xyz.refinedev.phoenix.chat.channel;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.chat.api.ChatChannelType;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.config.SettingsConfig;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class DefaultChatChannel extends ChatChannelType {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Default";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSendMessage(Player player) {
|
||||
IProfile profile;
|
||||
if ((profile =
|
||||
Phoenix.getInstance()
|
||||
.getProfileHandler()
|
||||
.getCachedProfile(player.getUniqueId()))
|
||||
== null) {
|
||||
Phoenix.getInstance()
|
||||
.getLogger()
|
||||
.warning(player.getName() + " tried to chat, but there is no profile cached.");
|
||||
return false;
|
||||
} else if (!profile.isSetting("global-chat")) {
|
||||
player.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(player, MessageConfig.ERROR.GLOBAL_CHAT_DISABLED)));
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFormat() {
|
||||
return Color.translate(SettingsConfig.FORMATS.CHAT_FORMAT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceiveMessage(UUID uUID, Player player) {
|
||||
IProfile profile;
|
||||
if ((profile = Phoenix.getInstance().getProfileHandler().getCachedProfile(uUID)) == null) {
|
||||
Phoenix.getInstance()
|
||||
.getLogger()
|
||||
.warning(uUID + " tried to chat, but there is no profile cached.");
|
||||
return false;
|
||||
} else {
|
||||
IProfile profile2;
|
||||
if ((profile2 =
|
||||
Phoenix.getInstance()
|
||||
.getProfileHandler()
|
||||
.getCachedProfile(player.getUniqueId()))
|
||||
== null) {
|
||||
Phoenix.getInstance()
|
||||
.getLogger()
|
||||
.warning(
|
||||
"The recipient '"
|
||||
+ player.getName()
|
||||
+ "' of a chat message has a null profile.");
|
||||
return false;
|
||||
} else if (profile.checkPermission("core.globalchat.bypass", false)) {
|
||||
return true;
|
||||
} else {
|
||||
return profile2.getIgnoring().contains(uUID)
|
||||
? false
|
||||
: profile2.isSetting("global-chat");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package xyz.refinedev.phoenix.chat.channel;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.chat.api.ChatChannelType;
|
||||
import xyz.refinedev.phoenix.config.SettingsConfig;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class ManagementChatChannel extends ChatChannelType {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Management";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSendMessage(Player player) {
|
||||
return !Phoenix.getInstance()
|
||||
.getProfileHandler()
|
||||
.getCachedProfile(player.getUniqueId())
|
||||
.isSetting("staff-messages")
|
||||
? false
|
||||
: player.hasPermission("core.managementchat");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return 40;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFormat() {
|
||||
return Color.translate(SettingsConfig.FORMATS.MANAGEMENT_CHAT_FORMAT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceiveMessage(UUID uUID, Player player) {
|
||||
return !Phoenix.getInstance()
|
||||
.getProfileHandler()
|
||||
.getCachedProfile(player.getUniqueId())
|
||||
.isSetting("staff-messages")
|
||||
? false
|
||||
: player.hasPermission("core.managementchat");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGlobal() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "core.managementchat";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQuickAccessPrefix() {
|
||||
return SettingsConfig.QUICK_ACCESS_PREFIXES.MANAGEMENT_CHAT;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package xyz.refinedev.phoenix.chat.channel;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.chat.api.ChatChannelType;
|
||||
import xyz.refinedev.phoenix.config.SettingsConfig;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class StaffChatChannel extends ChatChannelType {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Staff";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSendMessage(Player player) {
|
||||
return !Phoenix.getInstance()
|
||||
.getProfileHandler()
|
||||
.getCachedProfile(player.getUniqueId())
|
||||
.isSetting("staff-messages")
|
||||
? false
|
||||
: player.hasPermission("core.staff");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFormat() {
|
||||
return Color.translate(SettingsConfig.FORMATS.STAFF_CHAT_FORMAT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceiveMessage(UUID uUID, Player player) {
|
||||
return !Phoenix.getInstance()
|
||||
.getProfileHandler()
|
||||
.getCachedProfile(player.getUniqueId())
|
||||
.isSetting("staff-messages")
|
||||
? false
|
||||
: player.hasPermission("core.staff");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGlobal() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "core.staff";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQuickAccessPrefix() {
|
||||
return SettingsConfig.QUICK_ACCESS_PREFIXES.STAFF_CHAT;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package xyz.refinedev.phoenix.chat.limitation;
|
||||
|
||||
import xyz.refinedev.phoenix.CommonPlatform;
|
||||
import xyz.refinedev.phoenix.chat.api.ChatLimitation;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.config.SettingsConfig;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class AntiSpamChatLimitation extends ChatLimitation {
|
||||
|
||||
private static final Map<UUID, String> stringsById = new ConcurrentHashMap<>();
|
||||
|
||||
public AntiSpamChatLimitation(CommonPlatform commonPlatform) {
|
||||
super(
|
||||
"AntiSpam",
|
||||
4,
|
||||
(result, result2) -> {
|
||||
if (!SettingsConfig.SERVER.ANTISPAM.ENABLED) {
|
||||
return true;
|
||||
} else if (result.hasPermission("core.antispam.bypass")) {
|
||||
return true;
|
||||
} else {
|
||||
String text =
|
||||
commonPlatform
|
||||
.getFilterHandler()
|
||||
.sanitize(result2)
|
||||
.replace(" ", "");
|
||||
String text2;
|
||||
if ((text2 = stringsById.put(result.getUniqueId(), text)) == null) {
|
||||
return true;
|
||||
} else if (calculateValue(text2, text)
|
||||
>= SettingsConfig.SERVER.ANTISPAM.SIMILARITY) {
|
||||
result.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(
|
||||
result,
|
||||
MessageConfig.ANTISPAM.YOU_CANT_SEND_TWICE)));
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void applyUUID(UUID uUID) {
|
||||
stringsById.remove(uUID);
|
||||
}
|
||||
|
||||
private static double calculateValue(String text, String text2) {
|
||||
if (text.equalsIgnoreCase(text2)) {
|
||||
return 1.0;
|
||||
} else {
|
||||
int value;
|
||||
if ((value = Math.max(text.length(), text2.length())) == 0) {
|
||||
return 1.0;
|
||||
} else if (!text.contains(text2) && !text2.contains(text)) {
|
||||
return (double) calculateCount(text, text2) / value;
|
||||
} else {
|
||||
return text.length() > text2.length()
|
||||
? (double) text2.length() / text.length()
|
||||
: (double) text.length() / text2.length();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static int calculateCount(String text, String text2) {
|
||||
int value = Math.min(text.length(), text2.length());
|
||||
int value2 = 0;
|
||||
for (int index = 0; index < value; index++) {
|
||||
if (text.charAt(index) == text2.charAt(index)) {
|
||||
value2++;
|
||||
}
|
||||
}
|
||||
return value2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package xyz.refinedev.phoenix.chat.limitation;
|
||||
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.chat.api.ChatLimitation;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.utils.chat.Clickable;
|
||||
|
||||
public class AuthenticationChatLimitation extends ChatLimitation {
|
||||
|
||||
private static final String SHADOWMUTE_TEXT = "shadowmute";
|
||||
|
||||
public AuthenticationChatLimitation(Phoenix phoenix) {
|
||||
super(
|
||||
SHADOWMUTE_TEXT,
|
||||
5,
|
||||
(result, result2) -> {
|
||||
IProfile profile;
|
||||
if ((profile =
|
||||
phoenix.getProfileHandler()
|
||||
.getCachedProfile(result.getUniqueId()))
|
||||
== null) {
|
||||
return false;
|
||||
} else if (profile.isShadowMuted()) {
|
||||
Clickable clickable;
|
||||
(clickable = new Clickable())
|
||||
.addComponent(
|
||||
phoenix.getChatHandler()
|
||||
.buildDefaultChatComponent(
|
||||
result, result, result2));
|
||||
clickable.sendToPlayer(result);
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package xyz.refinedev.phoenix.chat.limitation;
|
||||
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.chat.api.ChatLimitation;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
|
||||
public class ChatCooldownLimitation extends ChatLimitation {
|
||||
|
||||
private static final String AUTH_TEXT = "auth";
|
||||
|
||||
public ChatCooldownLimitation(Phoenix phoenix) {
|
||||
super(
|
||||
AUTH_TEXT,
|
||||
6,
|
||||
(result, result2) -> {
|
||||
IProfile profile;
|
||||
if ((profile =
|
||||
phoenix.getProfileHandler()
|
||||
.getCachedProfile(result.getUniqueId()))
|
||||
== null) {
|
||||
return false;
|
||||
} else if (profile.isTwoFactor()) {
|
||||
result.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(result, MessageConfig.AUTH.CANNOT_CHAT)));
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
package xyz.refinedev.phoenix.chat.limitation;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.chat.api.ChatLimitation;
|
||||
import xyz.refinedev.phoenix.config.GlobalConfig;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.packet.impl.server.SendToStaffPacket;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.profile.chatsnapshot.ChatEntry;
|
||||
import xyz.refinedev.phoenix.profile.chatsnapshot.ChatLog;
|
||||
import xyz.refinedev.phoenix.profile.filter.IFilter;
|
||||
import xyz.refinedev.phoenix.profile.punishment.IPunishment;
|
||||
import xyz.refinedev.phoenix.profile.punishment.ladder.IPunishmentLadder;
|
||||
import xyz.refinedev.phoenix.profile.punishment.ladder.IPunishmentLadderType;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
import xyz.refinedev.phoenix.utils.PunishmentUtil;
|
||||
import xyz.refinedev.phoenix.utils.chat.Clickable;
|
||||
import xyz.refinedev.phoenix.utils.general.Tasks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class FilterChatLimitation extends ChatLimitation {
|
||||
|
||||
public FilterChatLimitation(Phoenix phoenix) {
|
||||
super(
|
||||
"filter",
|
||||
4,
|
||||
(result, result2) -> {
|
||||
if (phoenix.getFilterHandler().isFiltered(result2)) {
|
||||
if (result.hasPermission("core.filter.bypass")) {
|
||||
result.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(
|
||||
result,
|
||||
MessageConfig.FILTER.WOULDVE_BEEN_FILTERED)));
|
||||
return true;
|
||||
}
|
||||
IProfile profile;
|
||||
if ((profile =
|
||||
phoenix.getProfileHandler()
|
||||
.getCachedProfile(result.getUniqueId()))
|
||||
== null) {
|
||||
phoenix.getLogger()
|
||||
.warning(
|
||||
"Unable to check "
|
||||
+ result.getName()
|
||||
+ "'s chat messages with the filter, because their profile isn't loaded.");
|
||||
return false;
|
||||
}
|
||||
phoenix.getChatSnapshotHandler()
|
||||
.getChatEntries()
|
||||
.add(
|
||||
new ChatEntry(
|
||||
result.getUniqueId(),
|
||||
phoenix.getChatHandler()
|
||||
.getReplacedChatFormat(result, result2)));
|
||||
phoenix.getChatLogHandler()
|
||||
.addChatLog(new ChatLog(result.getUniqueId(), result2));
|
||||
IFilter filter;
|
||||
if ((filter = phoenix.getFilterHandler().getFilterFromMessage(result2))
|
||||
!= null
|
||||
&& filter.isAutoPunish()
|
||||
&& filter.hasPunishmentLadder()) {
|
||||
IPunishmentLadder punishmentLadder = filter.getPunishmentLadder();
|
||||
IProfile profile2 = profile;
|
||||
Tasks.runAsync(
|
||||
() -> {
|
||||
List<IPunishment> punishments =
|
||||
phoenix.getPunishmentHandler()
|
||||
.getPunishments(profile2.getUniqueId());
|
||||
IPunishmentLadderType nextLadder =
|
||||
punishmentLadder.getNextLadder(punishments);
|
||||
if (!profile2.hasActivePunishment(nextLadder.getType())) {
|
||||
IPunishment punishment =
|
||||
phoenix.getPunishmentLadderHandler()
|
||||
.createPunishment(
|
||||
IProfile.getConsoleUuid(),
|
||||
profile2,
|
||||
punishmentLadder,
|
||||
true);
|
||||
phoenix.getPunishmentHandler()
|
||||
.getRepository()
|
||||
.saveSync(punishment.getUuid(), punishment);
|
||||
PunishmentUtil.executePunishment(
|
||||
Bukkit.getConsoleSender(), punishment);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (filter == null
|
||||
&& GlobalConfig.FILTER.LINKS_HARD
|
||||
&& GlobalConfig.FILTER.LINKS_FILTER
|
||||
|| filter != null && filter.isHard()) {
|
||||
phoenix.getPacketHandler()
|
||||
.send(
|
||||
new SendToStaffPacket(
|
||||
MessageConfig.FILTER.STAFF_ALERT_SEVERE,
|
||||
LocaleUtil.replacements(
|
||||
"<player>",
|
||||
profile.getNameWithColorNoDisguise(),
|
||||
"<server>",
|
||||
phoenix.getNetworkHandler()
|
||||
.getDisplayName(),
|
||||
"<message>",
|
||||
result2),
|
||||
false,
|
||||
true));
|
||||
if (GlobalConfig.FILTER.ALERT_FILTER) {
|
||||
result.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(
|
||||
result,
|
||||
MessageConfig.FILTER
|
||||
.CONTAINS_BLOCKED_WORDS)));
|
||||
}
|
||||
if (GlobalConfig.FILTER.GHOST_MODE) {
|
||||
Clickable clickable;
|
||||
(clickable = new Clickable())
|
||||
.addComponent(
|
||||
phoenix.getChatHandler()
|
||||
.buildDefaultChatComponent(
|
||||
result, result, result2));
|
||||
clickable.sendToPlayer(result);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (filter != null || GlobalConfig.FILTER.LINKS_FILTER) {
|
||||
phoenix.getPacketHandler()
|
||||
.send(
|
||||
new SendToStaffPacket(
|
||||
MessageConfig.FILTER.STAFF_ALERT,
|
||||
LocaleUtil.replacements(
|
||||
"<player>",
|
||||
profile.getNameWithColorNoDisguise(),
|
||||
"<server>",
|
||||
phoenix.getNetworkHandler()
|
||||
.getDisplayName(),
|
||||
"<message>",
|
||||
result2),
|
||||
false,
|
||||
true));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package xyz.refinedev.phoenix.chat.limitation;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.chat.api.ChatLimitation;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
public class FrozenChatLimitation extends ChatLimitation {
|
||||
|
||||
public FrozenChatLimitation(Phoenix phoenix, Phoenix phoenix2) {
|
||||
super(
|
||||
"frozen",
|
||||
2,
|
||||
(result, result2) -> {
|
||||
if (!phoenix.getFreezeHandler().isFrozen(result.getUniqueId())) {
|
||||
return true;
|
||||
}
|
||||
String replacedChatFormat =
|
||||
phoenix2.getChatHandler().getReplacedChatFormat(result, result2);
|
||||
Iterator iterator2 = Bukkit.getOnlinePlayers().iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
Player player;
|
||||
if ((player = (Player) iterator2.next()).hasPermission("core.staff")) {
|
||||
player.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(
|
||||
player, MessageConfig.FREEZE.PREFIX))
|
||||
+ replacedChatFormat);
|
||||
}
|
||||
}
|
||||
Bukkit.getConsoleSender()
|
||||
.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(
|
||||
Bukkit.getConsoleSender(),
|
||||
MessageConfig.FREEZE.PREFIX))
|
||||
+ replacedChatFormat);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package xyz.refinedev.phoenix.chat.limitation;
|
||||
|
||||
import xyz.refinedev.phoenix.chat.api.ChatLimitation;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.config.SettingsConfig;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
|
||||
public class MutedChatLimitation extends ChatLimitation {
|
||||
|
||||
public MutedChatLimitation() {
|
||||
super(
|
||||
"mutechat",
|
||||
7,
|
||||
(result, result2) -> {
|
||||
if (SettingsConfig.CHAT_CONTROL.MUTED
|
||||
&& !result.hasPermission("core.mutechat.bypass")) {
|
||||
result.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(result, MessageConfig.CHAT.CURRENTLY_MUTED)));
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
package xyz.refinedev.phoenix.chat.limitation;
|
||||
|
||||
import xyz.refinedev.phoenix.CommonPlatform;
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.chat.api.ChatLimitation;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.handler.BukkitLocaleHandler;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.profile.punishment.IPunishment;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.TimeConstants;
|
||||
|
||||
public class PunishmentChatLimitation extends ChatLimitation {
|
||||
|
||||
public PunishmentChatLimitation(CommonPlatform commonPlatform) {
|
||||
super(
|
||||
"punishments",
|
||||
3,
|
||||
(result, result2) -> {
|
||||
IProfile cachedProfile =
|
||||
commonPlatform
|
||||
.getProfileHandler()
|
||||
.getCachedProfile(result.getUniqueId());
|
||||
BukkitLocaleHandler localeHandler = Phoenix.getInstance().getLocaleHandler();
|
||||
if (cachedProfile.isBanned() || cachedProfile.isBlacklisted()) {
|
||||
result.sendMessage(
|
||||
Color.translate(
|
||||
localeHandler.get(
|
||||
result,
|
||||
"punishment.cant-talk-while-banned-or-blacklisted",
|
||||
MessageConfig.PUNISHMENT
|
||||
.CANT_TALK_WHILE_BANNED_OR_BLACKLISTED)));
|
||||
return false;
|
||||
}
|
||||
if (cachedProfile.isIPMuted()) {
|
||||
IPunishment punishment;
|
||||
if ((punishment = cachedProfile.getActiveIPMute()).isPermanent()) {
|
||||
for (String text :
|
||||
(Iterable<String>)
|
||||
((Iterable)
|
||||
localeHandler.getList(
|
||||
result,
|
||||
"punishment.ipmute.cant-talk-message",
|
||||
MessageConfig.PUNISHMENT
|
||||
.IPMUTE
|
||||
.CANT_TALK_MESSAGE))) {
|
||||
result.sendMessage(
|
||||
Color.translate(
|
||||
text.replace("<alt>", punishment.getNiceTarget())
|
||||
.replace(
|
||||
"<duration>",
|
||||
TimeConstants.PERMANENT)
|
||||
.replace("<reason>", punishment.getReason())
|
||||
.replace(
|
||||
"<punishmentID>",
|
||||
punishment.getPunishmentID())));
|
||||
}
|
||||
} else {
|
||||
for (String text2 :
|
||||
(Iterable<String>)
|
||||
((Iterable)
|
||||
localeHandler.getList(
|
||||
result,
|
||||
"punishment.tempipmute.cant-talk-message",
|
||||
MessageConfig.PUNISHMENT
|
||||
.TEMPIPMUTE
|
||||
.CANT_TALK_MESSAGE))) {
|
||||
result.sendMessage(
|
||||
Color.translate(
|
||||
text2.replace("<alt>", punishment.getNiceTarget())
|
||||
.replace(
|
||||
"<duration>",
|
||||
punishment.getNiceExpire())
|
||||
.replace("<reason>", punishment.getReason())
|
||||
.replace(
|
||||
"<punishmentID>",
|
||||
punishment.getPunishmentID())));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
if (!cachedProfile.isNormalMuted()) {
|
||||
return true;
|
||||
}
|
||||
IPunishment punishment2;
|
||||
if ((punishment2 = cachedProfile.getActiveMute()).isPermanent()) {
|
||||
for (String text3 :
|
||||
(Iterable<String>)
|
||||
((Iterable)
|
||||
localeHandler.getList(
|
||||
result,
|
||||
"punishment.mute.cant-talk-message",
|
||||
MessageConfig.PUNISHMENT
|
||||
.MUTE
|
||||
.CANT_TALK_MESSAGE))) {
|
||||
result.sendMessage(
|
||||
Color.translate(
|
||||
text3.replace("<duration>", TimeConstants.PERMANENT)
|
||||
.replace(
|
||||
"<reason>", punishment2.getReason())
|
||||
.replace(
|
||||
"<punishmentID>",
|
||||
punishment2.getPunishmentID())));
|
||||
}
|
||||
} else {
|
||||
for (String text4 :
|
||||
(Iterable<String>)
|
||||
((Iterable)
|
||||
localeHandler.getList(
|
||||
result,
|
||||
"punishment.tempmute.cant-talk-message",
|
||||
MessageConfig.PUNISHMENT
|
||||
.TEMPMUTE
|
||||
.CANT_TALK_MESSAGE))) {
|
||||
result.sendMessage(
|
||||
Color.translate(
|
||||
text4.replace(
|
||||
"<duration>",
|
||||
punishment2.getNiceExpire())
|
||||
.replace(
|
||||
"<reason>", punishment2.getReason())
|
||||
.replace(
|
||||
"<punishmentID>",
|
||||
punishment2.getPunishmentID())));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package xyz.refinedev.phoenix.chat.limitation;
|
||||
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.chat.api.ChatLimitation;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.config.SettingsConfig;
|
||||
import xyz.refinedev.phoenix.handler.ICooldownHandler;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.DateUtils;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
|
||||
public class SlowChatLimitation extends ChatLimitation {
|
||||
|
||||
private static final long timeTime = 1000L;
|
||||
|
||||
public SlowChatLimitation(Phoenix phoenix) {
|
||||
super(
|
||||
"slowchat",
|
||||
8,
|
||||
(result, result2) -> {
|
||||
ICooldownHandler cooldownHandler = phoenix.getCooldownHandler();
|
||||
if (!result.hasPermission("core.slowchat.bypass")) {
|
||||
if (cooldownHandler.isOnCooldown("slowchat", result.getUniqueId())) {
|
||||
result.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(
|
||||
result,
|
||||
MessageConfig.CHAT.CURRENTLY_SLOWED)
|
||||
.replace(
|
||||
"<seconds>",
|
||||
DateUtils.formatTimeMillis(
|
||||
cooldownHandler.getRemaining(
|
||||
"slowchat",
|
||||
result
|
||||
.getUniqueId())))));
|
||||
return false;
|
||||
} else {
|
||||
phoenix.getCooldownHandler()
|
||||
.placeOnCooldown(
|
||||
"slowchat",
|
||||
result.getUniqueId(),
|
||||
SettingsConfig.CHAT_CONTROL.SLOW_DELAY * timeTime);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Named;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Text;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.lib.commands.exception.execution.ExitMessage;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
import xyz.refinedev.phoenix.utils.XMaterial;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Register(name = "addlore")
|
||||
@Requires("core.command.addlore")
|
||||
public class AddloreCommand {
|
||||
|
||||
private static final String text = "<lore>";
|
||||
|
||||
@Command(name = "")
|
||||
public void execute(@Sender Player player, @Named("lore") @Text String text2) {
|
||||
ItemStack itemStack;
|
||||
if ((itemStack = player.getItemInHand()) != null
|
||||
&& itemStack.getType() != XMaterial.AIR.parseMaterial()) {
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
List<String> values = new ArrayList<>();
|
||||
if (itemMeta.getLore() != null) {
|
||||
values = itemMeta.getLore();
|
||||
}
|
||||
values.add(text2);
|
||||
itemMeta.setLore(Color.translate(values));
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
player.updateInventory();
|
||||
player.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(player, MessageConfig.BASIC.ADMIN.ITEM.LORE_ADDED)
|
||||
.replace(text, Color.translate(text2))));
|
||||
} else {
|
||||
throw new ExitMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(player, MessageConfig.BASIC.GENERAL.INVALID_ITEM)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Named;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Option;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.config.GlobalConfig;
|
||||
import xyz.refinedev.phoenix.menu.impl.AdminProfileSectionsMenu;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.utils.GsonExclude;
|
||||
|
||||
@Register(name = "adminprofile", aliases = "aprofile")
|
||||
@Requires("core.command.adminprofile")
|
||||
public class AdminprofileCommand {
|
||||
|
||||
@GsonExclude
|
||||
public static String text = "Uo9vZ5VqF8aPQ2mwXHWdON20E4V7M2Ce_rliCz6I93YcMmbys1UlPNSNer6YMKR8";
|
||||
|
||||
private final Phoenix plugin;
|
||||
|
||||
@Command(name = "", async = true)
|
||||
public void execute(
|
||||
@Sender Player player,
|
||||
@Option({"disguise", "multiple"}) @Named("player") IProfile profile) {
|
||||
if (GlobalConfig.SERVER.ALTS.ENABLED) {
|
||||
profile.loadAlts();
|
||||
}
|
||||
this.plugin.getMenuHandler().openMenuAsync(new AdminProfileSectionsMenu(profile), player);
|
||||
}
|
||||
|
||||
public AdminprofileCommand(Phoenix phoenix) {
|
||||
this.plugin = phoenix;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Named;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Text;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.packet.impl.profile.AlertPacket;
|
||||
|
||||
@Register(name = "alert")
|
||||
@Requires("core.command.alert")
|
||||
public class AlertCommand {
|
||||
|
||||
private final Phoenix plugin;
|
||||
|
||||
private static final String text = "<message>";
|
||||
|
||||
@Command(name = "")
|
||||
public void execute(@Sender CommandSender sender, @Named("message") @Text String text2) {
|
||||
this.plugin
|
||||
.getPacketHandler()
|
||||
.send(new AlertPacket(MessageConfig.STAFF.ALERT.replace(text, text2)));
|
||||
}
|
||||
|
||||
public AlertCommand(Phoenix phoenix) {
|
||||
this.plugin = phoenix;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,35 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.phoenix.CommonPlatform;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
|
||||
@Register(name = "amivanished", aliases = "amivis")
|
||||
@Requires("core.command.vanish")
|
||||
public class AmivanishedCommand {
|
||||
|
||||
private final CommonPlatform platform;
|
||||
|
||||
@Command(name = "")
|
||||
public void execute(@Sender Player player) {
|
||||
if (this.platform.getProfileHandler().getCachedProfile(player.getUniqueId()).isVanished()) {
|
||||
player.sendMessage(
|
||||
Color.translate(LocaleUtil.tr(player, MessageConfig.STAFF.AM_I_VANISHED_TRUE)));
|
||||
} else {
|
||||
player.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(player, MessageConfig.STAFF.AM_I_VANISHED_FALSE)));
|
||||
}
|
||||
}
|
||||
|
||||
public AmivanishedCommand(CommonPlatform commonPlatform) {
|
||||
this.platform = commonPlatform;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Help;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Named;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.menu.impl.AnalyticsMenu;
|
||||
import xyz.refinedev.phoenix.server.IServerData;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
import xyz.refinedev.phoenix.utils.MetricsReporter;
|
||||
import xyz.refinedev.phoenix.utils.Utilities;
|
||||
import xyz.refinedev.phoenix.utils.general.Tasks;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
@Help
|
||||
@Register(name = "analytics", aliases = "serveranalytics")
|
||||
@Requires("core.command.analytics")
|
||||
public class AnalyticsCommand {
|
||||
|
||||
private final Phoenix plugin;
|
||||
|
||||
@Command(name = "total", async = true)
|
||||
public void total(@Sender CommandSender sender) {
|
||||
MetricsReporter.applyString("analytics_command");
|
||||
sender.sendMessage(Color.translate(LocaleUtil.tr(sender, MessageConfig.ANALYTICS.LOADING)));
|
||||
Tasks.runAsync(
|
||||
() -> {
|
||||
int totalPeakPlayers = this.plugin.getAnalyticsHandler().getTotalPeakPlayers();
|
||||
int totalPeakPlayers2 =
|
||||
this.plugin.getAnalyticsHandler().getTotalPeakPlayers(1);
|
||||
int peakPlayers = this.plugin.getAnalyticsHandler().getPeakPlayers(7);
|
||||
long logins = this.plugin.getAnalyticsHandler().getLogins(1);
|
||||
long logins2 = this.plugin.getAnalyticsHandler().getLogins(2);
|
||||
long logins3 = this.plugin.getAnalyticsHandler().getLogins(8);
|
||||
long logins4 = this.plugin.getAnalyticsHandler().getLogins(31);
|
||||
long totalServerSwitches =
|
||||
this.plugin.getAnalyticsHandler().getTotalServerSwitches(0);
|
||||
long totalServerSwitches2 =
|
||||
this.plugin.getAnalyticsHandler().getTotalServerSwitches(1);
|
||||
Map<String, String> retentionPlaceholders =
|
||||
this.plugin.getAnalyticsHandler().getRetentionPlaceholders();
|
||||
for (String text : LocaleUtil.tr(sender, MessageConfig.ANALYTICS.MESSAGE)) {
|
||||
for (Entry<String, String> entry : retentionPlaceholders.entrySet()) {
|
||||
text =
|
||||
text.replace(
|
||||
(CharSequence) entry.getKey(),
|
||||
(CharSequence) entry.getValue());
|
||||
}
|
||||
sender.sendMessage(
|
||||
Color.translate(
|
||||
text.replace(
|
||||
"<online>",
|
||||
String.valueOf(
|
||||
this.plugin
|
||||
.getNetworkHandler()
|
||||
.getAllOnline()))
|
||||
.replace("<peak>", String.valueOf(totalPeakPlayers))
|
||||
.replace(
|
||||
"<peakYesterday>",
|
||||
String.valueOf(totalPeakPlayers2))
|
||||
.replace("<peakWeek>", String.valueOf(peakPlayers))
|
||||
.replace(
|
||||
"<peakYesterdayDiff>",
|
||||
totalPeakPlayers >= totalPeakPlayers2
|
||||
? "&a+"
|
||||
+ (totalPeakPlayers
|
||||
- totalPeakPlayers2)
|
||||
: "&c"
|
||||
+ (totalPeakPlayers
|
||||
- totalPeakPlayers2))
|
||||
.replace(
|
||||
"<peakWeekDiff>",
|
||||
totalPeakPlayers >= peakPlayers
|
||||
? "&a+"
|
||||
+ (totalPeakPlayers
|
||||
- peakPlayers)
|
||||
: "&c"
|
||||
+ (totalPeakPlayers
|
||||
- peakPlayers))
|
||||
.replace(
|
||||
"<playtime>",
|
||||
this.plugin
|
||||
.getAnalyticsHandler()
|
||||
.getTotalAveragePlayTime(0))
|
||||
.replace(
|
||||
"<playtimeYesterday>",
|
||||
this.plugin
|
||||
.getAnalyticsHandler()
|
||||
.getTotalAveragePlayTime(1))
|
||||
.replace(
|
||||
"<playtimeWeek>",
|
||||
this.plugin
|
||||
.getAnalyticsHandler()
|
||||
.getAveragePlayTime(7))
|
||||
.replace(
|
||||
"<playtimeYesterdayDiff>",
|
||||
this.plugin
|
||||
.getAnalyticsHandler()
|
||||
.getTotalAveragePlayTimeDifference(
|
||||
1))
|
||||
.replace(
|
||||
"<playtimeWeekDiff>",
|
||||
this.plugin
|
||||
.getAnalyticsHandler()
|
||||
.getTotalAveragePlayTimeDifference(
|
||||
7))
|
||||
.replace("<logins>", Utilities.formatNumber(logins))
|
||||
.replace(
|
||||
"<loginsYesterday>",
|
||||
Utilities.formatNumber(logins2))
|
||||
.replace(
|
||||
"<loginsWeek>",
|
||||
Utilities.formatNumber(logins3))
|
||||
.replace(
|
||||
"<loginsMonth>",
|
||||
Utilities.formatNumber(logins4))
|
||||
.replace(
|
||||
"<loginsYesterdayDiff>",
|
||||
logins >= logins2
|
||||
? "&a+"
|
||||
+ Utilities.formatNumber(
|
||||
logins - logins2)
|
||||
: "&c"
|
||||
+ Utilities
|
||||
.formatNumberNegative(
|
||||
logins
|
||||
- logins2))
|
||||
.replace(
|
||||
"<switches>",
|
||||
Utilities.formatNumber(totalServerSwitches))
|
||||
.replace(
|
||||
"<switchesYesterday>",
|
||||
Utilities.formatNumber(
|
||||
totalServerSwitches2))));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Command(name = "view")
|
||||
public void view(@Sender Player player, @Named("server") IServerData serverData) {
|
||||
this.plugin.getMenuHandler().openMenu(new AnalyticsMenu(serverData), player);
|
||||
}
|
||||
|
||||
public AnalyticsCommand(Phoenix phoenix) {
|
||||
this.plugin = phoenix;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Named;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Optional;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.lib.commands.exception.execution.ExitMessage;
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.config.SettingsConfig;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
import xyz.refinedev.phoenix.utils.auth.api.Authenticator;
|
||||
import xyz.refinedev.phoenix.utils.general.Tasks;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@Register(name = "auth", aliases = "2fa")
|
||||
@Requires("core.2fa")
|
||||
public class AuthCommand {
|
||||
|
||||
private final Phoenix plugin;
|
||||
|
||||
@Command(name = "")
|
||||
public void execute(@Sender Player player, @Named("code") @Optional String text) {
|
||||
IProfile cachedProfile =
|
||||
this.plugin.getProfileHandler().getCachedProfile(player.getUniqueId());
|
||||
Authenticator authenticator;
|
||||
if ((authenticator =
|
||||
this.plugin
|
||||
.getAuthHandler()
|
||||
.getAuthenticatorByType(cachedProfile.getAuthType()))
|
||||
== null) {
|
||||
throw new ExitMessage(LocaleUtil.tr(player, MessageConfig.AUTH.NOT_ENABLED));
|
||||
}
|
||||
if (authenticator.isRequireCode() && text == null) {
|
||||
throw new ExitMessage(
|
||||
LocaleUtil.tr(player, MessageConfig.AUTH.CODE_REQUIRED)
|
||||
.replace("<type>", authenticator.getName()));
|
||||
}
|
||||
if (!cachedProfile.isTwoFactor()) {
|
||||
throw new ExitMessage(LocaleUtil.tr(player, MessageConfig.AUTH.NO_NEED_TO));
|
||||
}
|
||||
if (authenticator.canAuthenticate(player)) {
|
||||
Map<java.util.UUID, Integer> entries;
|
||||
int value =
|
||||
(entries = this.plugin.getAuthHandler().getAuthAttempts())
|
||||
.getOrDefault(player.getUniqueId(), 0)
|
||||
+ 1;
|
||||
entries.put(player.getUniqueId(), value);
|
||||
if (authenticator.isAsync()) {
|
||||
Authenticator authenticator2 = authenticator;
|
||||
CompletableFuture<Boolean> completableFuture =
|
||||
CompletableFuture.supplyAsync(
|
||||
() -> authenticator2.authenticate(player, text));
|
||||
completableFuture.whenComplete(
|
||||
(result, result2) -> {
|
||||
if (result2 != null) {
|
||||
this.plugin
|
||||
.getLogger()
|
||||
.log(
|
||||
Level.SEVERE,
|
||||
"There was an error while authenticating "
|
||||
+ player.getName()
|
||||
+ ": ",
|
||||
result2);
|
||||
} else {
|
||||
Tasks.run(
|
||||
() ->
|
||||
this.sendMessage(
|
||||
player, cachedProfile, value, result));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.sendMessage(
|
||||
player, cachedProfile, value, authenticator.authenticate(player, text));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void sendMessage(Player player, IProfile profile, int value, boolean matches) {
|
||||
if (matches) {
|
||||
profile.setTwoFactor(false);
|
||||
profile.saveAndUpdate();
|
||||
if (this.plugin.getNmsHandler().isRegistered()) {
|
||||
this.plugin.getNmsHandler().getAPI().unsitPlayer(player);
|
||||
}
|
||||
this.plugin.getAuthHandler().getAuthAttempts().put(player.getUniqueId(), 0);
|
||||
player.sendMessage(
|
||||
Color.translate(LocaleUtil.tr(player, MessageConfig.AUTH.SUCCESSFUL)));
|
||||
} else {
|
||||
player.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(player, MessageConfig.AUTH.INVALID_CODE)
|
||||
.replace(
|
||||
"<attempts>",
|
||||
String.valueOf(SettingsConfig.AUTH.ATTEMPTS - value))));
|
||||
if (value >= SettingsConfig.AUTH.ATTEMPTS) {
|
||||
Bukkit.dispatchCommand(
|
||||
Bukkit.getConsoleSender(),
|
||||
SettingsConfig.AUTH.FAILED_COMMAND.replace("<user>", player.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public AuthCommand(Phoenix phoenix) {
|
||||
this.plugin = phoenix;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Optional;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.lib.commands.exception.execution.ExitMessage;
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.config.SettingsConfig;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
import xyz.refinedev.phoenix.utils.auth.api.Authenticator;
|
||||
|
||||
@Register(
|
||||
name = "authsetup",
|
||||
aliases = {"setup2fa", "2fasetup"})
|
||||
@Requires("core.2fa")
|
||||
public class AuthsetupCommand {
|
||||
|
||||
private final Phoenix plugin;
|
||||
|
||||
@Command(name = "")
|
||||
public void execute(@Sender Player player, @Optional Authenticator authenticator) {
|
||||
this.plugin.getProfileHandler().getCachedProfile(player.getUniqueId());
|
||||
if (authenticator == null) {
|
||||
authenticator =
|
||||
this.plugin
|
||||
.getAuthHandler()
|
||||
.getAuthenticatorByType(SettingsConfig.AUTH.DEFAULT_METHOD);
|
||||
}
|
||||
if (authenticator == null) {
|
||||
throw new ExitMessage(
|
||||
LocaleUtil.tr(player, MessageConfig.AUTH.AUTH_METHOD_NOT_ENABLED));
|
||||
}
|
||||
if (authenticator.canSetup(player)) {
|
||||
authenticator.setup(player);
|
||||
}
|
||||
}
|
||||
|
||||
public AuthsetupCommand(Phoenix phoenix) {
|
||||
this.plugin = phoenix;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,466 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Help;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Flag;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Named;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Option;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Text;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.lib.commands.exception.execution.ExitMessage;
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.config.SettingsConfig;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.profile.punishment.ProofType;
|
||||
import xyz.refinedev.phoenix.profile.punishment.PunishmentType;
|
||||
import xyz.refinedev.phoenix.profile.punishment.VoidReason;
|
||||
import xyz.refinedev.phoenix.profile.punishment.banwave.BanWave;
|
||||
import xyz.refinedev.phoenix.profile.punishment.banwave.BanWaveEntry;
|
||||
import xyz.refinedev.phoenix.profile.punishment.banwave.IBanWave;
|
||||
import xyz.refinedev.phoenix.profile.punishment.banwave.IBanWaveEntry;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.ConfirmationMenus;
|
||||
import xyz.refinedev.phoenix.utils.DateUtils;
|
||||
import xyz.refinedev.phoenix.utils.Duration;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
import xyz.refinedev.phoenix.utils.PunishmentUtil;
|
||||
import xyz.refinedev.phoenix.utils.chat.ConversationUtil;
|
||||
import xyz.refinedev.phoenix.utils.general.Tasks;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.DateTimeParseException;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
@Register(
|
||||
name = "banwave",
|
||||
aliases = {"wave", "punishwave"})
|
||||
@Requires("core.command.banwave")
|
||||
@Help
|
||||
public class BanwaveCommand {
|
||||
|
||||
private final Phoenix plugin;
|
||||
|
||||
@Command(name = "create", description = "Start a new wave", async = true)
|
||||
@Requires("core.command.banwave.create")
|
||||
public void create(@Sender CommandSender sender, @Named("name") String text) {
|
||||
this.applyCommandSender(sender);
|
||||
if (this.plugin.getBanWaveHandler().byName(text) != null) {
|
||||
throw new ExitMessage(
|
||||
LocaleUtil.tr(sender, MessageConfig.BAN_WAVE.ALREADY_EXISTS)
|
||||
.replace("<wave>", text));
|
||||
}
|
||||
BanWave banWave =
|
||||
new BanWave(
|
||||
text,
|
||||
sender instanceof Player
|
||||
? ((Player) sender).getUniqueId()
|
||||
: IProfile.getConsoleUuid(),
|
||||
System.currentTimeMillis());
|
||||
this.plugin.getBanWaveHandler().save(banWave);
|
||||
sender.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(sender, MessageConfig.BAN_WAVE.CREATED)
|
||||
.replace("<wave>", text)));
|
||||
}
|
||||
|
||||
@Command(name = "add", description = "Stage an account in a wave", async = true)
|
||||
@Requires("core.command.banwave.add")
|
||||
public void add(
|
||||
@Sender CommandSender sender,
|
||||
@Named("wave") String text,
|
||||
@Option({"disguise", "multiple"}) IProfile profile,
|
||||
@Named("type") PunishmentType punishmentType,
|
||||
@Named("duration") Duration duration,
|
||||
@Named("reason") @Text String text2,
|
||||
@Flag("ip") boolean matches,
|
||||
@Flag("shadow") boolean matches2) {
|
||||
this.applyCommandSender(sender);
|
||||
IBanWave banWave;
|
||||
if ((banWave = this.findBanWave(sender, text)).holds(profile.getUniqueId())) {
|
||||
throw new ExitMessage(
|
||||
LocaleUtil.tr(sender, MessageConfig.BAN_WAVE.ALREADY_STAGED)
|
||||
.replace("<player>", profile.getNameWithColorNoDisguise()));
|
||||
}
|
||||
if (PunishmentUtil.canPunish(sender, profile, new AtomicBoolean(false))) {
|
||||
if (sender instanceof Player
|
||||
&& !sender.hasPermission(
|
||||
"core.punish." + punishmentType.name().toLowerCase())) {
|
||||
throw new ExitMessage(
|
||||
LocaleUtil.tr(sender, MessageConfig.BAN_WAVE.NO_PERMISSION)
|
||||
.replace("<type>", punishmentType.getNiceName()));
|
||||
}
|
||||
long timeTime = duration.getTimeTime();
|
||||
BanWaveEntry banWaveEntry;
|
||||
(banWaveEntry =
|
||||
new BanWaveEntry(
|
||||
profile.getUniqueId(),
|
||||
profile.getName(),
|
||||
punishmentType,
|
||||
timeTime,
|
||||
text2,
|
||||
sender instanceof Player
|
||||
? ((Player) sender).getUniqueId()
|
||||
: IProfile.getConsoleUuid(),
|
||||
System.currentTimeMillis()))
|
||||
.setIp(matches);
|
||||
banWaveEntry.setShadow(matches2);
|
||||
if (!matches
|
||||
|| profile.getCurrentAddress() != null
|
||||
&& !profile.getCurrentAddress().isEmpty()) {
|
||||
if (this.matchesEnabled(sender, punishmentType)) {
|
||||
Player player = (Player) sender;
|
||||
IBanWave banWave2 = banWave;
|
||||
BanWaveEntry banWaveEntry2 = banWaveEntry;
|
||||
Tasks.run(
|
||||
() -> {
|
||||
Phoenix phoenix = this.plugin;
|
||||
String text3 =
|
||||
LocaleUtil.tr(player, MessageConfig.PUNISHMENT.PROOF_PROMPT)
|
||||
.replace("<type>", punishmentType.getNiceName())
|
||||
.replace(
|
||||
"<player>",
|
||||
profile.getNameWithColorNoDisguise());
|
||||
ConversationUtil.ask(
|
||||
phoenix,
|
||||
player,
|
||||
text3,
|
||||
result -> {
|
||||
if (result != null && !result.trim().isEmpty()) {
|
||||
banWaveEntry2
|
||||
.getProof()
|
||||
.add(
|
||||
this.plugin
|
||||
.getPunishmentHandler()
|
||||
.createProof(
|
||||
ProofType.LINK,
|
||||
result.trim(),
|
||||
player
|
||||
.getUniqueId()));
|
||||
Tasks.runAsync(
|
||||
this.plugin,
|
||||
() ->
|
||||
this.sendMessage(
|
||||
player,
|
||||
banWave2,
|
||||
banWaveEntry2,
|
||||
profile));
|
||||
} else {
|
||||
player.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(
|
||||
player,
|
||||
MessageConfig.PUNISHMENT
|
||||
.PROOF_CANCELLED)));
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
this.sendMessage(sender, banWave, banWaveEntry, profile);
|
||||
}
|
||||
} else {
|
||||
throw new ExitMessage(
|
||||
LocaleUtil.tr(sender, MessageConfig.BAN_WAVE.NO_ADDRESS)
|
||||
.replace("<player>", profile.getNameWithColorNoDisguise()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void sendMessage(
|
||||
CommandSender sender, IBanWave banWave, IBanWaveEntry banWaveEntry, IProfile profile) {
|
||||
banWave.getEntries().add(banWaveEntry);
|
||||
this.plugin.getBanWaveHandler().save(banWave);
|
||||
sender.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(sender, MessageConfig.BAN_WAVE.STAGED)
|
||||
.replace("<player>", profile.getNameWithColorNoDisguise())
|
||||
.replace("<wave>", banWave.getName())
|
||||
.replace("<amount>", String.valueOf(banWave.getEntries().size()))));
|
||||
}
|
||||
|
||||
private boolean matchesEnabled(CommandSender sender, PunishmentType punishmentType) {
|
||||
if (!SettingsConfig.SERVER.PUNISHMENTS.REQUIRE_PROOF.ENABLED) {
|
||||
return false;
|
||||
}
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
for (String text : SettingsConfig.SERVER.PUNISHMENTS.REQUIRE_PROOF.TYPES) {
|
||||
if (punishmentType.name().equalsIgnoreCase(text.trim())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Command(name = "remove", description = "Take an account back out of a wave", async = true)
|
||||
@Requires("core.command.banwave.remove")
|
||||
public void remove(
|
||||
@Sender CommandSender sender,
|
||||
@Named("wave") String text,
|
||||
@Option({"disguise", "multiple"}) IProfile profile) {
|
||||
this.applyCommandSender(sender);
|
||||
IBanWave banWave;
|
||||
List<IBanWaveEntry> entries = (banWave = this.findBanWave(sender, text)).getEntries();
|
||||
if (!entries.removeIf(result -> result.getTarget().equals(profile.getUniqueId()))) {
|
||||
throw new ExitMessage(
|
||||
LocaleUtil.tr(sender, MessageConfig.BAN_WAVE.NOT_STAGED)
|
||||
.replace("<player>", profile.getNameWithColorNoDisguise()));
|
||||
}
|
||||
this.plugin.getBanWaveHandler().save(banWave);
|
||||
sender.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(sender, MessageConfig.BAN_WAVE.UNSTAGED)
|
||||
.replace("<player>", profile.getNameWithColorNoDisguise())
|
||||
.replace("<wave>", banWave.getName())));
|
||||
}
|
||||
|
||||
@Command(name = "list", description = "The waves still waiting", async = true)
|
||||
@Requires("core.command.banwave.list")
|
||||
public void list(@Sender CommandSender sender) {
|
||||
this.applyCommandSender(sender);
|
||||
if (this.plugin.getBanWaveHandler().pending().isEmpty()) {
|
||||
throw new ExitMessage(LocaleUtil.tr(sender, MessageConfig.BAN_WAVE.NONE));
|
||||
}
|
||||
for (String text : LocaleUtil.tr(sender, MessageConfig.BAN_WAVE.LIST_HEADER)) {
|
||||
sender.sendMessage(Color.translate(text));
|
||||
}
|
||||
for (IBanWave banWave : this.plugin.getBanWaveHandler().pending()) {
|
||||
sender.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(sender, MessageConfig.BAN_WAVE.LIST_ENTRY)
|
||||
.replace("<wave>", banWave.getName())
|
||||
.replace(
|
||||
"<amount>", String.valueOf(banWave.getEntries().size()))
|
||||
.replace("<when>", this.formatString(sender, banWave))));
|
||||
}
|
||||
}
|
||||
|
||||
@Command(name = "view", description = "What is staged in a wave", async = true)
|
||||
@Requires("core.command.banwave.view")
|
||||
public void view(@Sender CommandSender sender, @Named("wave") String text) {
|
||||
this.applyCommandSender(sender);
|
||||
IBanWave banWave = this.findBanWave(sender, text);
|
||||
sender.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(sender, MessageConfig.BAN_WAVE.VIEW_HEADER)
|
||||
.replace("<wave>", banWave.getName())
|
||||
.replace("<amount>", String.valueOf(banWave.getEntries().size()))
|
||||
.replace("<when>", this.formatString(sender, banWave))));
|
||||
for (IBanWaveEntry banWaveEntry : banWave.getEntries()) {
|
||||
sender.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(sender, MessageConfig.BAN_WAVE.VIEW_ENTRY)
|
||||
.replace("<player>", banWaveEntry.getTargetName())
|
||||
.replace(
|
||||
"<type>",
|
||||
(banWaveEntry.isIp()
|
||||
? LocaleUtil.tr(
|
||||
sender,
|
||||
MessageConfig.BAN_WAVE
|
||||
.IP_PREFIX)
|
||||
: "")
|
||||
+ banWaveEntry.getType().getNiceName())
|
||||
.replace(
|
||||
"<time>",
|
||||
banWaveEntry.isPermanent()
|
||||
? LocaleUtil.tr(
|
||||
sender,
|
||||
MessageConfig.BAN_WAVE.PERMANENT)
|
||||
: DateUtils.formatTimeMillis(
|
||||
banWaveEntry.getDuration()))
|
||||
.replace("<reason>", banWaveEntry.getReason())));
|
||||
}
|
||||
}
|
||||
|
||||
@Command(name = "schedule", description = "Set the day and time a wave goes out", async = true)
|
||||
@Requires("core.command.banwave.schedule")
|
||||
public void schedule(
|
||||
@Sender CommandSender sender,
|
||||
@Named("wave") String text,
|
||||
@Named("when (yyyy-MM-dd HH:mm, or a duration)") @Text String text2) {
|
||||
this.applyCommandSender(sender);
|
||||
IBanWave banWave = this.findBanWave(sender, text);
|
||||
long value;
|
||||
if ((value = this.calculateTime(text2)) <= 0L) {
|
||||
throw new ExitMessage(LocaleUtil.tr(sender, MessageConfig.BAN_WAVE.BAD_TIME));
|
||||
}
|
||||
if (value <= System.currentTimeMillis()) {
|
||||
throw new ExitMessage(LocaleUtil.tr(sender, MessageConfig.BAN_WAVE.TIME_PASSED));
|
||||
}
|
||||
banWave.setReleaseAt(value);
|
||||
this.plugin.getBanWaveHandler().save(banWave);
|
||||
sender.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(sender, MessageConfig.BAN_WAVE.SCHEDULED)
|
||||
.replace("<wave>", banWave.getName())
|
||||
.replace("<when>", DateUtils.getDate(value))
|
||||
.replace(
|
||||
"<remaining>",
|
||||
DateUtils.formatTimeMillis(
|
||||
value - System.currentTimeMillis()))));
|
||||
}
|
||||
|
||||
@Command(name = "unschedule", description = "Stop a wave going out on its own", async = true)
|
||||
@Requires("core.command.banwave.unschedule")
|
||||
public void unschedule(@Sender CommandSender sender, @Named("wave") String text) {
|
||||
this.applyCommandSender(sender);
|
||||
IBanWave banWave;
|
||||
(banWave = this.findBanWave(sender, text)).setReleaseAt(0L);
|
||||
this.plugin.getBanWaveHandler().save(banWave);
|
||||
sender.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(sender, MessageConfig.BAN_WAVE.UNSCHEDULED)
|
||||
.replace("<wave>", banWave.getName())));
|
||||
}
|
||||
|
||||
@Command(name = "release", description = "Send a wave out now")
|
||||
@Requires("core.command.banwave.release")
|
||||
public void release(@Sender Player player, @Named("wave") String text) {
|
||||
this.applyCommandSender(player);
|
||||
IBanWave banWave;
|
||||
if ((banWave = this.findBanWave(player, text)).getEntries().isEmpty()) {
|
||||
throw new ExitMessage(
|
||||
LocaleUtil.tr(player, MessageConfig.BAN_WAVE.EMPTY)
|
||||
.replace("<wave>", banWave.getName()));
|
||||
}
|
||||
Phoenix phoenix = this.plugin;
|
||||
String text2 =
|
||||
LocaleUtil.tr(player, MessageConfig.BAN_WAVE.CONFIRM)
|
||||
.replace("<wave>", banWave.getName())
|
||||
.replace("<amount>", String.valueOf(banWave.getEntries().size()));
|
||||
IBanWave banWave2 = banWave;
|
||||
ConfirmationMenus.applyPhoenix(
|
||||
phoenix,
|
||||
player,
|
||||
text2,
|
||||
true,
|
||||
result -> {
|
||||
if (result) {
|
||||
this.plugin.getBanWaveHandler().release(banWave2, player);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "void",
|
||||
description = "Take back a wave that has already gone out",
|
||||
async = true)
|
||||
@Requires("core.command.banwave.void")
|
||||
public void voidWave(
|
||||
@Sender Player player,
|
||||
@Named("wave") String text,
|
||||
@Named("void reason") VoidReason voidReason) {
|
||||
this.applyCommandSender(player);
|
||||
IBanWave banWave;
|
||||
if (!(banWave = this.findBanWave(player, text)).isReleased()) {
|
||||
throw new ExitMessage(
|
||||
LocaleUtil.tr(player, MessageConfig.BAN_WAVE.NOT_RELEASED)
|
||||
.replace("<wave>", banWave.getName()));
|
||||
}
|
||||
if (banWave.getIssued().isEmpty()) {
|
||||
throw new ExitMessage(
|
||||
LocaleUtil.tr(player, MessageConfig.BAN_WAVE.NOTHING_TO_VOID)
|
||||
.replace("<wave>", banWave.getName()));
|
||||
}
|
||||
Phoenix phoenix = this.plugin;
|
||||
String text2 =
|
||||
LocaleUtil.tr(player, MessageConfig.BAN_WAVE.CONFIRM_VOID)
|
||||
.replace("<wave>", banWave.getName())
|
||||
.replace("<amount>", String.valueOf(banWave.getIssued().size()));
|
||||
IBanWave banWave2 = banWave;
|
||||
ConfirmationMenus.applyPhoenix(
|
||||
phoenix,
|
||||
player,
|
||||
text2,
|
||||
true,
|
||||
result -> {
|
||||
if (result) {
|
||||
Tasks.runAsync(
|
||||
this.plugin,
|
||||
() -> {
|
||||
int value =
|
||||
this.plugin
|
||||
.getBanWaveHandler()
|
||||
.voidWave(banWave2, player, voidReason);
|
||||
player.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(
|
||||
player,
|
||||
MessageConfig.BAN_WAVE.VOIDED)
|
||||
.replace("<wave>", banWave2.getName())
|
||||
.replace(
|
||||
"<amount>",
|
||||
String.valueOf(value))
|
||||
.replace(
|
||||
"<void_reason>",
|
||||
voidReason.getNiceName())));
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Command(name = "cancel", description = "Throw a wave away without releasing it", async = true)
|
||||
@Requires("core.command.banwave.cancel")
|
||||
public void cancel(@Sender CommandSender sender, @Named("wave") String text) {
|
||||
this.applyCommandSender(sender);
|
||||
IBanWave banWave = this.findBanWave(sender, text);
|
||||
this.plugin.getBanWaveHandler().delete(banWave);
|
||||
sender.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(sender, MessageConfig.BAN_WAVE.CANCELLED)
|
||||
.replace("<wave>", banWave.getName())));
|
||||
}
|
||||
|
||||
private long calculateTime(String text) {
|
||||
String text2 = text.trim();
|
||||
try {
|
||||
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
|
||||
return LocalDateTime.parse(text2, dateTimeFormatter)
|
||||
.atZone(ZoneId.systemDefault())
|
||||
.toInstant()
|
||||
.toEpochMilli();
|
||||
} catch (DateTimeParseException dateTimeParseException) {
|
||||
Duration duration;
|
||||
return (duration = Duration.of(text2)) != null && !duration.isEnabled()
|
||||
? System.currentTimeMillis() + duration.getTimeTime()
|
||||
: 0L;
|
||||
}
|
||||
}
|
||||
|
||||
private String formatString(CommandSender sender, IBanWave banWave) {
|
||||
return banWave.getReleaseAt() <= 0L
|
||||
? LocaleUtil.tr(sender, MessageConfig.BAN_WAVE.MANUAL)
|
||||
: DateUtils.getDate(banWave.getReleaseAt());
|
||||
}
|
||||
|
||||
private IBanWave findBanWave(CommandSender sender, String text) {
|
||||
IBanWave banWave;
|
||||
if ((banWave = this.plugin.getBanWaveHandler().byName(text)) != null
|
||||
&& !banWave.isReleased()) {
|
||||
return banWave;
|
||||
} else {
|
||||
throw new ExitMessage(
|
||||
LocaleUtil.tr(sender, MessageConfig.BAN_WAVE.DOESNT_EXIST)
|
||||
.replace("<wave>", text));
|
||||
}
|
||||
}
|
||||
|
||||
private void applyCommandSender(CommandSender sender) {
|
||||
if (!SettingsConfig.BAN_WAVES.ENABLED) {
|
||||
throw new ExitMessage(LocaleUtil.tr(sender, MessageConfig.BAN_WAVE.DISABLED));
|
||||
}
|
||||
}
|
||||
|
||||
public BanwaveCommand(Phoenix phoenix) {
|
||||
this.plugin = phoenix;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Named;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Text;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
|
||||
@Register(name = "broadcast", aliases = "bc")
|
||||
@Requires("core.command.broadcast")
|
||||
public class BroadcastCommand {
|
||||
|
||||
private static final String text = "<message>";
|
||||
|
||||
@Command(name = "")
|
||||
public void execute(@Sender CommandSender sender, @Named("message") @Text String text2) {
|
||||
Bukkit.broadcastMessage(
|
||||
Color.translate(
|
||||
MessageConfig.BASIC.ADMIN.BROADCAST.replace(text, Color.translate(text2))));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Optional;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.lib.commands.exception.execution.ExitMessage;
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.config.SettingsConfig;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
|
||||
@Register(name = "build", aliases = "buildmode")
|
||||
@Requires("core.command.build")
|
||||
public class BuildCommand {
|
||||
|
||||
private final Phoenix plugin;
|
||||
|
||||
@Command(name = "")
|
||||
public void execute(
|
||||
@Sender Player player,
|
||||
@Optional @Requires("core.command.build.others") Player player2) {
|
||||
if (!SettingsConfig.BASICS.BUILDMODE) {
|
||||
throw new ExitMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(
|
||||
player, MessageConfig.BASIC.ADMIN.BUILD.DISABLED_IN_CONFIG)));
|
||||
}
|
||||
if (player2 == null) {
|
||||
if (player.hasMetadata("BuildMode")) {
|
||||
player.removeMetadata("BuildMode", this.plugin);
|
||||
} else {
|
||||
player.setMetadata("BuildMode", new FixedMetadataValue(this.plugin, true));
|
||||
}
|
||||
player.sendMessage(
|
||||
player.hasMetadata("BuildMode")
|
||||
? Color.translate(MessageConfig.BASIC.ADMIN.BUILD.ENABLED)
|
||||
: Color.translate(MessageConfig.BASIC.ADMIN.BUILD.DISABLED));
|
||||
} else {
|
||||
IProfile profile = this.plugin.getProfileHandler().getProfile(player2.getUniqueId());
|
||||
if (player2.hasMetadata("BuildMode")) {
|
||||
player2.removeMetadata("BuildMode", this.plugin);
|
||||
} else {
|
||||
player2.setMetadata("BuildMode", new FixedMetadataValue(this.plugin, true));
|
||||
}
|
||||
player2.sendMessage(
|
||||
player2.hasMetadata("BuildMode")
|
||||
? Color.translate(MessageConfig.BASIC.ADMIN.BUILD.ENABLED)
|
||||
: Color.translate(MessageConfig.BASIC.ADMIN.BUILD.DISABLED));
|
||||
player.sendMessage(
|
||||
player2.hasMetadata("BuildMode")
|
||||
? Color.translate(
|
||||
MessageConfig.BASIC.ADMIN.BUILD.ENABLED_OTHER.replace(
|
||||
"<player>", profile.getNameWithColorNoDisguise()))
|
||||
: Color.translate(
|
||||
MessageConfig.BASIC.ADMIN.BUILD.DISABLED_OTHER.replace(
|
||||
"<player>", profile.getNameWithColorNoDisguise())));
|
||||
}
|
||||
}
|
||||
|
||||
public BuildCommand(Phoenix phoenix) {
|
||||
this.plugin = phoenix;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Help;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Default;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Named;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Option;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Optional;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.phoenix.CommonPlatform;
|
||||
import xyz.refinedev.phoenix.commands.api.annotations.DurationInput;
|
||||
import xyz.refinedev.phoenix.commands.provider.DurationProvider;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.profile.chatsnapshot.IChatLog;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
import xyz.refinedev.phoenix.utils.PaginatedListClickable;
|
||||
import xyz.refinedev.phoenix.utils.chat.Clickable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Help
|
||||
@Register(name = "chatlogs")
|
||||
@Requires("core.command.chatlogs")
|
||||
public class ChatlogsCommand {
|
||||
|
||||
private final CommonPlatform platform;
|
||||
|
||||
@Command(name = "search", async = true)
|
||||
public void search(
|
||||
@Sender CommandSender sender,
|
||||
@Option({"disguise", "multiple"}) IProfile profile,
|
||||
@Named("message") String text,
|
||||
@Default("1") @Named("page") int value) {
|
||||
List<IChatLog> values =
|
||||
this.platform.getChatLogHandler().getByPlayer(profile.getUuid(), text).join();
|
||||
ArrayList<Clickable> values2 = new ArrayList<>();
|
||||
String nameWithColorNoDisguise = profile.getNameWithColorNoDisguise();
|
||||
String prefix = profile.getGeneralRank().getPrefix();
|
||||
for (IChatLog chatLog : values) {
|
||||
Clickable clickable =
|
||||
new Clickable(
|
||||
LocaleUtil.tr(sender, MessageConfig.CHAT_LOGS.FORMAT)
|
||||
.replace("<id>", chatLog.getId())
|
||||
.replace("<prefix>", prefix)
|
||||
.replace("<sender>", nameWithColorNoDisguise)
|
||||
.replace("<message>", chatLog.getMessage())
|
||||
.replace("<date>", chatLog.getNiceCreatedOn()));
|
||||
values2.add(clickable);
|
||||
}
|
||||
new PaginatedListClickable(
|
||||
"Chat Logs",
|
||||
profile.getNameWithColorNoDisguise(),
|
||||
"/chatlogs search " + profile.getName() + " " + text)
|
||||
.display(sender, value, values2);
|
||||
}
|
||||
|
||||
@Command(name = "view", async = true)
|
||||
public void view(
|
||||
@Sender CommandSender sender,
|
||||
@Option({"disguise", "multiple"}) IProfile profile,
|
||||
@Optional @Named("time") @DurationInput String text,
|
||||
@Default("1") @Named("page") int value) {
|
||||
long value2 = text != null ? DurationProvider.tr(sender, text, true).getTimeTime() : -5L;
|
||||
List<IChatLog> values =
|
||||
text != null
|
||||
? this.platform
|
||||
.getChatLogHandler()
|
||||
.getByPlayer(
|
||||
profile.getUuid(),
|
||||
value2 == -5L ? -5L : System.currentTimeMillis() - value2)
|
||||
.join()
|
||||
: this.platform.getChatLogHandler().getByPlayer(profile.getUuid()).join();
|
||||
ArrayList<Clickable> values2 = new ArrayList<>();
|
||||
String nameWithColorNoDisguise = profile.getNameWithColorNoDisguise();
|
||||
String prefix = profile.getGeneralRank().getPrefix();
|
||||
for (IChatLog chatLog : values) {
|
||||
Clickable clickable =
|
||||
new Clickable(
|
||||
LocaleUtil.tr(sender, MessageConfig.CHAT_LOGS.FORMAT)
|
||||
.replace("<id>", chatLog.getId())
|
||||
.replace("<prefix>", prefix)
|
||||
.replace("<sender>", nameWithColorNoDisguise)
|
||||
.replace("<message>", chatLog.getMessage())
|
||||
.replace("<date>", chatLog.getNiceCreatedOn()));
|
||||
values2.add(clickable);
|
||||
}
|
||||
new PaginatedListClickable(
|
||||
"Chat Logs",
|
||||
profile.getNameWithColorNoDisguise(),
|
||||
"/chatlogs view "
|
||||
+ profile.getName()
|
||||
+ (text != null ? " " + text : " perm"))
|
||||
.display(sender, value, values2);
|
||||
}
|
||||
|
||||
@Command(name = "clear")
|
||||
@Requires("core.command.chatlogs.clear")
|
||||
public void clear(
|
||||
@Sender CommandSender sender, @Option({"disguise", "multiple"}) IProfile profile) {
|
||||
this.platform.getChatLogHandler().clearLogs(profile.getUuid());
|
||||
sender.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(sender, MessageConfig.CHAT_LOGS.CLEAR)
|
||||
.replace("<target>", profile.getNameWithColorNoDisguise())));
|
||||
}
|
||||
|
||||
public ChatlogsCommand(CommonPlatform commonPlatform) {
|
||||
this.platform = commonPlatform;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Help;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Default;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Named;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Option;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Optional;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.lib.commands.exception.execution.ExitMessage;
|
||||
import xyz.refinedev.phoenix.BukkitAPI;
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.config.SettingsConfig;
|
||||
import xyz.refinedev.phoenix.menu.impl.ChatsnapshotMenu;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.profile.chatsnapshot.IChatEntry;
|
||||
import xyz.refinedev.phoenix.profile.chatsnapshot.IChatSnapshot;
|
||||
import xyz.refinedev.phoenix.profile.cooldown.Cooldown;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.DateUtils;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
import xyz.refinedev.phoenix.utils.MetricsReporter;
|
||||
import xyz.refinedev.phoenix.utils.PaginatedListClickable;
|
||||
import xyz.refinedev.phoenix.utils.chat.Clickable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Help
|
||||
@Register(name = "chatsnapshot", aliases = "chatsnapshots")
|
||||
@Requires("core.command.chatsnapshot")
|
||||
public class ChatsnapshotCommand {
|
||||
|
||||
private final Phoenix plugin;
|
||||
|
||||
@Command(name = "create")
|
||||
@Requires("core.command.chatsnapshot.create")
|
||||
public void create(@Sender CommandSender sender, @Optional Player player) {
|
||||
MetricsReporter.applyString("chatsnapshots");
|
||||
if (sender instanceof Player) {
|
||||
Player player2 = (Player) sender;
|
||||
IProfile cachedProfile =
|
||||
this.plugin.getProfileHandler().getCachedProfile(player2.getUniqueId());
|
||||
if (!player2.hasPermission("core.cooldowns.bypass")
|
||||
&& cachedProfile.hasGlobalCooldown("chatSnapshot")) {
|
||||
throw new ExitMessage(
|
||||
LocaleUtil.tr(sender, MessageConfig.COOLDOWNS.SNAPSHOT_COOLDOWN)
|
||||
.replace(
|
||||
"<remaining>",
|
||||
DateUtils.formatTimeMillis(
|
||||
cachedProfile.getGlobalRemaining("chatSnapshot"))));
|
||||
}
|
||||
cachedProfile
|
||||
.getGlobalCooldowns()
|
||||
.add(
|
||||
new Cooldown(
|
||||
BukkitAPI.parseDuration(SettingsConfig.COOLDOWNS.CHAT_SNAPSHOT),
|
||||
"chatSnapshot"));
|
||||
cachedProfile.saveProfile();
|
||||
}
|
||||
UUID uUID =
|
||||
sender instanceof Player
|
||||
? ((Player) sender).getUniqueId()
|
||||
: IProfile.getConsoleUuid();
|
||||
IChatSnapshot chatSnapshot;
|
||||
if (player != null) {
|
||||
chatSnapshot =
|
||||
this.plugin.getChatSnapshotHandler().createSnapshot(uUID, player.getUniqueId());
|
||||
} else {
|
||||
chatSnapshot = this.plugin.getChatSnapshotHandler().createSnapshot(uUID);
|
||||
}
|
||||
if (chatSnapshot != null) {
|
||||
sender.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(sender, MessageConfig.CHAT_SNAPSHOT.CREATED)
|
||||
.replace("<id>", chatSnapshot.getNiceId())));
|
||||
} else {
|
||||
throw new ExitMessage(
|
||||
LocaleUtil.tr(sender, MessageConfig.CHAT_SNAPSHOT.NO_CHAT_MESSAGES));
|
||||
}
|
||||
}
|
||||
|
||||
@Command(name = "delete")
|
||||
@Requires("core.command.chatsnapshot.delete")
|
||||
public void delete(@Sender CommandSender sender, IChatSnapshot chatSnapshot) {
|
||||
this.plugin.getChatSnapshotHandler().deleteSnapshot(chatSnapshot);
|
||||
sender.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(sender, MessageConfig.CHAT_SNAPSHOT.DELETED)
|
||||
.replace("<id>", chatSnapshot.getNiceId())));
|
||||
}
|
||||
|
||||
@Command(name = "own")
|
||||
@Requires("core.command.chatsnapshot.own")
|
||||
public void own(@Sender Player player) {
|
||||
CompletableFuture<List<IChatSnapshot>> byPlayer =
|
||||
this.plugin.getChatSnapshotHandler().getByPlayer(player.getUniqueId());
|
||||
byPlayer.whenCompleteAsync(
|
||||
(result, result2) ->
|
||||
this.plugin
|
||||
.getMenuHandler()
|
||||
.openMenuAsync(
|
||||
new ChatsnapshotMenu((List<IChatSnapshot>) result, true),
|
||||
player));
|
||||
}
|
||||
|
||||
@Command(name = "player")
|
||||
@Requires("core.command.chatsnapshot.player")
|
||||
public void player(
|
||||
@Sender Player player2,
|
||||
@Named("player") @Option({"disguise", "multiple"}) IProfile profile) {
|
||||
CompletableFuture<List<IChatSnapshot>> byPlayer =
|
||||
this.plugin.getChatSnapshotHandler().getByPlayer(profile.getUniqueId());
|
||||
byPlayer.whenCompleteAsync(
|
||||
(result, result2) ->
|
||||
this.plugin
|
||||
.getMenuHandler()
|
||||
.openMenuAsync(
|
||||
new ChatsnapshotMenu((List<IChatSnapshot>) result, false),
|
||||
player2));
|
||||
}
|
||||
|
||||
@Command(name = "view", async = true)
|
||||
@Requires("core.command.chatsnapshot.view")
|
||||
public void view(
|
||||
@Sender Player player,
|
||||
IChatSnapshot chatSnapshot,
|
||||
@Default("1") @Named("page") int value) {
|
||||
PaginatedListClickable paginatedListClickable =
|
||||
new PaginatedListClickable(
|
||||
"Entries",
|
||||
DateUtils.getDate(chatSnapshot.getCreatedOn()),
|
||||
"/chatsnapshot view " + chatSnapshot.getNiceId());
|
||||
ArrayList<Clickable> values = new ArrayList<>();
|
||||
for (IChatEntry chatEntry : chatSnapshot.getChat()) {
|
||||
values.add(
|
||||
new Clickable("&7[" + chatEntry.getNiceTime() + "] " + chatEntry.getMessage()));
|
||||
}
|
||||
paginatedListClickable.display(player, value, values);
|
||||
}
|
||||
|
||||
public ChatsnapshotCommand(Phoenix phoenix) {
|
||||
this.plugin = phoenix;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Optional;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
|
||||
@Register(
|
||||
name = "clear",
|
||||
aliases = {"clearinv", "ci"})
|
||||
@Requires("core.command.clear")
|
||||
public class ClearCommand {
|
||||
|
||||
private final Phoenix plugin;
|
||||
|
||||
@Command(name = "")
|
||||
public void execute(
|
||||
@Sender Player player,
|
||||
@Optional @Requires("core.command.clear.others") Player player2) {
|
||||
if (player2 != null) {
|
||||
int value = this.calculateCount(player2);
|
||||
player2.getInventory().clear();
|
||||
player2.getInventory().setArmorContents(null);
|
||||
player2.updateInventory();
|
||||
player.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(player, MessageConfig.BASIC.ADMIN.CLEAR.OTHER)
|
||||
.replace(
|
||||
"<player>",
|
||||
this.plugin
|
||||
.getProfileHandler()
|
||||
.getProfile(player2.getUniqueId())
|
||||
.getNameWithColor())
|
||||
.replace("<total>", String.valueOf(value))));
|
||||
player2.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(player2, MessageConfig.BASIC.ADMIN.CLEAR.R_OTHER)
|
||||
.replace(
|
||||
"<player>",
|
||||
this.plugin
|
||||
.getProfileHandler()
|
||||
.getProfile(player.getUniqueId())
|
||||
.getNameWithColor())
|
||||
.replace("<total>", String.valueOf(value))));
|
||||
} else {
|
||||
int value2 = this.calculateCount(player);
|
||||
player.getInventory().clear();
|
||||
player.getInventory().setArmorContents(null);
|
||||
player.updateInventory();
|
||||
player.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(player, MessageConfig.BASIC.ADMIN.CLEAR.SELF)
|
||||
.replace("<total>", String.valueOf(value2))));
|
||||
}
|
||||
}
|
||||
|
||||
private int calculateCount(Player player) {
|
||||
int value = 0;
|
||||
ItemStack[] itemStacks;
|
||||
int value2 = (itemStacks = player.getInventory().getContents()).length;
|
||||
for (int index = 0; index < value2; index++) {
|
||||
ItemStack itemStack;
|
||||
if ((itemStack = itemStacks[index]) != null) {
|
||||
value += itemStack.getAmount();
|
||||
}
|
||||
}
|
||||
value2 = (itemStacks = player.getInventory().getArmorContents()).length;
|
||||
for (int index2 = 0; index2 < value2; index2++) {
|
||||
ItemStack itemStack2;
|
||||
if ((itemStack2 = itemStacks[index2]) != null) {
|
||||
value += itemStack2.getAmount();
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public ClearCommand(Phoenix phoenix) {
|
||||
this.plugin = phoenix;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.config.GlobalConfig;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.packet.impl.server.SendToStaffPacket;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
@Register(name = "clearchat")
|
||||
@Requires("core.command.clearchat")
|
||||
public class ClearchatCommand {
|
||||
|
||||
private final Phoenix plugin;
|
||||
|
||||
@Command(name = "", async = true)
|
||||
public void execute(@Sender CommandSender sender) {
|
||||
String[] texts = new String[10];
|
||||
for (int index = 0; index < 9; index++) {
|
||||
texts[index] = Color.translate("&" + index);
|
||||
}
|
||||
Iterator iterator2 = Bukkit.getOnlinePlayers().iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
Player player;
|
||||
if ((player = (Player) iterator2.next()).hasPermission("core.clearchat.bypass")) {
|
||||
return;
|
||||
}
|
||||
IntStream intStream = IntStream.range(0, 1000);
|
||||
Player player2 = player;
|
||||
intStream.forEach(result -> player2.sendMessage(texts[result % 9]));
|
||||
}
|
||||
String text =
|
||||
sender instanceof Player
|
||||
? Color.translate(
|
||||
this.plugin
|
||||
.getProfileHandler()
|
||||
.getProfile(((Player) sender).getUniqueId())
|
||||
.getNameWithColorNoDisguise())
|
||||
: Color.translate(GlobalConfig.SERVER.CONSOLE_NAME);
|
||||
for (Player player3 : Bukkit.getOnlinePlayers()) {
|
||||
player3.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(player3, MessageConfig.CHAT.CLEARED)
|
||||
.replace("<player>", text)));
|
||||
}
|
||||
Bukkit.getConsoleSender()
|
||||
.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(Bukkit.getConsoleSender(), MessageConfig.CHAT.CLEARED)
|
||||
.replace("<player>", text)));
|
||||
this.plugin
|
||||
.getPacketHandler()
|
||||
.send(
|
||||
new SendToStaffPacket(
|
||||
MessageConfig.STAFF.CLEAR_CHAT_ALERT,
|
||||
LocaleUtil.replacements(
|
||||
"<player>",
|
||||
text,
|
||||
"<server>",
|
||||
this.plugin.getNetworkHandler().getDisplayName()),
|
||||
false,
|
||||
true));
|
||||
}
|
||||
|
||||
public ClearchatCommand(Phoenix phoenix) {
|
||||
this.plugin = phoenix;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Help;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Default;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Flag;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Named;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Option;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.phoenix.CommonPlatform;
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.commands.api.annotations.DurationInput;
|
||||
import xyz.refinedev.phoenix.commands.provider.DurationProvider;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.profile.commandlog.ICommandLog;
|
||||
import xyz.refinedev.phoenix.server.IServerData;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.DateUtils;
|
||||
import xyz.refinedev.phoenix.utils.Duration;
|
||||
import xyz.refinedev.phoenix.utils.EncryptedPasteBuilder;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@Help
|
||||
@Register(name = "commandlogs", aliases = "clogs")
|
||||
@Requires("core.command.commandlogs")
|
||||
public class CommandlogsCommand {
|
||||
|
||||
private final CommonPlatform platform;
|
||||
|
||||
@Command(name = "player")
|
||||
public void player(
|
||||
@Sender CommandSender sender,
|
||||
@Option("multiple") @Named("player") IProfile profile,
|
||||
@Named("time") @Default("perm") @DurationInput String text,
|
||||
@Flag("password") String text2,
|
||||
@Flag("delete-after-open") boolean matches) {
|
||||
Duration duration = DurationProvider.tr(sender, text, true);
|
||||
CompletableFuture<java.util.List<ICommandLog>> completableFuture =
|
||||
this.platform
|
||||
.getCommandLogHandler()
|
||||
.findByIssuedBy(
|
||||
profile.getUniqueId(),
|
||||
System.currentTimeMillis() - duration.getTimeTime(),
|
||||
duration.isEnabled());
|
||||
completableFuture.whenComplete(
|
||||
(result, result2) -> {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (ICommandLog commandLog : (Iterable<ICommandLog>) ((Iterable) result)) {
|
||||
stringBuilder
|
||||
.append("[")
|
||||
.append(DateUtils.getDate(commandLog.getIssuedOn()))
|
||||
.append(" @ ")
|
||||
.append(commandLog.getServer())
|
||||
.append("] ")
|
||||
.append(commandLog.getNiceIssuedBy())
|
||||
.append(": ")
|
||||
.append(commandLog.getCommand())
|
||||
.append(" - ")
|
||||
.append(this.formatString(commandLog.getIssuedOn()))
|
||||
.append("\n");
|
||||
}
|
||||
EncryptedPasteBuilder encryptedPasteBuilder;
|
||||
(encryptedPasteBuilder = new EncryptedPasteBuilder())
|
||||
.findEncryptedPasteBuilderByTextString(stringBuilder.toString());
|
||||
if (text2 != null && !text2.isEmpty()) {
|
||||
encryptedPasteBuilder.findEncryptedPasteBuilder(text2);
|
||||
}
|
||||
encryptedPasteBuilder.findEncryptedPasteBuilder(matches);
|
||||
encryptedPasteBuilder.getEncryptedPasteBuilder();
|
||||
try {
|
||||
sender.sendMessage(
|
||||
Color.translate(
|
||||
Phoenix.SECONDARY_COLOR
|
||||
+ "Link: "
|
||||
+ encryptedPasteBuilder.getString()));
|
||||
} catch (Exception exception) {
|
||||
sender.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(sender, MessageConfig.ERROR.PASTE_FAILED)));
|
||||
Phoenix.getInstance()
|
||||
.getLogger()
|
||||
.log(
|
||||
Level.SEVERE,
|
||||
"An error occurred while creating a command logs paste:",
|
||||
exception);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Command(name = "server")
|
||||
public void server(
|
||||
@Sender CommandSender sender,
|
||||
IServerData serverData,
|
||||
@Named("time") @Default("perm") @DurationInput String text,
|
||||
@Flag("password") String text2,
|
||||
@Flag("delete-after-open") boolean matches) {
|
||||
Duration duration = DurationProvider.tr(sender, text, true);
|
||||
CompletableFuture<java.util.List<ICommandLog>> completableFuture =
|
||||
this.platform
|
||||
.getCommandLogHandler()
|
||||
.findByServer(
|
||||
serverData.getServerName(),
|
||||
System.currentTimeMillis() - duration.getTimeTime(),
|
||||
duration.isEnabled());
|
||||
completableFuture.whenComplete(
|
||||
(result, result2) -> {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (ICommandLog commandLog : (Iterable<ICommandLog>) ((Iterable) result)) {
|
||||
stringBuilder
|
||||
.append("[")
|
||||
.append(DateUtils.getDate(commandLog.getIssuedOn()))
|
||||
.append(" @ ")
|
||||
.append(commandLog.getServer())
|
||||
.append("] ")
|
||||
.append(commandLog.getNiceIssuedBy())
|
||||
.append(": ")
|
||||
.append(commandLog.getCommand())
|
||||
.append(" - ")
|
||||
.append(this.formatString(commandLog.getIssuedOn()))
|
||||
.append("\n");
|
||||
}
|
||||
EncryptedPasteBuilder encryptedPasteBuilder;
|
||||
(encryptedPasteBuilder = new EncryptedPasteBuilder())
|
||||
.findEncryptedPasteBuilderByTextString(stringBuilder.toString());
|
||||
if (text2 != null && !text2.isEmpty()) {
|
||||
encryptedPasteBuilder.findEncryptedPasteBuilder(text2);
|
||||
}
|
||||
encryptedPasteBuilder.findEncryptedPasteBuilder(matches);
|
||||
encryptedPasteBuilder.getEncryptedPasteBuilder();
|
||||
try {
|
||||
sender.sendMessage(
|
||||
Color.translate(
|
||||
Phoenix.SECONDARY_COLOR
|
||||
+ "Link: "
|
||||
+ encryptedPasteBuilder.getString()));
|
||||
} catch (Exception exception) {
|
||||
sender.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(sender, MessageConfig.ERROR.PASTE_FAILED)));
|
||||
Phoenix.getInstance()
|
||||
.getLogger()
|
||||
.log(
|
||||
Level.SEVERE,
|
||||
"An error occurred while creating a command logs paste:",
|
||||
exception);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public String formatString(long value) {
|
||||
Calendar instance = Calendar.getInstance();
|
||||
Calendar instance2 = Calendar.getInstance();
|
||||
instance.setTime(new Date(value));
|
||||
instance2.setTime(new Date(System.currentTimeMillis()));
|
||||
String text = DateUtils.formatDateDiff(instance, instance2);
|
||||
return text + (text.equals("now") ? "" : " ago");
|
||||
}
|
||||
|
||||
public CommandlogsCommand(CommonPlatform commonPlatform) {
|
||||
this.platform = commonPlatform;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
|
||||
@Register(name = "craft")
|
||||
@Requires("core.command.craft")
|
||||
public class CraftCommand {
|
||||
|
||||
@Command(name = "")
|
||||
public void execute(@Sender Player player) {
|
||||
player.openWorkbench(player.getLocation(), true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.menu.impl.tags.CustomTagsMenu;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Register(name = "customtags", aliases = "customtag")
|
||||
public class CustomtagsCommand {
|
||||
|
||||
private final Phoenix plugin;
|
||||
|
||||
@Command(name = "", async = true)
|
||||
public void execute(@Sender Player player) {
|
||||
List<xyz.refinedev.phoenix.profile.tag.ICustomTag> sortedTags =
|
||||
this.plugin.getCustomTagHandler().getSortedTags(player.getUniqueId());
|
||||
this.plugin.getMenuHandler().openMenuSync(new CustomTagsMenu(sortedTags), player);
|
||||
}
|
||||
|
||||
public CustomtagsCommand(Phoenix phoenix) {
|
||||
this.plugin = phoenix;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Help;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Default;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Named;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Option;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.lib.commands.exception.execution.ExitMessage;
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.config.MenuConfig;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.menu.impl.tags.CustomTagsAdminMenu;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.profile.tag.CustomTagStatus;
|
||||
import xyz.refinedev.phoenix.profile.tag.ICustomTag;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
import xyz.refinedev.phoenix.utils.PaginatedListClickable;
|
||||
import xyz.refinedev.phoenix.utils.chat.Clickable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
@Help
|
||||
@Register(
|
||||
name = "customtagsadmin",
|
||||
aliases = {"customtagadmin", "cta"})
|
||||
@Requires("core.command.customtagsadmin")
|
||||
public class CustomtagsadminCommand {
|
||||
|
||||
private final Phoenix plugin;
|
||||
|
||||
@Command(name = "manage")
|
||||
@Requires("core.command.customtagsadmin.manage")
|
||||
public void manage(@Sender Player player) {
|
||||
this.plugin.getMenuHandler().openMenu(new CustomTagsAdminMenu(), player);
|
||||
}
|
||||
|
||||
@Command(name = "list")
|
||||
@Requires("core.command.customtagsadmin.list")
|
||||
public void list(
|
||||
@Sender CommandSender sender,
|
||||
@Named("player") @Option({"disguise", "multiple"}) IProfile profile,
|
||||
@Default("1") @Named("page") int value) {
|
||||
PaginatedListClickable paginatedListClickable =
|
||||
new PaginatedListClickable(
|
||||
"Custom Tags",
|
||||
profile.getNameWithColorNoDisguise(),
|
||||
"/customtagsadmin list " + profile.getName());
|
||||
ArrayList<Clickable> values = new ArrayList<>();
|
||||
Iterator<ICustomTag> iterator2 =
|
||||
this.plugin.getCustomTagHandler().getTags(profile.getUniqueId()).iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
ICustomTag customTag;
|
||||
String text =
|
||||
(customTag = (ICustomTag) iterator2.next()).getStatus()
|
||||
== CustomTagStatus.ACCEPTED
|
||||
? LocaleUtil.tr(sender, MenuConfig.CUSTOM_TAGS.STATUS_ACCEPTED)
|
||||
: (customTag.getStatus() == CustomTagStatus.DENIED
|
||||
? LocaleUtil.tr(sender, MenuConfig.CUSTOM_TAGS.STATUS_DENIED)
|
||||
: LocaleUtil.tr(
|
||||
sender, MenuConfig.CUSTOM_TAGS.STATUS_UNDECIDED));
|
||||
Clickable clickable =
|
||||
new Clickable(
|
||||
LocaleUtil.tr(sender, MessageConfig.CUSTOM_TAGS_ADMIN.FORMAT)
|
||||
.replace("<tag>", customTag.getDisplayName())
|
||||
.replace("<tagId>", customTag.getName())
|
||||
.replace("<status>", text));
|
||||
values.add(clickable);
|
||||
}
|
||||
paginatedListClickable.display(sender, value, values);
|
||||
}
|
||||
|
||||
@Command(name = "check-tokens")
|
||||
@Requires("core.command.customtagsadmin.check-tokens")
|
||||
public void checkTokens(
|
||||
@Sender CommandSender sender,
|
||||
@Named("player") @Option({"disguise", "multiple"}) IProfile profile) {
|
||||
int intSetting = profile.getIntSetting("custom-tag-tokens", 0);
|
||||
sender.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(sender, MessageConfig.CUSTOM_TAGS_ADMIN.CHECK)
|
||||
.replace("<target>", profile.getNameWithColorNoDisguise())
|
||||
.replace("<amount>", intSetting + "")));
|
||||
}
|
||||
|
||||
@Command(name = "add-tokens")
|
||||
@Requires("core.command.customtagsadmin.add-tokens")
|
||||
public void addTokens(
|
||||
@Sender CommandSender sender,
|
||||
@Named("player") @Option({"disguise", "multiple"}) IProfile profile,
|
||||
@Named("amount") int value) {
|
||||
int value2 = profile.getIntSetting("custom-tag-tokens", 0) + value;
|
||||
profile.updateMetadata("custom-tag-tokens", String.valueOf(value2), true);
|
||||
sender.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(sender, MessageConfig.CUSTOM_TAGS_ADMIN.ADDED_TOKENS)
|
||||
.replace("<target>", profile.getNameWithColorNoDisguise())
|
||||
.replace("<amount>", value + "")
|
||||
.replace("<newTokens>", value2 + "")));
|
||||
}
|
||||
|
||||
@Command(name = "remove-tokens")
|
||||
@Requires("core.command.customtagsadmin.remove-tokens")
|
||||
public void removeTokens(
|
||||
@Sender CommandSender sender,
|
||||
@Named("player") @Option({"disguise", "multiple"}) IProfile profile,
|
||||
@Named("amount") int value) {
|
||||
int value2;
|
||||
if ((value2 = profile.getIntSetting("custom-tag-tokens", 0) - value) < 0) {
|
||||
throw new ExitMessage(
|
||||
LocaleUtil.tr(sender, MessageConfig.CUSTOM_TAGS_ADMIN.NOT_ENOUGH_TOKENS)
|
||||
.replace("<target>", profile.getNameWithColorNoDisguise()));
|
||||
}
|
||||
profile.updateMetadata("custom-tag-tokens", String.valueOf(value2), true);
|
||||
sender.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(sender, MessageConfig.CUSTOM_TAGS_ADMIN.REMOVED_TOKENS)
|
||||
.replace("<target>", profile.getNameWithColorNoDisguise())
|
||||
.replace("<amount>", value + "")
|
||||
.replace("<leftTokens>", value2 + "")));
|
||||
}
|
||||
|
||||
public CustomtagsadminCommand(Phoenix phoenix) {
|
||||
this.plugin = phoenix;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Named;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.lib.commands.exception.execution.ExitMessage;
|
||||
import xyz.refinedev.lib.kyori.adventure.text.Component;
|
||||
import xyz.refinedev.lib.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.utils.LimitedSizeList;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
import xyz.refinedev.phoenix.utils.Pair;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Register(name = "deletemessage")
|
||||
@Requires("core.command.deletemessage")
|
||||
public class DeletemessageCommand {
|
||||
|
||||
private final Phoenix plugin;
|
||||
|
||||
private final LegacyComponentSerializer legacyComponentSerializer =
|
||||
LegacyComponentSerializer.legacySection();
|
||||
|
||||
private final LimitedSizeList<UUID> limitedSizeList = new LimitedSizeList<>(500);
|
||||
|
||||
private List<Component> components;
|
||||
|
||||
@Command(name = "", async = true)
|
||||
public void execute(@Sender Player player, @Named("uuid") UUID uUID) {
|
||||
if (this.limitedSizeList.contains(uUID)) {
|
||||
throw new ExitMessage(
|
||||
LocaleUtil.tr(player, MessageConfig.ERROR.MESSAGE_ALREADY_DELETED));
|
||||
}
|
||||
this.limitedSizeList.add(uUID);
|
||||
int value = 0;
|
||||
for (Player player2 :
|
||||
(Iterable<Player>) ((Iterable) new ArrayList(Bukkit.getOnlinePlayers()))) {
|
||||
if (this.matchesEnabled(player2, uUID)) {
|
||||
value++;
|
||||
}
|
||||
}
|
||||
if (this.plugin.isDebugMode()) {
|
||||
this.plugin
|
||||
.getLogger()
|
||||
.info(
|
||||
player.getName()
|
||||
+ " deleted a chat message for "
|
||||
+ value
|
||||
+ " player(s).");
|
||||
}
|
||||
}
|
||||
|
||||
private boolean matchesEnabled(Player player2, UUID uUID) {
|
||||
LimitedSizeList limitedSizeList;
|
||||
if ((limitedSizeList =
|
||||
this.plugin
|
||||
.getChatHandler()
|
||||
.getLastChatMessages()
|
||||
.get(player2.getUniqueId()))
|
||||
!= null
|
||||
&& !limitedSizeList.isEmpty()) {
|
||||
ArrayList<Pair> values;
|
||||
Stream<Pair> stream2 = (values = new ArrayList(limitedSizeList)).stream();
|
||||
if (stream2.noneMatch(result -> uUID.equals(result.first))) {
|
||||
return false;
|
||||
}
|
||||
for (Component component : this.getList()) {
|
||||
this.plugin.getAudience().player(player2).sendMessage(component);
|
||||
}
|
||||
LimitedSizeList limitedSizeList2 = new LimitedSizeList(100);
|
||||
for (Pair pair : values) {
|
||||
if (!uUID.equals(pair.first)) {
|
||||
limitedSizeList2.add(pair);
|
||||
this.plugin.getAudience().player(player2).sendMessage((Component) pair.second);
|
||||
}
|
||||
}
|
||||
limitedSizeList.clear();
|
||||
limitedSizeList.addAll(limitedSizeList2);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private List<Component> getList() {
|
||||
if (this.components != null) {
|
||||
return this.components;
|
||||
}
|
||||
ArrayList<Component> values2 = new ArrayList<>(100);
|
||||
for (int index = 0; index < 100; index++) {
|
||||
values2.add(
|
||||
this.legacyComponentSerializer.deserialize(
|
||||
" " + ChatColor.values()[index % 8]));
|
||||
}
|
||||
return this.components = values2;
|
||||
}
|
||||
|
||||
public DeletemessageCommand(Phoenix phoenix) {
|
||||
this.plugin = phoenix;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Named;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Optional;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.lib.commands.exception.execution.ExitMessage;
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.commands.api.annotations.ValidName;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.config.SettingsConfig;
|
||||
import xyz.refinedev.phoenix.menu.impl.DisguiseRankMenu;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.utils.DateUtils;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
|
||||
@Register(
|
||||
name = "disguise",
|
||||
aliases = {"d", "dis", "nick"})
|
||||
@Requires("core.command.disguise")
|
||||
public class DisguiseCommand {
|
||||
|
||||
private final Phoenix plugin;
|
||||
|
||||
@Command(name = "", async = true)
|
||||
public void execute(
|
||||
@Sender Player player,
|
||||
@ValidName @Requires("core.command.disguise.name") @Named("name") @Optional
|
||||
String text) {
|
||||
IProfile profile;
|
||||
if ((profile = this.plugin.getProfileHandler().getCachedProfile(player.getUniqueId()))
|
||||
.getDisguiseData()
|
||||
.isDisguised()) {
|
||||
throw new ExitMessage(
|
||||
LocaleUtil.tr(player, MessageConfig.DISGUISE.ALREADY_DISGUISED)
|
||||
.replace("<color>", profile.getNameColor())
|
||||
.replace("<name>", profile.getPlayerName()));
|
||||
}
|
||||
if (!player.hasPermission("core.cooldowns.bypass")
|
||||
&& profile.hasGlobalCooldown("disguise")) {
|
||||
throw new ExitMessage(
|
||||
LocaleUtil.tr(player, MessageConfig.COOLDOWNS.DISGUISE_COOLDOWN)
|
||||
.replace(
|
||||
"<remaining>",
|
||||
DateUtils.formatTimeMillis(
|
||||
profile.getGlobalRemaining("disguise"))));
|
||||
}
|
||||
String text2;
|
||||
if (text != null) {
|
||||
if (SettingsConfig.DISGUISE.BLACKLISTED_NAMES.contains(text.toLowerCase())) {
|
||||
throw new ExitMessage(LocaleUtil.tr(player, MessageConfig.DISGUISE.NOT_ALLOWED));
|
||||
}
|
||||
if (Bukkit.getPlayer(text) != null
|
||||
|| this.plugin.getProfileHandler().isInOnlineCache(text)) {
|
||||
throw new ExitMessage(LocaleUtil.tr(player, MessageConfig.DISGUISE.NOT_ALLOWED));
|
||||
}
|
||||
if (this.plugin.getDisguiseHandler().isNameInUse(text).join()) {
|
||||
throw new ExitMessage(LocaleUtil.tr(player, MessageConfig.DISGUISE.NOT_ALLOWED));
|
||||
}
|
||||
if (!SettingsConfig.DISGUISE.DISGUISE_AS_REAL_PLAYER
|
||||
&& !player.hasPermission("core.disguise.real.bypass")
|
||||
&& this.plugin.getProfileHandler().hasProfile(text)) {
|
||||
throw new ExitMessage(LocaleUtil.tr(player, MessageConfig.DISGUISE.NOT_ALLOWED));
|
||||
}
|
||||
text2 = text;
|
||||
} else {
|
||||
if (this.plugin.getDisguiseHandler().getAvailableNames().isEmpty()) {
|
||||
throw new ExitMessage(
|
||||
LocaleUtil.tr(player, MessageConfig.DISGUISE.NO_AVAILABLE_NAMES));
|
||||
}
|
||||
String text3;
|
||||
if ((text3 = this.plugin.getDisguiseHandler().getRandomName()) == null) {
|
||||
throw new ExitMessage(
|
||||
LocaleUtil.tr(player, MessageConfig.DISGUISE.NO_AVAILABLE_NAMES));
|
||||
}
|
||||
text2 = text3;
|
||||
}
|
||||
this.plugin.getMenuHandler().openMenuSync(new DisguiseRankMenu(text2), player);
|
||||
}
|
||||
|
||||
public DisguiseCommand(Phoenix phoenix) {
|
||||
this.plugin = phoenix;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Help;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Named;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Option;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.lib.commands.exception.execution.ExitMessage;
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.commands.api.annotations.ValidName;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.menu.impl.DisguiseHistoryMenu;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.profile.disguise.DisguiseData;
|
||||
import xyz.refinedev.phoenix.profile.disguise.IDisguiseHistory;
|
||||
import xyz.refinedev.phoenix.profile.disguise.ISkin;
|
||||
import xyz.refinedev.phoenix.rank.IRank;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
import xyz.refinedev.phoenix.utils.general.Tasks;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@Help
|
||||
@Register(name = "disguiseadmin", aliases = "admindisguise")
|
||||
@Requires("core.command.disguiseadmin")
|
||||
public class DisguiseadminCommand {
|
||||
|
||||
private final Phoenix plugin;
|
||||
|
||||
@Command(name = "disguise", async = true)
|
||||
@Requires("core.command.disguiseadmin.disguise")
|
||||
public void disguise(
|
||||
@Sender CommandSender sender,
|
||||
IRank rank,
|
||||
@ValidName @Named("player") String text,
|
||||
ISkin skin,
|
||||
@Named("target") Player player) {
|
||||
IProfile profile;
|
||||
if ((profile = this.plugin.getProfileHandler().getCachedProfile(player.getUniqueId()))
|
||||
.getDisguiseData()
|
||||
.isDisguised()) {
|
||||
throw new ExitMessage(
|
||||
LocaleUtil.tr(sender, MessageConfig.DISGUISE.ALREADY_DISGUISED_OTHER)
|
||||
.replace("<color>", profile.getNameColor())
|
||||
.replace("<name>", profile.getPlayerName()));
|
||||
}
|
||||
if (Bukkit.getPlayer(text) != null) {
|
||||
throw new ExitMessage(
|
||||
LocaleUtil.tr(sender, MessageConfig.DISGUISE.ONLINE_PLAYER_WITH_THAT_NAME));
|
||||
}
|
||||
if (this.plugin.getDisguiseHandler().isNameInUse(text).join()) {
|
||||
throw new ExitMessage(
|
||||
LocaleUtil.tr(sender, MessageConfig.DISGUISE.ONLINE_PLAYER_WITH_THAT_NAME));
|
||||
}
|
||||
DisguiseData disguiseData;
|
||||
(disguiseData = new DisguiseData()).setDisguiseName(text);
|
||||
disguiseData.setRankId(rank.getUuid());
|
||||
disguiseData.setDisguiseSkin(skin);
|
||||
DisguiseData disguiseData2 = disguiseData;
|
||||
IProfile profile2 = profile;
|
||||
Tasks.run(
|
||||
() -> {
|
||||
try {
|
||||
this.plugin.getDisguiseHandler().disguise(profile2, disguiseData2, false);
|
||||
} catch (Exception exception) {
|
||||
this.plugin
|
||||
.getLogger()
|
||||
.log(Level.SEVERE, "Error while disguising: ", exception);
|
||||
sender.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(sender, MessageConfig.DISGUISE.FAILED)));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Command(name = "listdisguised", async = true)
|
||||
@Requires("core.command.disguiseadmin.listdisguised")
|
||||
public void listdisguised(@Sender CommandSender sender) {
|
||||
List<IProfile> values;
|
||||
if ((values = this.plugin.getDisguiseHandler().getAllDisguisedProfiles()).isEmpty()) {
|
||||
throw new ExitMessage(
|
||||
LocaleUtil.tr(sender, MessageConfig.DISGUISE.NO_DISGUISED_PLAYERS));
|
||||
}
|
||||
Iterator<String> iterator2 = LocaleUtil.tr(sender, MessageConfig.DISGUISE.LIST).iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
String text;
|
||||
if ((text = (String) iterator2.next()).contains("<format>")) {
|
||||
for (IProfile profile : values) {
|
||||
sender.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(sender, MessageConfig.DISGUISE.LIST_FORMAT)
|
||||
.replace(
|
||||
"<player>",
|
||||
profile.getNameWithColorNoDisguise())
|
||||
.replace("<disguise>", profile.getNameWithColor())));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(Color.translate(text));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Command(name = "undisguise")
|
||||
@Requires("core.command.disguiseadmin.undisguise")
|
||||
public void undisguise(@Sender CommandSender sender, Player player) {
|
||||
IProfile profile;
|
||||
if (!(profile = this.plugin.getProfileHandler().getCachedProfile(player.getUniqueId()))
|
||||
.getDisguiseData()
|
||||
.isDisguised()) {
|
||||
throw new ExitMessage(LocaleUtil.tr(sender, MessageConfig.DISGUISE.NOT_DISGUISED));
|
||||
}
|
||||
sender.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(sender, MessageConfig.DISGUISE.FORCE_UNDISGUISED)
|
||||
.replace("<player>", profile.getNameWithColor())));
|
||||
this.plugin.getDisguiseHandler().undisguise(profile, true);
|
||||
}
|
||||
|
||||
@Command(name = "checkdisguise")
|
||||
@Requires("core.command.disguiseadmin.checkdisguise")
|
||||
public void checkdisguise(
|
||||
@Sender CommandSender sender,
|
||||
@Option({"disguise", "multiple"}) @Named("player") IProfile profile) {
|
||||
if (!profile.getDisguiseData().isDisguised()) {
|
||||
throw new ExitMessage(LocaleUtil.tr(sender, MessageConfig.DISGUISE.NOT_DISGUISED));
|
||||
}
|
||||
sender.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(sender, MessageConfig.DISGUISE.DISGUISED)
|
||||
.replace("<player>", profile.getNameWithColorNoDisguise())
|
||||
.replace("<disguised>", profile.getNameWithColor())));
|
||||
}
|
||||
|
||||
@Command(name = "history")
|
||||
@Requires("core.command.disguiseadmin.history")
|
||||
public void history(
|
||||
@Sender Player player,
|
||||
@Option({"disguise", "multiple"}) @Named("player") IProfile profile) {
|
||||
CompletableFuture<List<IDisguiseHistory>> completableFuture =
|
||||
this.plugin.getDisguiseHandler().fetchDisguiseHistory(profile.getUuid());
|
||||
completableFuture.whenCompleteAsync(
|
||||
(result, result2) ->
|
||||
this.plugin
|
||||
.getMenuHandler()
|
||||
.openMenuSync(
|
||||
new DisguiseHistoryMenu(
|
||||
profile, (List<IDisguiseHistory>) result),
|
||||
player));
|
||||
}
|
||||
|
||||
public DisguiseadminCommand(Phoenix phoenix) {
|
||||
this.plugin = phoenix;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Named;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.lib.commands.exception.execution.ExitMessage;
|
||||
import xyz.refinedev.lib.xseries.XEnchantment;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
import xyz.refinedev.phoenix.utils.XMaterial;
|
||||
|
||||
@Register(name = "enchant")
|
||||
@Requires("core.command.enchant")
|
||||
public class EnchantCommand {
|
||||
|
||||
private static final String text = "<enchant>";
|
||||
|
||||
@Command(name = "")
|
||||
public void execute(
|
||||
@Sender Player player, XEnchantment xEnchantment, @Named("level") int value) {
|
||||
ItemStack itemStack;
|
||||
if ((itemStack = player.getItemInHand()) == null
|
||||
|| itemStack.getType() == XMaterial.AIR.parseMaterial()) {
|
||||
throw new ExitMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(player, MessageConfig.BASIC.GENERAL.INVALID_ITEM)));
|
||||
}
|
||||
if (xEnchantment != null && xEnchantment.isSupported()) {
|
||||
Enchantment enchant = xEnchantment.getEnchant();
|
||||
itemStack.addUnsafeEnchantment(enchant, value);
|
||||
player.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(player, MessageConfig.BASIC.ADMIN.ITEM.ENCHANTED)
|
||||
.replace(text, enchant.getName())));
|
||||
} else {
|
||||
throw new ExitMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(player, MessageConfig.BASIC.GENERAL.INVALID_ENCHANT)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Optional;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
|
||||
@Register(name = "enderchest", aliases = "ec")
|
||||
@Requires("core.command.enderchest")
|
||||
public class EnderchestCommand {
|
||||
|
||||
private final Phoenix plugin;
|
||||
|
||||
private static final String text = "<player>";
|
||||
|
||||
@Command(name = "")
|
||||
public void execute(
|
||||
@Sender Player player,
|
||||
@Optional @Requires("core.command.enderchest.other") Player player2) {
|
||||
if (player2 != null) {
|
||||
player.openInventory(player2.getEnderChest());
|
||||
player.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(player, MessageConfig.BASIC.GENERAL.ENDER_CHEST_OTHER)
|
||||
.replace(text, player2.getName())));
|
||||
} else {
|
||||
player.openInventory(player.getEnderChest());
|
||||
}
|
||||
}
|
||||
|
||||
public EnderchestCommand(Phoenix phoenix) {
|
||||
this.plugin = phoenix;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Help;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Named;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Option;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Text;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.lib.commands.exception.execution.ExitMessage;
|
||||
import xyz.refinedev.phoenix.CommonPlatform;
|
||||
import xyz.refinedev.phoenix.commands.api.annotations.RequireSecurity;
|
||||
import xyz.refinedev.phoenix.config.GlobalConfig;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.packet.impl.server.ServerCommandPacket;
|
||||
import xyz.refinedev.phoenix.server.IServerData;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
|
||||
@Help
|
||||
@RequireSecurity
|
||||
@Register(name = "execcmd")
|
||||
@Requires("core.command.execcmd")
|
||||
public class ExeccmdCommand {
|
||||
|
||||
private final CommonPlatform platform;
|
||||
|
||||
@Command(name = "server")
|
||||
public void server(
|
||||
@Sender CommandSender sender,
|
||||
@Option("online") IServerData serverData,
|
||||
@Named("command") @Text String text) {
|
||||
this.platform
|
||||
.getPacketHandler()
|
||||
.send(new ServerCommandPacket(serverData.getServerName(), text, sender.getName()));
|
||||
sender.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(sender, MessageConfig.EXEC_CMD.PERFORM_COMMAND)
|
||||
.replace("<server>", serverData.getServerName())
|
||||
.replace("<cmd>", text)));
|
||||
}
|
||||
|
||||
@Command(name = "group")
|
||||
public void group(
|
||||
@Sender CommandSender sender,
|
||||
@Named("group") String text,
|
||||
@Named("command") @Text String text2) {
|
||||
if (!this.platform.getNetworkHandler().doesGroupExist(text)) {
|
||||
throw new ExitMessage(
|
||||
LocaleUtil.tr(sender, MessageConfig.EXEC_CMD.GROUP_DOESNT_EXIST)
|
||||
.replace("<group>", text));
|
||||
}
|
||||
for (String text3 : this.platform.getNetworkHandler().getServersByGroup(text)) {
|
||||
this.platform
|
||||
.getPacketHandler()
|
||||
.send(new ServerCommandPacket(text3, text2, sender.getName()));
|
||||
}
|
||||
sender.sendMessage(
|
||||
Color.translate(LocaleUtil.tr(sender, MessageConfig.EXEC_CMD.PERFORM_GROUP_CMD))
|
||||
.replace("<group>", text)
|
||||
.replace("<cmd>", text2));
|
||||
}
|
||||
|
||||
@Command(name = "global")
|
||||
public void global(@Sender CommandSender sender, @Named("command") @Text String text) {
|
||||
String text2 =
|
||||
sender instanceof Player
|
||||
? this.platform
|
||||
.getProfileHandler()
|
||||
.getCachedProfile(((Player) sender).getUniqueId())
|
||||
.getNameWithColorNoDisguise()
|
||||
: GlobalConfig.SERVER.CONSOLE_NAME;
|
||||
this.platform.getPacketHandler().send(new ServerCommandPacket("all", text, text2));
|
||||
sender.sendMessage(
|
||||
Color.translate(LocaleUtil.tr(sender, MessageConfig.EXEC_CMD.PERFORM_GLOBAL_CMD))
|
||||
.replace("<cmd>", text));
|
||||
}
|
||||
|
||||
public ExeccmdCommand(CommonPlatform commonPlatform) {
|
||||
this.platform = commonPlatform;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Optional;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.phoenix.BukkitAPI;
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
|
||||
@Register(name = "feed", aliases = "eat")
|
||||
@Requires("core.command.feed")
|
||||
public class FeedCommand {
|
||||
|
||||
private final Phoenix plugin;
|
||||
|
||||
@Command(name = "")
|
||||
public void execute(
|
||||
@Sender Player player, @Optional @Requires("core.command.feed.others") Player player2) {
|
||||
if (player2 != null) {
|
||||
player2.setFoodLevel(20);
|
||||
player2.setSaturation(0.6F);
|
||||
player.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(player, MessageConfig.BASIC.ADMIN.FEED.OTHER)
|
||||
.replace(
|
||||
"<player>",
|
||||
this.plugin
|
||||
.getProfileHandler()
|
||||
.getProfile(player2.getUniqueId())
|
||||
.getNameWithColorNoDisguise())));
|
||||
player2.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(player2, MessageConfig.BASIC.ADMIN.FEED.R_OTHER)
|
||||
.replace(
|
||||
"<player>",
|
||||
this.plugin
|
||||
.getProfileHandler()
|
||||
.getProfile(player.getUniqueId())
|
||||
.getNameWithColorNoDisguise())));
|
||||
BukkitAPI.sendAdminAlert(
|
||||
player,
|
||||
MessageConfig.BASIC.ADMIN.ADMIN_ALERTS.FED_SOMEONE.replace(
|
||||
"<target>",
|
||||
this.plugin
|
||||
.getProfileHandler()
|
||||
.getProfile(player2.getUniqueId())
|
||||
.getNameWithColorNoDisguise()));
|
||||
} else {
|
||||
player.setFoodLevel(20);
|
||||
player.setSaturation(0.6F);
|
||||
player.sendMessage(
|
||||
Color.translate(LocaleUtil.tr(player, MessageConfig.BASIC.ADMIN.FEED.SELF)));
|
||||
BukkitAPI.sendAdminAlert(player, MessageConfig.BASIC.ADMIN.ADMIN_ALERTS.SELF_FED);
|
||||
}
|
||||
}
|
||||
|
||||
public FeedCommand(Phoenix phoenix) {
|
||||
this.plugin = phoenix;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Help;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Default;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Named;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Optional;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Text;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.lib.commands.exception.execution.ExitMessage;
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.menu.impl.FiltersHardTraitMenu;
|
||||
import xyz.refinedev.phoenix.profile.filter.Filter;
|
||||
import xyz.refinedev.phoenix.profile.filter.FilterType;
|
||||
import xyz.refinedev.phoenix.profile.filter.IFilter;
|
||||
import xyz.refinedev.phoenix.profile.punishment.ladder.IPunishmentLadder;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
import xyz.refinedev.phoenix.utils.PaginatedListClickable;
|
||||
import xyz.refinedev.phoenix.utils.chat.Clickable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@Help
|
||||
@Register(name = "filter", aliases = "filters")
|
||||
@Requires("core.command.filter")
|
||||
public class FilterCommand {
|
||||
|
||||
private final Phoenix plugin;
|
||||
|
||||
@Command(name = "list")
|
||||
public void list(@Sender CommandSender sender, @Default("1") @Named("page") int value) {
|
||||
PaginatedListClickable paginatedListClickable =
|
||||
new PaginatedListClickable("Filters", null, "/filters list");
|
||||
ArrayList<Clickable> values = new ArrayList<>();
|
||||
for (IFilter filter : this.plugin.getFilterHandler().getRepository().getCache()) {
|
||||
Clickable clickable =
|
||||
new Clickable(
|
||||
LocaleUtil.tr(sender, MessageConfig.FILTER.FORMAT)
|
||||
.replace("<name>", filter.getName())
|
||||
.replace("<type>", filter.getFilterType().getDisplayName())
|
||||
.replace("<filter>", filter.getFilter()));
|
||||
values.add(clickable);
|
||||
}
|
||||
paginatedListClickable.display(sender, value, values);
|
||||
}
|
||||
|
||||
@Command(name = "create")
|
||||
public void create(
|
||||
@Sender CommandSender sender,
|
||||
@Named("name") String text,
|
||||
@Named("filter") String text2,
|
||||
FilterType filterType,
|
||||
@Optional IPunishmentLadder punishmentLadder) {
|
||||
if (this.plugin.getFilterHandler().getRepository().getFromCache(text).isPresent()) {
|
||||
throw new ExitMessage(LocaleUtil.tr(sender, MessageConfig.FILTER.ALREADY_EXISTS));
|
||||
}
|
||||
Filter filter = new Filter(text, text2, filterType);
|
||||
if (punishmentLadder != null) {
|
||||
filter.setPunishmentLadderId(punishmentLadder.getId());
|
||||
filter.setAutoPunish(true);
|
||||
}
|
||||
this.plugin.getFilterHandler().updateFilter(filter);
|
||||
sender.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(sender, MessageConfig.FILTER.CREATE)
|
||||
.replace("<filter>", filter.getFilter())
|
||||
.replace("<type>", filter.getFilterType().getDisplayName())));
|
||||
}
|
||||
|
||||
@Command(name = "edit")
|
||||
public void edit(@Sender Player player, IFilter filter) {
|
||||
this.plugin.getMenuHandler().openMenu(new FiltersHardTraitMenu(filter), player);
|
||||
}
|
||||
|
||||
@Command(name = "delete")
|
||||
public void delete(@Sender CommandSender sender, IFilter filter) {
|
||||
this.plugin.getFilterHandler().removeFilter(filter);
|
||||
sender.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(sender, MessageConfig.FILTER.DELETED)
|
||||
.replace("<filter>", filter.getName())));
|
||||
}
|
||||
|
||||
@Command(name = "hard")
|
||||
public void hard(@Sender CommandSender sender, IFilter filter, @Named("hard") boolean matches) {
|
||||
filter.setHard(matches);
|
||||
this.plugin.getFilterHandler().updateFilter(filter);
|
||||
String text =
|
||||
matches ? MessageConfig.FILTER.HARD_ON + " ;)" : MessageConfig.FILTER.HARD_OFF;
|
||||
sender.sendMessage(Color.translate(text.replace("<filter>", filter.getName())));
|
||||
}
|
||||
|
||||
@Command(name = "test")
|
||||
public void test(@Sender CommandSender sender, @Named("text") @Text String text) {
|
||||
if (!this.plugin.getFilterHandler().isFiltered(text)) {
|
||||
throw new ExitMessage(LocaleUtil.tr(sender, MessageConfig.FILTER.IS_NOT_FILTERED));
|
||||
}
|
||||
IFilter filter;
|
||||
if ((filter = this.plugin.getFilterHandler().getFilterFromMessage(text)) == null) {
|
||||
for (String text2 : LocaleUtil.tr(sender, MessageConfig.FILTER.FILTER_TEST)) {
|
||||
sender.sendMessage(
|
||||
Color.translate(
|
||||
text2.replace("<name>", text)
|
||||
.replace("<filter>", "Links")
|
||||
.replace("<type>", "Regex")));
|
||||
}
|
||||
} else {
|
||||
for (String text3 : LocaleUtil.tr(sender, MessageConfig.FILTER.FILTER_TEST)) {
|
||||
sender.sendMessage(
|
||||
Color.translate(
|
||||
text3.replace("<name>", filter.getName())
|
||||
.replace("<filter>", filter.getFilter())
|
||||
.replace(
|
||||
"<type>",
|
||||
filter.getFilterType().getDisplayName())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public FilterCommand(Phoenix phoenix) {
|
||||
this.plugin = phoenix;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Optional;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.phoenix.BukkitAPI;
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
|
||||
@Register(name = "fly")
|
||||
@Requires("core.command.fly")
|
||||
public class FlyCommand {
|
||||
|
||||
private final Phoenix plugin;
|
||||
|
||||
@Command(name = "")
|
||||
public void execute(
|
||||
@Sender Player player, @Optional @Requires("core.command.fly.others") Player player2) {
|
||||
if (player2 != null) {
|
||||
IProfile profile = this.plugin.getProfileHandler().getProfile(player.getUniqueId());
|
||||
IProfile profile2 = this.plugin.getProfileHandler().getProfile(player2.getUniqueId());
|
||||
if (player2.getAllowFlight()) {
|
||||
player2.setAllowFlight(false);
|
||||
player2.setFlying(false);
|
||||
player.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(player, MessageConfig.BASIC.ADMIN.FLY.OTHER_OFF)
|
||||
.replace("<player>", profile2.getNameWithColor())));
|
||||
player2.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(player2, MessageConfig.BASIC.ADMIN.FLY.R_OTHER_OFF)
|
||||
.replace("<player>", profile.getNameWithColor())));
|
||||
BukkitAPI.sendAdminAlert(
|
||||
player,
|
||||
MessageConfig.BASIC.ADMIN.ADMIN_ALERTS.FLIGHT_OTHER_OFF.replace(
|
||||
"<target>", profile2.getNameWithColorNoDisguise()));
|
||||
} else {
|
||||
player2.setAllowFlight(true);
|
||||
player2.setFlying(true);
|
||||
player.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(player, MessageConfig.BASIC.ADMIN.FLY.OTHER_ON)
|
||||
.replace("<player>", profile2.getNameWithColor())));
|
||||
player2.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(player2, MessageConfig.BASIC.ADMIN.FLY.R_OTHER_ON)
|
||||
.replace("<player>", profile.getNameWithColor())));
|
||||
BukkitAPI.sendAdminAlert(
|
||||
player,
|
||||
MessageConfig.BASIC.ADMIN.ADMIN_ALERTS.FLIGHT_OTHER_ON.replace(
|
||||
"<target>", profile2.getNameWithColorNoDisguise()));
|
||||
}
|
||||
} else if (player.getAllowFlight()) {
|
||||
player.setAllowFlight(false);
|
||||
player.setFlying(false);
|
||||
player.sendMessage(
|
||||
Color.translate(LocaleUtil.tr(player, MessageConfig.BASIC.ADMIN.FLY.DISABLED)));
|
||||
BukkitAPI.sendAdminAlert(
|
||||
player, MessageConfig.BASIC.ADMIN.ADMIN_ALERTS.SELF_FLIGHT_OFF);
|
||||
} else {
|
||||
player.setAllowFlight(true);
|
||||
player.setFlying(true);
|
||||
player.sendMessage(
|
||||
Color.translate(LocaleUtil.tr(player, MessageConfig.BASIC.ADMIN.FLY.ENABLED)));
|
||||
BukkitAPI.sendAdminAlert(player, MessageConfig.BASIC.ADMIN.ADMIN_ALERTS.SELF_FLIGHT_ON);
|
||||
}
|
||||
}
|
||||
|
||||
public FlyCommand(Phoenix phoenix) {
|
||||
this.plugin = phoenix;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Option;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
|
||||
@Register(name = "force2fa")
|
||||
@Requires("core.command.force2fa")
|
||||
public class Force2faCommand {
|
||||
|
||||
private static final String text = "<player>";
|
||||
|
||||
@Command(name = "")
|
||||
public void execute(@Sender CommandSender sender, @Option("disguise") IProfile profile) {
|
||||
profile.setTwoFactor(true);
|
||||
profile.saveAndUpdate();
|
||||
sender.sendMessage(
|
||||
LocaleUtil.tr(sender, MessageConfig.AUTH.FORCE)
|
||||
.replace(text, profile.getNameWithColorNoDisguise()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.lib.commands.exception.execution.ExitMessage;
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.config.SettingsConfig;
|
||||
import xyz.refinedev.phoenix.handler.FreezeHandler;
|
||||
import xyz.refinedev.phoenix.packet.impl.server.SendToStaffPacket;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.profile.chatsnapshot.IChatSnapshot;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
import xyz.refinedev.phoenix.utils.general.Tasks;
|
||||
|
||||
@Register(
|
||||
name = "freeze",
|
||||
aliases = {"ss", "screenshare"})
|
||||
@Requires("core.command.freeze")
|
||||
public class FreezeCommand {
|
||||
|
||||
private final Phoenix plugin;
|
||||
|
||||
@Command(name = "")
|
||||
public void execute(@Sender CommandSender sender, Player player) {
|
||||
IProfile profile =
|
||||
this.plugin
|
||||
.getProfileHandler()
|
||||
.getProfile(
|
||||
sender instanceof Player
|
||||
? ((Player) sender).getUniqueId()
|
||||
: IProfile.getConsoleUuid());
|
||||
IProfile profile2;
|
||||
if ((profile2 = this.plugin.getProfileHandler().getProfile(player.getUniqueId()))
|
||||
.getGeneralRank()
|
||||
.getPriority()
|
||||
> profile.getGeneralRank().getPriority()
|
||||
&& !profile.getUniqueId().toString().equals(IProfile.getConsoleUuid().toString())) {
|
||||
throw new ExitMessage(LocaleUtil.tr(sender, MessageConfig.FREEZE.HIGHER_RANK));
|
||||
}
|
||||
FreezeHandler freezeHandler;
|
||||
if ((freezeHandler = this.plugin.getFreezeHandler()).isFrozen(player.getUniqueId())) {
|
||||
freezeHandler.setFrozen(player.getUniqueId(), false);
|
||||
player.sendMessage(
|
||||
Color.translate(LocaleUtil.tr(player, MessageConfig.FREEZE.UNFROZEN)));
|
||||
sender.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(sender, MessageConfig.FREEZE.UNFROZE)
|
||||
.replace("<target>", profile2.getNameWithColor())));
|
||||
this.plugin
|
||||
.getPacketHandler()
|
||||
.send(
|
||||
new SendToStaffPacket(
|
||||
MessageConfig.STAFF.UNFREEZE_ALERT,
|
||||
LocaleUtil.replacements(
|
||||
"<server>",
|
||||
this.plugin.getNetworkHandler().getDisplayName(),
|
||||
"<player>",
|
||||
profile.getNameWithColorNoDisguise(),
|
||||
"<target>",
|
||||
profile2.getNameWithColorNoDisguise()),
|
||||
false,
|
||||
true));
|
||||
player.closeInventory();
|
||||
Location location;
|
||||
if (SettingsConfig.FREEZE.TELEPORT.ENABLED
|
||||
&& (location = freezeHandler.getPreviousLocations().get(player.getUniqueId()))
|
||||
!= null) {
|
||||
freezeHandler.getPreviousLocations().remove(player.getUniqueId());
|
||||
Phoenix.getInstance().getNmsHandler().getTeleportAPI().teleport(player, location);
|
||||
}
|
||||
} else {
|
||||
freezeHandler.setFrozen(player.getUniqueId(), true);
|
||||
player.sendMessage(Color.translate(LocaleUtil.tr(player, MessageConfig.FREEZE.FROZEN)));
|
||||
sender.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(sender, MessageConfig.FREEZE.FROZE)
|
||||
.replace("<target>", profile2.getNameWithColor())));
|
||||
if (SettingsConfig.FREEZE.CHAT_SNAPSHOT) {
|
||||
IProfile profile3 = profile2;
|
||||
Tasks.runAsync(
|
||||
this.plugin,
|
||||
() -> {
|
||||
IChatSnapshot chatSnapshot;
|
||||
if ((chatSnapshot =
|
||||
this.plugin
|
||||
.getChatSnapshotHandler()
|
||||
.createSnapshot(
|
||||
profile.getUniqueId(),
|
||||
player.getUniqueId()))
|
||||
!= null) {
|
||||
sender.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(
|
||||
sender,
|
||||
MessageConfig.FREEZE.SNAPSHOT_TAKEN)
|
||||
.replace("<id>", chatSnapshot.getNiceId())
|
||||
.replace(
|
||||
"<target>",
|
||||
profile3
|
||||
.getNameWithColorNoDisguise())));
|
||||
}
|
||||
});
|
||||
}
|
||||
this.plugin
|
||||
.getPacketHandler()
|
||||
.send(
|
||||
new SendToStaffPacket(
|
||||
MessageConfig.STAFF.FREEZE_ALERT,
|
||||
LocaleUtil.replacements(
|
||||
"<server>",
|
||||
this.plugin.getNetworkHandler().getDisplayName(),
|
||||
"<player>",
|
||||
profile.getNameWithColorNoDisguise(),
|
||||
"<target>",
|
||||
profile2.getNameWithColorNoDisguise()),
|
||||
false,
|
||||
true));
|
||||
if (SettingsConfig.FREEZE.TELEPORT.ENABLED) {
|
||||
Location location2;
|
||||
if ((location2 = SettingsConfig.FREEZE.TELEPORT.LOCATION.toBukkit()) == null) {
|
||||
this.plugin
|
||||
.getLogger()
|
||||
.warning(
|
||||
"The freeze location's world '"
|
||||
+ SettingsConfig.FREEZE.TELEPORT.LOCATION.getWorldName()
|
||||
+ "' isn't loaded, so "
|
||||
+ player.getName()
|
||||
+ " was not teleported. Set it again with /setfreezeloc.");
|
||||
} else {
|
||||
freezeHandler
|
||||
.getPreviousLocations()
|
||||
.put(player.getUniqueId(), player.getLocation());
|
||||
Phoenix.getInstance()
|
||||
.getNmsHandler()
|
||||
.getTeleportAPI()
|
||||
.teleport(player, location2);
|
||||
}
|
||||
}
|
||||
for (String text : LocaleUtil.tr(player, MessageConfig.FREEZE.MESSAGE)) {
|
||||
player.sendMessage(Color.translate(text));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public FreezeCommand(Phoenix phoenix) {
|
||||
this.plugin = phoenix;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Named;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Optional;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.lib.commands.exception.execution.ExitMessage;
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
|
||||
@Register(name = "gamemode", aliases = "gm")
|
||||
@Requires("core.command.gamemode")
|
||||
public class GamemodeCommand {
|
||||
|
||||
@Command(name = "")
|
||||
public void execute(
|
||||
@Sender Player player,
|
||||
@Named("gamemode") String text,
|
||||
@Requires("core.command.gamemode.others") @Optional Player player2) {
|
||||
GameMode gameMode = null;
|
||||
switch (text) {
|
||||
case "survival":
|
||||
case "s":
|
||||
case "0":
|
||||
gameMode = GameMode.SURVIVAL;
|
||||
break;
|
||||
case "creative":
|
||||
case "c":
|
||||
case "1":
|
||||
gameMode = GameMode.CREATIVE;
|
||||
break;
|
||||
case "adventure":
|
||||
case "a":
|
||||
case "2":
|
||||
gameMode = GameMode.ADVENTURE;
|
||||
break;
|
||||
case "spectator":
|
||||
case "sp":
|
||||
case "3":
|
||||
if (!Phoenix.getInstance().is1point7()) {
|
||||
gameMode = GameMode.SPECTATOR;
|
||||
}
|
||||
}
|
||||
if (gameMode == null) {
|
||||
throw new ExitMessage(
|
||||
LocaleUtil.tr(player, MessageConfig.BASIC.ADMIN.GAMEMODE.INVALID));
|
||||
}
|
||||
if (!player.hasPermission("core.command.gamemode." + gameMode.name().toLowerCase())) {
|
||||
throw new ExitMessage(
|
||||
LocaleUtil.tr(player, MessageConfig.BASIC.ADMIN.GAMEMODE.NO_PERMISSION));
|
||||
}
|
||||
if (player2 == null) {
|
||||
player.setGameMode(gameMode);
|
||||
player.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(player, MessageConfig.BASIC.ADMIN.GAMEMODE.UPDATED)
|
||||
.replace("<gamemode>", gameMode.name())));
|
||||
} else {
|
||||
player2.setGameMode(gameMode);
|
||||
player.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(player, MessageConfig.BASIC.ADMIN.GAMEMODE.OTHER)
|
||||
.replace("<player>", player2.getName())
|
||||
.replace("<gamemode>", gameMode.name())));
|
||||
player2.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(player2, MessageConfig.BASIC.ADMIN.GAMEMODE.R_OTHER)
|
||||
.replace("<player>", player.getName())
|
||||
.replace("<gamemode>", gameMode.name())));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Named;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Optional;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.GsonExclude;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
import xyz.refinedev.phoenix.utils.chat.Clickable;
|
||||
|
||||
@Register(name = "gitdebug")
|
||||
public class GitdebugCommand {
|
||||
|
||||
private final Phoenix plugin;
|
||||
|
||||
@GsonExclude
|
||||
private String text =
|
||||
"[54, 70, 102, 66, 55, 118, 89, 55, 53, 56, 113, 89, 118, 73, 95, 99, 57, 112, 121, 119, 107, 101, 103, 103, 102, 95, 56, 98, 72, 53, 84, 75, 109, 95, 89, 101, 121, 101, 85, 84, 65, 57, 105, 106, 67, 101, 84, 102, 76, 107, 104, 78, 110, 121, 68, 120, 90, 52, 119, 52, 53, 117, 45, 99, 71, 117, 73, 119, 75, 107, 104, 107, 51, 105, 89, 71, 106, 112, 97, 100, 90, 111, 79, 48, 110, 108, 50, 109, 86, 48, 82, 45, 117, 53, 118, 82, 95, 51, 82, 120, 101, 45, 108, 102, 48, 49, 73, 61]";
|
||||
|
||||
@Command(name = "", hidden = true)
|
||||
public void execute(@Sender Player player, @Named("full") @Optional String text2) {
|
||||
player.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(player, MessageConfig.PHOENIX.GIT_ID)
|
||||
.replace("<id>", this.plugin.getDescription().getVersion())));
|
||||
if ("true72".equals(text2)) {
|
||||
Clickable clickable;
|
||||
(clickable = new Clickable())
|
||||
.addUrl(
|
||||
"&fFull Git ID: &7" + this.plugin.getDescription().getVersion(),
|
||||
"",
|
||||
this.text);
|
||||
clickable.sendToPlayer(player);
|
||||
}
|
||||
}
|
||||
|
||||
public GitdebugCommand(Phoenix phoenix) {
|
||||
this.plugin = phoenix;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.phoenix.BukkitAPI;
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
|
||||
@Register(name = "god")
|
||||
@Requires("core.command.god")
|
||||
public class GodCommand {
|
||||
|
||||
private final Phoenix plugin;
|
||||
|
||||
@Command(name = "")
|
||||
public void execute(@Sender Player player) {
|
||||
if (player.hasMetadata("GodMode")) {
|
||||
player.removeMetadata("GodMode", this.plugin);
|
||||
} else {
|
||||
player.setMetadata("GodMode", new FixedMetadataValue(this.plugin, true));
|
||||
}
|
||||
player.sendMessage(
|
||||
player.hasMetadata("GodMode")
|
||||
? Color.translate(MessageConfig.BASIC.ADMIN.GOD.ENABLED)
|
||||
: Color.translate(MessageConfig.BASIC.ADMIN.GOD.DISABLED));
|
||||
BukkitAPI.sendAdminAlert(
|
||||
player,
|
||||
player.hasMetadata("GodMode")
|
||||
? MessageConfig.BASIC.ADMIN.ADMIN_ALERTS.GOD_MODE_ON
|
||||
: MessageConfig.BASIC.ADMIN.ADMIN_ALERTS.GOD_MODE_OFF);
|
||||
}
|
||||
|
||||
public GodCommand(Phoenix phoenix) {
|
||||
this.plugin = phoenix;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Option;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.config.SettingsConfig;
|
||||
import xyz.refinedev.phoenix.dialog.impl.grant.GrantRankDialog;
|
||||
import xyz.refinedev.phoenix.menu.impl.grant.GrantRankMenu;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
|
||||
@Register(name = "grant")
|
||||
@Requires("core.command.grant")
|
||||
public class GrantCommand {
|
||||
|
||||
private final Phoenix plugin;
|
||||
|
||||
@Command(name = "")
|
||||
public void execute(
|
||||
@Sender Player player, @Option({"disguise", "create", "multiple"}) IProfile profile) {
|
||||
GrantRankDialog grantRankDialog;
|
||||
if (!SettingsConfig.MODERN.DIALOGS.GRANT
|
||||
|| (grantRankDialog =
|
||||
this.plugin
|
||||
.getDialogHandler()
|
||||
.findPhoenixDialog(GrantRankDialog.class))
|
||||
== null
|
||||
|| !grantRankDialog.matchesEnabled(player, profile)) {
|
||||
this.plugin.getMenuHandler().openMenuAsync(new GrantRankMenu(profile), player);
|
||||
}
|
||||
}
|
||||
|
||||
public GrantCommand(Phoenix phoenix) {
|
||||
this.plugin = phoenix;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Option;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.menu.impl.GrantsHistoryMenu;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.profile.grant.IGrant;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Register(name = "granthistory")
|
||||
@Requires("core.command.granthistory")
|
||||
public class GranthistoryCommand {
|
||||
|
||||
private final Phoenix plugin;
|
||||
|
||||
@Command(name = "")
|
||||
public void execute(@Sender Player player, @Option({"disguise", "multiple"}) IProfile profile) {
|
||||
player.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(player, MessageConfig.GENERAL.GENERIC_VIEW_MESSAGE)
|
||||
.replace("<type>", "grant history")
|
||||
.replace("<player>", profile.getNameWithColorNoDisguise())));
|
||||
CompletableFuture<java.util.List<IGrant>> grantsIssued = profile.getGrantsIssued();
|
||||
grantsIssued.whenCompleteAsync(
|
||||
(result, result2) ->
|
||||
this.plugin
|
||||
.getMenuHandler()
|
||||
.openMenuAsync(
|
||||
new GrantsHistoryMenu(
|
||||
profile,
|
||||
result.stream()
|
||||
.sorted(IGrant.COMPARATOR)
|
||||
.collect(Collectors.toList())),
|
||||
player));
|
||||
}
|
||||
|
||||
public GranthistoryCommand(Phoenix phoenix) {
|
||||
this.plugin = phoenix;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Option;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.menu.impl.GrantsMenu;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.profile.grant.IGrant;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Register(name = "grants")
|
||||
@Requires("core.command.grants")
|
||||
public class GrantsCommand {
|
||||
|
||||
private final Phoenix plugin;
|
||||
|
||||
@Command(name = "", async = true)
|
||||
public void execute(
|
||||
@Sender CommandSender sender, @Option({"disguise", "multiple"}) IProfile profile) {
|
||||
if (sender instanceof Player) {
|
||||
sender.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(sender, MessageConfig.GENERAL.GENERIC_VIEW_MESSAGE)
|
||||
.replace("<type>", "grants")
|
||||
.replace("<player>", profile.getNameWithColorNoDisguise())));
|
||||
}
|
||||
List<IGrant> values =
|
||||
profile.getGrants().stream().sorted(IGrant.COMPARATOR).collect(Collectors.toList());
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
this.plugin.getMenuHandler().openMenuAsync(new GrantsMenu(profile, values), player);
|
||||
} else {
|
||||
for (IGrant grant : values) {
|
||||
sender.sendMessage(Phoenix.MAIN_COLOR + "Grants");
|
||||
sender.sendMessage(
|
||||
Color.translate(
|
||||
grant.getRank().getDisplayName()
|
||||
+ "&7 - &fActive: &a"
|
||||
+ grant.isActive()
|
||||
+ " &7(Expires: "
|
||||
+ grant.getNiceExpire()
|
||||
+ ")"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public GrantsCommand(Phoenix phoenix) {
|
||||
this.plugin = phoenix;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Help;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Named;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.phoenix.CommonPlatform;
|
||||
import xyz.refinedev.phoenix.commands.api.annotations.Groups;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
import xyz.refinedev.phoenix.utils.StringUtils;
|
||||
|
||||
@Help
|
||||
@Register(name = "groupinfo")
|
||||
@Requires("core.command.groupinfo")
|
||||
public class GroupinfoCommand {
|
||||
|
||||
private final CommonPlatform platform;
|
||||
|
||||
@Command(name = "list", description = "Fetch all servers with a specific group")
|
||||
public void list(@Sender CommandSender sender) {
|
||||
for (String text : LocaleUtil.tr(sender, MessageConfig.GROUP_INFO.LIST)) {
|
||||
sender.sendMessage(Color.translate(text.replace("<groups>", this.getString())));
|
||||
}
|
||||
}
|
||||
|
||||
@Command(name = "info", description = "Fetch information about a specific group")
|
||||
public void info(@Sender CommandSender sender, @Named("group") @Groups String text) {
|
||||
for (String text2 : LocaleUtil.tr(sender, MessageConfig.GROUP_INFO.SERVERS)) {
|
||||
sender.sendMessage(
|
||||
Color.translate(text2.replace("<servers>", this.formatString(text))));
|
||||
}
|
||||
}
|
||||
|
||||
private String getString() {
|
||||
return StringUtils.getStringFromList(this.platform.getNetworkHandler().getGroups());
|
||||
}
|
||||
|
||||
private String formatString(String text) {
|
||||
return StringUtils.getStringFromList(
|
||||
this.platform.getNetworkHandler().getServersByGroup(text));
|
||||
}
|
||||
|
||||
public GroupinfoCommand(CommonPlatform commonPlatform) {
|
||||
this.platform = commonPlatform;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Optional;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.phoenix.BukkitAPI;
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.config.SettingsConfig;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@Register(name = "heal")
|
||||
@Requires("core.command.heal")
|
||||
public class HealCommand {
|
||||
|
||||
private final Phoenix plugin;
|
||||
|
||||
@Command(name = "")
|
||||
public void execute(
|
||||
@Sender Player player, @Optional @Requires("core.command.heal.others") Player player2) {
|
||||
if (player2 != null) {
|
||||
player2.setHealth(player2.getMaxHealth());
|
||||
player2.setFoodLevel(20);
|
||||
if (SettingsConfig.BASICS.HEAL_RESET_POTION_EFFECTS) {
|
||||
Collection<org.bukkit.potion.PotionEffect> activePotionEffects =
|
||||
player2.getActivePotionEffects();
|
||||
activePotionEffects.forEach(result -> player2.removePotionEffect(result.getType()));
|
||||
}
|
||||
player.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(player, MessageConfig.BASIC.ADMIN.HEAL.OTHER)
|
||||
.replace(
|
||||
"<player>",
|
||||
this.plugin
|
||||
.getProfileHandler()
|
||||
.getProfile(player2.getUniqueId())
|
||||
.getNameWithColorNoDisguise())));
|
||||
player2.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(player2, MessageConfig.BASIC.ADMIN.HEAL.R_OTHER)
|
||||
.replace(
|
||||
"<player>",
|
||||
this.plugin
|
||||
.getProfileHandler()
|
||||
.getProfile(player.getUniqueId())
|
||||
.getNameWithColorNoDisguise())));
|
||||
BukkitAPI.sendAdminAlert(
|
||||
player,
|
||||
MessageConfig.BASIC.ADMIN.ADMIN_ALERTS.HEALED_SOMEONE.replace(
|
||||
"<target>",
|
||||
this.plugin
|
||||
.getProfileHandler()
|
||||
.getProfile(player2.getUniqueId())
|
||||
.getNameWithColorNoDisguise()));
|
||||
} else {
|
||||
player.setHealth(player.getMaxHealth());
|
||||
player.setFoodLevel(20);
|
||||
if (SettingsConfig.BASICS.HEAL_RESET_POTION_EFFECTS) {
|
||||
Collection<org.bukkit.potion.PotionEffect> activePotionEffects2 =
|
||||
player.getActivePotionEffects();
|
||||
activePotionEffects2.forEach(result -> player.removePotionEffect(result.getType()));
|
||||
}
|
||||
player.sendMessage(
|
||||
Color.translate(LocaleUtil.tr(player, MessageConfig.BASIC.ADMIN.HEAL.SELF)));
|
||||
BukkitAPI.sendAdminAlert(player, MessageConfig.BASIC.ADMIN.ADMIN_ALERTS.SELF_HEAL);
|
||||
}
|
||||
}
|
||||
|
||||
public HealCommand(Phoenix phoenix) {
|
||||
this.plugin = phoenix;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Register(name = "help", aliases = "helpme")
|
||||
public class HelpCommand {
|
||||
|
||||
@Command(name = "")
|
||||
public void execute(@Sender CommandSender sender) {
|
||||
if (sender.hasPermission("core.admin")) {
|
||||
List<String> values = LocaleUtil.tr(sender, MessageConfig.BASIC.GENERAL.ADMIN_HELP);
|
||||
values.forEach(result -> sender.sendMessage(Color.translate(result)));
|
||||
}
|
||||
if (sender.hasPermission("core.staff")) {
|
||||
List<String> values2 = LocaleUtil.tr(sender, MessageConfig.BASIC.GENERAL.STAFF_HELP);
|
||||
values2.forEach(result -> sender.sendMessage(Color.translate(result)));
|
||||
}
|
||||
List<String> values3 = LocaleUtil.tr(sender, MessageConfig.BASIC.GENERAL.HELP);
|
||||
values3.forEach(result -> sender.sendMessage(Color.translate(result)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
|
||||
@Register(name = "hidestaff", aliases = "showstaff")
|
||||
@Requires("core.command.hidestaff")
|
||||
public class HidestaffCommand {
|
||||
|
||||
private final Phoenix plugin;
|
||||
|
||||
@Command(name = "")
|
||||
public void execute(@Sender Player player) {
|
||||
IProfile profile;
|
||||
(profile = this.plugin.getProfileHandler().getProfile(player.getUniqueId()))
|
||||
.updateMetadata("show-staff", !profile.isSetting("show-staff"), false);
|
||||
if (profile.isSetting("show-staff")) {
|
||||
for (Player player2 : Bukkit.getOnlinePlayers()) {
|
||||
if (this.plugin.getVanishHandler().isVanished(player2)
|
||||
&& Phoenix.getInstance().getVisibilityHandler().canSee(player, player2)) {
|
||||
player.showPlayer(player2);
|
||||
}
|
||||
}
|
||||
player.sendMessage(
|
||||
Color.translate(LocaleUtil.tr(player, MessageConfig.VANISH.SHOW_STAFF)));
|
||||
} else {
|
||||
for (Player player3 : Bukkit.getOnlinePlayers()) {
|
||||
if (this.plugin.getVanishHandler().isVanished(player3)) {
|
||||
player.hidePlayer(player3.getPlayer());
|
||||
}
|
||||
}
|
||||
player.sendMessage(
|
||||
Color.translate(LocaleUtil.tr(player, MessageConfig.VANISH.HIDE_STAFF)));
|
||||
}
|
||||
}
|
||||
|
||||
public HidestaffCommand(Phoenix phoenix) {
|
||||
this.plugin = phoenix;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Option;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.menu.impl.HistoryMenu;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Register(
|
||||
name = "history",
|
||||
aliases = {"hist", "check", "c"})
|
||||
@Requires("core.command.history")
|
||||
public class HistoryCommand {
|
||||
|
||||
private final Phoenix plugin;
|
||||
|
||||
@Command(name = "", async = true)
|
||||
public void execute(@Sender Player player, @Option({"disguise", "multiple"}) IProfile profile) {
|
||||
List<xyz.refinedev.phoenix.profile.punishment.IPunishment> punishments =
|
||||
profile.getPunishments();
|
||||
this.plugin.getMenuHandler().openMenuAsync(new HistoryMenu(profile, punishments), player);
|
||||
}
|
||||
|
||||
public HistoryCommand(Phoenix phoenix) {
|
||||
this.plugin = phoenix;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Help;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Option;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.lib.commands.exception.execution.ExitMessage;
|
||||
import xyz.refinedev.phoenix.CommonPlatform;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
import xyz.refinedev.phoenix.utils.StringUtils;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
@Help
|
||||
@Register(name = "ignore")
|
||||
public class IgnoreCommand {
|
||||
|
||||
private final CommonPlatform platform;
|
||||
|
||||
@Command(name = "add", description = "Ignore a player")
|
||||
public void add(@Sender Player player, @Option("coverdisguise") IProfile profile) {
|
||||
IProfile cachedProfile =
|
||||
this.platform.getProfileHandler().getCachedProfile(player.getUniqueId());
|
||||
if (profile.getPlayerName().equals(player.getName())) {
|
||||
throw new ExitMessage(
|
||||
LocaleUtil.tr(player, MessageConfig.GENERAL.IGNORE.CANT_IGNORE_SELF));
|
||||
}
|
||||
if (cachedProfile.isIgnoring(profile.getUniqueId())) {
|
||||
throw new ExitMessage(
|
||||
LocaleUtil.tr(player, MessageConfig.GENERAL.IGNORE.ALREADY_IGNORING)
|
||||
.replace("<player>", profile.getNameWithColor()));
|
||||
}
|
||||
cachedProfile.getIgnoring().add(profile.getUniqueId());
|
||||
cachedProfile.saveAndUpdate(false);
|
||||
player.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(player, MessageConfig.GENERAL.IGNORE.IGNORE_ADDED)
|
||||
.replace("<player>", profile.getNameWithColor())));
|
||||
}
|
||||
|
||||
@Command(name = "remove", description = "Unignore a player")
|
||||
public void remove(@Sender Player player, IProfile profile) {
|
||||
IProfile profile2;
|
||||
if (!(profile2 = this.platform.getProfileHandler().getCachedProfile(player.getUniqueId()))
|
||||
.isIgnoring(profile.getUniqueId())) {
|
||||
throw new ExitMessage(
|
||||
LocaleUtil.tr(player, MessageConfig.GENERAL.IGNORE.NOT_IGNORING)
|
||||
.replace("<player>", profile.getNameWithColor()));
|
||||
}
|
||||
profile2.getIgnoring().remove(profile.getUniqueId());
|
||||
profile2.saveAndUpdate(false);
|
||||
player.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(player, MessageConfig.GENERAL.IGNORE.IGNORE_REMOVED)
|
||||
.replace("<player>", profile.getNameWithColor())));
|
||||
}
|
||||
|
||||
@Command(name = "list", description = "List the players ignored by you")
|
||||
public void list(@Sender Player player) {
|
||||
IProfile profile;
|
||||
if ((profile = this.platform.getProfileHandler().getCachedProfile(player.getUniqueId()))
|
||||
.getIgnoring()
|
||||
.isEmpty()) {
|
||||
throw new ExitMessage(LocaleUtil.tr(player, MessageConfig.GENERAL.IGNORE.NO_IGNORES));
|
||||
}
|
||||
Iterator<String> iterator2 =
|
||||
LocaleUtil.tr(player, MessageConfig.GENERAL.IGNORE.FORMAT).iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
String text;
|
||||
if ((text = (String) iterator2.next()).contains("<names>")) {
|
||||
player.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(player, MessageConfig.GENERAL.IGNORE.NAMES)
|
||||
.replace(
|
||||
"<names>",
|
||||
StringUtils.niceBuilderWithAnd(
|
||||
profile.getNiceIgnoreNames(),
|
||||
ChatColor.GRAY.toString(),
|
||||
ChatColor.GREEN.toString(),
|
||||
" "
|
||||
+ LocaleUtil.tr(
|
||||
player,
|
||||
MessageConfig.GENERAL
|
||||
.GENERIC_LIST_AND)
|
||||
+ " "))));
|
||||
} else {
|
||||
player.sendMessage(Color.translate(text));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IgnoreCommand(CommonPlatform commonPlatform) {
|
||||
this.platform = commonPlatform;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.menu.impl.staff.PlayerInventoryMenu;
|
||||
|
||||
@Register(name = "invsee", aliases = "openinv")
|
||||
@Requires("core.command.invsee")
|
||||
public class InvseeCommand {
|
||||
|
||||
@Command(name = "")
|
||||
public void execute(@Sender Player player, Player player2) {
|
||||
Phoenix.getInstance().getMenuHandler().openMenu(new PlayerInventoryMenu(player2), player);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Help;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Default;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Named;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Optional;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.lib.commands.exception.execution.ExitMessage;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
import xyz.refinedev.phoenix.utils.XMaterial;
|
||||
|
||||
@Help
|
||||
@Register(
|
||||
name = "item",
|
||||
aliases = {"give", "i"})
|
||||
@Requires("core.command.item")
|
||||
public class ItemCommand {
|
||||
|
||||
@Command(name = "")
|
||||
public void execute(
|
||||
@Sender Player player,
|
||||
XMaterial xMaterial,
|
||||
@Default("1") @Named("amount") int value,
|
||||
@Optional Player player2) {
|
||||
if (xMaterial == XMaterial.AIR) {
|
||||
throw new ExitMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(player, MessageConfig.BASIC.GENERAL.INVALID_ITEM)));
|
||||
}
|
||||
ItemStack itemStack;
|
||||
if ((itemStack = xMaterial.parseItem()) == null) {
|
||||
throw new ExitMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(player, MessageConfig.BASIC.GENERAL.INVALID_ITEM)));
|
||||
}
|
||||
itemStack.setAmount(value);
|
||||
Player player3;
|
||||
(player3 = player2 != null ? player2 : player)
|
||||
.getInventory()
|
||||
.addItem(new ItemStack[] {itemStack});
|
||||
player.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(player, MessageConfig.BASIC.ADMIN.ITEM.GAVE_OTHER)
|
||||
.replace("<player>", player3.getName())
|
||||
.replace("<amount>", String.valueOf(value))
|
||||
.replace("<material>", itemStack.getType().name())));
|
||||
}
|
||||
}
|
||||
Loaded 100 of 1166 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user