MassiveCore - More type. More editor.

This commit is contained in:
Olof Larsson 2015-11-06 02:10:56 +01:00
parent 8477a7e5b8
commit 60a705ecf3
177 changed files with 4763 additions and 2375 deletions

View File

@ -1,3 +1,3 @@
<a href="http://massivecraft.com/massivecore">
<a href="https://www.massivecraft.com/massivecore">
![MassiveCore Logotype](https://raw.github.com/MassiveCraft/MassiveCore/master/media/logo300.png)<br>
<b>http://massivecraft.com/massivecore</b></a>
<b>https://www.massivecraft.com/massivecore</b></a>

View File

@ -1,9 +1,9 @@
main: com.massivecraft.massivecore.MassiveCore
name: MassiveCore
version: 2.8.2
website: http://massivecraft.com/massivecore
website: https://www.massivecraft.com/massivecore
authors: [Cayorion]
description: §eMassiveCore 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: §eMassiveCore 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 §bhttps://www.massivecraft.com
load: startup
permissions:
# -------------------------------------------- #

View File

@ -28,11 +28,6 @@ import com.massivecraft.massivecore.adapter.MsonEventAdapter;
import com.massivecraft.massivecore.adapter.PlayerInventoryAdapter;
import com.massivecraft.massivecore.adapter.UUIDAdapter;
import com.massivecraft.massivecore.chestgui.EngineChestGui;
import com.massivecraft.massivecore.cmd.massivecore.CmdMassiveCore;
import com.massivecraft.massivecore.cmd.massivecore.CmdMassiveCoreBuffer;
import com.massivecraft.massivecore.cmd.massivecore.CmdMassiveCoreCmdurl;
import com.massivecraft.massivecore.cmd.massivecore.CmdMassiveCoreStore;
import com.massivecraft.massivecore.cmd.massivecore.CmdMassiveCoreUsys;
import com.massivecraft.massivecore.collections.BackstringEnumSet;
import com.massivecraft.massivecore.collections.MassiveList;
import com.massivecraft.massivecore.collections.MassiveListDef;
@ -44,6 +39,11 @@ import com.massivecraft.massivecore.collections.MassiveTreeMap;
import com.massivecraft.massivecore.collections.MassiveTreeMapDef;
import com.massivecraft.massivecore.collections.MassiveTreeSet;
import com.massivecraft.massivecore.collections.MassiveTreeSetDef;
import com.massivecraft.massivecore.command.massivecore.CmdMassiveCore;
import com.massivecraft.massivecore.command.massivecore.CmdMassiveCoreBuffer;
import com.massivecraft.massivecore.command.massivecore.CmdMassiveCoreCmdurl;
import com.massivecraft.massivecore.command.massivecore.CmdMassiveCoreStore;
import com.massivecraft.massivecore.command.massivecore.CmdMassiveCoreUsys;
import com.massivecraft.massivecore.integration.vault.IntegrationVault;
import com.massivecraft.massivecore.mixin.EngineTeleportMixinCause;
import com.massivecraft.massivecore.mson.Mson;

View File

@ -12,8 +12,8 @@ import org.bukkit.command.Command;
import org.bukkit.command.SimpleCommandMap;
import org.bukkit.plugin.Plugin;
import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.MassiveCoreBukkitCommand;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.MassiveCoreBukkitCommand;
import com.massivecraft.massivecore.util.ReflectionUtil;
public class MassiveCoreEngineCommandRegistration extends EngineAbstract

View File

@ -11,10 +11,10 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.plugin.Plugin;
import com.massivecraft.massivecore.cmd.type.TypePS;
import com.massivecraft.massivecore.cmd.type.TypeSenderId;
import com.massivecraft.massivecore.cmd.type.TypeWorldId;
import com.massivecraft.massivecore.collections.MassiveSet;
import com.massivecraft.massivecore.command.type.TypePS;
import com.massivecraft.massivecore.command.type.TypeWorldId;
import com.massivecraft.massivecore.command.type.sender.TypeSenderId;
import com.massivecraft.massivecore.event.EventMassiveCoreDestination;
import com.massivecraft.massivecore.ps.PS;
import com.massivecraft.massivecore.teleport.Destination;

View File

@ -10,7 +10,7 @@ import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.integration.IntegrationGlue;
import com.massivecraft.massivecore.integration.Integration;
import com.massivecraft.massivecore.store.Coll;

View File

@ -8,7 +8,7 @@ import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeSet;
import com.massivecraft.massivecore.cmd.type.TypeUniverse;
import com.massivecraft.massivecore.command.type.TypeUniverse;
import com.massivecraft.massivecore.store.Entity;
import com.massivecraft.massivecore.util.MUtil;

View File

@ -0,0 +1,6 @@
package com.massivecraft.massivecore;
public interface Named
{
public String getName();
}

View File

@ -7,9 +7,6 @@ import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import com.massivecraft.massivecore.cmd.type.TypeFloat;
import com.massivecraft.massivecore.cmd.type.TypeSound;
public final class SoundEffect implements Cloneable, Serializable
{
private static final transient long serialVersionUID = 1L;
@ -61,29 +58,6 @@ public final class SoundEffect implements Cloneable, Serializable
return new SoundEffect(sound, volume, pitch);
}
public static SoundEffect valueOf(String soundString) throws Exception
{
if (soundString == null) throw new NullPointerException("soundString was null");
soundString = soundString.trim();
String[] parts = soundString.split("[^a-zA-Z0-9_.]+");
Sound sound = TypeSound.get().read(parts[0]);
float volume = 1.0f;
if (parts.length >= 2)
{
volume = TypeFloat.get().read(parts[1]);
}
float pitch = 1.0f;
if (parts.length >= 3)
{
pitch = TypeFloat.get().read(parts[2]);
}
return SoundEffect.valueOf(sound, volume, pitch);
}
// -------------------------------------------- //
// RUN
// -------------------------------------------- //

View File

@ -1,65 +0,0 @@
package com.massivecraft.massivecore.cmd.req;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.bukkit.command.CommandSender;
import com.massivecraft.massivecore.cmd.MassiveCommand;
public class ReqAnd extends ReqAbstract
{
private static final long serialVersionUID = 1L;
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
public static ReqAnd get(Req... reqs) { return new ReqAnd(reqs); }
public ReqAnd(Req... reqs)
{
this(Arrays.asList(reqs));
}
public static ReqAnd get(Collection<Req> reqs) { return new ReqAnd(reqs); }
public ReqAnd(Collection<Req> reqs)
{
this.reqs = Collections.unmodifiableList(new ArrayList<Req>(reqs));
}
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
private final List<Req> reqs;
public List<Req> getReqs() { return this.reqs; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public boolean apply(CommandSender sender, MassiveCommand command)
{
return this.getFirstFailedSubreq(sender, command) == null;
}
@Override
public String createErrorMessage(CommandSender sender, MassiveCommand command)
{
return this.getFirstFailedSubreq(sender, command).createErrorMessage(sender, command);
}
public Req getFirstFailedSubreq(CommandSender sender, MassiveCommand command)
{
for (Req req : this.getReqs())
{
if (!req.apply(sender, command)) return req;
}
return null;
}
}

View File

@ -1,34 +0,0 @@
package com.massivecraft.massivecore.cmd.type;
import java.util.Collection;
import java.util.List;
import org.bukkit.command.CommandSender;
import com.massivecraft.massivecore.MassiveException;
public interface Type<T>
{
// Human friendly name
public String getTypeName();
// Read
public T read(String arg, CommandSender sender) throws MassiveException;
public T read(CommandSender sender) throws MassiveException;
public T read(String arg) throws MassiveException;
public T read() throws MassiveException;
// Valid (used for arbitary argument order)
public boolean isValid(String arg, CommandSender sender);
// Tab list
// The sender is the one that tried to tab complete.
// The arg is beginning the word they are trying to tab complete.
public Collection<String> getTabList(CommandSender sender, String arg);
public List<String> getTabListFiltered(CommandSender sender, String arg);
// Sometimes we put a space after a tab completion.
// That would however not make sense with all Types.
// Default is true;
public boolean allowSpaceAfterTab();
}

View File

@ -1,117 +0,0 @@
package com.massivecraft.massivecore.cmd.type;
import java.util.Collection;
import java.util.Collections;
import org.bukkit.command.CommandSender;
import com.massivecraft.massivecore.MassiveException;
public final class TypeAll
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
@SuppressWarnings("unchecked")
public static <T> Type<Collection<T>> get(Type<?> inner)
{
if (inner instanceof TypeCollection) return new TypeAllCollection<T>((TypeCollection<? extends Collection<T>>) inner);
if (inner instanceof TypeAllAble) return new TypeAllDefault<T>((TypeAllAble<T>) inner);
throw new IllegalArgumentException("innerType must be an instance of either TypeCollection or TypeAllAble");
}
// -------------------------------------------- //
// AR ALL DEFAULT
// -------------------------------------------- //
private static class TypeAllDefault<T> extends TypeWrapper<Collection<T>>
{
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
protected TypeAllAble<T> innerType;
@Override public TypeAllAble<T> getInnerType() { return this.innerType; }
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public TypeAllDefault(TypeAllAble<T> inner)
{
if (inner == null) throw new IllegalArgumentException("innerType musn't be null");
this.innerType = inner;
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public Collection<T> read(String arg, CommandSender sender) throws MassiveException
{
if ("all".equalsIgnoreCase(arg)) return getInnerType().getAll(sender);
T innerRet = getInnerType().read(arg, sender);
return Collections.singletonList(innerRet);
}
@Override
public boolean isValid(String arg, CommandSender sender)
{
return "all".equalsIgnoreCase(arg) || this.getInnerType().isValid(arg, sender);
}
}
// -------------------------------------------- //
// AR ALL COLLECTION
// -------------------------------------------- //
private static class TypeAllCollection<T> extends TypeWrapper<Collection<T>>
{
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
protected TypeCollection<? extends Collection<T>> innerType;
@Override public TypeCollection<? extends Collection<T>> getInnerType() { return this.innerType; }
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public TypeAllCollection(TypeCollection<? extends Collection<T>> inner)
{
if (inner == null) throw new IllegalArgumentException("innerType musn't be null");
if ( !(inner.getInnerType() instanceof TypeAllAble)) throw new IllegalArgumentException("innerType must implement ARAllAble");
this.innerType = inner;
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public Collection<T> read(String arg, CommandSender sender) throws MassiveException
{
if ("all".equalsIgnoreCase(arg))
{
@SuppressWarnings("unchecked")
TypeAllAble<T> innersInner = (TypeAllAble<T>) getInnerType().getInnerType();
return innersInner.getAll(sender);
}
return getInnerType().read(arg, sender);
}
@Override
public boolean isValid(String arg, CommandSender sender)
{
return "all".equalsIgnoreCase(arg) || this.getInnerType().isValid(arg, sender);
}
}
}

View File

@ -1,94 +0,0 @@
package com.massivecraft.massivecore.cmd.type;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import org.bukkit.block.Biome;
import org.bukkit.command.CommandSender;
public class TypeBiome extends TypeAbstractSelect<Biome> implements TypeAllAble<Biome>
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static TypeBiome i = new TypeBiome();
public static TypeBiome get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public Biome select(String arg, CommandSender sender)
{
arg = getComparable(arg);
for (Biome biome : Biome.values())
{
String biomestr = getComparable(biome);
if (biomestr.equals(arg)) return biome;
biomestr = String.valueOf(biome.ordinal());
if (biomestr.equals(arg)) return biome;
}
return null;
}
@Override
public Collection<String> altNames(CommandSender sender)
{
List<String> ret = new ArrayList<String>();
for (Biome biome : Biome.values())
{
ret.add(String.valueOf(biome.ordinal()));
ret.add(biome.toString());
}
return ret;
}
@Override
public Collection<String> getTabList(CommandSender sender, String arg)
{
List<String> ret = new ArrayList<String>();
for (Biome biome : Biome.values())
{
ret.add(getComparable(biome.name()));
}
return ret;
}
@Override
public Collection<Biome> getAll(CommandSender sender)
{
return Arrays.asList(Biome.values());
}
// -------------------------------------------- //
// UTIL
// -------------------------------------------- //
public static String getComparable(Biome biome)
{
if (biome == null) return null;
return getComparable(biome.name());
}
public static String getComparable(String string)
{
if (string == null) return null;
string = string.toLowerCase();
string = string.replace("_", "");
string = string.replace(" ", "");
return string;
}
}

View File

@ -1,79 +0,0 @@
package com.massivecraft.massivecore.cmd.type;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import org.bukkit.command.CommandSender;
import com.massivecraft.massivecore.util.MUtil;
public class TypeBoolean extends TypeAbstractPrimitive<Boolean>
{
// -------------------------------------------- //
// CONSTANTS
// -------------------------------------------- //
public static final Set<String> TRUE_OPTIONS = MUtil.set(
"y", "ye", "yes",
"on",
"t", "tr", "tru", "true");
public static final Set<String> FALSE_OPTIONS = MUtil.set(
"n", "no",
"of", "off",
"f", "fa", "fal", "fals", "false");
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static TypeBoolean i = new TypeBoolean();
public static TypeBoolean get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public String getTypeName()
{
return "toggle";
}
@Override
public Boolean valueOf(String arg, CommandSender sender) throws Exception
{
arg = arg.toLowerCase();
if (TRUE_OPTIONS.contains(arg)) return Boolean.TRUE;
if (FALSE_OPTIONS.contains(arg)) return Boolean.FALSE;
throw new Exception();
}
@Override
public Collection<String> getTabList(CommandSender sender, String arg)
{
List<String> ret = new ArrayList<String>();
// Default yes and no.
ret.add("yes");
ret.add("no");
// If it is empty we just want to show yes and no
// else we might want to show other things.
// We can safely add them because it is filtered.
if ( ! arg.isEmpty())
{
ret.add("true");
ret.add("false");
ret.add("on");
ret.add("off");
}
return ret;
}
}

View File

@ -1,90 +0,0 @@
package com.massivecraft.massivecore.cmd.type;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
public class TypeChatColor extends TypeAbstractSelect<ChatColor> implements TypeAllAble<ChatColor>
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static TypeChatColor i = new TypeChatColor();
public static TypeChatColor get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public ChatColor select(String arg, CommandSender sender)
{
arg = getComparable(arg);
for (ChatColor cc : ChatColor.values())
{
String ccstr = getComparable(cc);
if (ccstr.equals(arg)) return cc;
}
return null;
}
@Override
public Collection<String> altNames(CommandSender sender)
{
List<String> ret = new ArrayList<String>();
for (ChatColor cc : ChatColor.values())
{
ret.add(cc.toString() + getComparable(cc));
}
return ret;
}
@Override
public Collection<String> getTabList(CommandSender sender, String arg)
{
List<String> ret = new ArrayList<String>();
for (ChatColor cc : ChatColor.values())
{
ret.add(getComparable(cc));
}
return ret;
}
@Override
public Collection<ChatColor> getAll(CommandSender sender)
{
return Arrays.asList(ChatColor.values());
}
// -------------------------------------------- //
// UTIL
// -------------------------------------------- //
public static String getComparable(ChatColor color)
{
if (color == null) return null;
return getComparable(color.name());
}
// "DARK_RED" --> "darkred"
// "DARK RED" --> "darkred"
public static String getComparable(String string)
{
string = string.toLowerCase();
string = string.replace("_", "");
string = string.replace(" ", "");
return string;
}
}

View File

@ -1,46 +0,0 @@
package com.massivecraft.massivecore.cmd.type;
import java.util.Collection;
import org.bukkit.command.CommandSender;
import com.massivecraft.massivecore.store.Coll;
public class TypeColl extends TypeAbstractSelect<Coll<?>> implements TypeAllAble<Coll<?>>
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static TypeColl i = new TypeColl();
public static TypeColl get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public Coll<?> select(String arg, CommandSender sender)
{
return Coll.getMap().get(arg);
}
@Override
public Collection<String> altNames(CommandSender sender)
{
return Coll.getNames();
}
@Override
public Collection<String> getTabList(CommandSender sender, String arg)
{
return this.altNames(sender);
}
@Override
public Collection<Coll<?>> getAll(CommandSender sender)
{
return Coll.getMap().values();
}
}

