mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-21 18:15:32 +01:00
Argument check and debug cleanup
This commit is contained in:
parent
92eac0e943
commit
94d55c3be7
@ -67,7 +67,7 @@ public class BukkitQuestadminFinishCommand extends BukkitQuestsSubCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender cs, String[] args) {
|
public void execute(CommandSender cs, String[] args) {
|
||||||
if (args.length == 1) {
|
if (args.length < 3) {
|
||||||
// Shows command usage
|
// Shows command usage
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ public class BukkitQuestadminGiveCommand extends BukkitQuestsSubCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender cs, String[] args) {
|
public void execute(CommandSender cs, String[] args) {
|
||||||
if (args.length == 1) {
|
if (args.length < 3) {
|
||||||
// Shows command usage
|
// Shows command usage
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ public class BukkitQuestadminGivepointsCommand extends BukkitQuestsSubCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender cs, String[] args) {
|
public void execute(CommandSender cs, String[] args) {
|
||||||
if (args.length == 1) {
|
if (args.length < 3) {
|
||||||
// Shows command usage
|
// Shows command usage
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,8 @@ public class BukkitQuestadminNextstageCommand extends BukkitQuestsSubCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender cs, String[] args) {
|
public void execute(CommandSender cs, String[] args) {
|
||||||
if (args.length == 1) {
|
if (args.length < 3) {
|
||||||
|
System.out.println(args.length);
|
||||||
// Shows command usage
|
// Shows command usage
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ public class BukkitQuestadminPointsCommand extends BukkitQuestsSubCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender cs, String[] args) {
|
public void execute(CommandSender cs, String[] args) {
|
||||||
if (args.length == 1) {
|
if (args.length < 3) {
|
||||||
// Shows command usage
|
// Shows command usage
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ public class BukkitQuestadminQuitCommand extends BukkitQuestsSubCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender cs, String[] args) {
|
public void execute(CommandSender cs, String[] args) {
|
||||||
if (args.length == 1) {
|
if (args.length < 3) {
|
||||||
// Shows command usage
|
// Shows command usage
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ public class BukkitQuestadminRemoveCommand extends BukkitQuestsSubCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender cs, String[] args) {
|
public void execute(CommandSender cs, String[] args) {
|
||||||
if (args.length == 1) {
|
if (args.length < 3) {
|
||||||
// Shows command usage
|
// Shows command usage
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ public class BukkitQuestadminSetstageCommand extends BukkitQuestsSubCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender cs, String[] args) {
|
public void execute(CommandSender cs, String[] args) {
|
||||||
if (args.length == 1) {
|
if (args.length < 4) {
|
||||||
// Shows command usage
|
// Shows command usage
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ public class BukkitQuestadminTakepointsCommand extends BukkitQuestsSubCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender cs, String[] args) {
|
public void execute(CommandSender cs, String[] args) {
|
||||||
if (args.length == 1) {
|
if (args.length < 3) {
|
||||||
// Shows command usage
|
// Shows command usage
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -3191,7 +3191,6 @@ public class BukkitQuester implements Quester {
|
|||||||
String message = formatCompletedObjectiveMessage("craftItem", goal.getAmount());
|
String message = formatCompletedObjectiveMessage("craftItem", goal.getAmount());
|
||||||
if (plugin.getConfigSettings().canTranslateNames() && !goal.hasItemMeta()
|
if (plugin.getConfigSettings().canTranslateNames() && !goal.hasItemMeta()
|
||||||
&& !goal.getItemMeta().hasDisplayName()) {
|
&& !goal.getItemMeta().hasDisplayName()) {
|
||||||
plugin.getLogger().info(goal.getType().name());
|
|
||||||
// Bukkit version is 1.9+
|
// Bukkit version is 1.9+
|
||||||
if (goal.getType().name().equals("TIPPED_ARROW")) {
|
if (goal.getType().name().equals("TIPPED_ARROW")) {
|
||||||
final String level = BukkitItemUtil.getPrettyPotionLevel(goal.getItemMeta());
|
final String level = BukkitItemUtil.getPrettyPotionLevel(goal.getItemMeta());
|
||||||
@ -3324,8 +3323,8 @@ public class BukkitQuester implements Quester {
|
|||||||
final String message = formatCompletedObjectiveMessage("killPlayer", goal.getAmount());
|
final String message = formatCompletedObjectiveMessage("killPlayer", goal.getAmount());
|
||||||
sendMessage(message);
|
sendMessage(message);
|
||||||
} else if (type.equals(ObjectiveType.TALK_TO_NPC)) {
|
} else if (type.equals(ObjectiveType.TALK_TO_NPC)) {
|
||||||
final String message = ChatColor.GREEN + "(" + BukkitLang.get(p, "completed") + ") "
|
final String message = formatCompletedObjectiveMessage("talkTo", goal.getAmount())
|
||||||
+ BukkitLang.get(p, "talkTo").replace("<npc>", plugin.getDependencies().getNpcName(npc));
|
.replace("<npc>", plugin.getDependencies().getNpcName(npc));
|
||||||
sendMessage(message);
|
sendMessage(message);
|
||||||
} else if (type.equals(ObjectiveType.KILL_NPC)) {
|
} else if (type.equals(ObjectiveType.KILL_NPC)) {
|
||||||
final String message = formatCompletedObjectiveMessage("kill", goal.getAmount());
|
final String message = formatCompletedObjectiveMessage("kill", goal.getAmount());
|
||||||
@ -3396,7 +3395,7 @@ public class BukkitQuester implements Quester {
|
|||||||
* @return Formatted message
|
* @return Formatted message
|
||||||
*/
|
*/
|
||||||
private String formatCompletedObjectiveMessage(final String langKey, final int goal) {
|
private String formatCompletedObjectiveMessage(final String langKey, final int goal) {
|
||||||
String message = ChatColor.GREEN + "(" + BukkitLang.get("completed") + ") " + BukkitLang.get(langKey);
|
String message = ChatColor.GREEN + "(" + BukkitLang.get(getPlayer(), "completed") + ") " + BukkitLang.get(langKey);
|
||||||
if (message.contains("<count>")) {
|
if (message.contains("<count>")) {
|
||||||
message = message.replace("<count>", goal + "/" + goal);
|
message = message.replace("<count>", goal + "/" + goal);
|
||||||
}
|
}
|
||||||
|
@ -788,8 +788,7 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
|
|||||||
@SuppressWarnings({ "unchecked", "unused"})
|
@SuppressWarnings({ "unchecked", "unused"})
|
||||||
private void loadQuestStages(final Quest quest, final FileConfiguration config, final String questKey)
|
private void loadQuestStages(final Quest quest, final FileConfiguration config, final String questKey)
|
||||||
throws StageFormatException, ActionFormatException, ConditionFormatException {
|
throws StageFormatException, ActionFormatException, ConditionFormatException {
|
||||||
final ConfigurationSection ordered = config.getConfigurationSection("quests." + questKey
|
final ConfigurationSection ordered = config.getConfigurationSection("quests." + questKey + ".stages.ordered");
|
||||||
+ ".stages.ordered");
|
|
||||||
if (ordered == null) {
|
if (ordered == null) {
|
||||||
plugin.getLogger().severe(ChatColor.RED + questKey + " must have at least one stage!");
|
plugin.getLogger().severe(ChatColor.RED + questKey + " must have at least one stage!");
|
||||||
return;
|
return;
|
||||||
|
@ -46,7 +46,7 @@ public class BukkitLang {
|
|||||||
private static Quests plugin;
|
private static Quests plugin;
|
||||||
private static final LinkedHashMap<String, String> defaultLang = new LinkedHashMap<>();
|
private static final LinkedHashMap<String, String> defaultLang = new LinkedHashMap<>();
|
||||||
private static final LinkedHashMap<String, LinkedHashMap<String, String>> otherLang = new LinkedHashMap<>();
|
private static final LinkedHashMap<String, LinkedHashMap<String, String>> otherLang = new LinkedHashMap<>();
|
||||||
private static final Pattern hexPattern = Pattern.compile("(?i)%#([0-9A-F]{6})%");
|
private static final Pattern hexPattern = Pattern.compile("(?i)%#([0-9a-fA-F]{6})%");
|
||||||
|
|
||||||
public static Collection<String> values() {
|
public static Collection<String> values() {
|
||||||
return defaultLang.values();
|
return defaultLang.values();
|
||||||
@ -393,8 +393,8 @@ public class BukkitLang {
|
|||||||
final StringBuilder hex = new StringBuilder();
|
final StringBuilder hex = new StringBuilder();
|
||||||
hex.append(ChatColor.COLOR_CHAR + "x");
|
hex.append(ChatColor.COLOR_CHAR + "x");
|
||||||
final char[] chars = matcher.group(1).toCharArray();
|
final char[] chars = matcher.group(1).toCharArray();
|
||||||
for (final char aChar : chars) {
|
for (final char c : chars) {
|
||||||
hex.append(ChatColor.COLOR_CHAR).append(Character.toLowerCase(aChar));
|
hex.append(ChatColor.COLOR_CHAR).append(Character.toLowerCase(c));
|
||||||
}
|
}
|
||||||
s = s.replace(matcher.group(), hex.toString());
|
s = s.replace(matcher.group(), hex.toString());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user