progress???
This commit is contained in:
		
					parent
					
						
							
								1aeb0d7504
							
						
					
				
			
			
				commit
				
					
						3022a8b545
					
				
			
		
					 4 changed files with 57 additions and 27 deletions
				
			
		|  | @ -139,7 +139,7 @@ public class ArenaList { | |||
|         for(Location block : arena.getBlocks()) { // TODO | ||||
|             arenaBlocks.remove(block); | ||||
|         } | ||||
|         arena.removeBlockDisplays(); // TODO | ||||
|         arena.removeBlockDisplays(); | ||||
| 
 | ||||
|         arenas.remove(arena.getName()); | ||||
|         save(); | ||||
|  |  | |||
|  | @ -59,7 +59,6 @@ public class MinecleanerArena { | |||
|                 blockDisplays[i] = UUID.fromString(blockDisplay); | ||||
|             } | ||||
|         } | ||||
|         blockDisplays = new UUID[widthIndex * widthIndex]; | ||||
|     }  | ||||
| 
 | ||||
|     public MinecleanerArena(MinecleanerPlugin plugin, String name, Location location, int widthIndex, BlockFace orientation) { | ||||
|  | @ -164,6 +163,11 @@ public class MinecleanerArena { | |||
|         arenaSection.set("location", this.location); | ||||
|         arenaSection.set("fieldwidth", this.widthIndex); | ||||
|         arenaSection.set("orientation", this.orientation.name()); | ||||
|         List<String> blockDisplays = new ArrayList<>(); | ||||
|         for(UUID uuid : this.blockDisplays) { | ||||
|             blockDisplays.add(uuid == null ? null : uuid.toString()); | ||||
|         } | ||||
|         arenaSection.set("blockdisplays", blockDisplays); | ||||
|     } | ||||
| 
 | ||||
|     public void startNewGame() { | ||||
|  | @ -184,15 +188,16 @@ public class MinecleanerArena { | |||
|         this.currentPlayer = null; | ||||
|     } | ||||
| 
 | ||||
|     // block displays dont get removed | ||||
|     public void removeBlockDisplays() { | ||||
|         World world = location.getWorld(); | ||||
|         for(int fx = 0; fx < 9; fx++) { | ||||
|             for(int fy = 0; fy < 9; fy++) { | ||||
|                 UUID blockDisplayUuid = blockDisplays[fx + fy * 9]; | ||||
|                 Entity blockDisplayEntity = blockDisplayUuid != null ? world.getEntity(blockDisplayUuid) : null; | ||||
|                 if(blockDisplayEntity instanceof Display blockdisplay) { | ||||
|                     blockDisplayEntity.remove(); | ||||
|                 } | ||||
|                 //if(blockDisplayEntity instanceof BlockDisplay blockDisplay) { | ||||
|                     blockDisplayEntity.remove(); // Null Pointer after restart | ||||
|                 //} | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | @ -239,7 +244,7 @@ public class MinecleanerArena { | |||
|         int d1z = d0x; | ||||
| 
 | ||||
|         Location loc = location.clone(); | ||||
|         for(int fx = -1; fx < 2; fx++) { | ||||
|         for(int fx = -2; fx < 1; fx++) { | ||||
|             for(int fy = -1; fy < 2; fy++) { | ||||
|                 loc.set(location.getX() + d1x + fx, location.getY() + fy, location.getZ() + d1z * fx); | ||||
|                 blocks.add(loc.clone()); | ||||
|  |  | |||
|  | @ -18,6 +18,8 @@ import org.bukkit.event.player.PlayerInteractEvent; | |||
| import org.bukkit.event.player.PlayerMoveEvent; | ||||
| import org.bukkit.event.player.PlayerQuitEvent; | ||||
| import org.bukkit.inventory.EquipmentSlot; | ||||
| import org.bukkit.util.RayTraceResult; | ||||
| import org.bukkit.util.Vector; | ||||
| import net.md_5.bungee.api.ChatColor; | ||||
| 
 | ||||
| public class MinecleanerListener implements Listener { | ||||
|  | @ -42,30 +44,53 @@ public class MinecleanerListener implements Listener { | |||
|                     int d1z = d0x; | ||||
| 
 | ||||
|                     if (e.getBlockFace() == arena.getOrientation()) { | ||||
|                         Location loc = e.getInteractionPoint().clone().subtract(arena.getLocation()).subtract(0.5, 0.5, 0.5); // null on left-click | ||||
|                         double lx = loc.getX(); | ||||
|                         double ly = loc.getY(); | ||||
|                         double lz = loc.getZ(); | ||||
|                         double dy = ly + 1.5; | ||||
|                         double dz = -d1x * lx - d1z * lz + 1.5; | ||||
|                         // Raytrace  | ||||
|                         // kann null sein | ||||
| 
 | ||||
|                         double blockx = (dy / 3.0) * 9.0; | ||||
|                         double blockz = (dz / 3.0) * 9.0; | ||||
|                         Player player = e.getPlayer(); | ||||
|                         RayTraceResult rayTraceResult = player.getWorld().rayTraceBlocks(player.getEyeLocation(), player.getEyeLocation().getDirection(), 64.0); | ||||
| 
 | ||||
|                         int blockxInt = (int) blockx; | ||||
|                         int blockzInt = (int) blockz; | ||||
|                         blockx -= blockxInt; | ||||
|                         blockz -= blockzInt; | ||||
|                         if (blockx >= 0.1 && blockx <= 0.9 && blockz >= 0.1 && blockz <= 0.9) { | ||||
|                             boolean hasRightClicked = false; | ||||
|                             if(e.getAction() == Action.RIGHT_CLICK_BLOCK) { | ||||
|                                 hasRightClicked = true; | ||||
|                         //Location loc = e.getInteractionPoint().clone().subtract(arena.getLocation()).subtract(0.5, 0.5, 0.5); // null on left-click | ||||
| 
 | ||||
| 
 | ||||
|                         if(rayTraceResult != null) { | ||||
|                             Vector hitPos = rayTraceResult.getHitPosition(); | ||||
|                             Location loc = player.getLocation().add(hitPos).clone().subtract(arena.getLocation()).subtract(0.5, 0.5, 0.5); | ||||
|                             double lx = loc.getX(); | ||||
|                             double ly = loc.getY(); | ||||
|                             double lz = loc.getZ(); | ||||
|                             player.sendMessage(ChatColor.GRAY + "lx: " + lx + " ,ly: " + ly + " ,lz: " + lz); | ||||
|                             double dy = ly + 1.5; | ||||
|                             player.sendMessage(ChatColor.GRAY + "dy: " + dy); | ||||
|                             double dz = -d1x * lx - d1z * lz + 1.5; | ||||
|                             player.sendMessage(ChatColor.GRAY + "dz: " + dz); | ||||
| 
 | ||||
|                             double blockx = (dy / 3.0) * 9.0; | ||||
|                             double blockz = (dz / 3.0) * 9.0; | ||||
| 
 | ||||
|                              | ||||
| 
 | ||||
|                             int blockxInt = (int) blockx; | ||||
|                             int blockzInt = (int) blockz; | ||||
|                             blockx -= blockxInt; | ||||
|                             blockz -= blockzInt; | ||||
| 
 | ||||
|                             player.sendMessage(ChatColor.GRAY + "blockx: " + blockx + " ,blockz: " + blockz); | ||||
|                             player.sendMessage(ChatColor.GRAY + "blockxInt: " + blockxInt + " ,blockzInt: " + blockzInt); | ||||
| 
 | ||||
|                             if (blockx >= 0.1 && blockx <= 0.9 && blockz >= 0.1 && blockz <= 0.9) { | ||||
|                                 boolean hasRightClicked = false; | ||||
|                                 if(e.getAction() == Action.RIGHT_CLICK_BLOCK) { | ||||
|                                     hasRightClicked = true; | ||||
|                                 } | ||||
|                                 // TODO Doesnt show messages for Cells: [ROW] [>5] (6, 7, 8 are missing) | ||||
| 
 | ||||
|                                 player.sendMessage("Arena click! " + blockxInt + " " + blockzInt + " Right Clicked: " + hasRightClicked); | ||||
|                                 //plugin.getManager().handleFieldClick(e.getPlayer(), blockxInt, blockzInt, hasRightClicked); | ||||
|                             } | ||||
|                             // TODO Doesnt show messages for Cells: [ROW] [>5] (6, 7, 8 are missing) | ||||
| 
 | ||||
|                             e.getPlayer().sendMessage("Arena click! " + blockxInt + " " + blockzInt + " Right Clicked: " + hasRightClicked); | ||||
|                             //plugin.getManager().handleFieldClick(e.getPlayer(), blockxInt, blockzInt, hasRightClicked); | ||||
|                         } | ||||
|                          | ||||
|                          | ||||
|                     } | ||||
|                 } | ||||
|             } else { | ||||
|  |  | |||
|  | @ -32,7 +32,7 @@ public class MinecleanerManager { | |||
|         this.plugin = plugin; | ||||
| 
 | ||||
|         // Deprecated | ||||
|         this.confirmPlayingInventory = plugin.getServer().createInventory(null, InventoryType.HOPPER, "Möchtest du Minecleaner spielen?"); | ||||
|         this.confirmPlayingInventory = plugin.getServer().createInventory(null, InventoryType.HOPPER, "Minecleaner starten?"); | ||||
|         this.confirmPlayingInventory.setItem(1,  | ||||
|             ItemStacks.lore(ItemStacks.rename(new ItemStack(Material.GREEN_CONCRETE), ChatColor.GREEN + "Bestätigen"))); | ||||
|         this.confirmPlayingInventory.setItem(3, | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue