1.3.1 rc1

This commit is contained in:
Tyler Murphy 2021-12-20 21:17:30 -05:00
parent 0dee7fd2fb
commit 7bc3b4e399
7 changed files with 27 additions and 80 deletions

View file

@ -40,11 +40,4 @@
<version>4.7.0</version>
</dependency>
</dependencies>
<distributionManagement>
<repository>
<id>github</id>
<name>GitHub Packages</name>
<url>https://maven.pkg.github.com/tylermurphy534/KenshinsHideAndSeek</url>
</repository>
</distributionManagement>
</project>

View file

@ -13,9 +13,11 @@ public class ConfigManager {
private File file;
private YamlConfiguration config,defaultConfig;
private String defaultFilename;
public ConfigManager(String filename){
this.file = new File(Main.plugin.getDataFolder(), filename);
this.defaultFilename = file.getName();
if(!file.exists()){
saveDefaultConfiguration();
@ -33,6 +35,8 @@ public class ConfigManager {
}
public ConfigManager(String filename, String defaultFilename){
this.defaultFilename = defaultFilename;
this.file = new File(Main.plugin.getDataFolder(), filename);
if(!file.exists()){
@ -99,9 +103,14 @@ public class ConfigManager {
config.set(path, defaultConfig.get(path));
}
public void resetConfig(){
config = defaultConfig;
saveConfig();
public void resetFile(String newDefaultFilename){
this.defaultFilename = newDefaultFilename;
InputStream input = Main.plugin.getResource(defaultFilename);
InputStreamReader reader = new InputStreamReader(input);
this.config = YamlConfiguration.loadConfiguration(reader);
this.defaultConfig = YamlConfiguration.loadConfiguration(reader);
}
public boolean getBoolean(String path){
@ -128,7 +137,7 @@ public class ConfigManager {
public void saveConfig(){
try {
InputStream is = Main.plugin.getResource(file.getName());
InputStream is = Main.plugin.getResource(defaultFilename);
StringBuilder textBuilder = new StringBuilder();
Reader reader = new BufferedReader(new InputStreamReader(is, Charset.forName(StandardCharsets.UTF_8.name())));
int c = 0;
@ -144,15 +153,15 @@ public class ConfigManager {
int i = 0;
for(String part : parts) {
if(i == 0) {
index = yamlString.indexOf(part, index);
index = yamlString.indexOf(part+":", index);
} else {
index = yamlString.indexOf(" " + part, index);
index = yamlString.indexOf(" " + part+":", index);
index++;
}
i++;
if(index == -1) break;
}
if(index == -1) continue;;
if(index < 10) continue;;
int start = yamlString.indexOf(' ', index);
int end = yamlString.indexOf('\n', index);
if(end == -1) end = yamlString.length();
@ -160,8 +169,9 @@ public class ConfigManager {
if(entry.getValue() instanceof String){
replace = "\"" + replace + "\"";
}
System.out.println(entry.getKey() + " " + index + " " + start + " " + end);
StringBuilder builder = new StringBuilder(yamlString);
builder.replace(start+1, end == -1 ? yamlString.length() : end, replace);
builder.replace(start+1, end, replace);
yamlString = builder.toString();
}
}

View file

@ -28,12 +28,13 @@ public class Localization {
manager.reset("version");
}
String SELECTED_LOCAL = manager.getString("local");
if(!SELECTED_LOCAL.equals(Config.local)){
manager.resetConfig();
String SELECTED_LOCAL = manager.getString("type");
if(SELECTED_LOCAL == null){
manager.reset("type");
} else if(!SELECTED_LOCAL.equals(Config.local)){
manager.resetFile("lang"+File.separator+"localization_"+Config.local+".yml");
}
manager.saveConfig();
for(String key : manager.getConfigurationSection("Localization").getKeys(false)) {

View file

@ -36,9 +36,6 @@ autoJoin: false
# default: false
teleportToExit: false
countdown:
# The worldborder closes every interval, which is evey [delay] in minutes.
# Thw worldborder starts at [size], and decreases 100 blocks every interval.
# x & z are the center location. [enabled] is whenever the border is enabled.

View file

@ -57,4 +57,6 @@ Localization:
HIDERS_SUBTITLE: "Verstecke dich gut vor den Seekern!"
SEEKERS_SUBTITLE: "Finde alle Hider!"
# DO NOT EDIT IT OR IT MAY BREAK OR RESET FILE
version: 2
type: "de-DE"

View file

@ -61,4 +61,6 @@ Localization:
BOUNDS: "Successfully set bounds at this position ({AMOUNT}/2)."
NOT_AT_ZERO: "Please do not set at a location containing a coordinate at 0."
# DO NOT EDIT IT OR IT MAY BREAK OR RESET FILE
version: 2
type: "en-US"

View file

@ -1,58 +0,0 @@
Localization:
COMMAND_PLAYER_ONLY: "This command can only be run as a player."
COMMAND_NOT_ALLOWED: "You are not allowed to run this command."
COMMAND_ERROR: "An internal error has occurred."
GAME_PLAYER_DEATH: "&c{PLAYER}&f was killed."
GAME_PLAYER_FOUND: "&e{PLAYER}&f was found and became a seeker."
GAME_PLAYER_FOUND_BY: "&e{PLAYER}&f was found by &c{PLAYER}&f and became a seeker."
GAME_GAMEOVER_HIDERS_FOUND: "All hiders have been found."
GAME_GAMEOVER_SEEKERS_QUIT: "All seekers have quit."
GAME_GAMEOVER_TIME: "Seekers ran out of time. Hiders win!"
GAME_SETUP: "Game is not setup. Run /hs setup to see what you need to do."
GAME_INGAME: "You are already in the lobby/game."
GAME_NOT_INGAME: "You are not in a lobby/game."
GAME_INPROGRESS: "There is currently a game in progress."
GAME_NOT_INPROGRESS: "There is no game in progress."
GAME_JOIN: "{PLAYER} has joined the HideAndSeek lobby."
GAME_JOIN_SPECTATOR: "You have joined mid game and are now a spectator."
GAME_LEAVE: "{PLAYER} has left the HideAndSeek lobby."
CONFIG_RELOAD: "Reloaded the config."
MAPSAVE_INPROGRESS: "Map save is currently in progress. Try again later."
MAPSAVE_START: "Starting map save."
MAPSAVE_WARNING: "All commands will be disabled when the save is in progress. Do not turn off the server."
MAPSAVE_END: "Map save complete."
MAPSAVE_ERROR: "Couldn't find current map."
WORLDBORDER_DISABLE: "Disabled world border."
WORLDBORDER_INVALID_INPUT: "Invalid integer {AMOUNT}."
WORLDBORDER_MIN_SIZE: "World border cannot be smaller than 100 blocks."
WORLDBORDER_POSITION: "Spawn position must be 100 from world border center."
WORLDBORDER_ENABLE: "Set border center to current location, size to {AMOUNT}, and delay to {AMOUNT}."
WORLDBORDER_DECREASING: "World border decreasing by 100 blocks over the next 30s."
TAUNTED: "$c$oOh no! You have been chosen to be taunted."
TAUNT: "A random hider will be taunted in the next 30s."
TAUNT_ACTIVATE: "Taunt has been activated."
ERROR_GAME_SPAWN: "Please set game spawn location first"
SETUP: "&f&lThe following is needed for setup..."
SETUP_GAME: "&c&l- &fGame spawn isn't set, /hs setspawn"
SETUP_LOBBY: "&c&l- &fLobby spawn isn't set, /hs setlobby"
SETUP_EXIT: "&c&l- &fQuit/exit teleport location isn't set, /hs setexit"
SETUP_SAVEMAP: "&c&l- &fHide and seek map isn't saved, /hs savemap (after /hs setspawn)"
SETUP_BOUNDS: "&c&l- &fPlease set game bounds in 2 opposite corners of the game map, /hs setbounds"
SETUP_COMPLETE: "Everything is setup and ready to go!"
GAME_SPAWN: "Set game spawn position to current location"
LOBBY_SPAWN: "Set lobby position to current location"
EXIT_SPAWN: "Set exit position to current location"
START_MIN_PLAYERS: "You must have at least {AMOUNT} players to start."
START_INVALID_NAME: "Invalid player: {PLAYER}."
START_COUNTDOWN: "Hiders have {AMOUNT} seconds to hide!"
START: "Attention SEEKERS, its time to fin the hiders!"
STOP: "Game has been force stopped."
HIDERS_SUBTITLE: "Hide away from the seekers"
SEEKERS_SUBTITLE: "Eliminate all hiders"
BOUNDS_WRONG_WORLD: "Please run this command in the game world."
BOUNDS: "Successfully set bounds at this position ({AMOUNT}/2)."
NOT_AT_ZERO: "Please do not set at a location containing a coordinate at 0."
# DO NOT EDIT IT OR IT MAY BREAK OR RESET FILE
version: 2
type: "en-US"