Code: package me.davidml.zaphyffa.Managers.scoreboard; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.scoreboard.DisplaySlot; import org.bukkit.scoreboard.Objective; import org.bukkit.scoreboard.Scoreboard; import org.bukkit.scoreboard.Team; import me.davidml.zaphyffa.Arena.CombatManager; import me.davidml.zaphyffa.Economy.Balance; import me.davidml.zaphyffa.Economy.Level; import me.davidml.zaphyffa.Events.PlayerStreak; import me.davidml.zaphyffa.Managers.Methods; import me.davidml.zaphyffa.Managers.RomanNumeral; public class PlayerScoreboard { private Methods methods = new Methods(); private CombatManager combatManager = new CombatManager(); private PlayerStreak playerStreak = new PlayerStreak(); private Player p; private List<String> placeholders = Arrays.asList( new String[] { "%day%", "%month%", "%year%", "%prestige%", "%level%", "%neededxp%", "%gold%", "%status%", "%streak%" }); private static List<PlayerScoreboard> scoreboards = new ArrayList<PlayerScoreboard>(); private HashMap<Team, String> refresh = new HashMap<Team, String>(); private Scoreboard scoreboard; private Objective obj; private String title; public PlayerScoreboard(Player paramPlayer, String paramString, List<String> paramList) { this.p = paramPlayer; this.title = paramString; this.scoreboard = Bukkit.getScoreboardManager().getNewScoreboard(); this.obj = this.scoreboard.registerNewObjective("Scoreboard", "dummy"); this.obj.setDisplaySlot(DisplaySlot.SIDEBAR); setStrings(paramList); paramPlayer.setScoreboard(this.scoreboard); scoreboards.add(this); } private void setStrings(List<String> paramList) { for (Team localTeam1 : this.scoreboard.getTeams()) { localTeam1.unregister(); } this.refresh.clear(); this.obj.setDisplayName(this.title); int i = 0; Level pL = new Level(this.p); for (int j = paramList.size(); j > 0; j--) { Team localTeam2 = this.scoreboard.registerNewTeam("Line-" + j); localTeam2.addEntry(ChatColor.values()[(j - 1)].toString()); this.obj.getScore(ChatColor.values()[(j - 1)].toString()).setScore(i); i++; String str1 = (String) paramList.get(j - 1); for (String str2 : this.placeholders) { if ((!str1.contains(str2)) || (this.refresh.containsKey(localTeam2))) { this.refresh.put(localTeam2, str1); } } setContent(localTeam2, str1.replace("%day%", String.valueOf(this.methods.getDay())) .replace("%month%", String.valueOf(this.methods.getMonth())) .replace("%year%", String.valueOf(this.methods.getYear())) .replace("%prestige%", String.valueOf(RomanNumeral.c(pL.getPrestige()))) .replace("%level%", String.valueOf(pL.getLevel())) .replace("%neededxp%", String.valueOf(pL.getNeededXP())) .replace("%gold%", String.valueOf(new Balance(this.p).getBalance())) .replace("%status%", this.combatManager.getStatus(this.p)) .replace("%streak%", this.playerStreak.getStreak(this.p))); } } private void setContent(Team paramTeam, String paramString) { if (paramString.length() >= 16) { String str2 = paramString.substring(0, 16); String str1; if ((str2.endsWith("&")) || (str2.endsWith("§"))) { str2 = str2.substring(0, str2.length() - 1); str1 = paramString.substring(str2.length(), paramString.length()); } else if ((str2.substring(0, 15).endsWith("&")) || (str2.substring(0, 15).endsWith("§"))) { str2 = str2.substring(0, str2.length() - 2); str1 = paramString.substring(str2.length(), paramString.length()); } else { str1 = ChatColor.getLastColors(str2) + paramString.substring(str2.length(), paramString.length()); } if (str1.length() > 16) { str1 = str1.substring(0, 16); } paramTeam.setPrefix(str2); paramTeam.setSuffix(str1); } else { paramTeam.setPrefix(paramString); paramTeam.setSuffix(""); } } public void refresh() { if (Bukkit.getOnlinePlayers().size() != 0) { Level pL = new Level(this.p); pL.checkLevel(); for (Map.Entry<Team, String> localEntry : this.refresh.entrySet()) { setContent((Team) localEntry.getKey(), ((String) localEntry.getValue()).replace("%day%", String.valueOf(this.methods.getDay())) .replace("%month%", String.valueOf(this.methods.getMonth())) .replace("%year%", String.valueOf(this.methods.getYear())) .replace("%prestige%", String.valueOf(RomanNumeral.c(pL.getPrestige()))) .replace("%level%", String.valueOf(pL.getLevel())) .replace("%neededxp%", String.valueOf(pL.getNeededXP())) .replace("%gold%", String.valueOf(new Balance(this.p).getBalance())) .replace("%status%", this.combatManager.getStatus(this.p)) .replace("%streak%", this.playerStreak.getStreak(this.p))); } } } public void remove() { this.p.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard()); if(scoreboards.contains(this)) { scoreboards.remove(this); } } public static List<PlayerScoreboard> getScoreboards() { return scoreboards; } } Code: [18:40:13] [Server thread/ERROR]: Encountered an unexpected exception net.minecraft.server.v1_8_R3.ReportedException: Exception ticking world at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:781) ~[spigot.jar:git-Spigot-21fe707-e1ebe52] at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) ~[spigot.jar:git-Spigot-21fe707-e1ebe52] at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) ~[spigot.jar:git-Spigot-21fe707-e1ebe52] at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot.jar:git-Spigot-21fe707-e1ebe52] at java.lang.Thread.run(Unknown Source) [?:1.8.0_181] Caused by: java.lang.OutOfMemoryError: GC overhead limit exceeded at net.minecraft.server.v1_8_R3.BlockPosition.a(SourceFile:58) ~[spigot.jar:git-Spigot-21fe707-e1ebe52] at net.minecraft.server.v1_8_R3.BlockGrass.b(BlockGrass.java:49) ~[spigot.jar:git-Spigot-21fe707-e1ebe52] at net.minecraft.server.v1_8_R3.Block.a(Block.java:299) ~[spigot.jar:git-Spigot-21fe707-e1ebe52] at net.minecraft.server.v1_8_R3.WorldServer.h(WorldServer.java:495) ~[spigot.jar:git-Spigot-21fe707-e1ebe52] at net.minecraft.server.v1_8_R3.WorldServer.doTick(WorldServer.java:253) ~[spigot.jar:git-Spigot-21fe707-e1ebe52] at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:770) ~[spigot.jar:git-Spigot-21fe707-e1ebe52] ... 4 more [18:40:16] [Server thread/ERROR]: Cause of unexpected exception was java.lang.OutOfMemoryError: GC overhead limit exceeded at net.minecraft.server.v1_8_R3.BlockPosition.a(SourceFile:58) ~[spigot.jar:git-Spigot-21fe707-e1ebe52] at net.minecraft.server.v1_8_R3.BlockGrass.b(BlockGrass.java:49) ~[spigot.jar:git-Spigot-21fe707-e1ebe52] at net.minecraft.server.v1_8_R3.Block.a(Block.java:299) ~[spigot.jar:git-Spigot-21fe707-e1ebe52] at net.minecraft.server.v1_8_R3.WorldServer.h(WorldServer.java:495) ~[spigot.jar:git-Spigot-21fe707-e1ebe52] at net.minecraft.server.v1_8_R3.WorldServer.doTick(WorldServer.java:253) ~[spigot.jar:git-Spigot-21fe707-e1ebe52] at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:770) ~[spigot.jar:git-Spigot-21fe707-e1ebe52] at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) ~[spigot.jar:git-Spigot-21fe707-e1ebe52] at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) ~[spigot.jar:git-Spigot-21fe707-e1ebe52] at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot.jar:git-Spigot-21fe707-e1ebe52] at java.lang.Thread.run(Unknown Source) [?:1.8.0_181] [18:40:19] [Craft Scheduler Thread - 36/WARN]: Exception in thread "Craft Scheduler Thread - 36" [18:40:21] [Craft Scheduler Thread - 36/WARN]: org.apache.commons.lang.UnhandledException: Plugin ZaphyFFA v2.0 generated an exception while executing task 97 at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:56) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.OutOfMemoryError: GC overhead limit exceeded at java.util.regex.Pattern.compile(Unknown Source) at java.lang.String.replace(Unknown Source) at me.davidml.zaphyffa.Managers.scoreboard.PlayerScoreboard.refresh(PlayerScoreboard.java:116) at me.davidml.zaphyffa.Main$2.run(Main.java:399) at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftTask.run(CraftTask.java:71) at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:53) ... 3 more
@HimahoYT Your running out of memory. If you bought the server through a hosting company, you may need to buy more ram space. If the server is on your computer, you should check to make sure you are not limiting the amount of RAM the server has access to.
The server is in my computer, I have assigned to the server 2GB and I see with a plugin, the memory usage of my pluginis incrementing every time with the class code I put.
@HimahoYT Could you tell us how many times all method are being called? We should probably take a closer look at the one that occurs the most. You could experiment a bit with putting a // for some lines and see what happens with the memory useage.
@HimahoYT If I understand everything you said correctly, you know that the memory useage of your plug-in is incrementing every time. It sounds like you are measuring the memory useage some way. If I didn't understand it correctly, it might be a good idea to provide a little more explanation of what you know and how often your refresh method is being called.