Exact reason (kick, deop) is now displayed in the console

This commit is contained in:
JaTiTV 2022-01-05 01:49:27 +01:00
parent 9a0cda7cb6
commit 538f57f40b
6 changed files with 89 additions and 68 deletions

View File

@ -6,7 +6,7 @@
<groupId>de.jatitv</groupId>
<artifactId>OPSecurity</artifactId>
<version>2.3.6_Snapshot_3</version>
<version>2.4.0_DEV</version>
<packaging>jar</packaging>
<name>OPSecurity</name>

View File

@ -34,6 +34,8 @@ public class LanguagesCreate {
set("Permission_Whitelist.consoleOnJoin", MSG.DE_Perm_consoleOnJoin, yamlConfigurationDE);
set("Permission_Whitelist.kick", MSG.DE_Perm_kick, yamlConfigurationDE);
set("Permission_Whitelist.consoleKick", MSG.DE_Perm_consoleKick, yamlConfigurationDE);
set("Console.ExactKickReason", MSG.DE_ExactKickReason, yamlConfigurationDE);
try {
yamlConfigurationDE.save(messagesDE);
@ -59,6 +61,7 @@ public class LanguagesCreate {
set("Permission_Whitelist.consoleOnJoin", MSG.EN_Perm_consoleOnJoin, yamlConfigurationEN);
set("Permission_Whitelist.kick", MSG.EN_Perm_kick, yamlConfigurationEN);
set("Permission_Whitelist.consoleKick", MSG.EN_Perm_consoleKick, yamlConfigurationEN);
set("Console.ExactKickReason", MSG.EN_ExactKickReason, yamlConfigurationEN);
try {
yamlConfigurationEN.save(messagesEN);
@ -84,6 +87,7 @@ public class LanguagesCreate {
set("Permission_Whitelist.consoleOnJoin", MSG.NO_Perm_consoleOnJoin, yamlConfigurationNO);
set("Permission_Whitelist.kick", MSG.NO_Perm_kick, yamlConfigurationNO);
set("Permission_Whitelist.consoleKick", MSG.NO_Perm_consoleKick, yamlConfigurationNO);
set("Console.ExactKickReason", MSG.NO_ExactKickReason, yamlConfigurationNO);
try {
yamlConfigurationNO.save(messagesNO);

View File

@ -14,6 +14,7 @@ public class MSG {
public static String EN_OP_consoleDeop = "&4Player &6[player] &4 was removed OP because he is not on the playerlist!";
public static String EN_OP_kick = "&4You have op but are not authorized to do so, that's why you were kicked!";
public static String EN_OP_consoleKick = "&4Player &6[player] &4was kicked because he is not on the OP_Whitelist!";
public static String EN_ExactKickReason = "[prefix] &4Exact reason: &6[reason]";
public static String EN_Perm_consoleOnJoin = "&4Player &6[player] &4has permission &6[perm] &4and is not authorized to do so! &6[player] &4is not on the Player list!";
public static String EN_Perm_kick = "&4You were kicked because you have permissions to which you do not have permission!";
@ -36,6 +37,7 @@ public class MSG {
public static String DE_OP_kick = "&4You have op but are not authorized to do so, that's why you were kicked\n" +
"&4Du hast op bist dazu aber nicht berechtigt, deswegen wurdest du gekickt!";
public static String DE_OP_consoleKick = "&4Spieler &6[player] &4wurde gekickt, da er nicht auf der OP_Whitelist steht!";
public static String DE_ExactKickReason = "[prefix] &4Genauer Grund: &6[reason]";
public static String DE_Perm_consoleOnJoin = "&4Player &6[player] &4hat die Permission &6[perm] &4und ist dazu nicht berechtigt! &6[player] &4ist nicht in der Spielerliste!";
public static String DE_Perm_kick = "&4You were kicked because you have permissions to which you do not have permission!\n" +
@ -59,6 +61,7 @@ public class MSG {
public static String NO_OP_kick = "&4You have op but are not authorized to do so, that's why you were kicked\n" +
"&4Du er ikke på OP whitelist, så du ble sparket ut!";
public static String NO_OP_consoleKick = "&4Spiller &6[player] &4ble sparket ut fordi han ikke er på OP_Whitelist!";
public static String NO_ExactKickReason = "[prefix] &4Nøyaktig grunn: &6[reason]";
public static String NO_Perm_consoleOnJoin = "&4Spiller &6[player] &4har tillatelsen &6[perm] &4og er ikke godkjent til dette! &6[player] &4er ikke en spiller på Spiller listen! Sparket ut: &4Du ble sparket ut fordi du har tillatelse til noe du ikke er tillatt!";
public static String NO_Perm_kick = "&4You were kicked because you have permissions to which you do not have permission!\n" +

View File

@ -2,6 +2,7 @@
package de.jatitv.opsecurity.config.languages;
import de.jatitv.opsecurity.config.config.SelectConfig;
import de.jatitv.opsecurity.system.Main;
import de.jatitv.opsecurity.util.Replace;
@ -21,14 +22,15 @@ public class SelectMessages {
public static String ReloadStart;
public static String ReloadEnd;
public static String OP_opCommand ;
public static String OP_consoleOnJoin ;
public static String OP_opCommand;
public static String OP_consoleOnJoin;
public static String OP_deop;
public static String OP_consoleDeop ;
public static String OP_consoleDeop;
public static String OP_kick;
public static String OP_consoleKick ;
public static String OP_consoleKick;
public static String ExactReason;
public static String Perm_consoleOnJoin ;
public static String Perm_consoleOnJoin;
public static String Perm_kick;
public static String Perm_consoleKick;
@ -67,13 +69,16 @@ public class SelectMessages {
OP_kick = select("OP_Whitelist.kick", yamlConfiguration);
OP_consoleKick = select("OP_Whitelist.consoleKick", yamlConfiguration);
Perm_consoleOnJoin = select("Permission_Whitelist.consoleOnJoin", yamlConfiguration);
Perm_kick = select("Permission_Whitelist.kick", yamlConfiguration);
Perm_consoleKick = select("Permission_Whitelist.consoleKick", yamlConfiguration);
ExactReason = select("Console.ExactKickReason", yamlConfiguration);
send.console(Prefix + " §2Language successfully selected to: §6" + selectMSG + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
}
private static String select(String path, YamlConfiguration yamlConfiguration){
private static String select(String path, YamlConfiguration yamlConfiguration) {
return Replace.replace(yamlConfiguration.getString(path));
}

View File

@ -14,7 +14,9 @@ public class Check {
public static Boolean onCheck(Player player, Boolean join) {
if (SelectConfig.OP_Whitelist_Enable) {
if (player.isOp()) {
if (!opWhitelist(player)) {
if (opWhitelist(player)) {
return false;
}
if (join) {
send.console(Replace.replace(SelectMessages.OP_consoleOnJoin.replace("[player]", player.getName())));
}
@ -79,8 +81,6 @@ public class Check {
}.runTaskLater(Main.plugin, 5L);
return true;
}
}
}
}
@ -139,15 +139,27 @@ public class Check {
if (Main.opHashMap.containsKey(player.getName().toLowerCase())) {
if (Main.opHashMap.get(player.getName().toLowerCase()).UUID.equals(player.getUniqueId().toString().replace("-", ""))) {
return true;
} else return false;
} else return false;
} else {
send.console(SelectMessages.ExactReason.replace("[reason]", "Player UUID: " + player.getUniqueId().toString() + " not whitelisted"));
return false;
}
} else {
send.console(SelectMessages.ExactReason.replace("[reason]", "Player name: " + player.getName() + " not whitelisted"));
return false;
}
}
private static Boolean permWhitelist(Player player) {
if (Main.permissionHashMap.containsKey(player.getName().toLowerCase())) {
if (Main.permissionHashMap.get(player.getName().toLowerCase()).UUID.equals(player.getUniqueId().toString().replace("-", ""))) {
return true;
} else return false;
} else return false;
} else {
send.console(SelectMessages.ExactReason.replace("[reason]", "Player UUID: " + player.getUniqueId().toString() + " not whitelisted"));
return false;
}
} else {
send.console(SelectMessages.ExactReason.replace("[reason]", "Player name: " + player.getName() + " not whitelisted"));
return false;
}
}
}

View File

@ -4,10 +4,7 @@ package de.jatitv.opsecurity.listener;
import de.jatitv.opsecurity.config.config.SelectConfig;
import de.jatitv.opsecurity.system.Main;
import de.jatitv.opsecurity.util.TextBuilder;
import de.jatitv.opsecurity.util.UpdateChecker;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.*;