Guest User

Untitled

a guest
Jun 22nd, 2020
21
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package freyja_pack;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.HashMap;
  5. import java.util.List;
  6. import java.util.Stack;
  7.  
  8. import org.bukkit.Bukkit;
  9. import org.bukkit.Material;
  10. import org.bukkit.command.Command;
  11. import org.bukkit.command.CommandSender;
  12. import org.bukkit.enchantments.Enchantment;
  13. import org.bukkit.entity.HumanEntity;
  14. import org.bukkit.entity.Player;
  15. import org.bukkit.entity.Villager;
  16. import org.bukkit.event.EventHandler;
  17. import org.bukkit.event.Listener;
  18. import org.bukkit.event.entity.VillagerCareerChangeEvent;
  19. import org.bukkit.event.inventory.InventoryClickEvent;
  20. import org.bukkit.event.player.PlayerItemHeldEvent;
  21. import org.bukkit.event.player.PlayerMoveEvent;
  22. import org.bukkit.event.player.PlayerPickupItemEvent;
  23. import org.bukkit.event.player.PlayerSwapHandItemsEvent;
  24. import org.bukkit.inventory.ItemStack;
  25. import org.bukkit.inventory.MerchantRecipe;
  26. import org.bukkit.plugin.java.JavaPlugin;
  27. import org.bukkit.potion.PotionEffect;
  28. import org.bukkit.potion.PotionEffectType;
  29. import org.bukkit.scheduler.BukkitScheduler;
  30.  
  31. import net.md_5.bungee.api.ChatColor;
  32.  
  33. public class freyja_class extends JavaPlugin implements Listener {
  34.  
  35. public ArrayList<Player> spp = new ArrayList<Player>();
  36.  
  37. public custom_item ci;
  38. public custom_mob cm;
  39. public static freyja_class plugin;
  40.  
  41. public HashMap<Integer, ArrayList<ItemStack>> A = new HashMap<Integer, ArrayList<ItemStack>>();
  42. public HashMap<Integer, ItemStack> W = new HashMap<Integer, ItemStack>();
  43.  
  44.  
  45. public void Ranked_Gear() {
  46.  
  47. Bukkit.broadcastMessage("B4");
  48. Material LH = Material.LEATHER_HELMET;
  49. Material LC = Material.LEATHER_CHESTPLATE;
  50. Material LL = Material.LEATHER_LEGGINGS;
  51. Material LB = Material.LEATHER_BOOTS;
  52.  
  53. Material CH = Material.CHAINMAIL_HELMET;
  54. Material CC = Material.CHAINMAIL_CHESTPLATE;
  55. Material CL = Material.CHAINMAIL_LEGGINGS;
  56. Material CB = Material.CHAINMAIL_BOOTS;
  57.  
  58. Material GH = Material.GOLDEN_HELMET;
  59. Material GC = Material.GOLDEN_CHESTPLATE;
  60. Material GL = Material.GOLDEN_LEGGINGS;
  61. Material GB = Material.GOLDEN_BOOTS;
  62.  
  63. Material IH = Material.IRON_HELMET;
  64. Material IC = Material.IRON_CHESTPLATE;
  65. Material IL = Material.IRON_LEGGINGS;
  66. Material IB = Material.IRON_BOOTS;
  67.  
  68. Material DH = Material.DIAMOND_HELMET;
  69. Material DC = Material.DIAMOND_CHESTPLATE;
  70. Material DL = Material.DIAMOND_LEGGINGS;
  71. Material DB = Material.DIAMOND_BOOTS;
  72.  
  73. Enchantment aquaaffinity = Enchantment.WATER_WORKER;
  74. Enchantment respiration = Enchantment.OXYGEN;
  75. Enchantment depthstrider = Enchantment.DEPTH_STRIDER;
  76. Enchantment featherfalling = Enchantment.PROTECTION_FALL;
  77. Enchantment frostwalker = Enchantment.FROST_WALKER;
  78. Enchantment blastprotection = Enchantment.PROTECTION_EXPLOSIONS;
  79. Enchantment fireprotection = Enchantment.PROTECTION_FIRE;
  80. Enchantment projectileprotection = Enchantment.PROTECTION_PROJECTILE;
  81. Enchantment protection = Enchantment.PROTECTION_ENVIRONMENTAL;
  82. Enchantment thorns = Enchantment.THORNS;
  83. Enchantment unbreaking = Enchantment.DURABILITY;
  84.  
  85. ItemStack H = null;
  86. ItemStack C = null;
  87. ItemStack L = null;
  88. ItemStack B = null;
  89.  
  90. ArrayList<Enchantment> HE = new ArrayList<Enchantment>();
  91. ArrayList<Integer> HEL = new ArrayList<Integer>();
  92.  
  93. ArrayList<Enchantment> CE = new ArrayList<Enchantment>();
  94. ArrayList<Integer> CEL = new ArrayList<Integer>();
  95.  
  96. ArrayList<Enchantment> LE = new ArrayList<Enchantment>();
  97. ArrayList<Integer> LEL = new ArrayList<Integer>();
  98.  
  99. ArrayList<Enchantment> BE = new ArrayList<Enchantment>();
  100. ArrayList<Integer> BEL = new ArrayList<Integer>();
  101.  
  102. ArrayList<ItemStack> armor = new ArrayList<ItemStack>();
  103.  
  104. //Rank A
  105. HE.add(unbreaking);
  106. HEL.add(10);
  107. HE.add(protection);
  108. HEL.add(10);
  109. H = ci.make(DH, null, null, HE, HEL);
  110.  
  111. CE.add(unbreaking);
  112. CEL.add(10);
  113. CE.add(protection);
  114. CEL.add(10);
  115. C = ci.make(DC, null, null, CE, CEL);
  116.  
  117. LE.add(unbreaking);
  118. LEL.add(10);
  119. LE.add(protection);
  120. LEL.add(10);
  121. L = ci.make(DL, null, null, LE, LEL);
  122.  
  123. BE.add(unbreaking);
  124. BEL.add(10);
  125. BE.add(protection);
  126. BEL.add(10);
  127. B = ci.make(DB, null, null, BE, BEL);
  128.  
  129. armor.add(H);
  130. armor.add(C);
  131. armor.add(L);
  132. armor.add(B);
  133.  
  134. A.put(100, armor);
  135.  
  136. HE.clear();
  137. HEL.clear();
  138. CE.clear();
  139. CEL.clear();
  140. LE.clear();
  141. LEL.clear();
  142. BE.clear();
  143. BEL.clear();
  144. armor.clear();
  145.  
  146. //Rank B
  147. HE.add(unbreaking);
  148. HEL.add(10);
  149. HE.add(protection);
  150. HEL.add(10);
  151. H = ci.make(IH, null, null, HE, HEL);
  152.  
  153. CE.add(unbreaking);
  154. CEL.add(10);
  155. CE.add(protection);
  156. CEL.add(10);
  157. C = ci.make(IC, null, null, CE, CEL);
  158.  
  159. LE.add(unbreaking);
  160. LEL.add(10);
  161. LE.add(protection);
  162. LEL.add(10);
  163. L = ci.make(IL, null, null, LE, LEL);
  164.  
  165. BE.add(unbreaking);
  166. BEL.add(10);
  167. BE.add(protection);
  168. BEL.add(10);
  169. B = ci.make(IB, null, null, BE, BEL);
  170.  
  171. armor.add(H);
  172. armor.add(C);
  173. armor.add(L);
  174. armor.add(B);
  175.  
  176. for(int a = 95; a <= 99; a++) {A.put(a, armor);}
  177.  
  178. HE.clear();
  179. HEL.clear();
  180. CE.clear();
  181. CEL.clear();
  182. LE.clear();
  183. LEL.clear();
  184. BE.clear();
  185. BEL.clear();
  186. armor.clear();
  187.  
  188. //Rank C
  189. HE.add(unbreaking);
  190. HEL.add(10);
  191. HE.add(protection);
  192. HEL.add(10);
  193. H = ci.make(GH, null, null, HE, HEL);
  194.  
  195. CE.add(unbreaking);
  196. CEL.add(10);
  197. CE.add(protection);
  198. CEL.add(10);
  199. C = ci.make(GC, null, null, CE, CEL);
  200.  
  201. LE.add(unbreaking);
  202. LEL.add(10);
  203. LE.add(protection);
  204. LEL.add(10);
  205. L = ci.make(GL, null, null, LE, LEL);
  206.  
  207. BE.add(unbreaking);
  208. BEL.add(10);
  209. BE.add(protection);
  210. BEL.add(10);
  211. B = ci.make(GB, null, null, BE, BEL);
  212.  
  213. armor.add(H);
  214. armor.add(C);
  215. armor.add(L);
  216. armor.add(B);
  217.  
  218. for(int a = 85; a <= 95; a++) {A.put(a, armor);}
  219.  
  220. HE.clear();
  221. HEL.clear();
  222. CE.clear();
  223. CEL.clear();
  224. LE.clear();
  225. LEL.clear();
  226. BE.clear();
  227. BEL.clear();
  228. armor.clear();
  229.  
  230. //Rank D
  231. HE.add(unbreaking);
  232. HEL.add(10);
  233. HE.add(protection);
  234. HEL.add(10);
  235. H = ci.make(CH, null, null, HE, HEL);
  236.  
  237. CE.add(unbreaking);
  238. CEL.add(10);
  239. CE.add(protection);
  240. CEL.add(10);
  241. C = ci.make(CC, null, null, CE, CEL);
  242.  
  243. LE.add(unbreaking);
  244. LEL.add(10);
  245. LE.add(protection);
  246. LEL.add(10);
  247. L = ci.make(CL, null, null, LE, LEL);
  248.  
  249. BE.add(unbreaking);
  250. BEL.add(10);
  251. BE.add(protection);
  252. BEL.add(10);
  253. B = ci.make(CB, null, null, BE, BEL);
  254.  
  255. armor.add(H);
  256. armor.add(C);
  257. armor.add(L);
  258. armor.add(B);
  259.  
  260. for(int a = 65; a <= 85; a++) {A.put(a, armor);}
  261.  
  262. HE.clear();
  263. HEL.clear();
  264. CE.clear();
  265. CEL.clear();
  266. LE.clear();
  267. LEL.clear();
  268. BE.clear();
  269. BEL.clear();
  270. armor.clear();
  271.  
  272. //Rank F
  273. HE.add(unbreaking);
  274. HEL.add(10);
  275. HE.add(protection);
  276. HEL.add(10);
  277. H = ci.make(LH, null, null, HE, HEL);
  278.  
  279. CE.add(unbreaking);
  280. CEL.add(10);
  281. CE.add(protection);
  282. CEL.add(10);
  283. C = ci.make(LC, null, null, CE, CEL);
  284.  
  285. LE.add(unbreaking);
  286. LEL.add(10);
  287. LE.add(protection);
  288. LEL.add(10);
  289. L = ci.make(LL, null, null, LE, LEL);
  290.  
  291. BE.add(unbreaking);
  292. BEL.add(10);
  293. BE.add(protection);
  294. BEL.add(10);
  295. B = ci.make(LB, null, null, BE, BEL);
  296.  
  297. armor.add(H);
  298. armor.add(C);
  299. armor.add(L);
  300. armor.add(B);
  301.  
  302. for(int a = 0; a <= 65; a++) {
  303. Bukkit.broadcastMessage(a + " " + armor.get(0).getType().name());
  304. A.put(a, armor);
  305. Bukkit.broadcastMessage(A.get(65).get(0).getType().name());
  306. }
  307.  
  308. HE.clear();
  309. HEL.clear();
  310. CE.clear();
  311. CEL.clear();
  312. LE.clear();
  313. LEL.clear();
  314. BE.clear();
  315. BEL.clear();
  316. armor.clear();
  317.  
  318. Bukkit.broadcastMessage("AFTER");
  319. }
  320.  
  321. public void onEnable() {
  322. this.getServer().getPluginManager().registerEvents(this, this);
  323. Bukkit.getServer().getPluginManager().registerEvents(new custom_mob(), this);
  324. plugin = this;
  325. ci = new custom_item();
  326. cm = new custom_mob();
  327. pot_loop();
  328. }
  329.  
  330.  
  331. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
  332. Player p = Bukkit.getPlayer(sender.getName());
  333.  
  334. if(label.equalsIgnoreCase("v")) {
  335. cm.custom_villager(p);
  336. Ranked_Gear();
  337. }
  338.  
  339. return false;
  340. }
  341.  
  342. public void Item_Making() {
  343. //This is meant to be an example
  344.  
  345. List<String> lore = new ArrayList<String>();
  346. lore.add("SPECIAL:" + "JUMP_5 POISON_2");
  347. lore.add("Forged By The Mighty Moles");
  348.  
  349. List<Enchantment> ench = new ArrayList<Enchantment>();
  350. ench.add(Enchantment.DIG_SPEED);
  351. ench.add(Enchantment.DURABILITY);
  352.  
  353. List<Integer> lvl = new ArrayList<Integer>();
  354. lvl.add(100);
  355. lvl.add(50);
  356.  
  357. ci.make(Material.DIAMOND_PICKAXE, "DIGGO", lore, ench, lvl);
  358. }
  359.  
  360.  
  361. //Item Handling Start
  362. public void pot_loop() {
  363. Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
  364. public void run() {
  365. for(Player p : spp){
  366. Bukkit.broadcastMessage(p.toString());
  367. get_in_hand(p);
  368. }
  369. }
  370. }, 20, 100);
  371. }
  372.  
  373. public void get_in_hand(Player p) {
  374. this.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
  375. public void run() {
  376. ItemStack i = p.getInventory().getItemInMainHand();
  377. if (i == null || i.getType() == Material.AIR) {spp.remove(p);} else {sp_ef(p, i);}
  378. i = p.getInventory().getItemInOffHand();
  379. if (i == null || i.getType() == Material.AIR) {spp.remove(p);} else {sp_ef(p, i);}
  380. }
  381. },5);
  382. }
  383.  
  384. public void sp_ef(Player p, ItemStack i) {
  385. String sp = null;
  386. String[] ef = null;
  387.  
  388. if(i.getItemMeta().getLore() != null) {
  389.  
  390. for(Integer a = 0; a<i.getItemMeta().getLore().size(); a++) {
  391. if(i.getItemMeta().getLore().get(a).contains("SPECIAL:")) {
  392. sp = i.getItemMeta().getLore().get(a);
  393. if(!spp.contains(p)) {spp.add(p);}
  394. }}
  395.  
  396. if(!sp.contains("SPECIAL:")) {spp.remove(p); return;} else {
  397. ef = sp.split("SPECIAL:")[1].split(" ");
  398. }
  399.  
  400. for(Integer a = 1; a<ef.length; a++) {
  401. String p1 = ef[a].split("_")[0];
  402. String p2 = ef[a].split("_")[1];
  403. Integer str = Integer.valueOf(p2);
  404.  
  405. if(p1.equalsIgnoreCase("JUMP")) {add_pe(p, PotionEffectType.JUMP, 120, str);}
  406. if(p1.equalsIgnoreCase("POISON")) {add_pe(p, PotionEffectType.POISON, 120, str);}
  407. }
  408. } else {spp.remove(p);}
  409. }
  410.  
  411. @EventHandler
  412. public void main_item_change(PlayerItemHeldEvent e) {
  413. Player p = e.getPlayer();
  414. get_in_hand(p);
  415. }
  416.  
  417. @EventHandler
  418. public void off_item_change(InventoryClickEvent e) {
  419. HumanEntity p = e.getWhoClicked();
  420. Integer slot = e.getSlot();
  421. Bukkit.broadcastMessage(String.valueOf(slot));
  422. if(slot == 40) {
  423. get_in_hand((Player) p);
  424. }
  425. }
  426.  
  427. @EventHandler
  428. public void hand_swap(PlayerSwapHandItemsEvent e) {
  429. Player p = e.getPlayer();
  430. get_in_hand(p);
  431. }
  432. //Item Handling End
  433.  
  434. //Villager set trade start
  435. @EventHandler
  436. public void vcc(VillagerCareerChangeEvent e) {
  437. Villager v = e.getEntity();
  438. set_trade(v);
  439. }
  440.  
  441. public void set_trade(Villager v) {
  442. this.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
  443. public void run() {
  444. MerchantRecipe a = new MerchantRecipe(new ItemStack(Material.DIAMOND), Integer.MAX_VALUE);
  445. a.addIngredient(new ItemStack(Material.DIRT));
  446. v.setRecipe(0, a);
  447. }
  448. },5);
  449. }
  450. //Villager set trade end
  451.  
  452.  
  453.  
  454. @EventHandler
  455. public void onMove(PlayerMoveEvent e) {
  456.  
  457. Player p = e.getPlayer();
  458.  
  459. List<String> lore = new ArrayList<String>();
  460. lore.add("SPECIAL:" + " JUMP_5");
  461. lore.add("SWIMMING FOR JOY");
  462.  
  463. List<Enchantment> ench = new ArrayList<Enchantment>();
  464. ench.add(Enchantment.DIG_SPEED);
  465.  
  466. List<Integer> lvl = new ArrayList<Integer>();
  467. lvl.add(100);
  468.  
  469. ItemStack i = ci.make(Material.TROPICAL_FISH, ChatColor.YELLOW + "HAPPY", lore, ench, lvl);
  470. p.getInventory().addItem(i);
  471. }
  472.  
  473. public void add_pe(Player p, PotionEffectType pot, Integer timer, Integer str) {
  474. p.addPotionEffect(new PotionEffect(pot, timer, str));
  475. }
  476. }
RAW Paste Data