This is 6.9.0, now with fully dynamic command registration.

This commit is contained in:
Olof Larsson 2013-11-11 09:21:16 +01:00
parent 4b03dd4e2b
commit 86db5a6bdd
90 changed files with 1030 additions and 501 deletions

View File

@ -1,6 +1,6 @@
main: com.massivecraft.mcore.MCore main: com.massivecraft.mcore.MCore
name: mcore name: mcore
version: 6.8.1 version: 6.9.0
website: http://massivecraft.com/mcore website: http://massivecraft.com/mcore
authors: [Cayorion] authors: [Cayorion]
description: §eMCore stands for MassiveCraft Core and is a plugin that contains libraries and features that other plugins make use of. §aCayorion §efrom the minecraft server §aMassiveCraft §eis the lead programmer. Feel free to visit us at §bhttp://massivecraft.com description: §eMCore stands for MassiveCraft Core and is a plugin that contains libraries and features that other plugins make use of. §aCayorion §efrom the minecraft server §aMassiveCraft §eis the lead programmer. Feel free to visit us at §bhttp://massivecraft.com

View File

@ -45,4 +45,5 @@ public class AspectColl extends Coll<Aspect>
} }
return ret; return ret;
} }
} }

View File

@ -1,12 +1,10 @@
package com.massivecraft.mcore; package com.massivecraft.mcore;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import com.massivecraft.mcore.util.MUtil; import com.massivecraft.mcore.util.MUtil;
public class ConfServer extends SimpleConfig public class ConfServer extends SimpleConfig
{ {
// -------------------------------------------- // // -------------------------------------------- //
@ -23,16 +21,12 @@ public class ConfServer extends SimpleConfig
public static String serverid = UUID.randomUUID().toString(); public static String serverid = UUID.randomUUID().toString();
public static String dburi = "default";
public static Map<String, String> alias2uri = MUtil.map( public static Map<String, String> alias2uri = MUtil.map(
"default", "flatfile", "default", "flatfile",
"flatfile", "flatfile://mstore", "flatfile", "flatfile://mstore",
"mongodb", "mongodb://localhost:27017/mstore" "mongodb", "mongodb://localhost:27017/mstore"
); );
public static String dburi = "default";
public static List<String> aliasesOuterMCore = MUtil.list("mcore");
public static List<String> aliasesOuterMCoreUsys = MUtil.list("usys");
public static List<String> aliasesOuterMCoreMStore = MUtil.list("mstore");
} }

View File

@ -100,5 +100,4 @@ public class Couple<A, B> implements Entry<A, B>, Cloneable, Serializable
return this; return this;
} }
} }

View File

@ -0,0 +1,16 @@
package com.massivecraft.mcore;
import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin;
public interface Engine extends Listener, Runnable
{
public Plugin getPlugin();
public void activate();
public void deactivate();
public Long getDelay();
public Long getPeriod();
public Integer getTaskId();
}

View File

@ -0,0 +1,58 @@
package com.massivecraft.mcore;
import org.bukkit.Bukkit;
import org.bukkit.event.HandlerList;
public abstract class EngineAbstract implements Engine
{
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
private Integer taskId;
@Override public Integer getTaskId() { return this.taskId; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void activate()
{
Bukkit.getPluginManager().registerEvents(this, this.getPlugin());
if (this.getPeriod() != null)
{
this.taskId = Bukkit.getScheduler().scheduleSyncRepeatingTask(this.getPlugin(), this, this.getDelay(), this.getPeriod());
}
}
@Override
public void deactivate()
{
HandlerList.unregisterAll(this);
if (this.getTaskId() != null)
{
Bukkit.getScheduler().cancelTask(this.getTaskId());
this.taskId = null;
}
}
@Override
public Long getDelay()
{
return 0L;
}
@Override
public Long getPeriod()
{
return null;
}
@Override
public void run()
{
}
}

View File

@ -11,7 +11,6 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByBlockEvent; import org.bukkit.event.entity.EntityDamageByBlockEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.AsyncPlayerChatEvent;
@ -22,6 +21,7 @@ import org.bukkit.event.player.PlayerChatTabCompleteEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.plugin.Plugin;
import com.massivecraft.mcore.event.MCoreAfterPlayerRespawnEvent; import com.massivecraft.mcore.event.MCoreAfterPlayerRespawnEvent;
import com.massivecraft.mcore.event.MCoreAfterPlayerTeleportEvent; import com.massivecraft.mcore.event.MCoreAfterPlayerTeleportEvent;
@ -36,23 +36,30 @@ import com.massivecraft.mcore.store.SenderColl;
import com.massivecraft.mcore.util.SenderUtil; import com.massivecraft.mcore.util.SenderUtil;
import com.massivecraft.mcore.util.SmokeUtil; import com.massivecraft.mcore.util.SmokeUtil;
public class InternalListener implements Listener public class EngineMainMCore extends EngineAbstract
{ {
// -------------------------------------------- // // -------------------------------------------- //
// INSTANCE & CONSTRUCT // INSTANCE & CONSTRUCT
// -------------------------------------------- // // -------------------------------------------- //
private static InternalListener i = new InternalListener(); private static EngineMainMCore i = new EngineMainMCore();
public static InternalListener get() { return i; } public static EngineMainMCore get() { return i; }
// -------------------------------------------- // // -------------------------------------------- //
// REGISTER // OVERRIDE
// -------------------------------------------- // // -------------------------------------------- //
public void setup() @Override
public Plugin getPlugin()
{ {
return MCore.get();
}
@Override
public void activate()
{
super.activate();
MCorePlayerLeaveEvent.player2event.clear(); MCorePlayerLeaveEvent.player2event.clear();
Bukkit.getPluginManager().registerEvents(this, MCore.get());
} }
// -------------------------------------------- // // -------------------------------------------- //
@ -315,4 +322,5 @@ public class InternalListener implements Listener
pcoll.syncId(playerName); pcoll.syncId(playerName);
} }
} }
} }

View File

@ -7,9 +7,9 @@ import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerLoginEvent.Result; import org.bukkit.event.player.PlayerLoginEvent.Result;
import org.bukkit.plugin.Plugin;
import com.massivecraft.mcore.util.MUtil; import com.massivecraft.mcore.util.MUtil;
import com.massivecraft.mcore.util.Txt; import com.massivecraft.mcore.util.Txt;
@ -35,7 +35,7 @@ import com.massivecraft.mcore.util.Txt;
* After that you get kicked when using an incorrect casing. * After that you get kicked when using an incorrect casing.
* *
*/ */
public class EngineOfflineCase implements Listener public class EngineOfflineCase extends EngineAbstract
{ {
// -------------------------------------------- // // -------------------------------------------- //
// INSTANCE & CONSTRUCT // INSTANCE & CONSTRUCT
@ -45,11 +45,20 @@ public class EngineOfflineCase implements Listener
public static EngineOfflineCase get() { return i; } public static EngineOfflineCase get() { return i; }
// -------------------------------------------- // // -------------------------------------------- //
// SETUP // OVERRIDE
// -------------------------------------------- // // -------------------------------------------- //
public void setup() @Override
public Plugin getPlugin()
{ {
return MCore.get();
}
@Override
public void activate()
{
super.activate();
this.lowerToCorrect.clear(); this.lowerToCorrect.clear();
for (Player player : Bukkit.getOnlinePlayers()) for (Player player : Bukkit.getOnlinePlayers())
@ -61,8 +70,6 @@ public class EngineOfflineCase implements Listener
{ {
this.registerCase(pdname); this.registerCase(pdname);
} }
Bukkit.getPluginManager().registerEvents(this, MCore.get());
} }
// -------------------------------------------- // // -------------------------------------------- //
@ -71,10 +78,6 @@ public class EngineOfflineCase implements Listener
private Map<String, String> lowerToCorrect = new HashMap<String, String>(); private Map<String, String> lowerToCorrect = new HashMap<String, String>();
// -------------------------------------------- //
// UTIL
// -------------------------------------------- //
private void registerCase(String playerName) private void registerCase(String playerName)
{ {
this.lowerToCorrect.put(playerName.toLowerCase(), playerName); this.lowerToCorrect.put(playerName.toLowerCase(), playerName);

View File

@ -8,11 +8,11 @@ import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.world.WorldLoadEvent; import org.bukkit.event.world.WorldLoadEvent;
import org.bukkit.event.world.WorldUnloadEvent; import org.bukkit.event.world.WorldUnloadEvent;
import org.bukkit.plugin.Plugin;
public class EngineWorldNameSet implements Listener public class EngineWorldNameSet extends EngineAbstract
{ {
// -------------------------------------------- // // -------------------------------------------- //
// INSTANCE & CONSTRUCT // INSTANCE & CONSTRUCT
@ -22,18 +22,25 @@ public class EngineWorldNameSet implements Listener
public static EngineWorldNameSet get() { return i; } public static EngineWorldNameSet get() { return i; }
// -------------------------------------------- // // -------------------------------------------- //
// SETUP // OVERRIDE
// -------------------------------------------- // // -------------------------------------------- //
public void setup() @Override
public Plugin getPlugin()
{ {
return MCore.get();
}
@Override
public void activate()
{
super.activate();
this.worldNamesInner.clear(); this.worldNamesInner.clear();
for (World world : Bukkit.getWorlds()) for (World world : Bukkit.getWorlds())
{ {
this.worldNamesInner.add(world.getName()); this.worldNamesInner.add(world.getName());
} }
Bukkit.getPluginManager().registerEvents(this, MCore.get());
} }
// -------------------------------------------- // // -------------------------------------------- //

View File

@ -82,6 +82,4 @@ public final class HeatData
return valueOf(heatTarget, now); return valueOf(heatTarget, now);
} }
} }

View File

@ -1,6 +1,7 @@
package com.massivecraft.mcore; package com.massivecraft.mcore;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Random; import java.util.Random;
@ -18,18 +19,19 @@ import com.massivecraft.mcore.adapter.JsonElementAdapter;
import com.massivecraft.mcore.adapter.ObjectIdAdapter; import com.massivecraft.mcore.adapter.ObjectIdAdapter;
import com.massivecraft.mcore.adapter.PlayerInventoryAdapter; import com.massivecraft.mcore.adapter.PlayerInventoryAdapter;
import com.massivecraft.mcore.adapter.UUIDAdapter; import com.massivecraft.mcore.adapter.UUIDAdapter;
import com.massivecraft.mcore.cmd.MCoreBukkitSimpleCommandMap;
import com.massivecraft.mcore.integration.protocollib.ProtocolLibFeatures; import com.massivecraft.mcore.integration.protocollib.ProtocolLibFeatures;
import com.massivecraft.mcore.integration.vault.VaultFeatures; import com.massivecraft.mcore.integration.vault.VaultFeatures;
import com.massivecraft.mcore.mcorecmd.CmdMCore; import com.massivecraft.mcore.mcorecmd.CmdMCore;
import com.massivecraft.mcore.mcorecmd.CmdMCoreMStore; import com.massivecraft.mcore.mcorecmd.CmdMCoreMStore;
import com.massivecraft.mcore.mcorecmd.CmdMCoreUsys; import com.massivecraft.mcore.mcorecmd.CmdMCoreUsys;
import com.massivecraft.mcore.mixin.SenderIdMixinDefault; import com.massivecraft.mcore.mixin.SenderIdMixinDefault;
import com.massivecraft.mcore.mixin.TeleportMixinCauseEngine; import com.massivecraft.mcore.mixin.EngineTeleportMixinCause;
import com.massivecraft.mcore.ps.PS; import com.massivecraft.mcore.ps.PS;
import com.massivecraft.mcore.ps.PSAdapter; import com.massivecraft.mcore.ps.PSAdapter;
import com.massivecraft.mcore.store.Coll; import com.massivecraft.mcore.store.Coll;
import com.massivecraft.mcore.store.ExamineThread; import com.massivecraft.mcore.store.ExamineThread;
import com.massivecraft.mcore.teleport.ScheduledTeleportEngine; import com.massivecraft.mcore.teleport.EngineScheduledTeleport;
import com.massivecraft.mcore.util.PlayerUtil; import com.massivecraft.mcore.util.PlayerUtil;
import com.massivecraft.mcore.util.TimeDiffUtil; import com.massivecraft.mcore.util.TimeDiffUtil;
import com.massivecraft.mcore.util.TimeUnit; import com.massivecraft.mcore.util.TimeUnit;
@ -147,37 +149,40 @@ public class MCore extends MPlugin
SenderIdMixinDefault.get().setup(); SenderIdMixinDefault.get().setup();
// Register events // Register events
InternalListener.get().setup(); EngineMainMCore.get().activate();
ScheduledTeleportEngine.get().setup(); EngineScheduledTeleport.get().activate();
TeleportMixinCauseEngine.get().setup(); EngineTeleportMixinCause.get().activate();
EngineWorldNameSet.get().setup(); EngineWorldNameSet.get().activate();
EngineOfflineCase.get().setup(); EngineOfflineCase.get().activate(); // TODO: Make all engines
PlayerUtil.get().setup(); PlayerUtil.get().setup();
// Schedule the collection ticker. // Tasks
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, this.collTickTask, 1, 1); Bukkit.getScheduler().scheduleSyncRepeatingTask(this, this.collTickTask, 1, 1);
// Initialize Internal Collections // Collections
MultiverseColl.get().init(); MultiverseColl.get().init();
AspectColl.get().init(); AspectColl.get().init();
MCoreConfColl.get().init(); MCoreConfColl.get().init();
// Init aspects // Aspects
this.moneyAspect = AspectColl.get().get("mcore_money", true); this.moneyAspect = AspectColl.get().get("mcore_money", true);
this.moneyAspect.register(); this.moneyAspect.register();
this.moneyAspect.setDesc( this.moneyAspect.setDesc(
"<i>The aspect used for how much money a player has" "<i>The aspect used for how much money a player has"
); );
// Inject our command map with dynamic tweaks
MCoreBukkitSimpleCommandMap.inject();
// Register commands // Register commands
this.outerCmdMCore = new CmdMCore(ConfServer.aliasesOuterMCore); this.outerCmdMCore = new CmdMCore() { public List<String> getAliases() { return MCoreConf.get().aliasesOuterMCore; } };
this.outerCmdMCore.register(this); this.outerCmdMCore.register();
this.outerCmdMCoreUsys = new CmdMCoreUsys(ConfServer.aliasesOuterMCoreUsys); this.outerCmdMCoreUsys = new CmdMCoreUsys() { public List<String> getAliases() { return MCoreConf.get().aliasesOuterMCoreUsys; } };
this.outerCmdMCoreUsys.register(this); this.outerCmdMCoreUsys.register();
this.outerCmdMCoreMStore = new CmdMCoreMStore(ConfServer.aliasesOuterMCoreMStore); this.outerCmdMCoreMStore = new CmdMCoreMStore() { public List<String> getAliases() { return MCoreConf.get().aliasesOuterMCoreMStore; } };
this.outerCmdMCoreMStore.register(this); this.outerCmdMCoreMStore.register();
// Integration // Integration
this.integrate( this.integrate(

View File

@ -1,6 +1,7 @@
package com.massivecraft.mcore; package com.massivecraft.mcore;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import org.bukkit.permissions.Permissible; import org.bukkit.permissions.Permissible;
@ -18,24 +19,16 @@ public class MCoreConf extends Entity<MCoreConf>
protected static transient MCoreConf i; protected static transient MCoreConf i;
public static MCoreConf get() { return i; } public static MCoreConf get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public MCoreConf load(MCoreConf that)
{
this.usingRecipientChatEvent = that.usingRecipientChatEvent;
this.forcingOnePlayerNameCase = that.forcingOnePlayerNameCase;
this.permissionDeniedFormats = that.permissionDeniedFormats;
this.permissionToTpdelay = that.permissionToTpdelay;
return this;
}
// -------------------------------------------- // // -------------------------------------------- //
// FIELDS // FIELDS
// -------------------------------------------- // // -------------------------------------------- //
public List<String> aliasesOuterMCore = MUtil.list("mcore");
public List<String> aliasesOuterMCoreUsys = MUtil.list("usys");
public List<String> aliasesOuterMCoreMStore = MUtil.list("mstore");
// These getters and setters are obnoxious, defensive copying, NPE avoiding and probably thread safe. // These getters and setters are obnoxious, defensive copying, NPE avoiding and probably thread safe.
private boolean usingRecipientChatEvent = true; private boolean usingRecipientChatEvent = true;

View File

@ -38,6 +38,9 @@ public abstract class MPlugin extends JavaPlugin implements Listener
// Create Gson // Create Gson
this.gson = this.getGsonBuilder().create(); this.gson = this.getGsonBuilder().create();
// Listener
Bukkit.getPluginManager().registerEvents(this, this);
return true; return true;
} }

View File

@ -160,4 +160,5 @@ public class Progressbar
} }
return ret; return ret;
} }
} }

