Allow properties for types
This commit is contained in:
parent
d73126c544
commit
df4c031842
@ -47,6 +47,7 @@ import com.massivecraft.massivecore.command.massivecore.CmdMassiveCoreClick;
|
|||||||
import com.massivecraft.massivecore.command.massivecore.CmdMassiveCoreCmdurl;
|
import com.massivecraft.massivecore.command.massivecore.CmdMassiveCoreCmdurl;
|
||||||
import com.massivecraft.massivecore.command.massivecore.CmdMassiveCoreStore;
|
import com.massivecraft.massivecore.command.massivecore.CmdMassiveCoreStore;
|
||||||
import com.massivecraft.massivecore.command.massivecore.CmdMassiveCoreUsys;
|
import com.massivecraft.massivecore.command.massivecore.CmdMassiveCoreUsys;
|
||||||
|
import com.massivecraft.massivecore.command.type.RegistryType;
|
||||||
import com.massivecraft.massivecore.engine.EngineMassiveCoreGank;
|
import com.massivecraft.massivecore.engine.EngineMassiveCoreGank;
|
||||||
import com.massivecraft.massivecore.engine.EngineMassiveCoreChestGui;
|
import com.massivecraft.massivecore.engine.EngineMassiveCoreChestGui;
|
||||||
import com.massivecraft.massivecore.engine.EngineMassiveCoreCollTick;
|
import com.massivecraft.massivecore.engine.EngineMassiveCoreCollTick;
|
||||||
@ -234,6 +235,9 @@ public class MassiveCore extends MassivePlugin
|
|||||||
// Setup IdUtil
|
// Setup IdUtil
|
||||||
IdUtil.setup();
|
IdUtil.setup();
|
||||||
|
|
||||||
|
// Setup RegistryType
|
||||||
|
RegistryType.registerAll();
|
||||||
|
|
||||||
// Activate
|
// Activate
|
||||||
this.activate(
|
this.activate(
|
||||||
// Coll
|
// Coll
|
||||||
|
@ -6,6 +6,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
import org.bukkit.permissions.Permissible;
|
import org.bukkit.permissions.Permissible;
|
||||||
|
|
||||||
|
import com.massivecraft.massivecore.command.editor.annotation.EditorName;
|
||||||
import com.massivecraft.massivecore.command.editor.annotation.EditorNullable;
|
import com.massivecraft.massivecore.command.editor.annotation.EditorNullable;
|
||||||
import com.massivecraft.massivecore.command.editor.annotation.EditorType;
|
import com.massivecraft.massivecore.command.editor.annotation.EditorType;
|
||||||
import com.massivecraft.massivecore.store.Entity;
|
import com.massivecraft.massivecore.store.Entity;
|
||||||
@ -14,6 +15,7 @@ import com.massivecraft.massivecore.util.PermUtil;
|
|||||||
import com.massivecraft.massivecore.util.TimeUnit;
|
import com.massivecraft.massivecore.util.TimeUnit;
|
||||||
import com.massivecraft.massivecore.xlib.mongodb.WriteConcern;
|
import com.massivecraft.massivecore.xlib.mongodb.WriteConcern;
|
||||||
|
|
||||||
|
@EditorName("config")
|
||||||
public class MassiveCoreMConf extends Entity<MassiveCoreMConf>
|
public class MassiveCoreMConf extends Entity<MassiveCoreMConf>
|
||||||
{
|
{
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
@ -8,6 +8,8 @@ import org.bukkit.potion.PotionEffect;
|
|||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
import com.massivecraft.massivecore.collections.MassiveList;
|
import com.massivecraft.massivecore.collections.MassiveList;
|
||||||
|
import com.massivecraft.massivecore.command.editor.annotation.EditorType;
|
||||||
|
import com.massivecraft.massivecore.command.type.convert.TypeConverterPotionEffectType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class wraps the Bukkit PotionEffect class by reimplementing storage of the data.
|
* This class wraps the Bukkit PotionEffect class by reimplementing storage of the data.
|
||||||
@ -21,6 +23,7 @@ public class PotionEffectWrap
|
|||||||
// FIELDS
|
// FIELDS
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
@EditorType(TypeConverterPotionEffectType.class)
|
||||||
protected int id;
|
protected int id;
|
||||||
public int getId() { return this.id; }
|
public int getId() { return this.id; }
|
||||||
public void setId(int id) { this.id = id; }
|
public void setId(int id) { this.id = id; }
|
||||||
|
@ -8,6 +8,10 @@ import org.bukkit.Sound;
|
|||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.massivecraft.massivecore.command.editor.annotation.EditorName;
|
||||||
|
import com.massivecraft.massivecore.command.editor.annotation.EditorNullable;
|
||||||
|
import com.massivecraft.massivecore.command.editor.annotation.EditorType;
|
||||||
|
import com.massivecraft.massivecore.command.type.TypeId;
|
||||||
import com.massivecraft.massivecore.command.type.enumeration.TypeSound;
|
import com.massivecraft.massivecore.command.type.enumeration.TypeSound;
|
||||||
import com.massivecraft.massivecore.util.MUtil;
|
import com.massivecraft.massivecore.util.MUtil;
|
||||||
|
|
||||||
@ -19,6 +23,9 @@ public final class SoundEffect implements Serializable
|
|||||||
// FIELDS: RAW
|
// FIELDS: RAW
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
@EditorNullable(false)
|
||||||
|
@EditorName("sound")
|
||||||
|
@EditorType(value = TypeId.class, fieldName = "iSound")
|
||||||
private final String soundId;
|
private final String soundId;
|
||||||
public String getSoundId() { return this.soundId; }
|
public String getSoundId() { return this.soundId; }
|
||||||
public Sound getSound()
|
public Sound getSound()
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.massivecraft.massivecore.collections;
|
package com.massivecraft.massivecore.collections;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
import com.massivecraft.massivecore.comparator.ComparatorCaseInsensitive;
|
import com.massivecraft.massivecore.comparator.ComparatorCaseInsensitive;
|
||||||
|
|
||||||
public class ExceptionSet<T>
|
public class ExceptionSet<T>
|
||||||
@ -11,7 +13,7 @@ public class ExceptionSet<T>
|
|||||||
public boolean standard = true;
|
public boolean standard = true;
|
||||||
public boolean isStandard() { return this.standard; }
|
public boolean isStandard() { return this.standard; }
|
||||||
|
|
||||||
public MassiveTreeSet<String, ComparatorCaseInsensitive> exceptions = new MassiveTreeSet<String, ComparatorCaseInsensitive>(ComparatorCaseInsensitive.get());
|
public MassiveTreeSet<String, ComparatorCaseInsensitive> exceptions = new MassiveTreeSet<>(ComparatorCaseInsensitive.get());
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// CONSTRUCT
|
// CONSTRUCT
|
||||||
@ -32,11 +34,7 @@ public class ExceptionSet<T>
|
|||||||
{
|
{
|
||||||
this.standard = standard;
|
this.standard = standard;
|
||||||
if (exceptions.length == 0) return;
|
if (exceptions.length == 0) return;
|
||||||
for (Object exception : exceptions)
|
this.exceptions.addAll(asStrings(exceptions));
|
||||||
{
|
|
||||||
String string = asString(exception);
|
|
||||||
this.exceptions.add(string);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
@ -53,6 +51,25 @@ public class ExceptionSet<T>
|
|||||||
T t = (T)exception;
|
T t = (T)exception;
|
||||||
return this.convert(t);
|
return this.convert(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MassiveTreeSet<String, ComparatorCaseInsensitive> asStrings(Object... exceptions)
|
||||||
|
{
|
||||||
|
return asStrings(Arrays.asList(exceptions));
|
||||||
|
}
|
||||||
|
|
||||||
|
public MassiveTreeSet<String, ComparatorCaseInsensitive> asStrings(Iterable<?> exceptions)
|
||||||
|
{
|
||||||
|
MassiveTreeSet<String, ComparatorCaseInsensitive> ret = new MassiveTreeSet<>(ComparatorCaseInsensitive.get());
|
||||||
|
|
||||||
|
for (Object exception : exceptions)
|
||||||
|
{
|
||||||
|
String string = asString(exception);
|
||||||
|
ret.add(string);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// CONVERT
|
// CONVERT
|
||||||
|
@ -53,6 +53,8 @@ public class CommandEditAbstract<O, V> extends MassiveCommand
|
|||||||
|
|
||||||
// Requirements
|
// Requirements
|
||||||
this.addRequirements(RequirementEditorUse.get());
|
this.addRequirements(RequirementEditorUse.get());
|
||||||
|
this.addRequirements(settings.getPropertyRequirements());
|
||||||
|
this.addRequirements(property.getRequirements());
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
@ -158,7 +160,7 @@ public class CommandEditAbstract<O, V> extends MassiveCommand
|
|||||||
|
|
||||||
// Apply
|
// Apply
|
||||||
// We set the new property value.
|
// We set the new property value.
|
||||||
this.getProperty().setValue(sender, this.getObject(), after);
|
this.setValue(after);
|
||||||
|
|
||||||
// After
|
// After
|
||||||
// We inform what the value is after.
|
// We inform what the value is after.
|
||||||
@ -195,11 +197,19 @@ public class CommandEditAbstract<O, V> extends MassiveCommand
|
|||||||
{
|
{
|
||||||
return this.getSettings().getUsed(sender);
|
return this.getSettings().getUsed(sender);
|
||||||
}
|
}
|
||||||
|
public void setObject(CommandSender sender, O object)
|
||||||
|
{
|
||||||
|
this.getSettings().setUsed(sender, object);
|
||||||
|
}
|
||||||
|
|
||||||
public O getObject()
|
public O getObject()
|
||||||
{
|
{
|
||||||
return this.getSettings().getUsed(sender);
|
return this.getSettings().getUsed(sender);
|
||||||
}
|
}
|
||||||
|
public void setObject(O object)
|
||||||
|
{
|
||||||
|
this.setObject(sender, object);
|
||||||
|
}
|
||||||
|
|
||||||
public Mson getObjectVisual()
|
public Mson getObjectVisual()
|
||||||
{
|
{
|
||||||
@ -233,9 +243,11 @@ public class CommandEditAbstract<O, V> extends MassiveCommand
|
|||||||
return this.getProperty().getValue(this.getObject());
|
return this.getProperty().getValue(this.getObject());
|
||||||
}
|
}
|
||||||
|
|
||||||
public V setValue(V value)
|
public O setValue(V value)
|
||||||
{
|
{
|
||||||
return this.getProperty().setValue(sender, this.getObject(), value);
|
O object = this.getProperty().setValue(sender, this.getObject(), value);
|
||||||
|
this.setObject(object);
|
||||||
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Entry<O, V> getInheritedEntry()
|
public Entry<O, V> getInheritedEntry()
|
||||||
@ -289,33 +301,41 @@ public class CommandEditAbstract<O, V> extends MassiveCommand
|
|||||||
|
|
||||||
public void show(int page)
|
public void show(int page)
|
||||||
{
|
{
|
||||||
Mson descValue = this.getInheritedVisual();
|
List<Mson> show = this.getValueType().getShow(this.getValue(), sender);
|
||||||
|
|
||||||
|
Property<O, V> property = this.getProperty();
|
||||||
|
Mson descProperty = property.getDisplayNameMson();
|
||||||
|
Mson descObject = this.getObjectVisual();
|
||||||
|
|
||||||
|
Mson title;
|
||||||
|
if (property instanceof PropertyThis)
|
||||||
|
{
|
||||||
|
title = descObject;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
title = mson(
|
||||||
|
descProperty,
|
||||||
|
" for ",
|
||||||
|
descObject
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// For things with line breaks.
|
// For things with line breaks.
|
||||||
if (descValue.contains("\n"))
|
if (show.size() > 1)
|
||||||
{
|
{
|
||||||
Mson title = mson(
|
message(Txt.getPage(show, page, title, this));
|
||||||
this.getProperty().getDisplayNameMson(),
|
|
||||||
" for ",
|
|
||||||
this.getObjectVisual()
|
|
||||||
);
|
|
||||||
List<Mson> lines = descValue.split(Txt.PATTERN_NEWLINE);
|
|
||||||
|
|
||||||
message(Txt.getPage(lines, page, title, this));
|
|
||||||
}
|
}
|
||||||
// Others
|
// Others
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Mson descProperty = this.getProperty().getDisplayNameMson();
|
|
||||||
Mson descObject = this.getObjectVisual();
|
|
||||||
|
|
||||||
message(mson(
|
message(Mson.prepondfix(
|
||||||
descProperty,
|
title.add(mson(":").color(ChatColor.GRAY)),
|
||||||
" for ",
|
show,
|
||||||
descObject,
|
null
|
||||||
": ",
|
));
|
||||||
descValue
|
|
||||||
).color(ChatColor.GRAY));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ public abstract class CommandEditContainerAbstract<O, V> extends CommandEditAbst
|
|||||||
|
|
||||||
// Apply
|
// Apply
|
||||||
// We set the new property value.
|
// We set the new property value.
|
||||||
this.getProperty().setValue(sender, this.getObject(), after);
|
this.setValue(after);
|
||||||
|
|
||||||
// Create messages
|
// Create messages
|
||||||
List<Mson> messages = new MassiveList<>();
|
List<Mson> messages = new MassiveList<>();
|
||||||
|
@ -0,0 +1,33 @@
|
|||||||
|
package com.massivecraft.massivecore.command.editor;
|
||||||
|
|
||||||
|
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
|
||||||
|
import com.massivecraft.massivecore.command.type.Type;
|
||||||
|
|
||||||
|
public class CommandEditProperties<O, V> extends CommandEditAbstract<O, V>
|
||||||
|
{
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// CONSTRUCT
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
public CommandEditProperties(EditSettings<O> settings, Property<O, V> property, String permission)
|
||||||
|
{
|
||||||
|
// Super
|
||||||
|
super(settings, property, null);
|
||||||
|
|
||||||
|
this.addChild(new CommandEditShow<>(settings, property));
|
||||||
|
|
||||||
|
// Parameters
|
||||||
|
if (property.isEditable())
|
||||||
|
{
|
||||||
|
Type<V> type = this.getValueType();
|
||||||
|
EditSettings<V> fieldSettings = new EditSettingsDelegate<>(settings, property);
|
||||||
|
for (Property<V, ?> prop : type.getInnerProperties())
|
||||||
|
{
|
||||||
|
this.addChild(prop.createEditCommand(fieldSettings));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (permission != null) this.addRequirements(RequirementHasPerm.get(permission));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,30 +0,0 @@
|
|||||||
package com.massivecraft.massivecore.command.editor;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
|
|
||||||
import com.massivecraft.massivecore.command.MassiveCommand;
|
|
||||||
|
|
||||||
public class CommandEditReflection<O, V> extends CommandEditAbstract<O, V>
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CommandEditReflection(EditSettings<O> settings, Property<O, V> property, Class<V> clazz)
|
|
||||||
{
|
|
||||||
super(settings, property, null);
|
|
||||||
|
|
||||||
// TODO: What about super classes?
|
|
||||||
// TODO: While we not often use super classes they could in theory also be meant to be editable.
|
|
||||||
// TODO: Something to consider coding in for the future.
|
|
||||||
for (Field field : clazz.getDeclaredFields())
|
|
||||||
{
|
|
||||||
if ( ! PropertyReflection.isVisible(field)) continue;
|
|
||||||
Property<O, ?> fieldProperty = PropertyReflection.get(field);
|
|
||||||
MassiveCommand fieldCommand = fieldProperty.createEditCommand(settings);
|
|
||||||
this.addChild(fieldCommand);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,6 +1,7 @@
|
|||||||
package com.massivecraft.massivecore.command.editor;
|
package com.massivecraft.massivecore.command.editor;
|
||||||
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
import com.massivecraft.massivecore.MassiveException;
|
||||||
|
import com.massivecraft.massivecore.command.type.Type;
|
||||||
import com.massivecraft.massivecore.command.type.TypeNullable;
|
import com.massivecraft.massivecore.command.type.TypeNullable;
|
||||||
|
|
||||||
public class CommandEditSimple<O, V> extends CommandEditAbstract<O, V>
|
public class CommandEditSimple<O, V> extends CommandEditAbstract<O, V>
|
||||||
@ -17,7 +18,9 @@ public class CommandEditSimple<O, V> extends CommandEditAbstract<O, V>
|
|||||||
// Parameters
|
// Parameters
|
||||||
if (property.isEditable())
|
if (property.isEditable())
|
||||||
{
|
{
|
||||||
this.addParameter(TypeNullable.get(this.getProperty().getValueType()), "set", "show", true);
|
Type<V> type = this.getValueType();
|
||||||
|
if (property.isNullable()) type = TypeNullable.get(type);
|
||||||
|
this.addParameter(type, "set", "show", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
package com.massivecraft.massivecore.command.editor;
|
package com.massivecraft.massivecore.command.editor;
|
||||||
|
|
||||||
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
|
|
||||||
import com.massivecraft.massivecore.command.type.RegistryType;
|
import com.massivecraft.massivecore.command.type.RegistryType;
|
||||||
import com.massivecraft.massivecore.command.type.Type;
|
import com.massivecraft.massivecore.command.type.Type;
|
||||||
import com.massivecraft.massivecore.command.type.TypeSingleton;
|
import com.massivecraft.massivecore.command.type.TypeSingleton;
|
||||||
|
|
||||||
public class CommandEditSingleton<O> extends CommandEditReflection<O, O>
|
public class CommandEditSingleton<O> extends CommandEditProperties<O, O>
|
||||||
{
|
{
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// CONSTRUCT
|
// CONSTRUCT
|
||||||
@ -16,10 +15,9 @@ public class CommandEditSingleton<O> extends CommandEditReflection<O, O>
|
|||||||
this(object, getType(object), permission);
|
this(object, getType(object), permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public CommandEditSingleton(O object, Type<O> typeObject, String permission)
|
public CommandEditSingleton(O object, Type<O> typeObject, String permission)
|
||||||
{
|
{
|
||||||
super(createEditSettings(object, typeObject, permission), new PropertyThis<>(typeObject), (Class<O>) object.getClass());
|
super(createEditSettings(object, typeObject), new PropertyThis<>(typeObject), permission);
|
||||||
String name = typeObject.getName(object);
|
String name = typeObject.getName(object);
|
||||||
this.setAliases(name);
|
this.setAliases(name);
|
||||||
this.setDesc("edit " + name);
|
this.setDesc("edit " + name);
|
||||||
@ -29,15 +27,13 @@ public class CommandEditSingleton<O> extends CommandEditReflection<O, O>
|
|||||||
// UTIL
|
// UTIL
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
private static <O> EditSettings<O> createEditSettings(O object, Type<O> typeObject, String permission)
|
private static <O> EditSettings<O> createEditSettings(O object, Type<O> typeObject)
|
||||||
{
|
{
|
||||||
EditSettings<O> ret = new EditSettings<>(typeObject);
|
EditSettings<O> ret = new EditSettings<>(typeObject);
|
||||||
|
|
||||||
PropertyUsed<O> usedProperty = new PropertyUsed<O>(ret, object);
|
PropertyUsed<O> usedProperty = new PropertyUsed<O>(ret, object);
|
||||||
ret.setUsedProperty(usedProperty);
|
ret.setUsedProperty(usedProperty);
|
||||||
|
|
||||||
ret.addPropertyRequirements(RequirementHasPerm.get(permission));
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,63 +0,0 @@
|
|||||||
package com.massivecraft.massivecore.command.editor;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.massivecraft.massivecore.collections.MassiveList;
|
|
||||||
import com.massivecraft.massivecore.command.MassiveCommand;
|
|
||||||
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
|
|
||||||
import com.massivecraft.massivecore.command.type.RegistryType;
|
|
||||||
|
|
||||||
public abstract class CommandEditSingletons<O> extends MassiveCommand
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// FIELDS
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
private final String permission;
|
|
||||||
public String getPermission() { return this.permission; }
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CommandEditSingletons(Class<O> clazz, String permission)
|
|
||||||
{
|
|
||||||
// Aliases
|
|
||||||
String name = RegistryType.getType(clazz).getName() + "s";
|
|
||||||
this.setAliases(name);
|
|
||||||
this.setDesc("edit " + name);
|
|
||||||
|
|
||||||
// Requirements
|
|
||||||
this.permission = permission;
|
|
||||||
this.addRequirements(RequirementHasPerm.get(permission));
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// ABSTRACT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public abstract Collection<O> getAll();
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
// This is evaluated every time, because it might change.
|
|
||||||
// In Factions we use this to edit configuration of flags and perms, and those can be added and removed at any time.
|
|
||||||
@Override
|
|
||||||
public List<MassiveCommand> getChildren()
|
|
||||||
{
|
|
||||||
List<MassiveCommand> ret = new MassiveList<>();
|
|
||||||
for (O singleton : this.getAll())
|
|
||||||
{
|
|
||||||
MassiveCommand cmd = new CommandEditSingleton<>(singleton, this.getPermission());
|
|
||||||
List<MassiveCommand> chain = this.getChain();
|
|
||||||
chain.add(this);
|
|
||||||
cmd.setChain(chain);
|
|
||||||
ret.add(cmd);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,6 +1,5 @@
|
|||||||
package com.massivecraft.massivecore.command.editor;
|
package com.massivecraft.massivecore.command.editor;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -9,6 +8,7 @@ import java.util.Set;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
import com.massivecraft.massivecore.MassiveException;
|
||||||
|
import com.massivecraft.massivecore.collections.MassiveList;
|
||||||
import com.massivecraft.massivecore.command.requirement.Requirement;
|
import com.massivecraft.massivecore.command.requirement.Requirement;
|
||||||
import com.massivecraft.massivecore.command.type.Type;
|
import com.massivecraft.massivecore.command.type.Type;
|
||||||
import com.massivecraft.massivecore.command.type.sender.TypeSender;
|
import com.massivecraft.massivecore.command.type.sender.TypeSender;
|
||||||
@ -46,14 +46,14 @@ public class EditSettings<O>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Requirements to edit the used object.
|
// Requirements to edit the used object.
|
||||||
private List<Requirement> usedRequirements = new ArrayList<Requirement>();
|
private List<Requirement> usedRequirements = new MassiveList<>();
|
||||||
public List<Requirement> getUsedRequirements() { return this.usedRequirements; }
|
public List<Requirement> getUsedRequirements() { return this.usedRequirements; }
|
||||||
public void setUsedRequirements(List<Requirement> requirements) { this.usedRequirements = requirements; }
|
public void setUsedRequirements(List<Requirement> requirements) { this.usedRequirements = requirements; }
|
||||||
public void addUsedRequirements(Collection<Requirement> requirements) { this.usedRequirements.addAll(requirements); }
|
public void addUsedRequirements(Collection<Requirement> requirements) { this.usedRequirements.addAll(requirements); }
|
||||||
public void addUsedRequirements(Requirement... requirements) { this.addUsedRequirements(Arrays.asList(requirements)); }
|
public void addUsedRequirements(Requirement... requirements) { this.addUsedRequirements(Arrays.asList(requirements)); }
|
||||||
|
|
||||||
// Requirements to edit properties. Common stuff shared by all properties.
|
// Requirements to edit properties. Common stuff shared by all properties.
|
||||||
private List<Requirement> propertyRequirements = new ArrayList<Requirement>();
|
private List<Requirement> propertyRequirements = new MassiveList<>();
|
||||||
public List<Requirement> getPropertyRequirements() { return this.propertyRequirements; }
|
public List<Requirement> getPropertyRequirements() { return this.propertyRequirements; }
|
||||||
public void setPropertyRequirements(List<Requirement> requirements) { this.propertyRequirements = requirements; }
|
public void setPropertyRequirements(List<Requirement> requirements) { this.propertyRequirements = requirements; }
|
||||||
public void addPropertyRequirements(Collection<Requirement> requirements) { this.propertyRequirements.addAll(requirements); }
|
public void addPropertyRequirements(Collection<Requirement> requirements) { this.propertyRequirements.addAll(requirements); }
|
||||||
|
@ -0,0 +1,37 @@
|
|||||||
|
package com.massivecraft.massivecore.command.editor;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
public class EditSettingsDelegate<O, V> extends EditSettings<V>
|
||||||
|
{
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// INSTANCE & CONSTRUCT
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
public EditSettingsDelegate(final EditSettings<O> outerSettings, final Property<O, V> property)
|
||||||
|
{
|
||||||
|
super(property.getValueType());
|
||||||
|
|
||||||
|
PropertyUsed<V> usedProperty = new PropertyUsed<V>(this) {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public V getRaw(CommandSender sender)
|
||||||
|
{
|
||||||
|
return property.getRaw(outerSettings.getUsed(sender));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommandSender setRaw(CommandSender sender, V used)
|
||||||
|
{
|
||||||
|
property.setRaw(outerSettings.getUsed(sender), used);
|
||||||
|
return sender;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
this.setUsedProperty(usedProperty);
|
||||||
|
|
||||||
|
this.addUsedRequirements(outerSettings.getPropertyRequirements());
|
||||||
|
this.addUsedRequirements(property.getRequirements());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -5,6 +5,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.ListIterator;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -17,10 +18,15 @@ import com.massivecraft.massivecore.command.type.Type;
|
|||||||
import com.massivecraft.massivecore.mson.Mson;
|
import com.massivecraft.massivecore.mson.Mson;
|
||||||
import com.massivecraft.massivecore.store.Entity;
|
import com.massivecraft.massivecore.store.Entity;
|
||||||
import com.massivecraft.massivecore.util.MUtil;
|
import com.massivecraft.massivecore.util.MUtil;
|
||||||
import com.massivecraft.massivecore.util.Txt;
|
|
||||||
|
|
||||||
public abstract class Property<O, V> implements Named
|
public abstract class Property<O, V> implements Named
|
||||||
{
|
{
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// CONSTANTS
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
public static final String SHOW_INDENT = " "; // Two spaces
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// TYPE
|
// TYPE
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
@ -95,37 +101,34 @@ public abstract class Property<O, V> implements Named
|
|||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
public abstract V getRaw(O object);
|
public abstract V getRaw(O object);
|
||||||
public abstract void setRaw(O object, V value);
|
public abstract O setRaw(O object, V value);
|
||||||
|
|
||||||
public V getValue(O object)
|
public V getValue(O object)
|
||||||
{
|
{
|
||||||
return this.getRaw(object);
|
return this.getRaw(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
public V setValue(CommandSender sender, O object, V value)
|
public O setValue(CommandSender sender, O object, V value)
|
||||||
{
|
{
|
||||||
// Get Before
|
// Get Before
|
||||||
V before = this.getRaw(object);
|
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
|
// NoChange
|
||||||
if (entity != null && MUtil.equals(before, value)) return before;
|
if (MUtil.equals(before, value)) return object;
|
||||||
|
|
||||||
// Apply
|
// Apply
|
||||||
this.setRaw(object, value);
|
object = this.setRaw(object, value);
|
||||||
|
|
||||||
// Mark Change
|
// Mark Entity Changed
|
||||||
if (entity != null) entity.changed();
|
Entity<?> entity = null;
|
||||||
|
if (object instanceof Entity) entity = (Entity<?>)object;
|
||||||
|
if (entity != null && entity.isLive()) entity.changed();
|
||||||
|
|
||||||
// On Change
|
// On Change
|
||||||
this.onChange(sender, object, before, value);
|
this.onChange(sender, object, before, value);
|
||||||
|
|
||||||
// Return Before
|
// Return Before
|
||||||
return before;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
@ -164,15 +167,7 @@ public abstract class Property<O, V> implements Named
|
|||||||
|
|
||||||
public CommandEditAbstract<O, V> createEditCommand(EditSettings<O> settings)
|
public CommandEditAbstract<O, V> createEditCommand(EditSettings<O> settings)
|
||||||
{
|
{
|
||||||
CommandEditAbstract<O, V> ret = this.getValueType().createEditCommand(settings, this);
|
return this.getValueType().createEditCommand(settings, this);
|
||||||
|
|
||||||
// Add general requirements.
|
|
||||||
ret.addRequirements(settings.getPropertyRequirements());
|
|
||||||
|
|
||||||
// Add specific requirements.
|
|
||||||
ret.addRequirements(this.getRequirements());
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Mson getInheritedVisual(O object, O source, V value, CommandSender sender)
|
public Mson getInheritedVisual(O object, O source, V value, CommandSender sender)
|
||||||
@ -221,12 +216,19 @@ public abstract class Property<O, V> implements Named
|
|||||||
|
|
||||||
public List<Mson> getShowLines(O object, CommandSender sender)
|
public List<Mson> getShowLines(O object, CommandSender sender)
|
||||||
{
|
{
|
||||||
Mson ret = Mson.mson(
|
Mson prefix = Mson.mson(
|
||||||
this.getDisplayNameMson(),
|
this.getDisplayNameMson(),
|
||||||
Mson.mson(": ").color(ChatColor.GRAY),
|
Mson.mson(":").color(ChatColor.GRAY)
|
||||||
this.getInheritedVisual(object, sender)
|
);
|
||||||
);
|
List<Mson> ret = Mson.prepondfix(prefix, this.getValueType().getShow(this.getInheritedValue(object), sender), null);
|
||||||
return ret.split(Txt.PATTERN_NEWLINE);
|
|
||||||
|
for (ListIterator<Mson> it = ret.listIterator(1); it.hasNext();)
|
||||||
|
{
|
||||||
|
Mson mson = it.next();
|
||||||
|
it.set(mson.text(SHOW_INDENT + mson.getText()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <O> List<Mson> getShowLines(O object, CommandSender sender, Collection<? extends Property<O, ?>> properties)
|
public static <O> List<Mson> getShowLines(O object, CommandSender sender, Collection<? extends Property<O, ?>> properties)
|
||||||
|
@ -1,18 +1,40 @@
|
|||||||
package com.massivecraft.massivecore.command.editor;
|
package com.massivecraft.massivecore.command.editor;
|
||||||
|
|
||||||
|
import java.lang.annotation.Annotation;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import com.massivecraft.massivecore.collections.MassiveList;
|
||||||
import com.massivecraft.massivecore.command.editor.annotation.EditorEditable;
|
import com.massivecraft.massivecore.command.editor.annotation.EditorEditable;
|
||||||
import com.massivecraft.massivecore.command.editor.annotation.EditorInheritable;
|
import com.massivecraft.massivecore.command.editor.annotation.EditorInheritable;
|
||||||
|
import com.massivecraft.massivecore.command.editor.annotation.EditorMethods;
|
||||||
|
import com.massivecraft.massivecore.command.editor.annotation.EditorName;
|
||||||
import com.massivecraft.massivecore.command.editor.annotation.EditorNullable;
|
import com.massivecraft.massivecore.command.editor.annotation.EditorNullable;
|
||||||
import com.massivecraft.massivecore.command.editor.annotation.EditorVisible;
|
import com.massivecraft.massivecore.command.editor.annotation.EditorVisible;
|
||||||
import com.massivecraft.massivecore.command.type.RegistryType;
|
import com.massivecraft.massivecore.command.type.RegistryType;
|
||||||
import com.massivecraft.massivecore.command.type.Type;
|
import com.massivecraft.massivecore.command.type.Type;
|
||||||
|
import com.massivecraft.massivecore.command.type.TypeWrapper;
|
||||||
|
import com.massivecraft.massivecore.mson.Mson;
|
||||||
|
import com.massivecraft.massivecore.particleeffect.ReflectionUtils;
|
||||||
import com.massivecraft.massivecore.util.ReflectionUtil;
|
import com.massivecraft.massivecore.util.ReflectionUtil;
|
||||||
|
import com.massivecraft.massivecore.util.Txt;
|
||||||
|
|
||||||
public class PropertyReflection<O, V> extends Property<O, V>
|
public class PropertyReflection<O, V> extends Property<O, V>
|
||||||
{
|
{
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// CONSTANTS
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
public static final boolean VISIBLE_DEFAULT = true;
|
||||||
|
public static final boolean INHERITABLE_DEFAULT = true;
|
||||||
|
public static final boolean EDITABLE_DEFAULT = true;
|
||||||
|
public static final boolean NULLABLE_DEFAULT = false;
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// FIELDS
|
// FIELDS
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
@ -20,19 +42,106 @@ public class PropertyReflection<O, V> extends Property<O, V>
|
|||||||
private final Field field;
|
private final Field field;
|
||||||
public Field getField() { return this.field; }
|
public Field getField() { return this.field; }
|
||||||
|
|
||||||
|
private final Method getter;
|
||||||
|
public Method getGetter() { return this.getter; }
|
||||||
|
|
||||||
|
private final Method setter;
|
||||||
|
public Method getSetter() { return this.setter; }
|
||||||
|
|
||||||
|
public static Method calcGetter(Field field)
|
||||||
|
{
|
||||||
|
String name = Txt.upperCaseFirst(field.getName());
|
||||||
|
|
||||||
|
if ( ! getAnnotationValue(field, EditorMethods.class, false)) return null;
|
||||||
|
|
||||||
|
// Try with normal get
|
||||||
|
if (ReflectionUtil.hasMethod(field.getDeclaringClass(), "get" + name))
|
||||||
|
{
|
||||||
|
return ReflectionUtil.getMethod(field.getDeclaringClass(), "get" + name);
|
||||||
|
}
|
||||||
|
|
||||||
|
// For booleans try other options
|
||||||
|
if ( ! (boolean.class.equals(field.getType()) || Boolean.class.equals(field.getType()))) throw new RuntimeException(field.toString());
|
||||||
|
|
||||||
|
// Try is
|
||||||
|
if (ReflectionUtil.hasMethod(field.getDeclaringClass(), "is" + name))
|
||||||
|
{
|
||||||
|
return ReflectionUtil.getMethod(field.getDeclaringClass(), "is" + name);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try has
|
||||||
|
if (ReflectionUtil.hasMethod(field.getDeclaringClass(), "has" + name))
|
||||||
|
{
|
||||||
|
return ReflectionUtil.getMethod(field.getDeclaringClass(), "has" + name);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fail
|
||||||
|
throw new RuntimeException(field.toString());
|
||||||
|
}
|
||||||
|
public static Method calcSetter(Field field)
|
||||||
|
{
|
||||||
|
String name = Txt.upperCaseFirst(field.getName());
|
||||||
|
|
||||||
|
if ( ! getAnnotationValue(field, EditorMethods.class, false)) return null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return ReflectionUtils.getMethod(field.getDeclaringClass(), "set" + name, field.getType());
|
||||||
|
}
|
||||||
|
catch (NoSuchMethodException e)
|
||||||
|
{
|
||||||
|
// Fail
|
||||||
|
throw new RuntimeException(field.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// CONSTRUCT
|
// CONSTRUCT
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
public static <O, V> PropertyReflection<O, V> get(Class<O> clazz, String fieldName)
|
public static <O> List<PropertyReflection<O, ?>> getAll(Class<O> clazz, Type<O> typeObject)
|
||||||
{
|
{
|
||||||
return get(ReflectionUtil.getField(clazz, fieldName));
|
List<PropertyReflection<O, ?>> ret = new MassiveList<>();
|
||||||
|
|
||||||
|
// TODO: What about super classes?
|
||||||
|
// TODO: While we not often use super classes they could in theory also be meant to be editable.
|
||||||
|
// TODO: Something to consider coding in for the future.
|
||||||
|
for (Field field : clazz.getDeclaredFields())
|
||||||
|
{
|
||||||
|
if ( ! isVisible(field)) continue;
|
||||||
|
|
||||||
|
PropertyReflection<O, ?> property = get(field, typeObject);
|
||||||
|
ret.add(property);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <O, V> PropertyReflection<O, V> get(Field field)
|
public static <O, V> PropertyReflection<O, V> get(final Field field, Type<O> typeObject)
|
||||||
{
|
{
|
||||||
Type<O> typeObject = (Type<O>) RegistryType.getType(field.getDeclaringClass());
|
|
||||||
Type<V> typeValue = (Type<V>) RegistryType.getType(field);
|
Type<V> typeValue = (Type<V>) RegistryType.getType(field);
|
||||||
|
|
||||||
|
// This makes sure it is called "volume for clickSound" instead of "volume for UiButtonClick 0.75 1.0"
|
||||||
|
// We also only do it for things with properties, so the edited message works and shows the actual visual.
|
||||||
|
if (typeValue.hasInnerProperties())
|
||||||
|
{
|
||||||
|
typeValue = new TypeWrapper<V>(typeValue)
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public Mson getVisualMsonInner(V value, CommandSender sender)
|
||||||
|
{
|
||||||
|
return Mson.mson(PropertyReflection.getName(field)).color(ChatColor.AQUA);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getVisualInner(V value, CommandSender sender)
|
||||||
|
{
|
||||||
|
return ChatColor.AQUA + PropertyReflection.getName(field);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
return new PropertyReflection<>(typeObject, typeValue, field);
|
return new PropertyReflection<>(typeObject, typeValue, field);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,12 +151,14 @@ public class PropertyReflection<O, V> extends Property<O, V>
|
|||||||
|
|
||||||
ReflectionUtil.makeAccessible(field);
|
ReflectionUtil.makeAccessible(field);
|
||||||
this.field = field;
|
this.field = field;
|
||||||
|
this.getter = calcGetter(field);
|
||||||
|
this.setter = calcSetter(field);
|
||||||
|
|
||||||
this.setVisible(isVisible(field));
|
this.setVisible(isVisible(field));
|
||||||
this.setInheritable(isInheritable(field));
|
this.setInheritable(isInheritable(field));
|
||||||
this.setEditable(isEditable(field));
|
this.setEditable(isEditable(field));
|
||||||
this.setNullable(isNullable(field));
|
this.setNullable(isNullable(field));
|
||||||
this.setName(field.getName());
|
this.setName(getName(field));
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
@ -57,13 +168,33 @@ public class PropertyReflection<O, V> extends Property<O, V>
|
|||||||
@Override
|
@Override
|
||||||
public V getRaw(O object)
|
public V getRaw(O object)
|
||||||
{
|
{
|
||||||
return ReflectionUtil.getField(this.getField(), object);
|
// Use method if possible.
|
||||||
|
if (this.getGetter() != null)
|
||||||
|
{
|
||||||
|
return ReflectionUtil.invokeMethod(this.getGetter(), object);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Otherwise just get.
|
||||||
|
return ReflectionUtil.getField(this.getField(), object);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setRaw(O object, V value)
|
public O setRaw(O object, V value)
|
||||||
{
|
{
|
||||||
ReflectionUtil.setField(this.getField(), object, value);
|
// Use method if possible.
|
||||||
|
if (this.getSetter() != null)
|
||||||
|
{
|
||||||
|
ReflectionUtil.invokeMethod(this.getSetter(), object, value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Otherwise just set.
|
||||||
|
ReflectionUtil.setField(this.getField(), object, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
@ -73,15 +204,14 @@ public class PropertyReflection<O, V> extends Property<O, V>
|
|||||||
public static boolean isVisible(Field field)
|
public static boolean isVisible(Field field)
|
||||||
{
|
{
|
||||||
// Create
|
// Create
|
||||||
boolean ret = true;
|
boolean ret = VISIBLE_DEFAULT;
|
||||||
|
|
||||||
// Fill > Standard
|
// Fill > Standard
|
||||||
int modifiers = field.getModifiers();
|
int modifiers = field.getModifiers();
|
||||||
if (Modifier.isStatic(modifiers) || Modifier.isTransient(modifiers)) ret = false;
|
if (Modifier.isStatic(modifiers) || Modifier.isTransient(modifiers)) ret = false;
|
||||||
|
|
||||||
// Fill > Annotation
|
// Fill > Annotation
|
||||||
EditorVisible annotation = field.getAnnotation(EditorVisible.class);
|
ret = getAnnotationValue(field, EditorVisible.class, ret);
|
||||||
if (annotation != null) ret = annotation.value();
|
|
||||||
|
|
||||||
// Return
|
// Return
|
||||||
return ret;
|
return ret;
|
||||||
@ -89,29 +219,20 @@ public class PropertyReflection<O, V> extends Property<O, V>
|
|||||||
|
|
||||||
public static boolean isInheritable(Field field)
|
public static boolean isInheritable(Field field)
|
||||||
{
|
{
|
||||||
// Create
|
return getAnnotationValue(field, EditorInheritable.class, INHERITABLE_DEFAULT);
|
||||||
boolean ret = true;
|
|
||||||
|
|
||||||
// Fill > Annotation
|
|
||||||
EditorInheritable annotation = field.getAnnotation(EditorInheritable.class);
|
|
||||||
if (annotation != null) ret = annotation.value();
|
|
||||||
|
|
||||||
// Return
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isEditable(Field field)
|
public static boolean isEditable(Field field)
|
||||||
{
|
{
|
||||||
// Create
|
// Create
|
||||||
boolean ret = true;
|
boolean ret = EDITABLE_DEFAULT;
|
||||||
|
|
||||||
// Fill > Standard
|
// Fill > Standard
|
||||||
int modifiers = field.getModifiers();
|
int modifiers = field.getModifiers();
|
||||||
if (Modifier.isStatic(modifiers) || Modifier.isTransient(modifiers) || Modifier.isFinal(modifiers)) ret = false;
|
if (Modifier.isStatic(modifiers) || Modifier.isTransient(modifiers) || Modifier.isFinal(modifiers)) ret = false;
|
||||||
|
|
||||||
// Fill > Annotation
|
// Fill > Annotation
|
||||||
EditorEditable annotation = field.getAnnotation(EditorEditable.class);
|
ret = getAnnotationValue(field, EditorEditable.class, ret);
|
||||||
if (annotation != null) ret = annotation.value();
|
|
||||||
|
|
||||||
// Return
|
// Return
|
||||||
return ret;
|
return ret;
|
||||||
@ -122,15 +243,47 @@ public class PropertyReflection<O, V> extends Property<O, V>
|
|||||||
// Primitive
|
// Primitive
|
||||||
if (field.getType().isPrimitive()) return false;
|
if (field.getType().isPrimitive()) return false;
|
||||||
|
|
||||||
|
// Annotation
|
||||||
|
return getAnnotationValue(field, EditorNullable.class, NULLABLE_DEFAULT);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static String getName(Field field)
|
||||||
|
{
|
||||||
// Create
|
// Create
|
||||||
boolean ret = true;
|
String ret;
|
||||||
|
|
||||||
|
// Fill > Standard
|
||||||
|
ret = field.getName();
|
||||||
|
|
||||||
// Fill > Annotation
|
// Fill > Annotation
|
||||||
EditorNullable annotation = field.getAnnotation(EditorNullable.class);
|
EditorName annotation = field.getAnnotation(EditorName.class);
|
||||||
if (annotation != null) ret = annotation.value();
|
if (annotation != null) ret = annotation.value();
|
||||||
|
|
||||||
// Return
|
// Return
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// ANNOTATION UTIL
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
public static <U> U getAnnotationValue(Field field, Class<? extends Annotation> clazz, U defaultValue)
|
||||||
|
{
|
||||||
|
// Try for field
|
||||||
|
Annotation annotation = field.getAnnotation(clazz);
|
||||||
|
if (annotation != null) return invokeAnnotationValue(annotation, clazz);
|
||||||
|
|
||||||
|
// Try class
|
||||||
|
annotation = field.getDeclaringClass().getAnnotation(clazz);
|
||||||
|
if (annotation != null) return invokeAnnotationValue(annotation, clazz);
|
||||||
|
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static <U> U invokeAnnotationValue(Annotation annotation, Class<?> clazz)
|
||||||
|
{
|
||||||
|
return ReflectionUtil.invokeMethod(ReflectionUtil.getMethod(clazz, "value"), annotation);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,9 +24,9 @@ public class PropertyThis<O> extends Property<O, O>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setRaw(O object, O value)
|
public O setRaw(O object, O value)
|
||||||
{
|
{
|
||||||
return;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -36,9 +36,9 @@ public class PropertyThisSenderEntity<O extends SenderEntity<O>> extends Propert
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setRaw(CommandSender object, O value)
|
public CommandSender setRaw(CommandSender object, O value)
|
||||||
{
|
{
|
||||||
return;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -39,9 +39,10 @@ public class PropertyUsed<V> extends Property<CommandSender, V>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setRaw(CommandSender sender, V used)
|
public CommandSender setRaw(CommandSender sender, V used)
|
||||||
{
|
{
|
||||||
this.used = used;
|
this.used = used;
|
||||||
|
return sender;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
package com.massivecraft.massivecore.command.editor.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
@Target({ElementType.FIELD, ElementType.TYPE})
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
public @interface EditorMethods
|
||||||
|
{
|
||||||
|
boolean value();
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package com.massivecraft.massivecore.command.editor.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
@Target({ElementType.FIELD, ElementType.TYPE})
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
public @interface EditorName
|
||||||
|
{
|
||||||
|
String value();
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package com.massivecraft.massivecore.command.editor.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
@Target(ElementType.FIELD)
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
public @interface EditorTypeList
|
||||||
|
{
|
||||||
|
// This is the type class.
|
||||||
|
Class<?> value();
|
||||||
|
|
||||||
|
// The name of the singleton instance field to use.
|
||||||
|
String fieldName() default "i";
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package com.massivecraft.massivecore.command.editor.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
@Target(ElementType.FIELD)
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
public @interface EditorTypeMap
|
||||||
|
{
|
||||||
|
// This is the type class.
|
||||||
|
Class<?> typeKey();
|
||||||
|
Class<?> typeValue();
|
||||||
|
|
||||||
|
// The name of the singleton instance field to use.
|
||||||
|
String fieldNameKey() default "i";
|
||||||
|
String fieldNameValue() default "i";
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package com.massivecraft.massivecore.command.editor.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
@Target(ElementType.FIELD)
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
public @interface EditorTypeSet
|
||||||
|
{
|
||||||
|
// This is the type class.
|
||||||
|
Class<?> value();
|
||||||
|
|
||||||
|
// The name of the singleton instance field to use.
|
||||||
|
String fieldName() default "i";
|
||||||
|
}
|
@ -42,9 +42,6 @@ public class CmdMassiveCore extends MassiveCommand
|
|||||||
|
|
||||||
public CmdMassiveCore()
|
public CmdMassiveCore()
|
||||||
{
|
{
|
||||||
// Tweak
|
|
||||||
this.cmdMassiveCoreConfig.setAliases("config");
|
|
||||||
|
|
||||||
// Children
|
// Children
|
||||||
this.addChild(this.cmdMassiveCoreUsys);
|
this.addChild(this.cmdMassiveCoreUsys);
|
||||||
this.addChild(this.cmdMassiveCoreMStore);
|
this.addChild(this.cmdMassiveCoreMStore);
|
||||||
|
@ -7,36 +7,15 @@ import java.util.Map;
|
|||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Difficulty;
|
|
||||||
import org.bukkit.DyeColor;
|
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.Sound;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.World.Environment;
|
|
||||||
import org.bukkit.WorldType;
|
|
||||||
import org.bukkit.block.Biome;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.entity.Horse;
|
|
||||||
import org.bukkit.entity.Ocelot;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.entity.Skeleton.SkeletonType;
|
|
||||||
import org.bukkit.entity.Villager.Profession;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.permissions.Permission;
|
|
||||||
import org.bukkit.potion.PotionEffectType;
|
|
||||||
|
|
||||||
import com.massivecraft.massivecore.Aspect;
|
|
||||||
import com.massivecraft.massivecore.Multiverse;
|
|
||||||
import com.massivecraft.massivecore.PotionEffectWrap;
|
|
||||||
import com.massivecraft.massivecore.SoundEffect;
|
|
||||||
import com.massivecraft.massivecore.collections.ExceptionSet;
|
import com.massivecraft.massivecore.collections.ExceptionSet;
|
||||||
import com.massivecraft.massivecore.collections.MassiveMap;
|
import com.massivecraft.massivecore.collections.MassiveMap;
|
||||||
import com.massivecraft.massivecore.collections.WorldExceptionSet;
|
import com.massivecraft.massivecore.collections.WorldExceptionSet;
|
||||||
import com.massivecraft.massivecore.command.editor.annotation.EditorType;
|
import com.massivecraft.massivecore.command.editor.annotation.EditorType;
|
||||||
|
import com.massivecraft.massivecore.command.editor.annotation.EditorTypeList;
|
||||||
|
import com.massivecraft.massivecore.command.editor.annotation.EditorTypeMap;
|
||||||
|
import com.massivecraft.massivecore.command.editor.annotation.EditorTypeSet;
|
||||||
|
import com.massivecraft.massivecore.command.type.combined.TypeDataBannerPattern;
|
||||||
|
import com.massivecraft.massivecore.command.type.combined.TypeDataPotionEffect;
|
||||||
import com.massivecraft.massivecore.command.type.combined.TypeEntry;
|
import com.massivecraft.massivecore.command.type.combined.TypeEntry;
|
||||||
import com.massivecraft.massivecore.command.type.combined.TypePotionEffectWrap;
|
import com.massivecraft.massivecore.command.type.combined.TypePotionEffectWrap;
|
||||||
import com.massivecraft.massivecore.command.type.combined.TypeSoundEffect;
|
import com.massivecraft.massivecore.command.type.combined.TypeSoundEffect;
|
||||||
@ -51,6 +30,7 @@ import com.massivecraft.massivecore.command.type.enumeration.TypeDyeColor;
|
|||||||
import com.massivecraft.massivecore.command.type.enumeration.TypeEntityType;
|
import com.massivecraft.massivecore.command.type.enumeration.TypeEntityType;
|
||||||
import com.massivecraft.massivecore.command.type.enumeration.TypeEnvironment;
|
import com.massivecraft.massivecore.command.type.enumeration.TypeEnvironment;
|
||||||
import com.massivecraft.massivecore.command.type.enumeration.TypeEventPriority;
|
import com.massivecraft.massivecore.command.type.enumeration.TypeEventPriority;
|
||||||
|
import com.massivecraft.massivecore.command.type.enumeration.TypeFireworkEffectType;
|
||||||
import com.massivecraft.massivecore.command.type.enumeration.TypeGameMode;
|
import com.massivecraft.massivecore.command.type.enumeration.TypeGameMode;
|
||||||
import com.massivecraft.massivecore.command.type.enumeration.TypeHorseColor;
|
import com.massivecraft.massivecore.command.type.enumeration.TypeHorseColor;
|
||||||
import com.massivecraft.massivecore.command.type.enumeration.TypeHorseStyle;
|
import com.massivecraft.massivecore.command.type.enumeration.TypeHorseStyle;
|
||||||
@ -74,9 +54,6 @@ import com.massivecraft.massivecore.command.type.sender.TypePlayer;
|
|||||||
import com.massivecraft.massivecore.command.type.sender.TypeSender;
|
import com.massivecraft.massivecore.command.type.sender.TypeSender;
|
||||||
import com.massivecraft.massivecore.command.type.store.TypeAspect;
|
import com.massivecraft.massivecore.command.type.store.TypeAspect;
|
||||||
import com.massivecraft.massivecore.command.type.store.TypeMultiverse;
|
import com.massivecraft.massivecore.command.type.store.TypeMultiverse;
|
||||||
import com.massivecraft.massivecore.particleeffect.ParticleEffect;
|
|
||||||
import com.massivecraft.massivecore.ps.PS;
|
|
||||||
import com.massivecraft.massivecore.teleport.Destination;
|
|
||||||
import com.massivecraft.massivecore.util.ReflectionUtil;
|
import com.massivecraft.massivecore.util.ReflectionUtil;
|
||||||
|
|
||||||
public class RegistryType
|
public class RegistryType
|
||||||
@ -86,9 +63,28 @@ public class RegistryType
|
|||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
private static final Map<Class<?>, Type<?>> registry = new MassiveMap<>();
|
private static final Map<Class<?>, Type<?>> registry = new MassiveMap<>();
|
||||||
public static <T> void register(Class<T> clazz, Type<? super T> type) { registry.put(clazz, type); }
|
public static <T> void register(Class<T> clazz, Type<? super T> type)
|
||||||
@SuppressWarnings("unchecked") public static <T> Type<? super T> unregister(Class<T> clazz) { return (Type<T>) registry.remove(clazz); }
|
{
|
||||||
public static boolean isRegistered(Class<?> clazz) { return registry.containsKey(clazz); }
|
if (clazz == null) throw new NullPointerException("clazz");
|
||||||
|
if (type == null) throw new NullPointerException("type");
|
||||||
|
registry.put(clazz, type);
|
||||||
|
}
|
||||||
|
public static <T> void register(Type<T> type)
|
||||||
|
{
|
||||||
|
if (type == null) throw new NullPointerException("type");
|
||||||
|
register(type.getClazz(), type);
|
||||||
|
}
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public static <T> Type<? super T> unregister(Class<T> clazz)
|
||||||
|
{
|
||||||
|
if (clazz == null) throw new NullPointerException("clazz");
|
||||||
|
return (Type<T>) registry.remove(clazz);
|
||||||
|
}
|
||||||
|
public static boolean isRegistered(Class<?> clazz)
|
||||||
|
{
|
||||||
|
if (clazz == null) throw new NullPointerException("clazz");
|
||||||
|
return registry.containsKey(clazz);
|
||||||
|
}
|
||||||
|
|
||||||
public static Type<?> getType(Field field)
|
public static Type<?> getType(Field field)
|
||||||
{
|
{
|
||||||
@ -97,11 +93,32 @@ public class RegistryType
|
|||||||
{
|
{
|
||||||
Class<?> clazz = annotation.value();
|
Class<?> clazz = annotation.value();
|
||||||
if (clazz == void.class) clazz = getType(field.getGenericType()).getClass();
|
if (clazz == void.class) clazz = getType(field.getGenericType()).getClass();
|
||||||
return ReflectionUtil.getField(clazz, annotation.fieldName(), null);
|
return getType(clazz, annotation.fieldName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EditorTypeList annList = field.getAnnotation(EditorTypeList.class);
|
||||||
|
if (annList != null)
|
||||||
|
{
|
||||||
|
return TypeList.get(getType(annList.value(), annList.fieldName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
EditorTypeSet annSet = field.getAnnotation(EditorTypeSet.class);
|
||||||
|
if (annSet != null)
|
||||||
|
{
|
||||||
|
return TypeSet.get(getType(annSet.value(), annSet.fieldName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
EditorTypeMap annMap = field.getAnnotation(EditorTypeMap.class);
|
||||||
|
if (annMap != null)
|
||||||
|
{
|
||||||
|
return TypeMap.get(getType(annMap.typeKey(), annMap.fieldNameKey()), getType(annMap.typeValue(), annMap.fieldNameValue()));
|
||||||
|
}
|
||||||
return getType(field.getGenericType());
|
return getType(field.getGenericType());
|
||||||
}
|
}
|
||||||
|
private static Type<?> getType(Class<?> clazz, String fieldName)
|
||||||
|
{
|
||||||
|
return ReflectionUtil.getField(clazz, fieldName, null);
|
||||||
|
}
|
||||||
|
|
||||||
public static Type<?> getType(java.lang.reflect.Type reflectType)
|
public static Type<?> getType(java.lang.reflect.Type reflectType)
|
||||||
{
|
{
|
||||||
@ -150,12 +167,7 @@ public class RegistryType
|
|||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// DEFAULTS
|
// DEFAULTS
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
static
|
|
||||||
{
|
|
||||||
registerAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void registerAll()
|
public static void registerAll()
|
||||||
{
|
{
|
||||||
// Primitive
|
// Primitive
|
||||||
@ -177,57 +189,62 @@ public class RegistryType
|
|||||||
register(Long.TYPE, TypeLong.get());
|
register(Long.TYPE, TypeLong.get());
|
||||||
register(Long.class, TypeLong.get());
|
register(Long.class, TypeLong.get());
|
||||||
|
|
||||||
register(String.class, TypeString.get());
|
register(TypeString.get());
|
||||||
|
|
||||||
// Bukkit
|
|
||||||
register(Destination.class, TypeDestination.get());
|
|
||||||
register(ItemStack.class, TypeItemStack.get());
|
|
||||||
register(Permission.class, TypePermission.get());
|
|
||||||
register(PotionEffectType.class, TypePotionEffectType.get());
|
|
||||||
register(PS.class, TypePS.get());
|
|
||||||
register(World.class, TypeWorld.get());
|
|
||||||
register(PotionEffectWrap.class, TypePotionEffectWrap.get());
|
|
||||||
register(SoundEffect.class, TypeSoundEffect.get());
|
|
||||||
|
|
||||||
// Enum
|
// Enum
|
||||||
register(Biome.class, TypeBiome.get());
|
register(TypeBiome.get());
|
||||||
register(ChatColor.class, TypeChatColor.get());
|
register(TypeChatColor.get());
|
||||||
register(Difficulty.class, TypeDifficulty.get());
|
register(TypeDifficulty.get());
|
||||||
register(DyeColor.class, TypeDyeColor.get());
|
register(TypeDyeColor.get());
|
||||||
register(EntityType.class, TypeEntityType.get());
|
register(TypeEntityType.get());
|
||||||
register(Environment.class, TypeEnvironment.get());
|
register(TypeEnvironment.get());
|
||||||
register(EventPriority.class, TypeEventPriority.get());
|
register(TypeEventPriority.get());
|
||||||
register(GameMode.class, TypeGameMode.get());
|
register(TypeFireworkEffectType.get());
|
||||||
register(Horse.Color.class, TypeHorseColor.get());
|
register(TypeGameMode.get());
|
||||||
register(Horse.Style.class, TypeHorseStyle.get());
|
register(TypeHorseColor.get());
|
||||||
register(Horse.Variant.class, TypeHorseVariant.get());
|
register(TypeHorseStyle.get());
|
||||||
register(Material.class, TypeMaterial.get());
|
register(TypeHorseVariant.get());
|
||||||
register(Ocelot.Type.class, TypeOcelotType.get());
|
register(TypeMaterial.get());
|
||||||
register(ParticleEffect.class, TypeParticleEffect.get());
|
register(TypeOcelotType.get());
|
||||||
|
register(TypeParticleEffect.get());
|
||||||
|
|
||||||
// About 15% of all servers are still using 1.7.x.
|
// About 15% of all servers are still using 1.7.x.
|
||||||
// We catch NoClassDefFoundError and silently move along on those servers.
|
// We catch NoClassDefFoundError and silently move along on those servers.
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
register(org.bukkit.entity.Rabbit.Type.class, TypeRabbitType.get());
|
register(TypeRabbitType.get());
|
||||||
}
|
}
|
||||||
catch (Throwable t)
|
catch (Throwable t)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
register(SkeletonType.class, TypeSkeletonType.get());
|
register(TypeSkeletonType.get());
|
||||||
register(Sound.class, TypeSound.get());
|
register(TypeSound.get());
|
||||||
register(Profession.class, TypeVillagerProfession.get());
|
register(TypeVillagerProfession.get());
|
||||||
register(WorldType.class, TypeWorldType.get());
|
register(TypeWorldType.get());
|
||||||
|
|
||||||
|
// Bukkit
|
||||||
|
register(TypeDestination.get());
|
||||||
|
register(TypeItemStack.get());
|
||||||
|
register(TypeDataBannerPattern.get());
|
||||||
|
register(TypeDataPotionEffect.get());
|
||||||
|
register(TypeDataFireworkEffect.get());
|
||||||
|
register(TypeDataItemStack.get());
|
||||||
|
register(TypePermission.get());
|
||||||
|
register(TypePotionEffectType.get());
|
||||||
|
register(TypePS.get());
|
||||||
|
register(TypeWorld.get());
|
||||||
|
register(TypePotionEffectWrap.get());
|
||||||
|
register(TypeSoundEffect.get());
|
||||||
|
|
||||||
// Sender
|
// Sender
|
||||||
register(Player.class, TypePlayer.get());
|
register(TypePlayer.get());
|
||||||
register(CommandSender.class, TypeSender.get());
|
register(TypeSender.get());
|
||||||
|
|
||||||
// Store
|
// Store
|
||||||
register(Aspect.class, TypeAspect.get());
|
register(TypeAspect.get());
|
||||||
register(Multiverse.class, TypeMultiverse.get());
|
register(TypeMultiverse.get());
|
||||||
|
|
||||||
// Collection
|
// Collection
|
||||||
register(WorldExceptionSet.class, TypeExceptionSet.get(TypeWorld.get()));
|
register(WorldExceptionSet.class, TypeExceptionSet.get(TypeWorld.get()));
|
||||||
|
@ -24,8 +24,10 @@ public interface Type<T> extends Named
|
|||||||
// Human friendly name
|
// Human friendly name
|
||||||
public String getName();
|
public String getName();
|
||||||
|
|
||||||
|
public Class<T> getClazz();
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// INNER
|
// INNER TYPE
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
public <I extends Type<?>> List<I> getInnerTypes();
|
public <I extends Type<?>> List<I> getInnerTypes();
|
||||||
@ -42,6 +44,19 @@ public interface Type<T> extends Named
|
|||||||
public Integer getIndexUser(int indexTechy);
|
public Integer getIndexUser(int indexTechy);
|
||||||
public Integer getIndexTech(int indexUser);
|
public Integer getIndexTech(int indexUser);
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// INNER PROPERTY
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
public boolean hasInnerProperties();
|
||||||
|
|
||||||
|
public <I extends Property<T, ?>> List<I> getInnerProperties();
|
||||||
|
public <I extends Property<T, ?>> I getInnerProperty(int index);
|
||||||
|
|
||||||
|
public <I extends Property<T, ?>> void setInnerProperties(Collection<I> innerTypes);
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public <I extends Property<T, ?>> void setInnerProperties(I... innerTypes);
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// WRITE VISUAL COLOR
|
// WRITE VISUAL COLOR
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
@ -50,6 +65,15 @@ public interface Type<T> extends Named
|
|||||||
public ChatColor getVisualColor(T value);
|
public ChatColor getVisualColor(T value);
|
||||||
public void setVisualColor(ChatColor color);
|
public void setVisualColor(ChatColor color);
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// WRITE SHOW
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// A list of property values.
|
||||||
|
|
||||||
|
public List<Mson> getShowInner(T value, CommandSender sender);
|
||||||
|
public List<Mson> getShow(T value, CommandSender sender);
|
||||||
|
public List<Mson> getShow(T value);
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// WRITE VISUAL MSON
|
// WRITE VISUAL MSON
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.massivecraft.massivecore.command.type;
|
package com.massivecraft.massivecore.command.type;
|
||||||
|
|
||||||
|
import java.lang.reflect.Constructor;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -19,9 +20,11 @@ import com.massivecraft.massivecore.MassiveException;
|
|||||||
import com.massivecraft.massivecore.Named;
|
import com.massivecraft.massivecore.Named;
|
||||||
import com.massivecraft.massivecore.collections.MassiveList;
|
import com.massivecraft.massivecore.collections.MassiveList;
|
||||||
import com.massivecraft.massivecore.command.editor.CommandEditAbstract;
|
import com.massivecraft.massivecore.command.editor.CommandEditAbstract;
|
||||||
|
import com.massivecraft.massivecore.command.editor.CommandEditProperties;
|
||||||
import com.massivecraft.massivecore.command.editor.CommandEditSimple;
|
import com.massivecraft.massivecore.command.editor.CommandEditSimple;
|
||||||
import com.massivecraft.massivecore.command.editor.EditSettings;
|
import com.massivecraft.massivecore.command.editor.EditSettings;
|
||||||
import com.massivecraft.massivecore.command.editor.Property;
|
import com.massivecraft.massivecore.command.editor.Property;
|
||||||
|
import com.massivecraft.massivecore.command.editor.PropertyReflection;
|
||||||
import com.massivecraft.massivecore.comparator.ComparatorSmart;
|
import com.massivecraft.massivecore.comparator.ComparatorSmart;
|
||||||
import com.massivecraft.massivecore.mson.Mson;
|
import com.massivecraft.massivecore.mson.Mson;
|
||||||
import com.massivecraft.massivecore.store.SenderEntity;
|
import com.massivecraft.massivecore.store.SenderEntity;
|
||||||
@ -67,6 +70,29 @@ public abstract class TypeAbstract<T> implements Type<T>
|
|||||||
return Txt.implode(words, " ").toLowerCase();
|
return Txt.implode(words, " ").toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected final Class<T> clazz;
|
||||||
|
public Class<T> getClazz() { return this.clazz; }
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// CONSTRUCT
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public TypeAbstract(Class<?> clazz)
|
||||||
|
{
|
||||||
|
this.clazz = (Class<T>) clazz;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
constructor = ReflectionUtil.getConstructor(clazz);
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// INNER
|
// INNER
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
@ -110,6 +136,47 @@ public abstract class TypeAbstract<T> implements Type<T>
|
|||||||
return this.userOrder.get(indexUser);
|
return this.userOrder.get(indexUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// INNER PROPERTY
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
protected List<Property<T, ?>> innerProperties = new MassiveList<>();
|
||||||
|
|
||||||
|
public boolean hasInnerProperties() { return ! this.getInnerProperties().isEmpty(); }
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public <I extends Property<T, ?>> List<I> getInnerProperties() { return (List<I>) this.innerProperties; }
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public <I extends Property<T, ?>> I getInnerProperty(int index) { return (I) this.getInnerProperties().get(index); }
|
||||||
|
|
||||||
|
public <I extends Property<T, ?>> void setInnerProperties(Collection<I> innerProperties) { this.innerProperties = new MassiveList<Property<T, ?>>(innerProperties); }
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public <I extends Property<T, ?>> void setInnerProperties(I... innerProperties) { this.setInnerProperties(Arrays.asList(innerProperties)); }
|
||||||
|
public void setInnerProperties(Class<T> clazz) { this.setInnerProperties(PropertyReflection.getAll(clazz, this)); }
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// WRITE SHOW
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// A list of property values.
|
||||||
|
|
||||||
|
public List<Mson> getShowInner(T value, CommandSender sender)
|
||||||
|
{
|
||||||
|
if (this.hasInnerProperties())
|
||||||
|
{
|
||||||
|
return Property.getShowLines(value, sender, this.getInnerProperties());
|
||||||
|
}
|
||||||
|
return this.getVisualMsonInner(value, sender).split(Txt.PATTERN_NEWLINE);
|
||||||
|
}
|
||||||
|
public List<Mson> getShow(T value, CommandSender sender)
|
||||||
|
{
|
||||||
|
if (value == null) return Collections.singletonList(MSON_NULL);
|
||||||
|
return this.getShowInner(value, sender);
|
||||||
|
}
|
||||||
|
public List<Mson> getShow(T value)
|
||||||
|
{
|
||||||
|
return this.getShow(value, null);
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// WRITE VISUAL COLOR
|
// WRITE VISUAL COLOR
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
@ -153,8 +220,10 @@ public abstract class TypeAbstract<T> implements Type<T>
|
|||||||
public Mson getVisualMsonInner(T value, CommandSender sender)
|
public Mson getVisualMsonInner(T value, CommandSender sender)
|
||||||
{
|
{
|
||||||
String visualInner = this.getVisualInner(value, sender);
|
String visualInner = this.getVisualInner(value, sender);
|
||||||
if (visualInner == null) MUtil.stackTraceDebug("visualInner null for + " + value);
|
|
||||||
return Mson.fromParsedMessage(visualInner);
|
Mson ret = Mson.fromParsedMessage(visualInner);
|
||||||
|
if (this.hasInnerProperties()) ret.tooltip(Mson.toPlain(this.getShow(value, sender), true));
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -581,13 +650,29 @@ public abstract class TypeAbstract<T> implements Type<T>
|
|||||||
@Override
|
@Override
|
||||||
public <O> CommandEditAbstract<O, T> createEditCommand(EditSettings<O> settings, Property<O, T> property)
|
public <O> CommandEditAbstract<O, T> createEditCommand(EditSettings<O> settings, Property<O, T> property)
|
||||||
{
|
{
|
||||||
return new CommandEditSimple<O, T>(settings, property);
|
if (this.hasInnerProperties())
|
||||||
|
{
|
||||||
|
return new CommandEditProperties<O, T>(settings, property, null);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new CommandEditSimple<O, T>(settings, property);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private Constructor<T> constructor;
|
||||||
@Override
|
@Override
|
||||||
public T createNewInstance()
|
public T createNewInstance()
|
||||||
{
|
{
|
||||||
return null;
|
try
|
||||||
|
{
|
||||||
|
return this.constructor.newInstance();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -95,6 +95,15 @@ public abstract class TypeAbstractChoice<T> extends TypeAbstract<T> implements A
|
|||||||
public Collection<String> getTabs() { return this.tabs; }
|
public Collection<String> getTabs() { return this.tabs; }
|
||||||
public void setTabs(Collection<String> tabs) { this.tabs = tabs; }
|
public void setTabs(Collection<String> tabs) { this.tabs = tabs; }
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// CONSTRUCT
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
public TypeAbstractChoice(Class<?> clazz)
|
||||||
|
{
|
||||||
|
super(clazz);
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// OVERRIDE: TYPE
|
// OVERRIDE: TYPE
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
@ -13,6 +13,15 @@ public abstract class TypeAbstractException<T> extends TypeAbstract<T>
|
|||||||
|
|
||||||
public abstract T valueOf(String arg, CommandSender sender) throws Exception;
|
public abstract T valueOf(String arg, CommandSender sender) throws Exception;
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// CONSTRUCT
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
public TypeAbstractException(Class<?> clazz)
|
||||||
|
{
|
||||||
|
super(clazz);
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// OVERRIDE
|
// OVERRIDE
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
@ -28,6 +28,15 @@ public abstract class TypeAbstractSelect<T> extends TypeAbstract<T> implements A
|
|||||||
|
|
||||||
public boolean canList(CommandSender sender) { return true; }
|
public boolean canList(CommandSender sender) { return true; }
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// CONSTRUCT
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
public TypeAbstractSelect(Class<?> clazz)
|
||||||
|
{
|
||||||
|
super(clazz);
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// OVERRIDE
|
// OVERRIDE
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
@ -5,7 +5,16 @@ import org.bukkit.command.CommandSender;
|
|||||||
import com.massivecraft.massivecore.util.Txt;
|
import com.massivecraft.massivecore.util.Txt;
|
||||||
|
|
||||||
public abstract class TypeAbstractSimple<T> extends TypeAbstractException<T>
|
public abstract class TypeAbstractSimple<T> extends TypeAbstractException<T>
|
||||||
{
|
{
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// CONSTRUCT
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
public TypeAbstractSimple(Class<?> clazz)
|
||||||
|
{
|
||||||
|
super(clazz);
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// OVERRIDE
|
// OVERRIDE
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
@ -21,6 +21,7 @@ public class TypeColor extends TypeAbstract<Color>
|
|||||||
|
|
||||||
private static TypeColor i = new TypeColor();
|
private static TypeColor i = new TypeColor();
|
||||||
public static TypeColor get() { return i; }
|
public static TypeColor get() { return i; }
|
||||||
|
public TypeColor() { super(Color.class); }
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// WRITE VISUAL
|
// WRITE VISUAL
|
||||||
|
@ -0,0 +1,19 @@
|
|||||||
|
package com.massivecraft.massivecore.command.type;
|
||||||
|
|
||||||
|
import com.massivecraft.massivecore.command.type.primitive.TypeObject;
|
||||||
|
import com.massivecraft.massivecore.item.DataFireworkEffect;
|
||||||
|
|
||||||
|
public class TypeDataFireworkEffect extends TypeObject<DataFireworkEffect>
|
||||||
|
{
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// INSTANCE & CONSTRUCT
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
private static TypeDataFireworkEffect i = new TypeDataFireworkEffect();
|
||||||
|
public static TypeDataFireworkEffect get() { return i; }
|
||||||
|
public TypeDataFireworkEffect()
|
||||||
|
{
|
||||||
|
super(DataFireworkEffect.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -22,7 +22,8 @@ public class TypeDate extends TypeAbstractSimple<Date>
|
|||||||
|
|
||||||
private static TypeDate i = new TypeDate();
|
private static TypeDate i = new TypeDate();
|
||||||
public static TypeDate get() { return i; }
|
public static TypeDate get() { return i; }
|
||||||
|
public TypeDate() { super(Date.class); }
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// OVERRIDE
|
// OVERRIDE
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
@ -17,6 +17,7 @@ public class TypeDestination extends TypeAbstract<Destination>
|
|||||||
|
|
||||||
private static TypeDestination i = new TypeDestination();
|
private static TypeDestination i = new TypeDestination();
|
||||||
public static TypeDestination get() { return i; }
|
public static TypeDestination get() { return i; }
|
||||||
|
public TypeDestination() { super(Destination.class); }
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// OVERRIDE
|
// OVERRIDE
|
||||||
|
@ -19,6 +19,7 @@ public class TypeEnchantment extends TypeAbstractChoice<Enchantment>
|
|||||||
public static TypeEnchantment get() { return i; }
|
public static TypeEnchantment get() { return i; }
|
||||||
public TypeEnchantment()
|
public TypeEnchantment()
|
||||||
{
|
{
|
||||||
|
super(Enchantment.class);
|
||||||
this.setVisualColor(ChatColor.AQUA);
|
this.setVisualColor(ChatColor.AQUA);
|
||||||
this.setAll(Enchantment.values());
|
this.setAll(Enchantment.values());
|
||||||
}
|
}
|
||||||
|
51
src/com/massivecraft/massivecore/command/type/TypeId.java
Normal file
51
src/com/massivecraft/massivecore/command/type/TypeId.java
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
package com.massivecraft.massivecore.command.type;
|
||||||
|
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
|
||||||
|
import com.massivecraft.massivecore.MassiveException;
|
||||||
|
import com.massivecraft.massivecore.command.type.enumeration.TypeSound;
|
||||||
|
import com.massivecraft.massivecore.command.type.primitive.TypeStringId;
|
||||||
|
|
||||||
|
public class TypeId<T> extends TypeTransformer<T, String>
|
||||||
|
{
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// INSTANCE & CONSTRUCT
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
private static TypeId<Sound> iSound = TypeId.get(TypeSound.get());
|
||||||
|
public static TypeId<Sound> getSound() { return iSound; }
|
||||||
|
|
||||||
|
public static <T> TypeId<T> get(Type<T> inner) { return new TypeId<>(inner); }
|
||||||
|
public TypeId(Type<T> inner)
|
||||||
|
{
|
||||||
|
super(inner, TypeStringId.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// OVERRIDE
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String innerToOuter(T inner)
|
||||||
|
{
|
||||||
|
if (inner == null) return null;
|
||||||
|
return INNER.getId(inner);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public T outerToInner(String outer)
|
||||||
|
{
|
||||||
|
if (outer == null) return null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return this.INNER.read(outer);
|
||||||
|
}
|
||||||
|
catch (MassiveException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -36,6 +36,7 @@ public class TypeItemStack extends TypeAbstract<ItemStack>
|
|||||||
|
|
||||||
public TypeItemStack(ExceptionSet<Material> materialsAllowed)
|
public TypeItemStack(ExceptionSet<Material> materialsAllowed)
|
||||||
{
|
{
|
||||||
|
super(ItemStack.class);
|
||||||
this.materialsAllowed = materialsAllowed;
|
this.materialsAllowed = materialsAllowed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,42 @@
|
|||||||
|
package com.massivecraft.massivecore.command.type;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
|
||||||
|
import com.massivecraft.massivecore.command.type.enumeration.TypeMaterial;
|
||||||
|
import com.massivecraft.massivecore.command.type.primitive.TypeInteger;
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public class TypeMaterialId extends TypeTransformer<Material, Integer>
|
||||||
|
{
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// INSTANCE & CONSTRUCT
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
private static TypeMaterialId i = new TypeMaterialId();
|
||||||
|
public static TypeMaterialId get() { return i; }
|
||||||
|
|
||||||
|
public TypeMaterialId()
|
||||||
|
{
|
||||||
|
super(TypeMaterial.get(), TypeInteger.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// OVERRIDE
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer innerToOuter(Material inner)
|
||||||
|
{
|
||||||
|
if (inner == null) return null;
|
||||||
|
return inner.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Material outerToInner(Integer outer)
|
||||||
|
{
|
||||||
|
if (outer == null) return null;
|
||||||
|
return Material.getMaterial(outer);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -18,6 +18,7 @@ public class TypeMillisDiff extends TypeAbstractException<Long>
|
|||||||
|
|
||||||
private static TypeMillisDiff i = new TypeMillisDiff();
|
private static TypeMillisDiff i = new TypeMillisDiff();
|
||||||
public static TypeMillisDiff get() { return i; }
|
public static TypeMillisDiff get() { return i; }
|
||||||
|
public TypeMillisDiff() { super(Long.class); }
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// OVERRIDE
|
// OVERRIDE
|
||||||
|
@ -6,7 +6,6 @@ import java.util.Collections;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
import com.massivecraft.massivecore.MassiveException;
|
||||||
import com.massivecraft.massivecore.command.type.TypeAbstract;
|
|
||||||
|
|
||||||
public abstract class TypeNameAbstract extends TypeAbstract<String>
|
public abstract class TypeNameAbstract extends TypeAbstract<String>
|
||||||
{
|
{
|
||||||
@ -24,6 +23,7 @@ public abstract class TypeNameAbstract extends TypeAbstract<String>
|
|||||||
|
|
||||||
public TypeNameAbstract(boolean strict)
|
public TypeNameAbstract(boolean strict)
|
||||||
{
|
{
|
||||||
|
super(String.class);
|
||||||
this.strict = strict;
|
this.strict = strict;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ public class TypePS extends TypeAbstract<PS>
|
|||||||
|
|
||||||
private static TypePS i = new TypePS();
|
private static TypePS i = new TypePS();
|
||||||
public static TypePS get() { return i; }
|
public static TypePS get() { return i; }
|
||||||
|
public TypePS() { super(PS.class); }
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// OVERRIDE
|
// OVERRIDE
|
||||||
|
@ -12,6 +12,7 @@ public class TypePermission extends TypeAbstractChoice<Permission>
|
|||||||
|
|
||||||
private static TypePermission i = new TypePermission();
|
private static TypePermission i = new TypePermission();
|
||||||
public static TypePermission get() { return i; }
|
public static TypePermission get() { return i; }
|
||||||
|
public TypePermission() { super(Permission.class); }
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// OVERRIDE
|
// OVERRIDE
|
||||||
|
@ -12,6 +12,7 @@ public class TypePotionEffectType extends TypeAbstractChoice<PotionEffectType>
|
|||||||
public static TypePotionEffectType get() { return i; }
|
public static TypePotionEffectType get() { return i; }
|
||||||
public TypePotionEffectType()
|
public TypePotionEffectType()
|
||||||
{
|
{
|
||||||
|
super(PotionEffectType.class);
|
||||||
this.setAll(PotionEffectType.values());
|
this.setAll(PotionEffectType.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,46 @@
|
|||||||
|
package com.massivecraft.massivecore.command.type;
|
||||||
|
|
||||||
|
import com.massivecraft.massivecore.command.editor.annotation.EditorName;
|
||||||
|
|
||||||
|
public class TypeReflection<T> extends TypeAbstractChoice<T>
|
||||||
|
{
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// INSTANCE & CONSTRUCT
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
public static <T> TypeReflection<T> get(Class<T> clazz){ return new TypeReflection<>(clazz); }
|
||||||
|
public TypeReflection(Class<T> clazz)
|
||||||
|
{
|
||||||
|
super(clazz);
|
||||||
|
this.setInnerProperties(clazz);
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// OVERRIDE
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return this.getClazz().getSimpleName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getIdInner(T value)
|
||||||
|
{
|
||||||
|
return getId(value.getClass());
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// UTIL
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
public static String getId(Class<?> clazz)
|
||||||
|
{
|
||||||
|
EditorName ann = clazz.getAnnotation(EditorName.class);
|
||||||
|
if (ann != null) return ann.value();
|
||||||
|
|
||||||
|
return clazz.getSimpleName();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,42 +1,17 @@
|
|||||||
package com.massivecraft.massivecore.command.type;
|
package com.massivecraft.massivecore.command.type;
|
||||||
|
|
||||||
import com.massivecraft.massivecore.command.editor.CommandEditAbstract;
|
public class TypeSingleton<T> extends TypeReflection<T>
|
||||||
import com.massivecraft.massivecore.command.editor.CommandEditReflection;
|
|
||||||
import com.massivecraft.massivecore.command.editor.EditSettings;
|
|
||||||
import com.massivecraft.massivecore.command.editor.Property;
|
|
||||||
|
|
||||||
public class TypeSingleton<T> extends TypeAbstractChoice<T>
|
|
||||||
{
|
{
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// INSTANCE & CONSTRUCT
|
// INSTANCE & CONSTRUCT
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
public static <T> TypeSingleton<T> get(T singleton){ return new TypeSingleton<>(singleton); }
|
public static <T> TypeSingleton<T> get(T singleton){ return new TypeSingleton<>(singleton); }
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public TypeSingleton(T singleton)
|
public TypeSingleton(T singleton)
|
||||||
{
|
{
|
||||||
|
super((Class<T>) singleton.getClass());
|
||||||
super.setAll(singleton);
|
super.setAll(singleton);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName()
|
|
||||||
{
|
|
||||||
return this.getAll().iterator().next().getClass().getSimpleName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getIdInner(T value)
|
|
||||||
{
|
|
||||||
return value.getClass().getSimpleName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public <O> CommandEditAbstract<O, T> createEditCommand(EditSettings<O> settings, Property<O, T> property)
|
|
||||||
{
|
|
||||||
return new CommandEditReflection<O, T>(settings, property, (Class<T>) this.getAll().iterator().next().getClass());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,7 @@ public class TypeStringCommand extends TypeAbstract<String>
|
|||||||
|
|
||||||
public TypeStringCommand()
|
public TypeStringCommand()
|
||||||
{
|
{
|
||||||
|
super(String.class);
|
||||||
this.setVisualColor(ChatColor.AQUA);
|
this.setVisualColor(ChatColor.AQUA);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,6 +66,7 @@ public abstract class TypeTransformer<I, O> extends TypeAbstract<O>
|
|||||||
|
|
||||||
public TypeTransformer(Type<I> typeInner, Type<O> typeOuter)
|
public TypeTransformer(Type<I> typeInner, Type<O> typeOuter)
|
||||||
{
|
{
|
||||||
|
super(typeOuter.getClazz());
|
||||||
this.setInnerTypes(typeInner, typeOuter);
|
this.setInnerTypes(typeInner, typeOuter);
|
||||||
INNER = typeInner;
|
INNER = typeInner;
|
||||||
OUTER = typeOuter;
|
OUTER = typeOuter;
|
||||||
@ -89,6 +90,22 @@ public abstract class TypeTransformer<I, O> extends TypeAbstract<O>
|
|||||||
return INNER.getName();
|
return INNER.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// INNER PROPERTIES
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <U extends Property<O, ?>> List<U> getInnerProperties()
|
||||||
|
{
|
||||||
|
return OUTER.getInnerProperties();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <U extends Property<O, ?>> void setInnerProperties(Collection<U> innerProperties)
|
||||||
|
{
|
||||||
|
OUTER.setInnerProperties(innerProperties);
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// WRITE VISUAL COLOR
|
// WRITE VISUAL COLOR
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
@ -27,8 +27,8 @@ public class TypeUniverse extends TypeAbstractChoice<String>
|
|||||||
public static TypeUniverse get(Aspect aspect) { return new TypeUniverse(aspect); }
|
public static TypeUniverse get(Aspect aspect) { return new TypeUniverse(aspect); }
|
||||||
public static TypeUniverse get(Multiverse multiverse) { return new TypeUniverse(multiverse); }
|
public static TypeUniverse get(Multiverse multiverse) { return new TypeUniverse(multiverse); }
|
||||||
|
|
||||||
public TypeUniverse(Aspect aspect) { this.aspect = aspect; }
|
public TypeUniverse(Aspect aspect) { super(String.class); this.aspect = aspect; }
|
||||||
public TypeUniverse(Multiverse multiverse) { this.multiverse = multiverse; }
|
public TypeUniverse(Multiverse multiverse) { super(String.class); this.multiverse = multiverse; }
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// OVERRIDE
|
// OVERRIDE
|
||||||
|
@ -16,6 +16,7 @@ public class TypeWorld extends TypeAbstractChoice<World>
|
|||||||
|
|
||||||
private static TypeWorld i = new TypeWorld();
|
private static TypeWorld i = new TypeWorld();
|
||||||
public static TypeWorld get() { return i; }
|
public static TypeWorld get() { return i; }
|
||||||
|
public TypeWorld() { super(World.class); }
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// OVERRIDE
|
// OVERRIDE
|
||||||
|
@ -14,6 +14,7 @@ public class TypeWorldId extends TypeAbstractChoice<String>
|
|||||||
|
|
||||||
private static TypeWorldId i = new TypeWorldId();
|
private static TypeWorldId i = new TypeWorldId();
|
||||||
public static TypeWorldId get() { return i; }
|
public static TypeWorldId get() { return i; }
|
||||||
|
public TypeWorldId() { super(String.class); }
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// OVERRIDE
|
// OVERRIDE
|
||||||
|
@ -1,11 +1,16 @@
|
|||||||
package com.massivecraft.massivecore.command.type;
|
package com.massivecraft.massivecore.command.type;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
import com.massivecraft.massivecore.MassiveException;
|
||||||
import com.massivecraft.massivecore.collections.MassiveList;
|
import com.massivecraft.massivecore.collections.MassiveList;
|
||||||
|
import com.massivecraft.massivecore.command.editor.CommandEditAbstract;
|
||||||
|
import com.massivecraft.massivecore.command.editor.EditSettings;
|
||||||
|
import com.massivecraft.massivecore.command.editor.Property;
|
||||||
|
import com.massivecraft.massivecore.mson.Mson;
|
||||||
|
|
||||||
public class TypeWrapper<T> extends TypeAbstract<T>
|
public class TypeWrapper<T> extends TypeAbstract<T>
|
||||||
{
|
{
|
||||||
@ -15,7 +20,7 @@ public class TypeWrapper<T> extends TypeAbstract<T>
|
|||||||
|
|
||||||
public TypeWrapper(Type<T> innerType)
|
public TypeWrapper(Type<T> innerType)
|
||||||
{
|
{
|
||||||
if (innerType == null) throw new NullPointerException("inner");
|
super(innerType.getClazz());
|
||||||
this.setInnerType(innerType);
|
this.setInnerType(innerType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,6 +34,20 @@ public class TypeWrapper<T> extends TypeAbstract<T>
|
|||||||
return this.getInnerType().getName();
|
return this.getInnerType().getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Mson> getShowInner(T value, CommandSender sender)
|
||||||
|
{
|
||||||
|
Type<T> innerType = this.getInnerType();
|
||||||
|
return innerType.getShowInner(value, sender);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mson getVisualMsonInner(T value, CommandSender sender)
|
||||||
|
{
|
||||||
|
Type<T> innerType = this.getInnerType();
|
||||||
|
return innerType.getVisualMsonInner(value, sender);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getVisualInner(T value, CommandSender sender)
|
public String getVisualInner(T value, CommandSender sender)
|
||||||
{
|
{
|
||||||
@ -69,4 +88,32 @@ public class TypeWrapper<T> extends TypeAbstract<T>
|
|||||||
return this.getInnerType().allowSpaceAfterTab();
|
return this.getInnerType().allowSpaceAfterTab();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <I extends Property<T, ?>> List<I> getInnerProperties()
|
||||||
|
{
|
||||||
|
Type<T> innerType = this.getInnerType();
|
||||||
|
return innerType.getInnerProperties();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <I extends Property<T, ?>> void setInnerProperties(Collection<I> innerProperties)
|
||||||
|
{
|
||||||
|
Type<T> innerType = this.getInnerType();
|
||||||
|
innerType.setInnerProperties(innerProperties);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <O> CommandEditAbstract<O, T> createEditCommand(EditSettings<O> settings, Property<O, T> property)
|
||||||
|
{
|
||||||
|
Type<T> innerType = this.getInnerType();
|
||||||
|
return innerType.createEditCommand(settings, property);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public T createNewInstance()
|
||||||
|
{
|
||||||
|
Type<T> innerType = this.getInnerType();
|
||||||
|
return innerType.createNewInstance();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,8 @@ import org.bukkit.command.CommandSender;
|
|||||||
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
import com.massivecraft.massivecore.MassiveException;
|
||||||
import com.massivecraft.massivecore.collections.MassiveList;
|
import com.massivecraft.massivecore.collections.MassiveList;
|
||||||
|
import com.massivecraft.massivecore.command.editor.Property;
|
||||||
|
import com.massivecraft.massivecore.command.editor.PropertyReflection;
|
||||||
import com.massivecraft.massivecore.command.type.Type;
|
import com.massivecraft.massivecore.command.type.Type;
|
||||||
import com.massivecraft.massivecore.command.type.TypeAbstract;
|
import com.massivecraft.massivecore.command.type.TypeAbstract;
|
||||||
import com.massivecraft.massivecore.mson.Mson;
|
import com.massivecraft.massivecore.mson.Mson;
|
||||||
@ -87,19 +89,64 @@ public abstract class TypeCombined<T> extends TypeAbstract<T>
|
|||||||
// CONSTRUCT
|
// CONSTRUCT
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
public TypeCombined(Type<?>... innerTypes)
|
public TypeCombined(Class<?> clazz, Type<?>... innerTypes)
|
||||||
{
|
{
|
||||||
|
super(clazz);
|
||||||
this.setInnerTypes(innerTypes);
|
this.setInnerTypes(innerTypes);
|
||||||
this.setSeparators(SEPARATORS_DEFAULT);
|
this.setSeparators(SEPARATORS_DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TypeCombined(Class<T> clazz)
|
||||||
|
{
|
||||||
|
super(clazz);
|
||||||
|
this.setInnerProperties(PropertyReflection.getAll(clazz, this));
|
||||||
|
|
||||||
|
List<Type<?>> innerTypes = new MassiveList<>();
|
||||||
|
for (Property<T, ?> property : this.getInnerProperties())
|
||||||
|
{
|
||||||
|
innerTypes.add(property.getValueType());
|
||||||
|
}
|
||||||
|
this.setInnerTypes(innerTypes);
|
||||||
|
|
||||||
|
this.setSeparators(SEPARATORS_DEFAULT);
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// ABSTRACT
|
// CORE
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
public abstract T combine(List<Object> parts);
|
public T combine(List<Object> parts)
|
||||||
|
{
|
||||||
|
if ( ! this.hasInnerProperties()) throw new IllegalStateException("TypeCombined#combine must be implemented.");
|
||||||
|
|
||||||
|
T ret = this.createNewInstance();
|
||||||
|
if (ret == null) throw new IllegalStateException("Type#createNewInstance must be implemented.");
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
for (Object part : parts)
|
||||||
|
{
|
||||||
|
Property<T, Object> property = this.getInnerProperty(i);
|
||||||
|
property.setRaw(ret, part);
|
||||||
|
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
public abstract List<Object> split(T value);
|
public List<Object> split(T value)
|
||||||
|
{
|
||||||
|
if ( ! this.hasInnerProperties()) throw new IllegalStateException("TypeCombined#split must be implemented.");
|
||||||
|
|
||||||
|
List<Object> parts = new MassiveList<>();
|
||||||
|
|
||||||
|
for (Property<T, ?> property : this.getInnerProperties())
|
||||||
|
{
|
||||||
|
parts.add(property.getValue(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
return parts;
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// SPLIT ENTRIES
|
// SPLIT ENTRIES
|
||||||
@ -115,7 +162,7 @@ public abstract class TypeCombined<T> extends TypeAbstract<T>
|
|||||||
if (parts.size() > this.getInnerTypes().size()) throw new RuntimeException("Too many parts!");
|
if (parts.size() > this.getInnerTypes().size()) throw new RuntimeException("Too many parts!");
|
||||||
for (int i = 0; i < parts.size(); i++)
|
for (int i = 0; i < parts.size(); i++)
|
||||||
{
|
{
|
||||||
Type<?> type = this.getInnerTypes().get(i);
|
Type<?> type = this.getInnerType(i);
|
||||||
Object part = parts.get(i);
|
Object part = parts.get(i);
|
||||||
SimpleEntry<Type<?>, Object> entry = new SimpleEntry<Type<?>, Object>(type, part);
|
SimpleEntry<Type<?>, Object> entry = new SimpleEntry<Type<?>, Object>(type, part);
|
||||||
ret.add(entry);
|
ret.add(entry);
|
||||||
@ -203,6 +250,33 @@ public abstract class TypeCombined<T> extends TypeAbstract<T>
|
|||||||
return Txt.implode(parts, this.getTypeNameSeparator());
|
return Txt.implode(parts, this.getTypeNameSeparator());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// WRITE SHOW
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public List<Mson> getShowInner(T value, CommandSender sender)
|
||||||
|
{
|
||||||
|
if (this.hasInnerProperties())
|
||||||
|
{
|
||||||
|
return super.getShowInner(value, sender);
|
||||||
|
}
|
||||||
|
// Create
|
||||||
|
List<Mson> ret = new MassiveList<>();
|
||||||
|
|
||||||
|
// Fill
|
||||||
|
for (Entry<Type<?>, Object> entry : this.splitEntriesUser(value))
|
||||||
|
{
|
||||||
|
Type<Object> type = (Type<Object>) entry.getKey();
|
||||||
|
ret.addAll(type.getShow(entry.getValue()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Return
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// WRITE VISUAL MSON
|
// WRITE VISUAL MSON
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
@ -323,7 +397,7 @@ public abstract class TypeCombined<T> extends TypeAbstract<T>
|
|||||||
for (int i = 0; i < innerArgs.size(); i++)
|
for (int i = 0; i < innerArgs.size(); i++)
|
||||||
{
|
{
|
||||||
String innerArg = innerArgs.get(i);
|
String innerArg = innerArgs.get(i);
|
||||||
Type<?> innerType = this.getInnerTypes().get(getIndexUser(i));
|
Type<?> innerType = this.getInnerType(getIndexUser(i));
|
||||||
Object part = innerType.read(innerArg, sender);
|
Object part = innerType.read(innerArg, sender);
|
||||||
ret.add(part);
|
ret.add(part);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,19 @@
|
|||||||
|
package com.massivecraft.massivecore.command.type.combined;
|
||||||
|
|
||||||
|
import com.massivecraft.massivecore.item.DataBannerPattern;
|
||||||
|
|
||||||
|
public class TypeDataBannerPattern extends TypeCombined<DataBannerPattern>
|
||||||
|
{
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// INSTANCE & CONSTRUCT
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
private static TypeDataBannerPattern i = new TypeDataBannerPattern();
|
||||||
|
public static TypeDataBannerPattern get() { return i; }
|
||||||
|
|
||||||
|
public TypeDataBannerPattern()
|
||||||
|
{
|
||||||
|
super(DataBannerPattern.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package com.massivecraft.massivecore.command.type.combined;
|
||||||
|
|
||||||
|
import com.massivecraft.massivecore.item.DataPotionEffect;
|
||||||
|
|
||||||
|
public class TypeDataPotionEffect extends TypeCombined<DataPotionEffect>
|
||||||
|
{
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// INSTANCE & CONSTRUCT
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
private static TypeDataPotionEffect i = new TypeDataPotionEffect();
|
||||||
|
public static TypeDataPotionEffect get() { return i; }
|
||||||
|
public TypeDataPotionEffect()
|
||||||
|
{
|
||||||
|
super(DataPotionEffect.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -23,7 +23,7 @@ public class TypeEntry<K, V> extends TypeCombined<Entry<K, V>>
|
|||||||
public static <K, V> TypeEntry<K, V> get(Type<K> keyType, Type<V> valueType) { return new TypeEntry<K, V>(keyType, valueType); }
|
public static <K, V> TypeEntry<K, V> get(Type<K> keyType, Type<V> valueType) { return new TypeEntry<K, V>(keyType, valueType); }
|
||||||
public TypeEntry(Type<K> keyType, Type<V> valueType)
|
public TypeEntry(Type<K> keyType, Type<V> valueType)
|
||||||
{
|
{
|
||||||
super(keyType, valueType);
|
super(Entry.class, keyType, valueType);
|
||||||
this.setTypeNameSeparator(" and ");
|
this.setTypeNameSeparator(" and ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,66 +0,0 @@
|
|||||||
package com.massivecraft.massivecore.command.type.combined;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.DyeColor;
|
|
||||||
import org.bukkit.block.banner.Pattern;
|
|
||||||
import org.bukkit.block.banner.PatternType;
|
|
||||||
|
|
||||||
import com.massivecraft.massivecore.collections.MassiveList;
|
|
||||||
import com.massivecraft.massivecore.command.type.enumeration.TypeDyeColor;
|
|
||||||
import com.massivecraft.massivecore.command.type.enumeration.TypePatternType;
|
|
||||||
|
|
||||||
public class TypePattern extends TypeCombined<Pattern>
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// INSTANCE & CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
private static TypePattern i = new TypePattern();
|
|
||||||
public static TypePattern get() { return i; }
|
|
||||||
|
|
||||||
public TypePattern()
|
|
||||||
{
|
|
||||||
super(
|
|
||||||
TypeDyeColor.get(),
|
|
||||||
TypePatternType.get()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Object> split(Pattern value)
|
|
||||||
{
|
|
||||||
return new MassiveList<Object>(
|
|
||||||
value.getColor(),
|
|
||||||
value.getPattern()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Pattern combine(List<Object> parts)
|
|
||||||
{
|
|
||||||
DyeColor color = null;
|
|
||||||
PatternType pattern = null;
|
|
||||||
|
|
||||||
for (int i = 0 ; i < parts.size() ; i++)
|
|
||||||
{
|
|
||||||
Object part = parts.get(i);
|
|
||||||
|
|
||||||
if (i == 0)
|
|
||||||
{
|
|
||||||
color = (DyeColor)part;
|
|
||||||
}
|
|
||||||
else if (i == 1)
|
|
||||||
{
|
|
||||||
pattern = (PatternType) part;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Pattern(color, pattern);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,14 +1,6 @@
|
|||||||
package com.massivecraft.massivecore.command.type.combined;
|
package com.massivecraft.massivecore.command.type.combined;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.potion.PotionEffectType;
|
|
||||||
|
|
||||||
import com.massivecraft.massivecore.PotionEffectWrap;
|
import com.massivecraft.massivecore.PotionEffectWrap;
|
||||||
import com.massivecraft.massivecore.collections.MassiveList;
|
|
||||||
import com.massivecraft.massivecore.command.type.TypePotionEffectType;
|
|
||||||
import com.massivecraft.massivecore.command.type.primitive.TypeBoolean;
|
|
||||||
import com.massivecraft.massivecore.command.type.primitive.TypeInteger;
|
|
||||||
|
|
||||||
public class TypePotionEffectWrap extends TypeCombined<PotionEffectWrap>
|
public class TypePotionEffectWrap extends TypeCombined<PotionEffectWrap>
|
||||||
{
|
{
|
||||||
@ -21,71 +13,7 @@ public class TypePotionEffectWrap extends TypeCombined<PotionEffectWrap>
|
|||||||
|
|
||||||
public TypePotionEffectWrap()
|
public TypePotionEffectWrap()
|
||||||
{
|
{
|
||||||
super(
|
super(PotionEffectWrap.class);
|
||||||
TypePotionEffectType.get(),
|
|
||||||
TypeInteger.get(),
|
|
||||||
TypeInteger.get(),
|
|
||||||
TypeBoolean.getYes(),
|
|
||||||
TypeBoolean.getYes()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Object> split(PotionEffectWrap value)
|
|
||||||
{
|
|
||||||
return new MassiveList<Object>(
|
|
||||||
value.getPotionEffectType(),
|
|
||||||
value.getAmplifier(),
|
|
||||||
value.getDuration(),
|
|
||||||
value.isAmbient(),
|
|
||||||
value.isParticles()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PotionEffectWrap combine(List<Object> parts)
|
|
||||||
{
|
|
||||||
// Create
|
|
||||||
PotionEffectWrap ret = new PotionEffectWrap();
|
|
||||||
|
|
||||||
// Fill
|
|
||||||
for (int i = 0 ; i < parts.size() ; i++)
|
|
||||||
{
|
|
||||||
Object part = parts.get(i);
|
|
||||||
|
|
||||||
if (i == 0)
|
|
||||||
{
|
|
||||||
PotionEffectType potionEffectType = (PotionEffectType)part;
|
|
||||||
ret.setPotionEffectType(potionEffectType);
|
|
||||||
}
|
|
||||||
else if (i == 1)
|
|
||||||
{
|
|
||||||
Integer amplifier = (Integer) part;
|
|
||||||
ret.setAmplifier(amplifier);
|
|
||||||
}
|
|
||||||
else if (i == 2)
|
|
||||||
{
|
|
||||||
Integer duration = (Integer) part;
|
|
||||||
ret.setDuration(duration);
|
|
||||||
}
|
|
||||||
else if (i == 3)
|
|
||||||
{
|
|
||||||
Boolean ambient = (Boolean) part;
|
|
||||||
ret.setAmbient(ambient);
|
|
||||||
}
|
|
||||||
else if (i == 4)
|
|
||||||
{
|
|
||||||
Boolean particles = (Boolean) part;
|
|
||||||
ret.setParticles(particles);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,6 @@
|
|||||||
package com.massivecraft.massivecore.command.type.combined;
|
package com.massivecraft.massivecore.command.type.combined;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.Sound;
|
|
||||||
|
|
||||||
import com.massivecraft.massivecore.SoundEffect;
|
import com.massivecraft.massivecore.SoundEffect;
|
||||||
import com.massivecraft.massivecore.collections.MassiveList;
|
|
||||||
import com.massivecraft.massivecore.command.type.enumeration.TypeSound;
|
|
||||||
import com.massivecraft.massivecore.command.type.primitive.TypeFloat;
|
|
||||||
|
|
||||||
public class TypeSoundEffect extends TypeCombined<SoundEffect>
|
public class TypeSoundEffect extends TypeCombined<SoundEffect>
|
||||||
{
|
{
|
||||||
@ -15,58 +8,12 @@ public class TypeSoundEffect extends TypeCombined<SoundEffect>
|
|||||||
// INSTANCE & CONSTRUCT
|
// INSTANCE & CONSTRUCT
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
private static TypeSoundEffect i = new TypeSoundEffect();
|
private static final TypeSoundEffect i = new TypeSoundEffect();
|
||||||
public static TypeSoundEffect get() { return i; }
|
public static TypeSoundEffect get() { return i; }
|
||||||
|
|
||||||
public TypeSoundEffect()
|
public TypeSoundEffect()
|
||||||
{
|
{
|
||||||
super(
|
super(SoundEffect.class);
|
||||||
TypeSound.get(),
|
|
||||||
TypeFloat.get(),
|
|
||||||
TypeFloat.get()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Object> split(SoundEffect value)
|
|
||||||
{
|
|
||||||
return new MassiveList<Object>(
|
|
||||||
value.getSound(),
|
|
||||||
value.getVolume(),
|
|
||||||
value.getPitch()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SoundEffect combine(List<Object> parts)
|
|
||||||
{
|
|
||||||
Sound sound = null;
|
|
||||||
float volume = 1.0f;
|
|
||||||
float pitch = 1.0f;
|
|
||||||
|
|
||||||
for (int i = 0 ; i < parts.size() ; i++)
|
|
||||||
{
|
|
||||||
Object part = parts.get(i);
|
|
||||||
|
|
||||||
if (i == 0)
|
|
||||||
{
|
|
||||||
sound = (Sound)part;
|
|
||||||
}
|
|
||||||
else if (i == 1)
|
|
||||||
{
|
|
||||||
volume = (Float) part;
|
|
||||||
}
|
|
||||||
else if (i == 2)
|
|
||||||
{
|
|
||||||
pitch = (Float) part;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return SoundEffect.valueOf(sound, volume, pitch);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,8 +25,9 @@ public abstract class TypeContainer<C extends Object, E> extends TypeAbstract<C>
|
|||||||
// CONSTRUCT
|
// CONSTRUCT
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
public TypeContainer(Type<E> innerType)
|
public TypeContainer(Class<?> clazz, Type<E> innerType)
|
||||||
{
|
{
|
||||||
|
super(clazz);
|
||||||
this.setInnerType(innerType);
|
this.setInnerType(innerType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,9 +7,13 @@ import org.bukkit.command.CommandSender;
|
|||||||
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
import com.massivecraft.massivecore.MassiveException;
|
||||||
import com.massivecraft.massivecore.collections.ExceptionSet;
|
import com.massivecraft.massivecore.collections.ExceptionSet;
|
||||||
|
import com.massivecraft.massivecore.collections.MassiveSet;
|
||||||
|
import com.massivecraft.massivecore.command.editor.Property;
|
||||||
|
import com.massivecraft.massivecore.command.editor.PropertyReflection;
|
||||||
import com.massivecraft.massivecore.command.type.Type;
|
import com.massivecraft.massivecore.command.type.Type;
|
||||||
import com.massivecraft.massivecore.command.type.TypeAbstract;
|
import com.massivecraft.massivecore.command.type.TypeAbstract;
|
||||||
import com.massivecraft.massivecore.command.type.primitive.TypeBoolean;
|
import com.massivecraft.massivecore.command.type.primitive.TypeBoolean;
|
||||||
|
import com.massivecraft.massivecore.util.ReflectionUtil;
|
||||||
import com.massivecraft.massivecore.util.Txt;
|
import com.massivecraft.massivecore.util.Txt;
|
||||||
|
|
||||||
public class TypeExceptionSet<E> extends TypeAbstract<ExceptionSet<E>>
|
public class TypeExceptionSet<E> extends TypeAbstract<ExceptionSet<E>>
|
||||||
@ -30,14 +34,55 @@ public class TypeExceptionSet<E> extends TypeAbstract<ExceptionSet<E>>
|
|||||||
return new TypeExceptionSet<E>(innerType);
|
return new TypeExceptionSet<E>(innerType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TypeExceptionSet(Type<E> innerType)
|
@SuppressWarnings("unchecked")
|
||||||
|
public TypeExceptionSet(final Type<E> innerType)
|
||||||
{
|
{
|
||||||
|
super(ExceptionSet.class);
|
||||||
|
|
||||||
this.typeElements = TypeSet.get(innerType);
|
this.typeElements = TypeSet.get(innerType);
|
||||||
|
|
||||||
|
// PROPERTIES
|
||||||
|
Property<ExceptionSet<E>, Boolean> propertyStandard = PropertyReflection.get(ReflectionUtil.getField(ExceptionSet.class, "standard"), this);
|
||||||
|
|
||||||
|
Property<ExceptionSet<E>, Set<E>> propertyExceptions = new Property<ExceptionSet<E>, Set<E>>(this, typeElements, "exceptions")
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public Set<E> getRaw(ExceptionSet<E> object)
|
||||||
|
{
|
||||||
|
Set<E> ret = new MassiveSet<>();
|
||||||
|
|
||||||
|
for (String exception : object.exceptions)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ret.add(innerType.read(exception));
|
||||||
|
}
|
||||||
|
catch (MassiveException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ExceptionSet<E> setRaw(ExceptionSet<E> object, Set<E> value)
|
||||||
|
{
|
||||||
|
object.exceptions = object.asStrings(value);
|
||||||
|
return object;
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
propertyExceptions.setNullable(false);
|
||||||
|
|
||||||
|
this.setInnerProperties(propertyStandard, propertyExceptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// OVERRIDE
|
// OVERRIDE
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
// TODO: Do we even need this now?
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ExceptionSet<E> read(String arg, CommandSender sender) throws MassiveException
|
public ExceptionSet<E> read(String arg, CommandSender sender) throws MassiveException
|
||||||
|
@ -18,7 +18,7 @@ public class TypeList<E> extends TypeContainer<List<E>, E>
|
|||||||
|
|
||||||
public TypeList(Type<E> innerType)
|
public TypeList(Type<E> innerType)
|
||||||
{
|
{
|
||||||
super(innerType);
|
super(List.class, innerType);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
@ -25,7 +25,7 @@ public class TypeMap<K, V> extends TypeContainer<Map<K, V>, Entry<K, V>>
|
|||||||
|
|
||||||
public TypeMap(TypeEntry<K, V> entryType)
|
public TypeMap(TypeEntry<K, V> entryType)
|
||||||
{
|
{
|
||||||
super(entryType);
|
super(Map.class, entryType);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
@ -18,7 +18,7 @@ public class TypeSet<E> extends TypeContainer<Set<E>, E>
|
|||||||
|
|
||||||
public TypeSet(Type<E> innerType)
|
public TypeSet(Type<E> innerType)
|
||||||
{
|
{
|
||||||
super(innerType);
|
super(Set.class, innerType);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
@ -0,0 +1,48 @@
|
|||||||
|
package com.massivecraft.massivecore.command.type.convert;
|
||||||
|
|
||||||
|
|
||||||
|
import com.massivecraft.massivecore.command.type.Type;
|
||||||
|
import com.massivecraft.massivecore.command.type.TypeTransformer;
|
||||||
|
import com.massivecraft.massivecore.item.Converter;
|
||||||
|
|
||||||
|
public class TypeConverter<A, B> extends TypeTransformer<A, B>
|
||||||
|
{
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// FIELDS
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
private final Converter<A, B> a2b;
|
||||||
|
public Converter<A, B> getA2b() { return this.a2b; }
|
||||||
|
|
||||||
|
private final Converter<B, A> b2a;
|
||||||
|
public Converter<B, A> getB2a() { return this.b2a; }
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// INSTANCE & CONSTRUCT
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
public TypeConverter(Type<A> typeA, Type<B> typeB, Converter<A, B> a2b, Converter<B, A> b2a)
|
||||||
|
{
|
||||||
|
super(typeA, typeB);
|
||||||
|
this.a2b = a2b;
|
||||||
|
this.b2a = b2a;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// OVERRIDE
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public B innerToOuter(A inner)
|
||||||
|
{
|
||||||
|
return this.getA2b().convert(inner);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public A outerToInner(B outer)
|
||||||
|
{
|
||||||
|
return this.getB2a().convert(outer);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
package com.massivecraft.massivecore.command.type.convert;
|
||||||
|
|
||||||
|
import org.bukkit.block.banner.PatternType;
|
||||||
|
|
||||||
|
import com.massivecraft.massivecore.command.type.enumeration.TypePatternType;
|
||||||
|
import com.massivecraft.massivecore.command.type.primitive.TypeString;
|
||||||
|
import com.massivecraft.massivecore.item.ConverterFromBannerPatternType;
|
||||||
|
import com.massivecraft.massivecore.item.ConverterToBannerPatternType;
|
||||||
|
|
||||||
|
public class TypeConverterBannerPatternType extends TypeConverter<PatternType, String>
|
||||||
|
{
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// INSTANCE & CONSTRUCT
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
private static TypeConverterBannerPatternType i = new TypeConverterBannerPatternType();
|
||||||
|
public static TypeConverterBannerPatternType get() { return i; }
|
||||||
|
|
||||||
|
public TypeConverterBannerPatternType()
|
||||||
|
{
|
||||||
|
super(TypePatternType.get(), TypeString.get(), ConverterFromBannerPatternType.get(), ConverterToBannerPatternType.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
package com.massivecraft.massivecore.command.type.convert;
|
||||||
|
|
||||||
|
import org.bukkit.Color;
|
||||||
|
|
||||||
|
import com.massivecraft.massivecore.command.type.TypeColor;
|
||||||
|
import com.massivecraft.massivecore.command.type.primitive.TypeInteger;
|
||||||
|
import com.massivecraft.massivecore.item.ConverterFromColor;
|
||||||
|
import com.massivecraft.massivecore.item.ConverterToColor;
|
||||||
|
|
||||||
|
public class TypeConverterColor extends TypeConverter<Color, Integer>
|
||||||
|
{
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// INSTANCE & CONSTRUCT
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
private static TypeConverterColor i = new TypeConverterColor();
|
||||||
|
public static TypeConverterColor get() { return i; }
|
||||||
|
|
||||||
|
public TypeConverterColor()
|
||||||
|
{
|
||||||
|
super(TypeColor.get(), TypeInteger.get(), ConverterFromColor.get(), ConverterToColor.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
package com.massivecraft.massivecore.command.type.convert;
|
||||||
|
|
||||||
|
import org.bukkit.DyeColor;
|
||||||
|
|
||||||
|
import com.massivecraft.massivecore.command.type.enumeration.TypeDyeColor;
|
||||||
|
import com.massivecraft.massivecore.command.type.primitive.TypeInteger;
|
||||||
|
import com.massivecraft.massivecore.item.ConverterFromDyeColor;
|
||||||
|
import com.massivecraft.massivecore.item.ConverterToDyeColor;
|
||||||
|
|
||||||
|
public class TypeConverterDyeColor extends TypeConverter<DyeColor, Integer>
|
||||||
|
{
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// INSTANCE & CONSTRUCT
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
private static TypeConverterDyeColor i = new TypeConverterDyeColor();
|
||||||
|
public static TypeConverterDyeColor get() { return i; }
|
||||||
|
|
||||||
|
public TypeConverterDyeColor()
|
||||||
|
{
|
||||||
|
super(TypeDyeColor.get(), TypeInteger.get(), ConverterFromDyeColor.get(), ConverterToDyeColor.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
package com.massivecraft.massivecore.command.type.convert;
|
||||||
|
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
|
||||||
|
import com.massivecraft.massivecore.command.type.TypeEnchantment;
|
||||||
|
import com.massivecraft.massivecore.command.type.primitive.TypeInteger;
|
||||||
|
import com.massivecraft.massivecore.item.ConverterFromEnchant;
|
||||||
|
import com.massivecraft.massivecore.item.ConverterToEnchant;
|
||||||
|
|
||||||
|
public class TypeConverterEnchant extends TypeConverter<Enchantment, Integer>
|
||||||
|
{
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// INSTANCE & CONSTRUCT
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
private static TypeConverterEnchant i = new TypeConverterEnchant();
|
||||||
|
public static TypeConverterEnchant get() { return i; }
|
||||||
|
|
||||||
|
public TypeConverterEnchant()
|
||||||
|
{
|
||||||
|
super(TypeEnchantment.get(), TypeInteger.get(), ConverterFromEnchant.get(), ConverterToEnchant.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
package com.massivecraft.massivecore.command.type.convert;
|
||||||
|
|
||||||
|
import org.bukkit.FireworkEffect.Type;
|
||||||
|
|
||||||
|
import com.massivecraft.massivecore.command.type.enumeration.TypeFireworkEffectType;
|
||||||
|
import com.massivecraft.massivecore.command.type.primitive.TypeString;
|
||||||
|
import com.massivecraft.massivecore.item.ConverterFromFireworkEffectType;
|
||||||
|
import com.massivecraft.massivecore.item.ConverterToFireworkEffectType;
|
||||||
|
|
||||||
|
public class TypeConverterFireworkEffectType extends TypeConverter<Type, String>
|
||||||
|
{
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// INSTANCE & CONSTRUCT
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
private static TypeConverterFireworkEffectType i = new TypeConverterFireworkEffectType();
|
||||||
|
public static TypeConverterFireworkEffectType get() { return i; }
|
||||||
|
|
||||||
|
public TypeConverterFireworkEffectType()
|
||||||
|
{
|
||||||
|
super(TypeFireworkEffectType.get(), TypeString.get(), ConverterFromFireworkEffectType.get(), ConverterToFireworkEffectType.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
package com.massivecraft.massivecore.command.type.convert;
|
||||||
|
|
||||||
|
import org.bukkit.inventory.ItemFlag;
|
||||||
|
|
||||||
|
import com.massivecraft.massivecore.command.type.enumeration.TypeItemFlag;
|
||||||
|
import com.massivecraft.massivecore.command.type.primitive.TypeString;
|
||||||
|
import com.massivecraft.massivecore.item.ConverterFromItemFlag;
|
||||||
|
import com.massivecraft.massivecore.item.ConverterToItemFlag;
|
||||||
|
|
||||||
|
public class TypeConverterItemFlag extends TypeConverter<ItemFlag, String>
|
||||||
|
{
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// INSTANCE & CONSTRUCT
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
private static TypeConverterItemFlag i = new TypeConverterItemFlag();
|
||||||
|
public static TypeConverterItemFlag get() { return i; }
|
||||||
|
|
||||||
|
public TypeConverterItemFlag()
|
||||||
|
{
|
||||||
|
super(TypeItemFlag.get(), TypeString.get(), ConverterFromItemFlag.get(), ConverterToItemFlag.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
package com.massivecraft.massivecore.command.type.convert;
|
||||||
|
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
|
import com.massivecraft.massivecore.command.type.TypePotionEffectType;
|
||||||
|
import com.massivecraft.massivecore.command.type.primitive.TypeInteger;
|
||||||
|
import com.massivecraft.massivecore.item.ConverterFromPotionEffectType;
|
||||||
|
import com.massivecraft.massivecore.item.ConverterToPotionEffectType;
|
||||||
|
|
||||||
|
public class TypeConverterPotionEffectType extends TypeConverter<PotionEffectType, Integer>
|
||||||
|
{
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// INSTANCE & CONSTRUCT
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
private static TypeConverterPotionEffectType i = new TypeConverterPotionEffectType();
|
||||||
|
public static TypeConverterPotionEffectType get() { return i; }
|
||||||
|
|
||||||
|
public TypeConverterPotionEffectType()
|
||||||
|
{
|
||||||
|
super(TypePotionEffectType.get(), TypeInteger.get(), ConverterFromPotionEffectType.get(), ConverterToPotionEffectType.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -18,6 +18,7 @@ public class TypeEnum<T extends Enum<T>> extends TypeAbstractChoice<T>
|
|||||||
|
|
||||||
public TypeEnum(Class<T> clazz)
|
public TypeEnum(Class<T> clazz)
|
||||||
{
|
{
|
||||||
|
super(clazz);
|
||||||
if ( ! clazz.isEnum()) throw new IllegalArgumentException("clazz must be enum");
|
if ( ! clazz.isEnum()) throw new IllegalArgumentException("clazz must be enum");
|
||||||
this.clazz = clazz;
|
this.clazz = clazz;
|
||||||
|
|
||||||
|
@ -0,0 +1,18 @@
|
|||||||
|
package com.massivecraft.massivecore.command.type.enumeration;
|
||||||
|
|
||||||
|
import org.bukkit.FireworkEffect.Type;
|
||||||
|
|
||||||
|
public class TypeFireworkEffectType extends TypeEnum<Type>
|
||||||
|
{
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// INSTANCE & CONSTRUCT
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
private static TypeFireworkEffectType i = new TypeFireworkEffectType();
|
||||||
|
public static TypeFireworkEffectType get() { return i; }
|
||||||
|
public TypeFireworkEffectType()
|
||||||
|
{
|
||||||
|
super(Type.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -20,8 +20,9 @@ public abstract class TypeAbstractNumber<T extends Number> extends TypeAbstractS
|
|||||||
// OVERRIDE
|
// OVERRIDE
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
public TypeAbstractNumber()
|
public TypeAbstractNumber(Class<T> clazz)
|
||||||
{
|
{
|
||||||
|
super(clazz);
|
||||||
this.setVisualColor(COLOR_NUMBER);
|
this.setVisualColor(COLOR_NUMBER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,6 +54,7 @@ public class TypeBoolean extends TypeAbstractChoice<Boolean>
|
|||||||
|
|
||||||
public TypeBoolean(String t, String f)
|
public TypeBoolean(String t, String f)
|
||||||
{
|
{
|
||||||
|
super(Boolean.class);
|
||||||
this.stringTrue = t;
|
this.stringTrue = t;
|
||||||
this.stringFalse = f;
|
this.stringFalse = f;
|
||||||
this.setAll(
|
this.setAll(
|
||||||
|
@ -10,6 +10,7 @@ public class TypeByte extends TypeAbstractNumber<Byte>
|
|||||||
|
|
||||||
private static TypeByte i = new TypeByte();
|
private static TypeByte i = new TypeByte();
|
||||||
public static TypeByte get() { return i; }
|
public static TypeByte get() { return i; }
|
||||||
|
public TypeByte() { super(Byte.class); }
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// OVERRIDE
|
// OVERRIDE
|
||||||
|
@ -10,6 +10,7 @@ public class TypeDouble extends TypeAbstractNumber<Double>
|
|||||||
|
|
||||||
private static TypeDouble i = new TypeDouble();
|
private static TypeDouble i = new TypeDouble();
|
||||||
public static TypeDouble get() { return i; }
|
public static TypeDouble get() { return i; }
|
||||||
|
public TypeDouble() { super(Double.class); }
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// OVERRIDE
|
// OVERRIDE
|
||||||
|
@ -10,6 +10,7 @@ public class TypeFloat extends TypeAbstractNumber<Float>
|
|||||||
|
|
||||||
private static TypeFloat i = new TypeFloat();
|
private static TypeFloat i = new TypeFloat();
|
||||||
public static TypeFloat get() { return i; }
|
public static TypeFloat get() { return i; }
|
||||||
|
public TypeFloat() { super(Float.class); }
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// OVERRIDE
|
// OVERRIDE
|
||||||
|
@ -10,6 +10,7 @@ public class TypeInteger extends TypeAbstractNumber<Integer>
|
|||||||
|
|
||||||
private static TypeInteger i = new TypeInteger();
|
private static TypeInteger i = new TypeInteger();
|
||||||
public static TypeInteger get() { return i; }
|
public static TypeInteger get() { return i; }
|
||||||
|
public TypeInteger() { super(Integer.class); }
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// OVERRIDE
|
// OVERRIDE
|
||||||
|
@ -10,6 +10,7 @@ public class TypeLong extends TypeAbstractNumber<Long>
|
|||||||
|
|
||||||
private static TypeLong i = new TypeLong();
|
private static TypeLong i = new TypeLong();
|
||||||
public static TypeLong get() { return i; }
|
public static TypeLong get() { return i; }
|
||||||
|
public TypeLong() { super(Long.class); }
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// OVERRIDE
|
// OVERRIDE
|
||||||
|
@ -17,13 +17,18 @@ public class TypeObject<T> extends TypeAbstract<T>
|
|||||||
// INSTANCE & CONSTRUCT
|
// INSTANCE & CONSTRUCT
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
private static TypeObject<Object> i = new TypeObject<Object>();
|
/*private static TypeObject<Object> i = new TypeObject<Object>();
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <T> TypeObject<T> get() { return (TypeObject<T>) i; }
|
public static <T> TypeObject<T> get() { return (TypeObject<T>) i; }*/
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
public static <T> TypeObject<T> get(Class<T> clazz) { return new TypeObject<T>(clazz); }
|
||||||
public static <T> TypeObject<T> get(Class<T> classOfT) { return (TypeObject<T>) i; }
|
|
||||||
|
public TypeObject(Class<T> clazz)
|
||||||
|
{
|
||||||
|
super(clazz);
|
||||||
|
this.setInnerProperties(clazz);
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// OVERRIDE
|
// OVERRIDE
|
||||||
|
@ -10,6 +10,7 @@ public class TypeShort extends TypeAbstractNumber<Short>
|
|||||||
|
|
||||||
private static TypeShort i = new TypeShort();
|
private static TypeShort i = new TypeShort();
|
||||||
public static TypeShort get() { return i; }
|
public static TypeShort get() { return i; }
|
||||||
|
public TypeShort() { super(Short.class); }
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// OVERRIDE
|
// OVERRIDE
|
||||||
|
@ -15,6 +15,7 @@ public class TypeString extends TypeAbstract<String>
|
|||||||
|
|
||||||
private static TypeString i = new TypeString();
|
private static TypeString i = new TypeString();
|
||||||
public static TypeString get() { return i; }
|
public static TypeString get() { return i; }
|
||||||
|
public TypeString() { super(String.class); }
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// OVERRIDE
|
// OVERRIDE
|
||||||
|
@ -17,7 +17,7 @@ public class TypePlayer extends TypeSenderIdAbstract<Player>
|
|||||||
public static TypePlayer get() { return i; }
|
public static TypePlayer get() { return i; }
|
||||||
private TypePlayer()
|
private TypePlayer()
|
||||||
{
|
{
|
||||||
super(SenderIdSourceMixinAllSenderIds.get(), SenderPresence.LOCAL, SenderType.PLAYER);
|
super(Player.class, SenderIdSourceMixinAllSenderIds.get(), SenderPresence.LOCAL, SenderType.PLAYER);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
@ -17,7 +17,7 @@ public class TypeSender extends TypeSenderIdAbstract<CommandSender>
|
|||||||
public static TypeSender get() { return i; }
|
public static TypeSender get() { return i; }
|
||||||
private TypeSender()
|
private TypeSender()
|
||||||
{
|
{
|
||||||
super(SenderIdSourceMixinAllSenderIds.get(), SenderPresence.LOCAL, SenderType.ANY);
|
super(CommandSender.class, SenderIdSourceMixinAllSenderIds.get(), SenderPresence.LOCAL, SenderType.ANY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
@ -20,25 +20,25 @@ public class TypeSenderEntity<T extends SenderEntity<T>> extends TypeSenderIdAbs
|
|||||||
|
|
||||||
private TypeSenderEntity(SenderColl<T> coll, SenderPresence presence, SenderType type)
|
private TypeSenderEntity(SenderColl<T> coll, SenderPresence presence, SenderType type)
|
||||||
{
|
{
|
||||||
super(coll, presence, type);
|
super(SenderEntity.class, coll, presence, type);
|
||||||
this.coll = coll;
|
this.coll = coll;
|
||||||
}
|
}
|
||||||
|
|
||||||
private TypeSenderEntity(SenderColl<T> coll, SenderPresence presence)
|
private TypeSenderEntity(SenderColl<T> coll, SenderPresence presence)
|
||||||
{
|
{
|
||||||
super(coll, presence);
|
super(SenderEntity.class, coll, presence);
|
||||||
this.coll = coll;
|
this.coll = coll;
|
||||||
}
|
}
|
||||||
|
|
||||||
private TypeSenderEntity(SenderColl<T> coll, SenderType type)
|
private TypeSenderEntity(SenderColl<T> coll, SenderType type)
|
||||||
{
|
{
|
||||||
super(coll, type);
|
super(SenderEntity.class, coll, type);
|
||||||
this.coll = coll;
|
this.coll = coll;
|
||||||
}
|
}
|
||||||
|
|
||||||
private TypeSenderEntity(SenderColl<T> coll)
|
private TypeSenderEntity(SenderColl<T> coll)
|
||||||
{
|
{
|
||||||
super(coll);
|
super(SenderEntity.class, coll);
|
||||||
this.coll = coll;
|
this.coll = coll;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,22 +13,22 @@ public class TypeSenderId extends TypeSenderIdAbstract<String>
|
|||||||
|
|
||||||
private TypeSenderId(SenderIdSource source, SenderPresence presence, SenderType type)
|
private TypeSenderId(SenderIdSource source, SenderPresence presence, SenderType type)
|
||||||
{
|
{
|
||||||
super(source, presence, type);
|
super(String.class, source, presence, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
private TypeSenderId(SenderIdSource source, SenderPresence presence)
|
private TypeSenderId(SenderIdSource source, SenderPresence presence)
|
||||||
{
|
{
|
||||||
super(source, presence);
|
super(String.class, source, presence);
|
||||||
}
|
}
|
||||||
|
|
||||||
private TypeSenderId(SenderIdSource source, SenderType type)
|
private TypeSenderId(SenderIdSource source, SenderType type)
|
||||||
{
|
{
|
||||||
super(source, type);
|
super(String.class, source, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
private TypeSenderId(SenderIdSource source)
|
private TypeSenderId(SenderIdSource source)
|
||||||
{
|
{
|
||||||
super(source);
|
super(String.class, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
@ -31,8 +31,9 @@ public abstract class TypeSenderIdAbstract<T> extends TypeAbstract<T>
|
|||||||
// CONSTRUCT
|
// CONSTRUCT
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
public TypeSenderIdAbstract(SenderIdSource source, SenderPresence presence, SenderType type)
|
public TypeSenderIdAbstract(Class<?> clazz, SenderIdSource source, SenderPresence presence, SenderType type)
|
||||||
{
|
{
|
||||||
|
super(clazz);
|
||||||
if (source == null) throw new NullPointerException("source");
|
if (source == null) throw new NullPointerException("source");
|
||||||
if (presence == null) throw new NullPointerException("presence");
|
if (presence == null) throw new NullPointerException("presence");
|
||||||
if (type == null) throw new NullPointerException("type");
|
if (type == null) throw new NullPointerException("type");
|
||||||
@ -42,19 +43,19 @@ public abstract class TypeSenderIdAbstract<T> extends TypeAbstract<T>
|
|||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TypeSenderIdAbstract(SenderIdSource source, SenderPresence presence)
|
public TypeSenderIdAbstract(Class<?> clazz, SenderIdSource source, SenderPresence presence)
|
||||||
{
|
{
|
||||||
this(source, presence, SenderType.ANY);
|
this(clazz, source, presence, SenderType.ANY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TypeSenderIdAbstract(SenderIdSource source, SenderType type)
|
public TypeSenderIdAbstract(Class<?> clazz, SenderIdSource source, SenderType type)
|
||||||
{
|
{
|
||||||
this(source, SenderPresence.ANY, type);
|
this(clazz, source, SenderPresence.ANY, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TypeSenderIdAbstract(SenderIdSource source)
|
public TypeSenderIdAbstract(Class<?> clazz, SenderIdSource source)
|
||||||
{
|
{
|
||||||
this(source, SenderPresence.ANY);
|
this(clazz, source, SenderPresence.ANY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
@ -14,22 +14,22 @@ public class TypeSenderName extends TypeSenderIdAbstract<String>
|
|||||||
|
|
||||||
private TypeSenderName(SenderIdSource source, SenderPresence presence, SenderType type)
|
private TypeSenderName(SenderIdSource source, SenderPresence presence, SenderType type)
|
||||||
{
|
{
|
||||||
super(source, presence, type);
|
super(String.class, source, presence, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
private TypeSenderName(SenderIdSource source, SenderPresence presence)
|
private TypeSenderName(SenderIdSource source, SenderPresence presence)
|
||||||
{
|
{
|
||||||
super(source, presence);
|
super(String.class, source, presence);
|
||||||
}
|
}
|
||||||
|
|
||||||
private TypeSenderName(SenderIdSource source, SenderType type)
|
private TypeSenderName(SenderIdSource source, SenderType type)
|
||||||
{
|
{
|
||||||
super(source, type);
|
super(String.class, source, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
private TypeSenderName(SenderIdSource source)
|
private TypeSenderName(SenderIdSource source)
|
||||||
{
|
{
|
||||||
super(source);
|
super(String.class, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
@ -13,6 +13,7 @@ public class TypeColl extends TypeAbstractChoice<Coll<?>>
|
|||||||
|
|
||||||
private static TypeColl i = new TypeColl();
|
private static TypeColl i = new TypeColl();
|
||||||
public static TypeColl get() { return i; }
|
public static TypeColl get() { return i; }
|
||||||
|
public TypeColl() { super(Coll.class); }
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// OVERRIDE
|
// OVERRIDE
|
||||||
|
@ -19,6 +19,7 @@ public class TypeEntity<T extends Entity<T>> extends TypeAbstractChoice<T>
|
|||||||
|
|
||||||
public TypeEntity(Coll<T> coll)
|
public TypeEntity(Coll<T> coll)
|
||||||
{
|
{
|
||||||
|
super(coll.getEntityClass());
|
||||||
this.coll = coll;
|
this.coll = coll;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,5 +53,11 @@ public class TypeEntity<T extends Entity<T>> extends TypeAbstractChoice<T>
|
|||||||
{
|
{
|
||||||
return this.getColl().getAll();
|
return this.getColl().getAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public T createNewInstance()
|
||||||
|
{
|
||||||
|
return this.getColl().createNewInstance();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,9 +6,15 @@ import static com.massivecraft.massivecore.item.DataItemStack.set;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import org.bukkit.block.banner.Pattern;
|
import org.bukkit.block.banner.Pattern;
|
||||||
|
|
||||||
|
import com.massivecraft.massivecore.command.editor.annotation.EditorMethods;
|
||||||
|
import com.massivecraft.massivecore.command.editor.annotation.EditorType;
|
||||||
|
import com.massivecraft.massivecore.command.type.convert.TypeConverterBannerPatternType;
|
||||||
|
import com.massivecraft.massivecore.command.type.convert.TypeConverterDyeColor;
|
||||||
import com.massivecraft.massivecore.comparator.ComparatorSmart;
|
import com.massivecraft.massivecore.comparator.ComparatorSmart;
|
||||||
import com.massivecraft.massivecore.util.MUtil;
|
import com.massivecraft.massivecore.util.MUtil;
|
||||||
|
|
||||||
|
@EditorMethods(true)
|
||||||
public class DataBannerPattern implements Comparable<DataBannerPattern>
|
public class DataBannerPattern implements Comparable<DataBannerPattern>
|
||||||
{
|
{
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
@ -22,10 +28,12 @@ public class DataBannerPattern implements Comparable<DataBannerPattern>
|
|||||||
// FIELDS
|
// FIELDS
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
@EditorType(TypeConverterBannerPatternType.class)
|
||||||
private String id = null;
|
private String id = null;
|
||||||
public String getId() { return get(this.id, DEFAULT_ID); }
|
public String getId() { return get(this.id, DEFAULT_ID); }
|
||||||
public DataBannerPattern setId(String id) { this.id = set(id, DEFAULT_ID); return this; }
|
public DataBannerPattern setId(String id) { this.id = set(id, DEFAULT_ID); return this; }
|
||||||
|
|
||||||
|
@EditorType(TypeConverterDyeColor.class)
|
||||||
private Integer color = null;
|
private Integer color = null;
|
||||||
public Integer getColor() { return get(this.color, DEFAULT_COLOR); }
|
public Integer getColor() { return get(this.color, DEFAULT_COLOR); }
|
||||||
public DataBannerPattern setColor(Integer color) { this.color = set(color, DEFAULT_ID); return this; }
|
public DataBannerPattern setColor(Integer color) { this.color = set(color, DEFAULT_ID); return this; }
|
||||||
|
@ -1,20 +1,25 @@
|
|||||||
package com.massivecraft.massivecore.item;
|
package com.massivecraft.massivecore.item;
|
||||||
|
|
||||||
|
import static com.massivecraft.massivecore.item.DataItemStack.get;
|
||||||
|
import static com.massivecraft.massivecore.item.DataItemStack.set;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import org.bukkit.FireworkEffect;
|
import org.bukkit.FireworkEffect;
|
||||||
|
|
||||||
import static com.massivecraft.massivecore.item.DataItemStack.get;
|
|
||||||
import static com.massivecraft.massivecore.item.DataItemStack.set;
|
|
||||||
|
|
||||||
import com.massivecraft.massivecore.collections.MassiveListDef;
|
import com.massivecraft.massivecore.collections.MassiveListDef;
|
||||||
|
import com.massivecraft.massivecore.command.editor.annotation.EditorMethods;
|
||||||
|
import com.massivecraft.massivecore.command.editor.annotation.EditorType;
|
||||||
|
import com.massivecraft.massivecore.command.editor.annotation.EditorTypeList;
|
||||||
|
import com.massivecraft.massivecore.command.type.convert.TypeConverterColor;
|
||||||
|
import com.massivecraft.massivecore.command.type.convert.TypeConverterFireworkEffectType;
|
||||||
import com.massivecraft.massivecore.comparator.ComparatorSmart;
|
import com.massivecraft.massivecore.comparator.ComparatorSmart;
|
||||||
import com.massivecraft.massivecore.util.MUtil;
|
import com.massivecraft.massivecore.util.MUtil;
|
||||||
import com.massivecraft.massivecore.xlib.gson.annotations.SerializedName;
|
import com.massivecraft.massivecore.xlib.gson.annotations.SerializedName;
|
||||||
|
|
||||||
|
@EditorMethods(true)
|
||||||
public class DataFireworkEffect implements Comparable<DataFireworkEffect>
|
public class DataFireworkEffect implements Comparable<DataFireworkEffect>
|
||||||
{
|
{
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
@ -41,15 +46,18 @@ public class DataFireworkEffect implements Comparable<DataFireworkEffect>
|
|||||||
public boolean hasTrail() { return get(this.trail, DEFAULT_TRAIL); }
|
public boolean hasTrail() { return get(this.trail, DEFAULT_TRAIL); }
|
||||||
public DataFireworkEffect setTrail(boolean trail) { this.trail = set(trail, DEFAULT_TRAIL); return this; }
|
public DataFireworkEffect setTrail(boolean trail) { this.trail = set(trail, DEFAULT_TRAIL); return this; }
|
||||||
|
|
||||||
|
@EditorTypeList(TypeConverterColor.class)
|
||||||
private MassiveListDef<Integer> colors = null;
|
private MassiveListDef<Integer> colors = null;
|
||||||
public List<Integer> getColors() { return get(this.colors, DEFAULT_COLORS); }
|
public List<Integer> getColors() { return get(this.colors, DEFAULT_COLORS); }
|
||||||
public DataFireworkEffect setColors(List<Integer> colors) { this.colors = set(colors, DEFAULT_COLORS); return this; }
|
public DataFireworkEffect setColors(List<Integer> colors) { this.colors = set(colors, DEFAULT_COLORS); return this; }
|
||||||
|
|
||||||
|
@EditorTypeList(TypeConverterColor.class)
|
||||||
@SerializedName("fade-colors")
|
@SerializedName("fade-colors")
|
||||||
private MassiveListDef<Integer> fadeColors = null;
|
private MassiveListDef<Integer> fadeColors = null;
|
||||||
public List<Integer> getFadeColors() { return get(this.fadeColors, DEFAULT_FADE_COLORS); }
|
public List<Integer> getFadeColors() { return get(this.fadeColors, DEFAULT_FADE_COLORS); }
|
||||||
public DataFireworkEffect setFadeColors(List<Integer> fadeColors) { this.fadeColors = set(fadeColors, DEFAULT_FADE_COLORS); return this; }
|
public DataFireworkEffect setFadeColors(List<Integer> fadeColors) { this.fadeColors = set(fadeColors, DEFAULT_FADE_COLORS); return this; }
|
||||||
|
|
||||||
|
@EditorType(TypeConverterFireworkEffectType.class)
|
||||||
private String type = null;
|
private String type = null;
|
||||||
public String getType() { return get(this.type, DEFAULT_TYPE); }
|
public String getType() { return get(this.type, DEFAULT_TYPE); }
|
||||||
public DataFireworkEffect setType(String type) { this.type = set(type, DEFAULT_TYPE); return this; }
|
public DataFireworkEffect setType(String type) { this.type = set(type, DEFAULT_TYPE); return this; }
|
||||||
|
@ -16,6 +16,18 @@ import com.massivecraft.massivecore.collections.MassiveListDef;
|
|||||||
import com.massivecraft.massivecore.collections.MassiveMap;
|
import com.massivecraft.massivecore.collections.MassiveMap;
|
||||||
import com.massivecraft.massivecore.collections.MassiveTreeMapDef;
|
import com.massivecraft.massivecore.collections.MassiveTreeMapDef;
|
||||||
import com.massivecraft.massivecore.collections.MassiveTreeSetDef;
|
import com.massivecraft.massivecore.collections.MassiveTreeSetDef;
|
||||||
|
import com.massivecraft.massivecore.command.editor.annotation.EditorMethods;
|
||||||
|
import com.massivecraft.massivecore.command.editor.annotation.EditorType;
|
||||||
|
import com.massivecraft.massivecore.command.editor.annotation.EditorTypeList;
|
||||||
|
import com.massivecraft.massivecore.command.editor.annotation.EditorTypeMap;
|
||||||
|
import com.massivecraft.massivecore.command.editor.annotation.EditorTypeSet;
|
||||||
|
import com.massivecraft.massivecore.command.type.TypeMaterialId;
|
||||||
|
import com.massivecraft.massivecore.command.type.convert.TypeConverterColor;
|
||||||
|
import com.massivecraft.massivecore.command.type.convert.TypeConverterDyeColor;
|
||||||
|
import com.massivecraft.massivecore.command.type.convert.TypeConverterEnchant;
|
||||||
|
import com.massivecraft.massivecore.command.type.convert.TypeConverterItemFlag;
|
||||||
|
import com.massivecraft.massivecore.command.type.primitive.TypeInteger;
|
||||||
|
import com.massivecraft.massivecore.command.type.primitive.TypeStringParsed;
|
||||||
import com.massivecraft.massivecore.comparator.ComparatorSmart;
|
import com.massivecraft.massivecore.comparator.ComparatorSmart;
|
||||||
import com.massivecraft.massivecore.util.MUtil;
|
import com.massivecraft.massivecore.util.MUtil;
|
||||||
import com.massivecraft.massivecore.xlib.gson.annotations.SerializedName;
|
import com.massivecraft.massivecore.xlib.gson.annotations.SerializedName;
|
||||||
@ -32,6 +44,7 @@ import com.massivecraft.massivecore.xlib.gson.annotations.SerializedName;
|
|||||||
* It is mainly used by the ItemStackAdapter and InventoryAdapter.
|
* It is mainly used by the ItemStackAdapter and InventoryAdapter.
|
||||||
* It can also be used directly, for example in maps, since it provides a stable equals and hash code method (as opposed to Bukkit).
|
* It can also be used directly, for example in maps, since it provides a stable equals and hash code method (as opposed to Bukkit).
|
||||||
*/
|
*/
|
||||||
|
@EditorMethods(true)
|
||||||
public class DataItemStack implements Comparable<DataItemStack>
|
public class DataItemStack implements Comparable<DataItemStack>
|
||||||
{
|
{
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
@ -72,6 +85,7 @@ public class DataItemStack implements Comparable<DataItemStack>
|
|||||||
// FIELDS > BASIC
|
// FIELDS > BASIC
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
@EditorType(value = TypeMaterialId.class)
|
||||||
private Integer id = null;
|
private Integer id = null;
|
||||||
public int getId() { return get(this.id, DEFAULT_ID); }
|
public int getId() { return get(this.id, DEFAULT_ID); }
|
||||||
public DataItemStack setId(int id) { this.id = set(id, DEFAULT_ID); return this; }
|
public DataItemStack setId(int id) { this.id = set(id, DEFAULT_ID); return this; }
|
||||||
@ -88,10 +102,12 @@ public class DataItemStack implements Comparable<DataItemStack>
|
|||||||
// FIELDS > UNSPECIFIC
|
// FIELDS > UNSPECIFIC
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
@EditorType(TypeStringParsed.class)
|
||||||
private String name = null;
|
private String name = null;
|
||||||
public String getName() { return get(this.name, DEFAULT_NAME); }
|
public String getName() { return get(this.name, DEFAULT_NAME); }
|
||||||
public DataItemStack setName(String name) { this.name = set(name, DEFAULT_NAME); return this; }
|
public DataItemStack setName(String name) { this.name = set(name, DEFAULT_NAME); return this; }
|
||||||
|
|
||||||
|
@EditorTypeList(TypeStringParsed.class)
|
||||||
private MassiveListDef<String> lore = null;
|
private MassiveListDef<String> lore = null;
|
||||||
public List<String> getLore() { return get(this.lore, DEFAULT_LORE); }
|
public List<String> getLore() { return get(this.lore, DEFAULT_LORE); }
|
||||||
public DataItemStack setLore(List<String> lore) { this.lore = set(lore, DEFAULT_LORE); return this; }
|
public DataItemStack setLore(List<String> lore) { this.lore = set(lore, DEFAULT_LORE); return this; }
|
||||||
@ -99,6 +115,7 @@ public class DataItemStack implements Comparable<DataItemStack>
|
|||||||
// The Bukkit ItemMeta#getEnchants() is not sorted by the enchant id.
|
// The Bukkit ItemMeta#getEnchants() is not sorted by the enchant id.
|
||||||
// There may be some sort of custom sorting order, I'm not sure.
|
// There may be some sort of custom sorting order, I'm not sure.
|
||||||
// We are however enforcing sorting by the enchant id ourselves to be sure.
|
// We are however enforcing sorting by the enchant id ourselves to be sure.
|
||||||
|
@EditorTypeMap(typeKey = TypeConverterEnchant.class, typeValue = TypeInteger.class)
|
||||||
private MassiveTreeMapDef<Integer, Integer, ComparatorSmart> enchants = null;
|
private MassiveTreeMapDef<Integer, Integer, ComparatorSmart> enchants = null;
|
||||||
public Map<Integer, Integer> getEnchants() { return get(this.enchants, DEFAULT_ENCHANTS); }
|
public Map<Integer, Integer> getEnchants() { return get(this.enchants, DEFAULT_ENCHANTS); }
|
||||||
public DataItemStack setEnchants(Map<Integer, Integer> enchants) { this.enchants = set(enchants, DEFAULT_ENCHANTS); return this; }
|
public DataItemStack setEnchants(Map<Integer, Integer> enchants) { this.enchants = set(enchants, DEFAULT_ENCHANTS); return this; }
|
||||||
@ -111,6 +128,7 @@ public class DataItemStack implements Comparable<DataItemStack>
|
|||||||
// FIELDS > BOOK
|
// FIELDS > BOOK
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
@EditorType(TypeStringParsed.class)
|
||||||
private String title = null;
|
private String title = null;
|
||||||
public String getTitle() { return get(this.title, DEFAULT_TITLE); }
|
public String getTitle() { return get(this.title, DEFAULT_TITLE); }
|
||||||
public DataItemStack setTitle(String title) { this.title = set(title, DEFAULT_TITLE); return this; }
|
public DataItemStack setTitle(String title) { this.title = set(title, DEFAULT_TITLE); return this; }
|
||||||
@ -119,6 +137,7 @@ public class DataItemStack implements Comparable<DataItemStack>
|
|||||||
public String getAuthor() { return get(this.author, DEFAULT_AUTHOR); }
|
public String getAuthor() { return get(this.author, DEFAULT_AUTHOR); }
|
||||||
public DataItemStack setAuthor(String author) { this.author = set(author, DEFAULT_AUTHOR); return this; }
|
public DataItemStack setAuthor(String author) { this.author = set(author, DEFAULT_AUTHOR); return this; }
|
||||||
|
|
||||||
|
@EditorTypeList(TypeStringParsed.class)
|
||||||
private MassiveListDef<String> pages = null;
|
private MassiveListDef<String> pages = null;
|
||||||
public List<String> getPages() { return get(this.pages, DEFAULT_PAGES); }
|
public List<String> getPages() { return get(this.pages, DEFAULT_PAGES); }
|
||||||
public DataItemStack setPages(Collection<String> pages) { this.pages = set(pages, DEFAULT_PAGES); return this; }
|
public DataItemStack setPages(Collection<String> pages) { this.pages = set(pages, DEFAULT_PAGES); return this; }
|
||||||
@ -127,6 +146,7 @@ public class DataItemStack implements Comparable<DataItemStack>
|
|||||||
// FIELDS > LEATHER ARMOR
|
// FIELDS > LEATHER ARMOR
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
@EditorType(TypeConverterColor.class)
|
||||||
private Integer color = null;
|
private Integer color = null;
|
||||||
public Integer getColor() { return get(this.color, DEFAULT_COLOR); }
|
public Integer getColor() { return get(this.color, DEFAULT_COLOR); }
|
||||||
public DataItemStack setColor(int color) { this.color = set(color, DEFAULT_COLOR); return this; }
|
public DataItemStack setColor(int color) { this.color = set(color, DEFAULT_COLOR); return this; }
|
||||||
@ -186,6 +206,7 @@ public class DataItemStack implements Comparable<DataItemStack>
|
|||||||
// FIELDS > STORED ENCHANTS
|
// FIELDS > STORED ENCHANTS
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
@EditorTypeMap(typeKey = TypeConverterEnchant.class, typeValue = TypeInteger.class)
|
||||||
@SerializedName("stored-enchants")
|
@SerializedName("stored-enchants")
|
||||||
private MassiveTreeMapDef<Integer, Integer, ComparatorSmart> storedEnchants = null;
|
private MassiveTreeMapDef<Integer, Integer, ComparatorSmart> storedEnchants = null;
|
||||||
public Map<Integer, Integer> getStoredEnchants() { return get(this.storedEnchants, DEFAULT_STORED_ENCHANTS); }
|
public Map<Integer, Integer> getStoredEnchants() { return get(this.storedEnchants, DEFAULT_STORED_ENCHANTS); }
|
||||||
@ -205,6 +226,7 @@ public class DataItemStack implements Comparable<DataItemStack>
|
|||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// SINCE: 1.8
|
// SINCE: 1.8
|
||||||
|
|
||||||
|
@EditorTypeSet(TypeConverterItemFlag.class)
|
||||||
private MassiveTreeSetDef<String, ComparatorSmart> flags = null;
|
private MassiveTreeSetDef<String, ComparatorSmart> flags = null;
|
||||||
public Set<String> getFlags() { return get(this.flags, DEFAULT_FLAGS); }
|
public Set<String> getFlags() { return get(this.flags, DEFAULT_FLAGS); }
|
||||||
public DataItemStack setFlags(Set<String> flags) { this.flags = set(flags, DEFAULT_FLAGS); return this; }
|
public DataItemStack setFlags(Set<String> flags) { this.flags = set(flags, DEFAULT_FLAGS); return this; }
|
||||||
@ -216,6 +238,7 @@ public class DataItemStack implements Comparable<DataItemStack>
|
|||||||
// The integer is the dye color byte representation.
|
// The integer is the dye color byte representation.
|
||||||
// Is actually nullable in Bukkit.
|
// Is actually nullable in Bukkit.
|
||||||
|
|
||||||
|
@EditorType(TypeConverterDyeColor.class)
|
||||||
@SerializedName("banner-base")
|
@SerializedName("banner-base")
|
||||||
private Integer bannerBase = null;
|
private Integer bannerBase = null;
|
||||||
public Integer getBannerBase() { return get(this.bannerBase, DEFAULT_BANNER_BASE); }
|
public Integer getBannerBase() { return get(this.bannerBase, DEFAULT_BANNER_BASE); }
|
||||||
|
@ -7,9 +7,14 @@ import java.util.Objects;
|
|||||||
|
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
|
||||||
|
import com.massivecraft.massivecore.command.editor.annotation.EditorMethods;
|
||||||
|
import com.massivecraft.massivecore.command.editor.annotation.EditorType;
|
||||||
|
import com.massivecraft.massivecore.command.type.convert.TypeConverterColor;
|
||||||
|
import com.massivecraft.massivecore.command.type.convert.TypeConverterPotionEffectType;
|
||||||
import com.massivecraft.massivecore.comparator.ComparatorSmart;
|
import com.massivecraft.massivecore.comparator.ComparatorSmart;
|
||||||
import com.massivecraft.massivecore.util.MUtil;
|
import com.massivecraft.massivecore.util.MUtil;
|
||||||
|
|
||||||
|
@EditorMethods(true)
|
||||||
public class DataPotionEffect implements Comparable<DataPotionEffect>
|
public class DataPotionEffect implements Comparable<DataPotionEffect>
|
||||||
{
|
{
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
@ -27,6 +32,7 @@ public class DataPotionEffect implements Comparable<DataPotionEffect>
|
|||||||
// FIELDS
|
// FIELDS
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
@EditorType(value = TypeConverterPotionEffectType.class)
|
||||||
private Integer id = null;
|
private Integer id = null;
|
||||||
public Integer getId() { return get(this.id, DEFAULT_ID); }
|
public Integer getId() { return get(this.id, DEFAULT_ID); }
|
||||||
public DataPotionEffect setId(Integer id) { this.id = set(id, DEFAULT_ID); return this; }
|
public DataPotionEffect setId(Integer id) { this.id = set(id, DEFAULT_ID); return this; }
|
||||||
@ -49,6 +55,7 @@ public class DataPotionEffect implements Comparable<DataPotionEffect>
|
|||||||
public DataPotionEffect setParticles(boolean particles) { this.particles = set(particles, DEFAULT_PARTICLES); return this; }
|
public DataPotionEffect setParticles(boolean particles) { this.particles = set(particles, DEFAULT_PARTICLES); return this; }
|
||||||
|
|
||||||
// SINCE: 1.9
|
// SINCE: 1.9
|
||||||
|
@EditorType(TypeConverterColor.class)
|
||||||
private Integer color = null;
|
private Integer color = null;
|
||||||
public Integer getColor() { return get(this.color, DEFAULT_COLOR); }
|
public Integer getColor() { return get(this.color, DEFAULT_COLOR); }
|
||||||
public DataPotionEffect setColor(Integer color) { this.color = set(color, DEFAULT_COLOR); return this; }
|
public DataPotionEffect setColor(Integer color) { this.color = set(color, DEFAULT_COLOR); return this; }
|
||||||
|
@ -2,8 +2,6 @@ package com.massivecraft.massivecore.item;
|
|||||||
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public abstract class WriterAbstractItemStackField<FA, FB> extends WriterAbstractItemStack<ItemStack, ItemStack, FA, FB>
|
public abstract class WriterAbstractItemStackField<FA, FB> extends WriterAbstractItemStack<ItemStack, ItemStack, FA, FB>
|
||||||
{
|
{
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
@ -1228,6 +1228,18 @@ public class Mson implements Serializable
|
|||||||
return raw;
|
return raw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<String> toPlain(Iterable<Mson> iterable, boolean styled)
|
||||||
|
{
|
||||||
|
List<String> ret = new MassiveList<>();
|
||||||
|
|
||||||
|
for (Mson mson : iterable)
|
||||||
|
{
|
||||||
|
ret.add(mson.toPlain(styled));
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
public String toPlain(boolean styled)
|
public String toPlain(boolean styled)
|
||||||
{
|
{
|
||||||
final StringBuilder ret = new StringBuilder();
|
final StringBuilder ret = new StringBuilder();
|
||||||
|
@ -27,7 +27,7 @@ public class Test
|
|||||||
|
|
||||||
public static Mson mson;
|
public static Mson mson;
|
||||||
public static void test()
|
public static void test()
|
||||||
{
|
{
|
||||||
mson = mson("hello");
|
mson = mson("hello");
|
||||||
test("ofString");
|
test("ofString");
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user