public void addRecipes() { int i = 0; // fix lore recipes_config.set("shaped.Stattenheim Remote.lore", "Right-click block~to call TARDIS"); recipes_config.set("shaped.Artron Storage Cell.lore", "Charge Level~0"); // if (!recipes_config.contains("shaped.TARDIS Remote Key")) { recipes_config.set("shaped.TARDIS Remote Key.easy_shape", "RCR,-K-,-T-"); recipes_config.set("shaped.TARDIS Remote Key.easy_ingredients.R", "REDSTONE"); recipes_config.set("shaped.TARDIS Remote Key.easy_ingredients.C", "REDSTONE_COMPARATOR"); recipes_config.set("shaped.TARDIS Remote Key.easy_ingredients.K", "GOLD_NUGGET"); recipes_config.set("shaped.TARDIS Remote Key.easy_ingredients.T", "REDSTONE_TORCH_ON"); recipes_config.set("shaped.TARDIS Remote Key.hard_shape", "RCR,-K-,-T-"); recipes_config.set("shaped.TARDIS Remote Key.hard_ingredients.R", "REDSTONE"); recipes_config.set("shaped.TARDIS Remote Key.hard_ingredients.C", "REDSTONE_COMPARATOR"); recipes_config.set("shaped.TARDIS Remote Key.hard_ingredients.K", "GOLD_NUGGET"); recipes_config.set("shaped.TARDIS Remote Key.hard_ingredients.T", "MAP:1964"); recipes_config.set("shaped.TARDIS Remote Key.result", "GOLD_NUGGET"); recipes_config.set("shaped.TARDIS Remote Key.amount", 1); recipes_config.set("shaped.TARDIS Remote Key.lore", "Deadlock & unlock~Hide & rebuild"); } else if (recipes_config .getString("shaped.TARDIS Remote Key.easy_ingredients.T") .equals("REDSTONE_TORCH")) { recipes_config.set("shaped.TARDIS Remote Key.easy_ingredients.T", "REDSTONE_TORCH_ON"); } if (!recipes_config.contains("shaped.White Bow Tie")) { for (Map.Entry<String, Integer> map : colours.entrySet()) { recipes_config.set("shaped." + map.getKey() + " Bow Tie.easy_shape", "---,SWS,---"); recipes_config.set("shaped." + map.getKey() + " Bow Tie.easy_ingredients.S", "STRING"); recipes_config.set( "shaped." + map.getKey() + " Bow Tie.easy_ingredients.W", "WOOL:" + map.getValue()); recipes_config.set("shaped." + map.getKey() + " Bow Tie.hard_shape", "STS,L-L,WWW"); recipes_config.set("shaped." + map.getKey() + " Bow Tie.hard_ingredients.S", "STRING"); recipes_config.set( "shaped." + map.getKey() + " Bow Tie.hard_ingredients.T", "TRIPWIRE_HOOK"); recipes_config.set("shaped." + map.getKey() + " Bow Tie.hard_ingredients.L", "LEATHER"); recipes_config.set( "shaped." + map.getKey() + " Bow Tie.hard_ingredients.W", "WOOL:" + map.getValue()); recipes_config.set("shaped." + map.getKey() + " Bow Tie.result", "LEATHER_CHESTPLATE"); recipes_config.set("shaped." + map.getKey() + " Bow Tie.amount", 1); recipes_config.set("shaped." + map.getKey() + " Bow Tie.lore", "Bow ties are cool!"); i++; } } if (!recipes_config.contains("shaped.3-D Glasses")) { recipes_config.set("shaped.3-D Glasses.easy_shape", "---,P-P,CPM"); recipes_config.set("shaped.3-D Glasses.easy_ingredients.P", "PAPER"); recipes_config.set("shaped.3-D Glasses.easy_ingredients.C", "STAINED_GLASS_PANE:9"); recipes_config.set("shaped.3-D Glasses.easy_ingredients.M", "STAINED_GLASS_PANE:2"); recipes_config.set("shaped.3-D Glasses.hard_shape", "R-T,P-P,CPM"); recipes_config.set("shaped.3-D Glasses.hard_ingredients.R", "REDSTONE_COMPARATOR"); recipes_config.set("shaped.3-D Glasses.hard_ingredients.T", "REDSTONE_TORCH_ON"); recipes_config.set("shaped.3-D Glasses.hard_ingredients.P", "PAPER"); recipes_config.set("shaped.3-D Glasses.hard_ingredients.C", "STAINED_GLASS_PANE:9"); recipes_config.set("shaped.3-D Glasses.hard_ingredients.M", "STAINED_GLASS_PANE:2"); recipes_config.set("shaped.3-D Glasses.result", "LEATHER_HELMET"); recipes_config.set("shaped.3-D Glasses.amount", 1); recipes_config.set("shaped.3-D Glasses.lore", ""); i++; } if (!recipes_config.contains("shaped.Fob Watch")) { recipes_config.set("shaped.Fob Watch.easy_shape", "-C-,-W-,R-R"); recipes_config.set("shaped.Fob Watch.easy_ingredients.C", "MAP:1966"); recipes_config.set("shaped.Fob Watch.easy_ingredients.W", "WATCH"); recipes_config.set("shaped.Fob Watch.easy_ingredients.R", "REDSTONE"); recipes_config.set("shaped.Fob Watch.hard_shape", "-C-,IWI,R-R"); recipes_config.set("shaped.Fob Watch.hard_ingredients.C", "MAP:1966"); recipes_config.set("shaped.Fob Watch.hard_ingredients.W", "WATCH"); recipes_config.set("shaped.Fob Watch.hard_ingredients.I", "IRON_INGOT"); recipes_config.set("shaped.Fob Watch.hard_ingredients.R", "REDSTONE"); recipes_config.set("shaped.Fob Watch.result", "WATCH"); recipes_config.set("shaped.Fob Watch.amount", 1); recipes_config.set("shaped.Fob Watch.lore", ""); i++; } if (!recipes_config.contains("shaped.Jammy Dodger")) { recipes_config.set("shaped.Jammy Dodger.easy_shape", "---,WRW,---"); recipes_config.set("shaped.Jammy Dodger.easy_ingredients.W", "WHEAT"); recipes_config.set("shaped.Jammy Dodger.easy_ingredients.R", "INK_SACK:1"); recipes_config.set("shaped.Jammy Dodger.hard_shape", "---,WRW,---"); recipes_config.set("shaped.Jammy Dodger.hard_ingredients.W", "WHEAT"); recipes_config.set("shaped.Jammy Dodger.hard_ingredients.R", "INK_SACK:1"); recipes_config.set("shaped.Jammy Dodger.result", "COOKIE"); recipes_config.set("shaped.Jammy Dodger.amount", 8); recipes_config.set("shaped.Jammy Dodger.lore", ""); i++; } if (!recipes_config.contains("shaped.Fish Finger")) { recipes_config.set("shaped.Fish Finger.easy_shape", "-B-,-F-,-B-"); recipes_config.set("shaped.Fish Finger.easy_ingredients.B", "BREAD"); recipes_config.set("shaped.Fish Finger.easy_ingredients.F", "RAW_FISH"); recipes_config.set("shaped.Fish Finger.hard_shape", "-B-,-F-,-B-"); recipes_config.set("shaped.Fish Finger.hard_ingredients.B", "BREAD"); recipes_config.set("shaped.Fish Finger.hard_ingredients.F", "RAW_FISH"); recipes_config.set("shaped.Fish Finger.result", "COOKED_FISH"); recipes_config.set("shaped.Fish Finger.amount", 3); recipes_config.set("shaped.Fish Finger.lore", "Best eaten with custard!"); i++; } if (!recipes_config.contains("shapeless.Bowl of Custard")) { recipes_config.set("shapeless.Bowl of Custard.recipe", "BOWL,MILK_BUCKET,EGG"); recipes_config.set("shapeless.Bowl of Custard.result", "MUSHROOM_SOUP"); recipes_config.set("shapeless.Bowl of Custard.amount", 1); recipes_config.set("shapeless.Bowl of Custard.lore", ""); i++; } if (!recipes_config.contains("shapeless.Vanilla Jelly Baby")) { for (Map.Entry<String, Integer> map : flavours.entrySet()) { recipes_config.set( "shapeless." + map.getKey() + " Jelly Baby.recipe", "SUGAR,SLIME_BALL,INK_SACK:" + map.getValue()); recipes_config.set("shapeless." + map.getKey() + " Jelly Baby.result", "MELON"); recipes_config.set("shapeless." + map.getKey() + " Jelly Baby.amount", 4); recipes_config.set("shapeless." + map.getKey() + " Jelly Baby.lore", ""); i++; } } if (!recipes_config.contains("shaped.TARDIS Randomiser Circuit")) { recipes_config.set("shaped.TARDIS Randomiser Circuit.easy_shape", "-D-,NCE,-W-"); recipes_config.set("shaped.TARDIS Randomiser Circuit.easy_ingredients.D", "DIRT"); recipes_config.set("shaped.TARDIS Randomiser Circuit.easy_ingredients.N", "NETHERRACK"); recipes_config.set("shaped.TARDIS Randomiser Circuit.easy_ingredients.C", "COMPASS"); recipes_config.set("shaped.TARDIS Randomiser Circuit.easy_ingredients.E", "ENDER_STONE"); recipes_config.set("shaped.TARDIS Randomiser Circuit.easy_ingredients.W", "WATER_BUCKET"); recipes_config.set("shaped.TARDIS Randomiser Circuit.hard_shape", "-D-,NCE,-W-"); recipes_config.set("shaped.TARDIS Randomiser Circuit.hard_ingredients.D", "DIRT"); recipes_config.set("shaped.TARDIS Randomiser Circuit.hard_ingredients.N", "NETHERRACK"); recipes_config.set("shaped.TARDIS Randomiser Circuit.hard_ingredients.C", "COMPASS"); recipes_config.set("shaped.TARDIS Randomiser Circuit.hard_ingredients.E", "ENDER_STONE"); recipes_config.set("shaped.TARDIS Randomiser Circuit.hard_ingredients.W", "WATER_BUCKET"); recipes_config.set("shaped.TARDIS Randomiser Circuit.result", "MAP:1980"); recipes_config.set("shaped.TARDIS Randomiser Circuit.amount", 1); recipes_config.set("shaped.TARDIS Randomiser Circuit.lore", "Uses left~50"); i++; } if (!recipes_config.contains("shaped.TARDIS Invisibility Circuit")) { recipes_config.set("shaped.TARDIS Invisibility Circuit.easy_shape", "-D-,P-E,-W-"); recipes_config.set("shaped.TARDIS Invisibility Circuit.easy_ingredients.D", "DIAMOND"); recipes_config.set("shaped.TARDIS Invisibility Circuit.easy_ingredients.P", "MAP:1978"); recipes_config.set("shaped.TARDIS Invisibility Circuit.easy_ingredients.E", "EMERALD"); recipes_config.set("shaped.TARDIS Invisibility Circuit.easy_ingredients.W", "POTION:8206"); recipes_config.set("shaped.TARDIS Invisibility Circuit.hard_shape", "-D-,P-E,-W-"); recipes_config.set("shaped.TARDIS Invisibility Circuit.hard_ingredients.D", "DIAMOND"); recipes_config.set("shaped.TARDIS Invisibility Circuit.hard_ingredients.P", "MAP:1978"); recipes_config.set("shaped.TARDIS Invisibility Circuit.hard_ingredients.E", "EMERALD"); recipes_config.set("shaped.TARDIS Invisibility Circuit.hard_ingredients.W", "POTION:8270"); recipes_config.set("shaped.TARDIS Invisibility Circuit.result", "MAP:1981"); recipes_config.set("shaped.TARDIS Invisibility Circuit.amount", 1); recipes_config.set("shaped.TARDIS Invisibility Circuit.lore", "Uses left~5"); i++; } if (!recipes_config.contains("shaped.Painter Circuit")) { recipes_config.set("shaped.Painter Circuit.easy_shape", "-I-,DGD,-I-"); recipes_config.set("shaped.Painter Circuit.easy_ingredients.I", "INK_SACK:0"); recipes_config.set("shaped.Painter Circuit.easy_ingredients.D", "INK_SACK:5"); recipes_config.set("shaped.Painter Circuit.easy_ingredients.G", "GOLD_NUGGET"); recipes_config.set("shaped.Painter Circuit.hard_shape", "-I-,DGD,-I-"); recipes_config.set("shaped.Painter Circuit.hard_ingredients.I", "INK_SACK:0"); recipes_config.set("shaped.Painter Circuit.hard_ingredients.D", "INK_SACK:5"); recipes_config.set("shaped.Painter Circuit.hard_ingredients.G", "GOLD_BLOCK"); recipes_config.set("shaped.Painter Circuit.result", "MAP:1979"); recipes_config.set("shaped.Painter Circuit.amount", 1); recipes_config.set("shaped.Painter Circuit.lore", ""); i++; } else { // fix the hard recipe if necessary if (recipes_config.get("shaped.Painter Circuit.hard_shape").equals("-B-,-F-,-B-")) { recipes_config.set("shaped.Painter Circuit.hard_shape", "-I-,DGD,-I-"); } } if (!recipes_config.contains("shapeless.Painter Upgrade")) { recipes_config.set("shapeless.Painter Upgrade.recipe", "BLAZE_ROD,MAP:1979"); recipes_config.set("shapeless.Painter Upgrade.result", "BLAZE_ROD"); recipes_config.set("shapeless.Painter Upgrade.amount", 1); recipes_config.set("shapeless.Painter Upgrade.lore", ""); i++; } if (!recipes_config.contains("shaped.Ignite Circuit")) { recipes_config.set("shaped.Ignite Circuit.easy_shape", "-N-,NFN,-N-"); recipes_config.set("shaped.Ignite Circuit.easy_ingredients.N", "NETHERRACK"); recipes_config.set("shaped.Ignite Circuit.easy_ingredients.F", "FLINT_AND_STEEL"); recipes_config.set("shaped.Ignite Circuit.hard_shape", "LN-,NFN,-NL"); recipes_config.set("shaped.Ignite Circuit.hard_ingredients.N", "NETHERRACK"); recipes_config.set("shaped.Ignite Circuit.hard_ingredients.F", "FLINT_AND_STEEL"); recipes_config.set("shaped.Ignite Circuit.hard_ingredients.L", "LAVA_BUCKET"); recipes_config.set("shaped.Ignite Circuit.result", "MAP:1982"); recipes_config.set("shaped.Ignite Circuit.amount", 1); recipes_config.set("shaped.Ignite Circuit.lore", ""); i++; } if (!recipes_config.contains("shapeless.Ignite Upgrade")) { recipes_config.set("shapeless.Ignite Upgrade.recipe", "BLAZE_ROD,MAP:1982"); recipes_config.set("shapeless.Ignite Upgrade.result", "BLAZE_ROD"); recipes_config.set("shapeless.Ignite Upgrade.amount", 1); recipes_config.set("shapeless.Ignite Upgrade.lore", ""); i++; } if (!recipes_config.contains("shaped.TARDIS Artron Furnace")) { recipes_config.set("shaped.TARDIS Artron Furnace.easy_shape", "---,OFO,RRR"); recipes_config.set("shaped.TARDIS Artron Furnace.easy_ingredients.O", "OBSIDIAN"); recipes_config.set("shaped.TARDIS Artron Furnace.easy_ingredients.F", "FURNACE"); recipes_config.set("shaped.TARDIS Artron Furnace.easy_ingredients.R", "REDSTONE"); recipes_config.set("shaped.TARDIS Artron Furnace.hard_shape", "---,OFO,RRR"); recipes_config.set("shaped.TARDIS Artron Furnace.hard_ingredients.O", "OBSIDIAN"); recipes_config.set("shaped.TARDIS Artron Furnace.hard_ingredients.F", "FURNACE"); recipes_config.set("shaped.TARDIS Artron Furnace.hard_ingredients.R", "REDSTONE"); recipes_config.set("shaped.TARDIS Artron Furnace.result", "FURNACE"); recipes_config.set("shaped.TARDIS Artron Furnace.amount", 1); recipes_config.set("shaped.TARDIS Artron Furnace.lore", ""); i++; } for (Map.Entry<String, Integer> uses : damage.entrySet()) { if (recipes_config.getString(uses.getKey()).isEmpty()) { recipes_config.set(uses.getKey(), "Uses left~" + uses.getValue()); } } try { recipes_config.save(new File(plugin.getDataFolder(), "recipes.yml")); if (i > 0) { plugin .getConsole() .sendMessage( plugin.getPluginName() + "Added " + ChatColor.AQUA + i + ChatColor.RESET + " new items to recipes.yml"); } String key = recipes_config.getString("shaped.TARDIS Key.result"); if (!key.equals(plugin.getConfig().getString("preferences.key"))) { plugin .getConsole() .sendMessage( plugin.getPluginName() + "The TARDIS Key recipe result (recipes.yml) does not match the configured key preference (config.yml)"); } String r_key_5 = recipes_config.getString("shaped.TARDIS Remote Key.easy_ingredients.K"); if (r_key_5 != null && !key.equals(r_key_5)) { plugin .getConsole() .sendMessage( plugin.getPluginName() + "The TARDIS Key ingredient (" + r_key_5 + ") in the 'TARDIS Remote Key' recipe does not match the crafting result of the 'TARDIS Key' recipe (" + key + ") - they should be the same!"); } } catch (IOException io) { plugin.debug("Could not save recipes.yml, " + io); } }
public TARDISbPermissionsHandler(TARDIS plugin) { this.plugin = plugin; this.permissionsFile = new File(plugin.getDataFolder(), "permissions.txt"); }
/** * Listens for player clicking blocks. If the player's name is contained in various tracking * HashMaps then we know that they are trying to create a TARDIS area. * * @param event a player clicking a block */ @EventHandler(priority = EventPriority.MONITOR) public void onAreaInteract(PlayerInteractEvent event) { final Player player = event.getPlayer(); final String playerNameStr = player.getName(); Block block = event.getClickedBlock(); if (block != null) { if (plugin.trackPreset.containsKey(playerNameStr)) { String[] split = plugin.trackPreset.get(playerNameStr).split(":"); String name = split[0]; String bool = split[1]; Location block_loc = block.getLocation(); World w = block_loc.getWorld(); int fx = block_loc.getBlockX(); int fy = block_loc.getBlockY(); int fz = block_loc.getBlockZ(); player.sendMessage(plugin.pluginName + "Scanning 3 x 3 x 4 area..."); StringBuilder sb_id = new StringBuilder("["); StringBuilder sb_data = new StringBuilder("["); StringBuilder sb_stain_id = new StringBuilder("["); StringBuilder sb_stain_data = new StringBuilder("["); StringBuilder sb_glass_id = new StringBuilder("["); StringBuilder sb_glass_data = new StringBuilder("["); for (int c = 0; c < 10; c++) { sb_id.append("["); sb_data.append("["); sb_stain_id.append("["); sb_stain_data.append("["); sb_glass_id.append("["); sb_glass_data.append("["); for (int y = fy; y < (fy + 4); y++) { Block b = w.getBlockAt(fx + orderx[c], y, fz + orderz[c]); int id = b.getTypeId(); if (id == 19) { id = 0; // convert sponge to air } byte data = b.getData(); if (y == (fy + 3)) { sb_id.append(id); sb_data.append(data); if (not_glass.contains(id)) { sb_stain_id.append(id); sb_stain_data.append(data); sb_glass_id.append(id); sb_glass_data.append(data); } else { sb_stain_id.append(95); byte colour = plugin.lookup.getStain().get(id); if (colour == -1) { // use the same data as the original block colour = data; } sb_stain_data.append(colour); // get the appropiately coloured stained glass sb_glass_id.append(20); sb_glass_data.append(0); } } else { sb_id.append(id).append(","); sb_data.append(data).append(","); if (not_glass.contains(id)) { sb_stain_id.append(id).append(","); sb_stain_data.append(data).append(","); sb_glass_id.append(id).append(","); sb_glass_data.append(data).append(","); } else { sb_stain_id.append(95).append(","); byte colour = plugin.lookup.getStain().get(id); if (colour == -1) { // use the same data as the original block colour = data; } sb_stain_data .append(colour) .append(","); // get the appropiately coloured stained glass sb_glass_id.append(20).append(","); sb_glass_data.append(0).append(","); } } } if (c == 9) { sb_id.append("]"); sb_data.append("]"); sb_stain_id.append("]"); sb_stain_data.append("]"); sb_glass_id.append("]"); sb_glass_data.append("]"); } else { sb_id.append("],"); sb_data.append("],"); sb_stain_id.append("],"); sb_stain_data.append("],"); sb_glass_id.append("],"); sb_glass_data.append("],"); } } sb_id.append("]"); sb_data.append("]"); sb_stain_id.append("]"); sb_stain_data.append("]"); sb_glass_id.append("]"); sb_glass_data.append("]"); String ids = sb_id.toString(); String datas = sb_data.toString(); String stain_ids = sb_stain_id.toString(); String stain_datas = sb_stain_data.toString(); String glass_ids = sb_glass_id.toString(); String glass_datas = sb_glass_data.toString(); String filename = "custom_preset_" + name + ".txt"; String file = plugin.getDataFolder() + File.separator + filename; try { BufferedWriter bw = new BufferedWriter(new FileWriter(file, false)); bw.write("##start custom blueprint"); bw.newLine(); bw.write("#id"); bw.newLine(); bw.write(ids); bw.newLine(); bw.write("#data"); bw.newLine(); bw.write(datas); bw.newLine(); bw.write("##start custom stain"); bw.newLine(); bw.write("#id"); bw.newLine(); bw.write(stain_ids); bw.newLine(); bw.write("#data"); bw.newLine(); bw.write(stain_datas); bw.newLine(); bw.write("##start custom glass"); bw.newLine(); bw.write("#id"); bw.newLine(); bw.write(glass_ids); bw.newLine(); bw.write("#data"); bw.newLine(); bw.write(glass_datas); bw.newLine(); bw.write("##sign text - first line is player's name"); bw.newLine(); bw.write("#second line"); bw.newLine(); bw.write(name); bw.newLine(); bw.write("#third line"); bw.newLine(); bw.write("PRESET"); bw.newLine(); bw.write( "#is the preset asymmetrical? for example are some of the corners different to others"); bw.newLine(); bw.write(bool); bw.close(); } catch (IOException e) { plugin.debug("Could not create and write to " + filename + "! " + e.getMessage()); } plugin.trackPreset.remove(playerNameStr); player.sendMessage( plugin.pluginName + "Scanning complete! " + filename + " written to the plugins/TARDIS folder."); } } }