diff --git a/build.xml b/build.xml index b70de53..9d4d0a6 100644 --- a/build.xml +++ b/build.xml @@ -11,7 +11,6 @@ - diff --git a/libs/ProtocolLib-3.0.1.jar b/libs/ProtocolLib-3.0.1.jar deleted file mode 100644 index 55f8181..0000000 Binary files a/libs/ProtocolLib-3.0.1.jar and /dev/null differ diff --git a/libs/bukkit-1.7.2-R0.1-20131211.094436-7.jar b/libs/bukkit-1.7.2-R0.1-20131211.094436-7.jar deleted file mode 100644 index c0e6ffa..0000000 Binary files a/libs/bukkit-1.7.2-R0.1-20131211.094436-7.jar and /dev/null differ diff --git a/libs/javassist.jar b/libs/javassist.jar deleted file mode 100644 index e9840d5..0000000 Binary files a/libs/javassist.jar and /dev/null differ diff --git a/libs/spigot.jar b/libs/spigot172.jar similarity index 100% rename from libs/spigot.jar rename to libs/spigot172.jar diff --git a/src/com/cnaude/chairs/core/Chairs.java b/src/com/cnaude/chairs/core/Chairs.java index 44ff7b0..7284560 100644 --- a/src/com/cnaude/chairs/core/Chairs.java +++ b/src/com/cnaude/chairs/core/Chairs.java @@ -25,7 +25,7 @@ import com.cnaude.chairs.listeners.TrySitEventListener; import com.cnaude.chairs.listeners.TryUnsitEventListener; import com.cnaude.chairs.sitaddons.ChairEffects; import com.cnaude.chairs.sitaddons.CommandRestrict; -import com.cnaude.chairs.vehiclearrow.GenVehicleArrowClass; +import com.cnaude.chairs.vehiclearrow.GetVehicleArrowClass; public class Chairs extends JavaPlugin { public ChairEffects chairEffects; @@ -60,7 +60,7 @@ public class Chairs extends JavaPlugin { return vehiclearrowclass; } - GenVehicleArrowClass genvehiclearrow = new GenVehicleArrowClass(); + GetVehicleArrowClass genvehiclearrow = new GetVehicleArrowClass(); @Override public void onEnable() { @@ -75,7 +75,7 @@ public class Chairs extends JavaPlugin { getHandle.setAccessible(true); Class entityarrow = getHandle.invoke(arrow).getClass(); Class craftserver = getServer().getClass(); - vehiclearrowclass = genvehiclearrow.genAndLoadClass(arrowclass, entityarrow, craftserver); + vehiclearrowclass = genvehiclearrow.getVehicleArrowClass(arrowclass, entityarrow, craftserver); arrow.remove(); } catch (Exception e) { e.printStackTrace(); diff --git a/src/com/cnaude/chairs/sitaddons/ChairEffects.java b/src/com/cnaude/chairs/sitaddons/ChairEffects.java index c41c80d..edfefc6 100644 --- a/src/com/cnaude/chairs/sitaddons/ChairEffects.java +++ b/src/com/cnaude/chairs/sitaddons/ChairEffects.java @@ -50,7 +50,7 @@ public class ChairEffects { for (Player p : Bukkit.getOnlinePlayers()) { if (plugin.getPlayerSitData().isSitting(p)) { if (p.hasPermission("chairs.sit.health")) { - double pHealthPcnt = ((double) p.getHealth()) / (double) p.getMaxHealth() * 100d; + double pHealthPcnt = (p.getHealth()) / p.getMaxHealth() * 100d; if ((pHealthPcnt < plugin.sitMaxHealth) && (p.getHealth() < p.getMaxHealth())) { double newHealth = plugin.sitHealthPerInterval + p.getHealth(); if (newHealth > p.getMaxHealth()) { diff --git a/src/com/cnaude/chairs/vehiclearrow/GenVehicleArrowClass.java b/src/com/cnaude/chairs/vehiclearrow/GenVehicleArrowClass.java deleted file mode 100644 index 58c1550..0000000 --- a/src/com/cnaude/chairs/vehiclearrow/GenVehicleArrowClass.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.cnaude.chairs.vehiclearrow; - -import java.io.IOException; - -import org.bukkit.Bukkit; -import org.bukkit.entity.Vehicle; - -import javassist.CannotCompileException; -import javassist.ClassClassPath; -import javassist.ClassPool; -import javassist.CtClass; -import javassist.CtNewConstructor; -import javassist.CtNewMethod; -import javassist.NotFoundException; - -public class GenVehicleArrowClass { - - public Class genAndLoadClass(String arrowclass, Class entityarrow, Class craftserver) throws IOException, ClassNotFoundException, NotFoundException, CannotCompileException - { - ClassPool pool = ClassPool.getDefault(); - pool.insertClassPath - ( - new ClassClassPath(Bukkit.class) - ); - CtClass vehiclearrow = pool.makeClass("com.cnaude.chairs.VehicleArrow"); - vehiclearrow.setSuperclass(pool.getCtClass(arrowclass)); - vehiclearrow.setInterfaces - ( - new CtClass[] - { - pool.get(Vehicle.class.getName()) - } - ); - String counstructorsource = "public VehicleArrow("+craftserver.getName()+" server, "+entityarrow.getName()+" entity)\n{\nsuper(server, entity);\n}"; - vehiclearrow.addConstructor - ( - CtNewConstructor.make(counstructorsource, vehiclearrow) - ); - String removemethodsource = "public void remove()\n{\nif (this.getPassenger() == null)\n{\nsuper.remove();\n}\n}"; - vehiclearrow.addMethod - ( - CtNewMethod.make(removemethodsource, vehiclearrow) - ); - return vehiclearrow.toClass(); - } - - - -} diff --git a/src/com/cnaude/chairs/vehiclearrow/GetVehicleArrowClass.java b/src/com/cnaude/chairs/vehiclearrow/GetVehicleArrowClass.java new file mode 100644 index 0000000..aabf9c9 --- /dev/null +++ b/src/com/cnaude/chairs/vehiclearrow/GetVehicleArrowClass.java @@ -0,0 +1,25 @@ +package com.cnaude.chairs.vehiclearrow; + +import org.bukkit.Bukkit; + +public class GetVehicleArrowClass { + + private String pkgname = this.getClass().getPackage().getName(); + private String vehiclearrowclassname = "VehicleArrow"; + public Class getVehicleArrowClass(String arrowclass, Class entityarrow, Class craftserver) throws Exception + { + String packageName = Bukkit.getServer().getClass().getPackage().getName(); + String nmspackageversion = packageName.substring(packageName.lastIndexOf('.') + 1); + if (nmspackageversion.equals("v1_7_R1")) + { + return Class.forName(pkgname+"."+"nms172"+"."+vehiclearrowclassname); + } else if (nmspackageversion.equals("v1_6_R3")) + { + return Class.forName(pkgname+"."+"nms164"+"."+vehiclearrowclassname); + } + throw new Exception("ChiarsReloaded is not compatible with your server version"); + } + + + +} diff --git a/src/com/cnaude/chairs/vehiclearrow/nms164/VehicleArrow.java b/src/com/cnaude/chairs/vehiclearrow/nms164/VehicleArrow.java new file mode 100644 index 0000000..8ec8cf1 --- /dev/null +++ b/src/com/cnaude/chairs/vehiclearrow/nms164/VehicleArrow.java @@ -0,0 +1,5 @@ +package com.cnaude.chairs.vehiclearrow.nms164; + +public class VehicleArrow { + +} diff --git a/src/com/cnaude/chairs/vehiclearrow/nms172/VehicleArrow.java b/src/com/cnaude/chairs/vehiclearrow/nms172/VehicleArrow.java new file mode 100644 index 0000000..f47a04f --- /dev/null +++ b/src/com/cnaude/chairs/vehiclearrow/nms172/VehicleArrow.java @@ -0,0 +1,25 @@ +package com.cnaude.chairs.vehiclearrow.nms172; + +import net.minecraft.server.v1_7_R1.EntityArrow; + +import org.bukkit.craftbukkit.v1_7_R1.CraftServer; +import org.bukkit.craftbukkit.v1_7_R1.entity.CraftArrow; +import org.bukkit.entity.Vehicle; + +public class VehicleArrow extends CraftArrow implements Vehicle { + + public VehicleArrow(CraftServer server, EntityArrow entity) + { + super(server, entity); + } + + @Override + public void remove() + { + if (this.getPassenger() == null) + { + super.remove(); + } + } + +} diff --git a/src/plugin.yml b/src/plugin.yml index d735e61..312fb8e 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -6,7 +6,7 @@ authors: - spoothie - cnaude - _Shevchik_ -main: com.cnaude.chairs.Chairs +main: com.cnaude.chairs.core.Chairs commands: chairs: description: Various commands for Chairs.