FUCK TIME
God I hate using time so much
This commit is contained in:
parent
45c37ad2e8
commit
ddac6fbeae
4 changed files with 59 additions and 19 deletions
|
@ -13,7 +13,8 @@ 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));
|
||||
this.registerCommand(plugin, new HelloSave());
|
||||
this.registerCommand(plugin, new HelloLoad());
|
||||
this.registerCommand(plugin, new HelloTime());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,23 +5,17 @@ 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());
|
||||
sender.sendMessage("Data Type: " + this.getPlugin().getConfig().get("hellosave").getClass().toString());
|
||||
}
|
||||
List<String> mylist = plugin.getConfig().getStringList("hellosave");
|
||||
List<String> mylist = this.getPlugin().getConfig().getStringList("hellosave");
|
||||
for(String string : mylist){
|
||||
sender.sendMessage(string);
|
||||
}
|
||||
|
|
|
@ -3,25 +3,18 @@ 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();
|
||||
this.getPlugin().getConfig().set("hellosave", Arrays.asList(args));
|
||||
this.getPlugin().saveConfig();
|
||||
sender.sendMessage("Message saved!");
|
||||
}catch (Exception e){
|
||||
sender.sendMessage("Error when saving message:");
|
||||
|
|
52
src/main/java/buttondevteam/presents/hello/HelloTime.java
Normal file
52
src/main/java/buttondevteam/presents/hello/HelloTime.java
Normal file
|
@ -0,0 +1,52 @@
|
|||
package buttondevteam.presents.hello;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import buttondevteam.presents.architecture.commands.BaseCommand;
|
||||
|
||||
public class HelloTime extends BaseCommand {
|
||||
|
||||
@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)){
|
||||
|
||||
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){
|
||||
Date dateTime = new Date(time);
|
||||
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";
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue