Files
src
CHANGELOG.md
LICENSE
manifest.kod
pom.xml
README.md
Code
1266 3,426
src/main/java/ir/aquavortex/aquavortex/AquaVortex.java
package ir.aquavortex.aquavortex;
import ir.aquavortex.aquavortex.config.ConfigService;
import ir.aquavortex.aquavortex.data.DatabaseService;
import ir.aquavortex.aquavortex.data.JdbcProfileRepository;
import ir.aquavortex.aquavortex.data.ProfileRepository;
import ir.aquavortex.aquavortex.gui.GUIListener;
import ir.aquavortex.aquavortex.gui.GUIManager;
import ir.aquavortex.aquavortex.listener.PlayerListener;
import ir.aquavortex.aquavortex.service.CooldownService;
import ir.aquavortex.aquavortex.service.EconomyService;
import ir.aquavortex.aquavortex.service.MessageService;
import ir.aquavortex.aquavortex.service.ProfileService;
import ir.aquavortex.aquavortex.service.TeleportService;
import org.bukkit.Bukkit;
import org.bukkit.command.PluginCommand;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
public final class AquaVortex extends JavaPlugin {
private ConfigService configs;
private MessageService messages;
private DatabaseService database;
private ProfileService profiles;
private EconomyService economy;
private TeleportService teleport;
private CooldownService cooldowns;
private GUIManager guiManager;
private final Set<UUID> vanished = ConcurrentHashMap.newKeySet();
private final Map<UUID, TpaRequest> tpaRequests = new ConcurrentHashMap<>();
private final Map<UUID, UUID> previousLocations = new ConcurrentHashMap<>();
private final Map<UUID, UUID> replies = new ConcurrentHashMap<>();
@Override
public void onEnable() {
configs = new ConfigService(this);
messages = new MessageService(this, configs);
database = new DatabaseService(configs);
try {
database.connect(getDataFolder());
} catch (RuntimeException exception) {
getLogger().severe("Database startup failed: " + exception.getMessage());
getServer().getPluginManager().disablePlugin(this);
return;
}
ProfileRepository repository = new JdbcProfileRepository(database);
profiles = new ProfileService(configs, database, repository);
economy = new EconomyService(configs, profiles);
teleport = new TeleportService(this, configs, repository);
cooldowns = new CooldownService();
guiManager = new GUIManager();
Bukkit.getPluginManager().registerEvents(new PlayerListener(this), this);
Bukkit.getPluginManager().registerEvents(new GUIListener(guiManager), this);
AquaCommand command = new AquaCommand(this);
String[] commandNames = {"av", "spawn", "setspawn", "home", "sethome", "delhome", "homes", "warp", "setwarp",
"delwarp", "warps", "tpa", "tpahere", "tpaccept", "tpdeny", "back", "feed", "heal", "fly", "gamemode",
"gmc", "gms", "gma", "gmsp", "vanish", "invsee", "enderchest", "ec", "hat", "repair", "workbench",
"trash", "near", "top", "bottom", "suicide", "speed", "time", "weather", "broadcast", "msg", "reply",
"list", "ping", "motd", "rules", "help", "pay", "balance", "bal", "eco", "money", "afk", "profile",
"daily", "report", "reload", "version"};
for (String name : commandNames) {
PluginCommand pluginCommand = getCommand(name);
if (pluginCommand != null) {
pluginCommand.setExecutor(command);
pluginCommand.setTabCompleter(command);
}
}
getLogger().info("AquaVortex enabled with " + database.dataSource().getPoolName() + ".");
}
@Override
public void onDisable() {
if (profiles != null) {
Bukkit.getOnlinePlayers().forEach(player -> profiles.save(player.getUniqueId()));
}
if (guiManager != null) {
guiManager.clear();
}
if (database != null) {
database.close();
}
}
public ConfigService configs() { return configs; }
public MessageService messages() { return messages; }
public ProfileService profiles() { return profiles; }
public EconomyService economy() { return economy; }
public TeleportService teleport() { return teleport; }
public CooldownService cooldowns() { return cooldowns; }
public GUIManager guiManager() { return guiManager; }
public Set<UUID> vanished() { return vanished; }
public Map<UUID, TpaRequest> tpaRequests() { return tpaRequests; }
public Map<UUID, UUID> previousLocations() { return previousLocations; }
public Map<UUID, UUID> replies() { return replies; }
public record TpaRequest(UUID requester, boolean teleportHere) {}
}