mirror of
https://github.com/bloodmc/GriefDefender.git
synced 2024-11-25 12:45:48 +01:00
Fix NPE when checking player options on NPC.
This commit is contained in:
parent
84fdbd2de0
commit
99d0085d96
@ -338,6 +338,11 @@ public boolean onEntityMove(Event event, Location fromLocation, Location toLocat
|
||||
|
||||
private void runPlayerCommands(GDClaim claim, GDPermissionUser user, boolean enter) {
|
||||
final Player player = user.getOnlinePlayer();
|
||||
if (player == null) {
|
||||
// Most likely Citizens NPC
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> rawCommandList = new ArrayList<>();
|
||||
Set<Context> contexts = new HashSet<>();
|
||||
if (player.getUniqueId().equals(claim.getOwnerUniqueId())) {
|
||||
@ -406,6 +411,11 @@ private String replacePlaceHolders(GDClaim claim, Player player, String command)
|
||||
|
||||
private void checkPlayerFlight(GDPermissionUser user, GDClaim fromClaim, GDClaim toClaim) {
|
||||
final Player player = user.getOnlinePlayer();
|
||||
if (player == null) {
|
||||
// Most likely Citizens NPC
|
||||
return;
|
||||
}
|
||||
|
||||
final GDPlayerData playerData = user.getInternalPlayerData();
|
||||
final GameMode gameMode = player.getGameMode();
|
||||
if (gameMode == GameMode.CREATIVE || gameMode == GameMode.SPECTATOR) {
|
||||
@ -432,6 +442,11 @@ private void checkPlayerFlight(GDPermissionUser user, GDClaim fromClaim, GDClaim
|
||||
|
||||
private void checkPlayerGodMode(GDPermissionUser user, GDClaim fromClaim, GDClaim toClaim) {
|
||||
final Player player = user.getOnlinePlayer();
|
||||
if (player == null) {
|
||||
// Most likely Citizens NPC
|
||||
return;
|
||||
}
|
||||
|
||||
final GDPlayerData playerData = user.getInternalPlayerData();
|
||||
final GameMode gameMode = player.getGameMode();
|
||||
if (gameMode == GameMode.CREATIVE || gameMode == GameMode.SPECTATOR || !player.isInvulnerable()) {
|
||||
@ -456,6 +471,11 @@ private void checkPlayerGameMode(GDPermissionUser user, GDClaim fromClaim, GDCla
|
||||
}
|
||||
|
||||
final Player player = user.getOnlinePlayer();
|
||||
if (player == null) {
|
||||
// Most likely Citizens NPC
|
||||
return;
|
||||
}
|
||||
|
||||
final GDPlayerData playerData = user.getInternalPlayerData();
|
||||
final GameMode currentGameMode = player.getGameMode();
|
||||
final GameModeType gameModeType = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(GameModeType.class), playerData.getSubject(), Options.PLAYER_GAMEMODE, toClaim);
|
||||
@ -478,6 +498,11 @@ private void checkPlayerWalkSpeed(GDPermissionUser user, GDClaim fromClaim, GDCl
|
||||
}
|
||||
|
||||
final Player player = user.getOnlinePlayer();
|
||||
if (player == null) {
|
||||
// Most likely Citizens NPC
|
||||
return;
|
||||
}
|
||||
|
||||
final GDPlayerData playerData = user.getInternalPlayerData();
|
||||
final float currentWalkSpeed = player.getWalkSpeed();
|
||||
final double walkSpeed = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Double.class), playerData.getSubject(), Options.PLAYER_WALK_SPEED, toClaim);
|
||||
@ -499,6 +524,11 @@ public void checkPlayerWeather(GDPermissionUser user, GDClaim fromClaim, GDClaim
|
||||
}
|
||||
|
||||
final Player player = user.getOnlinePlayer();
|
||||
if (player == null) {
|
||||
// Most likely Citizens NPC
|
||||
return;
|
||||
}
|
||||
|
||||
final GDPlayerData playerData = user.getInternalPlayerData();
|
||||
final WeatherType weatherType = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(WeatherType.class), playerData.getSubject(), Options.PLAYER_WEATHER, toClaim);
|
||||
if (weatherType != null && weatherType != WeatherTypes.UNDEFINED) {
|
||||
|
@ -383,6 +383,11 @@ public boolean onEntityMove(MoveEntityEvent event, Location<World> fromLocation,
|
||||
|
||||
private void runPlayerCommands(GDClaim claim, GDPermissionUser user, boolean enter) {
|
||||
final Player player = user.getOnlinePlayer();
|
||||
if (player == null) {
|
||||
// Most likely NPC
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> rawCommandList = new ArrayList<>();
|
||||
Set<Context> contexts = new HashSet<>();
|
||||
if (player.getUniqueId().equals(claim.getOwnerUniqueId())) {
|
||||
@ -451,6 +456,11 @@ private String replacePlaceHolders(GDClaim claim, Player player, String command)
|
||||
|
||||
private void checkPlayerFlight(GDPermissionUser user, GDClaim fromClaim, GDClaim toClaim) {
|
||||
final Player player = user.getOnlinePlayer();
|
||||
if (player == null) {
|
||||
// Most likely NPC
|
||||
return;
|
||||
}
|
||||
|
||||
final GDPlayerData playerData = user.getInternalPlayerData();
|
||||
final GameMode gameMode = player.get(Keys.GAME_MODE).orElse(null);
|
||||
if (gameMode == null || gameMode == GameModes.CREATIVE || gameMode == GameModes.SPECTATOR) {
|
||||
@ -478,6 +488,11 @@ private void checkPlayerFlight(GDPermissionUser user, GDClaim fromClaim, GDClaim
|
||||
|
||||
private void checkPlayerGodMode(GDPermissionUser user, GDClaim fromClaim, GDClaim toClaim) {
|
||||
final Player player = user.getOnlinePlayer();
|
||||
if (player == null) {
|
||||
// Most likely NPC
|
||||
return;
|
||||
}
|
||||
|
||||
final GDPlayerData playerData = user.getInternalPlayerData();
|
||||
final GameMode gameMode = player.get(Keys.GAME_MODE).get();
|
||||
if (gameMode == GameModes.CREATIVE || gameMode == GameModes.SPECTATOR || !player.get(Keys.INVULNERABLE).get()) {
|
||||
@ -502,6 +517,11 @@ private void checkPlayerGameMode(GDPermissionUser user, GDClaim fromClaim, GDCla
|
||||
}
|
||||
|
||||
final Player player = user.getOnlinePlayer();
|
||||
if (player == null) {
|
||||
// Most likely NPC
|
||||
return;
|
||||
}
|
||||
|
||||
final GDPlayerData playerData = user.getInternalPlayerData();
|
||||
final GameMode currentGameMode = player.get(Keys.GAME_MODE).get();
|
||||
final GameModeType gameModeType = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(GameModeType.class), playerData.getSubject(), Options.PLAYER_GAMEMODE, toClaim);
|
||||
@ -524,6 +544,11 @@ private void checkPlayerWalkSpeed(GDPermissionUser user, GDClaim fromClaim, GDCl
|
||||
}
|
||||
|
||||
final Player player = user.getOnlinePlayer();
|
||||
if (player == null) {
|
||||
// Most likely NPC
|
||||
return;
|
||||
}
|
||||
|
||||
final GDPlayerData playerData = user.getInternalPlayerData();
|
||||
final double currentWalkSpeed = player.get(Keys.WALKING_SPEED).get();
|
||||
final double walkSpeed = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Double.class), playerData.getSubject(), Options.PLAYER_WALK_SPEED, toClaim);
|
||||
@ -544,6 +569,11 @@ public void checkPlayerWeather(GDPermissionUser user, GDClaim fromClaim, GDClaim
|
||||
}
|
||||
|
||||
final Player player = user.getOnlinePlayer();
|
||||
if (player == null) {
|
||||
// Most likely NPC
|
||||
return;
|
||||
}
|
||||
|
||||
final GDPlayerData playerData = user.getInternalPlayerData();
|
||||
final WeatherType weatherType = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(WeatherType.class), playerData.getSubject(), Options.PLAYER_WEATHER, toClaim);
|
||||
if (weatherType != null) {
|
||||
|
Loading…
Reference in New Issue
Block a user