MassiveCore - TypeTransformer innerToOuter sender

This commit is contained in:
Olof Larsson 2016-08-16 11:54:17 +02:00
parent 63836bf141
commit 21e5fa877c
No known key found for this signature in database
GPG Key ID: BBEF14F97DA52474
8 changed files with 54 additions and 8 deletions

View File

@ -1,5 +1,6 @@
package com.massivecraft.massivecore.command.type;
import org.bukkit.command.CommandSender;
import org.bukkit.inventory.ItemStack;
import com.massivecraft.massivecore.command.type.primitive.TypeObject;
@ -33,7 +34,7 @@ public class TypeDataItemStack extends TypeTransformer<ItemStack, DataItemStack>
// -------------------------------------------- //
@Override
public DataItemStack innerToOuter(ItemStack inner)
public DataItemStack innerToOuter(ItemStack inner, CommandSender sender)
{
return DataItemStack.fromBukkit(inner);
}

View File

@ -1,6 +1,7 @@
package com.massivecraft.massivecore.command.type;
import org.bukkit.Sound;
import org.bukkit.command.CommandSender;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.command.type.enumeration.TypeSound;
@ -27,7 +28,7 @@ public class TypeId<T> extends TypeTransformer<T, String>
@Override
public String innerToOuter(T inner)
public String innerToOuter(T inner, CommandSender sender)
{
if (inner == null) return null;
return INNER.getId(inner);

View File

@ -1,6 +1,7 @@
package com.massivecraft.massivecore.command.type;
import org.bukkit.Material;
import org.bukkit.command.CommandSender;
import com.massivecraft.massivecore.command.type.enumeration.TypeMaterial;
import com.massivecraft.massivecore.command.type.primitive.TypeInteger;
@ -26,7 +27,7 @@ public class TypeMaterialId extends TypeTransformer<Material, Integer>
@Override
public Integer innerToOuter(Material inner)
public Integer innerToOuter(Material inner, CommandSender sender)
{
if (inner == null) return null;
return inner.getId();

View File

@ -77,7 +77,7 @@ public abstract class TypeTransformer<I, O> extends TypeAbstract<O>
// -------------------------------------------- //
// 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);
// -------------------------------------------- //
@ -268,7 +268,7 @@ public abstract class TypeTransformer<I, O> extends TypeAbstract<O>
public O read(String arg, CommandSender sender) throws MassiveException
{
I inner = INNER.read(arg, sender);
O outer = innerToOuter(inner);
O outer = innerToOuter(inner, sender);
return outer;
}

View File

@ -1,6 +1,8 @@
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.TypeTransformer;
import com.massivecraft.massivecore.item.Converter;
@ -34,7 +36,7 @@ public class TypeConverter<A, B> extends TypeTransformer<A, B>
@Override
public B innerToOuter(A inner)
public B innerToOuter(A inner, CommandSender sender)
{
return this.getA2b().convert(inner);
}

View File

@ -1,5 +1,7 @@
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.primitive.TypeStringId;
import com.massivecraft.massivecore.store.SenderEntity;
@ -20,7 +22,7 @@ public class TypeSenderEntityId<I extends SenderEntity<I>> extends TypeTransform
// -------------------------------------------- //
@Override
public String innerToOuter(I inner)
public String innerToOuter(I inner, CommandSender sender)
{
if (inner == null) return null;
return inner.getId();

View File

@ -1,5 +1,7 @@
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.primitive.TypeStringId;
import com.massivecraft.massivecore.store.Entity;
@ -20,7 +22,7 @@ public class TypeEntityId<I extends Entity<I>> extends TypeTransformer<I, String
// -------------------------------------------- //
@Override
public String innerToOuter(I inner)
public String innerToOuter(I inner, CommandSender sender)
{
if (inner == null) return null;
return inner.getId();

View 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);
}
}