66 lines
1.8 KiB
Java
66 lines
1.8 KiB
Java
package pw.hamzantal.minionsplus;
|
|
|
|
import com.earth2me.essentials.Essentials;
|
|
import lombok.Getter;
|
|
import pw.hamzantal.minionsplus.command.MinionCommand;
|
|
import pw.hamzantal.minionsplus.manager.LinkingManager;
|
|
import pw.hamzantal.minionsplus.manager.MinionManager;
|
|
import pw.hamzantal.minionsplus.model.Fuel;
|
|
import net.milkbowl.vault.economy.Economy;
|
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
|
|
import java.util.Set;
|
|
import java.util.stream.Collectors;
|
|
|
|
public class MinionsPlus extends JavaPlugin {
|
|
|
|
@Getter private static MinionsPlus instance;
|
|
@Getter private static Economy econ;
|
|
@Getter private static Essentials essentials;
|
|
@Getter private MinionManager minionManager;
|
|
@Getter private LinkingManager linkingManager;
|
|
private MinionCommand minionCommand;
|
|
|
|
@Override
|
|
public void onEnable() {
|
|
instance = this;
|
|
saveDefaultConfig();
|
|
setupEconomy();
|
|
essentials = getPlugin(Essentials.class);
|
|
this.minionManager = new MinionManager(this);
|
|
this.linkingManager = new LinkingManager(this);
|
|
this.minionCommand = new MinionCommand();
|
|
getCommand("minions").setExecutor(minionCommand);
|
|
getCommand("minions").setTabCompleter(minionCommand);
|
|
}
|
|
|
|
@Override
|
|
public void onDisable() {
|
|
this.minionManager.close();
|
|
this.linkingManager.close();
|
|
}
|
|
|
|
private boolean setupEconomy() {
|
|
if (getServer().getPluginManager().getPlugin("Vault") == null) {
|
|
return false;
|
|
}
|
|
RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
|
|
if (rsp == null) {
|
|
return false;
|
|
}
|
|
econ = rsp.getProvider();
|
|
return econ != null;
|
|
}
|
|
|
|
public Set<Fuel> getFuels() {
|
|
return getConfig()
|
|
.getConfigurationSection("Fuel")
|
|
.getKeys(false)
|
|
.stream()
|
|
.map(s -> Fuel.fromConfigSection(getConfig().getConfigurationSection("Fuel." + s)))
|
|
.collect(Collectors.toSet());
|
|
}
|
|
|
|
}
|