Solved Variables not saving when method is called

Discussion in 'Spigot Help' started by ZachThePwn, Jun 13, 2018.

  1. Hello I am new to doing Minecraft plugins and somewhat new to Java. I am trying to make my variables i call in the SynthWeapont1 method carry over to my GUI. The values stay at what I call them as originally before i call the method instead of changing (0, 0, and a blank string) I hope that makes sense.

    Code (Text):
    public void synthDamageT1(double dmax, double dmin, String rarity) {
         
            int raritydecide;
            raritydecide = (int)(Math.random() * 100) + 1;
         
            if (raritydecide < 70 && raritydecide >= 1) {
                dmax = 5;
                dmin = 1;
                rarity = "Common";
            } else if (raritydecide < 93 && raritydecide >= 70) {
                dmax = 7;
                dmin = 2;
                rarity = "Rare";
            } else if (raritydecide < 96 && raritydecide >= 93) {
                dmax = 13;
                dmin = 7;
                rarity = "Legendary";
            } else if (raritydecide < 98 && raritydecide >= 96) {
                dmax = 18;
                dmin = 10;
                rarity = "Exotic";
            } else if (raritydecide < 100 && raritydecide >= 98) {
                dmax = 30;
                dmin = 20;
                rarity = "Hyper";
            }
         
    }
    public void openTest(Player p) {
            Inventory inv = Bukkit.createInventory(null, 27, ChatColor.GOLD + "Weapons");
            double dmax = 0;
            double dmin = 0;
            String rarity = "";
            double dmax2 = 0;
            double dmin2 = 0;
            String rarity2 = "";
         
            synthDamageT1(dmax, dmin, rarity);
         
            ItemStack woodensword1 = new ItemStack(Material.WOOD_SWORD);
            ItemMeta woodmeta1 = woodensword1.getItemMeta();
            woodmeta1.setDisplayName(ChatColor.WHITE + "Flimsy Wooden Sword");
            ArrayList<String> lore1 = new ArrayList<String>();
            lore1.add(ChatColor.WHITE + "Damage : " + ChatColor.RED + dmin + "-" + dmax);
            lore1.add(ChatColor.WHITE + rarity);
         
            woodmeta1.setLore(lore1);
            woodensword1.setItemMeta(woodmeta1);
            //p.getInventory().addItem(woodensword1);
         
            synthDamageT1(dmax2, dmin2, rarity2);
            ItemStack woodensword2 = new ItemStack(Material.WOOD_SWORD);
            ItemMeta woodmeta2 = woodensword2.getItemMeta();
            woodmeta2.setDisplayName(ChatColor.WHITE + "Basic Wooden Sword");
            ArrayList<String> lore2 = new ArrayList<String>();
            lore2.add(ChatColor.WHITE + "Damage : " + ChatColor.RED + dmin2 + "-" + dmax2);
            lore2.add(ChatColor.WHITE + rarity2);
            woodmeta2.setLore(lore2);
            woodensword2.setItemMeta(woodmeta2);
         
            inv.setItem(10, woodensword1);
            inv.setItem(12, woodensword2);
            p.openInventory(inv);
        }
    https://pastebin.com/fe92Dg5F
     
    #1 ZachThePwn, Jun 13, 2018
    Last edited: Jun 13, 2018
  2. bump please help i cant figure it out
     
  3. solved but i have another issue, it was very different than what i have now so i will post that in new thread