View File

@ -1,38 +0,0 @@
package com.massivecraft.massivecore.cmd.type;
import java.util.Collection;
import java.util.List;
import org.bukkit.command.CommandSender;
import com.massivecraft.massivecore.util.Txt;
public abstract class TypeCollection<E extends Collection<?>> extends TypeWrapper<E>
{
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public Collection<String> getTabList(CommandSender sender, String arg)
{
// Because we accept multiple arguments of the same type.
// The passed arg might be more than one. We only want the latest.
return this.getInnerType().getTabList(sender, getLastArg(arg));
}
@Override
public List<String> getTabListFiltered(CommandSender sender, String arg)
{
// Because we accept multiple arguments of the same type.
// The passed arg might be more than one. We only want the latest.
return this.getInnerType().getTabListFiltered(sender, getLastArg(arg));
}
public static String getLastArg(String str)
{
String[] innerArgs = Txt.REGEX_WHITESPACE.split(str, -1);
return innerArgs[innerArgs.length - 1];
}
}

View File

@ -1,83 +0,0 @@
package com.massivecraft.massivecore.cmd.type;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import org.bukkit.command.CommandSender;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.collections.MassiveList;
public class TypeCombined extends TypeAbstract<List<?>>
{
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
protected List<Type<?>> inners;
public List<Type<?>> getInners() { return this.inners; }
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
public static TypeCombined get(Collection<Type<?>> inners) { return new TypeCombined(inners); }
public static TypeCombined get(Type<?>... inners) { return new TypeCombined(inners); }
public TypeCombined(Collection<Type<?>> inners)
{
this.inners = new MassiveList<Type<?>>(inners);
}
public TypeCombined(Type<?>... inners)
{
this(Arrays.asList(inners));
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
//TODO: How to do this?
/*@Override
public String getTypeName()
{
}*/
@Override
public List<?> read(String arg, CommandSender sender) throws MassiveException
{
// Create Ret
List<Object> ret = new MassiveList<Object>();
// Fill Ret
List<String> parts = Arrays.asList(arg.split(","));
if (parts.size() > this.getInners().size())
{
throw new MassiveException().addMsg("<b>Too many parts!");
}
for (int i = 0; i < parts.size(); i++)
{
String part = parts.get(i);
Type<?> type = this.getInners().get(i);
Object asdf = type.read(part, sender);
ret.add(asdf);
}
// Return Ret
return ret;
}
//TODO: How to do this?
@Override
public Collection<String> getTabList(CommandSender sender, String arg)
{
return null; // ???
}
}

View File

@ -1,75 +0,0 @@
package com.massivecraft.massivecore.cmd.type;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.bukkit.Difficulty;
import org.bukkit.command.CommandSender;
import com.massivecraft.massivecore.util.MUtil;
public class TypeDifficulty extends TypeAbstractSelect<Difficulty> implements TypeAllAble<Difficulty>
{
// -------------------------------------------- //
// CONSTANTS
// -------------------------------------------- //
public static final List<String> ALT_NAMES = Collections.unmodifiableList(MUtil.list("peaceful", "easy", "normal", "hard"));
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static TypeDifficulty i = new TypeDifficulty();
public static TypeDifficulty get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public Difficulty select(String arg, CommandSender sender)
{
arg = arg.toLowerCase();
if (arg.startsWith("p"))
{
return Difficulty.PEACEFUL;
}
else if (arg.startsWith("e"))
{
return Difficulty.EASY;
}
else if (arg.startsWith("n"))
{
return Difficulty.NORMAL;
}
else if (arg.startsWith("h"))
{
return Difficulty.HARD;
}
return null;
}
@Override
public Collection<String> altNames(CommandSender sender)
{
return ALT_NAMES;
}
@Override
public Collection<String> getTabList(CommandSender sender, String arg)
{
return this.altNames(sender);
}
@Override
public Collection<Difficulty> getAll(CommandSender sender)
{
return Arrays.asList(Difficulty.values());
}
}

View File

@ -1,82 +0,0 @@
package com.massivecraft.massivecore.cmd.type;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.EntityType;
public class TypeEntityType extends TypeAbstractSelect<EntityType> implements TypeAllAble<EntityType>
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static TypeEntityType i = new TypeEntityType();
public static TypeEntityType get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public EntityType select(String arg, CommandSender sender)
{
arg = getComparable(arg);
// Custom Detection
if (arg.contains("pig") && ((arg.contains("man") || arg.contains("zombie")))) return EntityType.PIG_ZOMBIE;
// Algorithmic General Detection
for (EntityType entityType : EntityType.values())
{
String compare = getComparable(entityType);
if (compare.equals(arg)) return entityType;
}
// Nothing found
return null;
}
@Override
public Collection<String> altNames(CommandSender sender)
{
List<String> ret = new ArrayList<String>();
for (EntityType entityType : EntityType.values())
{
ret.add(getComparable(entityType));
}
return ret;
}
@Override
public Collection<String> getTabList(CommandSender sender, String arg)
{
return this.altNames(sender);
}
@Override
public Collection<EntityType> getAll(CommandSender sender)
{
return Arrays.asList(EntityType.values());
}
// -------------------------------------------- //
// UTIL
// -------------------------------------------- //
public static String getComparable(EntityType entityType)
{
if (entityType == null) return null;
return getComparable(entityType.toString());
}
public static String getComparable(String string)
{
if (string == null) return null;
return string.toLowerCase().replaceAll("[_\\-\\s]+", "");
}
}

View File

@ -1,124 +0,0 @@
package com.massivecraft.massivecore.cmd.type;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import org.bukkit.command.CommandSender;
import com.massivecraft.massivecore.util.Txt;
public class TypeEnum<T> extends TypeAbstractSelect<T> implements TypeAllAble<T>
{
// -------------------------------------------- //
// FIELD
// -------------------------------------------- //
private final Class<T> clazz;
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
public static <T> TypeEnum<T> get(Class<T> clazz)
{
return new TypeEnum<T>(clazz);
}
public TypeEnum(Class<T> clazz)
{
if ( ! clazz.isEnum()) throw new IllegalArgumentException("passed clazz param must be an enum");
this.clazz = clazz;
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public String getTypeName()
{
return Txt.getNicedEnumString(clazz.getSimpleName());
}
@Override
public T select(String arg, CommandSender sender)
{
if (arg == null) return null;
arg = getComparable(arg);
// Algorithmic General Detection
T startsWith = null;
for (T value : getEnumValues(clazz))
{
String comparable = getComparable(value);
if (comparable.equals(arg)) return value;
if (comparable.startsWith(arg))
{
// If there already were a result
// we have multiple results and stop.
if (startsWith != null) return null;
// Else we set the result.
startsWith = value;
}
}
// Nothing found
return startsWith;
}
@Override
public Collection<String> altNames(CommandSender sender)
{
List<String> ret = new ArrayList<String>();
for (T value : getEnumValues(clazz))
{
ret.add(getComparable(value));
}
return ret;
}
@Override
public Collection<String> getTabList(CommandSender sender, String arg)
{
return this.altNames(sender);
}
@Override
public Collection<T> getAll(CommandSender sender)
{
return Arrays.asList(getEnumValues(clazz));
}
// -------------------------------------------- //
// UTIL
// -------------------------------------------- //
public static <T> T[] getEnumValues(Class<T> clazz)
{
if (clazz == null) throw new IllegalArgumentException("passed clazz param is null");
if ( ! clazz.isEnum()) throw new IllegalArgumentException("passed clazz param must be an enum");
T[] ret = clazz.getEnumConstants();
if (ret == null) throw new RuntimeException("failed to retrieve enum constants");
return ret;
}
public static String getComparable(Object value)
{
if (value == null) return null;
return getComparable(value.toString());
}
public static String getComparable(String string)
{
if (string == null) return null;
return string.toLowerCase().replaceAll("[_\\-\\s]+", "");
}
}

View File

@ -1,99 +0,0 @@
package com.massivecraft.massivecore.cmd.type;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.bukkit.World.Environment;
import org.bukkit.command.CommandSender;
import com.massivecraft.massivecore.util.MUtil;
public class TypeEnvironment extends TypeAbstractSelect<Environment> implements TypeAllAble<Environment>
{
// -------------------------------------------- //
// CONSTANTS
// -------------------------------------------- //
public static final List<String> ALT_NAMES = Collections.unmodifiableList(MUtil.list("normal", "end", "nether"));
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static TypeEnvironment i = new TypeEnvironment();
public static TypeEnvironment get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public Environment select(String arg, CommandSender sender)
{
// "THE_END" --> "end"
arg = getComparable(arg);
if (arg.startsWith("no") || arg.startsWith("d"))
{
// "normal" or "default"
return Environment.NORMAL;
}
else if (arg.startsWith("ne"))
{
// "nether"
return Environment.NETHER;
}
else if (arg.startsWith("e"))
{
// "end"
return Environment.THE_END;
}
return null;
}
@Override
public Collection<String> altNames(CommandSender sender)
{
return ALT_NAMES;
}
@Override
public Collection<String> getTabList(CommandSender sender, String arg)
{
Collection<String> ret = this.altNames(sender);
// The_end or the_nether
if (StringUtils.startsWithIgnoreCase(arg, "t"))
{
ret.add("the_end");
ret.add("the_nether");
}
return ret;
}
@Override
public Collection<Environment> getAll(CommandSender sender)
{
return Arrays.asList(Environment.values());
}
// -------------------------------------------- //
// UTIL
// -------------------------------------------- //
public static String getComparable(String str)
{
str = str.toLowerCase();
str = str.replace(" ", "");
str = str.replace("_", "");
str = str.replace("the", "");
return str;
}
}

View File

@ -1,83 +0,0 @@
package com.massivecraft.massivecore.cmd.type;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import org.bukkit.GameMode;
import org.bukkit.command.CommandSender;
import com.massivecraft.massivecore.util.Txt;
public class TypeGameMode extends TypeAbstractSelect<GameMode> implements TypeAllAble<GameMode>
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static TypeGameMode i = new TypeGameMode();
public static TypeGameMode get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public GameMode select(String arg, CommandSender sender)
{
arg = getComparable(arg);
if (arg.length() < 2) return null; // Some gamemodes have the same beginning character. So we need atleast 2 characters.
for (GameMode gm : GameMode.values())
{
// Comparable
String compare = getComparable(gm);
if (compare.startsWith(arg)) return gm;
}
return null;
}
@Override
public Collection<String> altNames(CommandSender sender)
{
List<String> ret = new ArrayList<String>();
for (GameMode gm : GameMode.values())
{
ret.add(Txt.getNicedEnum(gm));
}
return ret;
}
@Override
public Collection<String> getTabList(CommandSender sender, String arg)
{
return this.altNames(sender);
}
@Override
public Collection<GameMode> getAll(CommandSender sender)
{
return Arrays.asList(GameMode.values());
}
// -------------------------------------------- //
// UTIL
// -------------------------------------------- //
public static String getComparable(GameMode gamemode)
{
if (gamemode == null) return null;
return getComparable(gamemode.name());
}
public static String getComparable(String string)
{
if (string == null) return null;
return string.toLowerCase();
}
}

