2021-12-27 19:01:39 +00:00
|
|
|
/*
|
|
|
|
* This file is part of Kenshins Hide and Seek
|
|
|
|
*
|
|
|
|
* Copyright (c) 2021 Tyler Murphy.
|
|
|
|
*
|
|
|
|
* Kenshins Hide and Seek free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
2021-12-27 19:14:32 +00:00
|
|
|
* he Free Software Foundation version 3.
|
2021-12-27 19:01:39 +00:00
|
|
|
*
|
|
|
|
* Kenshins Hide and Seek is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2021-10-23 00:03:15 +00:00
|
|
|
package net.tylermurphy.hideAndSeek.configuration;
|
2021-08-13 20:49:36 +00:00
|
|
|
|
2022-04-22 00:12:09 +00:00
|
|
|
import com.cryptomorin.xseries.XItemStack;
|
2022-04-20 00:00:53 +00:00
|
|
|
import com.cryptomorin.xseries.XMaterial;
|
2022-05-04 20:30:55 +00:00
|
|
|
import com.cryptomorin.xseries.XSound;
|
2022-05-05 16:22:04 +00:00
|
|
|
import net.tylermurphy.hideAndSeek.Main;
|
2022-05-14 01:17:46 +00:00
|
|
|
import net.tylermurphy.hideAndSeek.game.util.CountdownDisplay;
|
|
|
|
import net.tylermurphy.hideAndSeek.game.util.Version;
|
2022-04-22 00:12:09 +00:00
|
|
|
import org.bukkit.ChatColor;
|
2022-04-20 00:00:53 +00:00
|
|
|
import org.bukkit.Material;
|
2022-04-22 00:12:09 +00:00
|
|
|
import org.bukkit.configuration.ConfigurationSection;
|
|
|
|
import org.bukkit.configuration.file.YamlConfiguration;
|
|
|
|
import org.bukkit.inventory.ItemStack;
|
2021-08-13 20:49:36 +00:00
|
|
|
import org.bukkit.util.Vector;
|
2022-05-14 03:11:35 +00:00
|
|
|
import org.jetbrains.annotations.Nullable;
|
2021-08-13 20:49:36 +00:00
|
|
|
|
2022-04-20 00:00:53 +00:00
|
|
|
import java.util.ArrayList;
|
2022-04-12 19:11:49 +00:00
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.List;
|
2022-04-20 00:00:53 +00:00
|
|
|
import java.util.Optional;
|
2022-04-12 19:11:49 +00:00
|
|
|
|
2021-10-21 00:14:01 +00:00
|
|
|
public class Config {
|
2021-10-29 03:09:28 +00:00
|
|
|
|
2022-05-13 16:28:13 +00:00
|
|
|
private static ConfigManager config;
|
|
|
|
|
2021-08-26 13:38:12 +00:00
|
|
|
public static String
|
|
|
|
messagePrefix,
|
|
|
|
errorPrefix,
|
|
|
|
tauntPrefix,
|
|
|
|
worldborderPrefix,
|
|
|
|
abortPrefix,
|
|
|
|
gameoverPrefix,
|
2021-08-27 21:20:07 +00:00
|
|
|
warningPrefix,
|
2021-08-26 13:38:12 +00:00
|
|
|
spawnWorld,
|
2021-10-18 02:52:57 +00:00
|
|
|
exitWorld,
|
2021-12-20 22:24:43 +00:00
|
|
|
lobbyWorld,
|
2022-04-22 00:12:09 +00:00
|
|
|
locale,
|
2022-05-09 20:19:24 +00:00
|
|
|
leaveServer,
|
|
|
|
placeholderError,
|
|
|
|
placeholderNoData;
|
2021-08-18 23:21:59 +00:00
|
|
|
|
2021-10-18 02:52:57 +00:00
|
|
|
public static Vector
|
2021-08-26 13:38:12 +00:00
|
|
|
spawnPosition,
|
2021-10-11 21:06:21 +00:00
|
|
|
lobbyPosition,
|
2021-10-18 02:52:57 +00:00
|
|
|
exitPosition,
|
2021-08-26 13:38:12 +00:00
|
|
|
worldborderPosition;
|
2021-08-18 23:21:59 +00:00
|
|
|
|
2021-08-26 13:38:12 +00:00
|
|
|
public static boolean
|
|
|
|
nametagsVisible,
|
|
|
|
permissionsRequired,
|
2021-10-18 02:52:57 +00:00
|
|
|
announceMessagesToNonPlayers,
|
2021-10-29 23:57:40 +00:00
|
|
|
worldborderEnabled,
|
|
|
|
tauntEnabled,
|
|
|
|
tauntCountdown,
|
|
|
|
tauntLast,
|
|
|
|
glowEnabled,
|
2021-10-31 15:25:27 +00:00
|
|
|
glowStackable,
|
|
|
|
pvpEnabled,
|
|
|
|
autoJoin,
|
2021-12-25 14:16:03 +00:00
|
|
|
teleportToExit,
|
2022-04-11 16:36:11 +00:00
|
|
|
lobbyCountdownEnabled,
|
2022-04-22 00:12:09 +00:00
|
|
|
seekerPing,
|
|
|
|
bungeeLeave,
|
2022-05-04 16:22:23 +00:00
|
|
|
lobbyItemStartAdmin,
|
2022-05-06 16:22:04 +00:00
|
|
|
leaveOnEnd,
|
2022-05-08 03:54:48 +00:00
|
|
|
mapSaveEnabled,
|
|
|
|
allowNaturalCauses;
|
2021-08-25 03:43:01 +00:00
|
|
|
|
2021-08-26 13:38:12 +00:00
|
|
|
public static int
|
|
|
|
minPlayers,
|
|
|
|
worldborderSize,
|
|
|
|
worldborderDelay,
|
2021-10-18 02:52:57 +00:00
|
|
|
currentWorldborderSize,
|
2022-04-22 00:12:09 +00:00
|
|
|
worldborderChange,
|
2021-10-27 23:57:44 +00:00
|
|
|
gameLength,
|
|
|
|
saveMinX,
|
|
|
|
saveMinZ,
|
|
|
|
saveMaxX,
|
2021-10-29 23:57:40 +00:00
|
|
|
saveMaxZ,
|
|
|
|
tauntDelay,
|
2021-12-25 14:16:03 +00:00
|
|
|
glowLength,
|
|
|
|
countdown,
|
|
|
|
changeCountdown,
|
|
|
|
lobbyMin,
|
2022-04-11 16:36:11 +00:00
|
|
|
lobbyMax,
|
|
|
|
seekerPingLevel1,
|
|
|
|
seekerPingLevel2,
|
2022-04-22 00:12:09 +00:00
|
|
|
seekerPingLevel3,
|
|
|
|
lobbyItemLeavePosition,
|
2022-05-14 03:11:35 +00:00
|
|
|
lobbyItemStartPosition,
|
|
|
|
flightToggleItemPosition,
|
|
|
|
teleportItemPosition;
|
2022-04-12 19:11:49 +00:00
|
|
|
|
2022-05-04 20:30:55 +00:00
|
|
|
public static float
|
|
|
|
seekerPingLeadingVolume,
|
|
|
|
seekerPingVolume,
|
|
|
|
seekerPingPitch;
|
|
|
|
|
2022-04-20 00:00:53 +00:00
|
|
|
public static List<String>
|
|
|
|
blockedCommands,
|
|
|
|
blockedInteracts;
|
|
|
|
|
2022-04-12 19:11:49 +00:00
|
|
|
public static String
|
|
|
|
LOBBY_TITLE,
|
|
|
|
GAME_TITLE,
|
|
|
|
COUNTDOWN_WAITING,
|
|
|
|
COUNTDOWN_COUNTING,
|
|
|
|
COUNTDOWN_ADMINSTART,
|
|
|
|
TAUNT_COUNTING,
|
|
|
|
TAUNT_ACTIVE,
|
|
|
|
TAUNT_EXPIRED,
|
|
|
|
GLOW_ACTIVE,
|
|
|
|
GLOW_INACTIVE,
|
|
|
|
BORDER_COUNTING,
|
|
|
|
BORDER_DECREASING;
|
|
|
|
|
|
|
|
public static List<String>
|
|
|
|
LOBBY_CONTENTS,
|
|
|
|
GAME_CONTENTS;
|
2022-04-22 00:12:09 +00:00
|
|
|
|
|
|
|
public static ItemStack
|
|
|
|
lobbyLeaveItem,
|
2022-05-04 20:30:55 +00:00
|
|
|
lobbyStartItem,
|
2022-05-14 03:11:35 +00:00
|
|
|
glowPowerupItem,
|
|
|
|
flightToggleItem,
|
|
|
|
teleportItem;
|
2022-05-04 20:30:55 +00:00
|
|
|
|
|
|
|
public static XSound
|
|
|
|
ringingSound,
|
|
|
|
heartbeatSound;
|
2022-05-05 16:22:04 +00:00
|
|
|
|
|
|
|
public static CountdownDisplay
|
|
|
|
countdownDisplay;
|
2021-08-13 20:49:36 +00:00
|
|
|
|
2021-08-25 03:43:01 +00:00
|
|
|
public static void loadConfig() {
|
2021-10-29 03:09:28 +00:00
|
|
|
|
2022-05-05 16:58:57 +00:00
|
|
|
config = ConfigManager.create("config.yml");
|
2022-04-12 19:11:49 +00:00
|
|
|
config.saveConfig();
|
2022-05-13 16:28:13 +00:00
|
|
|
ConfigManager leaderboard = ConfigManager.create("leaderboard.yml");
|
2021-10-29 03:09:28 +00:00
|
|
|
|
2021-08-26 13:38:12 +00:00
|
|
|
//Spawn
|
2021-08-25 03:43:01 +00:00
|
|
|
spawnPosition = new Vector(
|
2022-04-12 19:11:49 +00:00
|
|
|
config.getDouble("spawns.game.x"),
|
2022-04-28 19:56:47 +00:00
|
|
|
Math.max(Version.atLeast("1.18") ? -64 : 0, Math.min(255, config.getDouble("spawns.game.y"))),
|
2022-04-12 19:11:49 +00:00
|
|
|
config.getDouble("spawns.game.z")
|
2021-10-29 03:09:28 +00:00
|
|
|
);
|
2022-04-12 19:11:49 +00:00
|
|
|
spawnWorld = config.getString("spawns.game.world");
|
2021-10-29 03:09:28 +00:00
|
|
|
|
2021-10-11 21:06:21 +00:00
|
|
|
///Lobby
|
|
|
|
lobbyPosition = new Vector(
|
2022-04-12 19:11:49 +00:00
|
|
|
config.getDouble("spawns.lobby.x"),
|
2022-04-22 00:12:09 +00:00
|
|
|
Math.max(Version.atLeast("1.18") ? -64 : 0, Math.min(255, config.getDouble("spawns.lobby.y"))),
|
2022-04-12 19:11:49 +00:00
|
|
|
config.getDouble("spawns.lobby.z")
|
2021-10-29 03:09:28 +00:00
|
|
|
);
|
2022-04-12 19:11:49 +00:00
|
|
|
lobbyWorld = config.getString("spawns.lobby.world");
|
2021-10-29 03:09:28 +00:00
|
|
|
|
2022-04-12 19:11:49 +00:00
|
|
|
announceMessagesToNonPlayers = config.getBoolean("announceMessagesToNonPlayers");
|
2021-10-29 03:09:28 +00:00
|
|
|
|
2021-10-18 02:52:57 +00:00
|
|
|
exitPosition = new Vector(
|
2022-04-12 19:11:49 +00:00
|
|
|
config.getDouble("spawns.exit.x"),
|
2022-04-22 00:12:09 +00:00
|
|
|
Math.max(Version.atLeast("1.18") ? -64 : 0, Math.min(255, config.getDouble("spawns.exit.y"))),
|
2022-04-12 19:11:49 +00:00
|
|
|
config.getDouble("spawns.exit.z")
|
2021-10-29 03:09:28 +00:00
|
|
|
);
|
2022-04-12 19:11:49 +00:00
|
|
|
exitWorld = config.getString("spawns.exit.world");
|
2021-10-29 03:09:28 +00:00
|
|
|
|
2021-08-26 13:38:12 +00:00
|
|
|
//World border
|
2021-08-25 03:43:01 +00:00
|
|
|
worldborderPosition = new Vector(
|
2022-04-12 19:11:49 +00:00
|
|
|
config.getInt("worldBorder.x"),
|
2021-10-29 03:09:28 +00:00
|
|
|
0,
|
2022-04-12 19:11:49 +00:00
|
|
|
config.getInt("worldBorder.z")
|
2021-10-29 03:09:28 +00:00
|
|
|
);
|
2022-04-12 19:11:49 +00:00
|
|
|
worldborderSize = Math.max(100, config.getInt("worldBorder.size"));
|
|
|
|
worldborderDelay = Math.max(1, config.getInt("worldBorder.delay"));
|
|
|
|
worldborderEnabled = config.getBoolean("worldBorder.enabled");
|
2022-04-22 00:12:09 +00:00
|
|
|
worldborderChange = config.getInt("worldBorder.moveAmount");
|
2021-10-29 03:09:28 +00:00
|
|
|
|
2021-08-26 13:38:12 +00:00
|
|
|
//Prefix
|
2021-08-25 04:02:24 +00:00
|
|
|
char SYMBOLE = '\u00A7';
|
2021-10-29 23:57:40 +00:00
|
|
|
String SYMBOLE_STRING = String.valueOf(SYMBOLE);
|
2021-10-29 03:09:28 +00:00
|
|
|
|
2022-04-12 19:11:49 +00:00
|
|
|
messagePrefix = config.getString("prefix.default").replace("&", SYMBOLE_STRING);
|
|
|
|
errorPrefix = config.getString("prefix.error").replace("&", SYMBOLE_STRING);
|
|
|
|
tauntPrefix = config.getString("prefix.taunt").replace("&", SYMBOLE_STRING);
|
|
|
|
worldborderPrefix = config.getString("prefix.border").replace("&", SYMBOLE_STRING);
|
|
|
|
abortPrefix = config.getString("prefix.abort").replace("&", SYMBOLE_STRING);
|
|
|
|
gameoverPrefix = config.getString("prefix.gameover").replace("&", SYMBOLE_STRING);
|
|
|
|
warningPrefix = config.getString("prefix.warning").replace("&", SYMBOLE_STRING);
|
2021-10-29 03:09:28 +00:00
|
|
|
|
2021-10-27 23:57:44 +00:00
|
|
|
//Map Bounds
|
2022-04-12 19:11:49 +00:00
|
|
|
saveMinX = config.getInt("bounds.min.x");
|
|
|
|
saveMinZ = config.getInt("bounds.min.z");
|
|
|
|
saveMaxX = config.getInt("bounds.max.x");
|
|
|
|
saveMaxZ = config.getInt("bounds.max.z");
|
2022-05-06 16:22:04 +00:00
|
|
|
mapSaveEnabled = config.getBoolean("mapSaveEnabled");
|
2021-10-29 03:09:28 +00:00
|
|
|
|
2021-10-29 23:57:40 +00:00
|
|
|
//Taunt
|
2022-04-12 19:11:49 +00:00
|
|
|
tauntEnabled = config.getBoolean("taunt.enabled");
|
|
|
|
tauntCountdown = config.getBoolean("taunt.showCountdown");
|
|
|
|
tauntDelay = Math.max(60, config.getInt("taunt.delay"));
|
|
|
|
tauntLast = config.getBoolean("taunt.whenLastPerson");
|
2021-10-29 23:57:40 +00:00
|
|
|
|
|
|
|
//Glow
|
2022-04-12 19:11:49 +00:00
|
|
|
glowLength = Math.max(1, config.getInt("glow.time"));
|
|
|
|
glowStackable = config.getBoolean("glow.stackable");
|
|
|
|
glowEnabled = config.getBoolean("glow.enabled") && Version.atLeast("1.9");
|
2022-05-13 17:01:31 +00:00
|
|
|
if (glowEnabled) {
|
2022-05-14 03:11:35 +00:00
|
|
|
glowPowerupItem = createItemStack("glow");
|
2022-05-04 20:30:55 +00:00
|
|
|
}
|
2021-10-29 23:57:40 +00:00
|
|
|
|
2021-12-25 14:16:03 +00:00
|
|
|
//Lobby
|
2022-04-12 19:11:49 +00:00
|
|
|
minPlayers = Math.max(2, config.getInt("minPlayers"));
|
|
|
|
countdown = Math.max(10, config.getInt("lobby.countdown"));
|
|
|
|
changeCountdown = Math.max(minPlayers, config.getInt("lobby.changeCountdown"));
|
|
|
|
lobbyMin = Math.max(minPlayers, config.getInt("lobby.min"));
|
|
|
|
lobbyMax = config.getInt("lobby.max");
|
|
|
|
lobbyCountdownEnabled = config.getBoolean("lobby.enabled");
|
2021-12-25 14:16:03 +00:00
|
|
|
|
2022-04-11 16:36:11 +00:00
|
|
|
//SeekerPing
|
2022-04-12 19:11:49 +00:00
|
|
|
seekerPing = config.getBoolean("seekerPing.enabled");
|
|
|
|
seekerPingLevel1 = config.getInt("seekerPing.distances.level1");
|
|
|
|
seekerPingLevel2 = config.getInt("seekerPing.distances.level2");
|
|
|
|
seekerPingLevel3 = config.getInt("seekerPing.distances.level3");
|
2022-05-04 20:30:55 +00:00
|
|
|
seekerPingLeadingVolume = config.getFloat("seekerPing.sounds.leadingVolume");
|
|
|
|
seekerPingVolume = config.getFloat("seekerPing.sounds.volume");
|
|
|
|
seekerPingPitch = config.getFloat("seekerPing.sounds.pitch");
|
|
|
|
Optional<XSound> heartbeatOptional = XSound.matchXSound(config.getString("seekerPing.sounds.heartbeatNoise"));
|
|
|
|
heartbeatSound = heartbeatOptional.orElse(XSound.BLOCK_NOTE_BLOCK_BASEDRUM);
|
|
|
|
Optional<XSound> ringingOptional = XSound.matchXSound(config.getString("seekerPing.sounds.ringingNoise"));
|
2022-05-11 15:31:43 +00:00
|
|
|
ringingSound = ringingOptional.orElse(XSound.BLOCK_NOTE_BLOCK_PLING);
|
2022-04-11 16:36:11 +00:00
|
|
|
|
2021-08-26 13:38:12 +00:00
|
|
|
//Other
|
2022-04-12 19:11:49 +00:00
|
|
|
nametagsVisible = config.getBoolean("nametagsVisible");
|
|
|
|
permissionsRequired = config.getBoolean("permissionsRequired");
|
|
|
|
gameLength = config.getInt("gameLength");
|
|
|
|
pvpEnabled = config.getBoolean("pvp");
|
2022-05-08 03:54:48 +00:00
|
|
|
allowNaturalCauses = config.getBoolean("allowNaturalCauses");
|
2022-04-12 19:11:49 +00:00
|
|
|
autoJoin = config.getBoolean("autoJoin");
|
|
|
|
teleportToExit = config.getBoolean("teleportToExit");
|
|
|
|
locale = config.getString("locale", "local");
|
|
|
|
blockedCommands = config.getStringList("blockedCommands");
|
2022-05-04 16:22:23 +00:00
|
|
|
leaveOnEnd = config.getBoolean("leaveOnEnd");
|
2022-05-09 20:19:24 +00:00
|
|
|
placeholderError = config.getString("placeholder.incorrect");
|
|
|
|
placeholderNoData = config.getString("placeholder.noData");
|
2022-05-05 16:22:04 +00:00
|
|
|
try {
|
|
|
|
countdownDisplay = CountdownDisplay.valueOf(config.getString("hideCountdownDisplay"));
|
2022-05-13 17:01:31 +00:00
|
|
|
} catch (IllegalArgumentException e) {
|
2022-05-05 16:22:04 +00:00
|
|
|
countdownDisplay = CountdownDisplay.CHAT;
|
2022-05-14 01:17:46 +00:00
|
|
|
Main.getInstance().getLogger().warning("hideCountdownDisplay: "+config.getString("hideCountdownDisplay")+" is not a valid configuration option!");
|
2022-05-05 16:22:04 +00:00
|
|
|
}
|
2022-04-20 00:00:53 +00:00
|
|
|
blockedInteracts = new ArrayList<>();
|
|
|
|
List<String> tempInteracts = config.getStringList("blockedInteracts");
|
2022-05-13 17:01:31 +00:00
|
|
|
for(String id : tempInteracts) {
|
2022-04-20 00:00:53 +00:00
|
|
|
Optional<XMaterial> optional_mat = XMaterial.matchXMaterial(id);
|
2022-05-13 17:01:31 +00:00
|
|
|
if (optional_mat.isPresent()) {
|
2022-04-20 00:00:53 +00:00
|
|
|
Material mat = optional_mat.get().parseMaterial();
|
2022-05-13 17:01:31 +00:00
|
|
|
if (mat != null) {
|
2022-04-20 00:00:53 +00:00
|
|
|
blockedInteracts.add(mat.name());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-04-22 00:12:09 +00:00
|
|
|
bungeeLeave = config.getString("leaveType") == null || config.getString("leaveType").equalsIgnoreCase("proxy");
|
|
|
|
leaveServer = config.getString("leaveServer");
|
2022-04-12 19:11:49 +00:00
|
|
|
|
|
|
|
//Leaderboard
|
|
|
|
LOBBY_TITLE = leaderboard.getString("lobby.title");
|
|
|
|
GAME_TITLE = leaderboard.getString("game.title");
|
|
|
|
LOBBY_CONTENTS = leaderboard.getStringList("lobby.content");
|
|
|
|
Collections.reverse(LOBBY_CONTENTS);
|
|
|
|
GAME_CONTENTS = leaderboard.getStringList("game.content");
|
|
|
|
Collections.reverse(GAME_CONTENTS);
|
|
|
|
COUNTDOWN_WAITING = leaderboard.getString("countdown.waiting");
|
|
|
|
COUNTDOWN_COUNTING = leaderboard.getString("countdown.counting");
|
|
|
|
COUNTDOWN_ADMINSTART = leaderboard.getString("countdown.adminStart");
|
|
|
|
TAUNT_COUNTING = leaderboard.getString("taunt.counting");
|
|
|
|
TAUNT_ACTIVE = leaderboard.getString("taunt.active");
|
|
|
|
TAUNT_EXPIRED = leaderboard.getString("taunt.expired");
|
|
|
|
GLOW_ACTIVE = leaderboard.getString("glow.active");
|
|
|
|
GLOW_INACTIVE = leaderboard.getString("glow.inactive");
|
|
|
|
BORDER_COUNTING = leaderboard.getString("border.counting");
|
|
|
|
BORDER_DECREASING = leaderboard.getString("border.decreasing");
|
2022-04-22 00:12:09 +00:00
|
|
|
|
|
|
|
//Lobby Items
|
2022-05-13 17:01:31 +00:00
|
|
|
if (config.getBoolean("lobbyItems.leave.enabled")) {
|
2022-05-14 03:11:35 +00:00
|
|
|
lobbyLeaveItem = createItemStack("lobbyItems.leave");
|
2022-04-22 00:12:09 +00:00
|
|
|
lobbyItemLeavePosition = config.getInt("lobbyItems.leave.position");
|
|
|
|
}
|
2022-05-13 17:01:31 +00:00
|
|
|
if (config.getBoolean("lobbyItems.start.enabled")) {
|
2022-05-14 03:11:35 +00:00
|
|
|
lobbyStartItem = createItemStack("lobbyItems.start");
|
2022-04-22 00:12:09 +00:00
|
|
|
lobbyItemStartAdmin = config.getBoolean("lobbyItems.start.adminOnly");
|
|
|
|
lobbyItemStartPosition = config.getInt("lobbyItems.start.position");
|
|
|
|
}
|
2022-05-14 03:11:35 +00:00
|
|
|
|
|
|
|
//Spectator Items
|
|
|
|
flightToggleItem = createItemStack("spectatorItems.flight");
|
|
|
|
flightToggleItemPosition = config.getInt("spectatorItems.flight.position");
|
|
|
|
|
|
|
|
teleportItem = createItemStack("spectatorItems.teleport");
|
|
|
|
teleportItemPosition = config.getInt("spectatorItems.teleport.position");
|
2021-08-25 03:43:01 +00:00
|
|
|
}
|
|
|
|
|
2021-10-27 23:57:44 +00:00
|
|
|
public static void addToConfig(String path, Object value) {
|
2022-04-12 19:11:49 +00:00
|
|
|
config.set(path, value);
|
2021-10-29 03:09:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static void saveConfig() {
|
2022-04-12 19:11:49 +00:00
|
|
|
config.saveConfig();
|
2021-10-27 23:57:44 +00:00
|
|
|
}
|
2022-05-14 03:11:35 +00:00
|
|
|
|
|
|
|
@Nullable
|
|
|
|
private static ItemStack createItemStack(String path){
|
|
|
|
ConfigurationSection item = new YamlConfiguration().createSection("temp");
|
|
|
|
item.set("name", ChatColor.translateAlternateColorCodes('&',config.getString(path+".name")));
|
|
|
|
item.set("material", config.getString(path+".material"));
|
|
|
|
if (Version.atLeast("1.14")) {
|
|
|
|
if (config.contains(path+".model-data") && config.getInt(path+".model-data") != 0) {
|
|
|
|
item.set("model-data", config.getInt(path+".model-data"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
List<String> lore = config.getStringList(path+".lore");
|
|
|
|
if (lore != null && !lore.isEmpty()) item.set("lore", lore);
|
|
|
|
ItemStack temp = null;
|
|
|
|
try{ temp = XItemStack.deserialize(item); } catch(Exception ignored) {}
|
|
|
|
return temp;
|
|
|
|
}
|
2021-10-27 23:57:44 +00:00
|
|
|
|
2021-08-18 23:21:59 +00:00
|
|
|
}
|