9
0
mirror of https://gitlab.com/SamB440/rpgregions-2.git synced 2025-12-29 19:59:11 +00:00

WIP fauna implementation

This commit is contained in:
SamB440
2023-11-19 17:32:05 +00:00
parent 35336884a7
commit c2e1e77bbf
28 changed files with 314 additions and 57 deletions

View File

@@ -75,7 +75,7 @@ public interface IntegrationManager {
List<String> discoveries = new ArrayList<>();
try {
RPGRegionsAccount account = RPGRegionsAPI.getAPI().getManagers().getStorageManager().getAccount(player.getUniqueId()).get();
discoveries.addAll(account.getDiscoveredRegions().keySet());
discoveries.addAll(account.getDiscoveries().keySet());
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}

View File

@@ -0,0 +1,36 @@
package net.islandearth.rpgregions.fauna;
import net.islandearth.rpgregions.fauna.trigger.FaunaTrigger;
import java.util.List;
public abstract class FaunaInstance<M> {
private final String identifier;
private final String name;
private final M type;
private final List<FaunaTrigger> triggers;
public FaunaInstance(String identifier, String name, M type, List<FaunaTrigger> triggers) {
this.identifier = identifier;
this.name = name;
this.type = type;
this.triggers = triggers;
}
public String getIdentifier() {
return identifier;
}
public String getName() {
return name;
}
public M getType() {
return type;
}
public List<FaunaTrigger> getTriggers() {
return triggers;
}
}

View File

@@ -0,0 +1,14 @@
package net.islandearth.rpgregions.fauna.trigger;
import net.islandearth.rpgregions.fauna.FaunaInstance;
import org.bukkit.entity.Player;
public abstract class FaunaTrigger {
/**
* Tests whether this trigger is met by the specified player.
* @param player the player to check
* @return true if met, false otherwise
*/
public abstract boolean testRepeatable(Player player, FaunaInstance<?> instance);
}

View File

@@ -4,6 +4,7 @@ import net.islandearth.rpgregions.api.integrations.IntegrationManager;
import net.islandearth.rpgregions.gui.element.IGuiFieldElementRegistry;
import net.islandearth.rpgregions.managers.data.IRPGRegionsCache;
import net.islandearth.rpgregions.managers.data.IStorageManager;
import net.islandearth.rpgregions.managers.data.fauna.IFaunaCache;
import net.islandearth.rpgregions.managers.registry.IRPGRegionsRegistry;
public interface IRPGRegionsManagers {
@@ -12,6 +13,8 @@ public interface IRPGRegionsManagers {
IntegrationManager getIntegrationManager();
IFaunaCache getFaunaCache();
IRPGRegionsCache getRegionsCache();
IRegenerationManager getRegenerationManager();

View File

@@ -13,13 +13,13 @@ import java.util.UUID;
public class RPGRegionsAccount {
private final UUID uuid;
private final Map<String, Discovery> discoveredRegions;
private final Map<String, Discovery> discoveries;
private final List<AccountCooldown> cooldowns;
private final Map<String, TimeEntry> secondsInRegion;
public RPGRegionsAccount(UUID uuid, Map<String, Discovery> discoveredRegions) {
public RPGRegionsAccount(UUID uuid, Map<String, Discovery> discoveries) {
this.uuid = uuid;
this.discoveredRegions = discoveredRegions;
this.discoveries = discoveries;
this.cooldowns = new ArrayList<>();
this.secondsInRegion = new HashMap<>();
}
@@ -28,12 +28,16 @@ public class RPGRegionsAccount {
return uuid;
}
public Map<String, Discovery> getDiscoveredRegions() {
return discoveredRegions;
public Map<String, Discovery> getDiscoveries() {
return discoveries;
}
public boolean hasDiscovered(String discoveryName) {
return discoveries.containsKey(discoveryName);
}
public void addDiscovery(Discovery discovery) {
discoveredRegions.put(discovery.getRegion(), discovery);
discoveries.put(discovery.getDiscoveredName(), discovery);
}
public List<AccountCooldown> getCooldowns() {

View File

@@ -0,0 +1,12 @@
package net.islandearth.rpgregions.managers.data.fauna;
import net.islandearth.rpgregions.fauna.FaunaInstance;
import java.util.List;
public interface IFaunaCache {
List<FaunaInstance<?>> getFauna();
void addFauna(FaunaInstance<?> instance);
}

View File

@@ -1,16 +1,18 @@
package net.islandearth.rpgregions.managers.data.region;
import java.time.LocalDateTime;
public interface Discovery {
/**
* Gets the date this discovery was made.
* @return date of discovery
*/
String getDate();
LocalDateTime getDate();
/**
* Gets the name of the region that was discovered.
* @return name of region discovered
* Gets the name of what was discovered.
* @return name of discovered
*/
String getRegion();
String getDiscoveredName();
}

View File

@@ -1,14 +1,17 @@
package net.islandearth.rpgregions.managers.data.region;
public record WorldDiscovery(String date, String region) implements Discovery {
import java.time.LocalDate;
import java.time.LocalDateTime;
public record WorldDiscovery(LocalDateTime date, String region) implements Discovery {
@Override
public String getDate() {
public LocalDateTime getDate() {
return date;
}
@Override
public String getRegion() {
public String getDiscoveredName() {
return region;
}
}

View File

@@ -45,7 +45,10 @@ public enum Translations {
DISCOVERING_AREA_PLACEHOLDER(TranslationKey.of("discovering_area_placeholder")),
REQUIREMENT_MET(TranslationKey.of("requirement_met")),
REQUIREMENT_NOT_MET(TranslationKey.of("requirement_not_met")),
COORDINATES(TranslationKey.of("coordinates"));
COORDINATES(TranslationKey.of("coordinates")),
// Fauna
FAUNA_DISCOVER_TITLE(TranslationKey.of("fauna_discover_title")),
FAUNA_DISCOVER_SUBTITLE(TranslationKey.of("fauna_discover_subtitle"));
private final TranslationKey key;
private final boolean isList;

View File

@@ -30,3 +30,6 @@ discovering_area_placeholder: "<gold>Discovering a new area (%d%)..."
requirement_met: "<gradient:dark_green:green>✔ %s"
requirement_not_met: "<gradient:dark_red:red>✘ %s"
coordinates: "<gray>Coordinates: %d, %d"
# Fauna related settings
fauna_discover_title: "<#F5AF2F>Bestiary Updated"
fauna_discover_subtitle: "<white>%s <#04DB64>indexed"