Advertisement
Guest User

Bukkit

a guest
May 17th, 2016
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 7.91 KB | None | 0 0
  1.  
  2.  
  3.  
  4. import java.lang.reflect.Field;
  5. import java.lang.reflect.Method;
  6. import java.util.ArrayList;
  7. import java.util.Random;
  8. import static me.batz.arvaksecurity.MobsArmadura.formatMessage;
  9. import net.md_5.bungee.api.ChatColor;
  10. import org.bukkit.Bukkit;
  11. import org.bukkit.Material;
  12. import org.bukkit.event.EventHandler;
  13. import org.bukkit.event.Listener;
  14. import org.bukkit.event.player.PlayerPickupItemEvent;
  15. import org.bukkit.inventory.ItemStack;
  16. import org.bukkit.inventory.meta.ItemMeta;
  17.  
  18. /**
  19.  *
  20.  * @author Gabriel
  21.  */
  22. public class MobsArma implements Listener{
  23.    
  24.    
  25.  
  26.    
  27.    
  28.    public static String formatMessage(String message) {
  29.     String messageFormated = message
  30.       .replace("&", "ยง");
  31.  
  32.      
  33.  
  34.     return messageFormated;
  35.   }
  36.    
  37.    
  38.    
  39.    
  40.     public int rollsDano1(){
  41.    int foo = (int) (Math.random() * 100);
  42.     int roll = (int) (Math.random() * 100);
  43.       Random r = new Random();
  44.   if (foo < 1) {
  45.   int min = 1;
  46.   int max = 5;
  47.  int resul = r.nextInt(max-min) + min;
  48.       return resul;
  49.   } else if (foo < 2) {
  50.    int min = 6;
  51.   int max = 9;
  52.  int resul = r.nextInt(max-min) + min;
  53.       return resul;
  54.   }   else if (foo < 95) {
  55.    int min = 10;
  56.   int max = 14;
  57.  int resul = r.nextInt(max-min) + min;
  58.       return resul;
  59.   }   else if (foo < 98) {
  60.    int min = 15;
  61.   int max = 19;
  62.  int resul = r.nextInt(max-min) + min;
  63.       return resul;
  64.    
  65.    } else {
  66.    int min = 20;
  67.   int max = 26;
  68.  int resul = r.nextInt(max-min) + min;
  69.       return resul;
  70. }
  71. }
  72.  
  73.  
  74.  
  75. public int rollsDano2(){
  76.    int foo = (int) (Math.random() * 100);
  77.     int roll = (int) (Math.random() * 100);
  78.       Random r = new Random();
  79.   if (foo < 70) {
  80.   int min = 1;
  81.   int max = 5;
  82.  int resul = r.nextInt(max-min) + min;
  83.       return resul;
  84.   } else if (foo < 90) {
  85.    int min = 6;
  86.   int max = 9;
  87.  int resul = r.nextInt(max-min) + min;
  88.       return resul;
  89.   }   else if (foo < 96) {
  90.    int min = 10;
  91.   int max = 13;
  92.  int resul = r.nextInt(max-min) + min;
  93.       return resul;
  94.   }   else if (foo < 99) {
  95.    int min = 14;
  96.   int max = 19;
  97.  int resul = r.nextInt(max-min) + min;
  98.       return resul;
  99.    
  100.    } else {
  101.    int min = 20;
  102.   int max = 26;
  103.  int resul = r.nextInt(max-min) + min;
  104.       return resul;
  105. }
  106. }
  107.  
  108. public String dano() {
  109.  
  110.     int dano1 = rollsDano1();
  111.  
  112.  
  113.         Random r = new Random();
  114.            int min = 1;
  115.   int max = 4;
  116.  int resul = r.nextInt(max-min) + min;
  117.        
  118.         int danonovo2 = dano1 + resul;
  119.          String dano = (formatMessage("&e"+dano1+"-"+danonovo2));
  120.        
  121.         return dano;
  122.     }
  123.  
  124.    public int danoele() {
  125.         int foo = (int) (Math.random() * 100);
  126.     int roll = (int) (Math.random() * 100);
  127.       Random r = new Random();
  128.   if (foo < 40) {
  129.   int min = 1;
  130.   int max = 3;
  131.  int resul = r.nextInt(max-min) + min;
  132.       return resul;
  133.   } else if (foo < 75) {
  134.    int min = 4;
  135.   int max = 7;
  136.  int resul = r.nextInt(max-min) + min;
  137.       return resul;
  138.  
  139.    } else {
  140.    int min = 8;
  141.   int max = 10;
  142.  int resul = r.nextInt(max-min) + min;
  143.       return resul;
  144. }
  145.      
  146.      
  147.      
  148.      
  149.      
  150.   }
  151.    
  152.    
  153.  
  154.    
  155.  
  156.  public int random (int i, int x) {
  157.      
  158.   int resultado;
  159.  Random r = new Random();
  160. return resultado = r.nextInt(x-i) + i;
  161.  }
  162.  public boolean t1(ItemStack item) {
  163.        if (item.getType() == Material.WOOD_SWORD|| item.getType() == Material.WOOD_AXE) {
  164.            return true;
  165.        } else {
  166.            return false;
  167.        }
  168.        
  169.        
  170.        
  171.    }
  172.  
  173.  
  174.  public final void atributos (ArrayList lore,int pos,  ItemMeta meta) {
  175.  
  176.       if (random(0, 3) < 1) {
  177.                   lore.set(pos ,formatMessage("&7DMG ELE: +&e"+random(1, 5)));
  178.                    
  179.              } else if (random(0, 3) < 2) {
  180.                  lore.set(pos,formatMessage("&7CRIT CHANCE: +&e"+random(5, 10)+"&7%"));
  181.              
  182.              } else if (random(0, 3) < 3) {
  183.                  lore.set(pos,formatMessage("&7DMG PVE: +&e"+random(5, 10)+"&7%"));
  184.                  
  185.              } else if (random(0, 3) < 4) {
  186.                  lore.set(pos, formatMessage("&7LIFESTEAL: +&e"+random(5, 10)+"&7%"));
  187.                  
  188.              }
  189.       meta.setLore(lore);
  190.      
  191.        
  192.        
  193.        
  194.        
  195.      
  196.  }
  197.  
  198.  
  199.  
  200.  public void darAtributoArma (ArrayList lore, ItemStack item) {
  201.      ItemMeta meta = item.getItemMeta();
  202.       String weapon = meta.getLore().get(0);
  203.  
  204. String str = weapon.replace("DMG: ", "");
  205. str = ChatColor.stripColor(str);
  206. String atributo1;
  207. String atributo2;
  208. String atributo3;
  209. String atributo4;
  210.  
  211.  
  212.  
  213. int dano1 = Integer.parseInt(str.substring(0,str.indexOf("-"))); // ammo = 10
  214.      if (dano1 > 7) {
  215.      if (random(0, 100) < 1) {
  216.         lore.add(1, "a");
  217.      atributos(lore, 1,meta);
  218.    
  219.      } else  if (random(0, 100) < 2) {
  220.      lore.add(1, "a");
  221.      lore.add(2, "a");
  222.           atributos(lore, 1,meta);
  223.            atributos(lore, 2,meta);
  224.            atributo1 = meta.getLore().get(1);
  225.       atributo1 = ChatColor.stripColor(atributo1);
  226.         atributo2 = meta.getLore().get(2);
  227.       atributo2 = ChatColor.stripColor(atributo2);
  228.      
  229.        
  230.      
  231.      
  232.          
  233.  } else  if (random(0, 100) < 99) {
  234.    
  235.      lore.add(1, "a");
  236.        lore.add(2, "a");
  237.        lore.add(3, "a");
  238.        meta.setLore(lore);
  239.       atributos(lore, 1, meta);
  240.            atributos(lore,2,  meta);
  241.             atributos(lore, 3, meta);
  242.                    atributo1 = meta.getLore().get(1);
  243.       atributo1 = ChatColor.stripColor(atributo1);
  244.              atributo2 = meta.getLore().get(2);
  245.       atributo2 = ChatColor.stripColor(atributo2);
  246.         atributo3 = meta.getLore().get(3);
  247.       atributo3 = ChatColor.stripColor(atributo3);
  248.      String atributo11 = atributo1.substring(0, atributo1.indexOf(":"));
  249.        String atributo22 = atributo2.substring(0, atributo2.indexOf(":"));
  250.       String atributo33 = atributo3.substring(0, atributo3.indexOf(":"));
  251.  
  252.  
  253.            
  254.              
  255.          
  256.                
  257.      
  258.                
  259.              
  260.            
  261.            
  262.            
  263.       for (int i = 0;i < 100; i++) {          
  264.        
  265.            
  266.             if ((atributo33.equalsIgnoreCase(atributo11) || atributo33.equalsIgnoreCase(atributo22) || atributo22.equalsIgnoreCase(atributo11))){
  267.              
  268.                   atributos(lore, 3, meta);
  269.   atributos(lore, 2, meta);
  270.  
  271.  
  272.             } else {
  273.              
  274.  
  275.   i = 103;
  276.             }
  277.       }
  278.      
  279.  }
  280.            
  281.            
  282.            
  283.  
  284.            
  285.      
  286.  }
  287.      
  288.      
  289.      
  290.      
  291.      
  292.      }
  293.  
  294.  
  295.  
  296.  
  297.  @EventHandler
  298.   public void pegar (PlayerPickupItemEvent e)  {
  299.       ItemStack item = e.getItem().getItemStack();
  300.       ItemMeta meta = item.getItemMeta();
  301.       ArrayList lore = new ArrayList();
  302.       if (t1(item) == true && !item.hasItemMeta()) {
  303.            int dpsarmor = (int) (Math.random() * 10);
  304.             int hpregener = (int) (Math.random() * 10);
  305.      
  306.          
  307.        
  308.           lore.add(0, formatMessage("&7DMG: "+dano()));
  309.          
  310.          
  311.    
  312.          
  313.           meta.setLore(lore);
  314.          
  315.        
  316.        
  317.      
  318.          
  319.           item.setItemMeta(meta);
  320.    
  321.  String weapon = meta.getLore().get(0);
  322.  
  323. String str = weapon.replace("DMG: ", "");
  324. str = ChatColor.stripColor(str);
  325.  
  326.  
  327. int dano1 = Integer.parseInt(str.substring(0,str.indexOf("-"))); // ammo = 10
  328.  
  329.         if (dano1 < 8) {
  330.            
  331.           meta.setDisplayName(formatMessage("&fMachado de Madeira"));
  332.          
  333.             lore.add( formatMessage("&7Comum"));
  334.         } else {
  335.            
  336.             darAtributoArma(lore, item);
  337.          
  338.            
  339.         }
  340.        
  341.        
  342.        
  343.        
  344.        
  345.        
  346.         meta.setLore(lore);
  347.        
  348.        
  349.        
  350.      
  351.          
  352.           item.setItemMeta(meta);
  353.          
  354.          
  355.       }
  356.      
  357.      
  358.      
  359.      
  360.   }
  361. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement