SteamWar/BungeeCore
Archiviert
13
2

Adding mod type only usable by YouTubers (and Teammembers)

Dieser Commit ist enthalten in:
Lixfel 2020-01-03 17:09:58 +01:00
Ursprung 9e09ed089e
Commit 767e4a24f3
3 geänderte Dateien mit 15 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -26,6 +26,7 @@ public class ConnectionListener extends BasicListener {
private static final String ADMIN_GROUP = "admin"; private static final String ADMIN_GROUP = "admin";
private static final String TEAM_GROUP = "team"; private static final String TEAM_GROUP = "team";
private static final String YOUTUBER_MODS = "bungeecore.youtubermods";
@EventHandler @EventHandler
public void onPostLogin(PostLoginEvent event) { public void onPostLogin(PostLoginEvent event) {
@ -36,30 +37,36 @@ public class ConnectionListener extends BasicListener {
case "Admin": case "Admin":
player.addGroups(ADMIN_GROUP, TEAM_GROUP); player.addGroups(ADMIN_GROUP, TEAM_GROUP);
player.setPermission("bungeecore.group.admin", true); player.setPermission("bungeecore.group.admin", true);
player.setPermission(YOUTUBER_MODS, true);
player.setDisplayName("§4Admin " + player.getName() + "§r"); player.setDisplayName("§4Admin " + player.getName() + "§r");
break; break;
case "Developer": case "Developer":
player.addGroups(ADMIN_GROUP, TEAM_GROUP); player.addGroups(ADMIN_GROUP, TEAM_GROUP);
player.setPermission("bungeecore.group.developer", true); player.setPermission("bungeecore.group.developer", true);
player.setPermission(YOUTUBER_MODS, true);
player.setDisplayName("§3Developer " + player.getName() + "§r"); player.setDisplayName("§3Developer " + player.getName() + "§r");
break; break;
case "Moderator": case "Moderator":
player.addGroups(ADMIN_GROUP, TEAM_GROUP); player.addGroups(ADMIN_GROUP, TEAM_GROUP);
player.setPermission("bungeecore.group.moderator", true); player.setPermission("bungeecore.group.moderator", true);
player.setPermission(YOUTUBER_MODS, true);
player.setDisplayName("§bModerator " + player.getName() + "§r"); player.setDisplayName("§bModerator " + player.getName() + "§r");
break; break;
case "Supporter": case "Supporter":
player.addGroups(TEAM_GROUP); player.addGroups(TEAM_GROUP);
player.setPermission("bungeecore.group.supporter", true); player.setPermission("bungeecore.group.supporter", true);
player.setPermission(YOUTUBER_MODS, true);
player.setDisplayName("§1Supporter " + player.getName() + "§r"); player.setDisplayName("§1Supporter " + player.getName() + "§r");
break; break;
case "Builder": case "Builder":
player.addGroups(TEAM_GROUP); player.addGroups(TEAM_GROUP);
player.setPermission("bungeecore.group.builder", true); player.setPermission("bungeecore.group.builder", true);
player.setPermission(YOUTUBER_MODS, true);
player.setDisplayName("§2Architekt " + player.getName() + "§r"); player.setDisplayName("§2Architekt " + player.getName() + "§r");
break; break;
case "Youtuber": case "Youtuber":
player.setPermission("bungeecore.group.youtuber", true); player.setPermission("bungeecore.group.youtuber", true);
player.setPermission(YOUTUBER_MODS, true);
player.setDisplayName("§5Youtuber " + player.getName() + "§r"); player.setDisplayName("§5Youtuber " + player.getName() + "§r");
break; break;
case "Member": case "Member":

Datei anzeigen

@ -35,11 +35,14 @@ class Utils {
} }
static boolean handleMods(ProxiedPlayer player, List<Mod> mods){ static boolean handleMods(ProxiedPlayer player, List<Mod> mods){
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
boolean privileged = player.hasPermission("bungeecore.youtubermods");
ModType max = ModType.YELLOW; ModType max = ModType.YELLOW;
Iterator<Mod> it = mods.iterator(); Iterator<Mod> it = mods.iterator();
while(it.hasNext()){ while(it.hasNext()){
Mod mod = it.next(); 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(); it.remove();
else if(mod.getModType() == ModType.RED) else if(mod.getModType() == ModType.RED)
max = ModType.RED; max = ModType.RED;
@ -52,7 +55,7 @@ class Utils {
if(max == ModType.YELLOW) 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.")); player.disconnect(BungeeCore.stringToText("§7Deaktiviere den Mod §e" + mods.get(0).getModName() + "§7, um weiter auf §eSteam§8War §7spielen zu können."));
else 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{ }else{
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
mods.forEach(mod -> sb.append(mod.getModName()).append('\n')); mods.forEach(mod -> sb.append(mod.getModName()).append('\n'));
@ -60,7 +63,7 @@ class Utils {
if(max == ModType.YELLOW) if(max == ModType.YELLOW)
player.disconnect(BungeeCore.stringToText("§7Deaktiviere die Mods\n§e" + sb.toString() + "§7um weiter auf §eSteam§8War §7spielen zu können.")); player.disconnect(BungeeCore.stringToText("§7Deaktiviere die Mods\n§e" + sb.toString() + "§7um weiter auf §eSteam§8War §7spielen zu können."));
else 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; return false;

Datei anzeigen

@ -59,7 +59,8 @@ public class Mod {
UNKLASSIFIED(0), UNKLASSIFIED(0),
GREEN(1), GREEN(1),
YELLOW(2), YELLOW(2),
RED(3); RED(3),
YOUTUBER_ONLY(4);
static ModType valueOf(int value){ static ModType valueOf(int value){
for(ModType mt : values()){ for(ModType mt : values()){