From 767e4a24f3916e2e03ea818c1fe11446ef60a1d1 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 3 Jan 2020 17:09:58 +0100 Subject: [PATCH] Adding mod type only usable by YouTubers (and Teammembers) --- .../bungeecore/listeners/ConnectionListener.java | 7 +++++++ src/de/steamwar/bungeecore/listeners/mods/Utils.java | 9 ++++++--- src/de/steamwar/bungeecore/sql/Mod.java | 3 ++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/ConnectionListener.java b/src/de/steamwar/bungeecore/listeners/ConnectionListener.java index 9f0368a..b3c7353 100644 --- a/src/de/steamwar/bungeecore/listeners/ConnectionListener.java +++ b/src/de/steamwar/bungeecore/listeners/ConnectionListener.java @@ -26,6 +26,7 @@ public class ConnectionListener extends BasicListener { private static final String ADMIN_GROUP = "admin"; private static final String TEAM_GROUP = "team"; + private static final String YOUTUBER_MODS = "bungeecore.youtubermods"; @EventHandler public void onPostLogin(PostLoginEvent event) { @@ -36,30 +37,36 @@ public class ConnectionListener extends BasicListener { case "Admin": player.addGroups(ADMIN_GROUP, TEAM_GROUP); player.setPermission("bungeecore.group.admin", true); + player.setPermission(YOUTUBER_MODS, true); player.setDisplayName("§4Admin " + player.getName() + "§r"); break; case "Developer": player.addGroups(ADMIN_GROUP, TEAM_GROUP); player.setPermission("bungeecore.group.developer", true); + player.setPermission(YOUTUBER_MODS, true); player.setDisplayName("§3Developer " + player.getName() + "§r"); break; case "Moderator": player.addGroups(ADMIN_GROUP, TEAM_GROUP); player.setPermission("bungeecore.group.moderator", true); + player.setPermission(YOUTUBER_MODS, true); player.setDisplayName("§bModerator " + player.getName() + "§r"); break; case "Supporter": player.addGroups(TEAM_GROUP); player.setPermission("bungeecore.group.supporter", true); + player.setPermission(YOUTUBER_MODS, true); player.setDisplayName("§1Supporter " + player.getName() + "§r"); break; case "Builder": player.addGroups(TEAM_GROUP); player.setPermission("bungeecore.group.builder", true); + player.setPermission(YOUTUBER_MODS, true); player.setDisplayName("§2Architekt " + player.getName() + "§r"); break; case "Youtuber": player.setPermission("bungeecore.group.youtuber", true); + player.setPermission(YOUTUBER_MODS, true); player.setDisplayName("§5Youtuber " + player.getName() + "§r"); break; case "Member": diff --git a/src/de/steamwar/bungeecore/listeners/mods/Utils.java b/src/de/steamwar/bungeecore/listeners/mods/Utils.java index f69b1af..548f411 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Utils.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Utils.java @@ -35,11 +35,14 @@ class Utils { } static boolean handleMods(ProxiedPlayer player, List mods){ + SteamwarUser user = SteamwarUser.get(player.getUniqueId()); + boolean privileged = player.hasPermission("bungeecore.youtubermods"); + ModType max = ModType.YELLOW; Iterator it = mods.iterator(); while(it.hasNext()){ Mod mod = it.next(); - if(mod.getModType() == ModType.UNKLASSIFIED || mod.getModType() == ModType.GREEN) + if(mod.getModType() == ModType.UNKLASSIFIED || mod.getModType() == ModType.GREEN || (mod.getModType() == ModType.YOUTUBER_ONLY && privileged)) it.remove(); else if(mod.getModType() == ModType.RED) max = ModType.RED; @@ -52,7 +55,7 @@ class Utils { if(max == ModType.YELLOW) player.disconnect(BungeeCore.stringToText("§7Deaktiviere den Mod §e" + mods.get(0).getModName() + "§7, um weiter auf §eSteam§8War §7spielen zu können.")); else - SteamwarUser.get(player.getUniqueId()).ban(Timestamp.from(Instant.now().plus(1, ChronoUnit.DAYS)), "Versuchte Benutzung des Mods " + mods.get(0).getModName()); + user.ban(Timestamp.from(Instant.now().plus(1, ChronoUnit.DAYS)), "Versuchte Benutzung des Mods " + mods.get(0).getModName()); }else{ StringBuilder sb = new StringBuilder(); mods.forEach(mod -> sb.append(mod.getModName()).append('\n')); @@ -60,7 +63,7 @@ class Utils { if(max == ModType.YELLOW) player.disconnect(BungeeCore.stringToText("§7Deaktiviere die Mods\n§e" + sb.toString() + "§7um weiter auf §eSteam§8War §7spielen zu können.")); else - SteamwarUser.get(player.getUniqueId()).ban(Timestamp.from(Instant.now().plus(1, ChronoUnit.DAYS)), "Versuchte Benutzung der Mods\n" + sb.toString()); + user.ban(Timestamp.from(Instant.now().plus(1, ChronoUnit.DAYS)), "Versuchte Benutzung der Mods\n" + sb.toString()); } return false; diff --git a/src/de/steamwar/bungeecore/sql/Mod.java b/src/de/steamwar/bungeecore/sql/Mod.java index 61e628d..54cfc2e 100644 --- a/src/de/steamwar/bungeecore/sql/Mod.java +++ b/src/de/steamwar/bungeecore/sql/Mod.java @@ -59,7 +59,8 @@ public class Mod { UNKLASSIFIED(0), GREEN(1), YELLOW(2), - RED(3); + RED(3), + YOUTUBER_ONLY(4); static ModType valueOf(int value){ for(ModType mt : values()){ -- 2.39.5