Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fix bug that enables players lost still being able to dig the floor.

Also fix NPE when not in game.
  • Loading branch information...
commit a3c0a33b8c1ef452c238f6f53a4f48e60b850a66 1 parent 3c8a022
Max authored
15  src/main/java/de/beimax/simplespleef/game/GameStandard.java
@@ -1064,10 +1064,11 @@ public boolean onPlayerMove(PlayerMoveEvent event) {
1064 1064
 	public boolean onPlayerInteract(PlayerInteractEvent event) {
1065 1065
 		if (!isEnabled()) return false; // ignore disabled arenas
1066 1066
 		Block block = event.getClickedBlock();
1067  
-		if (block == null || event.getPlayer() == null || !hasPlayer(event.getPlayer())) return false; // ignore null blocks and null players and players not in game
  1067
+		Player player = event.getPlayer();
  1068
+		if (block == null || player == null || !hasPlayer(player) || spleefers.getSpleefer(player).hasLost()) return false; // ignore null blocks and null players and players not in game
1068 1069
 		
1069 1070
 		// check instant dig and block may be broken
1070  
-		if (event.getAction() == Action.LEFT_CLICK_BLOCK && configuration.getBoolean("instantDig", true) && checkMayBreakBlock(block, event.getPlayer())) {
  1071
+		if (event.getAction() == Action.LEFT_CLICK_BLOCK && configuration.getBoolean("instantDig", true) && checkMayBreakBlock(block, player)) {
1071 1072
 			// cancel event
1072 1073
 			event.setCancelled(true);
1073 1074
 			// get block data
@@ -1091,7 +1092,7 @@ public boolean onPlayerInteract(PlayerInteractEvent event) {
1091 1092
 				if (readyBlockMaterial == null) return true; // ignore null materials
1092 1093
 				// material has been checked, now test, if clicked block is of the same material
1093 1094
 				if (readyBlockMaterial.getTypeId() == block.getTypeId() && MaterialHelper.isSameBlockType(block, readyBlockMaterial)) {
1094  
-					ready(event.getPlayer(), true);
  1095
+					ready(player, true);
1095 1096
 				}
1096 1097
 			}
1097 1098
 		return true;
@@ -1104,16 +1105,16 @@ public boolean onBlockBreak(BlockBreakEvent event) {
1104 1105
 		if (player == null) return false; // no NPEs
1105 1106
 		
1106 1107
 		// is player a spleefer?
1107  
-		if (isInProgress() && hasPlayer(player) && !spleefers.getSpleefer(player).hasLost()) {
1108  
-			blockBreakInGame(event);
1109  
-			return true;
1110  
-		} else { // not in spleefer list, check arena area nevertheless
  1108
+		if (!isInProgress() || !hasPlayer(player) || spleefers.getSpleefer(player).hasLost()) {
1111 1109
 			if (inProtectedArenaCube(event.getBlock())) { //check if block is in cube
1112 1110
 				// cancel event
1113 1111
 				event.setCancelled(true);
1114 1112
 				player.sendMessage(ChatColor.DARK_RED + SimpleSpleef.ll("errors.noDig"));
1115 1113
 				return true;
1116 1114
 			}
  1115
+		} else { // not in spleefer list, check arena area nevertheless
  1116
+			blockBreakInGame(event);
  1117
+			return true;			
1117 1118
 		}
1118 1119
 		return false;
1119 1120
 	}

0 notes on commit a3c0a33

Please sign in to comment.
Something went wrong with that request. Please try again.