View File

@ -1,61 +0,0 @@
package com.massivecraft.massivecore.cmd.type;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.command.CommandSender;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.util.Txt;
public class TypeList<E> extends TypeCollection<List<E>>
{
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
protected Type<E> elementType;
public Type<E> getElementType() { return this.elementType; }
@Override public Type<E> getInnerType() { return this.getElementType(); }
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
public static <E> TypeList<E> get(Type<E> elementType)
{
return new TypeList<E>(elementType);
}
public TypeList(Type<E> elementType)
{
this.elementType = elementType;
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
// NOTE: Must be used with argConcatFrom and setErrorOnTooManyArgs(false).
@Override
public List<E> read(String arg, CommandSender sender) throws MassiveException
{
// Split into inner args
String[] elementArgs = Txt.REGEX_WHITESPACE.split(arg);
// Create Ret
List<E> ret = new ArrayList<E>();
// For Each
for (String elementArg : elementArgs)
{
E element = this.getElementType().read(elementArg, sender);
ret.add(element);
}
// Return Ret
return ret;
}
}

View File

@ -1,59 +0,0 @@
package com.massivecraft.massivecore.cmd.type;
import java.util.Arrays;
import java.util.Collection;
import java.util.Set;
import java.util.TreeSet;
import org.bukkit.Material;
import org.bukkit.command.CommandSender;
import com.massivecraft.massivecore.MassiveException;
public class TypeMaterial extends TypeAbstract<Material> implements TypeAllAble<Material>
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static TypeMaterial i = new TypeMaterial();
public static TypeMaterial get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public Material read(String arg, CommandSender sender) throws MassiveException
{
Material ret = Material.matchMaterial(arg);
if (ret == null)
{
throw new MassiveException()
.addMsg("<b>No material matches <h>%s<b>.", arg)
.addMsg("<i>https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/browse/src/main/java/org/bukkit/Material.java");
}
return ret;
}
@Override
public Collection<String> getTabList(CommandSender sender, String arg)
{
Set<String> ret = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
for (Material material : Material.values())
{
ret.add(material.name());
}
return ret;
}
@Override
public Collection<Material> getAll(CommandSender sender)
{
return Arrays.asList(Material.values());
}
}

View File

@ -1,56 +0,0 @@
package com.massivecraft.massivecore.cmd.type;
import java.util.Collection;
import java.util.Set;
import java.util.TreeSet;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.Permission;
import com.massivecraft.massivecore.MassiveException;
public class TypePermission extends TypeAbstract<Permission> implements TypeAllAble<Permission>
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static TypePermission i = new TypePermission();
public static TypePermission get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public Permission read(String arg, CommandSender sender) throws MassiveException
{
for (Permission permission : Bukkit.getPluginManager().getPermissions())
{
if (permission.getName().equals(arg)) return permission;
}
throw new MassiveException().addMsg("<b>No permission with the name \"<h>%s<b>\" was found.", arg);
}
@Override
public Collection<String> getTabList(CommandSender sender, String arg)
{
Set<String> ret = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
for (Permission perm : Bukkit.getPluginManager().getPermissions())
{
ret.add(perm.getName());
}
return ret;
}
@Override
public Collection<Permission> getAll(CommandSender sender)
{
return Bukkit.getPluginManager().getPermissions();
}
}

View File

@ -1,91 +0,0 @@
package com.massivecraft.massivecore.cmd.type;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import org.bukkit.command.CommandSender;
import org.bukkit.potion.PotionEffectType;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.collections.MassiveList;
public class TypePotionEffectType extends TypeAbstractSelect<PotionEffectType> implements TypeAllAble<PotionEffectType>
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static TypePotionEffectType i = new TypePotionEffectType();
public static TypePotionEffectType get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public PotionEffectType select(String str, CommandSender sender) throws MassiveException
{
// Prepare
str = getComparable(str);
// Match Name
for (PotionEffectType potionEffectType : PotionEffectType.values())
{
String name = getComparable(potionEffectType);
if (str.equals(name)) return potionEffectType;
}
// :(
return null;
}
@Override
public Collection<String> altNames(CommandSender sender)
{
// Create Ret
List<String> ret = new MassiveList<String>();
// Match Name
for (PotionEffectType potionEffectType : PotionEffectType.values())
{
if (potionEffectType == null) continue;
String name = potionEffectType.getName();
if (name == null) continue;
ret.add(name);
}
// Return Ret
return ret;
}
@Override
public Collection<String> getTabList(CommandSender sender, String arg)
{
return this.altNames(sender);
}
@Override
public Collection<PotionEffectType> getAll(CommandSender sender)
{
return Arrays.asList(PotionEffectType.values());
}
// -------------------------------------------- //
// UTIL
// -------------------------------------------- //
public static String getComparable(PotionEffectType potionEffectType)
{
if (potionEffectType == null) return null;
return getComparable(potionEffectType.getName());
}
public static String getComparable(String string)
{
if (string == null) return null;
return string.toLowerCase();
}
}

View File

@ -1,86 +0,0 @@
package com.massivecraft.massivecore.cmd.type;
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.Set;
import org.bukkit.command.CommandSender;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.mixin.Mixin;
import com.massivecraft.massivecore.util.Txt;
public class TypeSet<E> extends TypeCollection<Set<E>>
{
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
protected final Type<E> elementType;
public Type<E> getElementType() { return this.elementType; }
@Override public Type<E> getInnerType() { return this.getElementType(); }
protected final boolean warnOnDuplicates;
public boolean getWarnOnDuplicate() { return warnOnDuplicates; }
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
public static <E> TypeSet<E> get(Type<E> elementType, boolean warnOnDuplicates)
{
return new TypeSet<E>(elementType, warnOnDuplicates);
}
public TypeSet(Type<E> elementType, boolean warnOnDuplicates)
{
this.elementType = elementType;
this.warnOnDuplicates = warnOnDuplicates;
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public String getTypeName()
{
return elementType.getTypeName();
}
// NOTE: Must be used with argConcatFrom and setErrorOnTooManyArgs(false).
@Override
public Set<E> read(String arg, CommandSender sender) throws MassiveException
{
// Split into inner args
String[] elementArgs = Txt.REGEX_WHITESPACE.split(arg);
// Create Ret
Set<E> ret = new LinkedHashSet<E>();
boolean duplicates = false;
// For Each
for (String elementArg : elementArgs)
{
E element = this.getElementType().read(elementArg, sender);
duplicates = ( ! ret.add(element) || duplicates);
}
if (warnOnDuplicates && duplicates)
{
Mixin.msgOne(sender, "<i>Some duplicate command input were removed.");
}
// Return Ret
return ret;
}
@Override
public Collection<String> getTabList(CommandSender sender, String arg)
{
return elementType.getTabList(sender, arg);
}
}

View File

@ -1,89 +0,0 @@
package com.massivecraft.massivecore.cmd.type;
import java.util.Arrays;
import java.util.Collection;
import java.util.Set;
import java.util.TreeSet;
import org.bukkit.Sound;
import org.bukkit.command.CommandSender;
import com.massivecraft.massivecore.MassiveException;
public class TypeSound extends TypeAbstract<Sound> implements TypeAllAble<Sound>
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static TypeSound i = new TypeSound();
public static TypeSound get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public Sound read(String arg, CommandSender sender) throws MassiveException
{
Sound result = getSoundFromString(arg);
if (result == null)
{
throw new MassiveException()
.addMsg("<b>No sound matches \"<h>%s<b>\".", arg)
.addMsg("<aqua>https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/browse/src/main/java/org/bukkit/Sound.java");
}
return result;
}
@Override
public Collection<String> getTabList(CommandSender sender, String arg)
{
Set<String> ret = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
for (Sound sound : Sound.values())
{
String name = getComparable(sound);
ret.add(name);
}
return ret;
}
@Override
public Collection<Sound> getAll(CommandSender sender)
{
return Arrays.asList(Sound.values());
}
// -------------------------------------------- //
// UTIL
// -------------------------------------------- //
public static Sound getSoundFromString(String str)
{
if (str == null) return null;
String string1 = getComparable(str);
for (Sound sound : Sound.values())
{
String compare = getComparable(sound);
if (string1.equals(compare)) return sound;
}
return null;
}
public static String getComparable(Sound sound)
{
if (sound == null) return null;
return getComparable(sound.name());
}
public static String getComparable(String string)
{
if (string == null) return null;
string = string.toLowerCase();
string = string.replaceAll("[^a-zA-Z0-9]", "");
return string;
}
}

View File

@ -1,49 +0,0 @@
package com.massivecraft.massivecore.cmd.type;
import java.util.Collection;
import java.util.Set;
import org.bukkit.command.CommandSender;
import com.massivecraft.massivecore.SoundEffect;
import com.massivecraft.massivecore.collections.MassiveSet;
public class TypeSoundEffect extends TypeAbstractException<SoundEffect>
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static TypeSoundEffect i = new TypeSoundEffect();
public static TypeSoundEffect get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public SoundEffect valueOf(String arg, CommandSender sender) throws Exception
{
return SoundEffect.valueOf(arg);
}
@Override
public Collection<String> getTabList(CommandSender sender, String arg)
{
Set<String> ret = new MassiveSet<String>();
for (String str : TypeSound.get().getTabList(sender, arg))
{
ret.add(str + "-");
}
return ret;
}
@Override
public boolean allowSpaceAfterTab()
{
return false;
}
}

View File

@ -1,73 +0,0 @@
package com.massivecraft.massivecore.cmd.type;
import java.util.ArrayList;
import java.util.Collection;
import org.bukkit.command.CommandSender;
import com.massivecraft.massivecore.Aspect;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.Multiverse;
import com.massivecraft.massivecore.collections.MassiveSet;
import com.massivecraft.massivecore.util.Txt;
public class TypeUniverse extends TypeAbstract<String>
{
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
protected Aspect aspect = null;
protected Multiverse multiverse = null;
public Multiverse getMultiverse()
{
if (this.aspect != null) return this.aspect.getMultiverse();
return this.multiverse;
}
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
public static TypeUniverse get(Aspect aspect) { return new TypeUniverse(aspect); }
public static TypeUniverse get(Multiverse multiverse) { return new TypeUniverse(multiverse); }
public TypeUniverse(Aspect aspect) { this.aspect = aspect; }
public TypeUniverse(Multiverse multiverse) { this.multiverse = multiverse; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public String read(String arg, CommandSender sender) throws MassiveException
{
Multiverse multiverse = this.getMultiverse();
if (multiverse.containsUniverse(arg))
{
return arg;
}
else
{
Collection<String> names = new ArrayList<String>(multiverse.getUniverses());
String format = Txt.parse("<h>%s");
String comma = Txt.parse("<i>, ");
String and = Txt.parse(" <i>or ");
String dot = Txt.parse("<i>.");
throw new MassiveException()
.addMsg("<b>No universe \"<h>%s<b>\" exists in multiverse <h>%s<b>.", arg, multiverse.getId())
.addMsg("<i>Use %s", Txt.implodeCommaAndDot(names, format, comma, and, dot));
}
}
@Override
public Collection<String> getTabList(CommandSender sender, String arg)
{
// MassiveSet is linked.
return new MassiveSet<String>(multiverse.getUniverses());
}
}

View File

@ -1,45 +0,0 @@
package com.massivecraft.massivecore.cmd.type;
import java.util.Collection;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import com.massivecraft.massivecore.MassiveException;
public class TypeWorld extends TypeAbstract<World>
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static TypeWorld i = new TypeWorld();
public static TypeWorld get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public World read(String arg, CommandSender sender) throws MassiveException
{
String worldId = TypeWorldId.get().read(arg, sender);
World ret = Bukkit.getWorld(worldId);
if (ret == null)
{
throw new MassiveException().addMsg("<b>The world \"<h>%s<b>\" could not be found.", arg);
}
return ret;
}
@Override
public Collection<String> getTabList(CommandSender sender, String arg)
{
return TypeWorldId.get().getTabList(sender, arg);
}
}

