otherwise system is ready to go.daily_nerf
parent
7cc2b9a7e2
commit
49325dedc1
Binary file not shown.
@ -0,0 +1,33 @@ |
||||
package sig.plugin.TwosideKeeper.HelperStructures; |
||||
|
||||
import org.bukkit.Location; |
||||
import org.bukkit.entity.ArmorStand; |
||||
import org.bukkit.entity.EntityType; |
||||
|
||||
import sig.plugin.TwosideKeeper.HelperStructures.Common.ArmorStandProperties; |
||||
import sig.plugin.TwosideKeeper.HelperStructures.Utils.EntityUtils; |
||||
|
||||
public class ArmorStandLinker { |
||||
ArmorStandProperties myModel; |
||||
ArmorStand ent; |
||||
Location loc; |
||||
|
||||
public ArmorStandLinker(Location loc) { |
||||
ent = (ArmorStand)loc.getWorld().spawnEntity(loc, EntityType.ARMOR_STAND); |
||||
this.loc=loc; |
||||
} |
||||
|
||||
public void run() { |
||||
if (!EntityUtils.isValidEntity(ent)) { |
||||
ent = (ArmorStand)loc.getWorld().spawnEntity(loc, EntityType.ARMOR_STAND); |
||||
} |
||||
} |
||||
|
||||
public void setLocation(Location loc) { |
||||
this.loc=loc.clone(); |
||||
} |
||||
|
||||
public Location getLocation() { |
||||
return loc; |
||||
} |
||||
} |
@ -0,0 +1,42 @@ |
||||
package sig.plugin.TwosideKeeper.HelperStructures; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
|
||||
import org.bukkit.Location; |
||||
|
||||
import sig.plugin.TwosideKeeper.HelperStructures.Common.ArmorStandProperties; |
||||
import utils.Utils.Vector3D; |
||||
|
||||
public class Model { |
||||
List<ArmorStandProperties> modelParts = new ArrayList<ArmorStandProperties>(); |
||||
List<ArmorStandLinker> models = new ArrayList<ArmorStandLinker>(); |
||||
|
||||
Location loc; |
||||
Vector3D offset = new Vector3D(0,0,0); |
||||
double degreeRotation = 0; |
||||
|
||||
public Model(Location loc, ArmorStandProperties...modelParts) { |
||||
this.modelParts = Arrays.asList(modelParts); |
||||
for (ArmorStandProperties prop : modelParts) { |
||||
models.add(new ArmorStandLinker(loc)); |
||||
} |
||||
this.loc=loc; |
||||
} |
||||
|
||||
public void run() { |
||||
for (ArmorStandLinker parts : models) { |
||||
parts.run(); |
||||
parts.setLocation(loc); |
||||
} |
||||
} |
||||
|
||||
public void setLocation(Location loc) { |
||||
this.loc = loc.clone(); |
||||
} |
||||
|
||||
public Location getLocation() { |
||||
return loc; |
||||
} |
||||
} |
@ -0,0 +1,49 @@ |
||||
package sig.plugin.TwosideKeeper.HelperStructures.Utils; |
||||
import java.lang.reflect.Field; |
||||
|
||||
public class JavaUtils { |
||||
public JavaUtils clone() { |
||||
JavaUtils newpos = new JavaUtils(); |
||||
for (Field f : this.getClass().getDeclaredFields()) { |
||||
if (ReflectUtils.isCloneable(f)) { |
||||
try { |
||||
f.set(newpos, f.get(this)); |
||||
} catch (IllegalArgumentException e) { |
||||
e.printStackTrace(); |
||||
} catch (IllegalAccessException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
} |
||||
return newpos; |
||||
} |
||||
public String toString() { |
||||
StringBuilder sb = new StringBuilder(); |
||||
sb.append(this.getClass().getName()+"("); |
||||
boolean first=false; |
||||
for (Field f : this.getClass().getDeclaredFields()) { |
||||
if (!ReflectUtils.isCloneable(f)) { |
||||
if (!first) { |
||||
try { |
||||
sb.append(f.getName()+"="+f.get(this)); |
||||
first=true; |
||||
} catch (IllegalArgumentException e) { |
||||
e.printStackTrace(); |
||||
} catch (IllegalAccessException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} else { |
||||
try { |
||||
sb.append(","+f.getName()+"="+f.get(this)); |
||||
} catch (IllegalArgumentException e) { |
||||
e.printStackTrace(); |
||||
} catch (IllegalAccessException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
sb.append(")"); |
||||
return sb.toString(); |
||||
} |
||||
} |
@ -0,0 +1,9 @@ |
||||
package sig.plugin.TwosideKeeper.HelperStructures.Utils; |
||||
import java.lang.reflect.Field; |
||||
|
||||
public class ReflectUtils { |
||||
public static boolean isCloneable(Field f) { |
||||
int mods = f.getModifiers(); |
||||
return mods<8; |
||||
} |
||||
} |
Loading…
Reference in new issue