Update to the latest Minecraft version
This commit is contained in:
parent
a37907ece9
commit
72ab3dae5d
4
pom.xml
4
pom.xml
@ -56,14 +56,14 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>org.bukkit</groupId>
|
||||||
<artifactId>bukkit</artifactId>
|
<artifactId>bukkit</artifactId>
|
||||||
<version>1.9-R0.1-SNAPSHOT</version>
|
<version>1.12-R0.1-SNAPSHOT</version>
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>org.bukkit</groupId>
|
||||||
<artifactId>craftbukkit</artifactId>
|
<artifactId>craftbukkit</artifactId>
|
||||||
<version>1.9-R0.1-SNAPSHOT</version>
|
<version>1.12-R0.1-SNAPSHOT</version>
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
@ -7,6 +7,7 @@ import java.util.UUID;
|
|||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@ -232,7 +233,14 @@ public class PrisonerManager {
|
|||||||
//only eject them if they're inside a vehicle and also eject anyone else on top of them
|
//only eject them if they're inside a vehicle and also eject anyone else on top of them
|
||||||
if(player.isInsideVehicle()) {
|
if(player.isInsideVehicle()) {
|
||||||
player.getVehicle().eject();
|
player.getVehicle().eject();
|
||||||
|
|
||||||
|
if (Util.doesClassHaveThisMethod(Entity.class, "getPassengers")) {
|
||||||
|
player.getPassengers().forEach(e -> e.eject());
|
||||||
|
} else {
|
||||||
|
//Ideally we should @SurpressWarnings due to the handling this, but leaving this here for now
|
||||||
player.getPassenger().eject();
|
player.getPassenger().eject();
|
||||||
|
}
|
||||||
|
|
||||||
player.eject();
|
player.eject();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -456,7 +464,14 @@ public class PrisonerManager {
|
|||||||
//them so we can possibly teleport them
|
//them so we can possibly teleport them
|
||||||
if(player.isInsideVehicle()) {
|
if(player.isInsideVehicle()) {
|
||||||
player.getVehicle().eject();
|
player.getVehicle().eject();
|
||||||
|
|
||||||
|
if (Util.doesClassHaveThisMethod(Entity.class, "getPassengers")) {
|
||||||
|
player.getPassengers().forEach(e -> e.eject());
|
||||||
|
} else {
|
||||||
|
//Ideally we should @SurpressWarnings due to the handling this, but leaving this here for now
|
||||||
player.getPassenger().eject();
|
player.getPassenger().eject();
|
||||||
|
}
|
||||||
|
|
||||||
player.eject();
|
player.eject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -512,4 +512,22 @@ public class Util {
|
|||||||
Bukkit.getLogger().severe("Unable to restore " + player.getName() + "'s inventory.");
|
Bukkit.getLogger().severe("Unable to restore " + player.getName() + "'s inventory.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the provided class has the provided method.
|
||||||
|
*
|
||||||
|
* @param c The {@link Class} to check on.
|
||||||
|
* @param method The name of the method to check for
|
||||||
|
* @return whether the method exists or not.
|
||||||
|
*/
|
||||||
|
public static boolean doesClassHaveThisMethod(Class<?> c, String method) {
|
||||||
|
try {
|
||||||
|
c.getMethod(method);
|
||||||
|
return true;
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
return true;
|
||||||
|
} catch (SecurityException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ import org.bukkit.WorldCreator;
|
|||||||
import org.bukkit.WorldType;
|
import org.bukkit.WorldType;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
import org.bukkit.craftbukkit.v1_9_R1.inventory.CraftItemFactory;
|
import org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemFactory;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.permissions.Permission;
|
import org.bukkit.permissions.Permission;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
Loading…
Reference in New Issue
Block a user