View File

@ -93,4 +93,3 @@ public class SimpleConfig
DiscUtil.writeCatch(file, content); DiscUtil.writeCatch(file, content);
} }
} }

View File

@ -81,5 +81,4 @@ public class Triple<A, B, C> implements Cloneable, Serializable
return this; return this;
} }
} }

View File

@ -141,4 +141,5 @@ public class FireworkEffectAdapter
return ret; return ret;
} }
} }

View File

@ -60,4 +60,5 @@ public class ObjectIdAdapter implements JsonDeserializer<ObjectId>, JsonSerializ
{ {
return convertStringToObjectId(jsonElement.getAsString()); return convertStringToObjectId(jsonElement.getAsString());
} }
} }

View File

@ -70,4 +70,5 @@ public class PolymorphicAdapter<T> implements JsonDeserializer<T>, JsonSerialize
} }
return context.deserialize(jsonObject.get(VALUE), typeClass); return context.deserialize(jsonObject.get(VALUE), typeClass);
} }
} }

View File

@ -76,4 +76,5 @@ public class PotionEffectAdapter
return new PotionEffect(pet, duration, amplifier, ambient); return new PotionEffect(pet, duration, amplifier, ambient);
} }
} }

View File

@ -59,4 +59,5 @@ public class UUIDAdapter implements JsonDeserializer<UUID>, JsonSerializer<UUID>
{ {
return convertStringToUUID(jsonElement.getAsString()); return convertStringToUUID(jsonElement.getAsString());
} }
} }

View File

@ -0,0 +1,115 @@
package com.massivecraft.mcore.cmd;
import java.lang.reflect.Field;
import java.util.Map;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandMap;
import org.bukkit.command.SimpleCommandMap;
import org.bukkit.craftbukkit.v1_6_R3.CraftServer;
import org.bukkit.plugin.SimplePluginManager;
@SuppressWarnings("unchecked")
public class BukkitCommandDoor
{
// -------------------------------------------- //
// SINGLETON
// -------------------------------------------- //
public static CraftServer getCraftServer()
{
return (CraftServer)Bukkit.getServer();
}
public static SimpleCommandMap getSimpleCommandMap()
{
return getCraftServer().getCommandMap();
}
public static void setSimpleCommandMap(SimpleCommandMap simpleCommandMap)
{
set(CraftServer.class, "commandMap", getCraftServer(), simpleCommandMap);
}
public static SimplePluginManager getSimplePluginManager()
{
return (SimplePluginManager)Bukkit.getPluginManager();
}
// -------------------------------------------- //
// SIMPLE COMMAND MAP
// -------------------------------------------- //
public static Map<String, Command> getSimpleCommandMapDotKnownCommands(SimpleCommandMap simpleCommandMap)
{
return (Map<String, Command>) get(SimpleCommandMap.class, "knownCommands", simpleCommandMap);
}
public static Set<String> getSimpleCommandMapDotAliases(SimpleCommandMap simpleCommandMap)
{
return (Set<String>) get(SimpleCommandMap.class, "aliases", simpleCommandMap);
}
// -------------------------------------------- //
// SIMPLE PLUGIN MANAGER
// -------------------------------------------- //
public static CommandMap getSimplePluginManagerCommandMap(SimplePluginManager simplePluginManager)
{
return (CommandMap) get(SimplePluginManager.class, "commandMap", simplePluginManager);
}
public static void setSimplePluginManagerCommandMap(SimplePluginManager simplePluginManager, CommandMap commandMap)
{
set(SimplePluginManager.class, "commandMap", simplePluginManager, commandMap);
}
// -------------------------------------------- //
// COMMAND
// -------------------------------------------- //
public static CommandMap getCommandDotCommandMap(Command command)
{
return (CommandMap) get(Command.class, "commandMap", command);
}
public static void setCommandDotCommandMap(Command command, CommandMap commandMap)
{
set(Command.class, "commandMap", command, commandMap);
}
// -------------------------------------------- //
// UTIL
// -------------------------------------------- //
public static Object get(Class<?> clazz, String fieldName, Object object)
{
try
{
Field field = clazz.getDeclaredField(fieldName);
field.setAccessible(true);
return field.get(object);
}
catch (Exception e)
{
return null;
}
}
public static void set(Class<?> clazz, String fieldName, Object object, Object value)
{
try
{
Field field = clazz.getDeclaredField(fieldName);
field.setAccessible(true);
field.set(object, value);
}
catch (Exception e)
{
return;
}
}
}

View File

@ -1,66 +0,0 @@
package com.massivecraft.mcore.cmd;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.Plugin;
import com.massivecraft.mcore.mixin.Mixin;
import com.massivecraft.mcore.util.Txt;
public class BukkitGlueCommand extends Command
{
public final MCommand mcommand;
public final Plugin plugin;
public BukkitGlueCommand(String name, MCommand mcommand, Plugin plugin)
{
super(name, mcommand.getDesc(), mcommand.getUseageTemplate(), new ArrayList<String>());
this.mcommand = mcommand;
this.plugin = plugin;
}
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args)
{
if ( ! plugin.isEnabled()) return false;
List<String> argList;
if (this.mcommand.isUsingTokenizer())
{
argList = Txt.tokenizeArguments(Txt.implode(args, " "));
}
else
{
argList = new ArrayList<String>(Arrays.asList(args));
}
this.mcommand.execute(sender, argList);
return true;
}
@Override
public List<String> tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException
{
List<String> superRet = super.tabComplete(sender, alias, args);
if (args.length == 0) return superRet;
Set<String> ret = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
ret.addAll(superRet);
String tokenlc = args[args.length - 1].toLowerCase();
// Add ids of all online senders that match and isn't added yet.
for (String senderId : Mixin.getOnlineSenderIds())
{
if (!senderId.toLowerCase().startsWith(tokenlc)) continue;
if (!Mixin.canSee(sender, senderId)) continue;
ret.add(senderId);
}
return new ArrayList<String>(ret);
}
}

View File

@ -8,19 +8,28 @@ import com.massivecraft.mcore.util.Txt;
public class HelpCommand extends MCommand public class HelpCommand extends MCommand
{ {
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static HelpCommand i = new HelpCommand();
public static HelpCommand get() { return i; }
private HelpCommand() private HelpCommand()
{ {
super();
this.addAliases("?", "h", "help"); this.addAliases("?", "h", "help");
this.setDesc(""); this.setDesc("");
this.addOptionalArg("page","1"); this.addOptionalArg("page","1");
} }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override @Override
public void perform() public void perform()
{ {
if (this.commandChain.size() == 0) return; if (this.getCommandChain().size() == 0) return;
MCommand parentCommand = this.commandChain.get(this.commandChain.size()-1); MCommand parentCommand = this.getCommandChain().get(this.getCommandChain().size()-1);
ArrayList<String> lines = new ArrayList<String>(); ArrayList<String> lines = new ArrayList<String>();
@ -29,11 +38,11 @@ public class HelpCommand extends MCommand
lines.add(Txt.parse("<a>#<i> "+helpline)); lines.add(Txt.parse("<a>#<i> "+helpline));
} }
for(MCommand subCommand : parentCommand.getSubCommands()) for (MCommand subCommand : parentCommand.getSubCommands())
{ {
if (subCommand.visibleTo(sender)) if (subCommand.visibleTo(sender))
{ {
lines.add(subCommand.getUseageTemplate(this.commandChain, true, true, sender)); lines.add(subCommand.getUseageTemplate(this.getCommandChain(), true, true, sender));
} }
} }
@ -42,12 +51,4 @@ public class HelpCommand extends MCommand
sendMessage(Txt.getPage(lines, pagenumber, "Help for command \""+parentCommand.getAliases().get(0)+"\"", sender)); sendMessage(Txt.getPage(lines, pagenumber, "Help for command \""+parentCommand.getAliases().get(0)+"\"", sender));
} }
// -------------------------------------------- //
// INSTANCE
// -------------------------------------------- //
private static HelpCommand i = new HelpCommand();
public static HelpCommand getInstance() { return i; }
public static HelpCommand get() { return i; }
} }

View File

