Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.39 KB | None | 0 0
  1. package com.bukkit.Hohahihehu.RuneCaster;
  2.  
  3. import org.bukkit.ChatColor;
  4. import org.bukkit.Server;
  5. import org.bukkit.World;
  6. import org.bukkit.entity.Player;
  7.  
  8. public class RuneCasterEnchanter {
  9.  
  10.     int tooltype;
  11.     String toolname;
  12.     String runename;
  13.     String playerenchants;
  14.     String playercharges;
  15.     String enchantname;
  16.  
  17.     // 0 = Sword
  18.     // 1 = Shovel
  19.     // 2 = Pickaxe
  20.     // 3 = Axe
  21.     // 4 = Hoe
  22.     // 5 = Bow
  23.  
  24.     public void EnchantTool(World world, Player player, Server server,
  25.             int runeid, int itemid) {
  26.         // Determine Tool Type
  27.         if (itemid == 267 || itemid == 276 || itemid == 283) {
  28.             tooltype = 0;
  29.             toolname = "Sword";
  30.         } else if (itemid == 256 || itemid == 277 || itemid == 284) {
  31.             tooltype = 1;
  32.             toolname = "Shovel";
  33.         } else if (itemid == 257 || itemid == 278 || itemid == 285) {
  34.             tooltype = 2;
  35.             toolname = "Pickaxe";
  36.         } else if (itemid == 258 || itemid == 279 || itemid == 286) {
  37.             tooltype = 3;
  38.             toolname = "Axe";
  39.         } else if (itemid >= 292 && itemid <= 294) {
  40.             tooltype = 4;
  41.             toolname = "Hoe";
  42.         } else if (itemid == 261) {
  43.             tooltype = 5;
  44.             toolname = "Bow";
  45.         }
  46.         // Determine name of rune
  47.         runename = RuneMaps.RuneNameTable.get((runeid % 100));
  48.  
  49.         // Draw player's current enchants
  50.         if (RuneMaps.PlayerEnchantTable.containsKey(player)) {
  51.             playerenchants = RuneMaps.PlayerEnchantTable.get(player);
  52.         } else {
  53.             RuneMaps.PlayerEnchantTable.put(player,
  54.                     "Blank,Blank,Blank,Blank,Blank,Blank");
  55.             playerenchants = RuneMaps.PlayerEnchantTable.get(player);
  56.         }
  57.  
  58.         // Draw player's enchant charges
  59.         if (RuneMaps.PlayerEnchantCharges.containsKey(player)) {
  60.             playercharges = RuneMaps.PlayerEnchantCharges.get(player);
  61.         } else {
  62.             RuneMaps.PlayerEnchantCharges.put(player, "-1,-1,-1,-1,-1,-1");
  63.         }
  64.  
  65.         // Check if enchant is valid
  66.         enchantname = toolname + "-" + runename;
  67.         if (RuneMaps.ValidEnchantTable.containsKey(enchantname)) {
  68.             if (RuneMaps.ValidEnchantTable.get(enchantname)) {
  69.                 // Various Permissions Checks
  70.                 if (!RuneCasterLoader.EnchantsAllowed) {
  71.                     player.sendMessage(ChatColor.GRAY
  72.                             + "Any attempts to inscribe the rune fail. It doesn't appear you could enchant anything.");
  73.                 } else if (!RuneCasterLoader.SwordChantAllowed
  74.                         && toolname == "Sword") {
  75.                     player.sendMessage(ChatColor.GRAY
  76.                             + "Your sword refuses to accept any attempts to inscribe it.");
  77.                     return;
  78.                 } else if (!RuneCasterLoader.ShovelChantAllowed
  79.                         && toolname == "Shovel") {
  80.                     player.sendMessage(ChatColor.GRAY
  81.                             + "Your shovel refuses to accept any attempts to inscribe it.");
  82.                     return;
  83.                 } else if (!RuneCasterLoader.PickaxeChantAllowed
  84.                         && toolname == "Pickaxe") {
  85.                     player.sendMessage(ChatColor.GRAY
  86.                             + "Your pickaxe refuses to accept any attempts to inscribe it.");
  87.                     return;
  88.                 } else if (!RuneCasterLoader.AxeChantAllowed
  89.                         && toolname == "Axe") {
  90.                     player.sendMessage(ChatColor.GRAY
  91.                             + "Your axe refuses to accept any attempts to inscribe it.");
  92.                     return;
  93.                 } else if (!RuneCasterLoader.HoeChantAllowed
  94.                         && toolname == "Hoe") {
  95.                     player.sendMessage(ChatColor.GRAY
  96.                             + "Your hoe refuses to accept any attempts to inscribe it. (Slap it)");
  97.                     return;
  98.                 } else if (!RuneCasterLoader.BowChantAllowed
  99.                         && toolname == "Bow") {
  100.                     player.sendMessage(ChatColor.GRAY
  101.                             + "Your bow refuses to accept any attempts to inscribe it.");
  102.                     return;
  103.                 } else if (!RunePermissionsCheck(runeid % 100)) {
  104.                     player.sendMessage(ChatColor.GRAY
  105.                             + "That rune seems blocked by outside forces. Maybe you should try another.");
  106.                     return;
  107.                 }
  108.                 // Apply Enchant
  109.                 String[] splitplayerenchants;
  110.                 splitplayerenchants = playerenchants.split("\\,");
  111.                 splitplayerenchants[tooltype] = runename;
  112.                 playerenchants = "";
  113.                 for (int i = 0; i < 6; i++) {
  114.                     playerenchants = playerenchants + splitplayerenchants[i];
  115.                     if (i != 5) {
  116.                         playerenchants = playerenchants + ",";
  117.                     }
  118.                 }
  119.                 RuneMaps.PlayerEnchantTable.put(player, playerenchants);
  120.                 player.sendMessage(ChatColor.GRAY + "You inscribe a "
  121.                         + runename + " rune into your " + toolname + ".");
  122.             } else {
  123.                 player.sendMessage(ChatColor.GRAY + "You cannot place a "
  124.                         + runename + " rune on that tool.");
  125.             }
  126.         } else {
  127.             return;
  128.         }
  129.     }
  130.  
  131.     public boolean RunePermissionsCheck(int runeid) {
  132.         return RuneMaps.RunePermissionTable.get(runeid % 100);
  133.     }
  134.  
  135. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement