mirror of
https://github.com/darksaid98/AlathranWars.git
synced 2026-12-02 22:16:00 +00:00
timeout purge
This commit is contained in:
1 parent
cfc28b8fa4
commit
7e83d66417
2 files changed
+112
-112
No files matched your search
@@ -82,7 +82,7 @@ public class Main extends JavaPlugin {
|
|||||||
initLogs();
|
initLogs();
|
||||||
|
|
||||||
new WarData(this);
|
new WarData(this);
|
||||||
new TimeoutData(this);
|
// new TimeoutData(this);
|
||||||
new WarCommands(this);
|
new WarCommands(this);
|
||||||
new SiegeCommands(this);
|
new SiegeCommands(this);
|
||||||
new RaidCommands(this);
|
new RaidCommands(this);
|
||||||
|
|||||||
@@ -11,116 +11,116 @@ import java.util.HashMap;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class TimeoutData {
|
public class TimeoutData {
|
||||||
// Static War list for all active wars
|
// // Static War list for all active wars
|
||||||
private static HashMap<UUID, Integer> timeouts = new HashMap<UUID, Integer>();
|
// private static HashMap<UUID, Integer> timeouts = new HashMap<UUID, Integer>();
|
||||||
private final static String dataFolderPath = "plugins" + File.separator + "AlathraWar" + File.separator + "data";
|
// private final static String dataFolderPath = "plugins" + File.separator + "AlathraWar" + File.separator + "data";
|
||||||
private static File timeoutData = new File(dataFolderPath + File.separator + "timeOutData.yml");
|
// private static File timeoutData = new File(dataFolderPath + File.separator + "timeOutData.yml");
|
||||||
|
//
|
||||||
// // Filter for only accessing yml files
|
//// // Filter for only accessing yml files
|
||||||
// private static FilenameFilter ymlFilter = new FilenameFilter() {
|
//// private static FilenameFilter ymlFilter = new FilenameFilter() {
|
||||||
// @Override
|
//// @Override
|
||||||
// public boolean accept(File dir, String name) {
|
//// public boolean accept(File dir, String name) {
|
||||||
// return name.endsWith(".yml");
|
//// return name.endsWith(".yml");
|
||||||
|
//// }
|
||||||
|
//// };
|
||||||
|
//
|
||||||
|
// // Constructor used to initialise folder.
|
||||||
|
// public TimeoutData(final Main plugin) {
|
||||||
|
// if (!timeoutData.exists()) {
|
||||||
|
// try {
|
||||||
|
// timeoutData.createNewFile();
|
||||||
|
// } catch (IOException e) {
|
||||||
|
// throw new RuntimeException(e);
|
||||||
|
// }
|
||||||
// }
|
// }
|
||||||
// };
|
// }
|
||||||
|
//
|
||||||
// Constructor used to initialise folder.
|
// public static HashMap<UUID, Integer> getWars() {
|
||||||
public TimeoutData(final Main plugin) {
|
// return timeouts;
|
||||||
if (!timeoutData.exists()) {
|
// }
|
||||||
try {
|
//
|
||||||
timeoutData.createNewFile();
|
// /**
|
||||||
} catch (IOException e) {
|
// * Gets a timeout for the player name, if failed to find return -1
|
||||||
throw new RuntimeException(e);
|
// *
|
||||||
}
|
// * @param name - name to check
|
||||||
}
|
// * @return timeout or -1
|
||||||
}
|
// */
|
||||||
|
// public static int getTimeout(String name) {
|
||||||
public static HashMap<UUID, Integer> getWars() {
|
// for (UUID uuid : timeouts.keySet()) {
|
||||||
return timeouts;
|
// if (Bukkit.getPlayer(name).getUniqueId().compareTo(uuid) == 0) return timeouts.get(uuid);
|
||||||
}
|
// }
|
||||||
|
// return -1;
|
||||||
/**
|
// }
|
||||||
* Gets a timeout for the player name, if failed to find return -1
|
//
|
||||||
*
|
// /**
|
||||||
* @param name - name to check
|
// * Gets a timeout for the player uuid, if failed to find return -1
|
||||||
* @return timeout or -1
|
// *
|
||||||
*/
|
// * @param uuidIN - UUID to check
|
||||||
public static int getTimeout(String name) {
|
// * @return timeout or -1
|
||||||
for (UUID uuid : timeouts.keySet()) {
|
// */
|
||||||
if (Bukkit.getPlayer(name).getUniqueId().compareTo(uuid) == 0) return timeouts.get(uuid);
|
// public static int getTimeout(UUID uuidIN) {
|
||||||
}
|
// for (UUID uuid : timeouts.keySet()) {
|
||||||
return -1;
|
// if (uuidIN.compareTo(uuid) == 0) return timeouts.get(uuid);
|
||||||
}
|
// }
|
||||||
|
// return -1;
|
||||||
/**
|
// }
|
||||||
* Gets a timeout for the player uuid, if failed to find return -1
|
//
|
||||||
*
|
// public static void setTimeouts(HashMap<UUID, Integer> timeouts) {
|
||||||
* @param uuidIN - UUID to check
|
// TimeoutData.timeouts = timeouts;
|
||||||
* @return timeout or -1
|
// }
|
||||||
*/
|
//
|
||||||
public static int getTimeout(UUID uuidIN) {
|
// /**
|
||||||
for (UUID uuid : timeouts.keySet()) {
|
// * add player timeout (in seconds)
|
||||||
if (uuidIN.compareTo(uuid) == 0) return timeouts.get(uuid);
|
// * @param player
|
||||||
}
|
// * @param time
|
||||||
return -1;
|
// */
|
||||||
}
|
// public static void addTimeout(Player player, int time) {
|
||||||
|
// if (player == null) {
|
||||||
public static void setTimeouts(HashMap<UUID, Integer> timeouts) {
|
// Main.warLogger.log("Attempted to add NULL to timeout list.");
|
||||||
TimeoutData.timeouts = timeouts;
|
// return;
|
||||||
}
|
// }
|
||||||
|
// timeouts.put(player.getUniqueId(), time);
|
||||||
/**
|
// }
|
||||||
* add player timeout (in seconds)
|
//
|
||||||
* @param player
|
// public static void removeTimeout(Player player) {
|
||||||
* @param time
|
// timeouts.remove(player.getUniqueId());
|
||||||
*/
|
//// deleteWar(war);
|
||||||
public static void addTimeout(Player player, int time) {
|
// }
|
||||||
if (player == null) {
|
//
|
||||||
Main.warLogger.log("Attempted to add NULL to timeout list.");
|
// /**
|
||||||
return;
|
// * Gets the wars currently saved in files as an ArrayList of War Objects
|
||||||
}
|
// *
|
||||||
timeouts.put(player.getUniqueId(), time);
|
// * @return War Object ArrayList
|
||||||
}
|
// */
|
||||||
|
// public static HashMap<UUID, Integer> createTimoutMap() {
|
||||||
public static void removeTimeout(Player player) {
|
//
|
||||||
timeouts.remove(player.getUniqueId());
|
// HashMap<String, Object> fileData = DataManager.getData(timeoutData);
|
||||||
// deleteWar(war);
|
// HashMap<String, Object> list = (HashMap<String, Object>) fileData.get("timeouts");
|
||||||
}
|
//
|
||||||
|
// HashMap<UUID, Integer> out = new HashMap<>();
|
||||||
/**
|
// for (String s : list.keySet()) {
|
||||||
* Gets the wars currently saved in files as an ArrayList of War Objects
|
// out.put(UUID.fromString(s), (Integer) list.get(s));
|
||||||
*
|
// }
|
||||||
* @return War Object ArrayList
|
//
|
||||||
*/
|
// return out;
|
||||||
public static HashMap<UUID, Integer> createTimoutMap() {
|
// }
|
||||||
|
//
|
||||||
HashMap<String, Object> fileData = DataManager.getData(timeoutData);
|
// /**
|
||||||
HashMap<String, Object> list = (HashMap<String, Object>) fileData.get("timeouts");
|
// * Saves the war into files.
|
||||||
|
// *
|
||||||
HashMap<UUID, Integer> out = new HashMap<>();
|
// * @param war - War to be saved.
|
||||||
for (String s : list.keySet()) {
|
// */
|
||||||
out.put(UUID.fromString(s), (Integer) list.get(s));
|
// public static void saveWar(War war) {
|
||||||
}
|
// HashMap<String, Object> sHashMap = new HashMap<String, Object>();
|
||||||
|
//
|
||||||
return out;
|
// HashMap<String, Object> list = new HashMap<>();
|
||||||
}
|
//
|
||||||
|
// for(UUID uuid : timeouts.keySet()) {
|
||||||
/**
|
// list.put(uuid.toString(), timeouts.get(uuid));
|
||||||
* Saves the war into files.
|
// }
|
||||||
*
|
// // Shoves everything into a map.
|
||||||
* @param war - War to be saved.
|
// sHashMap.put("timeouts", list);
|
||||||
*/
|
//
|
||||||
public static void saveWar(War war) {
|
// DataManager.saveData("timeOutData.yml", sHashMap);
|
||||||
HashMap<String, Object> sHashMap = new HashMap<String, Object>();
|
// }
|
||||||
|
|
||||||
HashMap<String, Object> list = new HashMap<>();
|
|
||||||
|
|
||||||
for(UUID uuid : timeouts.keySet()) {
|
|
||||||
list.put(uuid.toString(), timeouts.get(uuid));
|
|
||||||
}
|
|
||||||
// Shoves everything into a map.
|
|
||||||
sHashMap.put("timeouts", list);
|
|
||||||
|
|
||||||
DataManager.saveData("timeOutData.yml", sHashMap);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user