@ -3,11 +3,9 @@ package com.massivecraft.mcore.cmd;
import java.util.*; import java.util.*;
import java.util.Map.Entry; import java.util.Map.Entry;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.SimpleCommandMap; import org.bukkit.command.SimpleCommandMap;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import com.massivecraft.mcore.Lang; import com.massivecraft.mcore.Lang;
import com.massivecraft.mcore.MCore; import com.massivecraft.mcore.MCore;
@ -16,11 +14,10 @@ import com.massivecraft.mcore.cmd.arg.ArgResult;
import com.massivecraft.mcore.cmd.req.Req; import com.massivecraft.mcore.cmd.req.Req;
import com.massivecraft.mcore.cmd.req.ReqHasPerm; import com.massivecraft.mcore.cmd.req.ReqHasPerm;
import com.massivecraft.mcore.mixin.Mixin; import com.massivecraft.mcore.mixin.Mixin;
import com.massivecraft.mcore.util.BukkitCommandUtil;
import com.massivecraft.mcore.util.PermUtil; import com.massivecraft.mcore.util.PermUtil;
import com.massivecraft.mcore.util.Txt; import com.massivecraft.mcore.util.Txt;
public abstract class MCommand public class MCommand
{ {
// -------------------------------------------- // // -------------------------------------------- //
// COMMAND BEHAVIOR // COMMAND BEHAVIOR
@ -116,7 +113,7 @@ public abstract class MCommand
{ {
if (this.descPermission != null) return this.descPermission; if (this.descPermission != null) return this.descPermission;
// Otherwise we try to find one. // Otherwise we try to find one.
for (Req req : this.requirements) for (Req req : this.getRequirements())
{ {
if ( ! (req instanceof ReqHasPerm)) continue; if ( ! (req instanceof ReqHasPerm)) continue;
return ((ReqHasPerm)req).getPerm(); return ((ReqHasPerm)req).getPerm();
@ -161,46 +158,13 @@ public abstract class MCommand
// BUKKIT INTEGRATION // BUKKIT INTEGRATION
// -------------------------------------------- // // -------------------------------------------- //
public boolean register() protected final MCoreBukkitCommand bukkitCommand = new MCoreBukkitCommand(this);
public MCoreBukkitCommand getBukkitCommand() { return this.bukkitCommand; }
public void register()
{ {
return register(MCore.get(), true); SimpleCommandMap scm = BukkitCommandDoor.getSimpleCommandMap();
} scm.register(MCore.get().getDescription().getName(), this.getBukkitCommand());
public boolean register(Plugin plugin)
{
return this.register(plugin, true);
}
public boolean register(boolean override)
{
return this.register(MCore.get(), override);
}
public boolean register(Plugin plugin, boolean override)
{
boolean ret = false;
SimpleCommandMap scm = BukkitCommandUtil.getBukkitCommandMap();
for (String alias : this.getAliases())
{
BukkitGlueCommand bgc = new BukkitGlueCommand(alias, this, plugin);
if (override)
{
// Our commands are more important than your commands :P
Map<String, Command> knownCommands = BukkitCommandUtil.getKnownCommandsFromSimpleCommandMap(scm);
String lowerLabel = bgc.getName().trim().toLowerCase();
knownCommands.remove(lowerLabel);
}
if (scm.register(MCore.get().getDescription().getName(), bgc))
{
ret = true;
}
}
return ret;
} }
// -------------------------------------------- // // -------------------------------------------- //
@ -209,9 +173,8 @@ public abstract class MCommand
public MCommand() public MCommand()
{ {
this.descPermission = null;
this.subCommands = new ArrayList<MCommand>(); this.subCommands = new ArrayList<MCommand>();
this.aliases = new ArrayList<String>(); this.aliases = new ArrayList<String>();
this.requiredArgs = new ArrayList<String>(); this.requiredArgs = new ArrayList<String>();
@ -223,6 +186,7 @@ public abstract class MCommand
this.usingTokenizer = true; this.usingTokenizer = true;
this.desc = null; this.desc = null;
this.descPermission = null;
this.visibilityMode = VisibilityMode.VISIBLE; this.visibilityMode = VisibilityMode.VISIBLE;
} }
@ -242,15 +206,15 @@ public abstract class MCommand
this.fixSenderVars(); this.fixSenderVars();
this.args = args; this.setArgs(args);
this.commandChain = commandChain; this.setCommandChain(commandChain);
// Is there a matching sub command? // Is there a matching sub command?
if (args.size() > 0 ) if (args.size() > 0 )
{ {
for (MCommand subCommand: this.subCommands) for (MCommand subCommand: this.getSubCommands())
{ {
if (subCommand.aliases.contains(args.get(0))) if (subCommand.getAliases().contains(args.get(0)))
{ {
args.remove(0); args.remove(0);
commandChain.add(this); commandChain.add(this);
@ -260,7 +224,7 @@ public abstract class MCommand
} }
} }
if ( ! validCall(this.sender, this.args)) return; if ( ! validCall(this.sender, this.getArgs())) return;
perform(); perform();
} }
@ -273,8 +237,12 @@ public abstract class MCommand
} }
// This is where the command action is performed. // This is where the command action is performed.
public abstract void perform(); public void perform()
{
// Per default we just act as the help command!
this.getCommandChain().add(this);
HelpCommand.get().execute(this.sender, this.getArgs(), this.getCommandChain());
}
// -------------------------------------------- // // -------------------------------------------- //
// CALL VALIDATION // CALL VALIDATION
@ -323,7 +291,7 @@ public abstract class MCommand
public boolean validArgs(List<String> args, CommandSender sender) public boolean validArgs(List<String> args, CommandSender sender)
{ {
if (args.size() < this.requiredArgs.size()) if (args.size() < this.getRequiredArgs().size())
{ {
if (sender != null) if (sender != null)
{ {
@ -333,12 +301,12 @@ public abstract class MCommand
return false; return false;
} }
if (args.size() > this.requiredArgs.size() + this.optionalArgs.size() && this.errorOnToManyArgs) if (args.size() > this.getRequiredArgs().size() + this.getOptionalArgs().size() && this.getErrorOnToManyArgs())
{ {
if (sender != null) if (sender != null)
{ {
// Get the to many string slice // Get the to many string slice
List<String> theToMany = args.subList(this.requiredArgs.size() + this.optionalArgs.size(), args.size()); List<String> theToMany = args.subList(this.getRequiredArgs().size() + this.optionalArgs.size(), args.size());
msg(Lang.COMMAND_TO_MANY_ARGS, Txt.implodeCommaAndDot(theToMany, Txt.parse("<aqua>%s"), Txt.parse("<b>, "), Txt.parse("<b> and "), "")); msg(Lang.COMMAND_TO_MANY_ARGS, Txt.implodeCommaAndDot(theToMany, Txt.parse("<aqua>%s"), Txt.parse("<b>, "), Txt.parse("<b> and "), ""));
msg(Lang.COMMAND_TO_MANY_ARGS2); msg(Lang.COMMAND_TO_MANY_ARGS2);
sender.sendMessage(this.getUseageTemplate()); sender.sendMessage(this.getUseageTemplate());
@ -385,11 +353,11 @@ public abstract class MCommand
if (first && onlyFirstAlias) if (first && onlyFirstAlias)
{ {
ret.append(mc.aliases.get(0)); ret.append(mc.getAliases().get(0));
} }
else else
{ {
ret.append(Txt.implode(mc.aliases, ",")); ret.append(Txt.implode(mc.getAliases(), ","));
} }
if (iter.hasNext()) if (iter.hasNext())
@ -402,12 +370,12 @@ public abstract class MCommand
List<String> args = new ArrayList<String>(); List<String> args = new ArrayList<String>();
for (String requiredArg : this.requiredArgs) for (String requiredArg : this.getRequiredArgs())
{ {
args.add("<"+requiredArg+">"); args.add("<"+requiredArg+">");
} }
for (Entry<String, String> optionalArg : this.optionalArgs.entrySet()) for (Entry<String, String> optionalArg : this.getOptionalArgs().entrySet())
{ {
String val = optionalArg.getValue(); String val = optionalArg.getValue();
if (val == null) if (val == null)
@ -516,7 +484,7 @@ public abstract class MCommand
public String arg(int idx) public String arg(int idx)
{ {
if ( ! this.argIsSet(idx)) return null; if ( ! this.argIsSet(idx)) return null;
return this.args.get(idx); return this.getArgs().get(idx);
} }
public <T> T arg(int idx, ArgReader<T> argReader) public <T> T arg(int idx, ArgReader<T> argReader)
@ -537,9 +505,9 @@ public abstract class MCommand
{ {
if ( ! this.argIsSet(idx)) return null; if ( ! this.argIsSet(idx)) return null;
int from = idx; int from = idx;
int to = args.size(); int to = this.getArgs().size();
if (to <= from) return ""; if (to <= from) return "";
return Txt.implode(this.args.subList(from, to), " "); return Txt.implode(this.getArgs().subList(from, to), " ");
} }
public <T> T argConcatFrom(int idx, ArgReader<T> argReader) public <T> T argConcatFrom(int idx, ArgReader<T> argReader)

View File

@ -0,0 +1,116 @@
package com.massivecraft.mcore.cmd;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import com.massivecraft.mcore.mixin.Mixin;
import com.massivecraft.mcore.util.Txt;
public class MCoreBukkitCommand extends Command
{
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
private final MCommand mcommand;
public MCommand getMcommand() { return this.mcommand; }
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public MCoreBukkitCommand(MCommand mcommand)
{
super(
mcommand.getClass().getSimpleName(), // The name field is final. MCommand aliases/names are not final so we simply use the class name.
null, // Set description to null. Instead we override the getter.
null, // Set usage to null. Instead we override the getter.
new ArrayList<String>() // Set aliases to "null". Instead we override the getter.
);
this.mcommand = mcommand;
}
// -------------------------------------------- //
// OVERRIDE: GETTERS
// -------------------------------------------- //
@Override
public String getDescription()
{
return this.getMcommand().getDesc();
}
@Override
public String getUsage()
{
return this.getMcommand().getUseageTemplate();
}
@Override
public List<String> getAliases()
{
return this.getMcommand().getAliases();
}
@Override
public String getLabel()
{
return this.getMcommand().getAliases().get(0);
}
// -------------------------------------------- //
// OVERRIDE: EXECUTE
// -------------------------------------------- //
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args)
{
List<String> argList;
if (this.mcommand.isUsingTokenizer())
{
argList = Txt.tokenizeArguments(Txt.implode(args, " "));
}
else
{
argList = new ArrayList<String>(Arrays.asList(args));
}
this.mcommand.execute(sender, argList);
return true;
}
// -------------------------------------------- //
// OVERRIDE: TAB COMPLETE
// -------------------------------------------- //
@Override
public List<String> tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException
{
List<String> superRet = super.tabComplete(sender, alias, args);
if (args.length == 0) return superRet;
Set<String> ret = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
ret.addAll(superRet);
String tokenlc = args[args.length - 1].toLowerCase();
// Add ids of all online senders that match and isn't added yet.
for (String senderId : Mixin.getOnlineSenderIds())
{
if (!senderId.toLowerCase().startsWith(tokenlc)) continue;
if (!Mixin.canSee(sender, senderId)) continue;
ret.add(senderId);
}
return new ArrayList<String>(ret);
}
}

View File

@ -0,0 +1,110 @@
package com.massivecraft.mcore.cmd;
import java.util.LinkedHashSet;
import java.util.Map.Entry;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.SimpleCommandMap;
public class MCoreBukkitSimpleCommandMap extends SimpleCommandMap
{
// -------------------------------------------- //
// INJECT
// -------------------------------------------- //
public static MCoreBukkitSimpleCommandMap get()
{
SimpleCommandMap ret = BukkitCommandDoor.getSimpleCommandMap();
if (!(ret instanceof MCoreBukkitSimpleCommandMap)) return null;
return (MCoreBukkitSimpleCommandMap) ret;
}
public static boolean isInjected()
{
return get() != null;
}
public static void inject()
{
if (isInjected()) return;
MCoreBukkitSimpleCommandMap instance = new MCoreBukkitSimpleCommandMap();
BukkitCommandDoor.setSimpleCommandMap(instance);
BukkitCommandDoor.setSimplePluginManagerCommandMap(BukkitCommandDoor.getSimplePluginManager(), instance);
}
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
private final LinkedHashSet<MCoreBukkitCommand> mcoreBukkitCommands = new LinkedHashSet<MCoreBukkitCommand>();
public LinkedHashSet<MCoreBukkitCommand> getMCoreBukkitCommands() { return this.mcoreBukkitCommands; }
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public MCoreBukkitSimpleCommandMap(SimpleCommandMap simpleCommandMap)
{
// Trigger the super constructor
super(Bukkit.getServer());
// Fetch non static collection content
this.knownCommands.putAll(BukkitCommandDoor.getSimpleCommandMapDotKnownCommands(simpleCommandMap));
this.aliases.addAll(BukkitCommandDoor.getSimpleCommandMapDotAliases(simpleCommandMap));
// Convert registrations
for (Entry<String, Command> entry : this.knownCommands.entrySet())
{
Command command = entry.getValue();
if (BukkitCommandDoor.getCommandDotCommandMap(command) == null) continue;
BukkitCommandDoor.setCommandDotCommandMap(command, this);
}
}
public MCoreBukkitSimpleCommandMap()
{
this(BukkitCommandDoor.getSimpleCommandMap());
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public boolean register(String label, String fallbackPrefix, Command command)
{
// Bukkit
if (!(command instanceof MCoreBukkitCommand))
{
return super.register(label, fallbackPrefix, command);
}
// MCore
command.register(this);
this.getMCoreBukkitCommands().add((MCoreBukkitCommand)command);
return true;
}
@Override
public Command getCommand(String name)
{
// MCore
for (MCoreBukkitCommand mbc : this.getMCoreBukkitCommands())
{
for (String alias : mbc.getAliases())
{
if (alias.equalsIgnoreCase(name))
{
return mbc;
}
}
}
// Bukkit
return super.getCommand(name);
}
}

View File

@ -12,6 +12,10 @@ import com.massivecraft.mcore.util.Txt;
public class VersionCommand extends MCommand public class VersionCommand extends MCommand
{ {
// -------------------------------------------- //
// CONSTANTS
// -------------------------------------------- //
public static final String NOT_SPECIFIED = Txt.parse("<em><silver>not specified"); public static final String NOT_SPECIFIED = Txt.parse("<em><silver>not specified");
// -------------------------------------------- // // -------------------------------------------- //
@ -85,6 +89,4 @@ public class VersionCommand extends MCommand
sendMessage(Txt.parse("<pink>%s: <aqua>%s", Txt.upperCaseFirst(key), value == null ? NOT_SPECIFIED : value)); sendMessage(Txt.parse("<pink>%s: <aqua>%s", Txt.upperCaseFirst(key), value == null ? NOT_SPECIFIED : value));
} }
} }

View File

@ -31,4 +31,5 @@ public abstract class ARAbstractPrimitive<T> extends ArgReaderAbstract<T>
return result; return result;
} }
} }

View File

@ -45,4 +45,5 @@ public abstract class ARAbstractSelect<T> extends ArgReaderAbstract<T>
return result; return result;
} }
} }

View File

@ -19,4 +19,5 @@ public abstract class ReqAbstract implements Req, Serializable
{ {
return this.createErrorMessage(sender, null); return this.createErrorMessage(sender, null);
} }
} }

View File

@ -61,4 +61,5 @@ public class ReqAnd extends ReqAbstract
} }
return null; return null;
} }
} }

