Code cleanup

This commit is contained in:
BuildTools 2019-01-02 14:02:22 -05:00
parent 5e0fa7e219
commit bbfbc6a98b

View File

@ -111,19 +111,19 @@ public class PlayerListener implements Listener {
if (ItemUtil.compareItems(clicked, quest.guiDisplay, false) == 0) { if (ItemUtil.compareItems(clicked, quest.guiDisplay, false) == 0) {
if (quester.currentQuests.size() >= plugin.maxQuests && plugin.maxQuests > 0) { if (quester.currentQuests.size() >= plugin.maxQuests && plugin.maxQuests > 0) {
String msg = Lang.get(player, "questMaxAllowed"); String msg = Lang.get(player, "questMaxAllowed");
msg = msg.replaceAll("<number>", String.valueOf(plugin.maxQuests)); msg = msg.replace("<number>", String.valueOf(plugin.maxQuests));
player.sendMessage(ChatColor.YELLOW + msg); player.sendMessage(ChatColor.YELLOW + msg);
} else if (quester.completedQuests.contains(quest.getName()) && quest.cooldownPlanner < 0) { } else if (quester.completedQuests.contains(quest.getName()) && quest.cooldownPlanner < 0) {
String completed = Lang.get(player, "questAlreadyCompleted"); String completed = Lang.get(player, "questAlreadyCompleted");
completed = completed.replaceAll("<quest>", ChatColor.AQUA + quest.getName() + ChatColor.YELLOW); completed = completed.replace("<quest>", ChatColor.AQUA + quest.getName() + ChatColor.YELLOW);
player.sendMessage(ChatColor.YELLOW + completed); player.sendMessage(ChatColor.YELLOW + completed);
} else { } else {
boolean takeable = true; boolean takeable = true;
if (quester.completedQuests.contains(quest.getName())) { if (quester.completedQuests.contains(quest.getName())) {
if (quester.getDifference(quest) > 0) { if (quester.getDifference(quest) > 0) {
String early = Lang.get(player, "questTooEarly"); String early = Lang.get(player, "questTooEarly");
early = early.replaceAll("<quest>", ChatColor.AQUA + quest.getName() + ChatColor.YELLOW); early = early.replace("<quest>", ChatColor.AQUA + quest.getName() + ChatColor.YELLOW);
early = early.replaceAll("<time>", ChatColor.DARK_PURPLE + Quests.getTime(quester.getDifference(quest)) + ChatColor.YELLOW); early = early.replace("<time>", ChatColor.DARK_PURPLE + Quests.getTime(quester.getDifference(quest)) + ChatColor.YELLOW);
player.sendMessage(ChatColor.YELLOW + early); player.sendMessage(ChatColor.YELLOW + early);
takeable = false; takeable = false;
} }
@ -142,7 +142,7 @@ public class PlayerListener implements Listener {
} }
if (inRegion == false) { if (inRegion == false) {
String invalidLoc = Lang.get(player, "questInvalidLocation"); String invalidLoc = Lang.get(player, "questInvalidLocation");
invalidLoc = invalidLoc.replaceAll("<quest>", ChatColor.AQUA + quest.getName() + ChatColor.YELLOW); invalidLoc = invalidLoc.replace("<quest>", ChatColor.AQUA + quest.getName() + ChatColor.YELLOW);
player.sendMessage(ChatColor.YELLOW + invalidLoc); player.sendMessage(ChatColor.YELLOW + invalidLoc);
takeable = false; takeable = false;
} }
@ -256,19 +256,19 @@ public class PlayerListener implements Listener {
if (q.blockStart.equals(evt.getClickedBlock().getLocation())) { if (q.blockStart.equals(evt.getClickedBlock().getLocation())) {
if (quester.currentQuests.size() >= plugin.maxQuests && plugin.maxQuests > 0) { if (quester.currentQuests.size() >= plugin.maxQuests && plugin.maxQuests > 0) {
String msg = Lang.get(player, "questMaxAllowed"); String msg = Lang.get(player, "questMaxAllowed");
msg = msg.replaceAll("<number>", String.valueOf(plugin.maxQuests)); msg = msg.replace("<number>", String.valueOf(plugin.maxQuests));
player.sendMessage(ChatColor.YELLOW + msg); player.sendMessage(ChatColor.YELLOW + msg);
} else { } else {
if (quester.completedQuests.contains(q.getName())) { if (quester.completedQuests.contains(q.getName())) {
if (q.cooldownPlanner > -1 && (quester.getDifference(q)) > 0) { if (q.cooldownPlanner > -1 && (quester.getDifference(q)) > 0) {
String early = Lang.get(player, "questTooEarly"); String early = Lang.get(player, "questTooEarly");
early = early.replaceAll("<quest>", ChatColor.AQUA + q.getName() + ChatColor.YELLOW); early = early.replace("<quest>", ChatColor.AQUA + q.getName() + ChatColor.YELLOW);
early = early.replaceAll("<time>", ChatColor.DARK_PURPLE + Quests.getTime(quester.getDifference(q)) + ChatColor.YELLOW); early = early.replace("<time>", ChatColor.DARK_PURPLE + Quests.getTime(quester.getDifference(q)) + ChatColor.YELLOW);
player.sendMessage(ChatColor.YELLOW + early); player.sendMessage(ChatColor.YELLOW + early);
return; return;
} else if (quester.completedQuests.contains(q.getName()) && q.cooldownPlanner < 0) { } else if (quester.completedQuests.contains(q.getName()) && q.cooldownPlanner < 0) {
String completed = Lang.get(player, "questAlreadyCompleted"); String completed = Lang.get(player, "questAlreadyCompleted");
completed = completed.replaceAll("<quest>", ChatColor.AQUA + q.getName() + ChatColor.YELLOW); completed = completed.replace("<quest>", ChatColor.AQUA + q.getName() + ChatColor.YELLOW);
player.sendMessage(ChatColor.YELLOW + completed); player.sendMessage(ChatColor.YELLOW + completed);
return; return;
} }
@ -500,9 +500,7 @@ public class PlayerListener implements Listener {
} }
/** /**
* Checks if damager is blacklisted. * Checks if damager is blacklisted. Ensures damager is Player and not NPC. Kills target mob/NPC if objective exists
* Ensures damager is Player and not NPC.
* Kills target mob/NPC if objective exists
* *
* @param damager the attacking entity * @param damager the attacking entity
* @param target the entity being attacked * @param target the entity being attacked
@ -594,9 +592,7 @@ public class PlayerListener implements Listener {
} }
/** /**
* Checks if damager is blacklisted * Checks if damager is blacklisted. Ensures damager is Player and not NPC. Kills target Player if objective exists
* Ensures damager is Player and not NPC
* Kills target Player if objective exists
* *
* @param damager the attacking entity * @param damager the attacking entity
* @param target the entity being attacked * @param target the entity being attacked