From 2fa0e44cb0c385d792284e9f3a711b8570ad8b32 Mon Sep 17 00:00:00 2001 From: alisolarflare Date: Sat, 15 Apr 2017 21:01:05 -0400 Subject: [PATCH] Good evening FileIO; my old nemesis. --- .../buttondevteam/presents/hello/Hello.java | 2 + .../presents/hello/HelloBedsplode.java | 1 - .../presents/hello/HelloLoad.java | 45 +++++++++++++++++ .../presents/hello/HelloSave.java | 48 +++++++++++++++++++ 4 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 src/main/java/buttondevteam/presents/hello/HelloLoad.java create mode 100644 src/main/java/buttondevteam/presents/hello/HelloSave.java diff --git a/src/main/java/buttondevteam/presents/hello/Hello.java b/src/main/java/buttondevteam/presents/hello/Hello.java index 39040fd..6a8ae9b 100644 --- a/src/main/java/buttondevteam/presents/hello/Hello.java +++ b/src/main/java/buttondevteam/presents/hello/Hello.java @@ -13,5 +13,7 @@ public class Hello extends Component{ this.registerCommand(plugin, new HelloCow()); this.registerCommand(plugin, new HelloItem()); this.registerCommand(plugin, new HelloMagicPotato()); + this.registerCommand(plugin, new HelloSave(plugin)); + this.registerCommand(plugin, new HelloLoad(plugin)); } } diff --git a/src/main/java/buttondevteam/presents/hello/HelloBedsplode.java b/src/main/java/buttondevteam/presents/hello/HelloBedsplode.java index a7d8ff0..d676dc1 100644 --- a/src/main/java/buttondevteam/presents/hello/HelloBedsplode.java +++ b/src/main/java/buttondevteam/presents/hello/HelloBedsplode.java @@ -22,5 +22,4 @@ public class HelloBedsplode implements Listener { player.sendMessage("HELLO MOTHERFUCKER!"); player.sendMessage("WAKEY WAKEY!"); } - } diff --git a/src/main/java/buttondevteam/presents/hello/HelloLoad.java b/src/main/java/buttondevteam/presents/hello/HelloLoad.java new file mode 100644 index 0000000..2ab4b9e --- /dev/null +++ b/src/main/java/buttondevteam/presents/hello/HelloLoad.java @@ -0,0 +1,45 @@ +package buttondevteam.presents.hello; + + + +import java.util.List; + +import org.bukkit.command.CommandSender; +import org.bukkit.plugin.java.JavaPlugin; + +import buttondevteam.presents.architecture.commands.BaseCommand; + +public class HelloLoad extends BaseCommand { + JavaPlugin plugin; + + public HelloLoad(JavaPlugin plugin) { + this.plugin = plugin; + } + + @Override + public boolean OnCommand(CommandSender sender, String alias, String[] args) { + if (args.length > 1 && args[0].toLowerCase().contains("debug")){ + sender.sendMessage("Data Type: " + plugin.getConfig().get("hellosave").getClass().toString()); + } + List mylist = plugin.getConfig().getStringList("hellosave"); + for(String string : mylist){ + sender.sendMessage(string); + } + return true; + } + + @Override + public boolean GetPlayerOnly() { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean GetModOnly() { + // TODO Auto-generated method stub + return false; + } + public String GetCommandPath(){ + return "hello load"; + } +} diff --git a/src/main/java/buttondevteam/presents/hello/HelloSave.java b/src/main/java/buttondevteam/presents/hello/HelloSave.java new file mode 100644 index 0000000..48a3158 --- /dev/null +++ b/src/main/java/buttondevteam/presents/hello/HelloSave.java @@ -0,0 +1,48 @@ +package buttondevteam.presents.hello; + +import java.util.Arrays; + +import org.bukkit.command.CommandSender; +import org.bukkit.plugin.java.JavaPlugin; + +import buttondevteam.presents.architecture.commands.BaseCommand; + +public class HelloSave extends BaseCommand { + JavaPlugin plugin; + + public HelloSave(JavaPlugin plugin) { + this.plugin = plugin; + } + + @Override + public boolean OnCommand(CommandSender sender, String alias, String[] args) { + if (args.length < 1){ + sender.sendMessage("Can't save an empty string, Type /hellosave "); + }else{ + try{ + plugin.getConfig().set("hellosave", Arrays.asList(args)); + plugin.saveConfig(); + sender.sendMessage("Message saved!"); + }catch (Exception e){ + sender.sendMessage("Error when saving message:"); + sender.sendMessage(e.toString()); + } + } + return false; + } + + @Override + public boolean GetPlayerOnly() { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean GetModOnly() { + // TODO Auto-generated method stub + return false; + } + public String GetCommandPath(){ + return "hello save"; + } +}