found parsesettings bug

This commit is contained in:
Bryson Steck 2021-09-13 15:31:29 -06:00
parent ddb4587eb8
commit 2a6465534d
9 changed files with 33 additions and 13 deletions

View file

@ -2,9 +2,8 @@ package net.brysonsteck.Resurrection;
import net.brysonsteck.Resurrection.commands.*;
import net.brysonsteck.Resurrection.player.PlayerListener;
import net.brysonsteck.Resurrection.player.TimeCheck;
import net.brysonsteck.Resurrection.startup.CheckForUpdate;
import org.bukkit.Bukkit;
import net.brysonsteck.Resurrection.startup.ParseSettings;
import org.bukkit.event.Listener;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin;
@ -66,6 +65,8 @@ public class Resurrection extends JavaPlugin implements Listener {
System.out.println("[Resurrection] ---------------------------------------------------------");
ParseSettings parseSettings = null;
System.out.println("[Resurrection] Locating player data and settings files...");
// check if playerData.resurrection exists
File playerFile = new File("plugins/playerData.resurrection");
@ -85,7 +86,7 @@ public class Resurrection extends JavaPlugin implements Listener {
}
if (!settingsFile.exists()) {
System.out.println("[Resurrection] Settings file does not exist. (This file is new with the 0.2 beta if you upgraded.) Creating now in the \"plugins\" directory...");
ParseSettings parseSettings = new ParseSettings();
parseSettings = new ParseSettings();
System.out.println("[Resurrection] Settings file created successfully.");
} else {
System.out.println("[Resurrection] The settings file has also been found!");
@ -98,11 +99,11 @@ public class Resurrection extends JavaPlugin implements Listener {
this.getServer().getPluginManager().registerEvents(new PlayerListener(), this);
// register commands
this.getCommand("about").setExecutor(new CommandAbout(pluginInfo.getVersion(), outdated));
this.getCommand("bug").setExecutor(new CommandBug());
this.getCommand("resurrect").setExecutor(new CommandResurrect());
this.getCommand("howlong").setExecutor(new CommandHowLong());
this.getCommand("source").setExecutor(new CommandSource());
this.getCommand("about").setExecutor(new CommandAbout(parseSettings.getSetting("debug"), pluginInfo.getVersion(), outdated));
this.getCommand("bug").setExecutor(new CommandBug(parseSettings.getSetting("debug")));
this.getCommand("resurrect").setExecutor(new CommandResurrect(parseSettings.getSetting("debug")));
this.getCommand("howlong").setExecutor(new CommandHowLong(parseSettings.getSetting("debug")));
this.getCommand("source").setExecutor(new CommandSource(parseSettings.getSetting("debug")));
System.out.println("[Resurrection] ---------------------------------------------------------");
System.out.println("[Resurrection] Successfully Started!");
@ -112,6 +113,12 @@ public class Resurrection extends JavaPlugin implements Listener {
public static void main(String[] args) {
// String test = "fals";
//
// if (!test.toLowerCase().contains("true") && !test.toLowerCase().contains("false")) {
// System.out.println("fail");
// }
// DO THIS
// PlayerData playerData = new PlayerData();
// System.out.println("--- Reading Player data file ---");

View file

@ -10,7 +10,7 @@ public class CommandAbout implements CommandExecutor {
String currentVersion;
boolean outdated;
public CommandAbout(String currentVersion, boolean outdated) {
public CommandAbout(String debug, String currentVersion, boolean outdated) {
this.currentVersion = currentVersion;
this.outdated = outdated;
}

View file

@ -11,6 +11,9 @@ import org.bukkit.scheduler.BukkitRunnable;
public class CommandBug implements CommandExecutor {
public CommandBug(String debug) {
}
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
if (commandSender instanceof Player) {

View file

@ -11,6 +11,9 @@ import org.bukkit.entity.Player;
public class CommandHowLong implements CommandExecutor {
public CommandHowLong(String debug) {
}
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
if (commandSender instanceof Player) {

View file

@ -12,6 +12,9 @@ import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
public class CommandResurrect implements CommandExecutor {
public CommandResurrect(String debug) {
}
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
boolean valid = (strings.length == 1);

View file

@ -10,6 +10,11 @@ import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
public class CommandSource implements CommandExecutor {
boolean debug;
public CommandSource(String debug) {
this.debug = Boolean.parseBoolean(debug);
}
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {

View file

@ -1,9 +1,8 @@
package net.brysonsteck.Resurrection.player;
import net.brysonsteck.Resurrection.ParseSettings;
import net.brysonsteck.Resurrection.startup.ParseSettings;
import net.brysonsteck.Resurrection.Resurrection;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;

View file

@ -1,4 +1,4 @@
package net.brysonsteck.Resurrection;
package net.brysonsteck.Resurrection.startup;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
@ -91,7 +91,7 @@ public class ParseSettings {
failedSetting = "debug";
return false;
}
if (settings.get("debug").toLowerCase().contains("true") && settings.get("debug").toLowerCase().contains("false")) {
if (!settings.get("debug").toLowerCase().contains("true") && !settings.get("debug").toLowerCase().contains("false")) {
failedSetting = "debug";
return false;
}