View File

@ -38,4 +38,5 @@ public class ReqHasPerm extends ReqAbstract
{ {
return PermUtil.getDeniedMessage(this.perm); return PermUtil.getDeniedMessage(this.perm);
} }
} }

View File

@ -43,4 +43,5 @@ public class ReqIsntCertainSender extends ReqAbstract
{ {
return Txt.parse("<b>Player can't be <h>%s<b>.", Mixin.getDisplayName(this.getSenderId())); return Txt.parse("<b>Player can't be <h>%s<b>.", Mixin.getDisplayName(this.getSenderId()));
} }
} }

View File

@ -49,4 +49,5 @@ public class MCoreAfterPlayerRespawnEvent extends Event implements Runnable
{ {
Bukkit.getPluginManager().callEvent(this); Bukkit.getPluginManager().callEvent(this);
} }
} }

View File

@ -56,4 +56,5 @@ public class MCoreAfterPlayerTeleportEvent extends Event implements Runnable
{ {
Bukkit.getPluginManager().callEvent(this); Bukkit.getPluginManager().callEvent(this);
} }
} }

View File

@ -36,7 +36,7 @@ public abstract class MCoreEvent extends Event implements Runnable, Cancellable
public MCoreEvent() public MCoreEvent()
{ {
super();
} }
public MCoreEvent(boolean isAsync) public MCoreEvent(boolean isAsync)

View File

@ -33,4 +33,5 @@ public class MCorePermissionDeniedFormatEvent extends MCoreEvent
this.permissionName = permissionName; this.permissionName = permissionName;
this.format = null; this.format = null;
} }
} }

View File

@ -117,4 +117,5 @@ public class Integration implements Listener
{ {
this.tick(); this.tick();
} }
} }

View File

@ -42,4 +42,5 @@ public abstract class IntegrationFeaturesAbstract implements IntegrationFeatures
{ {
} }
} }

View File

@ -84,4 +84,5 @@ public class EntityPotionColorPacketAdapter extends PacketAdapter
e.printStackTrace(); e.printStackTrace();
} }
} }
} }

View File

@ -1,40 +1,38 @@
package com.massivecraft.mcore.mcorecmd; package com.massivecraft.mcore.mcorecmd;
import java.util.List;
import com.massivecraft.mcore.MCore; import com.massivecraft.mcore.MCore;
import com.massivecraft.mcore.MCorePerm; import com.massivecraft.mcore.MCorePerm;
import com.massivecraft.mcore.cmd.HelpCommand; import com.massivecraft.mcore.cmd.MCommand;
import com.massivecraft.mcore.cmd.VersionCommand; import com.massivecraft.mcore.cmd.VersionCommand;
import com.massivecraft.mcore.cmd.req.ReqHasPerm; import com.massivecraft.mcore.cmd.req.ReqHasPerm;
import com.massivecraft.mcore.util.MUtil;
public class CmdMCore extends MCoreCommand public class CmdMCore extends MCommand
{ {
public CmdMCoreUsys cmdMCoreUsys = new CmdMCoreUsys(MUtil.list("usys")); // -------------------------------------------- //
public CmdMCoreMStore cmdMCoreMStore = new CmdMCoreMStore(MUtil.list("mstore")); // FIELDS
public CmdMCoreId cmdMCoreId = new CmdMCoreId(MUtil.list("id")); // -------------------------------------------- //
public CmdMCoreHearsound cmdMCoreHearsound = new CmdMCoreHearsound(MUtil.list("hearsound", "hearsounds"));
public CmdMCoreUsys cmdMCoreUsys = new CmdMCoreUsys();
public CmdMCoreMStore cmdMCoreMStore = new CmdMCoreMStore();
public CmdMCoreId cmdMCoreId = new CmdMCoreId();
public CmdMCoreHearsound cmdMCoreHearsound = new CmdMCoreHearsound();
public VersionCommand cmdMCoreVersion = new VersionCommand(MCore.get(), MCorePerm.CMD_MCORE_VERSION.node, "v", "version"); public VersionCommand cmdMCoreVersion = new VersionCommand(MCore.get(), MCorePerm.CMD_MCORE_VERSION.node, "v", "version");
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdMCore(List<String> aliases) public CmdMCore()
{ {
super(aliases); // SubCommands
this.addSubCommand(this.cmdMCoreUsys); this.addSubCommand(this.cmdMCoreUsys);
this.addSubCommand(this.cmdMCoreMStore); this.addSubCommand(this.cmdMCoreMStore);
this.addSubCommand(this.cmdMCoreId); this.addSubCommand(this.cmdMCoreId);
this.addSubCommand(this.cmdMCoreHearsound); this.addSubCommand(this.cmdMCoreHearsound);
this.addSubCommand(this.cmdMCoreVersion); this.addSubCommand(this.cmdMCoreVersion);
// Requirements
this.addRequirements(ReqHasPerm.get(MCorePerm.CMD_MCORE.node)); this.addRequirements(ReqHasPerm.get(MCorePerm.CMD_MCORE.node));
} }
@Override
public void perform()
{
this.getCommandChain().add(this);
HelpCommand.getInstance().execute(this.sender, this.args, this.commandChain);
}
} }

View File

