Use a field for editor used requirements. Check source object for editor NoChange. Remove unused imports. Fix indentation.
This commit is contained in:
parent
422ceed9ad
commit
54f1c3ea4f
@ -13,6 +13,7 @@ import com.massivecraft.massivecore.command.requirement.RequirementEditorUse;
|
||||
import com.massivecraft.massivecore.command.type.Type;
|
||||
import com.massivecraft.massivecore.event.EventMassiveCoreEditorEdit;
|
||||
import com.massivecraft.massivecore.mson.Mson;
|
||||
import com.massivecraft.massivecore.util.MUtil;
|
||||
import com.massivecraft.massivecore.util.Txt;
|
||||
|
||||
public class CommandEditAbstract<O, V> extends MassiveCommand
|
||||
@ -110,11 +111,13 @@ public class CommandEditAbstract<O, V> extends MassiveCommand
|
||||
|
||||
// NoChange
|
||||
// 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());
|
||||
return;
|
||||
}
|
||||
|
||||
this.attemptSetPerform(after);
|
||||
}
|
||||
|
||||
@ -126,7 +129,7 @@ public class CommandEditAbstract<O, V> extends MassiveCommand
|
||||
this.getObjectVisual(),
|
||||
" already: ",
|
||||
this.getInheritedVisual()
|
||||
).color(ChatColor.GRAY);
|
||||
).color(ChatColor.GRAY);
|
||||
}
|
||||
|
||||
protected void attemptSetPerform(V after)
|
||||
@ -143,7 +146,7 @@ public class CommandEditAbstract<O, V> extends MassiveCommand
|
||||
messages.add(mson(
|
||||
mson("Before: ").color(ChatColor.AQUA),
|
||||
descValue
|
||||
));
|
||||
));
|
||||
|
||||
// Apply
|
||||
// We set the new property value.
|
||||
@ -155,7 +158,7 @@ public class CommandEditAbstract<O, V> extends MassiveCommand
|
||||
messages.add(mson(
|
||||
mson("After: ").color(ChatColor.AQUA),
|
||||
descValue
|
||||
));
|
||||
));
|
||||
|
||||
// Startup
|
||||
// We inform what property and object the edit is taking place on.
|
||||
@ -166,7 +169,7 @@ public class CommandEditAbstract<O, V> extends MassiveCommand
|
||||
" for ",
|
||||
descObject,
|
||||
" edited:"
|
||||
).color(ChatColor.GRAY));
|
||||
).color(ChatColor.GRAY));
|
||||
|
||||
message(messages);
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
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.Set;
|
||||
|
||||
@ -43,6 +45,13 @@ public class EditSettings<O>
|
||||
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
|
||||
// -------------------------------------------- //
|
||||
@ -81,15 +90,6 @@ public class EditSettings<O>
|
||||
return new CommandEditUsed<O>(this);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// PERMISSONS
|
||||
// -------------------------------------------- //
|
||||
|
||||
public List<Requirement> getUsedRequirements()
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// TYPE READ UTILITY
|
||||
// -------------------------------------------- //
|
||||
|
@ -13,7 +13,6 @@ import org.bukkit.command.CommandSender;
|
||||
import com.massivecraft.massivecore.Named;
|
||||
import com.massivecraft.massivecore.collections.MassiveList;
|
||||
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.mson.Mson;
|
||||
import com.massivecraft.massivecore.store.Entity;
|
||||
|
@ -21,13 +21,11 @@ public class TypeSenderId extends TypeSenderIdAbstract<String>
|
||||
super(source, presence);
|
||||
}
|
||||
|
||||
|
||||
private TypeSenderId(SenderIdSource source, SenderType type)
|
||||
{
|
||||
super(source, type);
|
||||
}
|
||||
|
||||
|
||||
private TypeSenderId(SenderIdSource source)
|
||||
{
|
||||
super(source);
|
||||
|
@ -22,13 +22,11 @@ public class TypeSenderName extends TypeSenderIdAbstract<String>
|
||||
super(source, presence);
|
||||
}
|
||||
|
||||
|
||||
private TypeSenderName(SenderIdSource source, SenderType type)
|
||||
{
|
||||
super(source, type);
|
||||
}
|
||||
|
||||
|
||||
private TypeSenderName(SenderIdSource source)
|
||||
{
|
||||
super(source);
|
||||
|
Loading…
Reference in New Issue
Block a user