Αποτελέσματα Αναζήτησης
27 Αυγ 2017 · HashMaps are like arrays, and is used to temporarily store data in your whole plugin. You can create one using this syntax: Code (Text): public HashMap<Kay, Value> map = new HashMap<> (); Just replace "Key" and "Value" with the type of data you want, in our case we'll use "Player" and "Integer".
10 Μαρ 2015 · This will be our method to save the HashMap: Code:Java. public void saveHashMap (HashMap <Object, Object> hm) {. } Inside it, we loop through every key in the HashMap and set the key + value to the config: Code:Java. for (Object key : hm. keySet()) {. config. set("HashMap."+ key, hm. get(key)); }
If I were to use the put method, with it allowing three parameters, my addSmelting constructor would look something like this: public void addSmelting(int par1, int par2, ItemStack par3ItemStack) { this.smeltingList.put(Integer.valueOf(par1), Integer.valueOf(par2), par3ItemStack); }
I get a weird error when I try to call methods from another class, it worked on my other plugin but here it doesn't work. private static Main plugin; public static Main getPlugin() {. return plugin; Tick tickClass = new Tick(); @Override. public void onEnable() {. // Plugin startup logic.
27 Μαρ 2024 · You don’t need a HashMap. Just use a HashSet of players: private Set<Player> runningPlayers = new HashSet<>(); (But you still need to make sure the hashCode and equals methods of Player are written correctly and their behavior never changes for a particular instance.) –
public HashMap(Map<? extends K,? extends V> m) Constructs a new HashMap with the same mappings as the specified Map . The HashMap is created with default load factor (0.75) and an initial capacity sufficient to hold the mappings in the specified Map .
Encapsulation. The meaning of Encapsulation, is to make sure that "sensitive" data is hidden from users. To achieve this, you must: declare class variables/attributes as private. provide public get and set methods to access and update the value of a private variable. Get and Set.