diff --git a/src/com/cnaude/chairs/core/Chairs.java b/src/com/cnaude/chairs/core/Chairs.java index 61e5608..f0bb9e1 100644 --- a/src/com/cnaude/chairs/core/Chairs.java +++ b/src/com/cnaude/chairs/core/Chairs.java @@ -31,7 +31,7 @@ public class Chairs extends JavaPlugin { public final HashSet sitDisabled = new HashSet<>(); public final HashMap validChairs = new HashMap<>(); - public final List validSigns = new ArrayList(); + public final List validSigns = new ArrayList<>(); public final HashSet sitDisabledCommands = new HashSet<>(); public final HashSet disabledWorlds = new HashSet<>(); public boolean autoRotate, signCheck, notifyplayer; diff --git a/src/com/cnaude/chairs/core/PlayerSitData.java b/src/com/cnaude/chairs/core/PlayerSitData.java index 6b4983a..a6b3bc9 100644 --- a/src/com/cnaude/chairs/core/PlayerSitData.java +++ b/src/com/cnaude/chairs/core/PlayerSitData.java @@ -18,8 +18,8 @@ public class PlayerSitData { this.plugin = plugin; } - private HashMap sit = new HashMap(); - private HashMap sitblock = new HashMap(); + private HashMap sit = new HashMap<>(); + private HashMap sitblock = new HashMap<>(); public boolean isSitting(Player player) { return sit.containsKey(player) && sit.get(player).sitting; @@ -60,7 +60,7 @@ public class PlayerSitData { ); sitdata.resittask = task; player.teleport(sitlocation); - arrow.setPassenger(player); + arrow.addPassenger(player); sit.put(player, sitdata); sitblock.put(blocktooccupy, player); sitdata.sitting = true; @@ -72,7 +72,7 @@ public class PlayerSitData { sitdata.sitting = false; Entity prevarrow = sit.get(player).arrow; Entity arrow = plugin.getNMSAccess().spawnArrow(prevarrow.getLocation()); - arrow.setPassenger(player); + arrow.addPassenger(player); sitdata.arrow = arrow; prevarrow.remove(); sitdata.sitting = true; diff --git a/src/com/cnaude/chairs/listeners/TrySitEventListener.java b/src/com/cnaude/chairs/listeners/TrySitEventListener.java index 6ecefa7..a2b231d 100644 --- a/src/com/cnaude/chairs/listeners/TrySitEventListener.java +++ b/src/com/cnaude/chairs/listeners/TrySitEventListener.java @@ -235,11 +235,7 @@ public class TrySitEventListener implements Listener { if (checkDirection(block, relative)) { continue; } - if (plugin.validSigns.contains(relative.getType())) { - return true; - } else { - return false; - } + return (plugin.validSigns.contains(relative.getType())); } return false; } @@ -275,10 +271,8 @@ public class TrySitEventListener implements Listener { } } } - return false; - } else { - return false; } + return false; } return false; } diff --git a/src/com/cnaude/chairs/listeners/TryUnsitEventListener.java b/src/com/cnaude/chairs/listeners/TryUnsitEventListener.java index 465c903..7184189 100644 --- a/src/com/cnaude/chairs/listeners/TryUnsitEventListener.java +++ b/src/com/cnaude/chairs/listeners/TryUnsitEventListener.java @@ -47,8 +47,8 @@ public class TryUnsitEventListener implements Listener { @EventHandler(priority=EventPriority.LOWEST) public void onExitVehicle(VehicleExitEvent e) { - if (e.getVehicle().getPassenger() instanceof Player) { - final Player player = (Player) e.getVehicle().getPassenger(); + if (e.getExited() instanceof Player) { + final Player player = (Player) e.getExited(); if (plugin.getPlayerSitData().isSitting(player)) { if (!plugin.getPlayerSitData().unsitPlayer(player)) { e.setCancelled(true); diff --git a/src/com/cnaude/chairs/sitaddons/ChairEffects.java b/src/com/cnaude/chairs/sitaddons/ChairEffects.java index 8e68edf..937491e 100644 --- a/src/com/cnaude/chairs/sitaddons/ChairEffects.java +++ b/src/com/cnaude/chairs/sitaddons/ChairEffects.java @@ -1,6 +1,7 @@ package com.cnaude.chairs.sitaddons; import org.bukkit.Bukkit; +import org.bukkit.attribute.Attribute; import org.bukkit.entity.Damageable; import org.bukkit.entity.Entity; import org.bukkit.entity.ExperienceOrb; @@ -66,7 +67,7 @@ public class ChairEffects { } private double getMaxPlayerHealth(Player player) { - return ((Damageable) player).getMaxHealth(); + return player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue(); } public void startPickup() { diff --git a/src/com/cnaude/chairs/vehiclearrow/NMSAccess.java b/src/com/cnaude/chairs/vehiclearrow/NMSAccess.java index 00d341e..799f5a9 100644 --- a/src/com/cnaude/chairs/vehiclearrow/NMSAccess.java +++ b/src/com/cnaude/chairs/vehiclearrow/NMSAccess.java @@ -8,7 +8,7 @@ public class NMSAccess { private NMSArrowFactoryInterface arrowfactory; - public void setupChairsArrow() throws NMSAccessException, ClassNotFoundException { + public void setupChairsArrow() throws NMSAccessException { String pkgname = getClass().getPackage().getName(); String packageName = Bukkit.getServer().getClass().getPackage().getName(); String nmspackageversion = packageName.substring(packageName.lastIndexOf('.') + 1); diff --git a/src/com/cnaude/chairs/vehiclearrow/v1_10_R1/CraftChairsArrow.java b/src/com/cnaude/chairs/vehiclearrow/v1_10_R1/CraftChairsArrow.java deleted file mode 100644 index 9677354..0000000 --- a/src/com/cnaude/chairs/vehiclearrow/v1_10_R1/CraftChairsArrow.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.cnaude.chairs.vehiclearrow.v1_10_R1; - -import net.minecraft.server.v1_10_R1.EntityArrow; - -import java.util.Collections; -import java.util.Set; - -import org.bukkit.craftbukkit.v1_10_R1.CraftServer; -import org.bukkit.craftbukkit.v1_10_R1.entity.CraftArrow; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; -import org.bukkit.entity.Vehicle; - -import com.cnaude.chairs.api.ChairsAPI; - -public class CraftChairsArrow extends CraftArrow implements Vehicle { - - public CraftChairsArrow(CraftServer server, EntityArrow entity) { - super(server, entity); - } - - @Override - public void remove() { - Entity passenger = getPassenger(); - if (passenger != null && passenger instanceof Player) { - if (ChairsAPI.isSitting((Player) passenger)) { - return; - } - } - super.remove(); - } - - @Override - public int getPortalCooldown() { - return 0; - } - - @Override - public void setPortalCooldown(int val) { - } - - @Override - public Set getScoreboardTags() { - return Collections.emptySet(); - } - - @Override - public boolean addScoreboardTag(String tag) { - return false; - } - - @Override - public boolean removeScoreboardTag(String tag) { - return false; - } - -} diff --git a/src/com/cnaude/chairs/vehiclearrow/v1_10_R1/NMSArrowFactory.java b/src/com/cnaude/chairs/vehiclearrow/v1_10_R1/NMSArrowFactory.java deleted file mode 100644 index b72353d..0000000 --- a/src/com/cnaude/chairs/vehiclearrow/v1_10_R1/NMSArrowFactory.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.cnaude.chairs.vehiclearrow.v1_10_R1; - -import net.minecraft.server.v1_10_R1.EntityArrow; - -import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_10_R1.CraftWorld; -import org.bukkit.entity.Arrow; - -import com.cnaude.chairs.vehiclearrow.NMSArrowFactoryInterface; - -public class NMSArrowFactory implements NMSArrowFactoryInterface { - - @Override - public Arrow spawnArrow(Location location) { - CraftWorld world = (CraftWorld) location.getWorld(); - EntityArrow arrow = new NMSChairsArrow(world, location); - return (Arrow) arrow.getBukkitEntity(); - } - -} diff --git a/src/com/cnaude/chairs/vehiclearrow/v1_10_R1/NMSChairsArrow.java b/src/com/cnaude/chairs/vehiclearrow/v1_10_R1/NMSChairsArrow.java deleted file mode 100644 index ddcf297..0000000 --- a/src/com/cnaude/chairs/vehiclearrow/v1_10_R1/NMSChairsArrow.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.cnaude.chairs.vehiclearrow.v1_10_R1; - -import net.minecraft.server.v1_10_R1.EntityTippedArrow; - -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_10_R1.CraftServer; -import org.bukkit.craftbukkit.v1_10_R1.CraftWorld; - -public class NMSChairsArrow extends EntityTippedArrow { - - public NMSChairsArrow(CraftWorld cworld, Location location) { - super(cworld.getHandle()); - setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); - world.addEntity(this); - bukkitEntity = new CraftChairsArrow((CraftServer) Bukkit.getServer(), this); - } - - @Override - public void m() { - } - -} diff --git a/src/com/cnaude/chairs/vehiclearrow/v1_11_R1/CraftChairsArrow.java b/src/com/cnaude/chairs/vehiclearrow/v1_11_R1/CraftChairsArrow.java deleted file mode 100644 index 1b9b09a..0000000 --- a/src/com/cnaude/chairs/vehiclearrow/v1_11_R1/CraftChairsArrow.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.cnaude.chairs.vehiclearrow.v1_11_R1; - -import com.cnaude.chairs.api.ChairsAPI; -import net.minecraft.server.v1_11_R1.EntityArrow; -import org.bukkit.craftbukkit.v1_11_R1.CraftServer; -import org.bukkit.craftbukkit.v1_11_R1.entity.CraftArrow; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; -import org.bukkit.entity.Vehicle; - -public class CraftChairsArrow extends CraftArrow implements Vehicle { - - public CraftChairsArrow(CraftServer server, EntityArrow entity) { - super(server, entity); - } - - @Override - public void remove() { - Entity passenger = getPassenger(); - if (passenger != null && passenger instanceof Player) { - if (ChairsAPI.isSitting((Player) passenger)) { - return; - } - } - super.remove(); - } - -} diff --git a/src/com/cnaude/chairs/vehiclearrow/v1_11_R1/NMSArrowFactory.java b/src/com/cnaude/chairs/vehiclearrow/v1_11_R1/NMSArrowFactory.java deleted file mode 100644 index f58f5ea..0000000 --- a/src/com/cnaude/chairs/vehiclearrow/v1_11_R1/NMSArrowFactory.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.cnaude.chairs.vehiclearrow.v1_11_R1; - -import com.cnaude.chairs.vehiclearrow.NMSArrowFactoryInterface; -import net.minecraft.server.v1_11_R1.EntityArrow; -import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_11_R1.CraftWorld; -import org.bukkit.entity.Arrow; - -public class NMSArrowFactory implements NMSArrowFactoryInterface { - - @Override - public Arrow spawnArrow(Location location) { - CraftWorld world = (CraftWorld) location.getWorld(); - EntityArrow arrow = new NMSChairsArrow(world, location); - return (Arrow) arrow.getBukkitEntity(); - } - -} diff --git a/src/com/cnaude/chairs/vehiclearrow/v1_11_R1/NMSChairsArrow.java b/src/com/cnaude/chairs/vehiclearrow/v1_11_R1/NMSChairsArrow.java deleted file mode 100644 index 04119a6..0000000 --- a/src/com/cnaude/chairs/vehiclearrow/v1_11_R1/NMSChairsArrow.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.cnaude.chairs.vehiclearrow.v1_11_R1; - -import net.minecraft.server.v1_11_R1.EntityTippedArrow; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_11_R1.CraftServer; -import org.bukkit.craftbukkit.v1_11_R1.CraftWorld; - -public class NMSChairsArrow extends EntityTippedArrow { - - public NMSChairsArrow(CraftWorld cworld, Location location) { - super(cworld.getHandle()); - setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); - world.addEntity(this); - bukkitEntity = new CraftChairsArrow((CraftServer) Bukkit.getServer(), this); - } - - @Override - public void A_() { - } -} diff --git a/src/com/cnaude/chairs/vehiclearrow/v1_9_R1/CraftChairsArrow.java b/src/com/cnaude/chairs/vehiclearrow/v1_9_R1/CraftChairsArrow.java deleted file mode 100644 index 650e4d9..0000000 --- a/src/com/cnaude/chairs/vehiclearrow/v1_9_R1/CraftChairsArrow.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.cnaude.chairs.vehiclearrow.v1_9_R1; - -import net.minecraft.server.v1_9_R1.EntityArrow; - -import java.util.Collections; -import java.util.Set; - -import org.bukkit.craftbukkit.v1_9_R1.CraftServer; -import org.bukkit.craftbukkit.v1_9_R1.entity.CraftArrow; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; -import org.bukkit.entity.Vehicle; - -import com.cnaude.chairs.api.ChairsAPI; - -public class CraftChairsArrow extends CraftArrow implements Vehicle { - - public CraftChairsArrow(CraftServer server, EntityArrow entity) { - super(server, entity); - } - - @Override - public void remove() { - Entity passenger = getPassenger(); - if (passenger != null && passenger instanceof Player) { - if (ChairsAPI.isSitting((Player) passenger)) { - return; - } - } - super.remove(); - } - - - @Override - public void setInvulnerable(boolean invulnerable) { - } - - @Override - public boolean isInvulnerable() { - return true; - } - - @Override - public boolean isSilent() { - return true; - } - - @Override - public void setSilent(boolean silent) { - } - - @Override - public boolean hasGravity() { - return false; - } - - @Override - public void setGravity(boolean gravity) { - } - - @Override - public int getPortalCooldown() { - return 0; - } - - @Override - public void setPortalCooldown(int val) { - } - - @Override - public Set getScoreboardTags() { - return Collections.emptySet(); - } - - @Override - public boolean addScoreboardTag(String tag) { - return false; - } - - @Override - public boolean removeScoreboardTag(String tag) { - return false; - } - -} diff --git a/src/com/cnaude/chairs/vehiclearrow/v1_9_R1/NMSArrowFactory.java b/src/com/cnaude/chairs/vehiclearrow/v1_9_R1/NMSArrowFactory.java deleted file mode 100644 index 9bdc789..0000000 --- a/src/com/cnaude/chairs/vehiclearrow/v1_9_R1/NMSArrowFactory.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.cnaude.chairs.vehiclearrow.v1_9_R1; - -import net.minecraft.server.v1_9_R1.EntityArrow; - -import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_9_R1.CraftWorld; -import org.bukkit.entity.Arrow; - -import com.cnaude.chairs.vehiclearrow.NMSArrowFactoryInterface; - -public class NMSArrowFactory implements NMSArrowFactoryInterface { - - @Override - public Arrow spawnArrow(Location location) { - CraftWorld world = (CraftWorld) location.getWorld(); - EntityArrow arrow = new NMSChairsArrow(world, location); - return (Arrow) arrow.getBukkitEntity(); - } - -} diff --git a/src/com/cnaude/chairs/vehiclearrow/v1_9_R1/NMSChairsArrow.java b/src/com/cnaude/chairs/vehiclearrow/v1_9_R1/NMSChairsArrow.java deleted file mode 100644 index aaa1387..0000000 --- a/src/com/cnaude/chairs/vehiclearrow/v1_9_R1/NMSChairsArrow.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.cnaude.chairs.vehiclearrow.v1_9_R1; - -import net.minecraft.server.v1_9_R1.EntityTippedArrow; - -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_9_R1.CraftServer; -import org.bukkit.craftbukkit.v1_9_R1.CraftWorld; - -public class NMSChairsArrow extends EntityTippedArrow { - - public NMSChairsArrow(CraftWorld cworld, Location location) { - super(cworld.getHandle()); - setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); - world.addEntity(this); - bukkitEntity = new CraftChairsArrow((CraftServer) Bukkit.getServer(), this); - } - - @Override - public void m() { - } - -} diff --git a/src/com/cnaude/chairs/vehiclearrow/v1_9_R2/CraftChairsArrow.java b/src/com/cnaude/chairs/vehiclearrow/v1_9_R2/CraftChairsArrow.java deleted file mode 100644 index 42a54d6..0000000 --- a/src/com/cnaude/chairs/vehiclearrow/v1_9_R2/CraftChairsArrow.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.cnaude.chairs.vehiclearrow.v1_9_R2; - -import net.minecraft.server.v1_9_R2.EntityArrow; - -import java.util.Collections; -import java.util.Set; - -import org.bukkit.craftbukkit.v1_9_R2.CraftServer; -import org.bukkit.craftbukkit.v1_9_R2.entity.CraftArrow; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; -import org.bukkit.entity.Vehicle; - -import com.cnaude.chairs.api.ChairsAPI; - -public class CraftChairsArrow extends CraftArrow implements Vehicle { - - public CraftChairsArrow(CraftServer server, EntityArrow entity) { - super(server, entity); - } - - @Override - public void remove() { - Entity passenger = getPassenger(); - if (passenger != null && passenger instanceof Player) { - if (ChairsAPI.isSitting((Player) passenger)) { - return; - } - } - super.remove(); - } - - - @Override - public boolean isSilent() { - return true; - } - - @Override - public void setSilent(boolean silent) { - } - - @Override - public boolean hasGravity() { - return false; - } - - @Override - public void setGravity(boolean gravity) { - } - - @Override - public int getPortalCooldown() { - return 0; - } - - @Override - public void setPortalCooldown(int val) { - } - - @Override - public Set getScoreboardTags() { - return Collections.emptySet(); - } - - @Override - public boolean addScoreboardTag(String tag) { - return false; - } - - @Override - public boolean removeScoreboardTag(String tag) { - return false; - } - -} diff --git a/src/com/cnaude/chairs/vehiclearrow/v1_9_R2/NMSArrowFactory.java b/src/com/cnaude/chairs/vehiclearrow/v1_9_R2/NMSArrowFactory.java deleted file mode 100644 index 8b66af5..0000000 --- a/src/com/cnaude/chairs/vehiclearrow/v1_9_R2/NMSArrowFactory.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.cnaude.chairs.vehiclearrow.v1_9_R2; - -import net.minecraft.server.v1_9_R2.EntityArrow; - -import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_9_R2.CraftWorld; -import org.bukkit.entity.Arrow; - -import com.cnaude.chairs.vehiclearrow.NMSArrowFactoryInterface; - -public class NMSArrowFactory implements NMSArrowFactoryInterface { - - @Override - public Arrow spawnArrow(Location location) { - CraftWorld world = (CraftWorld) location.getWorld(); - EntityArrow arrow = new NMSChairsArrow(world, location); - return (Arrow) arrow.getBukkitEntity(); - } - -} diff --git a/src/com/cnaude/chairs/vehiclearrow/v1_9_R2/NMSChairsArrow.java b/src/com/cnaude/chairs/vehiclearrow/v1_9_R2/NMSChairsArrow.java deleted file mode 100644 index 5a7c166..0000000 --- a/src/com/cnaude/chairs/vehiclearrow/v1_9_R2/NMSChairsArrow.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.cnaude.chairs.vehiclearrow.v1_9_R2; - -import net.minecraft.server.v1_9_R2.EntityTippedArrow; - -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_9_R2.CraftServer; -import org.bukkit.craftbukkit.v1_9_R2.CraftWorld; - -public class NMSChairsArrow extends EntityTippedArrow { - - public NMSChairsArrow(CraftWorld cworld, Location location) { - super(cworld.getHandle()); - setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); - world.addEntity(this); - bukkitEntity = new CraftChairsArrow((CraftServer) Bukkit.getServer(), this); - } - - @Override - public void m() { - } - -}