How to do this?

Discussion in 'Plugin Development' started by Sarcry, Sep 3, 2016.

Thread Status:
Not open for further replies.
  1. @Sarcry
    Show us where this "PlayerFrozen" constructor is called.
     
  2. Offline

    Sarcry

    it's in the main class ( Punish )
    public ArrayList<Player> frozen = new ArrayList<Player>();
    Code:
    This is why I use plugin.frozen.(etc)
    public PlayerFrozenListener(Punish plugin) {
            this.plugin = plugin;
        }
    
     
  3. @Sarcry
    Yes, but where do you call the constructor (where you do "new PlayerFrozenListener(plugin)")?
     
  4. Offline

    Sarcry

    You mean this?
    Code:
    PluginManager pm = Bukkit.getPluginManager();
    pm.registerEvents(new PlayerFrozenListener(this),this);
    
     
  5. @Sarcry
    Wait my bad. I though "PlayerFrozen" was a constructor.. but it's a method. Alright, show us where you call the "PlayerFrozen" method of the "PlayerFrozenListener" class.
     
  6. Offline

    Sarcry

    I think I've forgotten that. By the way, how do I call a method from that class if it's not static?
     
  7. @Sarcry
    Instantiate the class into an object and call the method on the object.
     
  8. Offline

    ArsenArsen

    Sorry to interrupt, just wanted to mention that this is the reason why code conventions exist. Here: http://www.oracle.com/technetwork/java/codeconventions-135099.html

    @Sarcry try reading up a bit on Object Oriented Programming and Java itself. Not (ab)using static is just a good practice
     
Thread Status:
Not open for further replies.

Share This Page