24 Commits

Author SHA1 Message Date
43e51fee59 3.0.4
Bugfix:
- In Permission Whitelist, the customCommands function did not work as expected.
2022-11-17 21:07:15 +01:00
466314f206 Merge branch 'main' of https://git.t2code.net/JaTiTV/OPSecurity 2022-11-15 02:33:22 +01:00
47a9080dba Update pom.xml 2022-11-15 02:31:56 +01:00
JaTiTV
af608fad02 Merge pull request 'dev-3.0.3' (#9) from dev-3.0.3 into main
Reviewed-on: #9
2022-11-15 01:27:43 +00:00
632c23b1ff update to T2CodeLib 13.4 (sn 1) 2022-11-15 00:35:45 +01:00
6fbd56ea63 3.0.3
New Update Checker
2022-11-14 20:15:30 +01:00
31a958ce7f Update pom.xml 2022-11-14 19:50:48 +01:00
JaTiTV
cfd34f6ce6 „README.md“ ändern 2022-11-14 15:55:21 +00:00
JaTiTV
050624f517 „README.md“ ändern 2022-11-14 15:12:16 +00:00
JaTiTV
2bae6f7118 „README.md“ ändern 2022-11-14 15:11:38 +00:00
JaTiTV
8e851dfc15 „README.md“ ändern 2022-11-14 15:10:24 +00:00
JaTiTV
94f0a688c9 „README.md“ ändern 2022-11-14 15:09:37 +00:00
JaTiTV
3ce922c602 „README.md“ ändern 2022-11-14 15:06:00 +00:00
JaTiTV
1ea97b5874 „README.md“ hinzufügen 2022-11-14 15:05:13 +00:00
dab5a4f557 Update pom.xml 2022-11-14 14:19:07 +01:00
5f2d97b5d3 Merge branch '3.0.0-Recode' 2022-11-13 16:02:24 +01:00
672335de98 3.0.2
https://www.spigotmc.org/resources/t2c-opsecurity-permission-security-1-8-x-1-19-x.90739/update?update=478946
2022-11-13 15:54:47 +01:00
224f53d027 3.0.1
https://www.spigotmc.org/resources/t2c-opsecurity-permission-security-1-8-x-1-19-x.90739/update?update=478627
2022-11-09 23:20:25 +01:00
930e48484c 3.0.0
https://www.spigotmc.org/resources/t2c-opsecurity-permission-security-1-8-x-1-19-x.90739/update?update=478193
2022-11-05 12:41:56 +01:00
JaTiTV
fc76ba90be Merge pull request '2.4.3' (#5) from customCommands-fix into main
Reviewed-on: JaTiTV/OPSecurity#5
2022-11-02 18:01:26 +00:00
ddd3a8982f Update Check.java 2022-11-02 18:30:02 +01:00
d66f6d0f59 small code changes 2022-10-25 17:12:54 +02:00
bbc8f2377b 2.4.3
T2CodeLib update to API Version 13.0
Small code changes
2022-10-25 17:06:36 +02:00
485b50de7a 2.4.3-DEV-1 2022-09-05 20:25:23 +02:00
17 changed files with 247 additions and 109 deletions

View File

@@ -1,7 +1,8 @@
// This claas was created by JaTiTV
package de.jatitv.opsecurity.util;
package de.jatitv.opsecurity.system;
import de.jatitv.opsecurity.Util;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
@@ -27,6 +28,11 @@ import java.util.zip.GZIPOutputStream;
public class Metrics {
public static void Bstats() {
int pluginId = Util.getBstatsID(); // <-- Replace with the id of your plugin!
Metrics metrics = new Metrics(Main.getPlugin(), pluginId);
}
private final Plugin plugin;
private final MetricsBase metricsBase;

View File

@@ -6,7 +6,8 @@
<groupId>net.t2code</groupId>
<artifactId>T2C-OPSecurity</artifactId>
<version>3.0.0-SNAPSHOT-#1</version>
<version>3.0.4</version>
<packaging>jar</packaging>
<name>T2C-OPSecurity</name>
@@ -17,6 +18,7 @@
</properties>
<build>
<finalName>${project.artifactId}_${project.version}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -81,7 +83,8 @@
<dependency>
<groupId>net.t2code</groupId>
<artifactId>T2CodeLib</artifactId>
<version>13.0</version>
<version>13.4</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
@@ -90,11 +93,5 @@
<version>1.18.24</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.22</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@@ -8,7 +8,7 @@ public class Util {
private static String infoText = "";
@Getter
private static String requiredT2CodeLibVersion = "13.1";
private static String requiredT2CodeLibVersion = "13.4";
@Getter
private static String prefix = "§8[§4T2C§8-§2OP§4Security§8]";
@@ -16,6 +16,9 @@ public class Util {
@Getter
private static Integer spigotID = 90739;
@Getter
private static String git = "JaTiTV/T2C-OPSecurity";
@Getter
private static Integer bstatsID = 10858;

View File

@@ -20,27 +20,45 @@ public class OpCheck {
if (!OPWhitelist.enable.valueBoolean) return false;
if (!player.isOp()) return false;
if (opWhitelist(player)) return false;
if (join) T2Csend.console(Language.opWhitelistNotifyOnJoin.value.replace("[player]", player.getName()));
if (join) T2Csend.console(Language.opWhitelistNotifyOnJoin.value.replace("[player]", player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
Bukkit.getScheduler().runTask(Main.getPlugin(), new Runnable() {
@Override
public void run() {
execute(player, join);
}
});
return true;
}
private static void execute(Player player, Boolean join) {
if (Config.notifyJoinWarning.valueBoolean && join) {
if (Config.notifyBungee.valueBoolean) {
BungeeSenderReceiver.sendToBungee(Language.opWhitelistNotifyOnJoin.value.replace("[player]", player.getName()));
} else Events.notifyPlayer(Language.opWhitelistNotifyOnJoin.value.replace("[player]", player.getName()));
BungeeSenderReceiver.sendToBungee(Language.opWhitelistNotifyOnJoin.value.replace("[player]", player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
} else Events.notifyPlayer(Language.opWhitelistNotifyOnJoin.value.replace("[player]", player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
}
if (OPWhitelist.noOpPlayerSetGameModeEnable.valueBoolean) {
player.setGameMode(OPWhitelist.noOpPlayerSetGameModeValue.valueGameMode);
}
if (OPWhitelist.noOpPlayerDeopEnable.valueBoolean) {
player.setOp(false);
if (OPWhitelist.noOpPlayerKickEnable.valueBoolean) {
if (!OPWhitelist.customCommandsEnable.valueBoolean) T2Ccmd.console(Config.kickCommand.path.replace("[player]", player.getName()).replace("[reason]",
if (!OPWhitelist.customCommandsEnable.valueBoolean) {
if (Config.kickCustomCommand.valueBoolean) {
T2Ccmd.console(Config.kickCommand.valueString.replace("[player]", player.getName()).replace("[reason]",
OPWhitelist.noOpPlayerKickEnable.valueBoolean && OPWhitelist.noOpPlayerDeopEnable.valueBoolean && OPWhitelist.noOpPlayerDeopPlayerSendMessage.valueBoolean
? Language.opWhitelistKick.value + "<br> <br>" + Language.opWhitelistDeop.value : Language.opWhitelistKick.value));
T2Csend.console(Language.opWhitelistNotifyDeop.value.replace("[player]", player.getName()) + "<br>"
+ Language.opWhitelistNotifyKick.value.replace("[player]", player.getName()));
} else player.kickPlayer(OPWhitelist.noOpPlayerDeopEnable.valueBoolean && OPWhitelist.noOpPlayerDeopPlayerSendMessage.valueBoolean
? Language.opWhitelistKick.value + "\n \n" + Language.opWhitelistDeop.value : Language.opWhitelistKick.value);
}
T2Csend.console(Language.opWhitelistNotifyDeop.value.replace("[player]", player.getName().replace("[uuid]", String.valueOf(player.getUniqueId()))) + "<br>"
+ Language.opWhitelistNotifyKick.value.replace("[player]", player.getName().replace("[uuid]", String.valueOf(player.getUniqueId()))).replace("[uuid]", String.valueOf(player.getUniqueId())));
Events.notifyPlayer(Language.opWhitelistNotifyDeop.value.replace("[player]", player.getName()) + "<br>"
+ Language.opWhitelistNotifyKick.value.replace("[player]", player.getName()));
+ Language.opWhitelistNotifyKick.value.replace("[player]", player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
} else {
T2Csend.console(Language.opWhitelistNotifyDeop.value.replace("[player]", player.getName()));
Events.notifyPlayer(Language.opWhitelistNotifyDeop.value.replace("[player]", player.getName()));
T2Csend.console(Language.opWhitelistNotifyDeop.value.replace("[player]", player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
Events.notifyPlayer(Language.opWhitelistNotifyDeop.value.replace("[player]", player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
if (OPWhitelist.noOpPlayerDeopPlayerSendMessage.valueBoolean) {
Bukkit.getScheduler().runTaskLater(Main.getPlugin(), new Runnable() {
@@ -53,25 +71,27 @@ public class OpCheck {
}
}
if (OPWhitelist.noOpPlayerKickEnable.valueBoolean) {
if (!OPWhitelist.customCommandsEnable.valueBoolean)
T2Ccmd.console(Config.kickCommand.path.replace("[player]", player.getName()).replace("[reason]", Language.opWhitelistKick.value));
T2Csend.console(Language.opWhitelistNotifyKick.value.replace("[player]", player.getName()));
Events.notifyPlayer(Language.opWhitelistNotifyKick.value.replace("[player]", player.getName()));
if (!OPWhitelist.noOpPlayerDeopEnable.valueBoolean) {
if (!OPWhitelist.customCommandsEnable.valueBoolean) {
if (Config.kickCustomCommand.valueBoolean) {
T2Ccmd.console(Config.kickCommand.valueString.replace("[player]", player.getName()).replace("[reason]", Language.opWhitelistKick.value));
} else player.kickPlayer(Language.opWhitelistKick.value);
}
T2Csend.console(Language.opWhitelistNotifyKick.value.replace("[player]", player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
Events.notifyPlayer(Language.opWhitelistNotifyKick.value.replace("[player]", player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
}
}
if (OPWhitelist.customCommandsEnable.valueBoolean) {
for (String cmd : OPWhitelist.customCommandsCommands.valueStringList) {
T2Ccmd.console(cmd.replace("[player]", player.getName()));
}
}
return true;
}
private static Boolean opWhitelist(Player player) {
public static Boolean opWhitelist(Player player) {
for (Map.Entry<String, PlayerObject> playerObject : PlayerCash.getOpHashMap().entrySet()) {
if (playerObject.getValue().playerName.equals(player.getName())) return true;
if (playerObject.getValue().uuid.equals(player.getUniqueId().toString())) return true;
if (playerObject.getValue().playerName.equals(player.getName()) && playerObject.getValue().uuid.equals(player.getUniqueId().toString())) return true;
}
T2Csend.console(Language.exactKickReason.value.replace("[reason]", "Player UUID: " + player.getUniqueId().toString() + " not whitelisted (opWhitelist)"));
return false;
}
}

View File

@@ -7,8 +7,10 @@ import net.t2code.opsecurity.events.Events;
import net.t2code.opsecurity.objects.PlayerCash;
import net.t2code.opsecurity.objects.PlayerObject;
import net.t2code.opsecurity.system.BungeeSenderReceiver;
import net.t2code.opsecurity.system.Main;
import net.t2code.t2codelib.SPIGOT.api.commands.T2Ccmd;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import java.util.Map;
@@ -19,35 +21,43 @@ public class PermissionCheck {
for (String perm : PermissionWhitelist.permissions.valueStringList) {
if (!player.hasPermission(perm)) continue;
if (permWhitelist(player)) continue;
if (join) T2Csend.console(Language.permissionWhitelistNotifyKick.value.replace("[player]", player.getName()));
if (Config.notifyJoinWarning.valueBoolean && join) {
if (Config.notifyBungee.valueBoolean) {
BungeeSenderReceiver.sendToBungee(Language.permissionWhitelistNotifyOnJoin.value.replace("[player]", player.getName()));
} else Events.notifyPlayer(Language.permissionWhitelistNotifyOnJoin.value.replace("[player]", player.getName()));
}
if (PermissionWhitelist.playerWithPermissionKick.valueBoolean) {
T2Ccmd.console(Config.kickCommand.valueString.replace("[player]", player.getName()).replace("[reason]", Language.permissionWhitelistKick.value));
T2Csend.console(Language.permissionWhitelistNotifyKick.value.replace("[player]",
player.getName()).replace("[perm]", perm));
}
if (PermissionWhitelist.customCommandsCommands.valueBoolean) {
for (String cmd : PermissionWhitelist.customCommandsCommands.valueStringList) {
T2Ccmd.console(cmd.replace("[player]", player.getName()).replace("[perm]", perm));
}
Bukkit.getScheduler().runTask(Main.getPlugin(), new Runnable() {
@Override
public void run() {
execute(player, join, perm);
}
});
return true;
}
return false;
}
private static void execute(Player player, Boolean join, String perm) {
if (join) T2Csend.console(Language.permissionWhitelistNotifyKick.value.replace("[player]", player.getName()).replace("[uuid]",String.valueOf(player.getUniqueId())));
if (Config.notifyJoinWarning.valueBoolean && join) {
if (Config.notifyBungee.valueBoolean) {
BungeeSenderReceiver.sendToBungee(Language.permissionWhitelistNotifyOnJoin.value.replace("[player]", player.getName()).replace("[uuid]",String.valueOf(player.getUniqueId())));
} else Events.notifyPlayer(Language.permissionWhitelistNotifyOnJoin.value.replace("[player]", player.getName()).replace("[uuid]",String.valueOf(player.getUniqueId())));
}
if (PermissionWhitelist.playerWithPermissionKick.valueBoolean) {
if (Config.kickCustomCommand.valueBoolean) {
T2Ccmd.console(Config.kickCommand.valueString.replace("[player]", player.getName()).replace("[reason]", Language.permissionWhitelistKick.value));
} else player.kickPlayer(Language.permissionWhitelistKick.value);
T2Csend.console(Language.permissionWhitelistNotifyKick.value.replace("[player]",
player.getName()).replace("[perm]", perm).replace("[uuid]",String.valueOf(player.getUniqueId())));
}
if (PermissionWhitelist.customCommandsEnable.valueBoolean) {
for (String cmd : PermissionWhitelist.customCommandsCommands.valueStringList) {
T2Ccmd.console(cmd.replace("[player]", player.getName()).replace("[perm]", perm));
}
}
}
private static Boolean permWhitelist(Player player) {
for (Map.Entry<String, PlayerObject> playerObject : PlayerCash.getPermissionHashMap().entrySet()) {
if (playerObject.getValue().playerName.equals(player.getName())) return true;
if (playerObject.getValue().uuid.equals(player.getUniqueId().toString())) return true;
if (playerObject.getValue().playerName.equals(player.getName()) && playerObject.getValue().uuid.equals(player.getUniqueId().toString())) return true;
}
T2Csend.console(Language.exactKickReason.value.replace("[reason]", "Player UUID: " + player.getUniqueId().toString() + " not whitelisted (permissionWhitelist)"));
return false;
}
}

View File

@@ -1,6 +1,5 @@
// This claas was created by JaTiTV
package net.t2code.opsecurity.check;
import net.t2code.opsecurity.config.config.Config;

View File

@@ -4,7 +4,8 @@ package net.t2code.opsecurity.command;
import net.t2code.opsecurity.Util;
import net.t2code.opsecurity.config.config.Config;
import net.t2code.opsecurity.config.opWhitelist.OPWhitelist;
import net.t2code.opsecurity.objects.PlayerCash;
import net.t2code.opsecurity.objects.PlayerObject;
import net.t2code.opsecurity.system.Main;
import net.t2code.opsecurity.system.Permissions;
import net.t2code.t2codelib.SPIGOT.api.commands.T2Ctab;
@@ -17,6 +18,7 @@ import org.bukkit.command.TabCompleter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class CmdExecuter implements CommandExecutor, TabCompleter {
@@ -42,11 +44,6 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
case "version":
case "ver":
Commands.info(sender);
break;
case "test":
T2Csend.debugmsg(Main.getPlugin(), OPWhitelist.enable.valueBoolean.toString());
T2Csend.debugmsg(Main.getPlugin(), Config.onlyOPcanUseThePlugin.valueBoolean.toString());
break;
case "help":
default:

View File

@@ -1,9 +1,11 @@
package net.t2code.opsecurity.command;
import net.t2code.opsecurity.Util;
import net.t2code.opsecurity.check.OpCheck;
import net.t2code.opsecurity.config.FileSelect;
import net.t2code.opsecurity.config.config.Config;
import net.t2code.opsecurity.config.language.Language;
import net.t2code.opsecurity.enums.OpCommandRequest;
import net.t2code.opsecurity.objects.PlayerCash;
import net.t2code.opsecurity.system.Main;
import net.t2code.opsecurity.system.Permissions;
@@ -52,13 +54,11 @@ public class Commands {
}
if (sender instanceof Player) {
Player player = (Player) sender;
if (!PlayerCash.getOpHashMap().containsKey(player.getName().toLowerCase())) {
sender.sendMessage(Util.getPrefix() + " §4You are not on the Whitelist!");
if (Config.onlyOPcanUseThePlugin.valueBoolean) {
if (!OpCheck.opWhitelist(player)) {
sender.sendMessage(Util.getPrefix() + " §4You are not on the Whitelist!"); // todo
return;
}
if (!PlayerCash.getOpHashMap().get(player.getName().toLowerCase()).uuid.equals(player.getUniqueId().toString().replace("-", ""))) {
sender.sendMessage(Util.getPrefix() + " §4You are not on the Whitelist!");
return;
}
T2Csend.player(player, Language.reloadStart.value);
}
@@ -76,7 +76,6 @@ public class Commands {
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + "§8-------------------------------");
}
public static void info(CommandSender sender) {
if (!sender.hasPermission(Permissions.info)) {
sender.sendMessage(Util.getPrefix() + "§cYou do not have permission for OPSecurity! §7<" + Permissions.info + ">");

View File

@@ -11,6 +11,7 @@ import net.t2code.opsecurity.system.Main;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.system.config.languages.SelectLibMsg;
import org.bukkit.GameMode;
import org.bukkit.Sound;
import org.bukkit.configuration.file.YamlConfiguration;
@@ -23,12 +24,12 @@ public class FileSelect {
File config = new File(Main.getPath(), "config.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
for (Config value : Config.values()) {
switch (value.cEnum) {
switch (value.configParam) {
case STRING:
if (!yamlConfiguration.contains(value.path)) {
yamlConfiguration.set(value.path, value.valueString);
}
value.valueString = T2Creplace.replace(Util.getPrefix(), yamlConfiguration.getString(value.path));
value.valueString = T2Creplace.replace(Util.getPrefix(), Objects.requireNonNull(yamlConfiguration.getString(value.path)));
break;
case SOUND:
if (!yamlConfiguration.contains(value.path)) {
@@ -91,7 +92,6 @@ public class FileSelect {
}
}
String selectMSG;
File config = new File(Main.getPath(), "languages/" + Config.language.valueString + ".yml");
T2Csend.debug(Main.getPlugin(), config.getAbsolutePath());
@@ -115,6 +115,7 @@ public class FileSelect {
}
public static void selectOpWhitelist() {
PlayerCash.getOpHashMap().clear();
File config = new File(Main.getPath(), "opWhitelist.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
for (OPWhitelist value : OPWhitelist.values()) {
@@ -139,10 +140,22 @@ public class FileSelect {
yamlConfiguration.set(value.pathPlayerUuid.replace("KEY", "player2"), value.valuePlayerUuid);
}
for (String key : yamlConfiguration.getConfigurationSection(value.pathPlayerListPath).getKeys(false)) {
String name = yamlConfiguration.getString(value.pathPlayerName.replace("KEY", key));
PlayerObject playerObject = new PlayerObject(
yamlConfiguration.getString(value.pathPlayerName.replace("KEY", key)),
yamlConfiguration.getString(value.pathPlayerUuid.replace("KEY", key).replace("-", "")));
PlayerCash.getOpHashMap().put(key, playerObject);
name,
yamlConfiguration.getString(value.pathPlayerUuid.replace("KEY", key)).replace("-", ""));
PlayerCash.getOpHashMap().put(name, playerObject);
}
break;
case GAMEMODE:
if (!yamlConfiguration.contains(value.path)) {
yamlConfiguration.set(value.path, value.valueGameMode.toString());
}
try {
value.valueGameMode = GameMode.valueOf(yamlConfiguration.getString(value.path).toUpperCase());
} catch (Exception ex) {
ex.printStackTrace();
value.valueGameMode = GameMode.SURVIVAL;
}
break;
}
@@ -155,6 +168,7 @@ public class FileSelect {
}
public static void selectPermissionWhitelist() {
PlayerCash.getPermissionHashMap().clear();
File config = new File(Main.getPath(), "permissionWhitelist.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
for (PermissionWhitelist value : PermissionWhitelist.values()) {
@@ -167,7 +181,7 @@ public class FileSelect {
break;
case STRINGLIST:
if (!yamlConfiguration.contains(value.path)) {
yamlConfiguration.set(value.path, value.valueBoolean);
yamlConfiguration.set(value.path, value.valueStringList);
}
value.valueStringList = T2Creplace.replace(Util.getPrefix(), yamlConfiguration.getStringList(value.path));
break;
@@ -179,10 +193,11 @@ public class FileSelect {
yamlConfiguration.set(value.pathPlayerUuid.replace("KEY", "player2"), value.valuePlayerUuid);
}
for (String key : yamlConfiguration.getConfigurationSection(value.pathPlayerListPath).getKeys(false)) {
String name = yamlConfiguration.getString(value.pathPlayerName.replace("KEY", key));
PlayerObject playerObject = new PlayerObject(
yamlConfiguration.getString(value.pathPlayerName.replace("KEY", key)),
name,
yamlConfiguration.getString(value.pathPlayerUuid.replace("KEY", key).replace("-", "")));
PlayerCash.getPermissionHashMap().put(key, playerObject);
PlayerCash.getPermissionHashMap().put(name, playerObject);
}
break;
}

View File

@@ -9,13 +9,18 @@ public enum Config {
language("plugin.language", "english", ConfigParam.STRING),
onlyOPcanUseThePlugin("plugin.onlyOPcanUseThePlugin", true, ConfigParam.BOOLEAN),
updateCheckOnJoin("plugin.updateCheck.onJoin",true,ConfigParam.BOOLEAN),
updateCheckSeePreReleaseUpdates("plugin.updateCheck.seePreReleaseUpdates",true,ConfigParam.BOOLEAN),
updateCheckTimeInterval("plugin.updateCheck.timeInterval",60,ConfigParam.INTEGER),
checkOnJoin("check.onJoin", true, ConfigParam.BOOLEAN),
checkOnInteract("check.onInteract", true, ConfigParam.BOOLEAN),
checkOnCommand("check.onCommand", true, ConfigParam.BOOLEAN),
checkOnChat("check.onChat", true, ConfigParam.BOOLEAN),
checkTimerEnable("check.timer.enable", true, ConfigParam.BOOLEAN),
checkTimerRefreshInSec("check.timer.refreshInSec", 60, ConfigParam.INTEGER),
kickCommand("kick.command", "minecraft:kick [player] [reason]", ConfigParam.STRING),
kickCustomCommand("kick.customCommand.Enable", false, ConfigParam.BOOLEAN),
kickCommand("kick.customCommand.command", "minecraft:kick [player] [reason]", ConfigParam.STRING),
notifyJoinWarning("notify.joinWarn.enable", true, ConfigParam.BOOLEAN),
notifyBungee("notify.allBungeePlayer.enable", false, ConfigParam.BOOLEAN),
notifySoundEnable("notify.soundEnable", true, ConfigParam.BOOLEAN),
@@ -26,30 +31,30 @@ public enum Config {
public Integer valueInt;
public Boolean valueBoolean;
public Sound sound;
public ConfigParam cEnum;
public ConfigParam configParam;
Config(String path, String value, ConfigParam cEnum) {
this.path = path;
this.valueString = value;
this.cEnum = cEnum;
this.configParam = cEnum;
}
Config(String path, Sound value, ConfigParam cEnum) {
this.path = path;
this.sound = value;
this.cEnum = cEnum;
this.configParam = cEnum;
}
Config(String path, Integer value, ConfigParam cEnum) {
this.path = path;
this.valueInt = value;
this.cEnum = cEnum;
this.configParam = cEnum;
}
Config(String path, Boolean value, ConfigParam cEnum) {
this.path = path;
this.valueBoolean = value;
this.cEnum = cEnum;
this.configParam = cEnum;
}
public static Sound sound() {

View File

@@ -30,32 +30,32 @@ public enum Language {
"[prefix] <dark_red>The specified player is not on the OP_Whitelist!</dark_red>"),
opWhitelistNotifyOnJoin("opWhitelist.notify.onJoin",null,
"[prefix] <dark_red>Spieler <gold>[player]</gold> ist dem Server beigetreten, befindet sich aber nicht auf der OP_Whitelist!</dark_red>",
"[prefix] <dark_red>Player <gold>[player]</gold> is joined to the server but is not on the OP_Whitelist!</dark_red>"),
"[prefix] <dark_red>Spieler <gold><hover:show_text:'<gold>Name:</gold> <yellow>[player]</yellow><br><gold>UUID:</gold> <yellow>[uuid]</yellow>'>[player]</hover></gold> ist dem Server beigetreten, befindet sich aber nicht auf der OP_Whitelist!</dark_red>",
"[prefix] <dark_red>Player <gold><hover:show_text:'<gold>Name:</gold> <yellow>[player]</yellow><br><gold>UUID:</gold> <yellow>[uuid]</yellow>'>[player]</hover></gold> is joined to the server but is not on the OP_Whitelist!</dark_red>"),
opWhitelistNotifyDeop("opWhitelist.notify.deop",null,
"[prefix] <dark_red>Spieler <gold>[player]</gold> wurde OP entfernt da er nicht auf der Spielerliste steht!</dark_red>",
"[prefix] <dark_red>Player <gold>[player]</gold> was removed OP because he is not on the playerlist!</dark_red>"),
"[prefix] <dark_red>Spieler <gold><hover:show_text:'<gold>Name:</gold> <yellow>[player]</yellow><br><gold>UUID:</gold> <yellow>[uuid]</yellow>'>[player]</hover></gold> wurde OP entfernt da er nicht auf der Spielerliste steht!</dark_red>",
"[prefix] <dark_red>Player <gold><hover:show_text:'<gold>Name:</gold> <yellow>[player]</yellow><br><gold>UUID:</gold> <yellow>[uuid]</yellow>'>[player]</hover></gold> was removed OP because he is not on the playerlist!</dark_red>"),
opWhitelistNotifyKick("opWhitelist.notify.kick",null,
"[prefix] <dark_red>Spieler <gold>[player]</gold> wurde gekickt, da er nicht auf der OP_Whitelist steht!</dark_red>",
"[prefix] <dark_red>Player <gold>[player]</gold> was kicked because he is not on the OP_Whitelist!</dark_red>"),
"[prefix] <dark_red>Spieler <gold><hover:show_text:'<gold>Name:</gold> <yellow>[player]</yellow><br><gold>UUID:</gold> <yellow>[uuid]</yellow>'>[player]</hover></gold> wurde gekickt, da er nicht auf der OP_Whitelist steht!</dark_red>",
"[prefix] <dark_red>Player <gold><hover:show_text:'<gold>Name:</gold> <yellow>[player]</yellow><br><gold>UUID:</gold> <yellow>[uuid]</yellow>'>[player]</hover></gold> was kicked because he is not on the OP_Whitelist!</dark_red>"),
opWhitelistDeop("opWhitelist.deop",null,
"[prefix] <dark_red>Dir wurde OP entfernt da du dazu keine Permission besitzt.</dark_red>",
"[prefix] <dark_red>You have been removed from OP because you do not have permission.</dark_red>"),
"&4Dir wurde OP entfernt da du dazu keine Permission besitzt.",
"&4You have been removed from OP because you do not have permission."),
opWhitelistKick("opWhitelist.kick",null,
"<dark_red>Du hast op bist dazu aber nicht berechtigt, deswegen wurdest du gekickt!</dark_red>",
"<dark_red>You have op but are not authorized to do so, that's why you were kicked!</dark_red>"),
"&4Du hast OP, bist dazu aber nicht berechtigt. Deswegen wurdest du gekickt!",
"&4You have op but are not authorized to do so, that's why you were kicked!"),
permissionWhitelistNotifyOnJoin("permissionWhitelist.notify.onJoin",null,
"[prefix] <dark_red>Player <gold>[player]</gold> hat die Permission <gold>[perm]</gold> und ist dazu nicht berechtigt! <gold>[player]</gold> ist nicht in der Spielerliste!</dark_red>",
"[prefix] <dark_red>Player <gold>[player]</gold> has permission <gold>[perm]</gold> and is not authorized to do so! <gold>[player]</gold> is not on the Player list!</dark_red>"),
"[prefix] <dark_red>Player <gold><hover:show_text:'<gold>Name:</gold> <yellow>[player]</yellow><br><gold>UUID:</gold> <yellow>[uuid]</yellow>'>[player]</hover></gold> hat die Permission <gold>[perm]</gold> und ist dazu nicht berechtigt! <gold><hover:show_text:'<gold>Name:</gold> <yellow>[player]</yellow><br><gold>UUID:</gold> <yellow>[uuid]</yellow>'>[player]</hover></gold> ist nicht in der Spielerliste!</dark_red>",
"[prefix] <dark_red>Player <gold><hover:show_text:'<gold>Name:</gold> <yellow>[player]</yellow><br><gold>UUID:</gold> <yellow>[uuid]</yellow>'>[player]</hover></gold> has permission <gold>[perm]</gold> and is not authorized to do so! <gold><hover:show_text:'<gold>Name:</gold> <yellow>[player]</yellow><br><gold>UUID:</gold> <yellow>[uuid]</yellow>'>[player]</hover></gold> is not on the Player list!</dark_red>"),
permissionWhitelistNotifyKick("permissionWhitelist.notify.kick",null,
"[prefix] <dark_red>Spieler <gold>[player]</gold> hat die Permission <gold>[perm]</gold> und ist dazu nicht berechtigt! Daher wurde er gekickt! <gold>[player]</gold> ist nicht in der Spielerliste!</dark_red>",
"[prefix] <dark_red>Player <gold>[player]</gold> has permission <gold>[perm]</gold> and is not authorized to do so! Therefore he was kicked! <gold>[player]</gold> is not on the Player list!</dark_red>"),
"[prefix] <dark_red>Spieler <gold><hover:show_text:'<gold>Name:</gold> <yellow>[player]</yellow><br><gold>UUID:</gold> <yellow>[uuid]</yellow>'>[player]</hover></gold> hat die Permission <gold>[perm]</gold> und ist dazu nicht berechtigt! Daher wurde er gekickt! <gold><hover:show_text:'<gold>Name:</gold> <yellow>[player]</yellow><br><gold>UUID:</gold> <yellow>[uuid]</yellow>'>[player]</hover></gold> ist nicht in der Spielerliste!</dark_red>",
"[prefix] <dark_red>Player <gold><hover:show_text:'<gold>Name:</gold> <yellow>[player]</yellow><br><gold>UUID:</gold> <yellow>[uuid]</yellow>'>[player]</hover></gold> has permission <gold>[perm]</gold> and is not authorized to do so! Therefore he was kicked! <gold><hover:show_text:'<gold>Name:</gold> <yellow>[player]</yellow><br><gold>UUID:</gold> <yellow>[uuid]</yellow>'>[player]</hover></gold> is not on the Player list!</dark_red>"),
permissionWhitelistKick("permissionWhitelist.kick",null,
"<dark_red>Du wurdest gekickt, da du Permissions besitzt, für die du keine Berechtigung besitzt!</dark_red>",

View File

@@ -1,6 +1,7 @@
package net.t2code.opsecurity.config.opWhitelist;
import net.t2code.opsecurity.enums.ConfigParam;
import org.bukkit.GameMode;
import java.util.Arrays;
import java.util.List;
@@ -11,6 +12,8 @@ public enum OPWhitelist {
noOpPlayerDeopEnable("opWhitelist.enable", true, ConfigParam.BOOLEAN),
noOpPlayerDeopPlayerSendMessage("opWhitelist.noOpPlayerDeop.playerSendMessage", true, ConfigParam.BOOLEAN),
noOpPlayerKickEnable("opWhitelist.noOpPlayerKick.enable", true, ConfigParam.BOOLEAN),
noOpPlayerSetGameModeEnable("opWhitelist.noOpPlayerSetGameMode.enable", true, ConfigParam.BOOLEAN),
noOpPlayerSetGameModeValue("opWhitelist.noOpPlayerSetGameMode.gameMode", GameMode.SURVIVAL, ConfigParam.GAMEMODE),
customCommandsEnable("opWhitelist.customCommands.enable", false, ConfigParam.BOOLEAN),
customCommandsCommands("opWhitelist.customCommands.commands", Arrays.asList("kick [player] &4You have op but are not authorized to do so, that's why you were kicked!")
, ConfigParam.STRINGLIST),
@@ -25,8 +28,15 @@ public enum OPWhitelist {
public List<String> valueStringList;
public Boolean valueBoolean;
public GameMode valueGameMode;
public ConfigParam cEnum;
OPWhitelist(String path, GameMode value, ConfigParam cEnum) {
this.path = path;
this.valueGameMode = value;
this.cEnum = cEnum;
}
OPWhitelist(String listPath,String pathPlayerName, String pathUuid, String playerName, String uuid, ConfigParam cEnum) {
this.pathPlayerListPath = listPath;
this.pathPlayerName = pathPlayerName;

View File

@@ -6,5 +6,6 @@ public enum ConfigParam {
BOOLEAN,
STRINGLIST,
PLAYERLIST,
SOUND
SOUND,
GAMEMODE
}

View File

@@ -28,8 +28,6 @@ public class Events implements Listener {
public void CommandSendEvent(PlayerCommandPreprocessEvent event) {
if (!Config.checkOnCommand.valueBoolean) return;
Player player = event.getPlayer();
T2Csend.debugmsg(Main.getPlugin(), "1 "+ OpCheck.onCheck(player,false));
T2Csend.debugmsg(Main.getPlugin(), "1 "+ PermissionCheck.onCheck(player,false));
if (OpCheck.onCheck(player, false) || PermissionCheck.onCheck(player, false)) {
if (event.isCancelled()) return;
event.setCancelled(true);
@@ -40,8 +38,6 @@ public class Events implements Listener {
public void PlayerChatEvent(PlayerChatEvent event) {
if (!Config.checkOnChat.valueBoolean) return;
Player player = event.getPlayer();
T2Csend.debugmsg(Main.getPlugin(), "2 "+OpCheck.onCheck(player,false));
T2Csend.debugmsg(Main.getPlugin(), "2 "+PermissionCheck.onCheck(player,false));
if (OpCheck.onCheck(player, false) || PermissionCheck.onCheck(player, false)) {
if (event.isCancelled()) return;
event.setCancelled(true);

View File

@@ -1,9 +1,11 @@
package net.t2code.opsecurity.events;
import net.t2code.opsecurity.check.OpCheck;
import net.t2code.opsecurity.config.language.Language;
import net.t2code.opsecurity.config.opWhitelist.OPWhitelist;
import net.t2code.opsecurity.enums.OpCommandRequest;
import net.t2code.opsecurity.objects.PlayerCash;
import net.t2code.opsecurity.objects.PlayerObject;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.player.T2CnameHistory;
import org.bukkit.Bukkit;
@@ -14,6 +16,7 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.server.ServerCommandEvent;
import java.io.IOException;
import java.util.Map;
public class OpCommand implements Listener {
@EventHandler
@@ -56,8 +59,7 @@ public class OpCommand implements Listener {
Player target = Bukkit.getPlayer(arg);
if (OPWhitelist.playerMustBeOnlineToOp.valueBoolean) {
if (target == null) return OpCommandRequest.mustOnline;
if (!PlayerCash.getOpHashMap().get(target.getName()).playerName.equals(target.getName())) return OpCommandRequest.notWhitelisted;
if (!PlayerCash.getOpHashMap().get(target.getName()).uuid.equals(target.getUniqueId().toString().replace("-", ""))) return OpCommandRequest.notWhitelisted;
if (!opWhitelist(target.getName(), target.getUniqueId().toString())) return OpCommandRequest.notWhitelisted;
}
String targetUUID;
if (target != null) {
@@ -69,8 +71,14 @@ public class OpCommand implements Listener {
throw new RuntimeException(e);
}
}
if (!PlayerCash.getOpHashMap().get(target.getName()).playerName.equals(arg)) return OpCommandRequest.notWhitelisted;
if (!PlayerCash.getOpHashMap().get(target.getName()).uuid.equals(targetUUID.replace("-", ""))) return OpCommandRequest.notWhitelisted;
if (!opWhitelist(arg, targetUUID)) return OpCommandRequest.notWhitelisted;
return OpCommandRequest.ok;
}
private static Boolean opWhitelist(String playerName, String playerUuid) {
for (Map.Entry<String, PlayerObject> playerObject : PlayerCash.getOpHashMap().entrySet()) {
if (playerObject.getValue().playerName.equals(playerName) && playerObject.getValue().uuid.equals(playerUuid)) return true;
}
return false;
}
}

View File

@@ -3,6 +3,7 @@ package net.t2code.opsecurity.system;
import net.t2code.opsecurity.Util;
import net.t2code.opsecurity.command.CmdExecuter;
import net.t2code.opsecurity.config.FileSelect;
import net.t2code.opsecurity.config.config.Config;
import net.t2code.opsecurity.config.config.Converter;
import net.t2code.opsecurity.events.Events;
import net.t2code.opsecurity.events.OpCommand;
@@ -11,6 +12,7 @@ import net.t2code.opsecurity.check.Timer;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
import net.t2code.t2codelib.SPIGOT.api.register.T2Cregister;
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
import org.checkerframework.checker.units.qual.C;
import java.util.List;
import java.util.logging.Level;
@@ -39,7 +41,8 @@ public class Load {
Timer.refreshTimer();
Permissions.register();
T2CupdateAPI.onUpdateCheck(plugin, Util.getPrefix(), Util.getSpigotID(), Util.getDiscord());
T2CupdateAPI.onUpdateCheck(plugin, Util.getPrefix(),Util.getGit(),Util.getSpigotID(),Util.getDiscord(), Config.updateCheckOnJoin.valueBoolean,
Config.updateCheckSeePreReleaseUpdates.valueBoolean, Config.updateCheckTimeInterval.valueInt);
Metrics.Bstats(plugin, Util.getBstatsID());
T2Ctemplate.onLoadFooter(Util.getPrefix(), long_);
}

69
README.md Normal file
View File

@@ -0,0 +1,69 @@
<p align="center">
<img src="https://i.imgur.com/TjwVdDO.png" width="300">
</p>
---
# Links
* [Spigot](https://www.spigotmc.org/resources/t2c-opsecurity-permission-security-1-8-x-1-19-x.90739/)
* [Discord](http://dc.T2Code.net)
---
<img src="https://i.imgur.com/9ahfmOG.png" width="600">
With OPSecurity you can specify usernames that are allowed to have OP or certain permissions.
If someone enters the server with OP who is not on this whitelist, Optional can be kicked or have OP removed.
This plugin also protects players from getting OP via unauthorized ways, e.g. hacked client, because only players who are on the OP whitelist can get OP with the command /op.
You can also use a timer that checks every few seconds (adjustable) if there is a player with OP or a permission on the server who is not on the whitelist.
Please note that you can only give OP via the console to players who are on the whitelist!
**Features:**
- Protection against op hacks
- Protection for specific permissions
- Decide who may have OP
- Even via console protects OP Security
Just come to the support Discord for further questions.
**You can use MiniMessage:**
Wiki: https://docs.adventure.kyori.net/minimessage/format.html
WebUI: https://webui.adventure.kyori.net
<img src="https://i.imgur.com/55BlvCg.png" width="600">
**/t2c-opsecurity** | **/opsecurity** | **/opsec**
**/t2c-opsecurity help** - Open the help.
**/t2c-opsecurity info** - See the current plugin version.
**/t2c-opsecurity reload** - Reloads the Plugin.
*t2c.opsecurity.notify* - Permission for ingame notifications when a player joins that is not on the whitelist
*t2c.opsecurity.updatemsg* - Update Check on join
*t2c.opsecurity.command.reload* - Reload command
*t2c.opsecurity.command.info* - Info command
*t2c.opsecurity.command.help* - Help command
*t2c.opsecurity.admin* - All permissions of T2C-OPSecurity
<img src="https://i.imgur.com/YbDziZO.png" width="600">
---
<img src="https://i.imgur.com/HoZSt7c.png" width="600">
<img src="https://bstats.org/signatures/bukkit/OPWhitelist.svg" width="600">