9
0
mirror of https://gitlab.com/SamB440/rpgregions-2.git synced 2025-12-28 03:09:14 +00:00

Add actionbar setting when entering region

This commit is contained in:
SamB440
2021-03-18 20:42:07 +00:00
parent fa09d7a003
commit b98f5e8b35
3 changed files with 19 additions and 1 deletions

View File

@@ -73,6 +73,7 @@ public class ConfiguredRegion {
private Regenerate regenerate;
@EditableField(material = XMaterial.NETHER_STAR, name = "Set teleport cooldown", description = "Set the cooldown for teleportation")
private int teleportCooldown;
private boolean showActionbar;
public ConfiguredRegion(@Nullable World world, String id, String customName,
List<DiscoveryReward> rewards, List<RegionEffect> effects) {
@@ -96,6 +97,7 @@ public class ConfiguredRegion {
this.discoveredLore = new ArrayList<>();
this.alwaysShowTitles = false;
this.teleportCooldown = 0;
this.showActionbar = true;
}
public ConfiguredRegion(@Nullable World world, String id, String customName,
@@ -304,6 +306,14 @@ public class ConfiguredRegion {
this.teleportCooldown = teleportCooldown;
}
public boolean showActionbar() {
return showActionbar;
}
public void setShowActionbar(boolean showActionbar) {
this.showActionbar = showActionbar;
}
public void save(IRPGRegionsAPI plugin) {
try {
File file = this.findFile(plugin);

View File

@@ -31,7 +31,8 @@ public enum Translations {
EXIT("&cExit"),
EXIT_LORE("&fExit the GUI", true),
CANNOT_ENTER("&cYou require %0 to enter this area."),
COOLDOWN("&cThat is currently on cooldown.");
COOLDOWN("&cThat is currently on cooldown."),
REGION_ENTER_ACTIONBAR("&a%0");
private final String defaultValue;
private final boolean isList;

View File

@@ -6,9 +6,12 @@ import net.islandearth.rpgregions.api.events.RegionsEnterEvent;
import net.islandearth.rpgregions.managers.data.region.ConfiguredRegion;
import net.islandearth.rpgregions.managers.data.region.Discovery;
import net.islandearth.rpgregions.managers.data.region.WorldDiscovery;
import net.islandearth.rpgregions.translation.Translations;
import net.islandearth.rpgregions.utils.RegenUtils;
import net.islandearth.rpgregions.utils.TitleAnimator;
import net.islandearth.rpgregions.utils.XSound;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@@ -58,6 +61,10 @@ public class RegionListener implements Listener {
this.sendTitles(player, configuredRegion, false);
}
if (configuredRegion.showActionbar()) {
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(Translations.REGION_ENTER_ACTIONBAR.get(player, configuredRegion.getCustomName())));
}
if (!has && configuredRegion.isDiscoverable() && prioritised) {
LocalDateTime date = LocalDateTime.now();
String formattedDate = date.format(format);