Use a field for editor used requirements. Check source object for editor NoChange. Remove unused imports. Fix indentation.

This commit is contained in:
Olof Larsson 2016-04-13 11:47:49 +02:00
parent 422ceed9ad
commit 54f1c3ea4f
No known key found for this signature in database
GPG Key ID: BBEF14F97DA52474
5 changed files with 18 additions and 20 deletions

View File

@ -13,6 +13,7 @@ import com.massivecraft.massivecore.command.requirement.RequirementEditorUse;
import com.massivecraft.massivecore.command.type.Type; import com.massivecraft.massivecore.command.type.Type;
import com.massivecraft.massivecore.event.EventMassiveCoreEditorEdit; import com.massivecraft.massivecore.event.EventMassiveCoreEditorEdit;
import com.massivecraft.massivecore.mson.Mson; import com.massivecraft.massivecore.mson.Mson;
import com.massivecraft.massivecore.util.MUtil;
import com.massivecraft.massivecore.util.Txt; import com.massivecraft.massivecore.util.Txt;
public class CommandEditAbstract<O, V> extends MassiveCommand public class CommandEditAbstract<O, V> extends MassiveCommand
@ -110,11 +111,13 @@ public class CommandEditAbstract<O, V> extends MassiveCommand
// NoChange // NoChange
// We check, inform and cancel on equality. // We check, inform and cancel on equality.
if (this.getValueType().equals(before, after)) // For this to count the source must be the object itself.
if (MUtil.equals(this.getObject(), source) && this.getValueType().equals(before, after))
{ {
message(this.attemptSetNochangeMessage()); message(this.attemptSetNochangeMessage());
return; return;
} }
this.attemptSetPerform(after); this.attemptSetPerform(after);
} }
@ -126,7 +129,7 @@ public class CommandEditAbstract<O, V> extends MassiveCommand
this.getObjectVisual(), this.getObjectVisual(),
" already: ", " already: ",
this.getInheritedVisual() this.getInheritedVisual()
).color(ChatColor.GRAY); ).color(ChatColor.GRAY);
} }
protected void attemptSetPerform(V after) protected void attemptSetPerform(V after)
@ -143,7 +146,7 @@ public class CommandEditAbstract<O, V> extends MassiveCommand
messages.add(mson( messages.add(mson(
mson("Before: ").color(ChatColor.AQUA), mson("Before: ").color(ChatColor.AQUA),
descValue descValue
)); ));
// Apply // Apply
// We set the new property value. // We set the new property value.
@ -155,7 +158,7 @@ public class CommandEditAbstract<O, V> extends MassiveCommand
messages.add(mson( messages.add(mson(
mson("After: ").color(ChatColor.AQUA), mson("After: ").color(ChatColor.AQUA),
descValue descValue
)); ));
// Startup // Startup
// We inform what property and object the edit is taking place on. // We inform what property and object the edit is taking place on.
@ -166,7 +169,7 @@ public class CommandEditAbstract<O, V> extends MassiveCommand
" for ", " for ",
descObject, descObject,
" edited:" " edited:"
).color(ChatColor.GRAY)); ).color(ChatColor.GRAY));
message(messages); message(messages);
} }

View File

@ -1,6 +1,8 @@
package com.massivecraft.massivecore.command.editor; package com.massivecraft.massivecore.command.editor;
import java.util.Collections; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@ -43,6 +45,13 @@ public class EditSettings<O>
return new EditSettings<CommandSender>(TypeSender.get(), new PropertyThis<CommandSender>(TypeSender.get())); return new EditSettings<CommandSender>(TypeSender.get(), new PropertyThis<CommandSender>(TypeSender.get()));
} }
// The requirements to edit used object.
private List<Requirement> usedRequirements = new ArrayList<Requirement>();
public List<Requirement> getUsedRequirements() { return this.usedRequirements; }
public void setUsedRequirements(List<Requirement> requirements) { this.usedRequirements = requirements; }
public void addUsedRequirements(Collection<Requirement> requirements) { this.usedRequirements.addAll(requirements); }
public void addUsedRequirements(Requirement... requirements) { this.addUsedRequirements(Arrays.asList(requirements)); }
// -------------------------------------------- // // -------------------------------------------- //
// INSTANCE & CONSTRUCT // INSTANCE & CONSTRUCT
// -------------------------------------------- // // -------------------------------------------- //
@ -81,15 +90,6 @@ public class EditSettings<O>
return new CommandEditUsed<O>(this); return new CommandEditUsed<O>(this);
} }
// -------------------------------------------- //
// PERMISSONS
// -------------------------------------------- //
public List<Requirement> getUsedRequirements()
{
return Collections.emptyList();
}
// -------------------------------------------- // // -------------------------------------------- //
// TYPE READ UTILITY // TYPE READ UTILITY
// -------------------------------------------- // // -------------------------------------------- //

View File

@ -13,7 +13,6 @@ import org.bukkit.command.CommandSender;
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.requirement.Requirement; import com.massivecraft.massivecore.command.requirement.Requirement;
import com.massivecraft.massivecore.command.requirement.RequirementAbstract;
import com.massivecraft.massivecore.command.type.Type; 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;

View File

@ -21,13 +21,11 @@ public class TypeSenderId extends TypeSenderIdAbstract<String>
super(source, presence); super(source, presence);
} }
private TypeSenderId(SenderIdSource source, SenderType type) private TypeSenderId(SenderIdSource source, SenderType type)
{ {
super(source, type); super(source, type);
} }
private TypeSenderId(SenderIdSource source) private TypeSenderId(SenderIdSource source)
{ {
super(source); super(source);

View File

@ -22,13 +22,11 @@ public class TypeSenderName extends TypeSenderIdAbstract<String>
super(source, presence); super(source, presence);
} }
private TypeSenderName(SenderIdSource source, SenderType type) private TypeSenderName(SenderIdSource source, SenderType type)
{ {
super(source, type); super(source, type);
} }
private TypeSenderName(SenderIdSource source) private TypeSenderName(SenderIdSource source)
{ {
super(source); super(source);