Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @EventHandler
- public void onBlockPlaceGame(BlockPlaceEvent ev)
- {
- identifier(ev.getBlock(), ev.getPlayer(), true);
- }
- //loops through all locations to identify if a placed block has to trigger an action
- public void identifier(Block b, Player p, Boolean bp)
- {
- File worlds = new File("plugins/ColorKeyBattle/config/worlds.yml");
- YamlConfiguration worlds2 = YamlConfiguration.loadConfiguration(worlds);
- File locs = new File("plugins/ColorKeyBattle/config/" + worlds2.getString(p.getWorld().getName()) + ".yml");
- YamlConfiguration locations = YamlConfiguration.loadConfiguration(locs);
- String[] slot = {"Baseslots", "Basespawners"};
- String[] color = {/*0*/"Red",/*1*/"RedBlue",/*2*/"RedGreen",/*3*/"RedBlack",/*4*/"Blue",/*5*/"BlueRed",/*6*/"BlueGreen",/*7*/"BlueBlack",/*8*/"Green",/*9*/"GreenRed",/*10*/"GreenBlue",/*11*/"GreenBlack",/*12*/"Black",/*13*/"BlackRed",/*14*/"BlackBlue",/*15*/"BlackGreen"};
- for(String x: slot)
- {
- for(String y: color)
- {
- if(locations.getInt(p.getWorld().getName() + "."+ x + "." + y + ".loc1.X") == b.getX() || locations.getInt(p.getWorld().getName() + "." + x + "." + y + ".loc2.X") == b.getX() || locations.getInt(p.getWorld().getName() + "." + x + "." + y + ".loc1.X") - (locations.getInt(p.getWorld().getName() + "." + x + "." + y + ".loc1.X") - locations.getInt(p.getWorld().getName() + "." + x + "." + y + ".loc2.X"))*0.5 == b.getX())
- {
- if(locations.getInt(p.getWorld().getName() + "." + x + "." + y + ".loc1.Y") == b.getY() || locations.getInt(p.getWorld().getName() + "." + x + "." + y + ".loc2.Y") == b.getY() || locations.getInt(p.getWorld().getName() + "." + x + "." + y + ".loc1.Y") - (locations.getInt(p.getWorld().getName() + "." + x + "." + y + ".loc1.Y") - locations.getInt(p.getWorld().getName() + "." + x + "." + y + ".loc2.Y"))*0.5 == b.getY() )
- {
- if(locations.getInt(p.getWorld().getName() + "." + x + "." + y + ".loc1.Z") == b.getZ() || locations.getInt(p.getWorld().getName() + "." + x + "." + y + ".loc2.Z") == b.getZ() || locations.getInt(p.getWorld().getName() + "." + x + "." + y + ".loc1.Z") - (locations.getInt(p.getWorld().getName() + "." + x + "." + y + ".loc1.Z") - locations.getInt(p.getWorld().getName() + "." + x + "." + y + ".loc2.Z"))*0.5 == b.getZ() )
- {
- blockAction(x, y, bp, p.getWorld(), p, b);
- }
- }
- }
- }
- }
- }
- // The action a placed block triggers selected by the data from identifier()
- public void blockAction(String slotId, String colorId, Boolean bp, World world, Player p, Block b)
- {
- File worlds = new File("plugins/ColorKeyBattle/config/worlds.yml");
- YamlConfiguration worlds2 = YamlConfiguration.loadConfiguration(worlds);
- File locs = new File("plugins/ColorKeyBattle/config/" + worlds2.getString(p.getWorld().getName()) + ".yml");
- YamlConfiguration locations = YamlConfiguration.loadConfiguration(locs);
- if(slotId.equals("Baseslots"))
- {
- Location loc = new Location(world, locations.getInt(p.getWorld().getName() + ".Beaconspots." + colorId + ".loc1.X"), locations.getInt(p.getWorld().getName() + ".Beaconspots." + colorId + ".loc1.Y"), locations.getInt(p.getWorld().getName() + ".Beaconspots." + colorId + ".loc1.Z"));
- if(bp == true)
- {
- if(blocks.get("Baseslots" + colorId) == null)
- {
- blocks.put("Baseslots" + colorId, 0);
- }
- blocks.put("Baseslots" + colorId, blocks.get("Baseslots" + colorId)+1);
- if(blocks.get("Baseslots" + colorId) == 1 && b.getType().equals(Material.WOOL))
- if(colorId.startsWith("Red") && DyeColor.getByWoolData(b.getData()) == DyeColor.RED)
- {
- loc.getBlock().setType(Material.BEACON);
- TimerClass.callTimer(p, "Red", "base", world.getName());
- }
- else if(colorId.startsWith("Blue") && DyeColor.getByWoolData(b.getData()) == DyeColor.BLUE)
- {
- loc.getBlock().setType(Material.BEACON);
- }
- else if(colorId.startsWith("Green") && DyeColor.getByWoolData(b.getData()) == DyeColor.LIME)
- {
- loc.getBlock().setType(Material.BEACON);
- }
- else if(colorId.startsWith("Black") && DyeColor.getByWoolData(b.getData()) == DyeColor.BLACK)
- {
- loc.getBlock().setType(Material.BEACON);
- }
- }
- else if(bp == false)
- {
- if(blocks.get("Baseslots" + colorId) == null)
- {
- blocks.put("Baseslots" + colorId, 0);
- }
- blocks.put("Baseslots" + colorId, blocks.get("Baseslots" + colorId)-1);
- if(blocks.get("Baseslots" + colorId) == 0)
- {
- loc.getBlock().setType(Material.AIR);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement