Add an intermediate Colls class for that shared universe-get logic.
This commit is contained in:
37
src/com/massivecraft/factions/entity/XColls.java
Normal file
37
src/com/massivecraft/factions/entity/XColls.java
Normal file
@ -0,0 +1,37 @@
|
||||
package com.massivecraft.factions.entity;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import com.massivecraft.mcore.store.Coll;
|
||||
import com.massivecraft.mcore.store.Colls;
|
||||
import com.massivecraft.mcore.store.Entity;
|
||||
import com.massivecraft.mcore.util.MUtil;
|
||||
import com.massivecraft.mcore.util.SenderUtil;
|
||||
|
||||
public abstract class XColls<C extends Coll<E>, E> extends Colls<C, E>
|
||||
{
|
||||
@Override
|
||||
public C get(Object o)
|
||||
{
|
||||
if (o == null) return null;
|
||||
|
||||
if (o instanceof Entity)
|
||||
{
|
||||
return this.getForUniverse(((Entity<?>)o).getUniverse());
|
||||
}
|
||||
|
||||
if (o instanceof Coll)
|
||||
{
|
||||
return this.getForUniverse(((Coll<?>)o).getUniverse());
|
||||
}
|
||||
|
||||
if (SenderUtil.isNonplayer(o))
|
||||
{
|
||||
return this.getForWorld(Bukkit.getWorlds().get(0).getName());
|
||||
}
|
||||
|
||||
String worldName = MUtil.extract(String.class, "worldName", o);
|
||||
if (worldName == null) return null;
|
||||
return this.getForWorld(worldName);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user