From d8ae035f846947724c88338812f74882e804a813 Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Sat, 28 Nov 2015 09:20:42 +0000 Subject: [PATCH] creative scoreboard team. and fixed npe in tutorials --- .../src/mineplex/core/common/Rank.java | 8 +++++ .../mineplex/core/common/util/UtilText.java | 4 +++ .../scoreboard/ClansPlayerScoreboard.java | 11 +++---- .../game/clans/tutorials/TutorialClient.java | 32 +++++++++++++++++++ 4 files changed, 49 insertions(+), 6 deletions(-) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialClient.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java index 45fd28921..9eeda0347 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java @@ -116,4 +116,12 @@ public enum Rank { return _donor; } + + public String getRawTag() + { + if (Name.equalsIgnoreCase("ALL")) + return ""; + + return Name; + } } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java index d5c8f563e..8bbac15bc 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java @@ -106,4 +106,8 @@ public class UtilText { return x <= 0 ? true : x > 1; } + public static String trim(int maxLength, String s) { + return s.length() <= maxLength ? s : s.substring(0, maxLength); + } + } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansPlayerScoreboard.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansPlayerScoreboard.java index 21709202d..74748387b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansPlayerScoreboard.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansPlayerScoreboard.java @@ -1,6 +1,7 @@ package mineplex.game.clans.clans.scoreboard; import org.bukkit.Bukkit; +import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.entity.Player; import org.bukkit.scoreboard.DisplaySlot; @@ -11,6 +12,7 @@ import org.bukkit.scoreboard.Team; import net.minecraft.server.v1_8_R3.ScoreboardTeam; import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilText; import mineplex.core.scoreboard.PlayerScoreboard; import mineplex.core.scoreboard.ScoreboardManager; import mineplex.game.clans.clans.ClanInfo; @@ -76,17 +78,14 @@ public class ClansPlayerScoreboard extends PlayerScoreboard { if (otherPlayer.getGameMode().equals(GameMode.CREATIVE)) { - String teamName = getTeamName(clanInfo, relation, ownScore); + String teamName = UtilText.trim(16, _clansManager.getClientManager().Get(otherPlayer).GetRank().getRawTag() + "CREATIVE"); Team team = scoreboard.getTeam(teamName); if (team == null) { team = scoreboard.registerNewTeam(teamName); - if (clanInfo != null) - team.setPrefix(relation.getColor(true) + clanInfo.getName() + relation.getColor(false) + " "); - else - team.setPrefix(relation.getColor(false).toString()); + team.setPrefix(UtilText.trim(16, _clansManager.getClientManager().Get(otherPlayer).GetRank().getTag(true, true) + ChatColor.RESET + " ")); + team.setSuffix(C.cRed + " CREATIVE"); } - Objective domObjective; if ((domObjective = scoreboard.getObjective(DisplaySlot.BELOW_NAME)) == null) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialClient.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialClient.java new file mode 100644 index 000000000..5229aaf24 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialClient.java @@ -0,0 +1,32 @@ +package mineplex.game.clans.tutorials; + +import org.bukkit.entity.Player; + +import mineplex.core.task.TaskManager; + +public class TutorialClient +{ + public Player Player; + public TutorialTask CurrentTask; + public long LastDescriptionSentTime = 0; + + public TutorialClient(Player player, Tutorial tutorial) + { + Player = player; + + CurrentTask = tutorial._tasks.get(1); + + for (TutorialTask task : tutorial._tasks.values()) + { + if (TaskManager.Instance.hasCompletedTask(player, String.format( + Tutorial.TASK_COMPLETE_TASK, + task.getTutorial().getTechnicalName(), task.getTechnicalName()))) + { + if (CurrentTask.getID() <= task.getID()) + { + CurrentTask = task.getTutorial().getTasks().get(Math.min(task.getTutorial().getTasks().size(), task.getID() + 1)); + } + } + } + } +}