View File

@ -1,79 +0,0 @@
package com.massivecraft.massivecore.cmd.type;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.bukkit.command.CommandSender;
import com.massivecraft.massivecore.mixin.Mixin;
public class TypeWorldId extends TypeAbstractSelect<String> implements TypeAllAble<String>
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static TypeWorldId i = new TypeWorldId();
public static TypeWorldId get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public String getTypeName()
{
return "world";
}
@Override
public String select(String arg, CommandSender sender)
{
List<String> visibleWorldIds = Mixin.getVisibleWorldIds(sender);
for (String worldId : visibleWorldIds)
{
// This was already done above in Mixin.getVisibleWorldIds(sender);
// if ( ! Mixin.canSeeWorld(sender, worldId)) continue;
if (arg.equalsIgnoreCase(worldId)) return worldId;
}
for (String worldId : visibleWorldIds)
{
// This was already done above in Mixin.getVisibleWorldIds(sender);
// if ( ! Mixin.canSeeWorld(sender, worldId)) continue;
for (String worldAlias : Mixin.getWorldAliases(worldId))
{
if (arg.equalsIgnoreCase(worldAlias)) return worldId;
}
}
return null;
}
@Override
public List<String> altNames(CommandSender sender)
{
List<String> ret = new ArrayList<String>();
for (String worldId : Mixin.getWorldIds())
{
if ( ! Mixin.canSeeWorld(sender, worldId)) continue;
ret.add(Mixin.getWorldDisplayName(worldId));
}
return ret;
}
@Override
public Collection<String> getTabList(CommandSender sender, String arg)
{
return Mixin.getVisibleWorldIds(sender);
}
@Override
public Collection<String> getAll(CommandSender sender)
{
return Mixin.getVisibleWorldIds(sender);
}
}

View File

@ -1,91 +0,0 @@
package com.massivecraft.massivecore.cmd.type;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.bukkit.WorldType;
import org.bukkit.command.CommandSender;
import com.massivecraft.massivecore.util.MUtil;
public class TypeWorldType extends TypeAbstractSelect<WorldType>
{
// -------------------------------------------- //
// CONSTANTS
// -------------------------------------------- //
public static final List<String> ALT_NAMES = Collections.unmodifiableList(MUtil.list("normal", "flat", "1.1", "largebiomes"));
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static TypeWorldType i = new TypeWorldType();
public static TypeWorldType get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public WorldType select(String arg, CommandSender sender)
{
arg = getComparable(arg);
if (arg.equals(""))
{
// "normal" or "default"
return WorldType.NORMAL;
}
else if (arg.startsWith("flat"))
{
// "flat"
return WorldType.FLAT;
}
else if (arg.contains("11"))
{
// "VERSION_1_1"
return WorldType.VERSION_1_1;
}
else if (arg.contains("large"))
{
// "LARGE_BIOMES"
return WorldType.LARGE_BIOMES;
}
return null;
}
@Override
public Collection<String> altNames(CommandSender sender)
{
return ALT_NAMES;
}
@Override
public Collection<String> getTabList(CommandSender sender, String arg)
{
return this.altNames(sender);
}
// -------------------------------------------- //
// UTIL
// -------------------------------------------- //
public static String getComparable(String string)
{
// "DEFAULT_1_1" --> "11"
// "LARGE_BIOMES" --> "large"
// "Default" --> ""
string = string.toLowerCase();
string = string.replace("_", "");
string = string.replace(".", "");
string = string.replace("normal", "");
string = string.replace("default", "");
string = string.replace("biomes", "");
return string;
}
}

View File

@ -1,43 +0,0 @@
package com.massivecraft.massivecore.cmd.type;
import java.util.Collection;
import org.bukkit.command.CommandSender;
public abstract class TypeWrapper<T> extends TypeAbstract<T>
{
// -------------------------------------------- //
// ABSTRACT
// -------------------------------------------- //
public abstract Type<?> getInnerType();
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public String getTypeName()
{
return this.getInnerType().getTypeName();
}
@Override
public boolean isValid(String arg, CommandSender sender)
{
return this.getInnerType().isValid(arg, sender);
}
@Override
public Collection<String> getTabList(CommandSender sender, String arg)
{
return this.getInnerType().getTabList(sender, arg);
}
@Override
public boolean allowSpaceAfterTab()
{
return this.getInnerType().allowSpaceAfterTab();
}
}

View File

@ -1,7 +1,7 @@
package com.massivecraft.massivecore.cmd;
package com.massivecraft.massivecore.command;
import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.Visibility;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.Visibility;
public class DeprecatedCommand extends MassiveCommand

View File

@ -1,4 +1,4 @@
package com.massivecraft.massivecore.cmd;
package com.massivecraft.massivecore.command;
import java.util.ArrayList;
import java.util.List;

View File

@ -1,4 +1,4 @@
package com.massivecraft.massivecore.cmd;
package com.massivecraft.massivecore.command;
import java.util.ArrayList;
import java.util.Arrays;
@ -20,11 +20,11 @@ import org.bukkit.plugin.Plugin;
import com.massivecraft.massivecore.Lang;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.PredicateStartsWithIgnoreCase;
import com.massivecraft.massivecore.cmd.req.Req;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.cmd.type.Type;
import com.massivecraft.massivecore.collections.MassiveList;
import com.massivecraft.massivecore.collections.MassiveMap;
import com.massivecraft.massivecore.command.requirement.Requirement;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.command.type.Type;
import com.massivecraft.massivecore.mixin.Mixin;
import com.massivecraft.massivecore.mson.Mson;
import com.massivecraft.massivecore.util.PermUtil;
@ -114,7 +114,7 @@ public class MassiveCommand
// === REQUIREMENTS ===
// All these requirements must be met for the command to be executable;
protected List<Req> requirements = new ArrayList<Req>();
protected List<Requirement> requirements = new ArrayList<Requirement>();
// === HELP ===
@ -635,20 +635,20 @@ public class MassiveCommand
// REQUIREMENTS
// -------------------------------------------- //
public List<Req> getRequirements() { return this.requirements; }
public void setRequirements(List<Req> requirements) { this.requirements = requirements; }
public List<Requirement> getRequirements() { return this.requirements; }
public void setRequirements(List<Requirement> requirements) { this.requirements = requirements; }
public void addRequirements(Req... requirements) { this.requirements.addAll(Arrays.asList(requirements)); }
public void addRequirements(Requirement... requirements) { this.requirements.addAll(Arrays.asList(requirements)); }
public boolean isRequirementsMet(CommandSender sender, boolean informSenderIfNot)
{
for (Req req : this.getRequirements())
for (Requirement requirement : this.getRequirements())
{
if (req.apply(sender, this)) continue;
if (requirement.apply(sender, this)) continue;
if (informSenderIfNot)
{
Mixin.messageOne(sender, req.createErrorMessage(sender, this));
Mixin.messageOne(sender, requirement.createErrorMessage(sender, this));
}
return false;
}
@ -682,10 +682,10 @@ public class MassiveCommand
{
if (this.descPermission != null) return this.descPermission;
// Otherwise we try to find one.
for (Req req : this.getRequirements())
for (Requirement requirement : this.getRequirements())
{
if ( ! (req instanceof ReqHasPerm)) continue;
return ((ReqHasPerm)req).getPerm();
if ( ! (requirement instanceof RequirementHasPerm)) continue;
return ((RequirementHasPerm)requirement).getPerm();
}
return null;
}

View File

@ -1,4 +1,4 @@
package com.massivecraft.massivecore.cmd;
package com.massivecraft.massivecore.command;
import java.util.ArrayList;
import java.util.Collections;

View File

@ -1,12 +1,12 @@
package com.massivecraft.massivecore.cmd;
package com.massivecraft.massivecore.command;
import static com.massivecraft.massivecore.mson.Mson.mson;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.massivecraft.massivecore.cmd.type.TypeInteger;
import com.massivecraft.massivecore.cmd.type.Type;
import com.massivecraft.massivecore.command.type.Type;
import com.massivecraft.massivecore.command.type.primitive.TypeInteger;
import com.massivecraft.massivecore.mson.Mson;
public class Parameter<T>

View File

@ -1,4 +1,4 @@
package com.massivecraft.massivecore.cmd;
package com.massivecraft.massivecore.command;
import java.util.Arrays;
import java.util.Collection;
@ -7,8 +7,8 @@ import java.util.List;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.util.Txt;
public class VersionCommand extends MassiveCommand
@ -41,7 +41,7 @@ public class VersionCommand extends MassiveCommand
if (permissionName != null)
{
this.addRequirements(ReqHasPerm.get(permissionName));
this.addRequirements(RequirementHasPerm.get(permissionName));
}
this.setDesc("display plugin version");

View File

@ -1,4 +1,4 @@
package com.massivecraft.massivecore.cmd;
package com.massivecraft.massivecore.command;
public enum Visibility
{

View File

@ -0,0 +1,252 @@
package com.massivecraft.massivecore.command.editor;
import java.util.List;
import java.util.Map.Entry;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.Permission;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementEditorUse;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.command.type.Type;
import com.massivecraft.massivecore.util.MUtil;
import com.massivecraft.massivecore.util.PermUtil;
public class CommandEditAbstract<O, V> extends MassiveCommand
{
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
protected final EditSettings<O> settings;
public EditSettings<O> getSettings() { return this.settings; }
protected final Property<O, V> property;
public Property<O, V> getProperty() { return this.property; }
// Null is allowed and means unknown/either/neither.
protected final Boolean write;
public Boolean isWrite() { return this.write; }
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CommandEditAbstract(EditSettings<O> settings, Property<O, V> property, Boolean write)
{
// Fields
this.settings = settings;
this.property = property;
this.write = write;
// Aliases
this.setAliases(this.getProperty().getNames());
// Desc
this.setDesc("edit " + this.getProperty().getName());
// Requirements
this.addRequirements(RequirementEditorUse.get());
if (this.isWrite() != null && this.isWrite())
{
Permission permission = this.getPropertyPermission();
if (permission != null) this.addRequirements(RequirementHasPerm.get(permission.getName()));
}
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform() throws MassiveException
{
if (this.isParent())
{
super.perform();
}
else
{
msg("<b>Not yet implemented.");
}
}
// -------------------------------------------- //
// ATTEMPT SET
// -------------------------------------------- //
public void attemptSet(V after)
{
// Editable
if ( ! this.getProperty().isEditable())
{
msg("<b>The property <h>%s<b> is not editable.", this.getProperty().getDisplayName());
return;
}
// Permission
if ( ! PermUtil.has(sender, this.getPropertyPermission(), true)) return;
// Inherited / Source / Before
Entry<O, V> inherited = this.getInheritedEntry();
O source = inherited.getKey();
V before = inherited.getValue();
// Setup
String descProperty = this.getProperty().getDisplayName();
String descObject = this.getObjectVisual();
String descValue = this.getInheritedVisual(source, before);
// NoChange
// We check, inform and cancel on equality.
if (MUtil.equals(before, after))
{
msg("%s<silver> for %s<silver> already: %s", descProperty, descObject, descValue);
return;
}
// Startup
// We inform what property and object the edit is taking place on.
msg("%s<silver> for %s<silver> edited:", descProperty, descObject);
// Before
// We inform what the value was before.
msg("<k>Before: %s", descValue);
// Apply
// We set the new property value.
this.getProperty().setValue(this.getObject(), after);
// After
// We inform what the value is after.
descValue = this.getInheritedVisual();
msg("<k>After: %s", descValue);
}
// -------------------------------------------- //
// SHORTCUTS > EDITORSETTINGS
// -------------------------------------------- //
public Type<O> getObjectType()
{
return this.getSettings().getObjectType();
}
public O getObject(CommandSender sender)
{
return this.getSettings().getUsed(sender);
}
public O getObject()
{
return this.getSettings().getUsed(sender);
}
public Permission getPropertyPermission()
{
return this.getSettings().getPropertyPermission(this.getProperty());
}
public Permission getUsedPermission()
{
return this.getSettings().getUsedPermission();
}
public String getObjectVisual()
{
return this.getObjectType().getVisual(this.getObject(), sender);
}
// -------------------------------------------- //
// SHORTCUTS > PROPERTY
// -------------------------------------------- //
// Type
public Type<V> getValueType()
{
return this.getProperty().getValueType();
}
// Name
public String getPropertyName()
{
return this.getProperty().getName();
}
public List<String> getPropertyNames()
{
return this.getProperty().getNames();
}
// Access
public V getValue()
{
return this.getProperty().getValue(this.getObject());
}
public V setValue(V value)
{
return this.getProperty().setValue(this.getObject(), value);
}
public Entry<O, V> getInheritedEntry()
{
return this.getProperty().getInheritedEntry(this.getObject());
}
public O getInheritedObject()
{
return this.getProperty().getInheritedObject(this.getObject());
}
public V getInheritedValue()
{
return this.getProperty().getInheritedValue(this.getObject());
}
public String getInheritedVisual(O source, V value)
{
return this.getProperty().getInheritedVisual(this.getObject(), source, value, sender);
}
public String getInheritedVisual()
{
return this.getProperty().getInheritedVisual(this.getObject(), sender);
}
// -------------------------------------------- //
// SHORTCUTS > PROPERTY > TYPE
// -------------------------------------------- //
// Only to be used with collection type properties.
public Type<Object> getValueInnerType()
{
return this.getProperty().getValueType().getInnerType();
}
// -------------------------------------------- //
// UTIL
// -------------------------------------------- //
// Simply picks the last word in the class name.
public String createCommandAlias()
{
// Split at uppercase letters
final String[] words = this.getClass().getSimpleName().split("(?=[A-Z])");
String alias = words[words.length - 1];
alias = alias.toLowerCase();
return alias;
}
public void show(CommandSender sender)
{
String descProperty = this.getProperty().getDisplayName();
String descObject = this.getObjectVisual();
String descValue = this.getInheritedVisual();
msg("%s<silver> for %s<silver>: %s", descProperty, descObject, descValue);
}
}

View File

@ -0,0 +1,30 @@
package com.massivecraft.massivecore.command.editor;
import java.util.Collection;
public class CommandEditCollection<O, V extends Collection<?>> extends CommandEditAbstract<O, V>
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CommandEditCollection(EditSettings<O> settings, Property<O, V> property)
{
// Super
super(settings, property, null);
// Children
this.addChild(new CommandEditShow<O, V>(settings, property));
this.addChild(new CommandEditCreate<O, V>(settings, property));
this.addChild(new CommandEditDelete<O, V>(settings, property));
this.addChild(new CommandEditCollectionAdd<O, V>(settings, property));
this.addChild(new CommandEditCollectionInsert<O, V>(settings, property));
this.addChild(new CommandEditCollectionSet<O, V>(settings, property));
this.addChild(new CommandEditCollectionRemove<O, V>(settings, property));
this.addChild(new CommandEditCollectionMove<O, V>(settings, property));
this.addChild(new CommandEditCollectionSwap<O, V>(settings, property));
this.addChild(new CommandEditCollectionClear<O, V>(settings, property));
}
}

View File

@ -0,0 +1,85 @@
package com.massivecraft.massivecore.command.editor;
import java.util.Collection;
import java.util.List;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.collections.MassiveList;
import com.massivecraft.massivecore.command.requirement.RequirementEditorPropertyCreated;
public abstract class CommandEditCollectionAbstract<O, V extends Collection<?>> extends CommandEditAbstract<O, V>
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CommandEditCollectionAbstract(EditSettings<O> settings, Property<O, V> property)
{
// Super
super(settings, property, true);
// Aliases
String alias = this.createCommandAlias();
this.setAliases(alias);
// Desc
this.setDesc(alias + " " + this.getPropertyName());
// Requirements
this.addRequirements(RequirementEditorPropertyCreated.get(true));
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@SuppressWarnings("unchecked")
@Override
public void perform() throws MassiveException
{
// Create
List<Object> after = this.getShallowCopy();
// Alter
try
{
after = this.alter(after);
}
catch (MassiveException e)
{
throw e;
}
catch (Exception e)
{
throw new MassiveException().addMsg("<b>%s", e.getMessage());
}
// Apply
Collection<Object> toSet = null;
if (after != null)
{
toSet = (Collection<Object>) this.getProperty().getValueType().createNewInstance();
toSet.addAll(after);
}
this.attemptSet((V) toSet);
}
// -------------------------------------------- //
// ABSTRACT
// -------------------------------------------- //
public abstract List<Object> alter(List<Object> list) throws MassiveException;
// -------------------------------------------- //
// UTIL
// -------------------------------------------- //
public List<Object> getShallowCopy()
{
V ret = this.getProperty().getRaw(this.getObject());
if (ret == null) return null;
return new MassiveList<Object>(ret);
}
}

View File

@ -0,0 +1,40 @@
package com.massivecraft.massivecore.command.editor;
import java.util.Collection;
import java.util.List;
import com.massivecraft.massivecore.MassiveException;
public class CommandEditCollectionAdd<O, V extends Collection<?>> extends CommandEditCollectionAbstract<O, V>
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CommandEditCollectionAdd(EditSettings<O> settings, Property<O, V> property)
{
// Super
super(settings, property);
// Parameters
this.addParameter(this.getValueInnerType(), this.getProperty().getName(), true);
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public List<Object> alter(List<Object> list) throws MassiveException
{
// Args
Object element = this.readArg();
// Alter
list.add(element);
// Return
return list;
}
}

View File

@ -0,0 +1,34 @@
package com.massivecraft.massivecore.command.editor;
import java.util.Collection;
import java.util.List;
import com.massivecraft.massivecore.MassiveException;
public class CommandEditCollectionClear<O, V extends Collection<?>> extends CommandEditCollectionAbstract<O, V>
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CommandEditCollectionClear(EditSettings<O> settings, Property<O, V> property)
{
// Super
super(settings, property);
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public List<Object> alter(List<Object> list) throws MassiveException
{
// Apply
list.clear();
// Return
return list;
}
}

View File

@ -0,0 +1,43 @@
package com.massivecraft.massivecore.command.editor;
import java.util.Collection;
import java.util.List;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.command.type.primitive.TypeInteger;
public class CommandEditCollectionInsert<O, V extends Collection<?>> extends CommandEditCollectionAbstract<O, V>
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CommandEditCollectionInsert(EditSettings<O> settings, Property<O, V> property)
{
// Super
super(settings, property);
// Parameters
this.addParameter(TypeInteger.get(), "index");
this.addParameter(this.getValueInnerType(), this.getProperty().getName(), true);
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public List<Object> alter(List<Object> list) throws MassiveException
{
// Args
int index = this.readArg();
Object element = this.readArg();
// Alter
list.add(index, element);
// Return
return list;
}
}

View File

@ -0,0 +1,44 @@
package com.massivecraft.massivecore.command.editor;
import java.util.Collection;
import java.util.List;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.command.type.primitive.TypeInteger;
public class CommandEditCollectionMove<O, V extends Collection<?>> extends CommandEditCollectionAbstract<O, V>
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CommandEditCollectionMove(EditSettings<O> settings, Property<O, V> property)
{
// Super
super(settings, property);
// Parameters
this.addParameter(TypeInteger.get(), "indexFrom");
this.addParameter(TypeInteger.get(), "indexTo");
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public List<Object> alter(List<Object> list) throws MassiveException
{
// Args
int indexFrom = this.readArg();
int indexTo = this.readArg();
// Alter
Object element = list.remove(indexFrom);
list.add(indexTo, element);
// Return
return list;
}
}

View File

@ -0,0 +1,41 @@
package com.massivecraft.massivecore.command.editor;
import java.util.Collection;
import java.util.List;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.command.type.primitive.TypeInteger;
public class CommandEditCollectionRemove<O, V extends Collection<?>> extends CommandEditCollectionAbstract<O, V>
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CommandEditCollectionRemove(EditSettings<O> settings, Property<O, V> property)
{
// Super
super(settings, property);
// Parameters
this.addParameter(TypeInteger.get(), "index");
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public List<Object> alter(List<Object> list) throws MassiveException
{
// Args
int index = this.readArg();
// Alter
list.remove(index);
// Return
return list;
}
}

View File

@ -0,0 +1,43 @@
package com.massivecraft.massivecore.command.editor;
import java.util.Collection;
import java.util.List;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.command.type.primitive.TypeInteger;
public class CommandEditCollectionSet<O, V extends Collection<?>> extends CommandEditCollectionAbstract<O, V>
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CommandEditCollectionSet(EditSettings<O> settings, Property<O, V> property)
{
// Super
super(settings, property);
// Parameters
this.addParameter(TypeInteger.get(), "index");
this.addParameter(this.getValueInnerType(), this.getProperty().getName(), true);
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public List<Object> alter(List<Object> list) throws MassiveException
{
// Args
int index = this.readArg();
Object element = this.readArg();
// Alter
list.set(index, element);
// Return
return list;
}
}

View File

@ -0,0 +1,46 @@
package com.massivecraft.massivecore.command.editor;
import java.util.Collection;
import java.util.List;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.command.type.primitive.TypeInteger;
public class CommandEditCollectionSwap<O, V extends Collection<?>> extends CommandEditCollectionAbstract<O, V>
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CommandEditCollectionSwap(EditSettings<O> settings, Property<O, V> property)
{
// Super
super(settings, property);
// Parameters
this.addParameter(TypeInteger.get(), "indexOne");
this.addParameter(TypeInteger.get(), "indexTwo");
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public List<Object> alter(List<Object> list) throws MassiveException
{
// Args
int indexOne = this.readArg();
int indexTwo = this.readArg();
// Alter
Object one = list.get(indexOne);
Object two = list.get(indexTwo);
list.set(indexOne, two);
list.set(indexTwo, one);
// Return
return list;
}
}

View File

@ -0,0 +1,39 @@
package com.massivecraft.massivecore.command.editor;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.command.requirement.RequirementEditorPropertyCreated;
public class CommandEditCreate<O, V> extends CommandEditAbstract<O, V>
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CommandEditCreate(EditSettings<O> settings, Property<O, V> property)
{
// Super
super(settings, property, true);
// Aliases
String alias = this.createCommandAlias();
this.setAliases(alias);
// Desc
this.setDesc(alias + " " + this.getPropertyName());
// Requirements
this.addRequirements(RequirementEditorPropertyCreated.get(false));
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform() throws MassiveException
{
V newInstance = this.getValueType().createNewInstance();
this.attemptSet(newInstance);
}
}

View File

@ -0,0 +1,38 @@
package com.massivecraft.massivecore.command.editor;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.command.requirement.RequirementEditorPropertyCreated;
public class CommandEditDelete<O, V> extends CommandEditAbstract<O, V>
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CommandEditDelete(EditSettings<O> settings, Property<O, V> property)
{
// Super
super(settings, property, true);
// Aliases
String alias = this.createCommandAlias();
this.setAliases(alias);
// Desc
this.setDesc(alias + " " + this.getPropertyName());
// Requirements
this.addRequirements(RequirementEditorPropertyCreated.get(true));
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform() throws MassiveException
{
this.attemptSet(null);
}
}

View File

@ -0,0 +1,25 @@
package com.massivecraft.massivecore.command.editor;
import java.util.List;
import org.bukkit.inventory.ItemStack;
public class CommandEditItemStacks<O> extends CommandEditAbstract<O, List<ItemStack>>
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CommandEditItemStacks(EditSettings<O> settings, Property<O, List<ItemStack>> property)
{
// Super
super(settings, property, true);
// Children
this.addChild(new CommandEditShow<O, List<ItemStack>>(settings, property));
this.addChild(new CommandEditCreate<O, List<ItemStack>>(settings, property));
this.addChild(new CommandEditDelete<O, List<ItemStack>>(settings, property));
this.addChild(new CommandEditItemStacksOpen<O>(settings, property));
}
}

View File

@ -0,0 +1,31 @@
package com.massivecraft.massivecore.command.editor;
import java.util.List;
import org.bukkit.inventory.ItemStack;
import com.massivecraft.massivecore.command.requirement.RequirementEditorPropertyCreated;
public abstract class CommandEditItemStacksAbstract<O> extends CommandEditAbstract<O, List<ItemStack>>
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CommandEditItemStacksAbstract(EditSettings<O> settings, Property<O, List<ItemStack>> property)
{
// Super
super(settings, property, true);
// Aliases
String alias = this.createCommandAlias();
this.setAliases(alias);
// Desc
this.setDesc(alias + " " + this.getPropertyName());
// Requirements
this.addRequirements(RequirementEditorPropertyCreated.get(true));
}
}

View File

