zd_shardks

Build

Kodari AI
KodariFeb 24 at 5:38 am 30,922 (v2)

I’ll examine the project files to identify any issues before building.

I’ll analyze the project and fix all cross-version compatibility issues by replacing direct Bukkit enums with XSeries wrappers.

Analysis:

  • Maven project using direct Bukkit Sound and Material enums

  • All Sound.* references must use XSound for cross-version support

  • All Material.* references must use XMaterial for cross-version support

  • Need to add XSeries dependency to pom.xml

All files updated with XSeries for cross-version compatibility across Minecraft 1.8-1.21+.

Kodari can make mistakes. Review important code before using.
Files
src
pom.xml
Code
23 1,408
src/main/java/com/jovanstar/donuttpa/main.java
package com.jovanstar.donuttpa;

import java.io.File;
import java.io.IOException;
import java.util.UUID;
import java.util.stream.Collectors;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

public class main extends JavaPlugin {
   private static main instance;
   private File togglesFile;
   private FileConfiguration togglesCfg;

   public void onEnable() {
      instance = this;
      this.saveDefaultConfig();
      this.saveResource("messages.yml", false);
      Messages.load(this);
      TeleportRequestManager.initialize();
      this.getCommand("tpa").setExecutor(new TpaCommand());
      this.getCommand("tpahere").setExecutor(new TpahereCommand());
      this.getCommand("tpa").setTabCompleter(new TpaTabCompleter());
      this.getCommand("tpahere").setTabCompleter(new TpaTabCompleter());
      this.getCommand("tpaccept").setExecutor(new TpacceptCommand());
      this.getCommand("tpaccept").setTabCompleter(new TpacceptTabCompleter());
      this.getCommand("tpacancel").setExecutor(new TpacancelCommand());
      this.getCommand("tpatoggle").setExecutor(new TpaToggleCommand());
      this.getCommand("tpaheretoggle").setExecutor(new TpahereToggleCommand());
      this.getCommand("tpareload").setExecutor(new ReloadCommand());
      this.getCommand("tpauto").setExecutor(new TpautoCommand());
      Bukkit.getScheduler().runTaskTimer(this, () -> {
         String bar = Messages.get("tpauto-on-actionbar");

         for (UUID uuid : TeleportRequestManager.getAutoAcceptList()) {
            Player p = Bukkit.getPlayer(uuid);
            if (p != null && p.isOnline()) {
               p.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(bar));
            }
         }
      }, 0L, 20L);
      this.togglesFile = new File(this.getDataFolder(), "saves.yml");
      if (!this.togglesFile.exists()) {
         this.saveResource("saves.yml", false);
      }

      this.togglesCfg = YamlConfiguration.loadConfiguration(this.togglesFile);
      this.togglesCfg.getStringList("disabled-tpa").forEach(s -> TeleportRequestManager.tpaDisabled.add(UUID.fromString(s)));
      this.togglesCfg.getStringList("disabled-tpahere").forEach(s -> TeleportRequestManager.tpahereDisabled.add(UUID.fromString(s)));
      this.togglesCfg.getStringList("auto-accept").forEach(s -> TeleportRequestManager.autoAccept.add(UUID.fromString(s)));
      this.getServer().getPluginManager().registerEvents(new TeleportListeners(), this);
   }

   public void onDisable() {
      this.togglesCfg.set("disabled-tpa", TeleportRequestManager.tpaDisabled.stream().map(UUID::toString).collect(Collectors.toList()));
      this.togglesCfg.set("disabled-tpahere", TeleportRequestManager.tpahereDisabled.stream().map(UUID::toString).collect(Collectors.toList()));
      this.togglesCfg.set("auto-accept", TeleportRequestManager.autoAccept.stream().map(UUID::toString).collect(Collectors.toList()));

      try {
         this.togglesCfg.save(this.togglesFile);
      } catch (IOException var2) {
         this.getLogger().severe("Could not save saves.yml!");
         var2.printStackTrace();
      }

      TeleportRequestManager.shutdown();
   }

   public static main getInstance() {
      return instance;
   }
}