MassiveCore - TypeTransformer innerToOuter sender
This commit is contained in:
parent
63836bf141
commit
21e5fa877c
@ -1,5 +1,6 @@
|
|||||||
package com.massivecraft.massivecore.command.type;
|
package com.massivecraft.massivecore.command.type;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import com.massivecraft.massivecore.command.type.primitive.TypeObject;
|
import com.massivecraft.massivecore.command.type.primitive.TypeObject;
|
||||||
@ -33,7 +34,7 @@ public class TypeDataItemStack extends TypeTransformer<ItemStack, DataItemStack>
|
|||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataItemStack innerToOuter(ItemStack inner)
|
public DataItemStack innerToOuter(ItemStack inner, CommandSender sender)
|
||||||
{
|
{
|
||||||
return DataItemStack.fromBukkit(inner);
|
return DataItemStack.fromBukkit(inner);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.massivecraft.massivecore.command.type;
|
package com.massivecraft.massivecore.command.type;
|
||||||
|
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
import com.massivecraft.massivecore.MassiveException;
|
||||||
import com.massivecraft.massivecore.command.type.enumeration.TypeSound;
|
import com.massivecraft.massivecore.command.type.enumeration.TypeSound;
|
||||||
@ -27,7 +28,7 @@ public class TypeId<T> extends TypeTransformer<T, String>
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String innerToOuter(T inner)
|
public String innerToOuter(T inner, CommandSender sender)
|
||||||
{
|
{
|
||||||
if (inner == null) return null;
|
if (inner == null) return null;
|
||||||
return INNER.getId(inner);
|
return INNER.getId(inner);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.massivecraft.massivecore.command.type;
|
package com.massivecraft.massivecore.command.type;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import com.massivecraft.massivecore.command.type.enumeration.TypeMaterial;
|
import com.massivecraft.massivecore.command.type.enumeration.TypeMaterial;
|
||||||
import com.massivecraft.massivecore.command.type.primitive.TypeInteger;
|
import com.massivecraft.massivecore.command.type.primitive.TypeInteger;
|
||||||
@ -26,7 +27,7 @@ public class TypeMaterialId extends TypeTransformer<Material, Integer>
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer innerToOuter(Material inner)
|
public Integer innerToOuter(Material inner, CommandSender sender)
|
||||||
{
|
{
|
||||||
if (inner == null) return null;
|
if (inner == null) return null;
|
||||||
return inner.getId();
|
return inner.getId();
|
||||||
|
@ -77,7 +77,7 @@ public abstract class TypeTransformer<I, O> extends TypeAbstract<O>
|
|||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// NOTE: These should return null on null input.
|
// NOTE: These should return null on null input.
|
||||||
|
|
||||||
public abstract O innerToOuter(I inner);
|
public abstract O innerToOuter(I inner, CommandSender sender) throws MassiveException;
|
||||||
public abstract I outerToInner(O outer);
|
public abstract I outerToInner(O outer);
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
@ -268,7 +268,7 @@ public abstract class TypeTransformer<I, O> extends TypeAbstract<O>
|
|||||||
public O read(String arg, CommandSender sender) throws MassiveException
|
public O read(String arg, CommandSender sender) throws MassiveException
|
||||||
{
|
{
|
||||||
I inner = INNER.read(arg, sender);
|
I inner = INNER.read(arg, sender);
|
||||||
O outer = innerToOuter(inner);
|
O outer = innerToOuter(inner, sender);
|
||||||
return outer;
|
return outer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package com.massivecraft.massivecore.command.type.convert;
|
package com.massivecraft.massivecore.command.type.convert;
|
||||||
|
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import com.massivecraft.massivecore.command.type.Type;
|
import com.massivecraft.massivecore.command.type.Type;
|
||||||
import com.massivecraft.massivecore.command.type.TypeTransformer;
|
import com.massivecraft.massivecore.command.type.TypeTransformer;
|
||||||
import com.massivecraft.massivecore.item.Converter;
|
import com.massivecraft.massivecore.item.Converter;
|
||||||
@ -34,7 +36,7 @@ public class TypeConverter<A, B> extends TypeTransformer<A, B>
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public B innerToOuter(A inner)
|
public B innerToOuter(A inner, CommandSender sender)
|
||||||
{
|
{
|
||||||
return this.getA2b().convert(inner);
|
return this.getA2b().convert(inner);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.massivecraft.massivecore.command.type.sender;
|
package com.massivecraft.massivecore.command.type.sender;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import com.massivecraft.massivecore.command.type.TypeTransformer;
|
import com.massivecraft.massivecore.command.type.TypeTransformer;
|
||||||
import com.massivecraft.massivecore.command.type.primitive.TypeStringId;
|
import com.massivecraft.massivecore.command.type.primitive.TypeStringId;
|
||||||
import com.massivecraft.massivecore.store.SenderEntity;
|
import com.massivecraft.massivecore.store.SenderEntity;
|
||||||
@ -20,7 +22,7 @@ public class TypeSenderEntityId<I extends SenderEntity<I>> extends TypeTransform
|
|||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String innerToOuter(I inner)
|
public String innerToOuter(I inner, CommandSender sender)
|
||||||
{
|
{
|
||||||
if (inner == null) return null;
|
if (inner == null) return null;
|
||||||
return inner.getId();
|
return inner.getId();
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.massivecraft.massivecore.command.type.store;
|
package com.massivecraft.massivecore.command.type.store;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import com.massivecraft.massivecore.command.type.TypeTransformer;
|
import com.massivecraft.massivecore.command.type.TypeTransformer;
|
||||||
import com.massivecraft.massivecore.command.type.primitive.TypeStringId;
|
import com.massivecraft.massivecore.command.type.primitive.TypeStringId;
|
||||||
import com.massivecraft.massivecore.store.Entity;
|
import com.massivecraft.massivecore.store.Entity;
|
||||||
@ -20,7 +22,7 @@ public class TypeEntityId<I extends Entity<I>> extends TypeTransformer<I, String
|
|||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String innerToOuter(I inner)
|
public String innerToOuter(I inner, CommandSender sender)
|
||||||
{
|
{
|
||||||
if (inner == null) return null;
|
if (inner == null) return null;
|
||||||
return inner.getId();
|
return inner.getId();
|
||||||
|
37
src/com/massivecraft/massivecore/predicate/PredicateNot.java
Normal file
37
src/com/massivecraft/massivecore/predicate/PredicateNot.java
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
package com.massivecraft.massivecore.predicate;
|
||||||
|
|
||||||
|
public class PredicateNot<T> implements Predicate<T>
|
||||||
|
{
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// INSTANCE
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
public static <T> PredicateNot<T> get(Predicate<? super T> predicate) { return new PredicateNot<T>(predicate); }
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// CONSTRUCT
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
public PredicateNot(Predicate<? super T> predicate)
|
||||||
|
{
|
||||||
|
this.predicate = predicate;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// FIELDS
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
private final Predicate<? super T> predicate;
|
||||||
|
public Predicate<? super T> getPredicate() { return this.predicate; }
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// OVERRIDE
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(T type)
|
||||||
|
{
|
||||||
|
return !this.getPredicate().apply(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user