The entity class may now decide when it's default

This commit is contained in:
Olof Larsson 2013-03-06 14:50:38 +01:00
parent 941478c574
commit 8c5c35c725
4 changed files with 54 additions and 1 deletions

View File

@ -6,6 +6,7 @@ public class Lang
public static final String permDoThat = "do that";
public static final String commandSenderMustBePlayer = "<b>This command can only be used by ingame players.";
public static final String commandSenderMusntBePlayer = "<b>This command can not be used by ingame players.";
public static final String commandToFewArgs = "<b>To few arguments. <i>Use like this:";
public static final String commandToManyArgs = "<b>Strange arguments %s<b>.";
public static final String commandToManyArgs2 = "<i>Use the command like this:";

View File

@ -0,0 +1,36 @@
package com.massivecraft.mcore.cmd.req;
import org.bukkit.command.CommandSender;
import com.massivecraft.mcore.Lang;
import com.massivecraft.mcore.cmd.MCommand;
import com.massivecraft.mcore.util.SenderUtil;
public class ReqIsntPlayer extends ReqAbstract
{
private static final long serialVersionUID = 1L;
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static ReqIsntPlayer i = new ReqIsntPlayer();
public static ReqIsntPlayer get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public boolean apply(CommandSender sender, MCommand command)
{
return !SenderUtil.isPlayer(sender);
}
@Override
public String createErrorMessage(CommandSender sender, MCommand command)
{
return Lang.commandSenderMusntBePlayer;
}
}

View File

@ -133,7 +133,18 @@ public class Coll<E, L extends Comparable<? super L>> implements CollInterface<E
// Should that instance be saved or not?
// If it is default it should not be saved.
@Override public boolean isDefault(E entity) { return false; }
@SuppressWarnings("rawtypes")
@Override public boolean isDefault(E entity)
{
if (entity instanceof Entity)
{
return ((Entity)entity).isDefault();
}
else
{
return false;
}
}
// -------------------------------------------- //
// COPY AND CREATE

View File

@ -102,6 +102,11 @@ public abstract class Entity<E extends Entity<E, L>, L extends Comparable<? supe
return (E) this;
}
public boolean isDefault()
{
return false;
}
@Override
public int compareTo(E that)
{