Remoce unused Aspect feature

This commit is contained in:
Magnus Ulf 2019-04-23 10:19:20 +02:00
parent 5cfd609478
commit d8047a4432
17 changed files with 18 additions and 580 deletions

View File

@ -55,7 +55,6 @@ import com.massivecraft.massivecore.engine.EngineMassiveCoreScheduledTeleport;
import com.massivecraft.massivecore.engine.EngineMassiveCoreTeleportMixinCause;
import com.massivecraft.massivecore.engine.EngineMassiveCoreVariable;
import com.massivecraft.massivecore.engine.EngineMassiveCoreWorldNameSet;
import com.massivecraft.massivecore.entity.AspectColl;
import com.massivecraft.massivecore.entity.MassiveCoreMConf;
import com.massivecraft.massivecore.entity.MassiveCoreMConfColl;
import com.massivecraft.massivecore.entity.MultiverseColl;
@ -294,7 +293,6 @@ public class MassiveCore extends MassivePlugin
{
return MUtil.list(
MassiveCoreMConfColl.class,
AspectColl.class,
MultiverseColl.class
);
}

View File

@ -20,6 +20,5 @@ public class CmdMassiveCoreUsys extends MassiveCoreCommand
public CmdMassiveCoreUsysMultiverse cmdMassiveCoreUsysMultiverse = new CmdMassiveCoreUsysMultiverse();
public CmdMassiveCoreUsysUniverse cmdMassiveCoreUsysUniverse = new CmdMassiveCoreUsysUniverse();
public CmdMassiveCoreUsysWorld cmdMassiveCoreUsysWorld = new CmdMassiveCoreUsysWorld();
public CmdMassiveCoreUsysAspect cmdMassiveCoreUsysAspect = new CmdMassiveCoreUsysAspect();
}

View File

@ -1,13 +0,0 @@
package com.massivecraft.massivecore.cmd;
public class CmdMassiveCoreUsysAspect extends MassiveCoreCommand
{
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
public CmdMassiveCoreUsysAspectList cmdMassiveCoreUsysAspectList = new CmdMassiveCoreUsysAspectList();
public CmdMassiveCoreUsysAspectShow cmdMassiveCoreUsysAspectShow = new CmdMassiveCoreUsysAspectShow();
public CmdMassiveCoreUsysAspectUse cmdMassiveCoreUsysAspectUse = new CmdMassiveCoreUsysAspectUse();
}

View File

@ -1,47 +0,0 @@
package com.massivecraft.massivecore.cmd;
import com.massivecraft.massivecore.entity.Aspect;
import com.massivecraft.massivecore.entity.AspectColl;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.command.Parameter;
import com.massivecraft.massivecore.pager.Pager;
import com.massivecraft.massivecore.pager.Stringifier;
import com.massivecraft.massivecore.util.Txt;
public class CmdMassiveCoreUsysAspectList extends MassiveCoreCommand
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdMassiveCoreUsysAspectList()
{
// Parameters
this.addParameter(Parameter.getPage()).setDesc("the page in the aspect list");
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform() throws MassiveException
{
// Args
int page = this.readArg();
// Pager Create
Pager<Aspect> pager = new Pager<>(this, "Aspect List", page, AspectColl.get().getAllRegistered(), new Stringifier<Aspect>()
{
@Override
public String toString(Aspect aspect, int index)
{
return Txt.parse("<h>" + aspect.getId() + " <white>--> <h>" + aspect.getMultiverse().getId());
}
});
// Pager Message
pager.message();
}
}

View File

@ -1,38 +0,0 @@
package com.massivecraft.massivecore.cmd;
import com.massivecraft.massivecore.entity.Aspect;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.command.type.store.TypeAspect;
import com.massivecraft.massivecore.util.Txt;
public class CmdMassiveCoreUsysAspectShow extends MassiveCoreCommand
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdMassiveCoreUsysAspectShow()
{
// Parameters
this.addParameter(TypeAspect.get(), "aspect").setDesc("the aspect to show info about");
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform() throws MassiveException
{
Aspect aspect = this.readArg();
message(Txt.titleize("Aspect: "+aspect.getId()));
msg("<k>using multiverse: <v>%s",aspect.getMultiverse().getId());
for (String descLine : aspect.getDesc())
{
msg(descLine);
}
}
}

View File

@ -1,37 +0,0 @@
package com.massivecraft.massivecore.cmd;
import com.massivecraft.massivecore.entity.Aspect;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.entity.Multiverse;
import com.massivecraft.massivecore.command.type.store.TypeAspect;
import com.massivecraft.massivecore.command.type.store.TypeMultiverse;
public class CmdMassiveCoreUsysAspectUse extends MassiveCoreCommand
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdMassiveCoreUsysAspectUse()
{
// Parameters
this.addParameter(TypeAspect.get(), "aspect").setDesc("the aspect to modify");
this.addParameter(TypeMultiverse.get(), "multiverse").setDesc("the multiverse which the aspect should use");
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform() throws MassiveException
{
Aspect aspect = this.readArg();
Multiverse multiverse = this.readArg();
aspect.setMultiverse(multiverse);
msg("<g>The aspect <h>%s<g> now use multiverse <h>%s<g>.", aspect.getId(), multiverse.getId());
}
}

View File

@ -1,15 +1,11 @@
package com.massivecraft.massivecore.cmd;
import com.massivecraft.massivecore.entity.Aspect;
import com.massivecraft.massivecore.MassiveCore;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.entity.Multiverse;
import com.massivecraft.massivecore.command.type.store.TypeMultiverse;
import com.massivecraft.massivecore.entity.Multiverse;
import com.massivecraft.massivecore.util.Txt;
import java.util.ArrayList;
import java.util.List;
public class CmdMassiveCoreUsysMultiverseShow extends MassiveCoreCommand
{
@ -40,32 +36,7 @@ public class CmdMassiveCoreUsysMultiverseShow extends MassiveCoreCommand
msg("<aqua>"+universe+"<i>: "+Txt.implodeCommaAndDot(multiverse.getWorlds(universe), "<h>%s", "<i>, ", " <i>and ", "<i>."));
}
msg("<aqua>default<i>: for all other worlds.");
msg("");
msg("<i>Aspects using this multiverse:");
this.msgAspects(multiverse.myAspects());
msg("");
msg("<i>Aspects NOT using this multiverse:");
this.msgAspects(multiverse.otherAspects());
}
public void msgAspects(List<Aspect> aspects)
{
List<String> ids = new ArrayList<>();
for (Aspect aspect : aspects)
{
ids.add(aspect.getId());
}
if (ids.size() == 0)
{
msg("<i>*none*");
}
else
{
msg(Txt.implodeCommaAndDot(ids, "<h>%s", "<i>, ", " <i>and ", "<i>."));
}
}
}

View File

@ -47,7 +47,6 @@ import com.massivecraft.massivecore.command.type.primitive.TypeLong;
import com.massivecraft.massivecore.command.type.primitive.TypeString;
import com.massivecraft.massivecore.command.type.sender.TypePlayer;
import com.massivecraft.massivecore.command.type.sender.TypeSender;
import com.massivecraft.massivecore.command.type.store.TypeAspect;
import com.massivecraft.massivecore.command.type.store.TypeMultiverse;
import com.massivecraft.massivecore.util.ReflectionUtil;
@ -337,7 +336,6 @@ public class RegistryType
register(TypeSender.get());
// Store
register(TypeAspect.get());
register(TypeMultiverse.get());
// Collection

View File

@ -1,6 +1,5 @@
package com.massivecraft.massivecore.command.type;
import com.massivecraft.massivecore.entity.Aspect;
import com.massivecraft.massivecore.entity.Multiverse;
import java.util.Collection;
@ -10,24 +9,20 @@ public class TypeUniverse extends TypeAbstractChoice<String>
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
protected Aspect aspect = null;
protected Multiverse multiverse = null;
public Multiverse getMultiverse()
{
if (this.aspect != null) return this.aspect.getMultiverse();
return this.multiverse;
}
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
public static TypeUniverse get(Aspect aspect) { return new TypeUniverse(aspect); }
public static TypeUniverse get(Multiverse multiverse) { return new TypeUniverse(multiverse); }
public TypeUniverse(Aspect aspect) { super(String.class); this.aspect = aspect; }
public TypeUniverse(Multiverse multiverse) { super(String.class); this.multiverse = multiverse; }
// -------------------------------------------- //

View File

@ -1,31 +0,0 @@
package com.massivecraft.massivecore.command.type.store;
import com.massivecraft.massivecore.entity.Aspect;
import com.massivecraft.massivecore.entity.AspectColl;
import com.massivecraft.massivecore.MassiveCorePerm;
import org.bukkit.command.CommandSender;
public class TypeAspect extends TypeEntity<Aspect>
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static TypeAspect i = new TypeAspect();
public static TypeAspect get() { return i; }
public TypeAspect()
{
super(AspectColl.get());
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public boolean canList(CommandSender sender)
{
return MassiveCorePerm.USYS_ASPECT_LIST.has(sender, false);
}
}

View File

@ -1,60 +0,0 @@
package com.massivecraft.massivecore.entity;
import com.google.gson.annotations.SerializedName;
import com.massivecraft.massivecore.MassiveCore;
import com.massivecraft.massivecore.store.Entity;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
public class Aspect extends Entity<Aspect>
{
// -------------------------------------------- //
// META
// -------------------------------------------- //
public static Aspect get(Object oid)
{
return AspectColl.get().get(oid);
}
// -------------------------------------------- //
// TRANSIENT FIELDS
// -------------------------------------------- //
private transient boolean registered = false;
public boolean isRegistered() { return this.registered; }
public void register() { this.registered = true; }
private transient Collection<String> desc = new ArrayList<>();
public Collection<String> getDesc() { return this.desc; }
public void setDesc(Collection<String> val) { this.desc = val; }
public void setDesc(String... val) { this.desc = Arrays.asList(val); }
// -------------------------------------------- //
// STORED FIELDS
// -------------------------------------------- //
@SerializedName("mid")
private String multiverseId;
public String getMultiverseId() { return this.multiverseId; }
public void setMultiverseId(String multiverseId) { this.multiverseId = multiverseId; }
public Multiverse getMultiverse()
{
Multiverse ret = MultiverseColl.get().get(this.multiverseId);
if (ret == null) ret = MultiverseColl.get().get(MassiveCore.DEFAULT);
return ret;
}
public void setMultiverse(Multiverse val) { this.multiverseId = val.getId(); }
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public Aspect()
{
}
}

View File

@ -1,54 +0,0 @@
package com.massivecraft.massivecore.entity;
import com.massivecraft.massivecore.store.Coll;
import java.util.ArrayList;
import java.util.List;
public class AspectColl extends Coll<Aspect>
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static AspectColl i = new AspectColl();
public static AspectColl get() { return i; }
// -------------------------------------------- //
// STACK TRACEABILITY
// -------------------------------------------- //
@Override
public void onTick()
{
super.onTick();
}
// -------------------------------------------- //
// EXTRAS
// -------------------------------------------- //
public List<Aspect> getAllRegistered()
{
List<Aspect> ret = new ArrayList<>();
for (Aspect aspect : this.getAll())
{
if (aspect.isRegistered() == false) continue;
ret.add(aspect);
}
return ret;
}
public List<Aspect> getAllRegisteredForMultiverse(Multiverse multiverse, boolean normal)
{
List<Aspect> ret = new ArrayList<>();
for (Aspect aspect : this.getAll())
{
if (aspect.isRegistered() == false) continue;
if ((aspect.getMultiverse() != multiverse) == normal) continue;
ret.add(aspect);
}
return ret;
}
}

View File

@ -7,7 +7,6 @@ import com.massivecraft.massivecore.util.MUtil;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
@ -40,20 +39,6 @@ public class Multiverse extends Entity<Multiverse>
}
// -------------------------------------------- //
// ASPECTS
// -------------------------------------------- //
public List<Aspect> myAspects()
{
return AspectColl.get().getAllRegisteredForMultiverse(this, true);
}
public List<Aspect> otherAspects()
{
return AspectColl.get().getAllRegisteredForMultiverse(this, false);
}
// -------------------------------------------- //
// UNIVERSE
// -------------------------------------------- //

View File

@ -3,11 +3,10 @@ package com.massivecraft.massivecore.ps;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.annotations.SerializedName;
import com.massivecraft.massivecore.entity.Aspect;
import com.massivecraft.massivecore.MassiveCore;
import com.massivecraft.massivecore.entity.Multiverse;
import com.massivecraft.massivecore.collections.MassiveSet;
import com.massivecraft.massivecore.comparator.ComparatorSmart;
import com.massivecraft.massivecore.entity.Multiverse;
import com.massivecraft.massivecore.util.MUtil;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
@ -851,11 +850,6 @@ public final class PS implements Serializable, Comparable<PS>
return m1.equalsIgnoreCase(m2);
}
public static boolean inSameUniverse(PS one, PS two, Aspect aspect)
{
return inSameUniverse(one, two, aspect.getMultiverse());
}
// -------------------------------------------- //
// GET SETS

View File

@ -1,79 +0,0 @@
package com.massivecraft.massivecore.sender;
import com.massivecraft.massivecore.MassiveCore;
import com.massivecraft.massivecore.util.IdUtil;
import org.bukkit.Bukkit;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissibleBase;
public abstract class BasicCommandSender extends PermissibleBase implements CommandSender
{
public final String name;
public BasicCommandSender(String name, boolean op, boolean opChangeable)
{
super(new BasicServerOperator(name, op, opChangeable));
this.name = name;
}
@Override
public void setOp(boolean value)
{
boolean before = this.isOp();
super.setOp(value);
boolean after = this.isOp();
if (before == after) return;
this.recalculatePermissions();
}
@Override
public String getName()
{
return this.name;
}
@Override
public Server getServer()
{
return Bukkit.getServer();
}
@Override
public void sendMessage(String[] messages)
{
for (String message : messages)
{
this.sendMessage(message);
}
}
public void register()
{
final BasicCommandSender ME = this;
// Register Now
registerImmediately();
// Register Later
Bukkit.getScheduler().scheduleSyncDelayedTask(MassiveCore.get(), new Runnable()
{
@Override
public void run()
{
ME.registerImmediately();
}
});
}
public void registerImmediately()
{
IdUtil.register(this);
}
public void unregister()
{
IdUtil.unregister(this);
}
}

View File

@ -1,143 +0,0 @@
package com.massivecraft.massivecore.store;
import com.massivecraft.massivecore.Active;
import com.massivecraft.massivecore.entity.Aspect;
import com.massivecraft.massivecore.MassivePlugin;
import com.massivecraft.massivecore.entity.Multiverse;
import com.massivecraft.massivecore.util.MUtil;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public abstract class Colls<C extends Coll<E>, E extends Entity<E>> implements Active
{
protected Map<String, C> name2coll = new HashMap<>();
public abstract Aspect getAspect();
public abstract String getBasename();
public abstract C createColl(String name);
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public List<C> getColls()
{
List<C> ret = new ArrayList<>();
Aspect a = this.getAspect();
Multiverse m = a.getMultiverse();
for (String universe : m.getUniverses())
{
ret.add(this.getForUniverse(universe));
}
return ret;
}
// -------------------------------------------- //
// ACTIVE
// -------------------------------------------- //
private boolean active = false;
@Override
public boolean isActive()
{
return this.active;
}
@Override
public void setActive(boolean active)
{
this.active = active;
if (active)
{
this.getColls();
}
else
{
// TODO: Uuuuuh
}
}
private MassivePlugin plugin = null;
@Override
public MassivePlugin setActivePlugin(MassivePlugin plugin)
{
MassivePlugin ret = this.plugin;
this.plugin = plugin;
return ret;
}
@Override
public MassivePlugin getActivePlugin()
{
return this.plugin;
}
@Override
public void setActive(MassivePlugin plugin)
{
this.setActivePlugin(plugin);
this.setActive(plugin != null);
}
// -------------------------------------------- //
// UTIL
// -------------------------------------------- //
public String collnameForUniverse(String universe)
{
return this.getBasename() + "@" + universe;
}
public String universeFromWorldName(String worldName)
{
if (worldName == null) throw new IllegalArgumentException("worldName may not be null.");
return this.getAspect().getMultiverse().getUniverseForWorldName(worldName);
}
// -------------------------------------------- //
// GET
// -------------------------------------------- //
public C getForWorld(String worldName)
{
if (worldName == null) throw new IllegalArgumentException("worldName may not be null.");
return this.getForUniverse(this.universeFromWorldName(worldName));
}
public C getForUniverse(String universe)
{
if (universe == null) throw new IllegalArgumentException("universe may not be null.");
String collname = this.collnameForUniverse(universe);
return this.getForCollname(collname);
}
public C getForCollname(String collname)
{
C ret = this.name2coll.get(collname);
if (ret == null)
{
ret = this.createColl(collname);
this.name2coll.put(collname, ret);
ret.setActivePlugin(this.getActivePlugin());
ret.setActive(true);
}
return ret;
}
public C get(Object worldNameExtractable)
{
if (worldNameExtractable == null) return null;
String worldName = MUtil.extract(String.class, "worldName", worldNameExtractable);
if (worldName == null) return null;
return this.getForWorld(worldName);
}
public E get2(Object worldNameExtractable)
{
C coll = this.get(worldNameExtractable);
if (coll == null) return null;
return coll.get(worldNameExtractable);
}
}

View File

