Im developing a simple Team plugin but i still get some errors maybe you can help me... My methodes: http://hastebin.com/woxudimizu.avrasm My Class: http://hastebin.com/orixomejah.avrasm ERrors http://hastebin.com/catutomuwu.coffee ~Kiwanga
http://bukkit.org/threads/how-to-re...ubleshoot-your-own-plugins-by-yourself.32457/ Also let me note a few things: Code: public static HashMap<Player, Player> teameinladung = new HashMap<>(); public static HashMap<Player, Player> teamannahme = new HashMap<>(); Dont abuse static Encapsulate dont store player long term since it is know to cause ram leaks when not hanled properly. And also, follow naming conventions
To expand on this a bit, it's also a terrible idea to use mutable objects as HashMap keys, the reason being that if the object is mutated in such a way that the hashcode changes, it will no longer match the code stored by the map and therefore will no longer be able to recall the associated value. Same logic goes for Sets, albeit in a slightly less breaking way.
But if he wants to access the map from a different class, how would he possibly do it without public static?
@DoggyCode™, uhh, one of the most basic principles of Java. OOP. If you don't know that you have a serious issue.
@DoggyCode™, for your own sake, learn to understand what is going on here. Code: public class Test { public static void main(String args) { Example example = new Example("An Object", 1); example.printID(); } } public class Example { private String name; private int id; public Example(String name, int id) { this.name = name; this.id = id; } public void printID() { System.out.println(this.id); } } If there's a typo, I did this on my phone. For OP, use the thread @mine-care linked.
In fairness, the main plugin class is effectively a singleton, so using a static has more or less the same effect as using an instance variable in this particular case.
@caseif @Tecno_Wizard Even then, the concept of "encapsulation" doesn't just not apply because the class could reasonably be considered a singleton. All that means is that you can have a static method that gets the instance of that Object. You still should have getter and setter methods regardless.
@mythbusterma, agreed, but I really didn't want to fight it at that moment. The stress that comes with college applications... I don't need any more.