mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-25 02:04:44 +02:00
Wip of Skill Help pages, code is ugly but it works.
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
||||
|
53
src/main/java/com/gmail/nossr50/util/Page.java
Normal file
53
src/main/java/com/gmail/nossr50/util/Page.java
Normal file
@ -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<String> grabPageContents(String header, String address, int pagenum)
|
||||
{
|
||||
int pageIndexStart = 0;
|
||||
|
||||
//Determine what string to start at
|
||||
if(pagenum > 1)
|
||||
{
|
||||
pageIndexStart = 8*(pagenum-1);
|
||||
}
|
||||
|
||||
ArrayList<String> allStrings = new ArrayList<String>();
|
||||
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++;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user