Hardening config cmd aliases and adding pageheight-aware pager.
This commit is contained in:
parent
e4da009bfc
commit
9a66c7ce2c
@ -6,6 +6,7 @@ permissions:
|
||||
# -------------------------------------------- #
|
||||
# THE REAL NODES
|
||||
# -------------------------------------------- #
|
||||
# usys command
|
||||
mcore.cmd.usys: {description: manage the universe system, default: false}
|
||||
mcore.cmd.usys.multiverse: {description: manage multiverses, default: false}
|
||||
mcore.cmd.usys.multiverse.list: {description: list multiverses, default: false}
|
||||
@ -21,6 +22,8 @@ permissions:
|
||||
mcore.cmd.usys.aspect.list: {description: list aspects, default: false}
|
||||
mcore.cmd.usys.aspect.show: {description: show aspect, default: false}
|
||||
mcore.cmd.usys.aspect.use: {description: set multiverse for aspect, default: false}
|
||||
# mcore command
|
||||
mcore.cmd.mcore: {description: use the mcore command, default: false}
|
||||
# -------------------------------------------- #
|
||||
# STAR NOTATION
|
||||
# -------------------------------------------- #
|
||||
@ -58,6 +61,7 @@ permissions:
|
||||
children:
|
||||
mcore.cmd.usys: true
|
||||
mcore.cmd.usys.*: true
|
||||
mcore.cmd.mcore: true
|
||||
mcore.*:
|
||||
default: false
|
||||
children:
|
||||
@ -80,3 +84,4 @@ permissions:
|
||||
mcore.cmd.usys.aspect: true
|
||||
mcore.cmd.usys.aspect.list: true
|
||||
mcore.cmd.usys.aspect.show: true
|
||||
mcore.cmd.mcore: true
|
@ -5,6 +5,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.massivecraft.mcore5.cmd.CmdMcore;
|
||||
import com.massivecraft.mcore5.usys.cmd.CmdUsys;
|
||||
import com.massivecraft.mcore5.util.MUtil;
|
||||
|
||||
@ -16,7 +17,22 @@ public class Conf extends SimpleConfig
|
||||
|
||||
public static String dburi = "gson://./mstore";
|
||||
public static String serverid = UUID.randomUUID().toString();
|
||||
public static Map<String, List<String>> cmdaliases = MUtil.map(CmdUsys.USYS, MUtil.list(CmdUsys.USYS));
|
||||
public static Map<String, List<String>> cmdaliases = MUtil.map(
|
||||
CmdUsys.USYS, MUtil.list(CmdUsys.USYS),
|
||||
CmdMcore.MCORE, MUtil.list(CmdMcore.MCORE)
|
||||
);
|
||||
|
||||
public static List<String> getCmdAliases(String name)
|
||||
{
|
||||
List<String> ret = cmdaliases.get(name);
|
||||
if (ret == null)
|
||||
{
|
||||
ret = MUtil.list(name);
|
||||
cmdaliases.put(name, ret);
|
||||
i.save();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// META
|
||||
|
@ -11,6 +11,7 @@ import com.massivecraft.mcore5.adapter.InventoryAdapter;
|
||||
import com.massivecraft.mcore5.adapter.ItemStackAdapter;
|
||||
import com.massivecraft.mcore5.adapter.MongoURIAdapter;
|
||||
import com.massivecraft.mcore5.adapter.PSAdapter;
|
||||
import com.massivecraft.mcore5.cmd.CmdMcore;
|
||||
import com.massivecraft.mcore5.store.Coll;
|
||||
import com.massivecraft.mcore5.store.Db;
|
||||
import com.massivecraft.mcore5.store.MStore;
|
||||
@ -81,6 +82,7 @@ public class MCore extends MPlugin
|
||||
|
||||
public InternalListener internalListener;
|
||||
public CmdUsys cmdUsys;
|
||||
public CmdMcore cmdMcore;
|
||||
|
||||
@Override
|
||||
public void onEnable()
|
||||
@ -113,6 +115,9 @@ public class MCore extends MPlugin
|
||||
this.cmdUsys = new CmdUsys();
|
||||
this.cmdUsys.register(true);
|
||||
|
||||
this.cmdMcore = new CmdMcore();
|
||||
this.cmdMcore.register(true);
|
||||
|
||||
this.postEnable();
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@ public enum Permission
|
||||
CMD_USYS_ASPECT_LIST("cmd.usys.aspect.list"),
|
||||
CMD_USYS_ASPECT_SHOW("cmd.usys.aspect.show"),
|
||||
CMD_USYS_ASPECT_USE("cmd.usys.aspect.use"),
|
||||
CMD_MCORE("cmd.mcore"),
|
||||
;
|
||||
|
||||
public final String node;
|
||||
|
30
src/com/massivecraft/mcore5/cmd/CmdMcore.java
Normal file
30
src/com/massivecraft/mcore5/cmd/CmdMcore.java
Normal file
@ -0,0 +1,30 @@
|
||||
package com.massivecraft.mcore5.cmd;
|
||||
|
||||
import com.massivecraft.mcore5.Conf;
|
||||
import com.massivecraft.mcore5.MCore;
|
||||
import com.massivecraft.mcore5.Permission;
|
||||
import com.massivecraft.mcore5.cmd.req.ReqHasPerm;
|
||||
|
||||
public class CmdMcore extends MCommand
|
||||
{
|
||||
public final static String MCORE = "mcore";
|
||||
|
||||
public CmdMcore()
|
||||
{
|
||||
this.addAliases(Conf.getCmdAliases(MCORE));
|
||||
this.addRequirements(ReqHasPerm.get(Permission.CMD_MCORE.node));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
this.msg("<i>You are running %s", MCore.p.getDescription().getFullName());
|
||||
this.msg("<i>The id of this server is \"<h>%s<i>\".", Conf.serverid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MCore p()
|
||||
{
|
||||
return MCore.p;
|
||||
}
|
||||
}
|
@ -18,7 +18,7 @@ public class CmdUsys extends UsysCommand
|
||||
{
|
||||
super();
|
||||
|
||||
this.addAliases(Conf.cmdaliases.get(USYS));
|
||||
this.addAliases(Conf.getCmdAliases(USYS));
|
||||
|
||||
this.addSubCommand(this.cmdUsysMultiverse);
|
||||
this.addSubCommand(this.cmdUsysUniverse);
|
||||
|
@ -207,8 +207,11 @@ public class PlayerUtil implements Listener
|
||||
// The player file may not exist yet
|
||||
if (playerfolder == null) return;
|
||||
|
||||
File[] playerfiles = playerfolder.listFiles();
|
||||
if (playerfiles == null) return;
|
||||
|
||||
// Populate by removing .dat
|
||||
for (File playerfile : playerfolder.listFiles())
|
||||
for (File playerfile : playerfiles)
|
||||
{
|
||||
String filename = playerfile.getName();
|
||||
String playername = filename.substring(0, filename.length()-4);
|
||||
|
@ -8,6 +8,8 @@ import java.util.regex.Pattern;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Txt
|
||||
{
|
||||
@ -15,6 +17,9 @@ public class Txt
|
||||
// STATIC
|
||||
// -------------------------------------------- //
|
||||
|
||||
public static final int PAGEHEIGHT_PLAYER = 9;
|
||||
public static final int PAGEHEIGHT_CONSOLE = 50;
|
||||
|
||||
public static final Map<String, String> parseReplacements;
|
||||
public static final Pattern parsePattern;
|
||||
|
||||
@ -31,19 +36,18 @@ public class Txt
|
||||
"a", "e", "i", "o", "u", "y", "å", "ä", "ö"
|
||||
);
|
||||
|
||||
public static Map<String, Long> unitMillis;
|
||||
public static final Map<String, Long> unitMillis = MUtil.map(
|
||||
"years", millisPerYear,
|
||||
"months", millisPerMonth,
|
||||
"weeks", millisPerWeek,
|
||||
"days", millisPerDay,
|
||||
"hours", millisPerHour,
|
||||
"minutes", millisPerMinute,
|
||||
"seconds", millisPerSecond
|
||||
);
|
||||
|
||||
static
|
||||
{
|
||||
unitMillis = new LinkedHashMap<String, Long>();
|
||||
unitMillis.put("years", millisPerYear);
|
||||
unitMillis.put("months", millisPerMonth);
|
||||
unitMillis.put("weeks", millisPerWeek);
|
||||
unitMillis.put("days", millisPerDay);
|
||||
unitMillis.put("hours", millisPerHour);
|
||||
unitMillis.put("minutes", millisPerMinute);
|
||||
unitMillis.put("seconds", millisPerSecond);
|
||||
|
||||
// Create the parce replacements map
|
||||
parseReplacements = new HashMap<String, String>();
|
||||
|
||||
@ -395,7 +399,21 @@ public class Txt
|
||||
|
||||
public static ArrayList<String> getPage(List<String> lines, int pageHumanBased, String title)
|
||||
{
|
||||
return getPage(lines, pageHumanBased, title, 9);
|
||||
return getPage(lines, pageHumanBased, title, PAGEHEIGHT_PLAYER);
|
||||
}
|
||||
|
||||
public static ArrayList<String> getPage(List<String> lines, int pageHumanBased, String title, CommandSender sender)
|
||||
{
|
||||
int pageheight;
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
pageheight = PAGEHEIGHT_PLAYER;
|
||||
}
|
||||
else
|
||||
{
|
||||
pageheight = PAGEHEIGHT_CONSOLE;
|
||||
}
|
||||
return getPage(lines, pageHumanBased, title, pageheight);
|
||||
}
|
||||
|
||||
public static ArrayList<String> getPage(List<String> lines, int pageHumanBased, String title, int pageheight)
|
||||
|
Loading…
Reference in New Issue
Block a user