10 Commits
3.0.2 ... 3.0.7

Author SHA1 Message Date
44507458e5 3.0.6 2022-11-20 20:17:55 +01:00
ea54d85ecc 3.0.5
https://git.t2code.net/JaTiTV/T2C-OPSecurity/releases/tag/3.0.5
2022-11-19 03:12:53 +01:00
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
dab5a4f557 Update pom.xml 2022-11-14 14:19:07 +01:00
9 changed files with 66 additions and 30 deletions

View File

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

View File

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

View File

@@ -50,7 +50,7 @@ public class OpCheck {
OPWhitelist.noOpPlayerKickEnable.valueBoolean && OPWhitelist.noOpPlayerDeopEnable.valueBoolean && OPWhitelist.noOpPlayerDeopPlayerSendMessage.valueBoolean OPWhitelist.noOpPlayerKickEnable.valueBoolean && OPWhitelist.noOpPlayerDeopEnable.valueBoolean && OPWhitelist.noOpPlayerDeopPlayerSendMessage.valueBoolean
? Language.opWhitelistKick.value + "<br> <br>" + Language.opWhitelistDeop.value : Language.opWhitelistKick.value)); ? Language.opWhitelistKick.value + "<br> <br>" + Language.opWhitelistDeop.value : Language.opWhitelistKick.value));
} else player.kickPlayer(OPWhitelist.noOpPlayerDeopEnable.valueBoolean && OPWhitelist.noOpPlayerDeopPlayerSendMessage.valueBoolean } else player.kickPlayer(OPWhitelist.noOpPlayerDeopEnable.valueBoolean && OPWhitelist.noOpPlayerDeopPlayerSendMessage.valueBoolean
? Language.opWhitelistKick.value + "\n \n" + Language.opWhitelistDeop.value : Language.opWhitelistKick.value); ? 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>" 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()))); + Language.opWhitelistNotifyKick.value.replace("[player]", player.getName().replace("[uuid]", String.valueOf(player.getUniqueId()))).replace("[uuid]", String.valueOf(player.getUniqueId())));
@@ -90,7 +90,15 @@ public class OpCheck {
public static Boolean opWhitelist(Player player) { public static Boolean opWhitelist(Player player) {
for (Map.Entry<String, PlayerObject> playerObject : PlayerCash.getOpHashMap().entrySet()) { for (Map.Entry<String, PlayerObject> playerObject : PlayerCash.getOpHashMap().entrySet()) {
if (playerObject.getValue().playerName.equals(player.getName()) && playerObject.getValue().uuid.equals(player.getUniqueId().toString())) return true; T2Csend.debug(Main.getPlugin(), "--------- " + player.getName());
T2Csend.debug(Main.getPlugin(), "opWhitelist playerObject Name: " + playerObject.getValue().playerName);
T2Csend.debug(Main.getPlugin(), "opWhitelist Player Name: " + player.getName());
T2Csend.debug(Main.getPlugin(), "opWhitelist playerObject UUID: " + playerObject.getValue().uuid);
T2Csend.debug(Main.getPlugin(), "opWhitelist Player UUID: " + player.getUniqueId().toString().replace("-", ""));
if (playerObject.getValue().playerName.equals(player.getName()) && playerObject.getValue().uuid.equals(player.getUniqueId().toString().replace("-", ""))) {
T2Csend.debug(Main.getPlugin(), "opWhitelist Player on list!");
return true;
}
} }
return false; return false;
} }

View File

@@ -19,8 +19,8 @@ public class PermissionCheck {
public static Boolean onCheck(Player player, Boolean join) { public static Boolean onCheck(Player player, Boolean join) {
if (!PermissionWhitelist.enable.valueBoolean) return false; if (!PermissionWhitelist.enable.valueBoolean) return false;
for (String perm : PermissionWhitelist.permissions.valueStringList) { for (String perm : PermissionWhitelist.permissions.valueStringList) {
if (!player.hasPermission(perm)) continue; if (!player.hasPermission(perm)) return false;
if (permWhitelist(player)) continue; if (permWhitelist(player)) return false;
Bukkit.getScheduler().runTask(Main.getPlugin(), new Runnable() { Bukkit.getScheduler().runTask(Main.getPlugin(), new Runnable() {
@Override @Override
public void run() { public void run() {
@@ -42,12 +42,12 @@ public class PermissionCheck {
if (PermissionWhitelist.playerWithPermissionKick.valueBoolean) { if (PermissionWhitelist.playerWithPermissionKick.valueBoolean) {
if (Config.kickCustomCommand.valueBoolean) { if (Config.kickCustomCommand.valueBoolean) {
T2Ccmd.console(Config.kickCommand.valueString.replace("[player]", player.getName()).replace("[reason]", Language.permissionWhitelistKick.value)); T2Ccmd.console(Config.kickCommand.valueString.replace("[perm]", perm).replace("[player]", player.getName()).replace("[reason]", Language.permissionWhitelistKick.value));
} else player.kickPlayer(Language.permissionWhitelistKick.value); } else player.kickPlayer(Language.permissionWhitelistKick.value);
T2Csend.console(Language.permissionWhitelistNotifyKick.value.replace("[player]", T2Csend.console(Language.permissionWhitelistNotifyKick.value.replace("[player]",
player.getName()).replace("[perm]", perm).replace("[uuid]",String.valueOf(player.getUniqueId()))); player.getName()).replace("[perm]", perm).replace("[uuid]",String.valueOf(player.getUniqueId())));
} }
if (PermissionWhitelist.customCommandsCommands.valueBoolean) { if (PermissionWhitelist.customCommandsEnable.valueBoolean) {
for (String cmd : PermissionWhitelist.customCommandsCommands.valueStringList) { for (String cmd : PermissionWhitelist.customCommandsCommands.valueStringList) {
T2Ccmd.console(cmd.replace("[player]", player.getName()).replace("[perm]", perm)); T2Ccmd.console(cmd.replace("[player]", player.getName()).replace("[perm]", perm));
} }
@@ -55,8 +55,17 @@ public class PermissionCheck {
} }
private static Boolean permWhitelist(Player player) { private static Boolean permWhitelist(Player player) {
for (Map.Entry<String, PlayerObject> playerObject : PlayerCash.getPermissionHashMap().entrySet()) { for (Map.Entry<String, PlayerObject> playerObject : PlayerCash.getPermissionHashMap().entrySet()) {
if (playerObject.getValue().playerName.equals(player.getName()) && playerObject.getValue().uuid.equals(player.getUniqueId().toString())) return true; T2Csend.debug(Main.getPlugin(), "--------- " + player.getName());
T2Csend.debug(Main.getPlugin(),"permWhitelist playerObject Name: "+playerObject.getValue().playerName );
T2Csend.debug(Main.getPlugin(),"permWhitelist Player Name: "+player.getName() );
T2Csend.debug(Main.getPlugin(),"permWhitelist playerObject UUID: "+playerObject.getValue().uuid );
T2Csend.debug(Main.getPlugin(),"permWhitelist Player UUID: "+player.getUniqueId().toString().replace("-","") );
if (playerObject.getValue().playerName.equals(player.getName()) && playerObject.getValue().uuid.equals(player.getUniqueId().toString().replace("-",""))){
T2Csend.debug(Main.getPlugin(),"permWhitelist Player on list!");
return true;
}
} }
return false; return false;
} }

View File

@@ -24,12 +24,12 @@ public class FileSelect {
File config = new File(Main.getPath(), "config.yml"); File config = new File(Main.getPath(), "config.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
for (Config value : Config.values()) { for (Config value : Config.values()) {
switch (value.cEnum) { switch (value.configParam) {
case STRING: case STRING:
if (!yamlConfiguration.contains(value.path)) { if (!yamlConfiguration.contains(value.path)) {
yamlConfiguration.set(value.path, value.valueString); 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; break;
case SOUND: case SOUND:
if (!yamlConfiguration.contains(value.path)) { if (!yamlConfiguration.contains(value.path)) {
@@ -128,7 +128,7 @@ public class FileSelect {
break; break;
case STRINGLIST: case STRINGLIST:
if (!yamlConfiguration.contains(value.path)) { 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)); value.valueStringList = T2Creplace.replace(Util.getPrefix(), yamlConfiguration.getStringList(value.path));
break; break;
@@ -143,7 +143,7 @@ public class FileSelect {
String name = yamlConfiguration.getString(value.pathPlayerName.replace("KEY", key)); String name = yamlConfiguration.getString(value.pathPlayerName.replace("KEY", key));
PlayerObject playerObject = new PlayerObject( PlayerObject playerObject = new PlayerObject(
name, name,
yamlConfiguration.getString(value.pathPlayerUuid.replace("KEY", key).replace("-", ""))); yamlConfiguration.getString(value.pathPlayerUuid.replace("KEY", key)).replace("-", ""));
PlayerCash.getOpHashMap().put(name, playerObject); PlayerCash.getOpHashMap().put(name, playerObject);
} }
break; break;
@@ -196,7 +196,7 @@ public class FileSelect {
String name = yamlConfiguration.getString(value.pathPlayerName.replace("KEY", key)); String name = yamlConfiguration.getString(value.pathPlayerName.replace("KEY", key));
PlayerObject playerObject = new PlayerObject( PlayerObject playerObject = new PlayerObject(
name, name,
yamlConfiguration.getString(value.pathPlayerUuid.replace("KEY", key).replace("-", ""))); yamlConfiguration.getString(value.pathPlayerUuid.replace("KEY", key)).replace("-", ""));
PlayerCash.getPermissionHashMap().put(name, playerObject); PlayerCash.getPermissionHashMap().put(name, playerObject);
} }
break; break;

View File

@@ -9,6 +9,10 @@ public enum Config {
language("plugin.language", "english", ConfigParam.STRING), language("plugin.language", "english", ConfigParam.STRING),
onlyOPcanUseThePlugin("plugin.onlyOPcanUseThePlugin", true, ConfigParam.BOOLEAN), 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), checkOnJoin("check.onJoin", true, ConfigParam.BOOLEAN),
checkOnInteract("check.onInteract", true, ConfigParam.BOOLEAN), checkOnInteract("check.onInteract", true, ConfigParam.BOOLEAN),
checkOnCommand("check.onCommand", true, ConfigParam.BOOLEAN), checkOnCommand("check.onCommand", true, ConfigParam.BOOLEAN),
@@ -27,30 +31,30 @@ public enum Config {
public Integer valueInt; public Integer valueInt;
public Boolean valueBoolean; public Boolean valueBoolean;
public Sound sound; public Sound sound;
public ConfigParam cEnum; public ConfigParam configParam;
Config(String path, String value, ConfigParam cEnum) { Config(String path, String value, ConfigParam cEnum) {
this.path = path; this.path = path;
this.valueString = value; this.valueString = value;
this.cEnum = cEnum; this.configParam = cEnum;
} }
Config(String path, Sound value, ConfigParam cEnum) { Config(String path, Sound value, ConfigParam cEnum) {
this.path = path; this.path = path;
this.sound = value; this.sound = value;
this.cEnum = cEnum; this.configParam = cEnum;
} }
Config(String path, Integer value, ConfigParam cEnum) { Config(String path, Integer value, ConfigParam cEnum) {
this.path = path; this.path = path;
this.valueInt = value; this.valueInt = value;
this.cEnum = cEnum; this.configParam = cEnum;
} }
Config(String path, Boolean value, ConfigParam cEnum) { Config(String path, Boolean value, ConfigParam cEnum) {
this.path = path; this.path = path;
this.valueBoolean = value; this.valueBoolean = value;
this.cEnum = cEnum; this.configParam = cEnum;
} }
public static Sound sound() { public static Sound sound() {

View File

@@ -58,8 +58,9 @@ public enum Language {
"[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>"), "[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, permissionWhitelistKick("permissionWhitelist.kick",null,
"<dark_red>Du wurdest gekickt, da du Permissions besitzt, für die du keine Berechtigung besitzt!</dark_red>", "&4Du wurdest gekickt, da du Permissions besitzt, für die du keine Berechtigung besitzt!",
"<dark_red>You were kicked because you have permissions to which you do not have permission!</dark_red>"), "&4You were kicked because you have permissions to which you do not have permission!"),
exactKickReason("console.exactKickReason", null, exactKickReason("console.exactKickReason", null,
"[prefix] <dark_red>Genauer Grund:</dark_red> <gold>[reason]</gold>", "[prefix] <dark_red>Genauer Grund:</dark_red> <gold>[reason]</gold>",
"[prefix] <dark_red>Exact reason:</dark_red> <gold>[reason]</gold>"); "[prefix] <dark_red>Exact reason:</dark_red> <gold>[reason]</gold>");

View File

@@ -6,6 +6,7 @@ import net.t2code.opsecurity.config.opWhitelist.OPWhitelist;
import net.t2code.opsecurity.enums.OpCommandRequest; import net.t2code.opsecurity.enums.OpCommandRequest;
import net.t2code.opsecurity.objects.PlayerCash; import net.t2code.opsecurity.objects.PlayerCash;
import net.t2code.opsecurity.objects.PlayerObject; import net.t2code.opsecurity.objects.PlayerObject;
import net.t2code.opsecurity.system.Main;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend; import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.player.T2CnameHistory; import net.t2code.t2codelib.SPIGOT.api.player.T2CnameHistory;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@@ -57,10 +58,12 @@ public class OpCommand implements Listener {
if (command.charAt(0) == '/') command = command.replaceFirst("/", ""); if (command.charAt(0) == '/') command = command.replaceFirst("/", "");
String arg = command.replace("op ", ""); String arg = command.replace("op ", "");
Player target = Bukkit.getPlayer(arg); Player target = Bukkit.getPlayer(arg);
if (OPWhitelist.playerMustBeOnlineToOp.valueBoolean) { if (OPWhitelist.playerMustBeOnlineToOp.valueBoolean) {
if (target == null) return OpCommandRequest.mustOnline; if (target == null) return OpCommandRequest.mustOnline;
if (!opWhitelist(target.getName(), target.getUniqueId().toString())) return OpCommandRequest.notWhitelisted; if (!opWhitelist(target.getName(), target.getUniqueId().toString())) return OpCommandRequest.notWhitelisted;
} }
String targetUUID; String targetUUID;
if (target != null) { if (target != null) {
targetUUID = target.getUniqueId().toString(); targetUUID = target.getUniqueId().toString();
@@ -77,7 +80,15 @@ public class OpCommand implements Listener {
private static Boolean opWhitelist(String playerName, String playerUuid) { private static Boolean opWhitelist(String playerName, String playerUuid) {
for (Map.Entry<String, PlayerObject> playerObject : PlayerCash.getOpHashMap().entrySet()) { for (Map.Entry<String, PlayerObject> playerObject : PlayerCash.getOpHashMap().entrySet()) {
if (playerObject.getValue().playerName.equals(playerName) && playerObject.getValue().uuid.equals(playerUuid)) return true; T2Csend.debug(Main.getPlugin(), "--------- " + playerName);
T2Csend.debug(Main.getPlugin(),"opWhitelist (op command) playerObject Name: "+playerObject.getValue().playerName );
T2Csend.debug(Main.getPlugin(),"opWhitelist (op command) Player Name: "+ playerName );
T2Csend.debug(Main.getPlugin(),"opWhitelist (op command) playerObject UUID: "+playerObject.getValue().uuid );
T2Csend.debug(Main.getPlugin(),"opWhitelist (op command) Player UUID: "+ playerUuid );
if (playerObject.getValue().playerName.equals(playerName) && playerObject.getValue().uuid.equals(playerUuid.replace("-", ""))) {
T2Csend.debug(Main.getPlugin(),"opWhitelist (op command) on list!");
return true;
}
} }
return false; return false;
} }

View File

@@ -3,6 +3,7 @@ package net.t2code.opsecurity.system;
import net.t2code.opsecurity.Util; import net.t2code.opsecurity.Util;
import net.t2code.opsecurity.command.CmdExecuter; import net.t2code.opsecurity.command.CmdExecuter;
import net.t2code.opsecurity.config.FileSelect; import net.t2code.opsecurity.config.FileSelect;
import net.t2code.opsecurity.config.config.Config;
import net.t2code.opsecurity.config.config.Converter; import net.t2code.opsecurity.config.config.Converter;
import net.t2code.opsecurity.events.Events; import net.t2code.opsecurity.events.Events;
import net.t2code.opsecurity.events.OpCommand; 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.messages.T2Ctemplate;
import net.t2code.t2codelib.SPIGOT.api.register.T2Cregister; import net.t2code.t2codelib.SPIGOT.api.register.T2Cregister;
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI; import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
import org.checkerframework.checker.units.qual.C;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
@@ -39,7 +41,8 @@ public class Load {
Timer.refreshTimer(); Timer.refreshTimer();
Permissions.register(); 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()); Metrics.Bstats(plugin, Util.getBstatsID());
T2Ctemplate.onLoadFooter(Util.getPrefix(), long_); T2Ctemplate.onLoadFooter(Util.getPrefix(), long_);
} }