Commit 89159142 authored by JuniorJPDJ's avatar JuniorJPDJ
Browse files

Configuration file

parent 72709998
Pipeline #19 canceled with stages
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-bin.zip
package pl.juniorjpdj.bukkit.wordtimemotd;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.java.JavaPlugin;
public final class Plugin extends JavaPlugin {
FileConfiguration config = this.getConfig();
@Override
public void onEnable() {
Bukkit.getPluginManager().registerEvents(new ServerListPingEventListener(), this);
this.config.options().copyDefaults(true);
config.addDefault("world", Bukkit.getWorlds().get(0).getName());
saveConfig();
Bukkit.getPluginManager().registerEvents(new ServerListPingEventListener(this), this);
}
}
......@@ -11,11 +11,16 @@ import java.util.Date;
import java.util.TimeZone;
public class ServerListPingEventListener implements Listener {
private Plugin plugin;
ServerListPingEventListener(Plugin plugin){
this.plugin = plugin;
}
@EventHandler
void onPing(ServerListPingEvent event){
String world_name = "world";
String motd_string = "{0}\nIt''s {1,time,HH:mm} o''clock on the server!";
String world_name = plugin.config.getString("world");
String motd_string = plugin.config.getString("motd");
World w = Bukkit.getWorld(world_name);
if(w == null) return;
......
motd: "{0}\nIt''s {1,time,HH:mm} o''clock on the server!"
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment