CometSkyBlock/plugin/src/main/java/com/alttd/cometskyblock/island/Island.java

78 lines
2.1 KiB
Java
Raw Normal View History

2024-01-18 07:58:21 +00:00
package com.alttd.cometskyblock.island;
2024-01-25 14:49:04 +00:00
import lombok.Getter;
import lombok.Setter;
2024-01-25 14:49:04 +00:00
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
2024-01-18 07:58:21 +00:00
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
2024-01-25 14:49:04 +00:00
@ConfigSerializable
@Getter
2024-01-18 07:58:21 +00:00
public class Island {
protected UUID worldId;
protected String worldName;
protected String islandName;
@Setter protected int level;
@Setter protected UUID owner;
protected final List<UUID> members = new ArrayList<>();
2024-01-18 07:58:21 +00:00
public boolean canBuild(UUID uuid) {
return owner.equals(uuid) || members.contains(uuid);
}
2024-01-25 14:49:04 +00:00
public boolean addMember(UUID uuid) {
return this.members.add(uuid);
}
public boolean removeMember(UUID uuid) {
return this.members.remove(uuid);
}
public static class IslandBuilder extends Island {
private final UUID worldUUID;
private final String worldName;
private String islandName;
private int level;
private UUID owner;
private final List<UUID> members = new ArrayList<>();
public IslandBuilder(UUID worldUUID, String worldName) {
this.worldUUID = worldUUID;
this.worldName = worldName;
}
public IslandBuilder islandName(String islandName) {
this.islandName = islandName;
return this;
}
public IslandBuilder level(int level) {
this.level = level;
return this;
}
public IslandBuilder owner(UUID owner) {
this.owner = owner;
return this;
}
public IslandBuilder members(List<UUID> members) {
this.members.addAll(members);
return this;
}
public Island build() {
Island island = new Island();
island.worldId = this.worldUUID;
island.worldName = this.worldName;
island.islandName = this.islandName;
island.level = this.level;
island.owner = this.owner;
island.members.addAll(this.members);
return island;
}
}
2024-01-18 07:58:21 +00:00
}