/[projects]/miscJava/bukkit-minecraft-plugins/HoerupUtils/src/main/java/dk/thoerup/bukkit/hoeruputils/ChestFillerAll.java
ViewVC logotype

Contents of /miscJava/bukkit-minecraft-plugins/HoerupUtils/src/main/java/dk/thoerup/bukkit/hoeruputils/ChestFillerAll.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3239 - (show annotations) (download)
Wed Jul 18 07:59:05 2018 UTC (5 years, 10 months ago) by torben
File size: 1716 byte(s)
Compile for spigot 1.13
1 package dk.thoerup.bukkit.hoeruputils;
2
3 import org.bukkit.Location;
4 import org.bukkit.Material;
5 import org.bukkit.World;
6 import org.bukkit.block.Block;
7 import org.bukkit.block.Chest;
8 import org.bukkit.command.Command;
9 import org.bukkit.command.CommandExecutor;
10 import org.bukkit.command.CommandSender;
11 import org.bukkit.entity.Player;
12 import org.bukkit.inventory.Inventory;
13 import org.bukkit.inventory.ItemStack;
14
15 public class ChestFillerAll implements CommandExecutor {
16
17 @Override
18 public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
19 if (! (sender instanceof Player) ) {
20 sender.sendMessage("this is not a console command!");
21 return true;
22 }
23
24 Player player = (Player) sender;
25 World world = player.getWorld();
26 if ( ! world.getName().equals("creative")) {
27 sender.sendMessage("May ONLY be used in creative");
28 return true;
29 }
30
31 Location loc = player.getLocation();
32 for (int x = loc.getBlockX()-10; x<= loc.getBlockX()+10; x++) {
33 for (int y = loc.getBlockY()-10; y<= loc.getBlockY()+10; y++) {
34 if (y<=0) {
35 continue;
36 }
37 for (int z = loc.getBlockZ()-10; z<= loc.getBlockZ()+10; z++) {
38 Block block = world.getBlockAt(x, y, z);
39 handleBlock(block);
40 }
41
42 }
43 }
44
45
46 return true;
47 }
48
49 private void handleBlock(Block block) {
50 Material mat = block.getType();
51
52 if (mat != Material.CHEST) {
53 return;
54 }
55
56 Chest chest = (Chest) block.getState();
57 Inventory inv = chest.getInventory();
58
59 ItemStack items = new ItemStack(Material.SNOWBALL, 16);
60
61 for (int i = 0; i< inv.getSize(); i++) {
62 inv.setItem(i, items);
63 }
64
65
66 }
67
68 }

  ViewVC Help
Powered by ViewVC 1.1.20