59 lines
1.5 KiB
Java
59 lines
1.5 KiB
Java
package world.bentobox.warps.objects;
|
|
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
import java.util.UUID;
|
|
|
|
import org.bukkit.Location;
|
|
import org.bukkit.World;
|
|
|
|
import com.google.gson.annotations.Expose;
|
|
|
|
import world.bentobox.bentobox.database.objects.DataObject;
|
|
import world.bentobox.bentobox.database.objects.Table;
|
|
|
|
@Table(name = "WarpsData")
|
|
public class WarpsData implements DataObject {
|
|
|
|
@Expose
|
|
private String uniqueId = "warps";
|
|
@Expose
|
|
private Map<Location, UUID> warpSigns = new HashMap<>();
|
|
|
|
public WarpsData() {
|
|
// Required by YAML database
|
|
}
|
|
|
|
@Override
|
|
public String getUniqueId() {
|
|
return uniqueId;
|
|
}
|
|
|
|
@Override
|
|
public void setUniqueId(String uniqueId) {
|
|
this.uniqueId = uniqueId;
|
|
}
|
|
|
|
public Map<Location, UUID> getWarpSigns() {
|
|
if (warpSigns == null)
|
|
return new HashMap<>();
|
|
return warpSigns;
|
|
}
|
|
|
|
public void setWarpSigns(Map<Location, UUID> warpSigns) {
|
|
this.warpSigns = warpSigns;
|
|
}
|
|
|
|
/**
|
|
* Puts all the data from the map into this objects ready for saving
|
|
* @param worldsWarpList 2D map of warp locations by world vs UUID
|
|
* @return this class filled with data
|
|
*/
|
|
public WarpsData save(Map<World, Map<UUID, Location>> worldsWarpList) {
|
|
getWarpSigns().clear();
|
|
worldsWarpList.values().forEach(world -> world.forEach((uuid,location) -> warpSigns.put(location, uuid)));
|
|
return this;
|
|
}
|
|
|
|
}
|