Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.lang.reflect.Field;
- import java.lang.reflect.Method;
- import java.util.ArrayList;
- import java.util.Random;
- import static me.batz.arvaksecurity.MobsArmadura.formatMessage;
- import net.md_5.bungee.api.ChatColor;
- import org.bukkit.Bukkit;
- import org.bukkit.Material;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.player.PlayerPickupItemEvent;
- import org.bukkit.inventory.ItemStack;
- import org.bukkit.inventory.meta.ItemMeta;
- /**
- *
- * @author Gabriel
- */
- public class MobsArma implements Listener{
- public static String formatMessage(String message) {
- String messageFormated = message
- .replace("&", "ยง");
- return messageFormated;
- }
- public int rollsDano1(){
- int foo = (int) (Math.random() * 100);
- int roll = (int) (Math.random() * 100);
- Random r = new Random();
- if (foo < 1) {
- int min = 1;
- int max = 5;
- int resul = r.nextInt(max-min) + min;
- return resul;
- } else if (foo < 2) {
- int min = 6;
- int max = 9;
- int resul = r.nextInt(max-min) + min;
- return resul;
- } else if (foo < 95) {
- int min = 10;
- int max = 14;
- int resul = r.nextInt(max-min) + min;
- return resul;
- } else if (foo < 98) {
- int min = 15;
- int max = 19;
- int resul = r.nextInt(max-min) + min;
- return resul;
- } else {
- int min = 20;
- int max = 26;
- int resul = r.nextInt(max-min) + min;
- return resul;
- }
- }
- public int rollsDano2(){
- int foo = (int) (Math.random() * 100);
- int roll = (int) (Math.random() * 100);
- Random r = new Random();
- if (foo < 70) {
- int min = 1;
- int max = 5;
- int resul = r.nextInt(max-min) + min;
- return resul;
- } else if (foo < 90) {
- int min = 6;
- int max = 9;
- int resul = r.nextInt(max-min) + min;
- return resul;
- } else if (foo < 96) {
- int min = 10;
- int max = 13;
- int resul = r.nextInt(max-min) + min;
- return resul;
- } else if (foo < 99) {
- int min = 14;
- int max = 19;
- int resul = r.nextInt(max-min) + min;
- return resul;
- } else {
- int min = 20;
- int max = 26;
- int resul = r.nextInt(max-min) + min;
- return resul;
- }
- }
- public String dano() {
- int dano1 = rollsDano1();
- Random r = new Random();
- int min = 1;
- int max = 4;
- int resul = r.nextInt(max-min) + min;
- int danonovo2 = dano1 + resul;
- String dano = (formatMessage("&e"+dano1+"-"+danonovo2));
- return dano;
- }
- public int danoele() {
- int foo = (int) (Math.random() * 100);
- int roll = (int) (Math.random() * 100);
- Random r = new Random();
- if (foo < 40) {
- int min = 1;
- int max = 3;
- int resul = r.nextInt(max-min) + min;
- return resul;
- } else if (foo < 75) {
- int min = 4;
- int max = 7;
- int resul = r.nextInt(max-min) + min;
- return resul;
- } else {
- int min = 8;
- int max = 10;
- int resul = r.nextInt(max-min) + min;
- return resul;
- }
- }
- public int random (int i, int x) {
- int resultado;
- Random r = new Random();
- return resultado = r.nextInt(x-i) + i;
- }
- public boolean t1(ItemStack item) {
- if (item.getType() == Material.WOOD_SWORD|| item.getType() == Material.WOOD_AXE) {
- return true;
- } else {
- return false;
- }
- }
- public final void atributos (ArrayList lore,int pos, ItemMeta meta) {
- if (random(0, 3) < 1) {
- lore.set(pos ,formatMessage("&7DMG ELE: +&e"+random(1, 5)));
- } else if (random(0, 3) < 2) {
- lore.set(pos,formatMessage("&7CRIT CHANCE: +&e"+random(5, 10)+"&7%"));
- } else if (random(0, 3) < 3) {
- lore.set(pos,formatMessage("&7DMG PVE: +&e"+random(5, 10)+"&7%"));
- } else if (random(0, 3) < 4) {
- lore.set(pos, formatMessage("&7LIFESTEAL: +&e"+random(5, 10)+"&7%"));
- }
- meta.setLore(lore);
- }
- public void darAtributoArma (ArrayList lore, ItemStack item) {
- ItemMeta meta = item.getItemMeta();
- String weapon = meta.getLore().get(0);
- String str = weapon.replace("DMG: ", "");
- str = ChatColor.stripColor(str);
- String atributo1;
- String atributo2;
- String atributo3;
- String atributo4;
- int dano1 = Integer.parseInt(str.substring(0,str.indexOf("-"))); // ammo = 10
- if (dano1 > 7) {
- if (random(0, 100) < 1) {
- lore.add(1, "a");
- atributos(lore, 1,meta);
- } else if (random(0, 100) < 2) {
- lore.add(1, "a");
- lore.add(2, "a");
- atributos(lore, 1,meta);
- atributos(lore, 2,meta);
- atributo1 = meta.getLore().get(1);
- atributo1 = ChatColor.stripColor(atributo1);
- atributo2 = meta.getLore().get(2);
- atributo2 = ChatColor.stripColor(atributo2);
- } else if (random(0, 100) < 99) {
- lore.add(1, "a");
- lore.add(2, "a");
- lore.add(3, "a");
- meta.setLore(lore);
- atributos(lore, 1, meta);
- atributos(lore,2, meta);
- atributos(lore, 3, meta);
- atributo1 = meta.getLore().get(1);
- atributo1 = ChatColor.stripColor(atributo1);
- atributo2 = meta.getLore().get(2);
- atributo2 = ChatColor.stripColor(atributo2);
- atributo3 = meta.getLore().get(3);
- atributo3 = ChatColor.stripColor(atributo3);
- String atributo11 = atributo1.substring(0, atributo1.indexOf(":"));
- String atributo22 = atributo2.substring(0, atributo2.indexOf(":"));
- String atributo33 = atributo3.substring(0, atributo3.indexOf(":"));
- for (int i = 0;i < 100; i++) {
- if ((atributo33.equalsIgnoreCase(atributo11) || atributo33.equalsIgnoreCase(atributo22) || atributo22.equalsIgnoreCase(atributo11))){
- atributos(lore, 3, meta);
- atributos(lore, 2, meta);
- } else {
- i = 103;
- }
- }
- }
- }
- }
- @EventHandler
- public void pegar (PlayerPickupItemEvent e) {
- ItemStack item = e.getItem().getItemStack();
- ItemMeta meta = item.getItemMeta();
- ArrayList lore = new ArrayList();
- if (t1(item) == true && !item.hasItemMeta()) {
- int dpsarmor = (int) (Math.random() * 10);
- int hpregener = (int) (Math.random() * 10);
- lore.add(0, formatMessage("&7DMG: "+dano()));
- meta.setLore(lore);
- item.setItemMeta(meta);
- String weapon = meta.getLore().get(0);
- String str = weapon.replace("DMG: ", "");
- str = ChatColor.stripColor(str);
- int dano1 = Integer.parseInt(str.substring(0,str.indexOf("-"))); // ammo = 10
- if (dano1 < 8) {
- meta.setDisplayName(formatMessage("&fMachado de Madeira"));
- lore.add( formatMessage("&7Comum"));
- } else {
- darAtributoArma(lore, item);
- }
- meta.setLore(lore);
- item.setItemMeta(meta);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement