Made the simple simpler

Following the KISS principle
This commit is contained in:
alisolarflare 2017-05-21 20:18:03 -04:00
parent bdff3fa6d1
commit 9b145bef9a
10 changed files with 32 additions and 69 deletions

View file

@ -5,7 +5,7 @@ import java.util.logging.Logger;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin;
import buttondevteam.presents.hello.Hello;
import buttondevteam.presents.hello.HelloComponent;
public class Main extends JavaPlugin{
public void onEnable(){
@ -14,7 +14,7 @@ PluginDescriptionFile pdfFile = getDescription();
Logger logger = getLogger();
logger.info(pdfFile.getName() + " has been started (V." + pdfFile.getVersion()+ ").");
new Hello().register(this);
new HelloComponent().register(this);
logger.info(pdfFile.getName() + " has fully registered (V." + pdfFile.getVersion()+ ").");
}

View file

@ -1,6 +1,6 @@
package buttondevteam.presents.architecture.commands;
public abstract class CommandBlockCommand extends BaseCommand{
public abstract class UniversalCommand extends BaseCommand{
@Override
public String[] GetHelpText(String alias){
return new String[] {

View file

@ -15,7 +15,7 @@ import buttondevteam.presents.hello.effects.HelloMagicPotato;
import buttondevteam.presents.hello.effects.HelloParticle;
import buttondevteam.presents.hello.effects.HelloSound;
public class Hello extends Component{
public class HelloComponent extends Component{
@Override
public void register(JavaPlugin plugin) {

View file

@ -2,27 +2,15 @@ package buttondevteam.presents.hello.commands;
import org.bukkit.command.CommandSender;
import buttondevteam.presents.architecture.commands.BaseCommand;
import buttondevteam.presents.architecture.commands.UniversalCommand;
public class HelloCommand extends BaseCommand {
public class HelloCommand extends UniversalCommand {
@Override
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
sender.sendMessage("Hello World!");
return false;
}
@Override
public boolean GetPlayerOnly() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean GetModOnly() {
// TODO Auto-generated method stub
return false;
}
@Override
public String GetCommandPath(){
return "hello command";

View file

@ -6,9 +6,9 @@ import java.util.List;
import org.bukkit.command.CommandSender;
import buttondevteam.presents.architecture.commands.BaseCommand;
import buttondevteam.presents.architecture.commands.UniversalCommand;
public class HelloLoad extends BaseCommand {
public class HelloLoad extends UniversalCommand {
@Override
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
@ -21,18 +21,6 @@ public class HelloLoad extends BaseCommand {
}
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

@ -4,9 +4,9 @@ import java.util.Arrays;
import org.bukkit.command.CommandSender;
import buttondevteam.presents.architecture.commands.BaseCommand;
import buttondevteam.presents.architecture.commands.UniversalCommand;
public class HelloSave extends BaseCommand {
public class HelloSave extends UniversalCommand {
@Override
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
if (args.length < 1){
@ -23,18 +23,6 @@ public class HelloSave extends BaseCommand {
}
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";
}

View file

@ -6,25 +6,27 @@ import java.util.Date;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import buttondevteam.presents.architecture.commands.BaseCommand;
import buttondevteam.presents.architecture.commands.UniversalCommand;
public class HelloTime extends BaseCommand {
public class HelloTime extends UniversalCommand {
final String path = "hellotime.lastincident";
@Override
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
String path = "hellotime.lastincident";
FileConfiguration config = this.getPlugin().getConfig();
if(!config.contains(path) || !config.isLong(path)){
if(config.contains(path) && config.isLong(path)){
sender.sendMessage("Last Time Incident: " + MillisToString(config.getLong(path)));
}else{
sender.sendMessage("Time Incident Occoured!");
sender.sendMessage("Setting...");
long time = System.currentTimeMillis();
config.set(path, time);
sender.sendMessage("Time set to" + MillisToString(time));
}
sender.sendMessage("Days since last Time Incident: " + MillisToString(config.getLong(path)));
return true;
}
public String MillisToString(long time){
@ -32,19 +34,7 @@ public class HelloTime extends BaseCommand {
SimpleDateFormat dateformatter = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss z");
return dateformatter.format(dateTime);
}
@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 time";
}

View file

@ -1,6 +1,7 @@
package buttondevteam.presents.hello.effects;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import buttondevteam.presents.architecture.commands.PlayerCommand;
@ -9,7 +10,10 @@ public class HelloBlock extends PlayerCommand {
@Override
public boolean OnCommand(Player player, String alias, String[] args) {
player.getWorld().getBlockAt(player.getLocation()).setType(Material.CAKE_BLOCK);
Block blockAtPlayer = player.getWorld().getBlockAt(player.getLocation());
blockAtPlayer.setType(Material.CAKE_BLOCK);
return false;
}
public String GetCommandPath(){

View file

@ -9,7 +9,10 @@ public class HelloCow extends PlayerCommand {
@Override
public boolean OnCommand(Player player, String alias, String[] args) {
player.getWorld().spawnEntity(player.getLocation(), EntityType.COW) ;
player.getWorld().spawnEntity(
player.getLocation(),
EntityType.COW
);
return true;
}

View file

@ -24,9 +24,11 @@ public class HelloMagicPotato extends ModCommand {
lore.add("There was a beautiful potato that ruled a fantastic kingdom. With its armies of french"
+ "fries and cannons of hash browns, it was unstopple.");
lore.add("Until one fateful day...");
meta.setLore(lore);
potato.setItemMeta(meta);
player.getInventory().addItem(potato);
return true;
}
public String GetCommandPath(){