44 lines
1.3 KiB
Java
44 lines
1.3 KiB
Java
package com.alttd.objects;
|
|
|
|
import com.alttd.VillagerUI;
|
|
import com.alttd.commands.database.Queries;
|
|
import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap;
|
|
import org.bukkit.scheduler.BukkitRunnable;
|
|
|
|
import java.util.UUID;
|
|
|
|
public class EconUser {
|
|
|
|
public static Object2ObjectArrayMap<UUID, EconUser> users = new Object2ObjectArrayMap<>();
|
|
|
|
private final UUID uuid;
|
|
private final Object2ObjectArrayMap<String, Integer> pointsMap;
|
|
|
|
public EconUser(UUID uuid, Object2ObjectArrayMap<String, Integer> points) {
|
|
this.uuid = uuid;
|
|
this.pointsMap = points;
|
|
users.put(this.uuid, this);
|
|
}
|
|
|
|
public UUID getUuid() {
|
|
return uuid;
|
|
}
|
|
|
|
public Object2ObjectArrayMap<String, Integer> getPointsMap() {
|
|
return pointsMap;
|
|
}
|
|
|
|
public void addPoints(String villagerType, int points) {
|
|
if (pointsMap.containsKey(villagerType))
|
|
pointsMap.put(villagerType, points);
|
|
else
|
|
pointsMap.put(villagerType, pointsMap.get(villagerType) + points);
|
|
new BukkitRunnable() {
|
|
@Override
|
|
public void run() {
|
|
Queries.updateUserPoints(uuid, villagerType, pointsMap.get(villagerType));
|
|
}
|
|
}.runTaskAsynchronously(VillagerUI.getInstance());
|
|
}
|
|
}
|