@ -0,0 +1,161 @@
package com.massivecraft.massivecore.command.editor;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import com.massivecraft.massivecore.MassiveCore;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.collections.MassiveList;
import com.massivecraft.massivecore.collections.MassiveSet;
import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer;
import com.massivecraft.massivecore.mixin.Mixin;
import com.massivecraft.massivecore.util.InventoryUtil;
import com.massivecraft.massivecore.util.MUtil;
public class CommandEditItemStacksOpen<O> extends CommandEditItemStacksAbstract<O> implements Listener
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CommandEditItemStacksOpen(EditSettings<O> settings, Property<O, List<ItemStack>> property)
{
// Super
super(settings, property);
// Requirements
this.addRequirements(RequirementIsPlayer.get());
// Listener
Bukkit.getPluginManager().registerEvents(this, MassiveCore.get());
}
// -------------------------------------------- //
// EDITING
// -------------------------------------------- //
protected Set<UUID> playerIds = new MassiveSet<UUID>();
public void setEditing(Player player, boolean editing)
{
UUID playerId = player.getUniqueId();
if (editing)
{
this.playerIds.add(playerId);
}
else
{
this.playerIds.remove(playerId);
}
}
public boolean isEditing(Player player)
{
UUID playerId = player.getUniqueId();
return this.playerIds.contains(playerId);
}
// -------------------------------------------- //
// LISTENER
// -------------------------------------------- //
// Not Cancellable
@EventHandler(priority = EventPriority.NORMAL)
public void onInventoryClose(InventoryCloseEvent event)
{
// If a player closes an inventory ...
if (MUtil.isntPlayer(event.getPlayer())) return;
Player player = (Player)event.getPlayer();
// ... and that player is editing ...
if ( ! this.isEditing(player)) return;
// ... set the player as not editing ...
this.setEditing(player, false);
// ... load the item stacks into a list ...
List<ItemStack> after = asList(event.getInventory());
// ... attempt set.
this.senderFieldsOuter(player);
this.attemptSet(after);
this.senderFieldsOuter(null);
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform() throws MassiveException
{
// Get Before
List<ItemStack> before = this.getProperty().getRaw(this.getObject());
// Open Chest
Inventory chest = asChest(before);
this.setEditing(me, true);
me.openInventory(chest);
}
// -------------------------------------------- //
// CONVERT LIST <--> CHEST
// -------------------------------------------- //
public Inventory asChest(List<ItemStack> itemStacks)
{
// Dodge Null
if (itemStacks == null) return null;
// Create Ret
Inventory ret = Mixin.createInventory(me, 54, this.getProperty().getName());
// Fill Ret
for (int i = 0; i < itemStacks.size(); i++)
{
ItemStack itemStack = itemStacks.get(i);
if (InventoryUtil.isNothing(itemStack)) continue;
itemStack = new ItemStack(itemStack);
ret.setItem(i, itemStack);
}
// Return Ret
return ret;
}
public List<ItemStack> asList(Inventory inventory)
{
// Dodge Null
if (inventory == null) return null;
// Create Ret
List<ItemStack> ret = new MassiveList<ItemStack>();
// Fill Ret
for (int i = 0; i < inventory.getSize(); i++)
{
ItemStack itemStack = inventory.getItem(i);
if (InventoryUtil.isNothing(itemStack)) continue;
itemStack = new ItemStack(itemStack);
ret.add(itemStack);
}
// Return Ret
return ret;
}
}

View File

@ -0,0 +1,36 @@
package com.massivecraft.massivecore.command.editor;
import java.util.Collection;
import com.massivecraft.massivecore.MassiveException;
public class CommandEditShow<O, V extends Collection<?>> extends CommandEditAbstract<O, V>
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CommandEditShow(EditSettings<O> settings, Property<O, V> property)
{
// Super
super(settings, property, false);
// Aliases
String alias = this.createCommandAlias();
this.setAliases(alias);
// Desc
this.setDesc(alias + " " + this.getPropertyName());
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform() throws MassiveException
{
this.show(sender);
}
}

View File

@ -0,0 +1,46 @@
package com.massivecraft.massivecore.command.editor;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.command.type.TypeNullable;
import com.massivecraft.massivecore.util.PermUtil;
public class CommandEditSimple<O, V> extends CommandEditAbstract<O, V>
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CommandEditSimple(EditSettings<O> settings, Property<O, V> property)
{
// Super
super(settings, property, null);
// Parameters
this.addParameter(TypeNullable.get(this.getProperty().getValueType()), "set", "show", true);
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform() throws MassiveException
{
// Show
if ( ! this.argIsSet(0))
{
this.show(sender);
return;
}
// Permission
if ( ! PermUtil.has(sender, this.getPropertyPermission(), true)) return;
// Arguments
V after = this.readArg();
// Apply
this.attemptSet(after);
}
}

View File

@ -0,0 +1,23 @@
package com.massivecraft.massivecore.command.editor;
import org.bukkit.command.CommandSender;
public class CommandEditUsed<O> extends CommandEditSimple<CommandSender, O>
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CommandEditUsed(EditSettings<O> settings)
{
// Super
super(settings.createUsedSettings(), settings.getUsedProperty());
// Aliases
this.setAliases("used", "selected");
// Desc
this.setDesc("edit used " + this.getProperty().getValueType().getTypeName());
}
}

View File

@ -0,0 +1,105 @@
package com.massivecraft.massivecore.command.editor;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.Permission;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.command.type.Type;
import com.massivecraft.massivecore.command.type.sender.TypeSender;
import com.massivecraft.massivecore.util.Txt;
public class EditSettings<O>
{
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
// This is the type of the object we are editing.
protected final Type<O> objectType;
public Type<O> getObjectType() { return this.objectType; }
// This property is used to get the object we are editing from the sender.
protected Property<CommandSender, O> usedProperty;
public Property<CommandSender, O> getUsedProperty() { return this.usedProperty; }
public void setUsedProperty(Property<CommandSender, O> usedProperty) { this.usedProperty = usedProperty; }
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
public EditSettings(Type<O> objectType, Property<CommandSender, O> objectProperty)
{
this.objectType = objectType;
this.usedProperty = objectProperty;
}
public EditSettings(Type<O> objectType)
{
this(objectType, null);
}
public EditSettings<CommandSender> createUsedSettings()
{
final EditSettings<O> main = this;
return new EditSettings<CommandSender>(TypeSender.get(), new PropertyThis<CommandSender>(TypeSender.get())) {
@Override
public Permission getPropertyPermission(Property<CommandSender,?> property)
{
return main.getUsedPermission();
};
};
}
// -------------------------------------------- //
// OBJECT
// -------------------------------------------- //
public O getUsed(CommandSender sender)
{
return this.getUsedProperty().getValue(sender);
}
public void setUsed(CommandSender sender, O used)
{
this.getUsedProperty().setValue(sender, used);
}
// -------------------------------------------- //
// USED COMMAND
// -------------------------------------------- //
public CommandEditUsed<O> createCommandEditUsed()
{
return new CommandEditUsed<O>(this);
}
// -------------------------------------------- //
// PERMISSONS
// -------------------------------------------- //
public Permission getPropertyPermission(Property<O, ?> property)
{
return null;
}
public Permission getUsedPermission()
{
return null;
}
// -------------------------------------------- //
// TYPE READ UTILITY
// -------------------------------------------- //
public O getUsedOrCommandException(CommandSender sender) throws MassiveException
{
O ret = this.getUsed(sender);
if (ret != null) return ret;
String noun = this.getObjectType().getTypeName();
String aan = Txt.aan(noun);
throw new MassiveException().addMsg("<b>You must select %s %s for use to skip the optional argument.", aan, noun);
}
}

View File

@ -0,0 +1,184 @@
package com.massivecraft.massivecore.command.editor;
import java.util.List;
import java.util.Map.Entry;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import java.util.AbstractMap.SimpleEntry;
import java.util.Arrays;
import java.util.Collection;
import com.massivecraft.massivecore.Named;
import com.massivecraft.massivecore.collections.MassiveList;
import com.massivecraft.massivecore.command.type.Type;
import com.massivecraft.massivecore.store.Entity;
import com.massivecraft.massivecore.util.MUtil;
import com.massivecraft.massivecore.util.Txt;
public abstract class Property<O, V> implements Named
{
// -------------------------------------------- //
// TYPE
// -------------------------------------------- //
protected Type<O> objectType = null;
public Type<O> getObjectType() { return this.objectType; }
public void setObjectType(Type<O> objectType) { this.objectType = objectType; }
protected Type<V> valueType = null;
public Type<V> getValueType() { return this.valueType; }
public void setValueType(Type<V> valueType) { this.valueType = valueType; }
// -------------------------------------------- //
// SETTINGS
// -------------------------------------------- //
protected boolean inheritable = true;
public boolean isInheritable() { return this.inheritable; }
public void setInheritable(boolean inheritable) { this.inheritable = inheritable; }
protected boolean editable = true;
public boolean isEditable() { return this.editable; }
public void setEditable(boolean editable) { this.editable = editable; }
// -------------------------------------------- //
// NAME
// -------------------------------------------- //
protected List<String> names = new MassiveList<String>();
public List<String> getNames() { return this.names; }
@Override public String getName() { return this.getNames().isEmpty() ? null : this.getNames().get(0); }
public void setName(String name) { this.names = new MassiveList<String>(name); }
public void setNames(String... names) { this.names = new MassiveList<String>(names); }
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public Property(Type<O> objectType, Type<V> valueType, Collection<String> names)
{
this.objectType = objectType;
this.valueType = valueType;
this.names = new MassiveList<String>(names);
}
public Property(Type<O> objectType, Type<V> valueType, String... names)
{
this(objectType, valueType, Arrays.asList(names));
}
// -------------------------------------------- //
// ACCESS
// -------------------------------------------- //
public abstract V getRaw(O object);
public abstract void setRaw(O object, V value);
public V getValue(O object)
{
return this.getRaw(object);
}
public V setValue(O object, V value)
{
// Get Before
V before = this.getRaw(object);
// Get Live Entity
Entity<?> entity = null;
if (object instanceof Entity) entity = (Entity<?>)object;
if (entity != null && ! entity.isLive()) entity = null;
// NoChange
if (entity != null && MUtil.equals(before, value)) return before;
// Apply
this.setRaw(object, value);
// Mark Change
if (entity != null) entity.changed();
// On Change
this.onChange(object, before, value);
// Return Before
return before;
}
// -------------------------------------------- //
// ON CHANGE
// -------------------------------------------- //
public void onChange(O object, V before, V after)
{
}
// -------------------------------------------- //
// INHERITED
// -------------------------------------------- //
public Entry<O, V> getInheritedEntry(O object)
{
if (object == null) return new SimpleEntry<O, V>(null, null);
V value = this.getValue(object);
return new SimpleEntry<O, V>(object, value);
}
public O getInheritedObject(O object)
{
return this.getInheritedEntry(object).getKey();
}
public V getInheritedValue(O object)
{
return this.getInheritedEntry(object).getValue();
}
// -------------------------------------------- //
// SHORTCUTS
// -------------------------------------------- //
public CommandEditAbstract<O, V> createEditCommand(EditSettings<O> settings)
{
return this.getValueType().createEditCommand(settings, this);
}
public String getDisplayName()
{
return ChatColor.AQUA.toString() + this.getName();
}
public String getInheritedVisual(O object, O source, V value, CommandSender sender)
{
String string = this.getValueType().getVisual(value, sender);
if (string == null)
{
System.out.println("value type " + this.getValueType());
System.out.println("value type name" + this.getValueType().getTypeName());
System.out.println("object " + object);
System.out.println("source " + source);
System.out.println("value " + value);
System.out.println("sender " + sender);
}
String suffix = null;
if (source != null && ! source.equals(object))
{
suffix = Txt.parse("<silver>[%s<silver>]", this.getObjectType().getVisual(source));
}
return Txt.prepondfix(null, string, suffix);
}
public String getInheritedVisual(O object, CommandSender sender)
{
Entry<O, V> inherited = this.getInheritedEntry(object);
O source = inherited.getKey();
V value = inherited.getValue();
return this.getInheritedVisual(object, source, value, sender);
}
}

View File

@ -0,0 +1,32 @@
package com.massivecraft.massivecore.command.editor;
import com.massivecraft.massivecore.command.type.Type;
public class PropertyThis<O> extends Property<O, O>
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public PropertyThis(Type<O> objectType)
{
super(objectType, objectType, "this");
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public O getRaw(O object)
{
return object;
}
@Override
public void setRaw(O object, O value)
{
return;
}
}

View File

@ -0,0 +1,18 @@
package com.massivecraft.massivecore.command.editor;
import org.bukkit.command.CommandSender;
import com.massivecraft.massivecore.command.type.sender.TypeSender;
public abstract class PropertyUsed<V> extends Property<CommandSender, V>
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public PropertyUsed(EditSettings<V> settings)
{
super(TypeSender.get(), settings.getObjectType(), "used " + settings.getObjectType().getTypeName());
}
}

View File

@ -1,10 +1,10 @@
package com.massivecraft.massivecore.cmd.massivecore;
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.MassiveCore;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.VersionCommand;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.VersionCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
public class CmdMassiveCore extends MassiveCommand
{
@ -38,7 +38,7 @@ public class CmdMassiveCore extends MassiveCommand
this.addChild(this.cmdMassiveCoreVersion);
// Requirements
this.addRequirements(ReqHasPerm.get(MassiveCorePerm.BASECOMMAND.node));
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.BASECOMMAND.node));
}
}

View File

@ -1,8 +1,8 @@
package com.massivecraft.massivecore.cmd.massivecore;
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
public class CmdMassiveCoreBuffer extends MassiveCommand
{
@ -33,7 +33,7 @@ public class CmdMassiveCoreBuffer extends MassiveCommand
this.addAliases("buffer");
// Requirements
this.addRequirements(ReqHasPerm.get(MassiveCorePerm.BUFFER.node));
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.BUFFER.node));
}
}

View File

