Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.bukkit.Hohahihehu.RuneCaster;
- import org.bukkit.ChatColor;
- import org.bukkit.Server;
- import org.bukkit.World;
- import org.bukkit.entity.Player;
- public class RuneCasterEnchanter {
- int tooltype;
- String toolname;
- String runename;
- String playerenchants;
- String playercharges;
- String enchantname;
- // 0 = Sword
- // 1 = Shovel
- // 2 = Pickaxe
- // 3 = Axe
- // 4 = Hoe
- // 5 = Bow
- public void EnchantTool(World world, Player player, Server server,
- int runeid, int itemid) {
- // Determine Tool Type
- if (itemid == 267 || itemid == 276 || itemid == 283) {
- tooltype = 0;
- toolname = "Sword";
- } else if (itemid == 256 || itemid == 277 || itemid == 284) {
- tooltype = 1;
- toolname = "Shovel";
- } else if (itemid == 257 || itemid == 278 || itemid == 285) {
- tooltype = 2;
- toolname = "Pickaxe";
- } else if (itemid == 258 || itemid == 279 || itemid == 286) {
- tooltype = 3;
- toolname = "Axe";
- } else if (itemid >= 292 && itemid <= 294) {
- tooltype = 4;
- toolname = "Hoe";
- } else if (itemid == 261) {
- tooltype = 5;
- toolname = "Bow";
- }
- // Determine name of rune
- runename = RuneMaps.RuneNameTable.get((runeid % 100));
- // Draw player's current enchants
- if (RuneMaps.PlayerEnchantTable.containsKey(player)) {
- playerenchants = RuneMaps.PlayerEnchantTable.get(player);
- } else {
- RuneMaps.PlayerEnchantTable.put(player,
- "Blank,Blank,Blank,Blank,Blank,Blank");
- playerenchants = RuneMaps.PlayerEnchantTable.get(player);
- }
- // Draw player's enchant charges
- if (RuneMaps.PlayerEnchantCharges.containsKey(player)) {
- playercharges = RuneMaps.PlayerEnchantCharges.get(player);
- } else {
- RuneMaps.PlayerEnchantCharges.put(player, "-1,-1,-1,-1,-1,-1");
- }
- // Check if enchant is valid
- enchantname = toolname + "-" + runename;
- if (RuneMaps.ValidEnchantTable.containsKey(enchantname)) {
- if (RuneMaps.ValidEnchantTable.get(enchantname)) {
- // Various Permissions Checks
- if (!RuneCasterLoader.EnchantsAllowed) {
- player.sendMessage(ChatColor.GRAY
- + "Any attempts to inscribe the rune fail. It doesn't appear you could enchant anything.");
- } else if (!RuneCasterLoader.SwordChantAllowed
- && toolname == "Sword") {
- player.sendMessage(ChatColor.GRAY
- + "Your sword refuses to accept any attempts to inscribe it.");
- return;
- } else if (!RuneCasterLoader.ShovelChantAllowed
- && toolname == "Shovel") {
- player.sendMessage(ChatColor.GRAY
- + "Your shovel refuses to accept any attempts to inscribe it.");
- return;
- } else if (!RuneCasterLoader.PickaxeChantAllowed
- && toolname == "Pickaxe") {
- player.sendMessage(ChatColor.GRAY
- + "Your pickaxe refuses to accept any attempts to inscribe it.");
- return;
- } else if (!RuneCasterLoader.AxeChantAllowed
- && toolname == "Axe") {
- player.sendMessage(ChatColor.GRAY
- + "Your axe refuses to accept any attempts to inscribe it.");
- return;
- } else if (!RuneCasterLoader.HoeChantAllowed
- && toolname == "Hoe") {
- player.sendMessage(ChatColor.GRAY
- + "Your hoe refuses to accept any attempts to inscribe it. (Slap it)");
- return;
- } else if (!RuneCasterLoader.BowChantAllowed
- && toolname == "Bow") {
- player.sendMessage(ChatColor.GRAY
- + "Your bow refuses to accept any attempts to inscribe it.");
- return;
- } else if (!RunePermissionsCheck(runeid % 100)) {
- player.sendMessage(ChatColor.GRAY
- + "That rune seems blocked by outside forces. Maybe you should try another.");
- return;
- }
- // Apply Enchant
- String[] splitplayerenchants;
- splitplayerenchants = playerenchants.split("\\,");
- splitplayerenchants[tooltype] = runename;
- playerenchants = "";
- for (int i = 0; i < 6; i++) {
- playerenchants = playerenchants + splitplayerenchants[i];
- if (i != 5) {
- playerenchants = playerenchants + ",";
- }
- }
- RuneMaps.PlayerEnchantTable.put(player, playerenchants);
- player.sendMessage(ChatColor.GRAY + "You inscribe a "
- + runename + " rune into your " + toolname + ".");
- } else {
- player.sendMessage(ChatColor.GRAY + "You cannot place a "
- + runename + " rune on that tool.");
- }
- } else {
- return;
- }
- }
- public boolean RunePermissionsCheck(int runeid) {
- return RuneMaps.RunePermissionTable.get(runeid % 100);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement