mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-01-02 22:07:50 +01:00
Make sure to restrict the "inventory" screen closing to interworld
teleports.
This commit is contained in:
parent
2f5a726494
commit
675a6a85d8
2
pom.xml
2
pom.xml
@ -3,7 +3,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>cc.co.evenprime.bukkit</groupId>
|
<groupId>cc.co.evenprime.bukkit</groupId>
|
||||||
<artifactId>NoCheat</artifactId>
|
<artifactId>NoCheat</artifactId>
|
||||||
<version>2.20a</version>
|
<version>2.20b</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>NoCheat</name>
|
<name>NoCheat</name>
|
||||||
<properties>
|
<properties>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package cc.co.evenprime.bukkit.nocheat.events;
|
package cc.co.evenprime.bukkit.nocheat.events;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
@ -32,17 +33,17 @@ public class WorkaroundsEventManager extends EventManagerImpl {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handlePlayerTeleportEvent(final PlayerTeleportEvent event, final Priority priority) {
|
protected void handlePlayerTeleportEvent(final PlayerTeleportEvent event, final Priority priority) {
|
||||||
handleTeleportation(event.getPlayer());
|
handleTeleportation(event.getPlayer(), event.getTo());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handlePlayerPortalEvent(final PlayerPortalEvent event, final Priority priority) {
|
protected void handlePlayerPortalEvent(final PlayerPortalEvent event, final Priority priority) {
|
||||||
handleTeleportation(event.getPlayer());
|
handleTeleportation(event.getPlayer(), event.getTo());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handlePlayerRespawnEvent(final PlayerRespawnEvent event, final Priority priority) {
|
protected void handlePlayerRespawnEvent(final PlayerRespawnEvent event, final Priority priority) {
|
||||||
handleTeleportation(event.getPlayer());
|
handleTeleportation(event.getPlayer(), event.getRespawnLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -51,10 +52,10 @@ public class WorkaroundsEventManager extends EventManagerImpl {
|
|||||||
if(!event.isCancelled())
|
if(!event.isCancelled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
handleTeleportation(event.getPlayer());
|
handleTeleportation(event.getPlayer(), event.getTo());
|
||||||
|
|
||||||
// Fix a common mistake that other developers make (cancelling move
|
// Fix a common mistake that other developers make (cancelling move
|
||||||
// events is crazy, rather set the target location to the from location
|
// events is crazy, rather set the target location to the from location)
|
||||||
if(plugin.getPlayer(event.getPlayer()).getConfiguration().debug.overrideIdiocy) {
|
if(plugin.getPlayer(event.getPlayer()).getConfiguration().debug.overrideIdiocy) {
|
||||||
event.setCancelled(false);
|
event.setCancelled(false);
|
||||||
event.setTo(event.getFrom().clone());
|
event.setTo(event.getFrom().clone());
|
||||||
@ -69,8 +70,8 @@ public class WorkaroundsEventManager extends EventManagerImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleTeleportation(final Player player) {
|
private void handleTeleportation(final Player player, final Location to) {
|
||||||
if(plugin.getPlayer(player).getConfiguration().inventory.closebeforeteleports && player instanceof CraftPlayer) {
|
if(plugin.getPlayer(player).getConfiguration().inventory.closebeforeteleports && player instanceof CraftPlayer && to != null && !(to.getWorld().equals(player.getWorld()))) {
|
||||||
((CraftPlayer) player).getHandle().closeInventory();
|
((CraftPlayer) player).getHandle().closeInventory();
|
||||||
}
|
}
|
||||||
plugin.clearCriticalData(player.getName());
|
plugin.clearCriticalData(player.getName());
|
||||||
|
Loading…
Reference in New Issue
Block a user