Solved Accessing methods from another in another class not working? (Neither are Main Class)

Discussion in 'Plugin Development' started by MayoDwarf, May 17, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    MayoDwarf

    In the Golem class we have this:
    Code:java
    1. SalvoAndChain sc;
    2. public Golem(SalvoAndChain sc) {
    3. this.sc = sc;
    4. }

    In the SalvoAndChain class we have:
    Code:java
    1. private Golem g = new Golem(this);

    Every way I have tried I can just not get the g to work as it should... It never calls the main class. However g.summonGolem() method works, but the g.isGolem() method does not work.
    Methods:
    Code:java
    1. final int task1 = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(main, new Runnable() {
    2. int count = 4;
    3. @Override
    4. public void run() {
    5. count--;
    6. if(count >= 1) {
    7. if(g.isGolem(p)) {
    8. short j = (short)(((int)i.getType().getMaxDurability())*count);
    9. p.getInventory().removeItem(i);
    10. ItemStack chainGun = new ItemStack(i.getType(), i.getAmount(), j);
    11. ItemMeta cIM = chainGun.getItemMeta();
    12. cIM.setDisplayName(ChatColor.LIGHT_PURPLE+"XO-16 Chaingun"+ChatColor.RED+" - Reloading... "+count);
    13. chainGun.setItemMeta(cIM);
    14. p.getInventory().setItem(0, chainGun);
    15. p.updateInventory();
    16. }
    17. } else {
    18. if(g.isGolem(p)) {
    19. cooldown.remove(p.getDisplayName());
    20. shots.remove(p.getDisplayName());
    21. p.getInventory().removeItem(i);
    22. ItemStack chainGun = new ItemStack(i.getType(), i.getAmount());
    23. ItemMeta cIM = chainGun.getItemMeta();
    24. cIM.setDisplayName(ChatColor.LIGHT_PURPLE+"XO-16 Chaingun");
    25. chainGun.setItemMeta(cIM);
    26. p.getInventory().setItem(0, chainGun);
    27. p.updateInventory();
    28. }
    29. }
    30. }
    31. }, 0, 20);

    Code:java
    1. public Boolean isGolem(Player p) {
    2. if(hasGolem.contains(p.getDisplayName())) {
    3. return true;
    4. }
    5. return false;
    6. }

    They go together ^
    Code:java
    1. @EventHandler
    2. public void onClick(PlayerInteractEvent evt) {
    3. final Player p = evt.getPlayer();
    4. final ItemStack i = p.getItemInHand();
    5. if(evt.getAction() == Action.RIGHT_CLICK_BLOCK) {
    6. if(i.getType() == Material.NETHER_STAR) {
    7. g.summonGolem(p, evt.getClickedBlock().getLocation());
    8. }
    9. }

    Code:java
    1. public void summonGolem(Player p, Location tFall) {
    2. IronGolem ig = (IronGolem) p.getWorld().spawnEntity(new Location(p.getWorld(), tFall.getX(), 200, tFall.getZ(), tFall.getYaw(), tFall.getPitch()), EntityType.IRON_GOLEM);
    3. ig.setCustomName(ChatColor.DARK_RED+""+p.getDisplayName());
    4. ig.setCustomNameVisible(true);
    5. ig.setPlayerCreated(true);
    6. ig.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 99999, 99999));
    7. p.getInventory().removeItem(new ItemStack(Material.NETHER_STAR));
    8. golem.put(p.getDisplayName(), ig);
    9. }

    So do these ^
    Please help me to the best of your abilities! Thanks - Jared (MayoDwarf)
     
Thread Status:
Not open for further replies.

Share This Page