@ -1,11 +1,11 @@
package com.massivecraft.massivecore.cmd.massivecore;
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.MassiveCoreEngineVariable;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.cmd.type.TypeString;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.command.type.primitive.TypeString;
public class CmdMassiveCoreBufferAdd extends MassiveCommand
{
@ -22,7 +22,7 @@ public class CmdMassiveCoreBufferAdd extends MassiveCommand
this.addParameter(TypeString.get(), "text", true).setDesc("the text to add to your buffer");
// Requirements
this.addRequirements(ReqHasPerm.get(MassiveCorePerm.BUFFER_ADD.node));
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.BUFFER_ADD.node));
}
// -------------------------------------------- //

View File

@ -1,9 +1,9 @@
package com.massivecraft.massivecore.cmd.massivecore;
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.MassiveCoreEngineVariable;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
public class CmdMassiveCoreBufferClear extends MassiveCommand
{
@ -17,7 +17,7 @@ public class CmdMassiveCoreBufferClear extends MassiveCommand
this.addAliases("clear");
// Requirements
this.addRequirements(ReqHasPerm.get(MassiveCorePerm.BUFFER_CLEAR.node));
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.BUFFER_CLEAR.node));
}
// -------------------------------------------- //

View File

@ -1,9 +1,9 @@
package com.massivecraft.massivecore.cmd.massivecore;
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.MassiveCoreEngineVariable;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
public class CmdMassiveCoreBufferPrint extends MassiveCommand
{
@ -17,7 +17,7 @@ public class CmdMassiveCoreBufferPrint extends MassiveCommand
this.addAliases("print");
// Requirements
this.addRequirements(ReqHasPerm.get(MassiveCorePerm.BUFFER_PRINT.node));
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.BUFFER_PRINT.node));
}
// -------------------------------------------- //

View File

@ -1,11 +1,11 @@
package com.massivecraft.massivecore.cmd.massivecore;
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.MassiveCoreEngineVariable;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.cmd.type.TypeString;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.command.type.primitive.TypeString;
public class CmdMassiveCoreBufferSet extends MassiveCommand
{
@ -22,7 +22,7 @@ public class CmdMassiveCoreBufferSet extends MassiveCommand
this.addParameter(TypeString.get(), "text", true).setDesc("the text to set your buffer to");
// Requirements
this.addRequirements(ReqHasPerm.get(MassiveCorePerm.BUFFER_SET.node));
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.BUFFER_SET.node));
}
// -------------------------------------------- //

View File

@ -1,11 +1,11 @@
package com.massivecraft.massivecore.cmd.massivecore;
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.MassiveCoreEngineVariable;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.cmd.type.TypeInteger;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.command.type.primitive.TypeInteger;
import com.massivecraft.massivecore.util.Txt;
public class CmdMassiveCoreBufferWhitespace extends MassiveCommand
@ -23,7 +23,7 @@ public class CmdMassiveCoreBufferWhitespace extends MassiveCommand
this.addParameter(1, TypeInteger.get(), "times").setDesc("the amount of whitespace to add to your buffer");
// Requirements
this.addRequirements(ReqHasPerm.get(MassiveCorePerm.BUFFER_WHITESPACE.node));
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.BUFFER_WHITESPACE.node));
}
// -------------------------------------------- //

View File

@ -1,4 +1,4 @@
package com.massivecraft.massivecore.cmd.massivecore;
package com.massivecraft.massivecore.command.massivecore;
import java.net.MalformedURLException;
import java.net.URL;
@ -10,10 +10,10 @@ import org.bukkit.entity.Player;
import com.massivecraft.massivecore.MassiveCore;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
import com.massivecraft.massivecore.cmd.type.TypeString;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer;
import com.massivecraft.massivecore.command.type.primitive.TypeString;
import com.massivecraft.massivecore.mixin.Mixin;
import com.massivecraft.massivecore.util.WebUtil;
@ -32,8 +32,8 @@ public class CmdMassiveCoreCmdurl extends MassiveCommand
this.addParameter(TypeString.get(), "url").setDesc("the url to load");
// Requirements
this.addRequirements(ReqHasPerm.get(MassiveCorePerm.CMDURL.node));
this.addRequirements(ReqIsPlayer.get());
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.CMDURL.node));
this.addRequirements(RequirementIsPlayer.get());
}
// -------------------------------------------- //

View File

@ -1,15 +1,15 @@
package com.massivecraft.massivecore.cmd.massivecore;
package com.massivecraft.massivecore.command.massivecore;
import java.util.List;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.SoundEffect;
import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
import com.massivecraft.massivecore.cmd.type.TypeList;
import com.massivecraft.massivecore.cmd.type.TypeSoundEffect;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer;
import com.massivecraft.massivecore.command.type.collection.TypeList;
import com.massivecraft.massivecore.command.type.combined.TypeSoundEffect;
public class CmdMassiveCoreHearsound extends MassiveCommand
{
@ -26,8 +26,8 @@ public class CmdMassiveCoreHearsound extends MassiveCommand
this.addParameter(TypeList.get(TypeSoundEffect.get()), "sound(s)", true).setDesc("the sounds to hear");
// Requirements
this.addRequirements(ReqHasPerm.get(MassiveCorePerm.HEARSOUND.node));
this.addRequirements(ReqIsPlayer.get());
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.HEARSOUND.node));
this.addRequirements(RequirementIsPlayer.get());
}
// -------------------------------------------- //

View File

@ -1,9 +1,9 @@
package com.massivecraft.massivecore.cmd.massivecore;
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.ConfServer;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
public class CmdMassiveCoreId extends MassiveCommand
{
@ -17,7 +17,7 @@ public class CmdMassiveCoreId extends MassiveCommand
this.addAliases("id");
// Requirements
this.addRequirements(ReqHasPerm.get(MassiveCorePerm.ID.node));
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.ID.node));
}
// -------------------------------------------- //

View File

@ -1,8 +1,8 @@
package com.massivecraft.massivecore.cmd.massivecore;
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
public class CmdMassiveCoreStore extends MassiveCommand
{
@ -29,7 +29,7 @@ public class CmdMassiveCoreStore extends MassiveCommand
this.addAliases("store");
// Requirements
this.addRequirements(ReqHasPerm.get(MassiveCorePerm.STORE.node));
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.STORE.node));
}
}

View File

@ -1,4 +1,4 @@
package com.massivecraft.massivecore.cmd.massivecore;
package com.massivecraft.massivecore.command.massivecore;
import java.util.Collection;
import java.util.Map.Entry;
@ -7,9 +7,9 @@ import java.util.Set;
import com.massivecraft.massivecore.MassiveCore;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.cmd.type.TypeString;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.command.type.primitive.TypeString;
import com.massivecraft.massivecore.store.Coll;
import com.massivecraft.massivecore.store.Db;
import com.massivecraft.massivecore.store.MStore;
@ -31,7 +31,7 @@ public class CmdMassiveCoreStoreCopydb extends MassiveCommand
this.addParameter(TypeString.get(), "to").setDesc("the database to copy to");
// Requirements
this.addRequirements(ReqHasPerm.get(MassiveCorePerm.STORE_COPYDB.node));
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.STORE_COPYDB.node));
}
// -------------------------------------------- //

View File

@ -1,4 +1,4 @@
package com.massivecraft.massivecore.cmd.massivecore;
package com.massivecraft.massivecore.command.massivecore;
import java.util.Set;
import java.util.TreeSet;
@ -7,9 +7,9 @@ import com.massivecraft.massivecore.ConfServer;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.NaturalOrderComparator;
import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.cmd.type.TypeString;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.command.type.primitive.TypeString;
import com.massivecraft.massivecore.store.Coll;
import com.massivecraft.massivecore.store.Db;
import com.massivecraft.massivecore.store.MStore;
@ -30,7 +30,7 @@ public class CmdMassiveCoreStoreListcolls extends MassiveCommand
this.addParameter(TypeString.get(), "db", ConfServer.dburi).setDesc("the database to list colls from");
// Requirements
this.addRequirements(ReqHasPerm.get(MassiveCorePerm.STORE_LISTCOLLS.node));
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.STORE_LISTCOLLS.node));
}
// -------------------------------------------- //

View File

@ -1,12 +1,12 @@
package com.massivecraft.massivecore.cmd.massivecore;
package com.massivecraft.massivecore.command.massivecore;
import java.util.Map.Entry;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.cmd.type.TypeColl;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.command.type.store.TypeColl;
import com.massivecraft.massivecore.store.Coll;
import com.massivecraft.massivecore.store.ExamineThread;
import com.massivecraft.massivecore.util.MUtil;
@ -27,7 +27,7 @@ public class CmdMassiveCoreStoreStats extends MassiveCommand
this.addParameter(TypeColl.get(), "coll", Coll.TOTAL).setDesc("the coll to show info about");
// Requirements
this.addRequirements(ReqHasPerm.get(MassiveCorePerm.STORE_STATS.node));
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.STORE_STATS.node));
}
// -------------------------------------------- //

View File

@ -1,7 +1,7 @@
package com.massivecraft.massivecore.cmd.massivecore;
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.command.MassiveCommand;
public class CmdMassiveCoreTest extends MassiveCommand
{

View File

@ -1,8 +1,8 @@
package com.massivecraft.massivecore.cmd.massivecore;
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
public class CmdMassiveCoreUsys extends MassiveCommand
{
@ -31,7 +31,7 @@ public class CmdMassiveCoreUsys extends MassiveCommand
this.addAliases("usys");
// Requirements
this.addRequirements(ReqHasPerm.get(MassiveCorePerm.USYS.node));
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.USYS.node));
}
}

View File

@ -1,8 +1,8 @@
package com.massivecraft.massivecore.cmd.massivecore;
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
public class CmdMassiveCoreUsysAspect extends MassiveCommand
{
@ -29,7 +29,7 @@ public class CmdMassiveCoreUsysAspect extends MassiveCommand
this.addAliases("aspect");
// Requirements
this.addRequirements(ReqHasPerm.get(MassiveCorePerm.USYS_ASPECT.node));
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.USYS_ASPECT.node));
}
}

View File

@ -1,12 +1,12 @@
package com.massivecraft.massivecore.cmd.massivecore;
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.Aspect;
import com.massivecraft.massivecore.AspectColl;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.cmd.Parameter;
import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.Parameter;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.pager.Pager;
import com.massivecraft.massivecore.pager.Stringifier;
import com.massivecraft.massivecore.util.Txt;
@ -26,7 +26,7 @@ public class CmdMassiveCoreUsysAspectList extends MassiveCommand
this.addParameter(Parameter.getPage()).setDesc("the page in the aspect list");
// Requirements
this.addRequirements(ReqHasPerm.get(MassiveCorePerm.USYS_ASPECT_LIST.node));
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.USYS_ASPECT_LIST.node));
}
// -------------------------------------------- //

View File

@ -1,11 +1,11 @@
package com.massivecraft.massivecore.cmd.massivecore;
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.Aspect;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.cmd.type.TypeAspect;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.command.type.store.TypeAspect;
import com.massivecraft.massivecore.util.Txt;
public class CmdMassiveCoreUsysAspectShow extends MassiveCommand
@ -23,7 +23,7 @@ public class CmdMassiveCoreUsysAspectShow extends MassiveCommand
this.addParameter(TypeAspect.get(), "aspect").setDesc("the aspect to show info about");
// Requirements
this.addRequirements(ReqHasPerm.get(MassiveCorePerm.USYS_ASPECT_SHOW.node));
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.USYS_ASPECT_SHOW.node));
}
// -------------------------------------------- //

View File

@ -1,13 +1,13 @@
package com.massivecraft.massivecore.cmd.massivecore;
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.Aspect;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.Multiverse;
import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.cmd.type.TypeAspect;
import com.massivecraft.massivecore.cmd.type.TypeMultiverse;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.command.type.store.TypeAspect;
import com.massivecraft.massivecore.command.type.store.TypeMultiverse;
public class CmdMassiveCoreUsysAspectUse extends MassiveCommand
{
@ -25,7 +25,7 @@ public class CmdMassiveCoreUsysAspectUse extends MassiveCommand
this.addParameter(TypeMultiverse.get(), "multiverse").setDesc("the multiverse which the aspect should use");
// Requirements
this.addRequirements(ReqHasPerm.get(MassiveCorePerm.USYS_ASPECT_USE.node));
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.USYS_ASPECT_USE.node));
}
// -------------------------------------------- //

View File

@ -1,8 +1,8 @@
package com.massivecraft.massivecore.cmd.massivecore;
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
public class CmdMassiveCoreUsysMultiverse extends MassiveCommand
{
@ -31,7 +31,7 @@ public class CmdMassiveCoreUsysMultiverse extends MassiveCommand
this.addAliases("multiverse");
// Requirements
this.addRequirements(ReqHasPerm.get(MassiveCorePerm.USYS_MULTIVERSE.node));
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.USYS_MULTIVERSE.node));
}
}

View File

@ -1,12 +1,12 @@
package com.massivecraft.massivecore.cmd.massivecore;
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.MassiveCore;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.Multiverse;
import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.cmd.type.TypeMultiverse;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.command.type.store.TypeMultiverse;
public class CmdMassiveCoreUsysMultiverseDel extends MassiveCommand
{
@ -23,7 +23,7 @@ public class CmdMassiveCoreUsysMultiverseDel extends MassiveCommand
this.addParameter(TypeMultiverse.get(), "multiverse").setDesc("the multiverse to delete");
// Requirements
this.addRequirements(ReqHasPerm.get(MassiveCorePerm.USYS_MULTIVERSE_DEL.node));
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.USYS_MULTIVERSE_DEL.node));
}
// -------------------------------------------- //

