creative scoreboard team. and fixed npe in tutorials

This commit is contained in:
NewGarbo 2015-11-28 09:20:42 +00:00
parent 0dceca5cfc
commit d8ae035f84
4 changed files with 49 additions and 6 deletions

View File

@ -116,4 +116,12 @@ public enum Rank
{
return _donor;
}
public String getRawTag()
{
if (Name.equalsIgnoreCase("ALL"))
return "";
return Name;
}
}

View File

@ -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);
}
}

View File

@ -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)

View File

@ -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));
}
}
}
}
}