Good evening FileIO; my old nemesis.
This commit is contained in:
parent
118ef6f970
commit
2fa0e44cb0
4 changed files with 95 additions and 1 deletions
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,5 +22,4 @@ public class HelloBedsplode implements Listener {
|
|||
player.sendMessage("HELLO MOTHERFUCKER!");
|
||||
player.sendMessage("WAKEY WAKEY!");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
45
src/main/java/buttondevteam/presents/hello/HelloLoad.java
Normal file
45
src/main/java/buttondevteam/presents/hello/HelloLoad.java
Normal 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";
|
||||
}
|
||||
}
|
48
src/main/java/buttondevteam/presents/hello/HelloSave.java
Normal file
48
src/main/java/buttondevteam/presents/hello/HelloSave.java
Normal 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";
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue