Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package fr.keke142.getiteminhand.commands;
- import org.bukkit.Bukkit;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.block.Block;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandExecutor;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.Player;
- public class groundFromLoc implements CommandExecutor {
- public boolean onCommand(CommandSender sender, Command cmd, String alias, String[] args) {
- if (alias.equalsIgnoreCase("groundfromloc")) {
- Player p = (Player) sender;
- String world = "world";
- int x = 10;
- int y = 256;
- int z = 20;
- //Ok donc la je créer ma location avec mes 3 coordonnées toi t'as déjà ta loc,
- //c'est celle que t'a chopé au hasard, parcontre vieille à ce que le y de ta loc random sois 256
- Location loc = new Location(Bukkit.getWorld(world), x, y, z);
- //La ma boucle elle s'éffectue tant que loc est égale à air
- while (loc.getBlock().getType() == Material.AIR) {
- //Tant que cette boucle continue, je retire 1 au y de ma loc
- loc = loc.subtract(0, -1, 0);
- if (loc.getBlock().getType() != Material.AIR) {
- Bukkit.broadcastMessage("Je viens de touché un bloc qui n'est pas de l'air!");
- loc.getBlock().setType(Material.CHEST);
- }
- }
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement