SynteX Use the getBlockAt(Location) method in World class, then modify its type. This works as setting a block in the world. Then you'll want to use some kind of loop to set a field of them. For a basic square platform, use this (pseudo) code. Code: for x = xMin to xMax for z = zMin to zMax set block at(x, original y, z)
Thanks i've made this code so far i know: Code:java public void makeArena(){ for (int x = -174 to -207){ for (int z = 204 to 170){ World world = Bukkit.getWorld("spawn"); world.getBlockAt(x, 30, z).setType(Material.TNT); } } } I don't know how to fix this?
SynteX That was a pseudo example, you were supposed to turn it into working code. Code: public void makeArena(Location start, Location end) { int aX = Math.max(start.getBlockX() end.getBlockX()); int bX = Math.min(start.getBlockX() end.getBlockX()); int aZ = Math.max(start.getBlockZ() end.getBlockZ()); int bZ = Math.min(start.getBlockZ() end.getBlockZ()); for(int x = bX; x <= aX; x++) { for(int z = bZ; z <= aZ; z++) { Block block = start.getWorld().getBlockAt(x, start.getBlockY(), z); block.setType(Material.TNT); } } } I wrote it on my phone, so something might be wrong. Just call that method with the start and end locations (the two corners), and it should work.
Assist Sorry man i'm new to Java and i got an error with: Code:java int aX = Math.max(start.getBlockX() end.getBlockX()); So i've fixt this with an , so now it is: Code:java int aX = Math.max(start.getBlockX(), end.getBlockX()); But i got an error on the start of the code: Code:java public void makeArena(-174 30 204, -207 30 170) {
SynteX Sorry, I missed the commas there. As for your second problem, make a Location out of the coordinates, then call the makeArena() method using those. Code: Location start = new Location(world, x, y, z); Location end = new Location(world, x, y, z); makeArena(start, end); Replace 'world' with your world, for instance, Bukkit.getWorld("world"). Then replace the first x, y and z with the first corner coordinates, and second x, y, z with the second corner coordinates.
Assist Thanks I think my code will work for now. I don't have errors now i need to test it on my server. Assist I've got a new problem when i make a command: Code:java public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) { if (commandLabel.equalsIgnoreCase("tntm")){ sender.sendMessage("Yeey ene command"); if (args.length == 1){ sender.sendMessage("Yes"); } else { sender.sendMessage("Wrong"); } } return false; } This works fine but it also give the usage in the chat? plugin.yml Code: name: TNT speelf main: plugin.arena version: 0.1 description: > Menno's plugin. commands: tntm: description: Description usage: /tntm [optional, arguments] EDIT by Moderator: merged posts, please use the edit button instead of double posting.
SynteX I'm not too sure about that, I usually use my own command system. What happens if you return true after you send the "Yes" message?