Removing the usel system.
This commit is contained in:
parent
682e6513a4
commit
4d613e3b45
@ -14,7 +14,6 @@ import com.massivecraft.mcore4.persist.Persist;
|
||||
import com.massivecraft.mcore4.store.Coll;
|
||||
import com.massivecraft.mcore4.store.Db;
|
||||
import com.massivecraft.mcore4.store.MStore;
|
||||
import com.massivecraft.mcore4.store.USelColl;
|
||||
import com.massivecraft.mcore4.usys.AspectColl;
|
||||
import com.massivecraft.mcore4.usys.MultiverseColl;
|
||||
import com.massivecraft.mcore4.usys.cmd.CmdUsys;
|
||||
@ -100,7 +99,6 @@ public class MCore extends MPlugin
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, this.collTickTask, 1, 1);
|
||||
|
||||
// Init internal collections
|
||||
USelColl.i.init(); // TODO: Remove and deprecate!? possibly yes... how soon?
|
||||
MultiverseColl.i.init();
|
||||
AspectColl.i.init();
|
||||
|
||||
|
@ -1,93 +0,0 @@
|
||||
package com.massivecraft.mcore4.store;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import com.massivecraft.mcore4.util.MUtil;
|
||||
|
||||
/**
|
||||
* USel stands for "Universe Selector".
|
||||
* The task of a USel is to select a "universe" based on a world.
|
||||
* There will be one USel per "context".
|
||||
*/
|
||||
public class USel extends Entity<USel, String>
|
||||
{
|
||||
public final static transient String RETURN = "_return";
|
||||
public final static transient String RUN = "_run";
|
||||
public final static transient String _DEFAULT = "_default";
|
||||
public final static transient String DEFAULT = "default";
|
||||
public final static transient List<USelRule> DEFAULT_RULES = MUtil.list(new USelRule(RUN, _DEFAULT));
|
||||
public final static transient List<USelRule> DEFAULT_DEFAULT_RULES = MUtil.list(new USelRule(RETURN, DEFAULT));
|
||||
|
||||
// -------------------------------------------- //
|
||||
// META
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override protected USel getThis() { return this; }
|
||||
|
||||
private final static transient USel defaultInstance = new USel();
|
||||
@Override public USel getDefaultInstance(){ return defaultInstance; }
|
||||
@Override protected Class<USel> getClazz() { return USel.class; }
|
||||
|
||||
|
||||
// -------------------------------------------- //
|
||||
// FIELDS
|
||||
// -------------------------------------------- //
|
||||
|
||||
protected List<USelRule> rules;
|
||||
public List<USelRule> rules() { return this.rules; };
|
||||
public void rules(List<USelRule> val) { this.rules = new ArrayList<USelRule>(val); };
|
||||
public void rules(String... namesAndParams)
|
||||
{
|
||||
this.rules = new ArrayList<USelRule>();
|
||||
Iterator<String> iter = Arrays.asList(namesAndParams).iterator();
|
||||
while (iter.hasNext())
|
||||
{
|
||||
String name = iter.next();
|
||||
String param = iter.next();
|
||||
this.rules.add(new USelRule(name, param));
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public USel()
|
||||
{
|
||||
this.rules(DEFAULT_RULES);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// THAT SPECIAL LOGIC
|
||||
// -------------------------------------------- //
|
||||
|
||||
public String select(String worldName)
|
||||
{
|
||||
if (worldName == null) return null;
|
||||
for (USelRule rule : this.rules())
|
||||
{
|
||||
String name = rule.name();
|
||||
String param = rule.param();
|
||||
if (name.equals(RETURN))
|
||||
{
|
||||
return param;
|
||||
}
|
||||
else if (name.equals(RUN))
|
||||
{
|
||||
USel subSelector = USelColl.i.get(param);
|
||||
String subSelectorResult = subSelector.select(worldName);
|
||||
if (subSelectorResult != null) return subSelectorResult;
|
||||
}
|
||||
else if (name.equalsIgnoreCase(worldName))
|
||||
{
|
||||
return param;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
package com.massivecraft.mcore4.store;
|
||||
|
||||
import com.massivecraft.mcore4.MCore;
|
||||
|
||||
public class USelColl extends Coll<USel, String>
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// META
|
||||
// -------------------------------------------- //
|
||||
public static USelColl i = new USelColl();
|
||||
|
||||
private USelColl()
|
||||
{
|
||||
super(MCore.p, "ai", "mcore_usel", USel.class, String.class, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(Object ofrom, Object oto)
|
||||
{
|
||||
USel from = (USel)ofrom;
|
||||
USel to = (USel)oto;
|
||||
to.rules = from.rules;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
|
||||
// Ensure the default WorldCategorizer is present.
|
||||
if ( ! this.ids().contains(USel._DEFAULT))
|
||||
{
|
||||
USel d = this.get(USel._DEFAULT);
|
||||
d.rules(USel.DEFAULT_DEFAULT_RULES);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDefault(USel entity)
|
||||
{
|
||||
return entity.rules().equals(USel.DEFAULT_RULES);
|
||||
}
|
||||
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
package com.massivecraft.mcore4.store;
|
||||
|
||||
public class USelRule
|
||||
{
|
||||
protected final String name;
|
||||
public String name() { return this.name; }
|
||||
|
||||
protected final String param;
|
||||
public String param() { return this.param; }
|
||||
|
||||
public USelRule()
|
||||
{
|
||||
this.name = null;
|
||||
this.param = null;
|
||||
}
|
||||
|
||||
public USelRule(String name, String param)
|
||||
{
|
||||
this.name = name;
|
||||
this.param = param;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user