Coded a persistence test to monitor config.yml

This commit is contained in:
alisolarflare 2017-05-25 18:16:52 -04:00
parent 6863487ad6
commit f830129381
5 changed files with 53 additions and 1 deletions

0
config.yml Normal file
View file

View file

@ -29,7 +29,7 @@ public class HelloSound extends PlayerCommand{
}
}
player.getWorld().playSound(player.getLocation(), Sound.BLOCK_ANVIL_LAND, volume, pitch);
player.getWorld().playSound(player.getLocation(), Sound.ENTITY_BLAZE_DEATH, volume, pitch);
return true;
}

View file

@ -0,0 +1,37 @@
package buttondevteam.presents.test;
import org.bukkit.command.CommandSender;
import buttondevteam.presents.architecture.commands.UniversalCommand;
public class PersistenceTest extends UniversalCommand {
final private String path = "test.presistence.data";
public PersistenceTest(){
runTest();
}
@Override
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
if(runTest()){
sender.sendMessage("Everything seems pretty fine");
sender.sendMessage(path + " contains the String");
sender.sendMessage(this.getPlugin().getConfig().getString(path));
return true;
}else{
sender.sendMessage("[ButtonPresents] Persistence Test Failed! Button Presents may have an erased config.yml");
return true;
}
}
private boolean runTest(){
boolean test = this.getPlugin().getConfig().contains(path);
if(test){
return true;
}else{
this.getPlugin().getConfig().set(path, "Lorem Ipsum");
throw new AssertionError("[ButtonPresents] Persistence Test Failed! Button Presents may have an erased config.yml");
}
}
}

View file

@ -0,0 +1,15 @@
package buttondevteam.presents.test;
import org.bukkit.plugin.java.JavaPlugin;
import buttondevteam.presents.architecture.Component;
public class TestComponent extends Component{
@Override
public void register(JavaPlugin plugin) {
this.registerCommand(plugin, new PersistenceTest());
}
}

View file