#Dev problem
1 messages · Page 1 of 1 (latest)
yes i've create playerData class
in your UserManager you want a Map<UUID, User>
but to put new values or get that it doesn't work
do you have an example code ?
i quiet see what you're talking about
No but its very basic to do
sorry ^^ i'm not very very good
use paste, its easier to read
i do but it's too heavy for discord
he means https://paste.md-5.net/
?paste
oh sorry
Sadge no bot
click save then post the link it gives you in here
line 126 is going to overwrite any changes you make
nm
its not
however, line 96, don;t store Player references. Only their UUID
i don't understand
this.player = player; you are storing a Player object
i want to overwrite new values of each players
ok
so only reference them by UUD
ok
line 86
how i do ?
PlayerData playerData = new PlayerData((Player) playerConfig);
you can't cast a YamlConfiguration to a Player
wow i'm not sure to understand
Object casting is when you try to change the Object interface/class you want use to access underlying object
ok
(Player) playerConfigIs trying to change the playerConfig into a Player
which it can not do
oh ok
as there is no relation between the two
your PlayerData Class needs two constructors. One that accepts a UUID and a second which takes a YamlConfigurations
ok i understand but i don't know what i must modifiy
It seems you are very new to Java
yes and i'm French so i understand but not all ^^
like constructors
you say i must use 2
each class has a constructor. You can have as many as you want, which is called overloading
ok
public PlayerData(Player player) { is your current constructor
ok i understand
that needs to change to public PlayerData(UUID playerID) {
i modify
show that class
where ?
and change private final Player player; to private final UUID playerID;
can you modify and explain me ? i don't understand how to do it
one sec, let me open my IDE
yes no problem
um odd question, why are you storing the players exp and level to a file?
why is the uuid a string
you only ever use it as a String so there no point in converting it every time
ok
it works ? or i test it ?
No clue, you need to test it
theres many things in there which are wrong but it's clear you are very new so lots to learn.
ty very very very much
But play with it and you'll see where you made mistakes.
now if i want to get exp and level from a new class like that https://paste.md-5.net/obehejesig.java
eg, in onPlayerJoin you overwrite the saved data and then do nothing with it
oh ok
because i want to get the amount of exp and level of the other class to overwrites the new values in the file
currently all you are doing is reading the players exp and level. nothing to do with any jobs
ok
ok
so you are not loading it every time you need it
ok and i must ?
so in your LegendJobs class add a Field Map<UUID, PlayerData> playerCache = new HashMap<>();
before onEnable ?
at the very top, below public final class LegendJobs
then in your getPlayerData method addjava private PlayerData getPlayerData(UUID playerId) { if (playerCache.containsKey(playerId)) return playerCache.get(playerId);
ok
now there are two places you need to modify and you need to do this yourself... I'll tell you where and you work out what you need to change.
return new PlayerData(playerId);andreturn new PlayerData(playerConfig);
both those lines in getPlayerData instead of returning that new Object first need to add it to the playerCache, then return it.
its quite simple, create the object, put in map, then return the object
currently it just returns a new object
return new PlayerData(playerId);
is just one part ? i must create the function right ?
no
i'm not sure to understand i'm very sorry
You need to take some Java lessons. There are many free ones on the Internet https://paste.md-5.net/hujezituwe.java
Yes i want but i don't find a good site or support
and i speak english but not very well
I just linked a selection in #help-development
ok
i got no one
And with that i put to cache exp and level and it's write in file after?
?
the code
that current code saves the player data when they disconnect
at the moment your code takes the players current exp and level
currently whatever is saved in the file gets ignored when they log in
so i can do that but getting exp and level amount from lumberjack or miner class ?
Well now you are moving into things you REALLY need to learn the basics of Java for
at the moment you have a data cache, loading and saving.
but you are overwriting anything your jobs would do when the player quits
ok
you need to pass an instance of your main class to your Listner so you can get access to the playerCahe
well just to the getPlayerData method
ok
in the main channel I linked to Dependency Injection
are you planning on just giving the player exp when they do a job?
Do jobs have levels?
yes like when player break wood it gives him exp and when he has a some exp he get a level
and exp reset
yes but i must keep data to save their job level
no need for any data, saving nor loading
like on a Skyblock
what does a job level mean? more exp?
per example, to get the level 1 you need to break 10 logs (1.0 exp each), and when you reach the level one you can win a diamond axe
ok
i've made some plugins but they were not enough difficult ^^
None of this is difficult, if you know Java
yes...
you may have right
codecademy is a good website ? I think i'll learn java with this
they all have their good and bad, but all are worth trying
just don't pay anything to anyone to learn