Good evening FileIO; my old nemesis.

This commit is contained in:
alisolarflare 2017-04-15 21:01:05 -04:00
parent 118ef6f970
commit 2fa0e44cb0
4 changed files with 95 additions and 1 deletions

View file

@ -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));
}
}

View file

@ -22,5 +22,4 @@ public class HelloBedsplode implements Listener {
player.sendMessage("HELLO MOTHERFUCKER!");
player.sendMessage("WAKEY WAKEY!");
}
}

View file

@ -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<String> 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";
}
}

View file

@ -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 <message>");
}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";
}
}