From 12fbaa436163ddcd24067c063f4d73affb1717e0 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Sat, 3 Mar 2012 09:54:16 -0800 Subject: [PATCH] Wip of Skill Help pages, code is ugly but it works. --- .../commands/skills/ExcavationCommand.java | 19 +++++-- .../java/com/gmail/nossr50/util/Page.java | 53 +++++++++++++++++++ .../resources/locale/locale_en_us.properties | 3 +- 3 files changed, 69 insertions(+), 6 deletions(-) create mode 100644 src/main/java/com/gmail/nossr50/util/Page.java diff --git a/src/main/java/com/gmail/nossr50/commands/skills/ExcavationCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/ExcavationCommand.java index f0b4bed3d..e6c97d4c9 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/ExcavationCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/ExcavationCommand.java @@ -7,11 +7,13 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.gmail.nossr50.Users; +import com.gmail.nossr50.m; import com.gmail.nossr50.mcPermissions; import com.gmail.nossr50.config.LoadProperties; import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.locale.mcLocale; +import com.gmail.nossr50.util.Page; public class ExcavationCommand implements CommandExecutor { @Override @@ -49,9 +51,15 @@ public class ExcavationCommand implements CommandExecutor { { if(args[0].equals("?")) { - if(args[1].equals("1")) + Page.clearChat(player); + if(args.length > 1 && m.isInt(args[1])) { - player.sendMessage("==EXCAVATION=="); + for(String target : Page.grabPageContents("Excavation Guide", "Guides.Excavation", m.getInt(args[1]))) + { + player.sendMessage(target); + } + + /* player.sendMessage(""); player.sendMessage("==XP Gain=="); player.sendMessage("Base XP: " + LoadProperties.mbase); @@ -71,16 +79,17 @@ public class ExcavationCommand implements CommandExecutor { player.sendMessage(ChatColor.GRAY + "Items found vary depending on skill level."); player.sendMessage(""); player.sendMessage("==PAGE 1 of 1=="); + */ + } else if(args.length > 1 && !m.isInt(args[1])) + { + player.sendMessage("Not a valid page number!"); } - } else { player.sendMessage(ChatColor.RED + "Usage is /excavation ? [page]"); } - } - return true; } } diff --git a/src/main/java/com/gmail/nossr50/util/Page.java b/src/main/java/com/gmail/nossr50/util/Page.java new file mode 100644 index 000000000..34b2d34b2 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/util/Page.java @@ -0,0 +1,53 @@ +package com.gmail.nossr50.util; + +import java.util.ArrayList; + +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.locale.mcLocale; + +public class Page { + public static ArrayList grabPageContents(String header, String address, int pagenum) + { + int pageIndexStart = 0; + + //Determine what string to start at + if(pagenum > 1) + { + pageIndexStart = 8*(pagenum-1); + } + + ArrayList allStrings = new ArrayList(); + String[] addressSplit = mcLocale.getString(address).split("\n"); + + allStrings.add(ChatColor.GOLD+"-="+ChatColor.GREEN+header+ChatColor.GOLD+"=-"); //So stylish + + //Add targeted strings + while(allStrings.size() < 9) + { + allStrings.add(addressSplit[pageIndexStart+allStrings.size()-1]); + } + + int totalPages = 1; + + if(addressSplit.length >= 8) + { + totalPages = (addressSplit.length/8)+1; + } + + allStrings.add("Page "+pagenum+" of "+totalPages); + return allStrings; + } + + public static void clearChat(Player player) + { + //Extremely ugly way of making the screen clear up + int x = 0; + while(x < 20) + { + player.sendMessage(""); + x++; + } + } +} diff --git a/src/main/resources/locale/locale_en_us.properties b/src/main/resources/locale/locale_en_us.properties index f84a60877..6aa5f7ecc 100644 --- a/src/main/resources/locale/locale_en_us.properties +++ b/src/main/resources/locale/locale_en_us.properties @@ -415,4 +415,5 @@ Skills.GigaDrillBreakerPlayerOff=[[RED]]Giga Drill Breaker[[GREEN]] has worn off Skills.SerratedStrikesPlayerOff=[[RED]]Serrated Strikes[[GREEN]] has worn off for [[YELLOW]]{0} Skills.BlastMiningPlayer=[[GREEN]]{0}[[DARK_GREEN]] has used [[RED]]Blast Mining! Skills.YourBlastMining=[[GREEN]]Your [[YELLOW]]Blast Mining [[GREEN]]ability is refreshed! -TreeFeller.AxeSplinters=[[RED]]YOUR AXE SPLINTERS INTO DOZENS OF PIECES \ No newline at end of file +TreeFeller.AxeSplinters=[[RED]]YOUR AXE SPLINTERS INTO DOZENS OF PIECES +Guides.Excavation=XP GAIN:\n\nGain XP from soft materials with your shovel.\nMaterials include Grass, Dirt, Sand,\nGravel, Mycelium, and Clay\nTHIS IS PROOF\nOF CONCEPT\nTHIS IS PROOF\nOF CONCEPT\nTHIS IS PROOF\nOF CONCEPT\nTHIS IS PROOF\nOF CONCEPT\nTHIS IS PROOF\nOF CONCEPT\nTHIS IS PROOF\nOF CONCEPT\nTHIS IS PROOF\nOF CONCEPT\nTHIS IS PROOF\nOF CONCEPT\nTHIS IS PROOF\nOF CONCEPT\nTHIS IS PROOF\nOF CONCEPT\nTHIS IS PROOF\nOF CONCEPT\nTHIS IS PROOF\nOF CONCEPT\nTHIS IS PROOF\nOF CONCEPT\nTHIS IS PROOF\nOF CONCEPT\nTHIS IS PROOF\nOF CONCEPT\nTHIS IS PROOF\nOF CONCEPT\nTHIS IS PROOF\nOF CONCEPT\nTHIS IS PROOF\nOF CONCEPT\nTHIS IS PROOF\nOF CONCEPT\nTHIS IS PROOF\nOF CONCEPT\nTHIS IS PROOF\nOF CONCEPT\nTHIS IS PROOF\nOF CONCEPT \ No newline at end of file