#KIt Sorting System
1 messages · Page 1 of 1 (latest)
make your kit class implements Comparable
and do whatever you want with the method inside it
You need a per-player serializable object that stores the data in a Map<Integer, ItemStack>
i believe i once did this using a Map<Integer, Integer> storing which slots the player had switched arround
^ Oh yeah you can also do a weak coherence approach by mapping the original slots to the players chosen slots
ok thanks for the ideas i will try to implement it
uh i know what you mean, but how do i do it so its for every player a custom map so everyone has a different sort
i would create something along the lines of a PlayerCache that will be loaded from a file or database any kind of storage you want.
and would save it when the player logs off.
this class can then house that Map
so it works but when i try to save the map in my config (temporaily solution) it has a map with the name i specified, but it doesnt safe the items from it. idk why
well uhh why dont you share some code
wait i can do it
Map<Integer, ItemStack> newSort = new HashMap<Integer, ItemStack>();
@Override
public boolean onCommand(CommandSender s, Command c, String l, String[] args) {
Player player = (Player) s;
KitManager.givePlayerKit(player, KitManager.getKit("tank"));
player.sendMessage("Sort test");
for(int i = 0; i < player.getInventory().getSize(); i++) {
newSort.put(i, player.getInventory().getItem(i));
}
return false;
}
@EventHandler
void onChat(PlayerChatEvent e) throws IOException {
System.out.println(newSort);
KitManager.givePlayerKitWithCustomSort(e.getPlayer(), KitManager.getKit("tank"));
Main.yamlConfiguration.set(e.getPlayer().getName()+ "tankkit", newSort);
Main.yamlConfiguration.save(Main.file);
}
``` im trying to save it, but it just doesnt contain anything. i maybe just be stupid rn idk xd
so ur trying to do it the way 7smile7 suggested right
keep in mind that that way uses considerably more space
did you register your listener?
yes i did.
the chatevent works, it saves it in the config, but without the data i provided in the map (the items etc)
im not sure u can save a map like that
i think u need to loop through and save each entry
is there another way?
well i suggested this
im trying to do something like that
well then. no i think there isnt much else u can do