Skip to content

Commit

Permalink
Version 0.0.2-RC1
Browse files Browse the repository at this point in the history
Closes #1
This hasn't been tested yet.
  • Loading branch information
JustBru00 committed Jun 9, 2023
1 parent 17f704b commit 374b704
Show file tree
Hide file tree
Showing 5 changed files with 181 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import com.justbru00.timingsystem.bluemap.utils.Messager;
import com.justbru00.timingsystem.bluemap.bstats.BStats;
import com.justbru00.timingsystem.bluemap.configuration.ConfigurationManager;

import de.bluecolored.bluemap.api.BlueMapAPI;
import de.bluecolored.bluemap.api.BlueMapMap;
Expand Down Expand Up @@ -44,7 +45,8 @@ public class TimingSystemBlueMapPlugin extends JavaPlugin {
private static TimingSystemBlueMapPlugin instance;
private static final int BSTATS_PLUGIN_ID = 18483;
private static final String[] TIMING_SYSTEM_SUPPORTED_VERSIONS = {"1.2", "1.3"};


public static String PLUGIN_VERSION = null;
public static ConsoleCommandSender clogger = Bukkit.getServer().getConsoleSender();
public static Logger log = Bukkit.getLogger();

Expand All @@ -60,7 +62,18 @@ public void onDisable() {
@Override
public void onEnable() {
instance = this;
Messager.msgConsole("&6Starting TimingSystemBlueMap " + getDescription().getVersion() + "...");

PLUGIN_VERSION = TimingSystemBlueMapPlugin.getInstance().getDescription().getVersion();
Messager.msgConsole("&6Starting TimingSystemBlueMap " + PLUGIN_VERSION + "...");

saveDefaultConfig();

if (ConfigurationManager.doesConfigYmlNeedUpdated()) {
Messager.msgConsole("&c[WARN] The config.yml file version is incorrect. TimingSystemBlueMap v" + PLUGIN_VERSION +
" expects a config.yml version of " + ConfigurationManager.CONFIG_VERSION +
". Attempting to add missing values to the config file.");
ConfigurationManager.updateConfigYml();
}

Plugin timingSystem = Bukkit.getPluginManager().getPlugin("TimingSystem");
if (timingSystem == null) {
Expand All @@ -79,7 +92,7 @@ public void onEnable() {
}

if (!supportedVersion) {
Messager.msgConsole("&cTimingSystemBlueMap version " + getDescription().getVersion() + " doesn't support TimingSystem version "
Messager.msgConsole("&cTimingSystemBlueMap version " + PLUGIN_VERSION + " doesn't support TimingSystem version "
+ timingSystemVersion + ". The add-on will attempt to run as normal, but you may encounter issues.");
}
}
Expand All @@ -93,6 +106,13 @@ public void onEnable() {
MarkerSet markerSet = MarkerSet.builder().label("TimingSystem Track Locations").toggleable(true).build();

for (Track track : TimingSystemAPI.getTracks()) {
// ISSUE #1
if (TimingSystemBlueMapPlugin.getInstance().getConfig().getBoolean("poi_markers.tracks.spawn_locations.hide_closed_tracks")) {
if (!track.isOpen()) {
continue;
}
} // END ISSUE #1

double x = track.getSpawnLocation().getX();
double y = track.getSpawnLocation().getY();
double z = track.getSpawnLocation().getZ();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
package com.justbru00.timingsystem.bluemap.configuration;

import java.util.ArrayList;
import java.util.List;

import org.bukkit.configuration.file.FileConfiguration;

import com.justbru00.timingsystem.bluemap.TimingSystemBlueMapPlugin;
import com.justbru00.timingsystem.bluemap.utils.Messager;

/**
* TimingSystemBlueMap - This plugin will display track spawn locations as poi markers on bluemap.
* Copyright (C) 2023 Justin "JustBru00" Brubaker
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 <https://www.gnu.org/licenses/>.
*
* @author Justin Brubaker
*
*/
public class ConfigUpdater {
private static FileConfiguration config;

public static void updateConfigYml() {
int currentConfigVersion = ConfigurationManager.CONFIG_VERSION;
if (config == null) {
config = TimingSystemBlueMapPlugin.getInstance().getConfig();
}

if (config.getInt("config_version") != 0) {
if (config.getInt("config_version") == currentConfigVersion) {
// The config version is up to date.
} else {
config.set("config_version", currentConfigVersion);
TimingSystemBlueMapPlugin.getInstance().saveConfig();
}
} else {
// Config value cannot be found.
config.set("config_version", currentConfigVersion);
TimingSystemBlueMapPlugin.getInstance().saveConfig();
}

// Add values if they are missing
updateConfigYmlBoolean("poi_markers.tracks.spawn_locations.hide_closed_tracks", false);
}

private static void updateConfigYmlInteger(String path, int updatedValue) {
if (!config.isSet(path)) {
// Path doesn't exist.
config.set(path, updatedValue);
Messager.msgConsole("[ConfigUpdater] Added " + path + " to config.yml.");
TimingSystemBlueMapPlugin.getInstance().saveConfig();
}
}

private static void updateConfigYmlString(String path, String updatedValue) {
if (!config.isSet(path)) {
// Path doesn't exist.
config.set(path, updatedValue);
Messager.msgConsole("[ConfigUpdater] Added " + path + " to config.yml.");
TimingSystemBlueMapPlugin.getInstance().saveConfig();
}
}

private static void updateConfigYmlBoolean(String path, boolean updatedValue) {
if (!config.isSet(path)) {
// Path doesn't exist.
config.set(path, updatedValue);
Messager.msgConsole("[ConfigUpdater] Added " + path + " to config.yml.");
TimingSystemBlueMapPlugin.getInstance().saveConfig();
}
}

private static void updateConfigYmlStringList(String path, String... updatedValue) {
if (!config.isSet(path)) {
// Path doesn't exist.
List<String> stringList = new ArrayList<String>();
for (String s : updatedValue) {
stringList.add(s);
}

config.set(path, stringList);
Messager.msgConsole("[ConfigUpdater] Added " + path + " to config.yml.");
TimingSystemBlueMapPlugin.getInstance().saveConfig();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.justbru00.timingsystem.bluemap.configuration;

import org.bukkit.configuration.file.FileConfiguration;

import com.justbru00.timingsystem.bluemap.TimingSystemBlueMapPlugin;

/**
* TimingSystemBlueMap - This plugin will display track spawn locations as poi markers on bluemap.
* Copyright (C) 2023 Justin "JustBru00" Brubaker
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 <https://www.gnu.org/licenses/>.
*
* @author Justin Brubaker
*
*/
public class ConfigurationManager {

public static final int CONFIG_VERSION = 1;
private static FileConfiguration config = null;

/**
* Checks the config version number vs the one this version has.
* @return True if it needs updated, false if it doesn't.
*/
public static boolean doesConfigYmlNeedUpdated() {
if (config == null) {
config = TimingSystemBlueMapPlugin.getInstance().getConfig();
}

return config.getInt("config_version") < CONFIG_VERSION;
}

/**
* Adds any new config values to the config.yml file if the config_version value doesn't match the value of this version of EpicRename.
* These must be set manually in the {@link ConfigUpdater}.
* Doesn't touch old values.
*/
public static void updateConfigYml() {
ConfigUpdater.updateConfigYml();
}

}
7 changes: 7 additions & 0 deletions src/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# TimingSystemBlueMap created by JustBru00. This file was generated by 0.0.2
config_version: 1

poi_markers:
tracks:
spawn_locations:
hide_closed_tracks: false
2 changes: 1 addition & 1 deletion src/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: TimingSystemBlueMap
version: 0.0.1
version: 0.0.2-RC1
authors: [Justin Brubaker (JustBru00)]
softdepend: [TimingSystem,BlueMap]
main: com.justbru00.timingsystem.bluemap.TimingSystemBlueMapPlugin
Expand Down

0 comments on commit 374b704

Please sign in to comment.