UltimateTimber/src/main/java/com/songoda/ultimatetimber/UltimateTimber.java

80 lines
2.6 KiB
Java
Raw Normal View History

2018-11-04 00:33:37 +01:00
package com.songoda.ultimatetimber;
import com.songoda.ultimatetimber.commands.CommandHandler;
import com.songoda.ultimatetimber.configurations.DefaultConfig;
import com.songoda.ultimatetimber.treefall.TreeFallAnimation;
import com.songoda.ultimatetimber.treefall.TreeFallEvent;
2018-11-05 23:41:25 +01:00
import com.songoda.ultimatetimber.utils.Methods;
import org.bukkit.Bukkit;
import org.bukkit.World;
2018-11-05 23:41:25 +01:00
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.ArrayList;
2018-11-05 23:41:25 +01:00
import java.util.Collections;
import java.util.List;
/*
Note: In this plugin, I have called the act of a tree falling over with pseudo-physics "toppling over". This is reflected
in the documentation, config files and variable names.
PS: MagmaGuy was here
*/
2018-11-04 00:33:37 +01:00
public class UltimateTimber extends JavaPlugin {
2018-11-05 23:41:25 +01:00
private static CommandSender console = Bukkit.getConsoleSender();
2018-11-05 23:41:25 +01:00
private final String prefix = "&8[&6UltimateTimber&8]";
private static UltimateTimber INSTANCE;
private List<World> validWorlds = new ArrayList<>();
@Override
public void onEnable() {
2018-11-05 23:41:25 +01:00
INSTANCE = this;
console.sendMessage(Methods.formatText("&a============================="));
console.sendMessage(Methods.formatText("&7" + this.getDescription().getName() + " " + this.getDescription().getVersion() + " by &5Brianna <3&7!"));
console.sendMessage(Methods.formatText("&7Action: &aEnabling&7..."));
/*
Register the main event that handles toppling down trees
*/
Bukkit.getServer().getPluginManager().registerEvents(new TreeFallEvent(), this);
/*
Prevent falling blocks from forming new blocks on the floor
*/
Bukkit.getServer().getPluginManager().registerEvents(new TreeFallAnimation(), this);
/*
Initialize and cache config
*/
DefaultConfig.initialize();
/*
Cache valid worlds for later use
*/
for (World world : Bukkit.getWorlds())
2018-11-05 23:41:25 +01:00
if (getConfig().getBoolean(DefaultConfig.VALID_WORLDS + world.getName()))
validWorlds.add(world);
2018-11-05 23:41:25 +01:00
this.getCommand("ultimatetimber").setExecutor(new CommandHandler(this));
console.sendMessage(Methods.formatText("&a============================="));
}
@Override
public void onDisable() {
validWorlds.clear();
2018-11-05 23:41:25 +01:00
}
public static UltimateTimber getInstance() {
return INSTANCE;
}
2018-11-05 23:41:25 +01:00
public List<World> getValidWorlds() {
return Collections.unmodifiableList(validWorlds);
}
2018-11-05 23:41:25 +01:00
public String getPrefix() {
return prefix;
}
}