diff --git a/varo/.factorypath b/varo/.factorypath new file mode 100644 index 0000000..f6482f8 --- /dev/null +++ b/varo/.factorypath @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/varo/.settings/org.eclipse.jdt.apt.core.prefs b/varo/.settings/org.eclipse.jdt.apt.core.prefs index d4313d4..dfa4f3a 100644 --- a/varo/.settings/org.eclipse.jdt.apt.core.prefs +++ b/varo/.settings/org.eclipse.jdt.apt.core.prefs @@ -1,2 +1,4 @@ eclipse.preferences.version=1 -org.eclipse.jdt.apt.aptEnabled=false +org.eclipse.jdt.apt.aptEnabled=true +org.eclipse.jdt.apt.genSrcDir=target/generated-sources/annotations +org.eclipse.jdt.apt.genTestSrcDir=target/generated-test-sources/test-annotations diff --git a/varo/.settings/org.eclipse.jdt.core.prefs b/varo/.settings/org.eclipse.jdt.core.prefs index 46235dc..2985089 100644 --- a/varo/.settings/org.eclipse.jdt.core.prefs +++ b/varo/.settings/org.eclipse.jdt.core.prefs @@ -4,6 +4,6 @@ org.eclipse.jdt.core.compiler.compliance=11 org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore -org.eclipse.jdt.core.compiler.processAnnotations=disabled +org.eclipse.jdt.core.compiler.processAnnotations=enabled org.eclipse.jdt.core.compiler.release=disabled org.eclipse.jdt.core.compiler.source=11 diff --git a/varo/pom.xml b/varo/pom.xml index c58415d..07e26df 100644 --- a/varo/pom.xml +++ b/varo/pom.xml @@ -26,6 +26,11 @@ papermc https://papermc.io/repo/repository/maven-public/ + + jcenter + jcenter-bintray + https://jcenter.bintray.com + @@ -42,6 +47,31 @@ 1.15.2-R0.1-SNAPSHOT provided + + + net.dv8tion + JDA + 4.1.1_101 + + + club.minnced + opus-java + + + + + + com.googlecode.json-simple + json-simple + 1.1.1 + + + + org.apache.logging.log4j + log4j-core + 2.1 + provided + ${project.basedir}/src/main/java @@ -53,5 +83,110 @@ + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 11 + 11 + UTF-8 + + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.3 + + + package + + shade + + + + + + + + + net.dv8tion.jda + de.cliffbreak.varo.dependencies.jda + + + com.neovisionaries.ws + de.cliffbreak.varo.dependencies.ws + + + net.kyori + de.cliffbreak.varo.dependencies.net.kyori + + + me.vankka + de.cliffbreak.varo.dependencies.me.vankka + + + + + + org.apache.http + de.cliffbreak.varo.dependencies.apache.http + + + org.json + de.cliffbreak.varo.dependencies.json + + + org.json.simple + de.cliffbreak.varo.dependencies.json.simple + + + okhttp3 + de.cliffbreak.varo.dependencies.okhttp3 + + + okio + de.cliffbreak.varo.dependencies.okio + + + + com.fasterxml.jackson + de.cliffbreak.varo.dependencies.jackson + + + + true + + + commons-logging:commons-logging + + ** + + + + com.fasterxml.jackson.core:jackson-databind + + ** + + + + + + + + false + + + \ No newline at end of file diff --git a/varo/src/main/java/de/cliffbreak/varo/Varo.java b/varo/src/main/java/de/cliffbreak/varo/Varo.java index bda2ce6..2a912ad 100644 --- a/varo/src/main/java/de/cliffbreak/varo/Varo.java +++ b/varo/src/main/java/de/cliffbreak/varo/Varo.java @@ -5,19 +5,20 @@ import java.io.IOException; import java.util.ArrayList; import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.plugin.java.JavaPlugin; import de.cliffbreak.varo.commands.CoordsCommand; import de.cliffbreak.varo.commands.VaroCommand; import de.cliffbreak.varo.commands.VaroTabCompleter; +import de.cliffbreak.varo.discord.DiscordBot; import de.cliffbreak.varo.listeners.BannedActionListener; import de.cliffbreak.varo.listeners.BannedItemListener; import de.cliffbreak.varo.listeners.ChatListener; -import de.cliffbreak.varo.listeners.PlayerInteractNPCListener; import de.cliffbreak.varo.listeners.EntityRegainHealthListener; import de.cliffbreak.varo.listeners.PlayerClientOptionsChangeListener; import de.cliffbreak.varo.listeners.PlayerDeathListener; +import de.cliffbreak.varo.listeners.PlayerInteractNPCListener; import de.cliffbreak.varo.listeners.PlayerJoinQuitListener; import de.cliffbreak.varo.listeners.PlayerLoginListener; import de.cliffbreak.varo.listeners.PlayerResourcePackStatusListener; @@ -38,6 +39,7 @@ public class Varo extends JavaPlugin { private VaroUtils varoUtils; private TeamManager teamManager; private MessageUtils messageUtils; + private DiscordBot discordBot; private boolean canCreatePortal = false; @@ -53,11 +55,13 @@ public class Varo extends JavaPlugin { this.playerCache = new PlayerCache(this); this.banUtils = new BanUtils(this); this.varoUtils = new VaroUtils(this); - this.teamManager = new TeamManager(this); + this.teamManager = new TeamManager(); this.messageUtils = new MessageUtils(this); this.config.addDefault("Varo.Start", 1590427800000f); this.config.addDefault("Varo.Debug", false); + this.config.addDefault("Varo.Discord.Token", "insert.token.here"); + this.config.addDefault("Varo.Discord.Channel", "numeric.channel.id"); this.config.addDefault("Varo.RetroHealthRegen", false); this.config.addDefault("Varo.Bans", new ArrayList()); this.config.options().copyDefaults(true); @@ -79,12 +83,19 @@ public class Varo extends JavaPlugin { this.getCommand("coords").setExecutor(new CoordsCommand(this)); this.varoUtils.init(); + + this.discordBot = new DiscordBot(this); } @Override public void onDisable() { this.getLogger().info("Stopping CliffbreakVaro!"); this.playerCache.shutdown(); + try { + this.discordBot.shutdown(); + } catch (final NoClassDefFoundError err) { + + } } @Override @@ -129,4 +140,8 @@ public class Varo extends JavaPlugin { public void setCanCreatePortal(final boolean canCreatePortal) { this.canCreatePortal = canCreatePortal; } + + public DiscordBot getDiscordBot() { + return this.discordBot; + } } diff --git a/varo/src/main/java/de/cliffbreak/varo/discord/DiscordBot.java b/varo/src/main/java/de/cliffbreak/varo/discord/DiscordBot.java new file mode 100644 index 0000000..9fc788a --- /dev/null +++ b/varo/src/main/java/de/cliffbreak/varo/discord/DiscordBot.java @@ -0,0 +1,50 @@ +package de.cliffbreak.varo.discord; + +import java.util.EnumSet; + +import javax.security.auth.login.LoginException; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.core.Filter; +import org.apache.logging.log4j.core.Logger; + +import de.cliffbreak.varo.Varo; +import de.cliffbreak.varo.discord.filters.JDAFilter; +import de.cliffbreak.varo.discord.listeners.MessageListener; +import net.dv8tion.jda.api.JDA; +import net.dv8tion.jda.api.JDABuilder; +import net.dv8tion.jda.api.utils.cache.CacheFlag; + +public class DiscordBot { + + private final Varo plugin; + private final JDA jda; + + public DiscordBot(final Varo plugin) { + this.plugin = plugin; + ((Logger) LogManager.getRootLogger()).addFilter((Filter) new JDAFilter()); + this.jda = getJDA(); + } + + public void shutdown() { + this.jda.shutdown(); + } + + public void broadcastMessage(final String message) { + this.jda.getTextChannelById(this.plugin.getConfig().getString("Varo.Discord.Channel")).sendMessage(message) + .queue(); + } + + private JDA getJDA() { + try { + return new JDABuilder().setAutoReconnect(true).setBulkDeleteSplittingEnabled(false) + .setDisabledCacheFlags(EnumSet.of(CacheFlag.ACTIVITY, CacheFlag.VOICE_STATE)) + .setToken(this.plugin.getConfig().getString("Varo.Discord.Token")).setContextEnabled(false) + .addEventListeners(new MessageListener(this.plugin)).build().awaitReady(); + } catch (LoginException | InterruptedException e) { + this.plugin.getLogger().warning("The Discord-Service didn't connect properly."); + return null; + } + } + +} \ No newline at end of file diff --git a/varo/src/main/java/de/cliffbreak/varo/discord/filters/JDAFilter.java b/varo/src/main/java/de/cliffbreak/varo/discord/filters/JDAFilter.java new file mode 100644 index 0000000..951bb1e --- /dev/null +++ b/varo/src/main/java/de/cliffbreak/varo/discord/filters/JDAFilter.java @@ -0,0 +1,172 @@ +package de.cliffbreak.varo.discord.filters; + +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Marker; +import org.apache.logging.log4j.core.Filter; +import org.apache.logging.log4j.core.LogEvent; +import org.apache.logging.log4j.core.Logger; +import org.apache.logging.log4j.message.Message; +import org.bukkit.Bukkit; + +public class JDAFilter implements Filter { + + public Result check(final Logger logger, final Level level, final String message, final Throwable throwable) { + // only listen for JDA logs + if (!logger.getName().startsWith("de.cliffbreak.varo.dependencies.jda")) + return Result.NEUTRAL; + + switch (level.name()) { + case "INFO": + Bukkit.getLogger().info("[Discord:INFO] " + message); + break; + case "WARN": + Bukkit.getLogger().warning("[Discord:WARN] " + message); + break; + case "ERROR": + if (message.contains("Got an unexpected error. Please redirect following message to the")) + return Result.DENY; + Bukkit.getLogger().warning("[Discord:ERROR] " + message); + break; + default: + Bukkit.getLogger().info("[Discord] " + message); + } + + // all JDA messages should be denied because we handle them ourselves + return Result.DENY; + } + + @Override + public Result filter(final LogEvent logEvent) { + return check((Logger) LogManager.getLogger(logEvent.getLoggerName()), logEvent.getLevel(), + logEvent.getMessage().getFormattedMessage(), logEvent.getThrown()); + } + + @Override + public Result filter(final Logger logger, final Level level, final Marker marker, final String message, + final Object... parameters) { + return check(logger, level, message, null); + } + + @Override + public Result filter(final Logger logger, final Level level, final Marker marker, final Object message, + final Throwable throwable) { + return check(logger, level, message.toString(), throwable); + } + + @Override + public Result filter(final Logger logger, final Level level, final Marker marker, final Message message, + final Throwable throwable) { + return check(logger, level, message.getFormattedMessage(), throwable); + } + + public void start() { + } + + public void stop() { + } + + public boolean isStarted() { + return true; + } + + public boolean isStopped() { + return false; + } + + @Override + public Result getOnMismatch() { + return Result.NEUTRAL; + } + + @Override + public Result getOnMatch() { + return Result.NEUTRAL; + } + + @Override + public State getState() { + // Auto-generated method stub + return null; + } + + @Override + public void initialize() { + // Auto-generated method stub + + } + + @Override + public Result filter(final Logger arg0, final Level arg1, final Marker arg2, final String arg3, final Object arg4) { + // Auto-generated method stub + return null; + } + + @Override + public Result filter(final Logger arg0, final Level arg1, final Marker arg2, final String arg3, final Object arg4, + final Object arg5) { + // Auto-generated method stub + return null; + } + + @Override + public Result filter(final Logger arg0, final Level arg1, final Marker arg2, final String arg3, final Object arg4, + final Object arg5, final Object arg6) { + // Auto-generated method stub + return null; + } + + @Override + public Result filter(final Logger arg0, final Level arg1, final Marker arg2, final String arg3, final Object arg4, + final Object arg5, final Object arg6, final Object arg7) { + // Auto-generated method stub + return null; + } + + @Override + public Result filter(final Logger arg0, final Level arg1, final Marker arg2, final String arg3, final Object arg4, + final Object arg5, final Object arg6, final Object arg7, final Object arg8) { + // Auto-generated method stub + return null; + } + + @Override + public Result filter(final Logger arg0, final Level arg1, final Marker arg2, final String arg3, final Object arg4, + final Object arg5, final Object arg6, final Object arg7, final Object arg8, final Object arg9) { + // Auto-generated method stub + return null; + } + + @Override + public Result filter(final Logger arg0, final Level arg1, final Marker arg2, final String arg3, final Object arg4, + final Object arg5, final Object arg6, final Object arg7, final Object arg8, final Object arg9, + final Object arg10) { + // Auto-generated method stub + return null; + } + + @Override + public Result filter(final Logger arg0, final Level arg1, final Marker arg2, final String arg3, final Object arg4, + final Object arg5, final Object arg6, final Object arg7, final Object arg8, final Object arg9, + final Object arg10, final Object arg11) { + // Auto-generated method stub + return null; + } + + @Override + public Result filter(final Logger arg0, final Level arg1, final Marker arg2, final String arg3, final Object arg4, + final Object arg5, final Object arg6, final Object arg7, final Object arg8, final Object arg9, + final Object arg10, final Object arg11, final Object arg12) { + // Auto-generated method stub + return null; + } + + @Override + public Result filter(final Logger arg0, final Level arg1, final Marker arg2, final String arg3, final Object arg4, + final Object arg5, final Object arg6, final Object arg7, final Object arg8, final Object arg9, + final Object arg10, final Object arg11, final Object arg12, final Object arg13) { + // Auto-generated method stub + return null; + } + +} \ No newline at end of file diff --git a/varo/src/main/java/de/cliffbreak/varo/discord/listeners/MessageListener.java b/varo/src/main/java/de/cliffbreak/varo/discord/listeners/MessageListener.java new file mode 100644 index 0000000..6743965 --- /dev/null +++ b/varo/src/main/java/de/cliffbreak/varo/discord/listeners/MessageListener.java @@ -0,0 +1,45 @@ +package de.cliffbreak.varo.discord.listeners; + +import java.util.ArrayList; +import java.util.Arrays; + +import de.cliffbreak.varo.Varo; +import net.dv8tion.jda.api.entities.EmbedType; +import net.dv8tion.jda.api.entities.Message; +import net.dv8tion.jda.api.entities.MessageChannel; +import net.dv8tion.jda.api.entities.MessageEmbed; +import net.dv8tion.jda.api.entities.MessageEmbed.Field; +import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.hooks.ListenerAdapter; + +public class MessageListener extends ListenerAdapter { + + final Varo plugin; + + public MessageListener(final Varo plugin) { + this.plugin = plugin; + } + + @Override + public void onMessageReceived(final MessageReceivedEvent e) { + // Don't respond to Bot accounts (and myself) + if (e.getAuthor().isBot()) { + return; + } + // Only answer in configured Channels + final MessageChannel channel = e.getChannel(); + if (!channel.getId().equals(this.plugin.getConfig().getString("Varo.Discord.Channel"))) { + return; + } + final Message message = e.getMessage(); + switch (message.getContentRaw()) { + case "!ping": + channel.sendMessage("Pong!").queue(); + break; + case "!test": + channel.sendMessage(new MessageEmbed(null, "title", "description", EmbedType.RICH, null, 0, null, null, + null, null, null, null, new ArrayList(Arrays.asList()))).queue(); + break; + } + } +} \ No newline at end of file diff --git a/varo/src/main/java/de/cliffbreak/varo/listeners/PlayerDeathListener.java b/varo/src/main/java/de/cliffbreak/varo/listeners/PlayerDeathListener.java index 06c12d5..c731792 100644 --- a/varo/src/main/java/de/cliffbreak/varo/listeners/PlayerDeathListener.java +++ b/varo/src/main/java/de/cliffbreak/varo/listeners/PlayerDeathListener.java @@ -27,6 +27,8 @@ public class PlayerDeathListener implements Listener { e.getEntity().setHealth(20d); // Reset health to prevent death dialog after rejoin (if unbanned) e.getEntity().setGameMode(GameMode.SPECTATOR); this.plugin.getBanUtils().addBan(e.getEntity().getUniqueId()); + this.plugin.getDiscordBot().broadcastMessage("Der Spieler <@!" + + this.plugin.getTeamManager().getDiscordIdByPlayer(e.getEntity()) + "> ist gestorben."); } } \ No newline at end of file diff --git a/varo/src/main/java/de/cliffbreak/varo/managers/TeamManager.java b/varo/src/main/java/de/cliffbreak/varo/managers/TeamManager.java index 9e9e09a..de71e45 100644 --- a/varo/src/main/java/de/cliffbreak/varo/managers/TeamManager.java +++ b/varo/src/main/java/de/cliffbreak/varo/managers/TeamManager.java @@ -15,27 +15,24 @@ import org.json.simple.JSONObject; import org.json.simple.JSONValue; import org.json.simple.parser.ParseException; -import de.cliffbreak.varo.Varo; import de.cliffbreak.varo.uitls.JSONConfig; import de.cliffbreak.varo.uitls.WebUtils; public class TeamManager { - private final Varo plugin; private final JSONConfig config; private final Scoreboard scoreboard; private final ArrayList teams; private static final String TEAM_PREFIX = "~"; - public TeamManager(final Varo plugin) { - this.plugin = plugin; + public TeamManager() { this.config = new JSONConfig(new File("plugins/CliffbreakVaro", "teams.json"), getDefaults()); this.config.save(); this.scoreboard = Bukkit.getScoreboardManager().getMainScoreboard(); this.teams = new ArrayList(); - for (Team team : this.scoreboard.getTeams()) { + for (final Team team : this.scoreboard.getTeams()) { team.unregister(); } @@ -43,49 +40,56 @@ public class TeamManager { } private void init() { - final JSONArray jsonTeams = config.getArray("Teams"); + final JSONArray jsonTeams = config.getArray("teams"); + int teamKey = -1; for (final Object jsonRawTeam : jsonTeams) { + teamKey++; final JSONObject jsonTeam = (JSONObject) jsonRawTeam; final Team team, afkTeam; - if (jsonTeam.get("Name") == null) { + if (jsonTeam.get("name") == null) { continue; } - if (this.scoreboard.getTeam((String) jsonTeam.get("Name")) == null) { - team = this.scoreboard.registerNewTeam((String) jsonTeam.get("Name")); + if (this.scoreboard.getTeam((String) jsonTeam.get("name")) == null) { + team = this.scoreboard.registerNewTeam((String) jsonTeam.get("name")); } else { - team = this.scoreboard.getTeam((String) jsonTeam.get("Name")); + team = this.scoreboard.getTeam((String) jsonTeam.get("name")); } - if (this.scoreboard.getTeam(TEAM_PREFIX + jsonTeam.get("Name")) == null) { - afkTeam = this.scoreboard.registerNewTeam(TEAM_PREFIX + jsonTeam.get("Name")); + if (this.scoreboard.getTeam(TEAM_PREFIX + jsonTeam.get("name")) == null) { + afkTeam = this.scoreboard.registerNewTeam(TEAM_PREFIX + jsonTeam.get("name")); } else { - afkTeam = this.scoreboard.getTeam(TEAM_PREFIX + jsonTeam.get("Name")); + afkTeam = this.scoreboard.getTeam(TEAM_PREFIX + jsonTeam.get("name")); } this.teams.add(team); this.teams.add(afkTeam); - team.setPrefix(ChatColor.valueOf((String) jsonTeam.get("Color")) + "§l[" + jsonTeam.get("Prefix") + "] "); + team.setPrefix(ChatColor.valueOf((String) jsonTeam.get("color")) + "§l[" + jsonTeam.get("prefix") + "] "); afkTeam.setPrefix("§8§l[AFK] "); team.setColor(ChatColor.WHITE); - afkTeam.setColor(ChatColor.valueOf((String) jsonTeam.get("Color"))); + afkTeam.setColor(ChatColor.valueOf((String) jsonTeam.get("color"))); for (final String entry : team.getEntries()) { team.removeEntry(entry); } for (final String entry : afkTeam.getEntries()) { team.removeEntry(entry); } - for (final Object uuid : (JSONArray) jsonTeam.get("Players")) { + String playerName = ""; + int playerKey = -1; + for (final Object rawPlayer : (JSONArray) jsonTeam.get("players")) { + playerKey++; + final JSONObject player = (JSONObject) rawPlayer; try { final String result = WebUtils - .GET("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid); + .GET("https://sessionserver.mojang.com/session/minecraft/profile/" + player.get("uuid")); if (result.isEmpty()) { continue; } final JSONObject profile = (JSONObject) JSONValue.parseWithException(result); - team.addEntry((String) profile.get("name")); + playerName = (String) profile.get("name"); + config.updatePlayerName(teamKey, playerKey, playerName); } catch (IOException | ParseException e) { - this.plugin.getLogger().info( - "§c§lFehler:§r§c beim Verbinden mit der Mojang-API ist ein Fehler aufgetreten. Eventuell sind die Mojang Server down."); + playerName = (String) player.get("name"); } + team.addEntry(playerName); } } } @@ -99,6 +103,20 @@ public class TeamManager { return null; } + public String getDiscordIdByPlayer(final Player player) { + final JSONArray jsonTeams = config.getArray("teams"); + for (final Object jsonRawTeam : jsonTeams) { + final JSONObject jsonTeam = (JSONObject) jsonRawTeam; + for (final Object rawPlayer : ((JSONArray) jsonTeam.get("players"))) { + final JSONObject jsonPlayer = (JSONObject) rawPlayer; + if (jsonPlayer.get("uuid").equals(player.getUniqueId().toString().replace("-", ""))) { + return jsonPlayer.get("discord").toString(); + } + } + } + return ""; + } + public void setAFK(final String player) { final Team oldTeam = getTeamByPlayer(player); for (final Team team : this.teams) { @@ -109,13 +127,16 @@ public class TeamManager { } public void setTeam(final Player player) { - final JSONArray jsonTeams = config.getArray("Teams"); + final JSONArray jsonTeams = config.getArray("teams"); for (final Object jsonRawTeam : jsonTeams) { final JSONObject jsonTeam = (JSONObject) jsonRawTeam; - if (((JSONArray) jsonTeam.get("Players")).contains(player.getUniqueId().toString().replace("-", ""))) { - for (final Team team : this.teams) { - if (team.getName().equals(jsonTeam.get("Name").toString())) { - team.addEntry(player.getName()); + for (final Object rawPlayer : ((JSONArray) jsonTeam.get("players"))) { + final JSONObject jsonPlayer = (JSONObject) rawPlayer; + if (jsonPlayer.get("uuid").equals(player.getUniqueId().toString().replace("-", ""))) { + for (final Team team : this.teams) { + if (team.getName().equals(jsonTeam.get("name").toString())) { + team.addEntry(player.getName()); + } } } } @@ -127,26 +148,38 @@ public class TeamManager { final HashMap defaults = new HashMap(); final JSONObject team1 = new JSONObject(); - team1.put("Name", "Demo-Team"); - team1.put("Color", ChatColor.RED); - team1.put("Prefix", "DMO"); + team1.put("name", "Demo-Team"); + team1.put("color", ChatColor.RED); + team1.put("prefix", "DMO"); final JSONArray team1Players = new JSONArray(); - team1Players.add("a6019ccffe694bf780bcc3f3afa265dd"); - team1Players.add("069a79f444e94726a5befca90e38aaf5"); - team1.put("Players", team1Players); + final JSONObject player = new JSONObject(); + player.put("name", "AragurLP"); + player.put("uuid", "a6019ccffe694bf780bcc3f3afa265dd"); + player.put("discord", "99820967022329856"); + team1Players.add(player); + final JSONObject player2 = new JSONObject(); + player2.put("name", "Notch"); + player2.put("uuid", "069a79f444e94726a5befca90e38aaf5"); + player2.put("discord", ""); + team1Players.add(player2); + team1.put("players", team1Players); final JSONObject team2 = new JSONObject(); - team2.put("Name", "Demo-Team 2"); - team2.put("Color", ChatColor.GREEN); - team2.put("Prefix", "DM2"); + team2.put("name", "Demo-Team 2"); + team2.put("color", ChatColor.GREEN); + team2.put("prefix", "DM2"); final JSONArray team2Players = new JSONArray(); - team2Players.add("dff082fcd52d4ad2b2d8d8202aea53ec"); - team2.put("Players", team2Players); + final JSONObject player3 = new JSONObject(); + player3.put("name", "AragurTV"); + player3.put("uuid", "dff082fcd52d4ad2b2d8d8202aea53ec"); + player3.put("discord", "550794603754815520"); + team2Players.add(player3); + team2.put("players", team2Players); final JSONArray teams = new JSONArray(); teams.add(team1); teams.add(team2); - defaults.put("Teams", teams); + defaults.put("teams", teams); return defaults; } } \ No newline at end of file