mirror of
https://gitlab.com/SamB440/rpgregions-2.git
synced 2026-01-06 15:41:35 +00:00
Add discovered titles
This commit is contained in:
@@ -70,8 +70,8 @@ public class RegionListener implements Listener {
|
||||
});
|
||||
}
|
||||
|
||||
if (configuredRegion.alwaysShowTitles() && ree.hasChanged()) {
|
||||
this.sendTitles(player, configuredRegion);
|
||||
if (configuredRegion.alwaysShowTitles() && ree.hasChanged() && has) {
|
||||
this.sendTitles(player, configuredRegion, false);
|
||||
}
|
||||
|
||||
if (!has && configuredRegion.isDiscoverable()) {
|
||||
@@ -93,7 +93,7 @@ public class RegionListener implements Listener {
|
||||
String region = rde.getRegion();
|
||||
if (plugin.getManagers().getRegionsCache().getConfiguredRegions().containsKey(region)) {
|
||||
ConfiguredRegion configuredRegion = plugin.getManagers().getRegionsCache().getConfiguredRegion(region);
|
||||
this.sendTitles(player, configuredRegion);
|
||||
this.sendTitles(player, configuredRegion, true);
|
||||
|
||||
if (configuredRegion.getSound() == null) {
|
||||
player.playSound(
|
||||
@@ -115,7 +115,18 @@ public class RegionListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
private void sendTitles(Player player, ConfiguredRegion configuredRegion) {
|
||||
private void sendTitles(Player player, ConfiguredRegion configuredRegion, boolean discovered) {
|
||||
if (!discovered) {
|
||||
List<String> discoveredTitle = configuredRegion.getDiscoveredTitle(player);
|
||||
List<String> discoveredSubtitle = configuredRegion.getDiscoveredSubtitle(player);
|
||||
new TitleAnimator(player,
|
||||
plugin,
|
||||
discoveredTitle,
|
||||
discoveredSubtitle,
|
||||
plugin.getConfig().getInt("settings.server.discoveries.discovered.title.animation_speed"));
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> title = configuredRegion.getTitle(player);
|
||||
List<String> subtitle = configuredRegion.getSubtitle(player);
|
||||
new TitleAnimator(player,
|
||||
|
||||
@@ -52,6 +52,8 @@ public class ConfiguredRegion {
|
||||
private final boolean alwaysShowTitles;
|
||||
private List<String> title;
|
||||
private List<String> subtitle;
|
||||
private List<String> discoveredTitle;
|
||||
private List<String> discoveredSubtitle;
|
||||
|
||||
public ConfiguredRegion(@Nullable World world, String id, String customName,
|
||||
List<DiscoveryReward> rewards, List<RegionEffect> effects, int x, int y, int z) {
|
||||
@@ -242,6 +244,38 @@ public class ConfiguredRegion {
|
||||
subtitle.forEach(sub -> translatedSubtitle.add(ChatColor.translateAlternateColorCodes('&', sub)));
|
||||
return translatedSubtitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the region discovered title for a player. If region title is null, the translation files will be used.
|
||||
* @param player the player
|
||||
* @return A string list of title
|
||||
*/
|
||||
@NotNull
|
||||
public List<String> getDiscoveredTitle(Player player) {
|
||||
if (title == null) {
|
||||
return Translations.ALREADY_DISCOVERED_TITLE.getList(player, customName);
|
||||
}
|
||||
|
||||
List<String> translatedTitle = new ArrayList<>();
|
||||
discoveredTitle.forEach(titles -> translatedTitle.add(ChatColor.translateAlternateColorCodes('&', titles)));
|
||||
return translatedTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the region discovered subtitle for a player. If region subtitle is null, the translation files will be used.
|
||||
* @param player the player
|
||||
* @return A string list of subtitles
|
||||
*/
|
||||
@NotNull
|
||||
public List<String> getDiscoveredSubtitle(Player player) {
|
||||
if (discoveredSubtitle == null) {
|
||||
return Translations.ALREADY_DISCOVERED_SUBTITLE.getList(player, customName);
|
||||
}
|
||||
|
||||
List<String> translatedSubtitle = new ArrayList<>();
|
||||
discoveredSubtitle.forEach(sub -> translatedSubtitle.add(ChatColor.translateAlternateColorCodes('&', sub)));
|
||||
return translatedSubtitle;
|
||||
}
|
||||
|
||||
public void save(RPGRegions plugin) throws IOException {
|
||||
File file = new File(plugin.getDataFolder() + "/regions/" + this.id + ".json");
|
||||
|
||||
@@ -22,6 +22,8 @@ public enum Translations {
|
||||
DISCOVERED_ON("&7Discovered on: %0"),
|
||||
DISCOVERED_TITLE("&d%0 discovered!", true),
|
||||
DISCOVERED_SUBTITLE("&fKeep exploring to discover more!", true),
|
||||
ALREADY_DISCOVERED_TITLE("&d%0 entered!", true),
|
||||
ALREADY_DISCOVERED_SUBTITLE("&fAlready discovered!", true),
|
||||
TELEPORT("&aClick to teleport"),
|
||||
CANNOT_TELEPORT("&cWe can't teleport you because that world doesn't exist!"),
|
||||
UNKNOWN_REGION("Unknown Realm"),
|
||||
|
||||
Reference in New Issue
Block a user