diff --git a/core/src/main/java/io/github/dre2n/dungeonsxl/config/WorldConfig.java b/core/src/main/java/io/github/dre2n/dungeonsxl/config/WorldConfig.java index 83ccafbb..5ec33a7d 100644 --- a/core/src/main/java/io/github/dre2n/dungeonsxl/config/WorldConfig.java +++ b/core/src/main/java/io/github/dre2n/dungeonsxl/config/WorldConfig.java @@ -265,6 +265,34 @@ public class WorldConfig extends GameRules { if (configFile.contains("forcedGameType")) { forcedGameType = plugin.getGameTypes().getByName(configFile.getString("forcedGameType")); } + + if (configFile.contains("title.title")) { + title = configFile.getString("title.title"); + } + + if (configFile.contains("title.subtitle")) { + subtitle = configFile.getString("title.subtitle"); + } + + if (configFile.contains("title.actionBar")) { + actionBar = configFile.getString("title.actionBar"); + } + + if (configFile.contains("title.chat")) { + chat = configFile.getString("title.chat"); + } + + if (configFile.contains("title.fadeIn")) { + titleFadeIn = (int) configFile.getDouble("title.fadeIn") * 20; + } + + if (configFile.contains("title.fadeOut")) { + titleFadeOut = (int) configFile.getDouble("title.fadeOut") * 20; + } + + if (configFile.contains("title.show")) { + titleShow = (int) configFile.getDouble("title.show") * 20; + } } public void save() { diff --git a/core/src/main/java/io/github/dre2n/dungeonsxl/game/GameRules.java b/core/src/main/java/io/github/dre2n/dungeonsxl/game/GameRules.java index 0cd6e350..55b6744a 100644 --- a/core/src/main/java/io/github/dre2n/dungeonsxl/game/GameRules.java +++ b/core/src/main/java/io/github/dre2n/dungeonsxl/game/GameRules.java @@ -79,6 +79,11 @@ public class GameRules { DEFAULT_VALUES.gameCommandWhitelist = new ArrayList<>(); DEFAULT_VALUES.gamePermissions = new ArrayList<>(); + /* Title */ + DEFAULT_VALUES.titleFadeIn = 20; + DEFAULT_VALUES.titleFadeOut = 20; + DEFAULT_VALUES.titleShow = 60; + /* Misc */ DEFAULT_VALUES.msgs = new HashMap<>(); DEFAULT_VALUES.secureObjects = new ArrayList<>(); @@ -125,6 +130,15 @@ public class GameRules { protected List gameCommandWhitelist; protected List gamePermissions; + /* Title */ + protected String title; + protected String subtitle; + protected String actionBar; + protected String chat; + protected Integer titleFadeIn; + protected Integer titleFadeOut; + protected Integer titleShow; + /* Misc */ protected Map msgs; protected List secureObjects; @@ -372,6 +386,112 @@ public class GameRules { return gamePermissions; } + // Title + /** + * @return the main title string or null for the default one + */ + public String getTitle() { + return title; + } + + /** + * @param text + * the text to set + */ + public void setTitle(String text) { + title = text; + } + + /** + * @return the subtitle string or null for the default one + */ + public String getSubTitle() { + return subtitle; + } + + /** + * @param text + * the text to set + */ + public void setSubTitle(String text) { + subtitle = text; + } + + /** + * @return the action bar string or null for the default one + */ + public String getActionBar() { + return actionBar; + } + + /** + * @param text + * the text to set + */ + public void setActionBar(String text) { + actionBar = text; + } + + /** + * @return the chat message string or null for the default one + */ + public String getChatText() { + return chat; + } + + /** + * @param text + * the text to set + */ + public void setChatText(String text) { + chat = text; + } + + /** + * @return the title fade in time in ticks + */ + public int getTitleFadeIn() { + return titleFadeIn; + } + + /** + * @param time + * the time to set + */ + public void setTitleFadeIn(int time) { + titleFadeIn = time; + } + + /** + * @return the title fade out time in ticks + */ + public int getTitleFadeOut() { + return titleFadeOut; + } + + /** + * @param time + * the time to set + */ + public void setTitleFadeOut(int time) { + titleFadeOut = time; + } + + /** + * @return the time until the title disappears in ticks + */ + public int getTitleShow() { + return titleShow; + } + + /** + * @param time + * the time to set + */ + public void setTitleShow(int time) { + titleShow = time; + } + // Misc /** * @param id @@ -579,6 +699,35 @@ public class GameRules { gamePermissions.addAll(defaultValues.gamePermissions); } + /* Title */ + if (title == null) { + title = defaultValues.title; + } + + if (subtitle == null) { + subtitle = defaultValues.subtitle; + } + + if (actionBar == null) { + actionBar = defaultValues.actionBar; + } + + if (chat == null) { + chat = defaultValues.chat; + } + + if (titleFadeIn == null) { + titleFadeIn = defaultValues.titleFadeIn; + } + + if (titleFadeOut == null) { + titleFadeOut = defaultValues.titleFadeOut; + } + + if (titleShow == null) { + titleShow = defaultValues.titleShow; + } + /* Misc */ if (msgs == null) { msgs = defaultValues.msgs; diff --git a/core/src/main/java/io/github/dre2n/dungeonsxl/player/DGroup.java b/core/src/main/java/io/github/dre2n/dungeonsxl/player/DGroup.java index 8a73c1a1..3fb8773d 100644 --- a/core/src/main/java/io/github/dre2n/dungeonsxl/player/DGroup.java +++ b/core/src/main/java/io/github/dre2n/dungeonsxl/player/DGroup.java @@ -710,12 +710,26 @@ public class DGroup { dPlayer.respawn(); if (plugin.getMainConfig().isSendFloorTitleEnabled()) { - if (dungeonName != null) { + if (rules.getTitle() != null || rules.getSubTitle() != null) { + String title = rules.getTitle() == null ? "" : rules.getTitle(); + String subtitle = rules.getSubTitle() == null ? "" : rules.getSubTitle(); + + MessageUtil.sendTitleMessage(player, title, subtitle, rules.getTitleFadeIn(), rules.getTitleShow(), rules.getTitleFadeOut()); + + } else if (dungeonName != null) { MessageUtil.sendTitleMessage(player, "&b&l" + dungeonName.replaceAll("_", " "), "&4&l" + mapName.replaceAll("_", " ")); } else { MessageUtil.sendTitleMessage(player, "&4&l" + mapName.replaceAll("_", " ")); } + + if (rules.getActionBar() != null) { + MessageUtil.sendActionBarMessage(player, rules.getActionBar()); + } + + if (rules.getChatText() != null) { + MessageUtil.sendCenteredMessage(player, rules.getChatText()); + } } for (Requirement requirement : rules.getRequirements()) {