Files
src
build.gradle
README.md
Code
12 1,086
src/main/java/com/example/plugin/MyCustomPlugin.java
package com.example.plugin;
import com.example.plugin.command.TpaCommand;
import com.example.plugin.config.ConfigManager;
import com.example.plugin.listener.PlayerListener;
import com.example.plugin.manager.RequestManager;
import com.example.plugin.manager.TeleportManager;
import com.example.plugin.placeholder.TpaPlaceholderExpansion;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
public final class MyCustomPlugin extends JavaPlugin {
private static MyCustomPlugin instance;
private ConfigManager configManager;
private RequestManager requestManager;
private TeleportManager teleportManager;
@Override
public void onEnable() {
instance = this;
// Load configurations
this.configManager = new ConfigManager(this);
this.configManager.loadConfigs();
// Initialize managers
this.requestManager = new RequestManager(this);
this.teleportManager = new TeleportManager(this);
// Register listeners
getServer().getPluginManager().registerEvents(new PlayerListener(this), this);
// Register commands
TpaCommand tpaCommand = new TpaCommand(this);
getCommand("tpa").setExecutor(tpaCommand);
getCommand("tpa").setTabCompleter(tpaCommand);
getCommand("tpahere").setExecutor(tpaCommand);
getCommand("tpahere").setTabCompleter(tpaCommand);
getCommand("tpaccept").setExecutor(tpaCommand);
getCommand("tpaccept").setTabCompleter(tpaCommand);
getCommand("tpdeny").setExecutor(tpaCommand);
getCommand("tpdeny").setTabCompleter(tpaCommand);
getCommand("tpacancel").setExecutor(tpaCommand);
getCommand("tpacancel").setTabCompleter(tpaCommand);
getCommand("toggletpa").setExecutor(tpaCommand);
getCommand("toggletpa").setTabCompleter(tpaCommand);
// Register PlaceholderAPI expansion if present
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
new TpaPlaceholderExpansion(this).register();
getLogger().info("PlaceholderAPI integration registered successfully!");
}
getLogger().info("AdvancedTPA (MyCustomPlugin) has been enabled successfully!");
}
@Override
public void onDisable() {
// Cancel all active teleports and clear requests
if (teleportManager != null) {
teleportManager.cancelAll();
}
if (requestManager != null) {
requestManager.clearAll();
}
getLogger().info("AdvancedTPA (MyCustomPlugin) has been disabled.");
}
public static MyCustomPlugin getInstance() {
return instance;
}
public ConfigManager getConfigManager() {
return configManager;
}
public RequestManager getRequestManager() {
return requestManager;
}
public TeleportManager getTeleportManager() {
return teleportManager;
}
}