Permalink
Browse files

Update entity wrapper classes

  • Loading branch information...
PseudoKnight committed May 31, 2018
1 parent 88a131a commit fb12c5cdb769fe9a1b8a8ad1fd1d2aba36e46844
@@ -0,0 +1,16 @@
package com.laytonsmith.abstraction.bukkit.entities;
import com.laytonsmith.abstraction.entities.MCExplosiveMinecart;
import org.bukkit.entity.Entity;
import org.bukkit.entity.minecart.ExplosiveMinecart;
public class BukkitMCExplosiveMinecart extends BukkitMCMinecart implements MCExplosiveMinecart {
ExplosiveMinecart em;
public BukkitMCExplosiveMinecart(Entity e) {
super(e);
this.em = (ExplosiveMinecart) e;
}
}
@@ -0,0 +1,22 @@
package com.laytonsmith.abstraction.bukkit.entities;
import com.laytonsmith.abstraction.MCInventory;
import com.laytonsmith.abstraction.bukkit.BukkitMCInventory;
import com.laytonsmith.abstraction.entities.MCHopperMinecart;
import org.bukkit.entity.Entity;
import org.bukkit.entity.minecart.HopperMinecart;
public class BukkitMCHopperMinecart extends BukkitMCMinecart implements MCHopperMinecart {
HopperMinecart hm;
public BukkitMCHopperMinecart(Entity e) {
super(e);
this.hm = (HopperMinecart) e;
}
@Override
public MCInventory getInventory() {
return new BukkitMCInventory(hm.getInventory());
}
}
@@ -0,0 +1,15 @@
package com.laytonsmith.abstraction.bukkit.entities;
import com.laytonsmith.abstraction.entities.MCPoweredMinecart;
import org.bukkit.entity.Entity;
import org.bukkit.entity.minecart.PoweredMinecart;
public class BukkitMCPoweredMinecart extends BukkitMCMinecart implements MCPoweredMinecart {
PoweredMinecart pm;
public BukkitMCPoweredMinecart(Entity e) {
super(e);
this.pm = (PoweredMinecart) e;
}
}
@@ -0,0 +1,16 @@
package com.laytonsmith.abstraction.bukkit.entities;
import com.laytonsmith.abstraction.entities.MCRideableMinecart;
import org.bukkit.entity.Entity;
import org.bukkit.entity.minecart.RideableMinecart;
public class BukkitMCRideableMinecart extends BukkitMCMinecart implements MCRideableMinecart {
RideableMinecart rm;
public BukkitMCRideableMinecart(Entity e) {
super(e);
this.rm = (RideableMinecart) e;
}
}
@@ -0,0 +1,16 @@
package com.laytonsmith.abstraction.bukkit.entities;
import com.laytonsmith.abstraction.entities.MCSpawnerMinecart;
import org.bukkit.entity.Entity;
import org.bukkit.entity.minecart.SpawnerMinecart;
public class BukkitMCSpawnerMinecart extends BukkitMCMinecart implements MCSpawnerMinecart {
SpawnerMinecart sm;
public BukkitMCSpawnerMinecart(Entity e) {
super(e);
this.sm = (SpawnerMinecart) e;
}
}
@@ -0,0 +1,22 @@
package com.laytonsmith.abstraction.bukkit.entities;
import com.laytonsmith.abstraction.MCInventory;
import com.laytonsmith.abstraction.bukkit.BukkitMCInventory;
import com.laytonsmith.abstraction.entities.MCHopperMinecart;
import org.bukkit.entity.Entity;
import org.bukkit.entity.minecart.StorageMinecart;
public class BukkitMCStorageMinecart extends BukkitMCMinecart implements MCHopperMinecart {
StorageMinecart sm;
public BukkitMCStorageMinecart(Entity e) {
super(e);
this.sm = (StorageMinecart) e;
}
@Override
public MCInventory getInventory() {
return new BukkitMCInventory(sm.getInventory());
}
}
@@ -0,0 +1,5 @@
package com.laytonsmith.abstraction.entities;
public interface MCExplosiveMinecart extends MCMinecart {
}
@@ -0,0 +1,7 @@
package com.laytonsmith.abstraction.entities;
import com.laytonsmith.abstraction.MCInventoryHolder;
public interface MCHopperMinecart extends MCMinecart, MCInventoryHolder {
}
@@ -0,0 +1,5 @@
package com.laytonsmith.abstraction.entities;
public interface MCPoweredMinecart extends MCMinecart {
}
@@ -0,0 +1,5 @@
package com.laytonsmith.abstraction.entities;
public interface MCRideableMinecart extends MCMinecart {
}
@@ -0,0 +1,5 @@
package com.laytonsmith.abstraction.entities;
public interface MCSpawnerMinecart extends MCMinecart {
}
@@ -0,0 +1,7 @@
package com.laytonsmith.abstraction.entities;
import com.laytonsmith.abstraction.MCInventoryHolder;
public interface MCStorageMinecart extends MCMinecart, MCInventoryHolder {
}
@@ -2,10 +2,14 @@
import com.laytonsmith.abstraction.MCEntity;
import com.laytonsmith.abstraction.bukkit.entities.BukkitMCCommandMinecart;
import com.laytonsmith.abstraction.bukkit.entities.BukkitMCExplosiveMinecart;
import com.laytonsmith.abstraction.bukkit.entities.BukkitMCFishHook;
import com.laytonsmith.abstraction.bukkit.entities.BukkitMCHopperMinecart;
import com.laytonsmith.abstraction.bukkit.entities.BukkitMCItem;
import com.laytonsmith.abstraction.bukkit.entities.BukkitMCLightningStrike;
import com.laytonsmith.abstraction.bukkit.entities.BukkitMCMinecart;
import com.laytonsmith.abstraction.bukkit.entities.BukkitMCPoweredMinecart;
import com.laytonsmith.abstraction.bukkit.entities.BukkitMCStorageMinecart;
import com.laytonsmith.abstraction.bukkit.entities.BukkitMCTNT;
import com.laytonsmith.abstraction.bukkit.entities.BukkitMCThrownPotion;
import com.laytonsmith.abstraction.enums.MCEntityType;
@@ -125,25 +129,33 @@ private void setWrapperClass() {
case LINGERING_POTION:
wrapperClass = BukkitMCThrownPotion.class;
break;
case MINECART_CHEST:
wrapperClass = BukkitMCStorageMinecart.class;
break;
case MINECART_FURNACE:
wrapperClass = BukkitMCPoweredMinecart.class;
break;
case MINECART_HOPPER:
wrapperClass = BukkitMCHopperMinecart.class;
break;
case MINECART_TNT:
wrapperClass = BukkitMCExplosiveMinecart.class;
break;
case MINECART_MOB_SPAWNER:
wrapperClass = BukkitMCMinecart.class;
break;
case MINECART_COMMAND:
wrapperClass = BukkitMCCommandMinecart.class;
break;
case FISHING_HOOK:
wrapperClass = BukkitMCFishHook.class;
break;
default:
String[] split = abstracted.name().toLowerCase().split("_");
if(split.length == 0 || "".equals(split[0])) {
break;
}
String name = "com.laytonsmith.abstraction.bukkit.entities.BukkitMC";
if("minecart".equals(split[0])) {
if(split.length == 1 || !"command".equals(split[1])) {
wrapperClass = BukkitMCMinecart.class;
break;
} else {
wrapperClass = BukkitMCCommandMinecart.class;
break;
}
}
if(split[0].startsWith("fish")) { // Bukkit enum matches neither the old class or the new
wrapperClass = BukkitMCFishHook.class;
break;
}
for(String s : split) {
name = name.concat(Character.toUpperCase(s.charAt(0)) + s.substring(1));
}

0 comments on commit fb12c5c

Please sign in to comment.