View File

@ -1,12 +1,12 @@
package com.massivecraft.massivecore.cmd.massivecore;
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.Multiverse;
import com.massivecraft.massivecore.MultiverseColl;
import com.massivecraft.massivecore.cmd.Parameter;
import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.Parameter;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.pager.Pager;
import com.massivecraft.massivecore.pager.Stringifier;
import com.massivecraft.massivecore.util.Txt;
@ -26,7 +26,7 @@ public class CmdMassiveCoreUsysMultiverseList extends MassiveCommand
this.addParameter(Parameter.getPage());
// Requirements
this.addRequirements(ReqHasPerm.get(MassiveCorePerm.USYS_MULTIVERSE_LIST.node));
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.USYS_MULTIVERSE_LIST.node));
}
// -------------------------------------------- //

View File

@ -1,11 +1,11 @@
package com.massivecraft.massivecore.cmd.massivecore;
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.MultiverseColl;
import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.cmd.type.TypeString;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.command.type.primitive.TypeString;
public class CmdMassiveCoreUsysMultiverseNew extends MassiveCommand
{
@ -22,7 +22,7 @@ public class CmdMassiveCoreUsysMultiverseNew extends MassiveCommand
this.addParameter(TypeString.get(), "multiverse").setDesc("name of multiverse to create");
// Requirements
this.addRequirements(ReqHasPerm.get(MassiveCorePerm.USYS_MULTIVERSE_NEW.node));
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.USYS_MULTIVERSE_NEW.node));
}
// -------------------------------------------- //

View File

@ -1,4 +1,4 @@
package com.massivecraft.massivecore.cmd.massivecore;
package com.massivecraft.massivecore.command.massivecore;
import java.util.ArrayList;
import java.util.List;
@ -8,9 +8,9 @@ import com.massivecraft.massivecore.MassiveCore;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.Multiverse;
import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.cmd.type.TypeMultiverse;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.command.type.store.TypeMultiverse;
import com.massivecraft.massivecore.util.Txt;
public class CmdMassiveCoreUsysMultiverseShow extends MassiveCommand
@ -28,7 +28,7 @@ public class CmdMassiveCoreUsysMultiverseShow extends MassiveCommand
this.addParameter(TypeMultiverse.get(), "multiverse").setDesc("the multiverse to show info about");
// Requirements
this.addRequirements(ReqHasPerm.get(MassiveCorePerm.USYS_MULTIVERSE_SHOW.node));
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.USYS_MULTIVERSE_SHOW.node));
}
// -------------------------------------------- //

View File

@ -1,8 +1,8 @@
package com.massivecraft.massivecore.cmd.massivecore;
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
public class CmdMassiveCoreUsysUniverse extends MassiveCommand
{
@ -29,7 +29,7 @@ public class CmdMassiveCoreUsysUniverse extends MassiveCommand
this.addAliases("universe");
// Requirements
this.addRequirements(ReqHasPerm.get(MassiveCorePerm.USYS_UNIVERSE.node));
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.USYS_UNIVERSE.node));
}
}

View File

@ -1,13 +1,13 @@
package com.massivecraft.massivecore.cmd.massivecore;
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.MassiveCore;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.Multiverse;
import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.cmd.type.TypeMultiverse;
import com.massivecraft.massivecore.cmd.type.TypeString;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.command.type.primitive.TypeString;
import com.massivecraft.massivecore.command.type.store.TypeMultiverse;
public class CmdMassiveCoreUsysUniverseClear extends MassiveCommand
{
@ -25,7 +25,7 @@ public class CmdMassiveCoreUsysUniverseClear extends MassiveCommand
this.addParameter(TypeMultiverse.get(), "multiverse").setDesc("the multiverse of the universe to clear");
// Requirements
this.addRequirements(ReqHasPerm.get(MassiveCorePerm.USYS_UNIVERSE_CLEAR.node));
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.USYS_UNIVERSE_CLEAR.node));
}
// -------------------------------------------- //

View File

@ -1,13 +1,13 @@
package com.massivecraft.massivecore.cmd.massivecore;
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.MassiveCore;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.Multiverse;
import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.cmd.type.TypeMultiverse;
import com.massivecraft.massivecore.cmd.type.TypeString;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.command.type.primitive.TypeString;
import com.massivecraft.massivecore.command.type.store.TypeMultiverse;
public class CmdMassiveCoreUsysUniverseDel extends MassiveCommand
{
@ -25,7 +25,7 @@ public class CmdMassiveCoreUsysUniverseDel extends MassiveCommand
this.addParameter(TypeMultiverse.get(), "multiverse").setDesc("the multiverse of the universe to delete");
// Requirements
this.addRequirements(ReqHasPerm.get(MassiveCorePerm.USYS_MULTIVERSE_DEL.node));
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.USYS_MULTIVERSE_DEL.node));
}
// -------------------------------------------- //

View File

@ -1,12 +1,12 @@
package com.massivecraft.massivecore.cmd.massivecore;
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.Multiverse;
import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.cmd.type.TypeMultiverse;
import com.massivecraft.massivecore.cmd.type.TypeString;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.command.type.primitive.TypeString;
import com.massivecraft.massivecore.command.type.store.TypeMultiverse;
public class CmdMassiveCoreUsysUniverseNew extends MassiveCommand
{
@ -24,7 +24,7 @@ public class CmdMassiveCoreUsysUniverseNew extends MassiveCommand
this.addParameter(TypeMultiverse.get(), "multiverse").setDesc("the multiverse of the universe to create");
// Requirements
this.addRequirements(ReqHasPerm.get(MassiveCorePerm.USYS_UNIVERSE_NEW.node));
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.USYS_UNIVERSE_NEW.node));
}
// -------------------------------------------- //

View File

@ -1,12 +1,12 @@
package com.massivecraft.massivecore.cmd.massivecore;
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.Multiverse;
import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.cmd.type.TypeMultiverse;
import com.massivecraft.massivecore.cmd.type.TypeString;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.command.type.primitive.TypeString;
import com.massivecraft.massivecore.command.type.store.TypeMultiverse;
public class CmdMassiveCoreUsysWorld extends MassiveCommand
{
@ -25,7 +25,7 @@ public class CmdMassiveCoreUsysWorld extends MassiveCommand
this.addParameter(TypeMultiverse.get(), "multiverse").setDesc("the multiverse of the universe to move the world to");
// Requirements
this.addRequirements(ReqHasPerm.get(MassiveCorePerm.USYS_WORLD.node));
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.USYS_WORLD.node));
}
// -------------------------------------------- //

View File

@ -1,11 +1,11 @@
package com.massivecraft.massivecore.cmd.req;
package com.massivecraft.massivecore.command.requirement;
import org.bukkit.command.CommandSender;
import com.massivecraft.massivecore.Predicate;
import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.command.MassiveCommand;
public interface Req extends Predicate<CommandSender>
public interface Requirement extends Predicate<CommandSender>
{
public boolean apply(CommandSender sender, MassiveCommand command);

View File

@ -1,12 +1,12 @@
package com.massivecraft.massivecore.cmd.req;
package com.massivecraft.massivecore.command.requirement;
import java.io.Serializable;
import org.bukkit.command.CommandSender;
import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.command.MassiveCommand;
public abstract class ReqAbstract implements Req, Serializable
public abstract class RequirementAbstract implements Requirement, Serializable
{
private static final long serialVersionUID = 1L;

View File

@ -0,0 +1,65 @@
package com.massivecraft.massivecore.command.requirement;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.bukkit.command.CommandSender;
import com.massivecraft.massivecore.command.MassiveCommand;
public class RequirementAnd extends RequirementAbstract
{
private static final long serialVersionUID = 1L;
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
public static RequirementAnd get(Requirement... requirements) { return new RequirementAnd(requirements); }
public RequirementAnd(Requirement... requirements)
{
this(Arrays.asList(requirements));
}
public static RequirementAnd get(Collection<Requirement> requirements) { return new RequirementAnd(requirements); }
public RequirementAnd(Collection<Requirement> requirements)
{
this.requirements = Collections.unmodifiableList(new ArrayList<Requirement>(requirements));
}
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
private final List<Requirement> requirements;
public List<Requirement> getRequirements() { return this.requirements; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public boolean apply(CommandSender sender, MassiveCommand command)
{
return this.getFirstFailedSubreq(sender, command) == null;
}
@Override
public String createErrorMessage(CommandSender sender, MassiveCommand command)
{
return this.getFirstFailedSubreq(sender, command).createErrorMessage(sender, command);
}
public Requirement getFirstFailedSubreq(CommandSender sender, MassiveCommand command)
{
for (Requirement requirement : this.getRequirements())
{
if (!requirement.apply(sender, command)) return requirement;
}
return null;
}
}

View File

@ -0,0 +1,70 @@
package com.massivecraft.massivecore.command.requirement;
import org.bukkit.command.CommandSender;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.editor.CommandEditAbstract;
import com.massivecraft.massivecore.command.editor.Property;
import com.massivecraft.massivecore.command.requirement.RequirementAbstract;
import com.massivecraft.massivecore.util.Txt;
public class RequirementEditorPropertyCreated extends RequirementAbstract
{
private static final long serialVersionUID = 1L;
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
protected final boolean createdTarget;
public boolean isCreatedTarget() { return this.createdTarget; }
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
public static RequirementEditorPropertyCreated get(boolean createdTarget) { return new RequirementEditorPropertyCreated(createdTarget); }
public RequirementEditorPropertyCreated(boolean createdTarget)
{
this.createdTarget = createdTarget;
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public boolean apply(CommandSender sender, MassiveCommand command)
{
return this.applyInner(sender, command);
}
public <O, V> boolean applyInner(CommandSender sender, MassiveCommand command)
{
if ( ! (command instanceof CommandEditAbstract)) return false;
@SuppressWarnings("unchecked")
CommandEditAbstract<O, V> commandEditor = (CommandEditAbstract<O, V>)command;
Property<O, V> property = commandEditor.getProperty();
if (property == null) return false;
O used = commandEditor.getObject(sender);
if (used == null) return false;
boolean created = (property.getRaw(used) != null);
return created == this.isCreatedTarget();
}
@Override
public String createErrorMessage(CommandSender sender, MassiveCommand command)
{
if ( ! (command instanceof CommandEditAbstract)) return Txt.parse("<b>This is not an editor!");
CommandEditAbstract<?, ?> commandEditor = (CommandEditAbstract<?, ?>)command;
Property<?, ?> property = commandEditor.getProperty();
return Txt.parse("<b>You must " + (this.isCreatedTarget() ? "create" : "delete") + " " + (property != null ? property.getName() : "the property") + " before you " + getDesc(command) + ".");
}
}

View File

@ -0,0 +1,43 @@
package com.massivecraft.massivecore.command.requirement;
import org.bukkit.command.CommandSender;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.editor.CommandEditAbstract;
import com.massivecraft.massivecore.util.Txt;
public class RequirementEditorUse extends RequirementAbstract
{
private static final long serialVersionUID = 1L;
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static RequirementEditorUse i = new RequirementEditorUse();
public static RequirementEditorUse get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public boolean apply(CommandSender sender, MassiveCommand command)
{
if ( ! (command instanceof CommandEditAbstract)) return false;
CommandEditAbstract<?, ?> commandEditor = (CommandEditAbstract<?, ?>)command;
return commandEditor.getSettings().getUsed(sender) != null;
}
@Override
public String createErrorMessage(CommandSender sender, MassiveCommand command)
{
if ( ! (command instanceof CommandEditAbstract)) return Txt.parse("<b>This is not an editor!");
CommandEditAbstract<?, ?> commandEditor = (CommandEditAbstract<?, ?>)command;
String noun = commandEditor.getSettings().getObjectType().getTypeName();
String aan = Txt.aan(noun);
return Txt.parse("<b>You must use %s %s to edit it.", aan, noun);
}
}

View File

@ -1,11 +1,11 @@
package com.massivecraft.massivecore.cmd.req;
package com.massivecraft.massivecore.command.requirement;
import org.bukkit.command.CommandSender;
import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.util.PermUtil;
public class ReqHasPerm extends ReqAbstract
public class RequirementHasPerm extends RequirementAbstract
{
private static final long serialVersionUID = 1L;
@ -13,8 +13,8 @@ public class ReqHasPerm extends ReqAbstract
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
public static ReqHasPerm get(String perm) { return new ReqHasPerm(perm); }
public ReqHasPerm(String perm) { this.perm = perm; }
public static RequirementHasPerm get(String perm) { return new RequirementHasPerm(perm); }
public RequirementHasPerm(String perm) { this.perm = perm; }
// -------------------------------------------- //
// FIELDS

Some files were not shown because too many files have changed in this diff Show More