@ -146,19 +146,19 @@ public abstract class EntityContainerAbstract<E extends EntityInternal<E>> imple
@Override public List<E> getAll(Integer limit) { return MUtil.transform(this.getAll(), limit); }
// OLD PREDICATE
@Override public List<E> getAll(Iterable<?> oids, com.massivecraft.massivecore.predicate.Predicate<? super E> where, Comparator<? super E> orderby, Integer limit, Integer offset) { return MUtil.transform(this.getAll(oids), where, orderby, limit, offset); }
@Override public List<E> getAll(Iterable<?> oids, com.massivecraft.massivecore.predicate.Predicate<? super E> where, Comparator<? super E> orderby, Integer limit) { return MUtil.transform(this.getAll(oids), where, orderby, limit); }
@Override public List<E> getAll(Iterable<?> oids, com.massivecraft.massivecore.predicate.Predicate<? super E> where, Comparator<? super E> orderby) { return MUtil.transform(this.getAll(oids), where, orderby); }
@Override public List<E> getAll(Iterable<?> oids, com.massivecraft.massivecore.predicate.Predicate<? super E> where, Integer limit, Integer offset) { return MUtil.transform(this.getAll(oids), where, limit, offset); }
@Override public List<E> getAll(Iterable<?> oids, com.massivecraft.massivecore.predicate.Predicate<? super E> where, Integer limit) { return MUtil.transform(this.getAll(oids), where, limit); }
@Override public List<E> getAll(Iterable<?> oids, com.massivecraft.massivecore.predicate.Predicate<? super E> where) { return MUtil.transform(this.getAll(oids), where); }
@Deprecated @Override public List<E> getAll(Iterable<?> oids, com.massivecraft.massivecore.predicate.Predicate<? super E> where, Comparator<? super E> orderby, Integer limit, Integer offset) { return MUtil.transform(this.getAll(oids), where, orderby, limit, offset); }
@Deprecated @Override public List<E> getAll(Iterable<?> oids, com.massivecraft.massivecore.predicate.Predicate<? super E> where, Comparator<? super E> orderby, Integer limit) { return MUtil.transform(this.getAll(oids), where, orderby, limit); }
@Deprecated @Override public List<E> getAll(Iterable<?> oids, com.massivecraft.massivecore.predicate.Predicate<? super E> where, Comparator<? super E> orderby) { return MUtil.transform(this.getAll(oids), where, orderby); }
@Deprecated @Override public List<E> getAll(Iterable<?> oids, com.massivecraft.massivecore.predicate.Predicate<? super E> where, Integer limit, Integer offset) { return MUtil.transform(this.getAll(oids), where, limit, offset); }
@Deprecated @Override public List<E> getAll(Iterable<?> oids, com.massivecraft.massivecore.predicate.Predicate<? super E> where, Integer limit) { return MUtil.transform(this.getAll(oids), where, limit); }
@Deprecated @Override public List<E> getAll(Iterable<?> oids, com.massivecraft.massivecore.predicate.Predicate<? super E> where) { return MUtil.transform(this.getAll(oids), where); }
@Override public List<E> getAll(com.massivecraft.massivecore.predicate.Predicate<? super E> where, Comparator<? super E> orderby, Integer limit, Integer offset) { return MUtil.transform(this.getAll(), where, orderby, limit, offset); }
@Override public List<E> getAll(com.massivecraft.massivecore.predicate.Predicate<? super E> where, Comparator<? super E> orderby, Integer limit) { return MUtil.transform(this.getAll(), where, orderby, limit); }
@Override public List<E> getAll(com.massivecraft.massivecore.predicate.Predicate<? super E> where, Comparator<? super E> orderby) { return MUtil.transform(this.getAll(), where, orderby); }
@Override public List<E> getAll(com.massivecraft.massivecore.predicate.Predicate<? super E> where, Integer limit, Integer offset) { return MUtil.transform(this.getAll(), where, limit, offset); }
@Override public List<E> getAll(com.massivecraft.massivecore.predicate.Predicate<? super E> where, Integer limit) { return MUtil.transform(this.getAll(), where, limit); }
@Override public List<E> getAll(com.massivecraft.massivecore.predicate.Predicate<? super E> where) { return MUtil.transform(this.getAll(), where); }
@Deprecated @Override public List<E> getAll(com.massivecraft.massivecore.predicate.Predicate<? super E> where, Comparator<? super E> orderby, Integer limit, Integer offset) { return MUtil.transform(this.getAll(), where, orderby, limit, offset); }
@Deprecated @Override public List<E> getAll(com.massivecraft.massivecore.predicate.Predicate<? super E> where, Comparator<? super E> orderby, Integer limit) { return MUtil.transform(this.getAll(), where, orderby, limit); }
@Deprecated @Override public List<E> getAll(com.massivecraft.massivecore.predicate.Predicate<? super E> where, Comparator<? super E> orderby) { return MUtil.transform(this.getAll(), where, orderby); }
@Deprecated @Override public List<E> getAll(com.massivecraft.massivecore.predicate.Predicate<? super E> where, Integer limit, Integer offset) { return MUtil.transform(this.getAll(), where, limit, offset); }
@Deprecated @Override public List<E> getAll(com.massivecraft.massivecore.predicate.Predicate<? super E> where, Integer limit) { return MUtil.transform(this.getAll(), where, limit); }
@Deprecated @Override public List<E> getAll(com.massivecraft.massivecore.predicate.Predicate<? super E> where) { return MUtil.transform(this.getAll(), where); }
// -------------------------------------------- //
// BEHAVIOR