Converting to PDK
This commit is contained in:
11
build.gradle
11
build.gradle
@@ -5,6 +5,15 @@ plugins {
|
|||||||
group = project.group
|
group = project.group
|
||||||
version = project.version
|
version = project.version
|
||||||
|
|
||||||
|
jar {
|
||||||
|
from {
|
||||||
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||||
|
configurations.runtimeClasspath.collect {
|
||||||
|
it.isDirectory() ? it : zipTree(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven {
|
maven {
|
||||||
@@ -20,6 +29,7 @@ repositories {
|
|||||||
dependencies {
|
dependencies {
|
||||||
compileOnly "org.spigotmc:spigot-api:1.20.2-R0.1-SNAPSHOT"
|
compileOnly "org.spigotmc:spigot-api:1.20.2-R0.1-SNAPSHOT"
|
||||||
implementation 'com.google.code.gson:gson:2.10.1'
|
implementation 'com.google.code.gson:gson:2.10.1'
|
||||||
|
implementation files("libs/PDK-1.3.3.jar")
|
||||||
}
|
}
|
||||||
|
|
||||||
def targetJavaVersion = 16
|
def targetJavaVersion = 16
|
||||||
@@ -52,4 +62,3 @@ compileJava.options.encoding("UTF-8")
|
|||||||
tasks.withType(JavaCompile) {
|
tasks.withType(JavaCompile) {
|
||||||
options.encoding = "UTF-8"
|
options.encoding = "UTF-8"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
BIN
libs/PDK-1.3.3.jar
Normal file
BIN
libs/PDK-1.3.3.jar
Normal file
Binary file not shown.
@@ -1,10 +1,12 @@
|
|||||||
package io.github.thetrouper.sentinel;
|
package io.github.thetrouper.sentinel;
|
||||||
|
|
||||||
|
import io.github.itzispyder.pdk.PDK;
|
||||||
import io.github.thetrouper.sentinel.auth.Auth;
|
import io.github.thetrouper.sentinel.auth.Auth;
|
||||||
import io.github.thetrouper.sentinel.commands.*;
|
import io.github.thetrouper.sentinel.cmds.*;
|
||||||
import io.github.thetrouper.sentinel.data.Config;
|
|
||||||
import io.github.thetrouper.sentinel.data.LanguageFile;
|
|
||||||
import io.github.thetrouper.sentinel.events.*;
|
import io.github.thetrouper.sentinel.events.*;
|
||||||
|
import io.github.thetrouper.sentinel.server.config.Config;
|
||||||
|
import io.github.thetrouper.sentinel.server.config.LanguageFile;
|
||||||
|
import io.github.thetrouper.sentinel.server.config.MainConfig;
|
||||||
import io.github.thetrouper.sentinel.server.functions.AntiSpam;
|
import io.github.thetrouper.sentinel.server.functions.AntiSpam;
|
||||||
import io.github.thetrouper.sentinel.server.functions.Authenticator;
|
import io.github.thetrouper.sentinel.server.functions.Authenticator;
|
||||||
import io.github.thetrouper.sentinel.server.functions.ProfanityFilter;
|
import io.github.thetrouper.sentinel.server.functions.ProfanityFilter;
|
||||||
@@ -15,11 +17,14 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public final class Sentinel extends JavaPlugin {
|
public final class Sentinel extends JavaPlugin {
|
||||||
private static Sentinel instance;
|
private static Sentinel instance;
|
||||||
public static LanguageFile dict;
|
public static LanguageFile dict;
|
||||||
|
private static File cfgfile = new File("plugins/Sentinel/main-config.json");
|
||||||
|
public static MainConfig mainConfig = JsonSerializable.load(cfgfile, MainConfig.class, new MainConfig());
|
||||||
public static final PluginManager manager = Bukkit.getPluginManager();
|
public static final PluginManager manager = Bukkit.getPluginManager();
|
||||||
public static String prefix = "";
|
public static String prefix = "";
|
||||||
public static String key = "";
|
public static String key = "";
|
||||||
@@ -33,6 +38,7 @@ public final class Sentinel extends JavaPlugin {
|
|||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
log.info("\n]======------ Pre-load started! ------======[");
|
log.info("\n]======------ Pre-load started! ------======[");
|
||||||
|
PDK.init(this);
|
||||||
instance = this;
|
instance = this;
|
||||||
log.info("Loading Config...");
|
log.info("Loading Config...");
|
||||||
loadConfig();
|
loadConfig();
|
||||||
@@ -49,7 +55,7 @@ public final class Sentinel extends JavaPlugin {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
log.info("WTFFFF ARE YOU DOING MAN??????");
|
log.info("WTFFFF ARE YOU DOING MAN??????");
|
||||||
getServer().getPluginManager().disablePlugin(this);
|
manager.disablePlugin(this);
|
||||||
}
|
}
|
||||||
switch (authStatus) {
|
switch (authStatus) {
|
||||||
case "AUTHORIZED" -> {
|
case "AUTHORIZED" -> {
|
||||||
@@ -67,21 +73,21 @@ public final class Sentinel extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
case "FAILURE" -> {
|
case "FAILURE" -> {
|
||||||
log.info("Dynamic IP Failure. Webhook Error possible? Please contact obvWolf to fix this.");
|
log.info("Dynamic IP Failure. Webhook Error possible? Please contact obvWolf to fix this.");
|
||||||
getServer().getPluginManager().disablePlugin(this);
|
manager.disablePlugin(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case "INVALID-ID" -> {
|
case "INVALID-ID" -> {
|
||||||
log.info("Authentication Failure, You have not whitelisted this server ID yet.");
|
log.info("Authentication Failure, You have not whitelisted this server ID yet.");
|
||||||
getServer().getPluginManager().disablePlugin(this);
|
manager.disablePlugin(this);
|
||||||
}
|
}
|
||||||
case "UNREGISTERED" -> {
|
case "UNREGISTERED" -> {
|
||||||
log.warning("Authentication Failure, YOU SHALL NOT PASS! License: " + key + " Server ID: " + serverID);
|
log.warning("Authentication Failure, YOU SHALL NOT PASS! License: " + key + " Server ID: " + serverID);
|
||||||
getServer().getPluginManager().disablePlugin(this);
|
manager.disablePlugin(this);
|
||||||
}
|
}
|
||||||
case "ERROR" -> {
|
case "ERROR" -> {
|
||||||
log.warning("Hmmmmmm thats not right... License: " + key + " Server ID: " + serverID + "\nPlease report the above stacktrace.");
|
log.warning("Hmmmmmm thats not right... License: " + key + " Server ID: " + serverID + "\nPlease report the above stacktrace.");
|
||||||
getServer().getPluginManager().disablePlugin(this);
|
manager.disablePlugin(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -96,7 +102,7 @@ public final class Sentinel extends JavaPlugin {
|
|||||||
AntiSpam.enableAntiSpam();
|
AntiSpam.enableAntiSpam();
|
||||||
ProfanityFilter.enableAntiSwear();
|
ProfanityFilter.enableAntiSwear();
|
||||||
|
|
||||||
prefix = Config.Plugin.getPrefix();
|
prefix = MainConfig.Plugin.prefix;
|
||||||
|
|
||||||
// Commands -> BE SURE TO REGISTER ANY NEW COMMANDS IN PLUGIN.YML (src/main/java/resources/plugin.yml)!
|
// Commands -> BE SURE TO REGISTER ANY NEW COMMANDS IN PLUGIN.YML (src/main/java/resources/plugin.yml)!
|
||||||
new SentinelCommand().register();
|
new SentinelCommand().register();
|
||||||
@@ -107,14 +113,15 @@ public final class Sentinel extends JavaPlugin {
|
|||||||
new ChatClickCallback().register();
|
new ChatClickCallback().register();
|
||||||
|
|
||||||
// Events
|
// Events
|
||||||
manager.registerEvents(new CommandEvent(),this);
|
new ChatEvent().register();
|
||||||
manager.registerEvents(new CMDBlockExecute(), this);
|
new CommandEvent().register();
|
||||||
manager.registerEvents(new CMDBlockPlace(), this);
|
new CMDBlockExecute().register();
|
||||||
manager.registerEvents(new CMDBlockUse(), this);
|
new CMDBlockPlace().register();
|
||||||
manager.registerEvents(new CMDMinecartPlace(), this);
|
new CMDBlockUse().register();
|
||||||
manager.registerEvents(new CMDMinecartUse(), this);
|
new CMDMinecartPlace().register();
|
||||||
manager.registerEvents(new NBTEvents(), this);
|
new CMDMinecartUse().register();
|
||||||
manager.registerEvents(new ChatEvent(),this);
|
new NBTEvents().register();
|
||||||
|
|
||||||
|
|
||||||
// Scheduled timers
|
// Scheduled timers
|
||||||
Bukkit.getScheduler().runTaskTimer(this, AntiSpam::decayHeat,0, 20);
|
Bukkit.getScheduler().runTaskTimer(this, AntiSpam::decayHeat,0, 20);
|
||||||
@@ -132,9 +139,8 @@ public final class Sentinel extends JavaPlugin {
|
|||||||
|
|
||||||
public void loadConfig() {
|
public void loadConfig() {
|
||||||
// Init
|
// Init
|
||||||
Config.loadConfiguration();
|
|
||||||
|
|
||||||
log.info("Loading Dictionary (" + Config.lang + ")...");
|
log.info("Loading Dictionary (" + MainConfig.Plugin.lang + ")...");
|
||||||
dict = JsonSerializable.load(LanguageFile.PATH,LanguageFile.class,new LanguageFile());
|
dict = JsonSerializable.load(LanguageFile.PATH,LanguageFile.class,new LanguageFile());
|
||||||
|
|
||||||
log.info("Verifying Config...");
|
log.info("Verifying Config...");
|
||||||
@@ -160,7 +166,7 @@ public final class Sentinel extends JavaPlugin {
|
|||||||
* @return true if the player is trusted, false otherwise
|
* @return true if the player is trusted, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isTrusted(Player player) {
|
public static boolean isTrusted(Player player) {
|
||||||
return Config.trustedPlayers.contains(player.getUniqueId().toString());
|
return MainConfig.Plugin.trustedPlayers.contains(player.getUniqueId().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -169,7 +175,7 @@ public final class Sentinel extends JavaPlugin {
|
|||||||
* @return true if the command is logged, false otherwise
|
* @return true if the command is logged, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isLoggedCommand(String command) {
|
public static boolean isLoggedCommand(String command) {
|
||||||
return Config.logged.contains(command);
|
return MainConfig.Plugin.logged.contains(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -178,7 +184,7 @@ public final class Sentinel extends JavaPlugin {
|
|||||||
* @return true if the command is dangerous, false otherwise
|
* @return true if the command is dangerous, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isDangerousCommand(String command) {
|
public static boolean isDangerousCommand(String command) {
|
||||||
return Config.dangerous.contains(command);
|
return MainConfig.Plugin.dangerous.contains(command);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Returns an instance of this plugin
|
* Returns an instance of this plugin
|
||||||
|
|||||||
@@ -1,38 +1,28 @@
|
|||||||
/**
|
package io.github.thetrouper.sentinel.cmds;
|
||||||
* This file is for tutorial purposes made by ImproperIssues. Distribute if you want :)
|
|
||||||
*/
|
|
||||||
|
|
||||||
package io.github.thetrouper.sentinel.commands;
|
|
||||||
|
|
||||||
|
import io.github.itzispyder.pdk.commands.Args;
|
||||||
|
import io.github.itzispyder.pdk.commands.CustomCommand;
|
||||||
|
import io.github.itzispyder.pdk.commands.completions.CompletionBuilder;
|
||||||
|
import io.github.itzispyder.pdk.utils.misc.Cooldown;
|
||||||
import io.github.thetrouper.sentinel.Sentinel;
|
import io.github.thetrouper.sentinel.Sentinel;
|
||||||
import io.github.thetrouper.sentinel.server.functions.ReportFalsePositives;
|
import io.github.thetrouper.sentinel.server.functions.ReportFalsePositives;
|
||||||
import io.github.thetrouper.sentinel.server.util.Cooldown;
|
|
||||||
import io.github.thetrouper.sentinel.server.util.Text;
|
import io.github.thetrouper.sentinel.server.util.Text;
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
public class ChatClickCallback implements CustomCommand {
|
||||||
* Example command
|
Cooldown<UUID> fpReportCooldown = new Cooldown<>();
|
||||||
*/
|
|
||||||
public class ChatClickCallback extends CustomCommand {
|
|
||||||
public static Cooldown<UUID> fpReportCooldown = new Cooldown<>();
|
|
||||||
public ChatClickCallback() {
|
|
||||||
super("sentinelcallback");
|
|
||||||
this.setPrintStacktrace(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dispatchCommand(CommandSender sender, Command command, String label, String[] args) {
|
public void dispatchCommand(CommandSender sender, Args args) {
|
||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
switch (args[0]) {
|
switch (args.get(0).toString()) {
|
||||||
case "fpreport" -> {
|
case "fpreport" -> {
|
||||||
if (fpReportCooldown.isOnCooldown(p.getUniqueId()) && !p.isOp()) {
|
if (fpReportCooldown.isOnCooldown(p.getUniqueId()) && !p.isOp()) {
|
||||||
p.sendMessage(Text.prefix(Sentinel.dict.get("cooldown") + fpReportCooldown.getCooldown(p.getUniqueId())));
|
p.sendMessage(Text.prefix(Sentinel.dict.get("cooldown") + fpReportCooldown.getCooldown(p.getUniqueId())));
|
||||||
} else {
|
} else {
|
||||||
ReportFalsePositives.sendFalsePositiveReport(args[1]);
|
ReportFalsePositives.sendFalsePositiveReport(args.get(1).toString());
|
||||||
p.sendMessage(Text.prefix(Sentinel.dict.get("false-positive-report-success")));
|
p.sendMessage(Text.prefix(Sentinel.dict.get("false-positive-report-success")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -40,7 +30,7 @@ public class ChatClickCallback extends CustomCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerCompletions(CompletionBuilder builder) {
|
public void dispatchCompletions(CompletionBuilder b) {
|
||||||
builder.addCompletion(1,"a_you","b_must","c_be","d_called","e_before","f_running","g_a","h_callback");
|
b.then(b.arg("a_you","b_must","c_be","d_called","e_before","f_running","g_a","h_callback"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package io.github.thetrouper.sentinel.cmds;
|
||||||
|
|
||||||
|
import io.github.itzispyder.pdk.commands.Args;
|
||||||
|
import io.github.itzispyder.pdk.commands.CommandRegistry;
|
||||||
|
import io.github.itzispyder.pdk.commands.CustomCommand;
|
||||||
|
import io.github.itzispyder.pdk.commands.Permission;
|
||||||
|
import io.github.itzispyder.pdk.commands.completions.CompletionBuilder;
|
||||||
|
import io.github.thetrouper.sentinel.Sentinel;
|
||||||
|
import io.github.thetrouper.sentinel.server.functions.Message;
|
||||||
|
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
||||||
|
import io.github.thetrouper.sentinel.server.util.Text;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandRegistry(value = "sentinelmessage",permission = @Permission("sentinel.message"))
|
||||||
|
public class MessageCommand implements CustomCommand {
|
||||||
|
@Override
|
||||||
|
public void dispatchCommand(CommandSender sender, Args args) {
|
||||||
|
Player p = (Player) sender;
|
||||||
|
Player r = null;
|
||||||
|
if (args.getSize() == 0) {
|
||||||
|
p.sendMessage(Text.prefix(Sentinel.dict.get("no-online-player")));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (args.getSize() == 1) {
|
||||||
|
p.sendMessage(Text.prefix(Sentinel.dict.get("no-message-provided")));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
r = Bukkit.getPlayer(args.get(0).toString());
|
||||||
|
|
||||||
|
String msg = args.getAll(1).toString().trim();
|
||||||
|
|
||||||
|
if (p.hasPermission("sentinel.message") && r != null) {
|
||||||
|
Message.messagePlayer(p,r,msg);
|
||||||
|
} else if (r == null) p.sendMessage(Text.prefix((Sentinel.dict.get("no-online-player"))));
|
||||||
|
else sender.sendMessage(Text.prefix(Sentinel.dict.get("no-permission")));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dispatchCompletions(CompletionBuilder b) {
|
||||||
|
b.then(b.arg(ServerUtils.unVanishedPlayers())
|
||||||
|
.then(b.arg("[<Message>]")));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,19 +1,16 @@
|
|||||||
package io.github.thetrouper.sentinel.commands;
|
package io.github.thetrouper.sentinel.cmds;
|
||||||
|
|
||||||
|
import io.github.itzispyder.pdk.commands.Args;
|
||||||
|
import io.github.itzispyder.pdk.commands.CustomCommand;
|
||||||
|
import io.github.itzispyder.pdk.commands.completions.CompletionBuilder;
|
||||||
import io.github.thetrouper.sentinel.Sentinel;
|
import io.github.thetrouper.sentinel.Sentinel;
|
||||||
import io.github.thetrouper.sentinel.server.util.Text;
|
import io.github.thetrouper.sentinel.server.util.Text;
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class ReopCommand extends CustomCommand {
|
public class ReopCommand implements CustomCommand {
|
||||||
public ReopCommand() {
|
|
||||||
super("reop");
|
|
||||||
this.setPrintStacktrace(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dispatchCommand(CommandSender sender, Command command, String label, String[] args) {
|
public void dispatchCommand(CommandSender sender, Args args) {
|
||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
if (Sentinel.isTrusted(p)) {
|
if (Sentinel.isTrusted(p)) {
|
||||||
if (!p.isOp()) {
|
if (!p.isOp()) {
|
||||||
@@ -31,8 +28,7 @@ public class ReopCommand extends CustomCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerCompletions(CompletionBuilder builder) {
|
public void dispatchCompletions(CompletionBuilder completionBuilder) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,26 +1,21 @@
|
|||||||
package io.github.thetrouper.sentinel.commands;
|
package io.github.thetrouper.sentinel.cmds;
|
||||||
|
|
||||||
|
import io.github.itzispyder.pdk.commands.Args;
|
||||||
|
import io.github.itzispyder.pdk.commands.CustomCommand;
|
||||||
|
import io.github.itzispyder.pdk.commands.completions.CompletionBuilder;
|
||||||
import io.github.thetrouper.sentinel.Sentinel;
|
import io.github.thetrouper.sentinel.Sentinel;
|
||||||
import io.github.thetrouper.sentinel.server.functions.Message;
|
import io.github.thetrouper.sentinel.server.functions.Message;
|
||||||
import io.github.thetrouper.sentinel.server.util.Text;
|
import io.github.thetrouper.sentinel.server.util.Text;
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class ReplyCommand extends CustomCommand {
|
public class ReplyCommand implements CustomCommand {
|
||||||
public static Map<UUID, UUID> replyMap = MessageCommand.replyMap;
|
public static Map<UUID, UUID> replyMap = Message.replyMap;
|
||||||
|
|
||||||
public ReplyCommand() {
|
|
||||||
super("reply");
|
|
||||||
this.setPrintStacktrace(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dispatchCommand(CommandSender sender, Command command, String label, String[] args) {
|
public void dispatchCommand(CommandSender sender, Args args) {
|
||||||
String name = sender.getName();
|
String name = sender.getName();
|
||||||
Player p = sender.getServer().getPlayer(name);
|
Player p = sender.getServer().getPlayer(name);
|
||||||
UUID senderID = p.getUniqueId();
|
UUID senderID = p.getUniqueId();
|
||||||
@@ -29,10 +24,10 @@ public class ReplyCommand extends CustomCommand {
|
|||||||
}
|
}
|
||||||
Player r = sender.getServer().getPlayer(replyMap.get(senderID));
|
Player r = sender.getServer().getPlayer(replyMap.get(senderID));
|
||||||
UUID reciverID = r.getUniqueId();
|
UUID reciverID = r.getUniqueId();
|
||||||
if (args[0] == null) {
|
if (args.get(0).toString() == null) {
|
||||||
p.sendMessage(Text.prefix(Sentinel.dict.get("no-message-provided")));
|
p.sendMessage(Text.prefix(Sentinel.dict.get("no-message-provided")));
|
||||||
}
|
}
|
||||||
String msg = String.join(" ", Arrays.asList(args));
|
String msg = args.getAll().toString();
|
||||||
if (p.hasPermission("sentinel.message")) {
|
if (p.hasPermission("sentinel.message")) {
|
||||||
Message.messagePlayer(p,r,msg);
|
Message.messagePlayer(p,r,msg);
|
||||||
replyMap.put(senderID,reciverID);
|
replyMap.put(senderID,reciverID);
|
||||||
@@ -42,7 +37,7 @@ public class ReplyCommand extends CustomCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerCompletions(CompletionBuilder builder) {
|
public void dispatchCompletions(CompletionBuilder b) {
|
||||||
builder.addCompletion(1,builder.args.length >= 2, "[<message>]");
|
b.then(b.arg("[<Message>]"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
package io.github.thetrouper.sentinel.cmds;
|
||||||
|
|
||||||
|
import io.github.itzispyder.pdk.commands.Args;
|
||||||
|
import io.github.itzispyder.pdk.commands.CommandRegistry;
|
||||||
|
import io.github.itzispyder.pdk.commands.CustomCommand;
|
||||||
|
import io.github.itzispyder.pdk.commands.Permission;
|
||||||
|
import io.github.itzispyder.pdk.commands.completions.CompletionBuilder;
|
||||||
|
import io.github.thetrouper.sentinel.Sentinel;
|
||||||
|
import io.github.thetrouper.sentinel.server.config.Config;
|
||||||
|
import io.github.thetrouper.sentinel.server.functions.AntiSpam;
|
||||||
|
import io.github.thetrouper.sentinel.server.functions.ProfanityFilter;
|
||||||
|
import io.github.thetrouper.sentinel.server.util.Text;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
@CommandRegistry(value = "sentinel",permission = @Permission("sentinel.debug"))
|
||||||
|
public class SentinelCommand implements CustomCommand {
|
||||||
|
public static boolean debugMode;
|
||||||
|
@Override
|
||||||
|
public void dispatchCommand(CommandSender commandSender, Args args) {
|
||||||
|
Player p = (Player) commandSender;
|
||||||
|
Sentinel instance = Sentinel.getInstance();
|
||||||
|
switch (args.get(0).toString()) {
|
||||||
|
case "reload" -> {
|
||||||
|
if (!Sentinel.isTrusted(p)) return;
|
||||||
|
p.sendMessage(Text.prefix("Reloading Sentinel!"));
|
||||||
|
Sentinel.log.info("[Sentinel] Re-Initializing Sentinel!");
|
||||||
|
instance.loadConfig();
|
||||||
|
}
|
||||||
|
case "debug" -> {
|
||||||
|
switch (args.get(1).toString()) {
|
||||||
|
case "antiswear" -> {
|
||||||
|
HashSet<Player> players = new HashSet<>();
|
||||||
|
players.add(p);
|
||||||
|
String msg = args.getAll(1).toString().trim();
|
||||||
|
AsyncPlayerChatEvent e = new AsyncPlayerChatEvent(true, p, msg, players);
|
||||||
|
ProfanityFilter.handleProfanityFilter(e);
|
||||||
|
}
|
||||||
|
case "antispam" -> {
|
||||||
|
HashSet<Player> players = new HashSet<>();
|
||||||
|
players.add(p);
|
||||||
|
String msg = args.getAll(1).toString().trim();
|
||||||
|
AsyncPlayerChatEvent e = new AsyncPlayerChatEvent(true, p, msg, players);
|
||||||
|
AntiSpam.handleAntiSpam(e);
|
||||||
|
}
|
||||||
|
case "lang" -> {
|
||||||
|
p.sendMessage(Sentinel.dict.get("exmaple-message"));
|
||||||
|
}
|
||||||
|
case "toggle" -> {
|
||||||
|
debugMode = !debugMode;
|
||||||
|
p.sendMessage(Text.prefix((debugMode ? "Enabled" : "Disabled") + " debug mode."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case "getHeat" -> {
|
||||||
|
Player target = Bukkit.getPlayer(args.get(1).toString());
|
||||||
|
if (target == null) {
|
||||||
|
p.sendMessage(Text.prefix("Invalid Player!"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
p.sendMessage(Text.prefix("Heat of " + target.getName() + ": &8(&c" + AntiSpam.heatMap.get(target) + "&7/&4" + Config.punishHeat + "&8)"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dispatchCompletions(CompletionBuilder b) {
|
||||||
|
b.then(b.arg("reload","getheat"));
|
||||||
|
b.then(b.arg("debug").then(
|
||||||
|
b.arg("antiswear","antispam","lang","toggle")));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,10 @@
|
|||||||
package io.github.thetrouper.sentinel.commands;
|
package io.github.thetrouper.sentinel.cmds;
|
||||||
|
|
||||||
|
import io.github.itzispyder.pdk.commands.Args;
|
||||||
|
import io.github.itzispyder.pdk.commands.CustomCommand;
|
||||||
|
import io.github.itzispyder.pdk.commands.completions.CompletionBuilder;
|
||||||
import io.github.thetrouper.sentinel.Sentinel;
|
import io.github.thetrouper.sentinel.Sentinel;
|
||||||
import io.github.thetrouper.sentinel.server.util.Text;
|
import io.github.thetrouper.sentinel.server.util.Text;
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@@ -10,16 +12,11 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class SocialSpyCommand extends CustomCommand {
|
public class SocialSpyCommand implements CustomCommand {
|
||||||
|
|
||||||
public static Map<UUID, Boolean> spyMap = new HashMap<>();
|
public static Map<UUID, Boolean> spyMap = new HashMap<>();
|
||||||
|
|
||||||
public SocialSpyCommand() {
|
|
||||||
super("socialspy");
|
|
||||||
this.setPrintStacktrace(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dispatchCommand(CommandSender sender, Command command, String label, String[] args) {
|
public void dispatchCommand(CommandSender sender, Args args) {
|
||||||
String name = sender.getName();
|
String name = sender.getName();
|
||||||
Player p = sender.getServer().getPlayer(name);
|
Player p = sender.getServer().getPlayer(name);
|
||||||
UUID senderID = p.getUniqueId();
|
UUID senderID = p.getUniqueId();
|
||||||
@@ -33,7 +30,7 @@ public class SocialSpyCommand extends CustomCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerCompletions(CompletionBuilder builder) {
|
public void dispatchCompletions(CompletionBuilder completionBuilder) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,166 +0,0 @@
|
|||||||
package io.github.thetrouper.sentinel.commands;
|
|
||||||
|
|
||||||
import io.github.thetrouper.sentinel.Sentinel;
|
|
||||||
import io.github.thetrouper.sentinel.server.util.Text;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.command.TabExecutor;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.function.Predicate;
|
|
||||||
|
|
||||||
public abstract class CustomCommand implements TabExecutor {
|
|
||||||
|
|
||||||
protected static final Sentinel system = Sentinel.getInstance();
|
|
||||||
private final String name;
|
|
||||||
private boolean printStacktrace;
|
|
||||||
|
|
||||||
public CustomCommand(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPrintStacktrace(boolean printStacktrace) {
|
|
||||||
this.printStacktrace = printStacktrace;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean canPrintStacktrace() {
|
|
||||||
return printStacktrace;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract void dispatchCommand(CommandSender sender, Command command, String label, String[] args);
|
|
||||||
public abstract void registerCompletions(CompletionBuilder builder);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
||||||
try {
|
|
||||||
dispatchCommand(sender, command, label, args);
|
|
||||||
}
|
|
||||||
catch (Exception ex) {
|
|
||||||
String msg = ex.getMessage();
|
|
||||||
|
|
||||||
if (ex instanceof IndexOutOfBoundsException)
|
|
||||||
msg = "command incomplete";
|
|
||||||
else if (ex instanceof NullPointerException)
|
|
||||||
msg = "command contains a null value";
|
|
||||||
|
|
||||||
sender.sendMessage(Text.prefix("\u00a74Command Error: \u00a7cUnknown or incomplete command!"));
|
|
||||||
sender.sendMessage(Text.prefix("\u00a7cCaused by: \u00a78\u00a7o(" + ex.getClass().getSimpleName() + ") \u00a77" + msg));
|
|
||||||
sender.sendMessage(Text.prefix("\u00a7cCorrect Usage: \u00a77" + command.getUsage()));
|
|
||||||
|
|
||||||
if (printStacktrace) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
|
|
||||||
CompletionBuilder builder = new CompletionBuilder(sender, command, label, args);
|
|
||||||
registerCompletions(builder);
|
|
||||||
return builder.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public CustomCommand register() {
|
|
||||||
return register(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static CustomCommand register(CustomCommand command) {
|
|
||||||
system.getCommand(command.name).setExecutor(command);
|
|
||||||
system.getCommand(command.name).setTabCompleter(command);
|
|
||||||
return command;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class CompletionBuilder {
|
|
||||||
|
|
||||||
public final CommandSender sender;
|
|
||||||
public final Command command;
|
|
||||||
public final String label;
|
|
||||||
public final String[] args;
|
|
||||||
private final Map<Integer, List<String>> entries;
|
|
||||||
|
|
||||||
public CompletionBuilder(CommandSender sender, Command command, String label, String[] args) {
|
|
||||||
this.sender = sender;
|
|
||||||
this.command = command;
|
|
||||||
this.label = label;
|
|
||||||
this.args = args;
|
|
||||||
this.entries = new HashMap<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public CompletionBuilder addCompletion(int index, Predicate<CompletionBuilder> condition, Iterable<String> args) {
|
|
||||||
addCompletion(index, condition.test(this), args);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CompletionBuilder addCompletion(int index, Predicate<CompletionBuilder> condition, String... args) {
|
|
||||||
addCompletion(index, condition.test(this), args);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CompletionBuilder addCompletion(int index, Predicate<CompletionBuilder> condition, List<String> args) {
|
|
||||||
addCompletion(index, condition.test(this), args);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CompletionBuilder addCompletion(int index, boolean condition, Iterable<String> args) {
|
|
||||||
if (condition) {
|
|
||||||
addCompletion(index, args);
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CompletionBuilder addCompletion(int index, boolean condition, String... args) {
|
|
||||||
if (condition) {
|
|
||||||
addCompletion(index, args);
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CompletionBuilder addCompletion(int index, boolean condition, List<String> args) {
|
|
||||||
if (condition) {
|
|
||||||
addCompletion(index, args);
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CompletionBuilder addCompletion(int index, Iterable<String> args) {
|
|
||||||
List<String> list = new ArrayList<>();
|
|
||||||
args.forEach(list::add);
|
|
||||||
addCompletion(index, list);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CompletionBuilder addCompletion(int index, String... args) {
|
|
||||||
addCompletion(index, Arrays.asList(args));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CompletionBuilder addCompletion(int index, List<String> args) {
|
|
||||||
entries.put(index, args);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeCompletion(int index) {
|
|
||||||
entries.remove(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
public <I> List<String> convertLists(Collection<I> input, Function<I, String> conversion) {
|
|
||||||
List<String> list = new ArrayList<>();
|
|
||||||
for (I i : input) {
|
|
||||||
list.add(conversion.apply(i));
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> build() {
|
|
||||||
return entries.getOrDefault(args.length, new ArrayList<>()).stream()
|
|
||||||
.filter(s -> s.toLowerCase().contains(args[args.length - 1].toLowerCase()))
|
|
||||||
.toList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
package io.github.thetrouper.sentinel.commands;
|
|
||||||
|
|
||||||
import io.github.thetrouper.sentinel.Sentinel;
|
|
||||||
import io.github.thetrouper.sentinel.server.functions.Message;
|
|
||||||
import io.github.thetrouper.sentinel.server.util.ArrayUtils;
|
|
||||||
import io.github.thetrouper.sentinel.server.util.Text;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class MessageCommand extends CustomCommand {
|
|
||||||
public static Map<UUID, UUID> replyMap = new HashMap<>();
|
|
||||||
|
|
||||||
public MessageCommand() {
|
|
||||||
super("msg");
|
|
||||||
this.setPrintStacktrace(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void dispatchCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
||||||
Player p = (Player) sender;
|
|
||||||
Player r = null;
|
|
||||||
if (args.length == 0) {
|
|
||||||
p.sendMessage(Text.prefix(Sentinel.dict.get("no-online-player")));
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
p.sendMessage(Text.prefix(Sentinel.dict.get("no-message-provided")));
|
|
||||||
}
|
|
||||||
r = Bukkit.getPlayer(args[0]);
|
|
||||||
String msg = "";
|
|
||||||
for (int i = 1; i < args.length; i++) {
|
|
||||||
msg = msg.concat(" " + args[i]);
|
|
||||||
}
|
|
||||||
msg = msg.trim();
|
|
||||||
if (p.hasPermission("sentinel.message") && r != null) {
|
|
||||||
Message.messagePlayer(p,r,msg);
|
|
||||||
} else if (r == null) {
|
|
||||||
p.sendMessage(Text.prefix((Sentinel.dict.get("no-online-player"))));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sender.sendMessage(Text.prefix(Sentinel.dict.get("no-permission")));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void registerCompletions(CompletionBuilder builder) {
|
|
||||||
builder.addCompletion(1, ArrayUtils.toNewList(Bukkit.getOnlinePlayers(), Player::getName));
|
|
||||||
builder.addCompletion(2,builder.args.length >= 2, "[<message>]");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,102 +0,0 @@
|
|||||||
/**
|
|
||||||
* This file is for tutorial purposes made by ImproperIssues. Distribute if you want :)
|
|
||||||
*/
|
|
||||||
|
|
||||||
package io.github.thetrouper.sentinel.commands;
|
|
||||||
|
|
||||||
import io.github.thetrouper.sentinel.Sentinel;
|
|
||||||
import io.github.thetrouper.sentinel.data.Config;
|
|
||||||
import io.github.thetrouper.sentinel.server.functions.AntiSpam;
|
|
||||||
import io.github.thetrouper.sentinel.server.functions.ProfanityFilter;
|
|
||||||
import io.github.thetrouper.sentinel.server.util.ArrayUtils;
|
|
||||||
import io.github.thetrouper.sentinel.server.util.Text;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Example command
|
|
||||||
*/
|
|
||||||
public class SentinelCommand extends CustomCommand {
|
|
||||||
public static boolean debugmode;
|
|
||||||
|
|
||||||
public SentinelCommand() {
|
|
||||||
super("sentinel");
|
|
||||||
this.setPrintStacktrace(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void dispatchCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
||||||
Player p = (Player) sender;
|
|
||||||
Sentinel instance = Sentinel.getInstance();
|
|
||||||
switch (args[0]) {
|
|
||||||
case "reload" -> {
|
|
||||||
if (!Sentinel.isTrusted(p)) return;
|
|
||||||
p.sendMessage(Text.prefix("Reloading Sentinel!"));
|
|
||||||
Sentinel.log.info("[Sentinel] Re-Initializing Sentinel!");
|
|
||||||
instance.loadConfig();
|
|
||||||
}
|
|
||||||
case "debug" -> {
|
|
||||||
switch (args[1]) {
|
|
||||||
case "antiswear" -> {
|
|
||||||
HashSet<Player> players = new HashSet<>();
|
|
||||||
players.add((Player) sender);
|
|
||||||
String msg = "";
|
|
||||||
for (int i = 1; i < args.length; i++) {
|
|
||||||
msg = msg.concat(" " + args[i]);
|
|
||||||
}
|
|
||||||
msg = msg.trim();
|
|
||||||
AsyncPlayerChatEvent e = new AsyncPlayerChatEvent(true, (Player) sender, msg, players);
|
|
||||||
ProfanityFilter.handleProfanityFilter(e);
|
|
||||||
}
|
|
||||||
case "antispam" -> {
|
|
||||||
HashSet<Player> players = new HashSet<>();
|
|
||||||
players.add((Player) sender);
|
|
||||||
String msg = "";
|
|
||||||
for (int i = 1; i < args.length; i++) {
|
|
||||||
msg = msg.concat(" " + args[i]);
|
|
||||||
}
|
|
||||||
msg = msg.trim();
|
|
||||||
AsyncPlayerChatEvent e = new AsyncPlayerChatEvent(true, (Player) sender, msg, players);
|
|
||||||
AntiSpam.handleAntiSpam(e);
|
|
||||||
}
|
|
||||||
case "lang" -> {
|
|
||||||
p.sendMessage(Sentinel.dict.get("exmaple-message"));
|
|
||||||
}
|
|
||||||
case "toggle" -> {
|
|
||||||
debugmode = !debugmode;
|
|
||||||
p.sendMessage(Text.prefix((debugmode ? "enabled" : "disabled") + " debug mode."));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "getHeat" -> {
|
|
||||||
Player target = Bukkit.getPlayer(args[1]);
|
|
||||||
if (target == null) {
|
|
||||||
p.sendMessage(Text.prefix("Invalid Player!"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
p.sendMessage(Text.prefix("Heat of " + target.getName() + ": &8(&c" + AntiSpam.heatMap.get(target) + "&7/&4" + Config.punishHeat + "&8)"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void registerCompletions(CompletionBuilder builder) {
|
|
||||||
builder.addCompletion(1, "debug",
|
|
||||||
"getHeat",
|
|
||||||
"reload");
|
|
||||||
if (builder.args.length >= 2 && builder.args[1].equals("debug")) {
|
|
||||||
builder.addCompletion(2, "antiswear",
|
|
||||||
"antispam",
|
|
||||||
"lang",
|
|
||||||
"toggle");
|
|
||||||
//builder.addCompletion(2, (builder.args.length >= 1 && builder.args[1].equals("getHeat")), ArrayUtils.toNewList(Bukkit.getOnlinePlayers(), Player::getName));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -17,8 +17,8 @@ public enum ActionType {
|
|||||||
private final String messageTitle;
|
private final String messageTitle;
|
||||||
private final Color embedColor;
|
private final Color embedColor;
|
||||||
|
|
||||||
ActionType(String messagetop, String messageTitle, Color embedColor) {
|
ActionType(String messageTop, String messageTitle, Color embedColor) {
|
||||||
this.messageTop = messagetop;
|
this.messageTop = messageTop;
|
||||||
this.messageTitle = messageTitle;
|
this.messageTitle = messageTitle;
|
||||||
this.embedColor = embedColor;
|
this.embedColor = embedColor;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package io.github.thetrouper.sentinel.data;
|
package io.github.thetrouper.sentinel.data;
|
||||||
|
|
||||||
|
import io.github.thetrouper.sentinel.server.config.Config;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
public enum FAT {
|
public enum FAT {
|
||||||
|
|||||||
@@ -1,16 +1,13 @@
|
|||||||
package io.github.thetrouper.sentinel.discord;
|
package io.github.thetrouper.sentinel.discord;
|
||||||
|
|
||||||
import javax.net.ssl.HttpsURLConnection;
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
import java.awt.Color;
|
import java.awt.*;
|
||||||
import java.io.*;
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStream;
|
||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.*;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class used to execute Discord Webhooks with low effort
|
* Class used to execute Discord Webhooks with low effort
|
||||||
|
|||||||
@@ -1,15 +1,7 @@
|
|||||||
package io.github.thetrouper.sentinel.events;
|
package io.github.thetrouper.sentinel.events;
|
||||||
|
|
||||||
import io.github.thetrouper.sentinel.Sentinel;
|
import io.github.itzispyder.pdk.events.CustomListener;
|
||||||
import io.github.thetrouper.sentinel.commands.SentinelCommand;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.block.CommandBlock;
|
|
||||||
import org.bukkit.command.BlockCommandSender;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.server.ServerCommandEvent;
|
|
||||||
import org.bukkit.inventory.meta.BlockDataMeta;
|
|
||||||
|
|
||||||
public class CMDBlockExecute implements Listener {
|
public class CMDBlockExecute implements CustomListener {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
package io.github.thetrouper.sentinel.events;
|
package io.github.thetrouper.sentinel.events;
|
||||||
|
|
||||||
|
import io.github.itzispyder.pdk.events.CustomListener;
|
||||||
import io.github.thetrouper.sentinel.Sentinel;
|
import io.github.thetrouper.sentinel.Sentinel;
|
||||||
import io.github.thetrouper.sentinel.data.Config;
|
|
||||||
import io.github.thetrouper.sentinel.data.Action;
|
|
||||||
import io.github.thetrouper.sentinel.data.ActionType;
|
import io.github.thetrouper.sentinel.data.ActionType;
|
||||||
|
import io.github.thetrouper.sentinel.server.Action;
|
||||||
|
import io.github.thetrouper.sentinel.server.config.Config;
|
||||||
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
|
|
||||||
public class CMDBlockPlace implements Listener {
|
public class CMDBlockPlace implements CustomListener {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
private void onCMDBlockPlace(BlockPlaceEvent e) {
|
private void onCMDBlockPlace(BlockPlaceEvent e) {
|
||||||
ServerUtils.sendDebugMessage("CommandBlockPlace: Detected block place");
|
ServerUtils.sendDebugMessage("CommandBlockPlace: Detected block place");
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
package io.github.thetrouper.sentinel.events;
|
package io.github.thetrouper.sentinel.events;
|
||||||
|
|
||||||
|
import io.github.itzispyder.pdk.events.CustomListener;
|
||||||
import io.github.thetrouper.sentinel.Sentinel;
|
import io.github.thetrouper.sentinel.Sentinel;
|
||||||
import io.github.thetrouper.sentinel.data.Config;
|
|
||||||
import io.github.thetrouper.sentinel.data.Action;
|
|
||||||
import io.github.thetrouper.sentinel.data.ActionType;
|
import io.github.thetrouper.sentinel.data.ActionType;
|
||||||
|
import io.github.thetrouper.sentinel.server.Action;
|
||||||
|
import io.github.thetrouper.sentinel.server.config.Config;
|
||||||
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@@ -11,11 +12,10 @@ import org.bukkit.block.BlockState;
|
|||||||
import org.bukkit.block.CommandBlock;
|
import org.bukkit.block.CommandBlock;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
|
||||||
public class CMDBlockUse implements Listener {
|
public class CMDBlockUse implements CustomListener {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
private void onCMDBlockUse(PlayerInteractEvent e) {
|
private void onCMDBlockUse(PlayerInteractEvent e) {
|
||||||
ServerUtils.sendDebugMessage("CommandBlockUse: Detected Interaction");
|
ServerUtils.sendDebugMessage("CommandBlockUse: Detected Interaction");
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
package io.github.thetrouper.sentinel.events;
|
package io.github.thetrouper.sentinel.events;
|
||||||
|
|
||||||
|
import io.github.itzispyder.pdk.events.CustomListener;
|
||||||
import io.github.thetrouper.sentinel.Sentinel;
|
import io.github.thetrouper.sentinel.Sentinel;
|
||||||
import io.github.thetrouper.sentinel.data.Config;
|
|
||||||
import io.github.thetrouper.sentinel.data.Action;
|
|
||||||
import io.github.thetrouper.sentinel.data.ActionType;
|
import io.github.thetrouper.sentinel.data.ActionType;
|
||||||
|
import io.github.thetrouper.sentinel.server.Action;
|
||||||
|
import io.github.thetrouper.sentinel.server.config.Config;
|
||||||
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
|
||||||
public class CMDMinecartPlace implements Listener {
|
public class CMDMinecartPlace implements CustomListener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
private void onCMDMinecartPlace(PlayerInteractEvent e) {
|
private void onCMDMinecartPlace(PlayerInteractEvent e) {
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
package io.github.thetrouper.sentinel.events;
|
package io.github.thetrouper.sentinel.events;
|
||||||
|
|
||||||
|
import io.github.itzispyder.pdk.events.CustomListener;
|
||||||
import io.github.thetrouper.sentinel.Sentinel;
|
import io.github.thetrouper.sentinel.Sentinel;
|
||||||
import io.github.thetrouper.sentinel.data.Config;
|
|
||||||
import io.github.thetrouper.sentinel.data.Action;
|
|
||||||
import io.github.thetrouper.sentinel.data.ActionType;
|
import io.github.thetrouper.sentinel.data.ActionType;
|
||||||
|
import io.github.thetrouper.sentinel.server.Action;
|
||||||
|
import io.github.thetrouper.sentinel.server.config.Config;
|
||||||
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||||
|
|
||||||
public class CMDMinecartUse implements Listener {
|
public class CMDMinecartUse implements CustomListener {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
private void onCMDBlockMinecartUse(PlayerInteractEntityEvent e) {
|
private void onCMDBlockMinecartUse(PlayerInteractEntityEvent e) {
|
||||||
ServerUtils.sendDebugMessage("MinecartCommandUse: Detected Interaction with entity");
|
ServerUtils.sendDebugMessage("MinecartCommandUse: Detected Interaction with entity");
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
package io.github.thetrouper.sentinel.events;
|
package io.github.thetrouper.sentinel.events;
|
||||||
|
|
||||||
|
import io.github.itzispyder.pdk.events.CustomListener;
|
||||||
import io.github.thetrouper.sentinel.Sentinel;
|
import io.github.thetrouper.sentinel.Sentinel;
|
||||||
import io.github.thetrouper.sentinel.data.Config;
|
import io.github.thetrouper.sentinel.server.config.Config;
|
||||||
|
import io.github.thetrouper.sentinel.server.config.MainConfig;
|
||||||
import io.github.thetrouper.sentinel.server.functions.AntiSpam;
|
import io.github.thetrouper.sentinel.server.functions.AntiSpam;
|
||||||
import io.github.thetrouper.sentinel.server.functions.AntiUnicode;
|
import io.github.thetrouper.sentinel.server.functions.AntiUnicode;
|
||||||
import io.github.thetrouper.sentinel.server.functions.ProfanityFilter;
|
import io.github.thetrouper.sentinel.server.functions.ProfanityFilter;
|
||||||
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
||||||
import io.github.thetrouper.sentinel.server.util.Text;
|
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
|
|
||||||
public class ChatEvent implements Listener {
|
public class ChatEvent implements CustomListener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public static void onChat(AsyncPlayerChatEvent e) {
|
public static void onChat(AsyncPlayerChatEvent e) {
|
||||||
@@ -19,7 +19,7 @@ public class ChatEvent implements Listener {
|
|||||||
ServerUtils.sendDebugMessage("ChatEvent: Chat event detected!");
|
ServerUtils.sendDebugMessage("ChatEvent: Chat event detected!");
|
||||||
if (!Sentinel.isTrusted(e.getPlayer()) || !e.getPlayer().hasPermission("sentinel.chat.antiunicode.bypass")) {
|
if (!Sentinel.isTrusted(e.getPlayer()) || !e.getPlayer().hasPermission("sentinel.chat.antiunicode.bypass")) {
|
||||||
ServerUtils.sendDebugMessage("ChatEvent: Permission bypass failed, checking for unicode");
|
ServerUtils.sendDebugMessage("ChatEvent: Permission bypass failed, checking for unicode");
|
||||||
if (Config.antiUnicode) {
|
if (MainConfig.Chat.antiUnicode) {
|
||||||
ServerUtils.sendDebugMessage(("ChatEvent: Enabled, Continuing unicode check!"));
|
ServerUtils.sendDebugMessage(("ChatEvent: Enabled, Continuing unicode check!"));
|
||||||
AntiUnicode.handleAntiUnicode(e);
|
AntiUnicode.handleAntiUnicode(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,16 @@
|
|||||||
package io.github.thetrouper.sentinel.events;
|
package io.github.thetrouper.sentinel.events;
|
||||||
|
|
||||||
|
import io.github.itzispyder.pdk.events.CustomListener;
|
||||||
import io.github.thetrouper.sentinel.Sentinel;
|
import io.github.thetrouper.sentinel.Sentinel;
|
||||||
import io.github.thetrouper.sentinel.data.Config;
|
|
||||||
import io.github.thetrouper.sentinel.data.Action;
|
|
||||||
import io.github.thetrouper.sentinel.data.ActionType;
|
import io.github.thetrouper.sentinel.data.ActionType;
|
||||||
|
import io.github.thetrouper.sentinel.server.Action;
|
||||||
|
import io.github.thetrouper.sentinel.server.config.Config;
|
||||||
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
||||||
import io.github.thetrouper.sentinel.server.util.Text;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
|
||||||
public class CommandEvent implements Listener {
|
public class CommandEvent implements CustomListener {
|
||||||
private String trusted;
|
private String trusted;
|
||||||
@EventHandler
|
@EventHandler
|
||||||
private void onCommand(PlayerCommandPreprocessEvent e) {
|
private void onCommand(PlayerCommandPreprocessEvent e) {
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
package io.github.thetrouper.sentinel.events;
|
package io.github.thetrouper.sentinel.events;
|
||||||
|
|
||||||
|
import io.github.itzispyder.pdk.events.CustomListener;
|
||||||
import io.github.thetrouper.sentinel.Sentinel;
|
import io.github.thetrouper.sentinel.Sentinel;
|
||||||
import io.github.thetrouper.sentinel.data.Config;
|
|
||||||
import io.github.thetrouper.sentinel.data.Action;
|
|
||||||
import io.github.thetrouper.sentinel.data.ActionType;
|
import io.github.thetrouper.sentinel.data.ActionType;
|
||||||
|
import io.github.thetrouper.sentinel.server.Action;
|
||||||
|
import io.github.thetrouper.sentinel.server.config.Config;
|
||||||
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@@ -12,7 +13,6 @@ import org.bukkit.block.Container;
|
|||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.inventory.InventoryCreativeEvent;
|
import org.bukkit.event.inventory.InventoryCreativeEvent;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@@ -21,7 +21,7 @@ import org.bukkit.inventory.meta.ItemMeta;
|
|||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class NBTEvents implements Listener {
|
public class NBTEvents implements CustomListener {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
private void onNBTPull(InventoryCreativeEvent e) {
|
private void onNBTPull(InventoryCreativeEvent e) {
|
||||||
ServerUtils.sendDebugMessage("NBT: Detected creative mode action");
|
ServerUtils.sendDebugMessage("NBT: Detected creative mode action");
|
||||||
|
|||||||
@@ -1,15 +1,17 @@
|
|||||||
package io.github.thetrouper.sentinel.data;
|
package io.github.thetrouper.sentinel.server;
|
||||||
|
|
||||||
|
|
||||||
import io.github.thetrouper.sentinel.Sentinel;
|
import io.github.thetrouper.sentinel.Sentinel;
|
||||||
|
import io.github.thetrouper.sentinel.data.ActionType;
|
||||||
|
import io.github.thetrouper.sentinel.data.Emojis;
|
||||||
import io.github.thetrouper.sentinel.discord.DiscordWebhook;
|
import io.github.thetrouper.sentinel.discord.DiscordWebhook;
|
||||||
|
import io.github.thetrouper.sentinel.server.config.Config;
|
||||||
import io.github.thetrouper.sentinel.server.util.FileUtils;
|
import io.github.thetrouper.sentinel.server.util.FileUtils;
|
||||||
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
||||||
import io.github.thetrouper.sentinel.server.util.Text;
|
import io.github.thetrouper.sentinel.server.util.Text;
|
||||||
import net.md_5.bungee.api.chat.HoverEvent;
|
import net.md_5.bungee.api.chat.HoverEvent;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
@@ -19,36 +21,8 @@ import java.io.IOException;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Action {
|
public class Action {
|
||||||
private final Cancellable event;
|
|
||||||
private final ActionType action;
|
|
||||||
private final Player player;
|
|
||||||
private final String command;
|
|
||||||
private final String loggedCommand;
|
|
||||||
private final ItemStack item;
|
|
||||||
private final Block block;
|
|
||||||
private final boolean denied;
|
|
||||||
private final boolean deoped;
|
|
||||||
private final boolean punished;
|
|
||||||
private final boolean revertGM;
|
|
||||||
private final boolean notifyDiscord;
|
|
||||||
private final boolean notifyTrusted;
|
|
||||||
private final boolean notifyConsole;
|
|
||||||
|
|
||||||
private Action(Cancellable event, ActionType action, Player player, String command, String loggedCommand, ItemStack item, Block block, boolean denied, boolean deoped, boolean punished, boolean revertedGM, boolean notifyDiscord, boolean notifyTrusted, boolean notifyConsole) {
|
private Action(Cancellable event, ActionType action, Player player, String command, String loggedCommand, ItemStack item, Block block, boolean denied, boolean deoped, boolean punished, boolean revertedGM, boolean notifyDiscord, boolean notifyTrusted, boolean notifyConsole) {
|
||||||
this.event = event;
|
|
||||||
this.action = action;
|
|
||||||
this.player = player;
|
|
||||||
this.command = command;
|
|
||||||
this.loggedCommand = loggedCommand;
|
|
||||||
this.item = item;
|
|
||||||
this.block = block;
|
|
||||||
this.denied = denied;
|
|
||||||
this.deoped = deoped;
|
|
||||||
this.punished = punished;
|
|
||||||
this.revertGM = revertedGM;
|
|
||||||
this.notifyDiscord = notifyDiscord;
|
|
||||||
this.notifyTrusted = notifyTrusted;
|
|
||||||
this.notifyConsole = notifyConsole;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder {
|
public static class Builder {
|
||||||
@@ -140,7 +114,7 @@ public class Action {
|
|||||||
|
|
||||||
if (punished) {
|
if (punished) {
|
||||||
for (String command : punishCommands) {
|
for (String command : punishCommands) {
|
||||||
ServerUtils.sendCommand(command);
|
ServerUtils.sendCommand(command.replaceAll("%player%",player.getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
package io.github.thetrouper.sentinel.data;
|
package io.github.thetrouper.sentinel.server;
|
||||||
|
|
||||||
import io.github.thetrouper.sentinel.Sentinel;
|
import io.github.thetrouper.sentinel.Sentinel;
|
||||||
|
import io.github.thetrouper.sentinel.data.Emojis;
|
||||||
|
import io.github.thetrouper.sentinel.data.FAT;
|
||||||
import io.github.thetrouper.sentinel.discord.DiscordWebhook;
|
import io.github.thetrouper.sentinel.discord.DiscordWebhook;
|
||||||
import io.github.thetrouper.sentinel.server.functions.ProfanityFilter;
|
import io.github.thetrouper.sentinel.server.config.Config;
|
||||||
import io.github.thetrouper.sentinel.server.functions.ReportFalsePositives;
|
import io.github.thetrouper.sentinel.server.functions.ReportFalsePositives;
|
||||||
import io.github.thetrouper.sentinel.server.util.GPTUtils;
|
|
||||||
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
||||||
import io.github.thetrouper.sentinel.server.util.Text;
|
import io.github.thetrouper.sentinel.server.util.Text;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
@@ -13,7 +14,6 @@ import net.md_5.bungee.api.chat.TextComponent;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package io.github.thetrouper.sentinel.server.config;
|
||||||
|
|
||||||
|
import io.github.itzispyder.pdk.utils.misc.JsonSerializable;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class AdvancedConfig implements JsonSerializable<AdvancedConfig> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public File getFile() {
|
||||||
|
return new File("plugins/Sentinel/advanced-config.json");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Map<String, String> leetPatterns = new HashMap<>() {{
|
||||||
|
put("0", "o");
|
||||||
|
put("1", "i");
|
||||||
|
put("3", "e");
|
||||||
|
put("4", "a");
|
||||||
|
put("5", "s");
|
||||||
|
put("6", "g");
|
||||||
|
put("7", "l");
|
||||||
|
put("$", "s");
|
||||||
|
put("!", "i");
|
||||||
|
put("|", "i");
|
||||||
|
put("+", "t");
|
||||||
|
put("#", "h");
|
||||||
|
put("@", "a");
|
||||||
|
put("<", "c");
|
||||||
|
put("V", "u");
|
||||||
|
put("v", "u");
|
||||||
|
}};
|
||||||
|
public static String falsePosRegex = "";
|
||||||
|
public static String swearRegex;
|
||||||
|
public static String strictRegex;
|
||||||
|
public static String urlRegex = "^(https?://)?([a-zA-Z0-9-]+\\.)*[a-zA-Z0-9-]+\\.[a-zA-Z]{2,}(/\\S*)?$\n";
|
||||||
|
}
|
||||||
@@ -2,18 +2,14 @@
|
|||||||
* This file is for tutorial purposes made by ImproperIssues. Distribute if you want :)
|
* This file is for tutorial purposes made by ImproperIssues. Distribute if you want :)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package io.github.thetrouper.sentinel.data;
|
package io.github.thetrouper.sentinel.server.config;
|
||||||
|
|
||||||
import com.google.common.base.Charsets;
|
|
||||||
import io.github.thetrouper.sentinel.Sentinel;
|
import io.github.thetrouper.sentinel.Sentinel;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package io.github.thetrouper.sentinel.server.config;
|
||||||
|
|
||||||
|
import io.github.itzispyder.pdk.utils.misc.JsonSerializable;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class FPConfig implements JsonSerializable<FPConfig> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public File getFile() {
|
||||||
|
return new File("plugins/Sentinel/false-positives.json");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<String> swearWhitelist;
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package io.github.thetrouper.sentinel.server.config;
|
||||||
|
|
||||||
|
import io.github.itzispyder.pdk.utils.misc.JsonSerializable;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
public class Lang implements JsonSerializable<Lang> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public File getFile() {
|
||||||
|
return new File("plugins/Sentinel/lang/" + Config.lang);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package io.github.thetrouper.sentinel.data;
|
package io.github.thetrouper.sentinel.server.config;
|
||||||
|
|
||||||
import io.github.thetrouper.sentinel.Sentinel;
|
import io.github.thetrouper.sentinel.Sentinel;
|
||||||
import io.github.thetrouper.sentinel.server.util.JsonSerializable;
|
import io.github.thetrouper.sentinel.server.util.JsonSerializable;
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
package io.github.thetrouper.sentinel.server.config;
|
||||||
|
|
||||||
|
import io.github.thetrouper.sentinel.server.util.JsonSerializable;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class MainConfig implements JsonSerializable<MainConfig> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public File getFile() {
|
||||||
|
return new File("plugins/Sentinel/main-config.json");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Plugin {
|
||||||
|
public static String prefix = "§d§lSentinel §8» §7";
|
||||||
|
public static String webhook;
|
||||||
|
public static String lang;
|
||||||
|
public static List<String> trustedPlayers;
|
||||||
|
public static boolean blockSpecific;
|
||||||
|
public static boolean preventNBT;
|
||||||
|
public static boolean preventCmdBlockPlace;
|
||||||
|
public static boolean preventCmdBlockUse;
|
||||||
|
public static boolean preventCmdBlockChange;
|
||||||
|
public static boolean preventCmdCartPlace;
|
||||||
|
public static boolean preventCmdCartUse;
|
||||||
|
public static boolean cmdBlockOpCheck;
|
||||||
|
public static List<String> dangerous;
|
||||||
|
public static boolean logDangerous;
|
||||||
|
public static boolean logCmdBlocks;
|
||||||
|
public static boolean logNBT;
|
||||||
|
public static boolean logSpecific;
|
||||||
|
public static List<String> logged;
|
||||||
|
public static boolean deop;
|
||||||
|
public static boolean nbtPunish;
|
||||||
|
public static boolean cmdBlockPunish;
|
||||||
|
public static boolean commandPunish;
|
||||||
|
public static boolean specificPunish;
|
||||||
|
public static List<String> punishCommands;
|
||||||
|
public static boolean reopCommand;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Chat {
|
||||||
|
public static boolean antiUnicode;
|
||||||
|
|
||||||
|
public static class antiSpam {
|
||||||
|
public static boolean antiSpamEnabled;
|
||||||
|
public static int defaultGain;
|
||||||
|
public static int lowGain;
|
||||||
|
public static int mediumGain;
|
||||||
|
public static int highGain;
|
||||||
|
public static int heatDecay;
|
||||||
|
public static int blockHeat;
|
||||||
|
public static int punishHeat;
|
||||||
|
public static boolean clearChat;
|
||||||
|
public static String chatClearCommand;
|
||||||
|
public static String spamPunishCommand;
|
||||||
|
public static boolean logSpam;
|
||||||
|
}
|
||||||
|
public static class antiSwear {
|
||||||
|
public static boolean antiSwearEnabled;
|
||||||
|
public static int lowScore;
|
||||||
|
public static int mediumLowScore;
|
||||||
|
public static int mediumScore;
|
||||||
|
public static int mediumHighScore;
|
||||||
|
public static int highScore;
|
||||||
|
public static int scoreDecay;
|
||||||
|
public static int punishScore;
|
||||||
|
public static boolean strictInstaPunish;
|
||||||
|
public static String swearPunishCommand;
|
||||||
|
public static String strictPunishCommand;
|
||||||
|
public static boolean logSwears;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
package io.github.thetrouper.sentinel.server.config;
|
||||||
|
|
||||||
|
import io.github.itzispyder.pdk.utils.FileValidationUtils;
|
||||||
|
import io.github.itzispyder.pdk.utils.misc.JsonSerializable;
|
||||||
|
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
|
||||||
|
public class NBTConfig implements JsonSerializable<NBTConfig> {
|
||||||
|
@Override
|
||||||
|
public File getFile() {
|
||||||
|
return new File("plugins/Sentinel/NBTConfig.json");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean allowName;
|
||||||
|
public static boolean allowLore;
|
||||||
|
public static boolean allowAttributes;
|
||||||
|
public static int globalMaxEnchant;
|
||||||
|
public static int maxMending;
|
||||||
|
public static int maxUnbreaking;
|
||||||
|
public static int maxVanishing;
|
||||||
|
public static int maxAquaAffinity;
|
||||||
|
public static int maxBlastProtection;
|
||||||
|
public static int maxCurseOfBinding;
|
||||||
|
public static int maxDepthStrider;
|
||||||
|
public static int maxFeatherFalling;
|
||||||
|
public static int maxFireProtection;
|
||||||
|
public static int maxFrostWalker;
|
||||||
|
public static int maxProjectileProtection;
|
||||||
|
public static int maxProtection;
|
||||||
|
public static int maxRespiration;
|
||||||
|
public static int maxSoulSpeed;
|
||||||
|
public static int maxThorns;
|
||||||
|
public static int maxSwiftSneak;
|
||||||
|
public static int maxBaneOfArthropods;
|
||||||
|
public static int maxEfficiency;
|
||||||
|
public static int maxFireAspect;
|
||||||
|
public static int maxLooting;
|
||||||
|
public static int maxImpaling;
|
||||||
|
public static int maxKnockback;
|
||||||
|
public static int maxSharpness;
|
||||||
|
public static int maxSmite;
|
||||||
|
public static int maxSweepingEdge;
|
||||||
|
public static int maxChanneling;
|
||||||
|
public static int maxFlame;
|
||||||
|
public static int maxInfinity;
|
||||||
|
public static int maxLoyalty;
|
||||||
|
public static int maxRiptide;
|
||||||
|
public static int maxMultishot;
|
||||||
|
public static int maxPiercing;
|
||||||
|
public static int maxPower;
|
||||||
|
public static int maxPunch;
|
||||||
|
public static int maxQuickCharge;
|
||||||
|
public static int maxFortune;
|
||||||
|
public static int maxLuckOfTheSea;
|
||||||
|
public static int maxLure;
|
||||||
|
public static int maxSilkTouch;
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package io.github.thetrouper.sentinel.server.config;
|
||||||
|
|
||||||
|
import io.github.itzispyder.pdk.utils.misc.JsonSerializable;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class StrictConfig implements JsonSerializable<StrictConfig> {
|
||||||
|
@Override
|
||||||
|
public File getFile() {
|
||||||
|
return new File("plugins/Sentinel/strict.json");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<String> strict;
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package io.github.thetrouper.sentinel.server.config;
|
||||||
|
|
||||||
|
import io.github.itzispyder.pdk.utils.misc.JsonSerializable;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class SwearsConfig implements JsonSerializable<SwearsConfig> {
|
||||||
|
@Override
|
||||||
|
public File getFile() {
|
||||||
|
return new File("plugins/Sentinel/swears.json");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<String> swears;
|
||||||
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package io.github.thetrouper.sentinel.server.functions;
|
package io.github.thetrouper.sentinel.server.functions;
|
||||||
|
|
||||||
import io.github.thetrouper.sentinel.data.Config;
|
|
||||||
import io.github.thetrouper.sentinel.data.FAT;
|
import io.github.thetrouper.sentinel.data.FAT;
|
||||||
import io.github.thetrouper.sentinel.data.FilterAction;
|
import io.github.thetrouper.sentinel.server.FilterAction;
|
||||||
|
import io.github.thetrouper.sentinel.server.config.Config;
|
||||||
import io.github.thetrouper.sentinel.server.util.GPTUtils;
|
import io.github.thetrouper.sentinel.server.util.GPTUtils;
|
||||||
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
||||||
import io.github.thetrouper.sentinel.server.util.Text;
|
import io.github.thetrouper.sentinel.server.util.Text;
|
||||||
@@ -29,6 +29,7 @@ public class AntiSpam {
|
|||||||
lastMessageMap.put(p,"/* Placeholder Message from Sentinel */");
|
lastMessageMap.put(p,"/* Placeholder Message from Sentinel */");
|
||||||
ServerUtils.sendDebugMessage("AntiSpam: " + p.getName() + " did not have a previous message, setting to placeholder!");
|
ServerUtils.sendDebugMessage("AntiSpam: " + p.getName() + " did not have a previous message, setting to placeholder!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!heatMap.containsKey(p)) {
|
if (!heatMap.containsKey(p)) {
|
||||||
heatMap.put(p,0);
|
heatMap.put(p,0);
|
||||||
ServerUtils.sendDebugMessage("AntiSpam: " + p.getName() + " did not have a heat, setting it to 0!");
|
ServerUtils.sendDebugMessage("AntiSpam: " + p.getName() + " did not have a heat, setting it to 0!");
|
||||||
|
|||||||
@@ -1,22 +1,22 @@
|
|||||||
package io.github.thetrouper.sentinel.server.functions;
|
package io.github.thetrouper.sentinel.server.functions;
|
||||||
|
|
||||||
|
import io.github.itzispyder.pdk.utils.ServerUtils;
|
||||||
import io.github.thetrouper.sentinel.Sentinel;
|
import io.github.thetrouper.sentinel.Sentinel;
|
||||||
import io.github.thetrouper.sentinel.commands.MessageCommand;
|
import io.github.thetrouper.sentinel.cmds.SocialSpyCommand;
|
||||||
import io.github.thetrouper.sentinel.commands.SocialSpyCommand;
|
import io.github.thetrouper.sentinel.server.config.Config;
|
||||||
import io.github.thetrouper.sentinel.data.Config;
|
|
||||||
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
|
||||||
import net.md_5.bungee.api.chat.HoverEvent;
|
import net.md_5.bungee.api.chat.HoverEvent;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import net.md_5.bungee.api.chat.hover.content.Text;
|
import net.md_5.bungee.api.chat.hover.content.Text;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class Message {
|
public class Message {
|
||||||
private static final Map<UUID,UUID> replyMap = MessageCommand.replyMap;
|
public static final Map<UUID,UUID> replyMap = new HashMap<>();
|
||||||
public static void messagePlayer(Player sender, Player receiver, String message) {
|
public static void messagePlayer(Player sender, Player receiver, String message) {
|
||||||
HashSet<Player> receivers = new HashSet<>();
|
HashSet<Player> receivers = new HashSet<>();
|
||||||
receivers.add(receiver);
|
receivers.add(receiver);
|
||||||
@@ -26,9 +26,7 @@ public class Message {
|
|||||||
if (!Sentinel.isTrusted(sender) || !sender.hasPermission("sentinel.chat.antiswear.bypass")) if (Config.antiSwearEnabled) ProfanityFilter.handleProfanityFilter(checkEvent);
|
if (!Sentinel.isTrusted(sender) || !sender.hasPermission("sentinel.chat.antiswear.bypass")) if (Config.antiSwearEnabled) ProfanityFilter.handleProfanityFilter(checkEvent);
|
||||||
if (!Sentinel.isTrusted(sender) || !sender.hasPermission("sentinel.chat.antispam.bypass")) if (Config.antiSpamEnabled) AntiSpam.handleAntiSpam(checkEvent);
|
if (!Sentinel.isTrusted(sender) || !sender.hasPermission("sentinel.chat.antispam.bypass")) if (Config.antiSpamEnabled) AntiSpam.handleAntiSpam(checkEvent);
|
||||||
if (!Sentinel.isTrusted(sender) || !sender.hasPermission("sentinel.chat.antiunicode.bypass")) if (Config.antiUnicode) AntiUnicode.handleAntiUnicode(checkEvent);
|
if (!Sentinel.isTrusted(sender) || !sender.hasPermission("sentinel.chat.antiunicode.bypass")) if (Config.antiUnicode) AntiUnicode.handleAntiUnicode(checkEvent);
|
||||||
if (checkEvent.isCancelled()) {
|
if (checkEvent.isCancelled()) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
sender.sendMessage(Sentinel.dict.get("message-sent").formatted(receiver.getName(),message));
|
sender.sendMessage(Sentinel.dict.get("message-sent").formatted(receiver.getName(),message));
|
||||||
receiver.sendMessage(Sentinel.dict.get("message-received").formatted(sender.getName(),message));
|
receiver.sendMessage(Sentinel.dict.get("message-received").formatted(sender.getName(),message));
|
||||||
|
|||||||
@@ -1,18 +1,17 @@
|
|||||||
package io.github.thetrouper.sentinel.server.functions;
|
package io.github.thetrouper.sentinel.server.functions;
|
||||||
import io.github.thetrouper.sentinel.data.Config;
|
|
||||||
import io.github.thetrouper.sentinel.data.FilterAction;
|
|
||||||
import io.github.thetrouper.sentinel.data.FAT;
|
import io.github.thetrouper.sentinel.data.FAT;
|
||||||
|
import io.github.thetrouper.sentinel.server.FilterAction;
|
||||||
|
import io.github.thetrouper.sentinel.server.config.Config;
|
||||||
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
||||||
import io.github.thetrouper.sentinel.server.util.Text;
|
import io.github.thetrouper.sentinel.server.util.Text;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static io.github.thetrouper.sentinel.server.util.Text.SECTION_SYMBOL;
|
|
||||||
|
|
||||||
public class ProfanityFilter {
|
public class ProfanityFilter {
|
||||||
public static Map<Player, Integer> scoreMap;
|
public static Map<Player, Integer> scoreMap;
|
||||||
private static final List<String> swearBlacklist = Config.swearBlacklist;
|
private static final List<String> swearBlacklist = Config.swearBlacklist;
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
package io.github.thetrouper.sentinel.server.functions;
|
package io.github.thetrouper.sentinel.server.functions;
|
||||||
|
|
||||||
import io.github.thetrouper.sentinel.Sentinel;
|
import io.github.thetrouper.sentinel.Sentinel;
|
||||||
import io.github.thetrouper.sentinel.data.Config;
|
|
||||||
import io.github.thetrouper.sentinel.data.Emojis;
|
import io.github.thetrouper.sentinel.data.Emojis;
|
||||||
import io.github.thetrouper.sentinel.discord.DiscordWebhook;
|
import io.github.thetrouper.sentinel.discord.DiscordWebhook;
|
||||||
|
import io.github.thetrouper.sentinel.server.config.Config;
|
||||||
import io.github.thetrouper.sentinel.server.util.Randomizer;
|
import io.github.thetrouper.sentinel.server.util.Randomizer;
|
||||||
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
||||||
import io.github.thetrouper.sentinel.server.util.Text;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
|
|||||||
@@ -1,90 +0,0 @@
|
|||||||
/**
|
|
||||||
* This file is for tutorial purposes made by ImproperIssues. Distribute if you want :)
|
|
||||||
*/
|
|
||||||
|
|
||||||
package io.github.thetrouper.sentinel.server.util;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents Argument builder
|
|
||||||
*/
|
|
||||||
public class ArgBuilder {
|
|
||||||
|
|
||||||
private String result;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs an argument builder.
|
|
||||||
*/
|
|
||||||
public ArgBuilder() {
|
|
||||||
this.result = " ";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs an argument builder with a string.
|
|
||||||
* @param begin the beginner string
|
|
||||||
*/
|
|
||||||
public ArgBuilder(String begin) {
|
|
||||||
this.result = begin + " ";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Appends a string
|
|
||||||
* @param string string
|
|
||||||
* @return this class
|
|
||||||
*/
|
|
||||||
public ArgBuilder append(String string) {
|
|
||||||
this.result += string + " ";
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Appends a string array
|
|
||||||
* @param args string array
|
|
||||||
* @return this class
|
|
||||||
*/
|
|
||||||
public ArgBuilder append(String[] args) {
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
for (String arg : args) builder.append(arg).append(" ");
|
|
||||||
this.result += builder.toString();
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Appends a string list
|
|
||||||
* @param args string list
|
|
||||||
* @return this class
|
|
||||||
*/
|
|
||||||
public ArgBuilder append(List<String> args) {
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
for (String arg : args) builder.append(arg).append(" ");
|
|
||||||
this.result += builder.toString();
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Appends a string set
|
|
||||||
* @param args string set
|
|
||||||
* @return this class
|
|
||||||
*/
|
|
||||||
public ArgBuilder append(Set<String> args) {
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
for (String arg : args) builder.append(arg).append(" ");
|
|
||||||
this.result += builder.toString();
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns this class as a string
|
|
||||||
* @return this class as a string
|
|
||||||
*/
|
|
||||||
public String build() {
|
|
||||||
return this.toString().trim();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
package io.github.thetrouper.sentinel.server.util;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
public final class ArrayUtils {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Transforms an array to another one
|
|
||||||
* @param e iterable list
|
|
||||||
* @param a action
|
|
||||||
* @return new transformed list
|
|
||||||
* @param <I> input
|
|
||||||
* @param <O> output
|
|
||||||
*/
|
|
||||||
public static <I,O> List<O> toNewList(Iterable<I> e, Function<I,O> a) {
|
|
||||||
List<O> list = new ArrayList<>();
|
|
||||||
e.forEach(i -> list.add(a.apply(i)));
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> String list2string(List<T> list) {
|
|
||||||
return ("\u00a77[\u00a7e" + String.join("\u00a77, \u00a7e", ArrayUtils.toNewList(list, Object::toString)) + "\u00a77]");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> List<T> bind(Iterable<T> tList, T... ts) {
|
|
||||||
List<T> list = Arrays.asList(ts);
|
|
||||||
tList.forEach(list::add);
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Constants {
|
|
||||||
public static final List<String> MATERIAL_NAMES = toNewList(Arrays.stream(Material.values()).toList(),m -> m.name().toLowerCase());
|
|
||||||
public static final List<String> ENTITY_NAMES = toNewList(Arrays.stream(EntityType.values()).toList(),e -> e.name().toLowerCase());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
package io.github.thetrouper.sentinel.server.util;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class Cooldown<T> {
|
|
||||||
|
|
||||||
private final Map<T,Long> timer;
|
|
||||||
|
|
||||||
public Cooldown() {
|
|
||||||
this.timer = new HashMap<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
private <O> O getOrDefault(O value, O def) {
|
|
||||||
return value != null ? value : def;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getCooldown(T obj) {
|
|
||||||
return Math.max(getOrDefault(timer.get(obj), 0L) - System.currentTimeMillis(), 0L);
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getCooldownSec(T obj) {
|
|
||||||
final long cooldown = this.getCooldown(obj);
|
|
||||||
return MathUtils.round(cooldown / 1000.0, 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isOnCooldown(T obj) {
|
|
||||||
return getCooldown(obj) > 0L;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCooldown(T obj, long millis) {
|
|
||||||
timer.put(obj, System.currentTimeMillis() + millis);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addCooldown(T obj, long millis) {
|
|
||||||
setCooldown(obj, getCooldown(obj) + millis);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,33 +1,11 @@
|
|||||||
package io.github.thetrouper.sentinel.server.util;
|
package io.github.thetrouper.sentinel.server.util;
|
||||||
|
|
||||||
import com.google.gson.reflect.TypeToken;
|
|
||||||
import io.github.thetrouper.sentinel.Sentinel;
|
import io.github.thetrouper.sentinel.Sentinel;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.BufferedWriter;
|
||||||
import java.time.*;
|
import java.io.File;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Random;
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.UUID;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
public class FileUtils {
|
public class FileUtils {
|
||||||
public static boolean folderExists(String folderName) {
|
public static boolean folderExists(String folderName) {
|
||||||
File folder = new File(Sentinel.getInstance().getDataFolder(), folderName);
|
File folder = new File(Sentinel.getInstance().getDataFolder(), folderName);
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package io.github.thetrouper.sentinel.server.util;
|
package io.github.thetrouper.sentinel.server.util;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Randomize items from a list
|
* Randomize items from a list
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
package io.github.thetrouper.sentinel.server.util;
|
package io.github.thetrouper.sentinel.server.util;
|
||||||
|
|
||||||
import io.github.thetrouper.sentinel.Sentinel;
|
import io.github.thetrouper.sentinel.Sentinel;
|
||||||
import io.github.thetrouper.sentinel.commands.SentinelCommand;
|
import io.github.thetrouper.sentinel.cmds.SentinelCommand;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.metadata.MetadataValue;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -27,7 +28,7 @@ public class ServerUtils {
|
|||||||
},1);
|
},1);
|
||||||
}
|
}
|
||||||
public static void sendDebugMessage(String message) {
|
public static void sendDebugMessage(String message) {
|
||||||
if (SentinelCommand.debugmode) {
|
if (SentinelCommand.debugMode) {
|
||||||
String log = "[Sentinel] [DEBUG]: " + message;
|
String log = "[Sentinel] [DEBUG]: " + message;
|
||||||
Sentinel.log.info(log);
|
Sentinel.log.info(log);
|
||||||
for (Player trustedPlayer : Bukkit.getOnlinePlayers()) {
|
for (Player trustedPlayer : Bukkit.getOnlinePlayers()) {
|
||||||
@@ -90,4 +91,15 @@ public class ServerUtils {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isVanished(Player player) {
|
||||||
|
for (MetadataValue meta : player.getMetadata("vanished")) {
|
||||||
|
if (meta.asBoolean()) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String[] unVanishedPlayers() {
|
||||||
|
return io.github.itzispyder.pdk.utils.ServerUtils.players(ServerUtils::isVanished).stream().map(Player::getName).toArray(String[]::new);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package io.github.thetrouper.sentinel.server.util;
|
|||||||
|
|
||||||
|
|
||||||
import io.github.thetrouper.sentinel.Sentinel;
|
import io.github.thetrouper.sentinel.Sentinel;
|
||||||
import io.github.thetrouper.sentinel.data.Config;
|
import io.github.thetrouper.sentinel.server.config.Config;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.regex.PatternSyntaxException;
|
import java.util.regex.PatternSyntaxException;
|
||||||
|
|||||||
Reference in New Issue
Block a user