itsfuryxx.ow
πŸ“Ž 1 file 3,027 chars
πŸ“„
pasted-code-1772033285376.txt
txt 94 lines
β–Ά
package com.flaggerhome.plugin;

import org.bukkit.*;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.java.JavaPlugin;

import java.io.File;
import java.io.IOException;
import java.util.*;

public class FlaggerHome extends JavaPlugin {

    private static FlaggerHome instance;
    private final Map homeCache = new HashMap<>();
    private File homesFile;
    private FileConfiguration homesConfig;

    public static FlaggerHome getInstance() {
        return instance;
    }

    public Map getHomeCache() {
        return homeCache;
    }

    public FileConfiguration getHomesConfig() {
        return homesConfig;
    }

    @Override
    public void onEnable() {
        instance = this;

        saveDefaultConfig();
        setupHomesFile();
        loadHomes();

        getCommand("home").setExecutor(new HomeCommand());
        getCommand("sethome").setExecutor(new HomeCommand());
        getCommand("delhome").setExecutor(new HomeCommand());
        getCommand("home").setTabCompleter(new HomeTabCompleter());

        Bukkit.getPluginManager().registerEvents(new TeleportListener(), this);

        getLogger().info("FlaggerHome Enabled!");
    }

    @Override
    public void onDisable() {
        saveHomes();
    }

    private void setupHomesFile() {
        homesFile = new File(getDataFolder(), "homes.yml");
        if (!homesFile.exists()) {
            homesFile.getParentFile().mkdirs();
            saveResource("homes.yml", false);
        }
        homesConfig = YamlConfiguration.loadConfiguration(homesFile);
    }

    public void saveHomes() {
        for (UUID uuid : homeCache.keySet()) {
            Location loc = homeCache.get(uuid);
            String path = uuid.toString();
            homesConfig.set(path + ".world", loc.getWorld().getName());
            homesConfig.set(path + ".x", loc.getX());
            homesConfig.set(path + ".y", loc.getY());
            homesConfig.set(path + ".z", loc.getZ());
            homesConfig.set(path + ".yaw", loc.getYaw());
            homesConfig.set(path + ".pitch", loc.getPitch());
        }

        try {
            homesConfig.save(homesFile);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private void loadHomes() {
        for (String key : homesConfig.getKeys(false)) {
            World world = Bukkit.getWorld(homesConfig.getString(key + ".world"));
            double x = homesConfig.getDouble(key + ".x");
            double y = homesConfig.getDouble(key + ".y");
            double z = homesConfig.getDouble(key + ".z");
            float yaw = (float) homesConfig.getDouble(key + ".yaw");
            float pitch = (float) homesConfig.getDouble(key + ".pitch");

            homeCache.put(UUID.fromString(key), new Location(world, x, y, z, yaw, pitch));
        }
    }
}
Kodari AI
KodariFeb 25 at 3:28 pm 3,837 (v2)

I can see you have a FlaggerHome plugin with basic home teleportation functionality. The main class references HomeCommand, HomeTabCompleter, and TeleportListener classes that aren’t shown.

What would you like me to do with this plugin? For example:

  • Add missing classes to make it functional?

  • Add new features (like multiple homes, GUI interface, etc.)?

  • Fix or improve existing functionality?

  • Convert to a different system?

  • Something else?

Please let me know what changes or additions you’d like!

Kodari can make mistakes. Review important code before using.
Files

No files in this session

Code