@ -4,24 +4,35 @@ import java.util.List;
import com.massivecraft.mcore.MCorePerm; import com.massivecraft.mcore.MCorePerm;
import com.massivecraft.mcore.SoundEffect; import com.massivecraft.mcore.SoundEffect;
import com.massivecraft.mcore.cmd.MCommand;
import com.massivecraft.mcore.cmd.arg.ARSoundEffects; import com.massivecraft.mcore.cmd.arg.ARSoundEffects;
import com.massivecraft.mcore.cmd.req.ReqHasPerm; import com.massivecraft.mcore.cmd.req.ReqHasPerm;
import com.massivecraft.mcore.cmd.req.ReqIsPlayer; import com.massivecraft.mcore.cmd.req.ReqIsPlayer;
public class CmdMCoreHearsound extends MCoreCommand public class CmdMCoreHearsound extends MCommand
{ {
public CmdMCoreHearsound(List<String> aliases) // -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdMCoreHearsound()
{ {
super(aliases); // Aliases
this.addAliases("hearsound", "hearsounds");
// Args
this.addRequiredArg("sound(s)"); this.addRequiredArg("sound(s)");
this.setErrorOnToManyArgs(false); this.setErrorOnToManyArgs(false);
// Requirements
this.addRequirements(ReqHasPerm.get(MCorePerm.CMD_MCORE_HEARSOUND.node)); this.addRequirements(ReqHasPerm.get(MCorePerm.CMD_MCORE_HEARSOUND.node));
this.addRequirements(ReqIsPlayer.get()); this.addRequirements(ReqIsPlayer.get());
} }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override @Override
public void perform() public void perform()
{ {

View File

@ -1,22 +1,35 @@
package com.massivecraft.mcore.mcorecmd; package com.massivecraft.mcore.mcorecmd;
import java.util.List;
import com.massivecraft.mcore.ConfServer; import com.massivecraft.mcore.ConfServer;
import com.massivecraft.mcore.MCorePerm; import com.massivecraft.mcore.MCorePerm;
import com.massivecraft.mcore.cmd.MCommand;
import com.massivecraft.mcore.cmd.req.ReqHasPerm; import com.massivecraft.mcore.cmd.req.ReqHasPerm;
public class CmdMCoreId extends MCoreCommand public class CmdMCoreId extends MCommand
{ {
public CmdMCoreId(List<String> aliases) // -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdMCoreId()
{ {
super(aliases); // Aliases
this.addAliases("id");
// Requirements
this.addRequirements(ReqHasPerm.get(MCorePerm.CMD_MCORE_ID.node)); this.addRequirements(ReqHasPerm.get(MCorePerm.CMD_MCORE_ID.node));
} }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override @Override
public void perform() public void perform()
{ {
this.msg("<i>The id of this server is \"<h>%s<i>\".", ConfServer.serverid); this.msg("<i>The id of this server is \"<h>%s<i>\".", ConfServer.serverid);
} }
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
} }

View File

@ -1,33 +1,35 @@
package com.massivecraft.mcore.mcorecmd; package com.massivecraft.mcore.mcorecmd;
import java.util.List;
import com.massivecraft.mcore.MCorePerm; import com.massivecraft.mcore.MCorePerm;
import com.massivecraft.mcore.cmd.HelpCommand; import com.massivecraft.mcore.cmd.MCommand;
import com.massivecraft.mcore.cmd.req.ReqHasPerm; import com.massivecraft.mcore.cmd.req.ReqHasPerm;
import com.massivecraft.mcore.util.MUtil;
public class CmdMCoreMStore extends MCoreCommand public class CmdMCoreMStore extends MCommand
{ {
public CmdMCoreMStoreStats cmdMCoreMStoreStats = new CmdMCoreMStoreStats(MUtil.list("stats")); // -------------------------------------------- //
public CmdMCoreMStoreListcolls cmdMCoreMStoreListcolls = new CmdMCoreMStoreListcolls(MUtil.list("listcolls")); // FIELDS
public CmdMCoreMStoreCopydb cmdMCoreMStoreCopydb = new CmdMCoreMStoreCopydb(MUtil.list("copydb")); // -------------------------------------------- //
public CmdMCoreMStore(List<String> aliases) public CmdMCoreMStoreStats cmdMCoreMStoreStats = new CmdMCoreMStoreStats();
public CmdMCoreMStoreListcolls cmdMCoreMStoreListcolls = new CmdMCoreMStoreListcolls();
public CmdMCoreMStoreCopydb cmdMCoreMStoreCopydb = new CmdMCoreMStoreCopydb();
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdMCoreMStore()
{ {
super(aliases); // SubCommands
this.addSubCommand(this.cmdMCoreMStoreStats); this.addSubCommand(this.cmdMCoreMStoreStats);
this.addSubCommand(this.cmdMCoreMStoreListcolls); this.addSubCommand(this.cmdMCoreMStoreListcolls);
this.addSubCommand(this.cmdMCoreMStoreCopydb); this.addSubCommand(this.cmdMCoreMStoreCopydb);
// Args
this.addAliases("mstore");
// Requirements
this.addRequirements(ReqHasPerm.get(MCorePerm.CMD_MCORE_MSTORE.node)); this.addRequirements(ReqHasPerm.get(MCorePerm.CMD_MCORE_MSTORE.node));
} }
@Override
public void perform()
{
this.getCommandChain().add(this);
HelpCommand.getInstance().execute(this.sender, this.args, this.commandChain);
}
} }

View File

@ -1,12 +1,12 @@
package com.massivecraft.mcore.mcorecmd; package com.massivecraft.mcore.mcorecmd;
import java.util.Collection; import java.util.Collection;
import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import com.massivecraft.mcore.MCore; import com.massivecraft.mcore.MCore;
import com.massivecraft.mcore.MCorePerm; import com.massivecraft.mcore.MCorePerm;
import com.massivecraft.mcore.cmd.MCommand;
import com.massivecraft.mcore.cmd.req.ReqHasPerm; import com.massivecraft.mcore.cmd.req.ReqHasPerm;
import com.massivecraft.mcore.store.Coll; import com.massivecraft.mcore.store.Coll;
import com.massivecraft.mcore.store.Db; import com.massivecraft.mcore.store.Db;
@ -14,18 +14,29 @@ import com.massivecraft.mcore.store.Driver;
import com.massivecraft.mcore.store.MStore; import com.massivecraft.mcore.store.MStore;
import com.massivecraft.mcore.xlib.gson.JsonElement; import com.massivecraft.mcore.xlib.gson.JsonElement;
public class CmdMCoreMStoreCopydb extends MCoreCommand public class CmdMCoreMStoreCopydb extends MCommand
{ {
public CmdMCoreMStoreCopydb(List<String> aliases) // -------------------------------------------- //
{ // CONSTRUCT
super(aliases); // -------------------------------------------- //
public CmdMCoreMStoreCopydb()
{
// Aliases
this.addAliases("copydb");
// Args
this.addRequiredArg("from"); this.addRequiredArg("from");
this.addRequiredArg("to"); this.addRequiredArg("to");
// Requirements
this.addRequirements(ReqHasPerm.get(MCorePerm.CMD_MCORE_MSTORE_COPYDB.node)); this.addRequirements(ReqHasPerm.get(MCorePerm.CMD_MCORE_MSTORE_COPYDB.node));
} }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override @Override
public void perform() public void perform()
{ {

View File

@ -1,12 +1,12 @@
package com.massivecraft.mcore.mcorecmd; package com.massivecraft.mcore.mcorecmd;
import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.TreeSet; import java.util.TreeSet;
import com.massivecraft.mcore.ConfServer; import com.massivecraft.mcore.ConfServer;
import com.massivecraft.mcore.MCorePerm; import com.massivecraft.mcore.MCorePerm;
import com.massivecraft.mcore.NaturalOrderComparator; import com.massivecraft.mcore.NaturalOrderComparator;
import com.massivecraft.mcore.cmd.MCommand;
import com.massivecraft.mcore.cmd.arg.ARString; import com.massivecraft.mcore.cmd.arg.ARString;
import com.massivecraft.mcore.cmd.req.ReqHasPerm; import com.massivecraft.mcore.cmd.req.ReqHasPerm;
import com.massivecraft.mcore.store.Coll; import com.massivecraft.mcore.store.Coll;
@ -14,17 +14,28 @@ import com.massivecraft.mcore.store.Db;
import com.massivecraft.mcore.store.MStore; import com.massivecraft.mcore.store.MStore;
import com.massivecraft.mcore.util.Txt; import com.massivecraft.mcore.util.Txt;
public class CmdMCoreMStoreListcolls extends MCoreCommand public class CmdMCoreMStoreListcolls extends MCommand
{ {
public CmdMCoreMStoreListcolls(List<String> aliases) // -------------------------------------------- //
{ // CONSTRUCT
super(aliases); // -------------------------------------------- //
public CmdMCoreMStoreListcolls()
{
// Aliases
this.addAliases("listcolls");
// Args
this.addOptionalArg("db", ConfServer.dburi); this.addOptionalArg("db", ConfServer.dburi);
// Requirements
this.addRequirements(ReqHasPerm.get(MCorePerm.CMD_MCORE_MSTORE_LISTCOLLS.node)); this.addRequirements(ReqHasPerm.get(MCorePerm.CMD_MCORE_MSTORE_LISTCOLLS.node));
} }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override @Override
public void perform() public void perform()
{ {

View File

@ -1,9 +1,9 @@
package com.massivecraft.mcore.mcorecmd; package com.massivecraft.mcore.mcorecmd;
import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import com.massivecraft.mcore.MCorePerm; import com.massivecraft.mcore.MCorePerm;
import com.massivecraft.mcore.cmd.MCommand;
import com.massivecraft.mcore.cmd.arg.ARColl; import com.massivecraft.mcore.cmd.arg.ARColl;
import com.massivecraft.mcore.cmd.req.ReqHasPerm; import com.massivecraft.mcore.cmd.req.ReqHasPerm;
import com.massivecraft.mcore.store.Coll; import com.massivecraft.mcore.store.Coll;
@ -11,17 +11,28 @@ import com.massivecraft.mcore.store.ExamineThread;
import com.massivecraft.mcore.util.MUtil; import com.massivecraft.mcore.util.MUtil;
import com.massivecraft.mcore.util.Txt; import com.massivecraft.mcore.util.Txt;
public class CmdMCoreMStoreStats extends MCoreCommand public class CmdMCoreMStoreStats extends MCommand
{ {
public CmdMCoreMStoreStats(List<String> aliases) // -------------------------------------------- //
{ // CONSTRUCT
super(aliases); // -------------------------------------------- //
public CmdMCoreMStoreStats()
{
// Aliases
this.addAliases("stats");
// Args
this.addOptionalArg("coll", Coll.TOTAL); this.addOptionalArg("coll", Coll.TOTAL);
// Requirements
this.addRequirements(ReqHasPerm.get(MCorePerm.CMD_MCORE_MSTORE_STATS.node)); this.addRequirements(ReqHasPerm.get(MCorePerm.CMD_MCORE_MSTORE_STATS.node));
} }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override @Override
public void perform() public void perform()
{ {
@ -82,4 +93,5 @@ public class CmdMCoreMStoreStats extends MCoreCommand
msg("<k>%s <v>%d", entry.getKey(), entry.getValue()); msg("<k>%s <v>%d", entry.getKey(), entry.getValue());
} }
} }
} }

View File

@ -1,35 +1,37 @@
package com.massivecraft.mcore.mcorecmd; package com.massivecraft.mcore.mcorecmd;
import java.util.List;
import com.massivecraft.mcore.MCorePerm; import com.massivecraft.mcore.MCorePerm;
import com.massivecraft.mcore.cmd.HelpCommand; import com.massivecraft.mcore.cmd.MCommand;
import com.massivecraft.mcore.cmd.req.ReqHasPerm; import com.massivecraft.mcore.cmd.req.ReqHasPerm;
import com.massivecraft.mcore.util.MUtil;
public class CmdMCoreUsys extends MCoreCommand public class CmdMCoreUsys extends MCommand
{ {
public CmdMCoreUsysMultiverse cmdUsysMultiverse = new CmdMCoreUsysMultiverse(MUtil.list("m", "multiverse")); // -------------------------------------------- //
public CmdMCoreUsysUniverse cmdUsysUniverse = new CmdMCoreUsysUniverse(MUtil.list("u", "universe")); // FIELDS
public CmdMCoreUsysWorld cmdUsysWorld = new CmdMCoreUsysWorld(MUtil.list("w", "world")); // -------------------------------------------- //
public CmdMCoreUsysAspect cmdUsysAspect = new CmdMCoreUsysAspect(MUtil.list("a", "aspect"));
public CmdMCoreUsys(List<String> aliases) public CmdMCoreUsysMultiverse cmdUsysMultiverse = new CmdMCoreUsysMultiverse();
public CmdMCoreUsysUniverse cmdUsysUniverse = new CmdMCoreUsysUniverse();
public CmdMCoreUsysWorld cmdUsysWorld = new CmdMCoreUsysWorld();
public CmdMCoreUsysAspect cmdUsysAspect = new CmdMCoreUsysAspect();
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdMCoreUsys()
{ {
super(aliases); // SubCommands
this.addSubCommand(this.cmdUsysMultiverse); this.addSubCommand(this.cmdUsysMultiverse);
this.addSubCommand(this.cmdUsysUniverse); this.addSubCommand(this.cmdUsysUniverse);
this.addSubCommand(this.cmdUsysWorld); this.addSubCommand(this.cmdUsysWorld);
this.addSubCommand(this.cmdUsysAspect); this.addSubCommand(this.cmdUsysAspect);
// Aliases
this.addAliases("usys");
// Requirements
this.addRequirements(ReqHasPerm.get(MCorePerm.CMD_MCORE_USYS.node)); this.addRequirements(ReqHasPerm.get(MCorePerm.CMD_MCORE_USYS.node));
} }
@Override
public void perform()
{
this.getCommandChain().add(this);
HelpCommand.getInstance().execute(this.sender, this.args, this.commandChain);
}
} }

View File

@ -1,33 +1,35 @@
package com.massivecraft.mcore.mcorecmd; package com.massivecraft.mcore.mcorecmd;
import java.util.List;
import com.massivecraft.mcore.MCorePerm; import com.massivecraft.mcore.MCorePerm;
import com.massivecraft.mcore.cmd.HelpCommand; import com.massivecraft.mcore.cmd.MCommand;
import com.massivecraft.mcore.cmd.req.ReqHasPerm; import com.massivecraft.mcore.cmd.req.ReqHasPerm;
import com.massivecraft.mcore.util.MUtil;
public class CmdMCoreUsysAspect extends MCoreCommand public class CmdMCoreUsysAspect extends MCommand
{ {
public CmdMCoreUsysAspectList cmdUsysAspectList = new CmdMCoreUsysAspectList(MUtil.list("l", "list")); // -------------------------------------------- //
public CmdMCoreUsysAspectShow cmdUsysAspectShow = new CmdMCoreUsysAspectShow(MUtil.list("s", "show")); // FIELDS
public CmdMCoreUsysAspectUse cmdUsysAspectUse = new CmdMCoreUsysAspectUse(MUtil.list("u", "use")); // -------------------------------------------- //
public CmdMCoreUsysAspect(List<String> aliases) public CmdMCoreUsysAspectList cmdUsysAspectList = new CmdMCoreUsysAspectList();
public CmdMCoreUsysAspectShow cmdUsysAspectShow = new CmdMCoreUsysAspectShow();
public CmdMCoreUsysAspectUse cmdUsysAspectUse = new CmdMCoreUsysAspectUse();
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdMCoreUsysAspect()
{ {
super(aliases); // SubCommands
this.addSubCommand(this.cmdUsysAspectList); this.addSubCommand(this.cmdUsysAspectList);
this.addSubCommand(this.cmdUsysAspectShow); this.addSubCommand(this.cmdUsysAspectShow);
this.addSubCommand(this.cmdUsysAspectUse); this.addSubCommand(this.cmdUsysAspectUse);
// Aliases
this.addAliases("a", "aspect");
// Requirements
this.addRequirements(ReqHasPerm.get(MCorePerm.CMD_MCORE_USYS_ASPECT.node)); this.addRequirements(ReqHasPerm.get(MCorePerm.CMD_MCORE_USYS_ASPECT.node));
} }
@Override
public void perform()
{
this.getCommandChain().add(this);
HelpCommand.getInstance().execute(this.sender, this.args, this.commandChain);
}
} }

View File

@ -6,20 +6,33 @@ import java.util.List;
import com.massivecraft.mcore.Aspect; import com.massivecraft.mcore.Aspect;
import com.massivecraft.mcore.AspectColl; import com.massivecraft.mcore.AspectColl;
import com.massivecraft.mcore.MCorePerm; import com.massivecraft.mcore.MCorePerm;
import com.massivecraft.mcore.cmd.MCommand;
import com.massivecraft.mcore.cmd.arg.ARInteger; import com.massivecraft.mcore.cmd.arg.ARInteger;
import com.massivecraft.mcore.cmd.req.ReqHasPerm; import com.massivecraft.mcore.cmd.req.ReqHasPerm;
import com.massivecraft.mcore.util.Txt; import com.massivecraft.mcore.util.Txt;
public class CmdMCoreUsysAspectList extends MCoreCommand public class CmdMCoreUsysAspectList extends MCommand
{ {
public CmdMCoreUsysAspectList(List<String> aliases) // -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdMCoreUsysAspectList()
{ {
super(aliases); // Aliases
this.addAliases("l", "list");
// Args
this.addOptionalArg("page", "1"); this.addOptionalArg("page", "1");
// Requirements
this.addRequirements(ReqHasPerm.get(MCorePerm.CMD_MCORE_USYS_ASPECT_LIST.node)); this.addRequirements(ReqHasPerm.get(MCorePerm.CMD_MCORE_USYS_ASPECT_LIST.node));
} }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override @Override
public void perform() public void perform()
{ {
@ -38,4 +51,5 @@ public class CmdMCoreUsysAspectList extends MCoreCommand
lines = Txt.parseWrap(lines); lines = Txt.parseWrap(lines);
this.sendMessage(Txt.getPage(lines, pageHumanBased, "Aspect List", sender)); this.sendMessage(Txt.getPage(lines, pageHumanBased, "Aspect List", sender));
} }
} }

View File

@ -1,23 +1,34 @@
package com.massivecraft.mcore.mcorecmd; package com.massivecraft.mcore.mcorecmd;
import java.util.List;
import com.massivecraft.mcore.Aspect; import com.massivecraft.mcore.Aspect;
import com.massivecraft.mcore.MCorePerm; import com.massivecraft.mcore.MCorePerm;
import com.massivecraft.mcore.cmd.MCommand;
import com.massivecraft.mcore.cmd.arg.ARAspect; import com.massivecraft.mcore.cmd.arg.ARAspect;
import com.massivecraft.mcore.cmd.req.ReqHasPerm; import com.massivecraft.mcore.cmd.req.ReqHasPerm;
import com.massivecraft.mcore.util.Txt; import com.massivecraft.mcore.util.Txt;
public class CmdMCoreUsysAspectShow extends MCoreCommand public class CmdMCoreUsysAspectShow extends MCommand
{ {
public CmdMCoreUsysAspectShow(List<String> aliases) // -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdMCoreUsysAspectShow()
{ {
super(aliases); // Aliases
this.addAliases("s", "show");
// Args
this.addRequiredArg("aspect"); this.addRequiredArg("aspect");
// Requirements
this.addRequirements(ReqHasPerm.get(MCorePerm.CMD_MCORE_USYS_ASPECT_SHOW.node)); this.addRequirements(ReqHasPerm.get(MCorePerm.CMD_MCORE_USYS_ASPECT_SHOW.node));
} }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override @Override
public void perform() public void perform()
{ {
@ -32,4 +43,5 @@ public class CmdMCoreUsysAspectShow extends MCoreCommand
msg(descLine); msg(descLine);
} }
} }
} }

View File

@ -1,25 +1,36 @@
package com.massivecraft.mcore.mcorecmd; package com.massivecraft.mcore.mcorecmd;
import java.util.List;
import com.massivecraft.mcore.Aspect; import com.massivecraft.mcore.Aspect;
import com.massivecraft.mcore.Multiverse; import com.massivecraft.mcore.Multiverse;
import com.massivecraft.mcore.MCorePerm; import com.massivecraft.mcore.MCorePerm;
import com.massivecraft.mcore.cmd.MCommand;
import com.massivecraft.mcore.cmd.arg.ARAspect; import com.massivecraft.mcore.cmd.arg.ARAspect;
import com.massivecraft.mcore.cmd.arg.ARMultiverse; import com.massivecraft.mcore.cmd.arg.ARMultiverse;
import com.massivecraft.mcore.cmd.req.ReqHasPerm; import com.massivecraft.mcore.cmd.req.ReqHasPerm;
public class CmdMCoreUsysAspectUse extends MCoreCommand public class CmdMCoreUsysAspectUse extends MCommand
{ {
public CmdMCoreUsysAspectUse(List<String> aliases) // -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdMCoreUsysAspectUse()
{ {
super(aliases); // Aliases
this.addAliases("u", "use");
// Args
this.addRequiredArg("aspect"); this.addRequiredArg("aspect");
this.addRequiredArg("multiverse"); this.addRequiredArg("multiverse");
// Requirements
this.addRequirements(ReqHasPerm.get(MCorePerm.CMD_MCORE_USYS_ASPECT_USE.node)); this.addRequirements(ReqHasPerm.get(MCorePerm.CMD_MCORE_USYS_ASPECT_USE.node));
} }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override @Override
public void perform() public void perform()
{ {
@ -33,4 +44,5 @@ public class CmdMCoreUsysAspectUse extends MCoreCommand
msg("<g>The aspect <h>%s<g> now use multiverse <h>%s<g>.", aspect.getId(), multiverse.getId()); msg("<g>The aspect <h>%s<g> now use multiverse <h>%s<g>.", aspect.getId(), multiverse.getId());
} }
} }

View File

@ -1,35 +1,37 @@
package com.massivecraft.mcore.mcorecmd; package com.massivecraft.mcore.mcorecmd;
import java.util.List;
import com.massivecraft.mcore.MCorePerm; import com.massivecraft.mcore.MCorePerm;
import com.massivecraft.mcore.cmd.HelpCommand; import com.massivecraft.mcore.cmd.MCommand;
import com.massivecraft.mcore.cmd.req.ReqHasPerm; import com.massivecraft.mcore.cmd.req.ReqHasPerm;
import com.massivecraft.mcore.util.MUtil;
public class CmdMCoreUsysMultiverse extends MCoreCommand public class CmdMCoreUsysMultiverse extends MCommand
{ {
public CmdMCoreUsysMultiverseList cmdUsysMultiverseList = new CmdMCoreUsysMultiverseList(MUtil.list("l", "list")); // -------------------------------------------- //
public CmdMCoreUsysMultiverseShow cmdUsysMultiverseShow = new CmdMCoreUsysMultiverseShow(MUtil.list("s", "show")); // FIELDS
public CmdMCoreUsysMultiverseNew cmdUsysMultiverseNew = new CmdMCoreUsysMultiverseNew(MUtil.list("n", "new")); // -------------------------------------------- //
public CmdMCoreUsysMultiverseDel cmdUsysMultiverseDel = new CmdMCoreUsysMultiverseDel(MUtil.list("d", "del"));
public CmdMCoreUsysMultiverse(List<String> aliases) public CmdMCoreUsysMultiverseList cmdUsysMultiverseList = new CmdMCoreUsysMultiverseList();
public CmdMCoreUsysMultiverseShow cmdUsysMultiverseShow = new CmdMCoreUsysMultiverseShow();
public CmdMCoreUsysMultiverseNew cmdUsysMultiverseNew = new CmdMCoreUsysMultiverseNew();
public CmdMCoreUsysMultiverseDel cmdUsysMultiverseDel = new CmdMCoreUsysMultiverseDel();
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdMCoreUsysMultiverse()
{ {
super(aliases); // SubCommands
this.addSubCommand(this.cmdUsysMultiverseList); this.addSubCommand(this.cmdUsysMultiverseList);
this.addSubCommand(this.cmdUsysMultiverseShow); this.addSubCommand(this.cmdUsysMultiverseShow);
this.addSubCommand(this.cmdUsysMultiverseNew); this.addSubCommand(this.cmdUsysMultiverseNew);
this.addSubCommand(this.cmdUsysMultiverseDel); this.addSubCommand(this.cmdUsysMultiverseDel);
// Aliases
this.addAliases("m", "multiverse");
// Requirements
this.addRequirements(ReqHasPerm.get(MCorePerm.CMD_MCORE_USYS_MULTIVERSE.node)); this.addRequirements(ReqHasPerm.get(MCorePerm.CMD_MCORE_USYS_MULTIVERSE.node));
} }
@Override
public void perform()
{
this.getCommandChain().add(this);
HelpCommand.getInstance().execute(this.sender, this.args, this.commandChain);
}
} }

View File

@ -1,23 +1,34 @@
package com.massivecraft.mcore.mcorecmd; package com.massivecraft.mcore.mcorecmd;
import java.util.List;
import com.massivecraft.mcore.MCore; import com.massivecraft.mcore.MCore;
import com.massivecraft.mcore.Multiverse; import com.massivecraft.mcore.Multiverse;
import com.massivecraft.mcore.MCorePerm; import com.massivecraft.mcore.MCorePerm;
import com.massivecraft.mcore.cmd.MCommand;
import com.massivecraft.mcore.cmd.arg.ARMultiverse; import com.massivecraft.mcore.cmd.arg.ARMultiverse;
import com.massivecraft.mcore.cmd.req.ReqHasPerm; import com.massivecraft.mcore.cmd.req.ReqHasPerm;
public class CmdMCoreUsysMultiverseDel extends MCoreCommand public class CmdMCoreUsysMultiverseDel extends MCommand
{ {
public CmdMCoreUsysMultiverseDel(List<String> aliases) // -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdMCoreUsysMultiverseDel()
{ {
super(aliases); // Aliases
this.addAliases("d", "del");
// Args
this.addRequiredArg("multiverse"); this.addRequiredArg("multiverse");
// Requirements
this.addRequirements(ReqHasPerm.get(MCorePerm.CMD_MCORE_USYS_MULTIVERSE_DEL.node)); this.addRequirements(ReqHasPerm.get(MCorePerm.CMD_MCORE_USYS_MULTIVERSE_DEL.node));
} }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override @Override
public void perform() public void perform()
{ {
@ -36,4 +47,5 @@ public class CmdMCoreUsysMultiverseDel extends MCoreCommand
msg("<g>Deleted multiverse <h>%s<g>.", id); msg("<g>Deleted multiverse <h>%s<g>.", id);
} }
} }

View File

@ -6,20 +6,33 @@ import java.util.List;
import com.massivecraft.mcore.Multiverse; import com.massivecraft.mcore.Multiverse;
import com.massivecraft.mcore.MultiverseColl; import com.massivecraft.mcore.MultiverseColl;
import com.massivecraft.mcore.MCorePerm; import com.massivecraft.mcore.MCorePerm;
import com.massivecraft.mcore.cmd.MCommand;
import com.massivecraft.mcore.cmd.arg.ARInteger; import com.massivecraft.mcore.cmd.arg.ARInteger;
import com.massivecraft.mcore.cmd.req.ReqHasPerm; import com.massivecraft.mcore.cmd.req.ReqHasPerm;
import com.massivecraft.mcore.util.Txt; import com.massivecraft.mcore.util.Txt;
public class CmdMCoreUsysMultiverseList extends MCoreCommand public class CmdMCoreUsysMultiverseList extends MCommand
{ {
public CmdMCoreUsysMultiverseList(List<String> aliases) // -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdMCoreUsysMultiverseList()
{ {
super(aliases); // Aliases
this.addAliases("l", "list");
// Args
this.addOptionalArg("page", "1"); this.addOptionalArg("page", "1");
// Requirements
this.addRequirements(ReqHasPerm.get(MCorePerm.CMD_MCORE_USYS_MULTIVERSE_LIST.node)); this.addRequirements(ReqHasPerm.get(MCorePerm.CMD_MCORE_USYS_MULTIVERSE_LIST.node));
} }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override @Override
public void perform() public void perform()
{ {
@ -38,4 +51,5 @@ public class CmdMCoreUsysMultiverseList extends MCoreCommand
lines = Txt.parseWrap(lines); lines = Txt.parseWrap(lines);
this.sendMessage(Txt.getPage(lines, pageHumanBased, "Multiverse List", sender)); this.sendMessage(Txt.getPage(lines, pageHumanBased, "Multiverse List", sender));
} }
} }

View File

@ -1,21 +1,32 @@
package com.massivecraft.mcore.mcorecmd; package com.massivecraft.mcore.mcorecmd;
import java.util.List;
import com.massivecraft.mcore.MultiverseColl; import com.massivecraft.mcore.MultiverseColl;
import com.massivecraft.mcore.MCorePerm; import com.massivecraft.mcore.MCorePerm;
import com.massivecraft.mcore.cmd.MCommand;
import com.massivecraft.mcore.cmd.req.ReqHasPerm; import com.massivecraft.mcore.cmd.req.ReqHasPerm;
public class CmdMCoreUsysMultiverseNew extends MCoreCommand public class CmdMCoreUsysMultiverseNew extends MCommand
{ {
public CmdMCoreUsysMultiverseNew(List<String> aliases) // -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdMCoreUsysMultiverseNew()
{ {
super(aliases); // Aliases
this.addAliases("n", "new");
// Args
this.addRequiredArg("multiverse"); this.addRequiredArg("multiverse");
// Requirements
this.addRequirements(ReqHasPerm.get(MCorePerm.CMD_MCORE_USYS_MULTIVERSE_NEW.node)); this.addRequirements(ReqHasPerm.get(MCorePerm.CMD_MCORE_USYS_MULTIVERSE_NEW.node));
} }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override @Override
public void perform() public void perform()
{ {
@ -31,4 +42,5 @@ public class CmdMCoreUsysMultiverseNew extends MCoreCommand
msg("<g>Created multiverse <h>%s<g>.", id); msg("<g>Created multiverse <h>%s<g>.", id);
} }
} }

View File

@ -7,20 +7,33 @@ import com.massivecraft.mcore.Aspect;
import com.massivecraft.mcore.MCore; import com.massivecraft.mcore.MCore;
import com.massivecraft.mcore.Multiverse; import com.massivecraft.mcore.Multiverse;
import com.massivecraft.mcore.MCorePerm; import com.massivecraft.mcore.MCorePerm;
import com.massivecraft.mcore.cmd.MCommand;
import com.massivecraft.mcore.cmd.arg.ARMultiverse; import com.massivecraft.mcore.cmd.arg.ARMultiverse;
import com.massivecraft.mcore.cmd.req.ReqHasPerm; import com.massivecraft.mcore.cmd.req.ReqHasPerm;
import com.massivecraft.mcore.util.Txt; import com.massivecraft.mcore.util.Txt;
public class CmdMCoreUsysMultiverseShow extends MCoreCommand public class CmdMCoreUsysMultiverseShow extends MCommand
{ {
public CmdMCoreUsysMultiverseShow(List<String> aliases) // -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdMCoreUsysMultiverseShow()
{ {
super(aliases); // Aliases
this.addAliases("s", "show");
// Args
this.addRequiredArg("multiverse"); this.addRequiredArg("multiverse");
// Requirements
this.addRequirements(ReqHasPerm.get(MCorePerm.CMD_MCORE_USYS_MULTIVERSE_SHOW.node)); this.addRequirements(ReqHasPerm.get(MCorePerm.CMD_MCORE_USYS_MULTIVERSE_SHOW.node));
} }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override @Override
public void perform() public void perform()
{ {
@ -62,4 +75,5 @@ public class CmdMCoreUsysMultiverseShow extends MCoreCommand
msg(Txt.implodeCommaAndDot(ids, "<h>%s", "<i>, ", " <i>and ", "<i>.")); msg(Txt.implodeCommaAndDot(ids, "<h>%s", "<i>, ", " <i>and ", "<i>."));
} }
} }
} }

View File

@ -1,33 +1,35 @@
package com.massivecraft.mcore.mcorecmd; package com.massivecraft.mcore.mcorecmd;
import java.util.List;
import com.massivecraft.mcore.MCorePerm; import com.massivecraft.mcore.MCorePerm;
import com.massivecraft.mcore.cmd.HelpCommand; import com.massivecraft.mcore.cmd.MCommand;
import com.massivecraft.mcore.cmd.req.ReqHasPerm; import com.massivecraft.mcore.cmd.req.ReqHasPerm;
import com.massivecraft.mcore.util.MUtil;
public class CmdMCoreUsysUniverse extends MCoreCommand public class CmdMCoreUsysUniverse extends MCommand
{ {
public CmdMCoreUsysUniverseNew cmdUsysUniverseNew = new CmdMCoreUsysUniverseNew(MUtil.list("n", "new")); // -------------------------------------------- //
public CmdMCoreUsysUniverseDel cmdUsysUniverseDel = new CmdMCoreUsysUniverseDel(MUtil.list("d", "del")); // FIELDS
public CmdMCoreUsysUniverseClear cmdUsysUniverseClear = new CmdMCoreUsysUniverseClear(MUtil.list("c", "clear")); // -------------------------------------------- //
public CmdMCoreUsysUniverse(List<String> aliases) public CmdMCoreUsysUniverseNew cmdUsysUniverseNew = new CmdMCoreUsysUniverseNew();
public CmdMCoreUsysUniverseDel cmdUsysUniverseDel = new CmdMCoreUsysUniverseDel();
public CmdMCoreUsysUniverseClear cmdUsysUniverseClear = new CmdMCoreUsysUniverseClear();
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdMCoreUsysUniverse()
{ {
super(aliases); // SubCommands
this.addSubCommand(this.cmdUsysUniverseNew); this.addSubCommand(this.cmdUsysUniverseNew);
this.addSubCommand(this.cmdUsysUniverseDel); this.addSubCommand(this.cmdUsysUniverseDel);
this.addSubCommand(this.cmdUsysUniverseClear); this.addSubCommand(this.cmdUsysUniverseClear);
// Aliases
this.addAliases("u", "universe");
// Requirements
this.addRequirements(ReqHasPerm.get(MCorePerm.CMD_MCORE_USYS_UNIVERSE.node)); this.addRequirements(ReqHasPerm.get(MCorePerm.CMD_MCORE_USYS_UNIVERSE.node));
} }
@Override
public void perform()
{
this.getCommandChain().add(this);
HelpCommand.getInstance().execute(this.sender, this.args, this.commandChain);
}
} }

View File

@ -1,24 +1,35 @@
package com.massivecraft.mcore.mcorecmd; package com.massivecraft.mcore.mcorecmd;
import java.util.List;
import com.massivecraft.mcore.MCore; import com.massivecraft.mcore.MCore;
import com.massivecraft.mcore.Multiverse; import com.massivecraft.mcore.Multiverse;
import com.massivecraft.mcore.MCorePerm; import com.massivecraft.mcore.MCorePerm;
import com.massivecraft.mcore.cmd.MCommand;
import com.massivecraft.mcore.cmd.arg.ARMultiverse; import com.massivecraft.mcore.cmd.arg.ARMultiverse;
import com.massivecraft.mcore.cmd.req.ReqHasPerm; import com.massivecraft.mcore.cmd.req.ReqHasPerm;
public class CmdMCoreUsysUniverseClear extends MCoreCommand public class CmdMCoreUsysUniverseClear extends MCommand
{ {
public CmdMCoreUsysUniverseClear(List<String> aliases) // -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdMCoreUsysUniverseClear()
{ {
super(aliases); // Aliases
this.addAliases("c", "clear");
// Args
this.addRequiredArg("universe"); this.addRequiredArg("universe");
this.addRequiredArg("multiverse"); this.addRequiredArg("multiverse");
// Requirements
this.addRequirements(ReqHasPerm.get(MCorePerm.CMD_MCORE_USYS_UNIVERSE_CLEAR.node)); this.addRequirements(ReqHasPerm.get(MCorePerm.CMD_MCORE_USYS_UNIVERSE_CLEAR.node));
} }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override @Override
public void perform() public void perform()
{ {
@ -43,4 +54,5 @@ public class CmdMCoreUsysUniverseClear extends MCoreCommand
msg("<b>No universe <h>%s<b> exists in multiverse <h>%s<b>.", universe, multiverse.getId()); msg("<b>No universe <h>%s<b> exists in multiverse <h>%s<b>.", universe, multiverse.getId());
} }
} }
} }

View File

@ -1,24 +1,35 @@
package com.massivecraft.mcore.mcorecmd; package com.massivecraft.mcore.mcorecmd;
import java.util.List;
import com.massivecraft.mcore.MCore; import com.massivecraft.mcore.MCore;
import com.massivecraft.mcore.Multiverse; import com.massivecraft.mcore.Multiverse;
import com.massivecraft.mcore.MCorePerm; import com.massivecraft.mcore.MCorePerm;
import com.massivecraft.mcore.cmd.MCommand;
import com.massivecraft.mcore.cmd.arg.ARMultiverse; import com.massivecraft.mcore.cmd.arg.ARMultiverse;
import com.massivecraft.mcore.cmd.req.ReqHasPerm; import com.massivecraft.mcore.cmd.req.ReqHasPerm;
public class CmdMCoreUsysUniverseDel extends MCoreCommand public class CmdMCoreUsysUniverseDel extends MCommand
{ {
public CmdMCoreUsysUniverseDel(List<String> aliases) // -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdMCoreUsysUniverseDel()
{ {
super(aliases); // Aliases
this.addAliases("d", "del");
// Args
this.addRequiredArg("universe"); this.addRequiredArg("universe");
this.addRequiredArg("multiverse"); this.addRequiredArg("multiverse");
// Requirements
this.addRequirements(ReqHasPerm.get(MCorePerm.CMD_MCORE_USYS_MULTIVERSE_DEL.node)); this.addRequirements(ReqHasPerm.get(MCorePerm.CMD_MCORE_USYS_MULTIVERSE_DEL.node));
} }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override @Override
public void perform() public void perform()
{ {
@ -44,4 +55,5 @@ public class CmdMCoreUsysUniverseDel extends MCoreCommand
msg("<g>Deleted universe <h>%s<g> in multiverse <h>%s<g>.", universe, multiverse.getId()); msg("<g>Deleted universe <h>%s<g> in multiverse <h>%s<g>.", universe, multiverse.getId());
} }
} }

View File

@ -1,23 +1,34 @@
package com.massivecraft.mcore.mcorecmd; package com.massivecraft.mcore.mcorecmd;
import java.util.List;
import com.massivecraft.mcore.Multiverse; import com.massivecraft.mcore.Multiverse;
import com.massivecraft.mcore.MCorePerm; import com.massivecraft.mcore.MCorePerm;
import com.massivecraft.mcore.cmd.MCommand;
import com.massivecraft.mcore.cmd.arg.ARMultiverse; import com.massivecraft.mcore.cmd.arg.ARMultiverse;
import com.massivecraft.mcore.cmd.req.ReqHasPerm; import com.massivecraft.mcore.cmd.req.ReqHasPerm;
public class CmdMCoreUsysUniverseNew extends MCoreCommand public class CmdMCoreUsysUniverseNew extends MCommand
{ {
public CmdMCoreUsysUniverseNew(List<String> aliases) // -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdMCoreUsysUniverseNew()
{ {
super(aliases); // Aliases
this.addAliases("n", "new");
// Args
this.addRequiredArg("universe"); this.addRequiredArg("universe");
this.addRequiredArg("multiverse"); this.addRequiredArg("multiverse");
// Requirements
this.addRequirements(ReqHasPerm.get(MCorePerm.CMD_MCORE_USYS_UNIVERSE_NEW.node)); this.addRequirements(ReqHasPerm.get(MCorePerm.CMD_MCORE_USYS_UNIVERSE_NEW.node));
} }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override @Override
public void perform() public void perform()
{ {
@ -36,4 +47,5 @@ public class CmdMCoreUsysUniverseNew extends MCoreCommand
msg("<g>Created universe <h>%s<g> in multiverse <h>%s<g>.", universe, multiverse.getId()); msg("<g>Created universe <h>%s<g> in multiverse <h>%s<g>.", universe, multiverse.getId());
} }
} }

View File

@ -1,24 +1,35 @@
package com.massivecraft.mcore.mcorecmd; package com.massivecraft.mcore.mcorecmd;
import java.util.List;
import com.massivecraft.mcore.Multiverse; import com.massivecraft.mcore.Multiverse;
import com.massivecraft.mcore.MCorePerm; import com.massivecraft.mcore.MCorePerm;
import com.massivecraft.mcore.cmd.MCommand;
import com.massivecraft.mcore.cmd.arg.ARMultiverse; import com.massivecraft.mcore.cmd.arg.ARMultiverse;
import com.massivecraft.mcore.cmd.req.ReqHasPerm; import com.massivecraft.mcore.cmd.req.ReqHasPerm;
public class CmdMCoreUsysWorld extends MCoreCommand public class CmdMCoreUsysWorld extends MCommand
{ {
public CmdMCoreUsysWorld(List<String> aliases) // -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdMCoreUsysWorld()
{ {
super(aliases); // Aliases
this.addAliases("w", "world");
// Args
this.addRequiredArg("world"); this.addRequiredArg("world");
this.addRequiredArg("universe"); this.addRequiredArg("universe");
this.addRequiredArg("multiverse"); this.addRequiredArg("multiverse");
// Requirements
this.addRequirements(ReqHasPerm.get(MCorePerm.CMD_MCORE_USYS_WORLD.node)); this.addRequirements(ReqHasPerm.get(MCorePerm.CMD_MCORE_USYS_WORLD.node));
} }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override @Override
public void perform() public void perform()
{ {
@ -45,4 +56,5 @@ public class CmdMCoreUsysWorld extends MCoreCommand
msg("<i>World <h>%s <i>is already in universe <h>%s <i>in multiverse <h>%s<i>.", worldName, universe, multiverse.getId()); msg("<i>World <h>%s <i>is already in universe <h>%s <i>in multiverse <h>%s<i>.", worldName, universe, multiverse.getId());
} }
} }
} }

View File

@ -1,13 +0,0 @@
package com.massivecraft.mcore.mcorecmd;
import java.util.List;
import com.massivecraft.mcore.cmd.MCommand;
public abstract class MCoreCommand extends MCommand
{
public MCoreCommand(List<String> aliases)
{
this.setAliases(aliases);
}
}

View File

@ -7,28 +7,30 @@ import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.plugin.Plugin;
import com.massivecraft.mcore.EngineAbstract;
import com.massivecraft.mcore.MCore; import com.massivecraft.mcore.MCore;
public class TeleportMixinCauseEngine implements Listener public class EngineTeleportMixinCause extends EngineAbstract
{ {
// -------------------------------------------- // // -------------------------------------------- //
// INSTANCE & CONSTRUCT // INSTANCE & CONSTRUCT
// -------------------------------------------- // // -------------------------------------------- //
private static TeleportMixinCauseEngine i = new TeleportMixinCauseEngine(); private static EngineTeleportMixinCause i = new EngineTeleportMixinCause();
public static TeleportMixinCauseEngine get() { return i; } public static EngineTeleportMixinCause get() { return i; }
public TeleportMixinCauseEngine() {} public EngineTeleportMixinCause() {}
// -------------------------------------------- // // -------------------------------------------- //
// SETUP // OVERRIDE
// -------------------------------------------- // // -------------------------------------------- //
public void setup() @Override
public Plugin getPlugin()
{ {
Bukkit.getPluginManager().registerEvents(this, MCore.get()); return MCore.get();
} }
// -------------------------------------------- // // -------------------------------------------- //

View File

@ -30,7 +30,7 @@ public abstract class TeleportMixinAbstract implements TeleportMixin
@Override @Override
public boolean isCausedByMixin(PlayerTeleportEvent event) public boolean isCausedByMixin(PlayerTeleportEvent event)
{ {
return TeleportMixinCauseEngine.get().isCausedByTeleportMixin(event); return EngineTeleportMixinCause.get().isCausedByTeleportMixin(event);
} }
// -------------------------------------------- // // -------------------------------------------- //

View File

@ -49,9 +49,9 @@ public class TeleportMixinDefault extends TeleportMixinAbstract
if (vehicle != null) vehicle.eject(); if (vehicle != null) vehicle.eject();
// Do the teleport // Do the teleport
TeleportMixinCauseEngine.get().setMixinCausedTeleportIncoming(true); EngineTeleportMixinCause.get().setMixinCausedTeleportIncoming(true);
player.teleport(location); player.teleport(location);
TeleportMixinCauseEngine.get().setMixinCausedTeleportIncoming(false); EngineTeleportMixinCause.get().setMixinCausedTeleportIncoming(false);
// Bukkit velocity // Bukkit velocity
Vector velocity = null; Vector velocity = null;

View File

@ -6,7 +6,7 @@ public class TeleporterException extends Exception
public TeleporterException() public TeleporterException()
{ {
super();
} }
public TeleporterException(String message) public TeleporterException(String message)

View File

@ -90,6 +90,11 @@ public class MStore
return db; return db;
} }
public static Db getDb()
{
return getDb(ConfServer.dburi);
}
public static Db getDb(URI uri) public static Db getDb(URI uri)
{ {
String scheme = uri.getScheme(); String scheme = uri.getScheme();

View File

@ -17,4 +17,5 @@ public final class Accessor
} }
return ret; return ret;
} }
} }

View File

@ -171,5 +171,4 @@ public class AccessorUtil
return new PropertyAccessorComposite(getter, setter); return new PropertyAccessorComposite(getter, setter);
} }
} }

View File

@ -48,4 +48,5 @@ public abstract class EntityAccessorAbstract implements EntityAccessor
{ {
this.copy(from, to, DEFAULT_TRANSPARENT); this.copy(from, to, DEFAULT_TRANSPARENT);
} }
} }

View File

@ -82,4 +82,5 @@ public class EntityAccessorPerProperty extends EntityAccessorAbstract
{ {
return this.propertyAccessors.keySet(); return this.propertyAccessors.keySet();
} }
} }

View File

@ -22,4 +22,5 @@ public class PropertyAccessorComposite implements PropertyAccessor
{ {
return this.getter.get(entity); return this.getter.get(entity);
} }
} }

View File

@ -3,25 +3,25 @@ package com.massivecraft.mcore.teleport;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.plugin.Plugin;
import com.massivecraft.mcore.EngineAbstract;
import com.massivecraft.mcore.MCore; import com.massivecraft.mcore.MCore;
import com.massivecraft.mcore.mixin.Mixin; import com.massivecraft.mcore.mixin.Mixin;
import com.massivecraft.mcore.util.MUtil; import com.massivecraft.mcore.util.MUtil;
import com.massivecraft.mcore.util.SenderUtil; import com.massivecraft.mcore.util.SenderUtil;
public class ScheduledTeleportEngine implements Listener, Runnable public class EngineScheduledTeleport extends EngineAbstract
{ {
// -------------------------------------------- // // -------------------------------------------- //
// INSTANCE & CONSTRUCT // INSTANCE & CONSTRUCT
// -------------------------------------------- // // -------------------------------------------- //
private static ScheduledTeleportEngine i = new ScheduledTeleportEngine(); private static EngineScheduledTeleport i = new EngineScheduledTeleport();
public static ScheduledTeleportEngine get() { return i; } public static EngineScheduledTeleport get() { return i; }
// -------------------------------------------- // // -------------------------------------------- //
// SCHEDULED TELEPORT INDEX // SCHEDULED TELEPORT INDEX
@ -56,13 +56,32 @@ public class ScheduledTeleportEngine implements Listener, Runnable
} }
// -------------------------------------------- // // -------------------------------------------- //
// SETUP // OVERRIDE
// -------------------------------------------- // // -------------------------------------------- //
public void setup() @Override
public Plugin getPlugin()
{ {
Bukkit.getPluginManager().registerEvents(this, MCore.get()); return MCore.get();
Bukkit.getScheduler().scheduleSyncRepeatingTask(MCore.get(), this, 1, 1); }
@Override
public Long getPeriod()
{
return 1L;
}
@Override
public void run()
{
long now = System.currentTimeMillis();
for (ScheduledTeleport st : teleporteeIdToScheduledTeleport.values())
{
if (st.isDue(now))
{
st.run();
}
}
} }
// -------------------------------------------- // // -------------------------------------------- //
@ -86,21 +105,4 @@ public class ScheduledTeleportEngine implements Listener, Runnable
Mixin.msg(scheduledTeleport.getTeleporteeId(), "<rose>Cancelled <i>teleport to <h>"+scheduledTeleport.getDestinationDesc()+"<i>."); Mixin.msg(scheduledTeleport.getTeleporteeId(), "<rose>Cancelled <i>teleport to <h>"+scheduledTeleport.getDestinationDesc()+"<i>.");
} }
// -------------------------------------------- //
// LISTENER
// -------------------------------------------- //
@Override
public void run()
{
long now = System.currentTimeMillis();
for (ScheduledTeleport st : teleporteeIdToScheduledTeleport.values())
{
if (st.isDue(now))
{
st.run();
}
}
}
} }

View File

@ -45,17 +45,17 @@ public class ScheduledTeleport implements Runnable
public boolean isScheduled() public boolean isScheduled()
{ {
return ScheduledTeleportEngine.get().isScheduled(this); return EngineScheduledTeleport.get().isScheduled(this);
} }
public ScheduledTeleport schedule() public ScheduledTeleport schedule()
{ {
return ScheduledTeleportEngine.get().schedule(this); return EngineScheduledTeleport.get().schedule(this);
} }
public boolean unschedule() public boolean unschedule()
{ {
return ScheduledTeleportEngine.get().unschedule(this); return EngineScheduledTeleport.get().unschedule(this);
} }
// -------------------------------------------- // // -------------------------------------------- //

View File

@ -63,4 +63,5 @@ public class BiomeUtil
{ {
return getBiomeIdAndNameAt(world, x, z).getValue(); return getBiomeIdAndNameAt(world, x, z).getValue();
} }
} }

View File

@ -1,33 +0,0 @@
package com.massivecraft.mcore.util;
import java.lang.reflect.Field;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.SimpleCommandMap;
import org.bukkit.craftbukkit.v1_6_R3.CraftServer;
public class BukkitCommandUtil
{
public static SimpleCommandMap getBukkitCommandMap()
{
CraftServer craftServer = (CraftServer)Bukkit.getServer();
return craftServer.getCommandMap();
}
@SuppressWarnings("unchecked")
public static Map<String, Command> getKnownCommandsFromSimpleCommandMap(SimpleCommandMap scm)
{
try
{
Field field = SimpleCommandMap.class.getDeclaredField("knownCommands");
field.setAccessible(true);
return (Map<String, Command>) field.get(scm);
}
catch (Exception e)
{
return null;
}
}
}

View File

@ -47,4 +47,5 @@ public class ClassLoadHack
return false; return false;
} }
} }
} }

View File

@ -10,6 +10,7 @@ public class IntervalUtil
// -------------------------------------------- // // -------------------------------------------- //
// PARSING SIMPLE // PARSING SIMPLE
// -------------------------------------------- // // -------------------------------------------- //
public static Double parseDouble(String str, Double def) public static Double parseDouble(String str, Double def)
{ {
if (str == null) return def; if (str == null) return def;
@ -144,4 +145,5 @@ public class IntervalUtil
return parseInteger(data, def); return parseInteger(data, def);
} }
} }
} }

View File

@ -6,6 +6,7 @@ import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_6_R3.inventory.CraftInventoryCustom; import org.bukkit.craftbukkit.v1_6_R3.inventory.CraftInventoryCustom;
import org.bukkit.craftbukkit.v1_6_R3.inventory.CraftInventoryPlayer; import org.bukkit.craftbukkit.v1_6_R3.inventory.CraftInventoryPlayer;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.inventory.InventoryType;
@ -25,19 +26,21 @@ public class InventoryUtil
// -------------------------------------------- // // -------------------------------------------- //
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public static void update(Player player) public static void update(HumanEntity human)
{ {
if (!(human instanceof Player)) return;
Player player = (Player)human;
player.updateInventory(); player.updateInventory();
} }
public static void updateSoon(final Player player) public static void updateSoon(final HumanEntity human)
{ {
Bukkit.getScheduler().scheduleSyncDelayedTask(MCore.get(), new Runnable() Bukkit.getScheduler().scheduleSyncDelayedTask(MCore.get(), new Runnable()
{ {
@Override @Override
public void run() public void run()
{ {
update(player); update(human);
} }
}); });
} }

View File

@ -40,4 +40,5 @@ public class LibLoader
{ {
return new File("./lib/"+filename); return new File("./lib/"+filename);
} }
} }

View File

@ -38,4 +38,5 @@ public class LightUtil
WorldServer worldServer = cworld.getHandle(); WorldServer worldServer = cworld.getHandle();
worldServer.A(x, y, z); worldServer.A(x, y, z);
} }
} }

View File

@ -45,7 +45,7 @@ import org.bukkit.potion.Potion;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import com.massivecraft.mcore.InternalListener; import com.massivecraft.mcore.EngineMainMCore;
import com.massivecraft.mcore.MCore; import com.massivecraft.mcore.MCore;
import com.massivecraft.mcore.EngineWorldNameSet; import com.massivecraft.mcore.EngineWorldNameSet;
import com.massivecraft.mcore.util.extractor.Extractor; import com.massivecraft.mcore.util.extractor.Extractor;
@ -291,7 +291,7 @@ public class MUtil
public static String kickReason(PlayerQuitEvent event) public static String kickReason(PlayerQuitEvent event)
{ {
return InternalListener.kickedPlayerReasons.get(event.getPlayer().getName()); return EngineMainMCore.kickedPlayerReasons.get(event.getPlayer().getName());
} }
public static boolean causedByKick(PlayerQuitEvent event) public static boolean causedByKick(PlayerQuitEvent event)
@ -647,4 +647,5 @@ public class MUtil
registerExtractor(String.class, "moneyUniverse", ExtractorMoneyUniverse.get()); registerExtractor(String.class, "moneyUniverse", ExtractorMoneyUniverse.get());
registerExtractor(String.class, "accountId", ExtractorPlayerName.get()); registerExtractor(String.class, "accountId", ExtractorPlayerName.get());
} }
} }

View File

@ -395,4 +395,5 @@ public class PermUtil
} }
return ret; return ret;
} }
} }

View File

@ -104,4 +104,5 @@ public class TextWrapper
// Return it split // Return it split
return out.toString().split("\n"); return out.toString().split("\n");
} }
} }