yanush.des

Створи адон до PlotSquared котрий буде денамічно обмежувати світ за допомогою світового барєру. Щоб гравець не блукав по пустому сіту, світ буде обмежаний світовим барєром. І цей барєр буде розширятися по мірі заповнення гравцями плотів

Kodari AI
KodariJul 6 at 9:35 am 8

I’ll create a PlotSquared addon plugin that dynamically manages world borders based on claimed plot coverage.

PlotBorderExpander
A PlotSquared addon that dynamically expands the world border as players claim plots. When no plots are claimed, the world border is set to a small default area. As players claim and fill plots, the border automatically expands to encompass the entire claimed area with configurable padding. Supports both instant updates via PlotSquared events and periodic fallback checks. This prevents players from wandering into unclaimed, empty terrain while preserving access to all claimed plots.</project_description<project_name>PlotBorderExpander</project_name>
PlotSquared addon that dynamically manages world borders based on claimed plot coverage. As players claim more plots, the world border expands to encompass the new territory with configurable padding. Prevents players from wandering into empty unclaimed space. Supports border shrinking when plots are unclaimed, multiple worlds, configurable min/max limits, and admin commands for manual control.
yanush.des

The compilation failed with this error:

code
Compilation failed with 6 error(s):

ERROR in src/main/java/com/plotborder/listener/PlotListener.java at line 6: package com.plotsquared.bukkit.events does not exist
import com.plotsquared.bukkit.events.PlayerClaimPlotEvent;
                                    ^

ERROR in src/main/java/com/plotborder/listener/PlotListener.java at line 7: package com.plotsquared.bukkit.events does not exist
import com.plotsquared.bukkit.events.PlayerUnclaimPlotEvent;
                                    ^

ERROR in src/main/java/com/plotborder/listener/PlotListener.java at line 8: package com.plotsquared.bukkit.events does not exist
import com.plotsquared.bukkit.events.PlotDeleteEvent;
                                    ^

ERROR in src/main/java/com/plotborder/listener/PlotListener.java at line 26: cannot find symbol
    public void onPlotClaim(PlayerClaimPlotEvent event) {
                            ^
  symbol: class PlayerClaimPlotEvent
  location: class PlotListener

ERROR in src/main/java/com/plotborder/listener/PlotListener.java at line 33: cannot find symbol
    public void onPlotUnclaim(PlayerUnclaimPlotEvent event) {
                              ^
  symbol: class PlayerUnclaimPlotEvent
  location: class PlotListener

ERROR in src/main/java/com/plotborder/listener/PlotListener.java at line 40: cannot find symbol
    public void onPlotDelete(PlotDeleteEvent event) {
                             ^
  symbol: class PlotDeleteEvent
  location: class PlotListener


=== COMPILATION ERROR ANALYSIS ===

MISSING CLASSES:
  - PlayerClaimPlotEvent
  - PlayerUnclaimPlotEvent
  - PlotDeleteEvent
ACTION: Create these classes or check imports

FILES TO INVESTIGATE:
  - src/main/java/com/plotborder/listener/PlotListener.java

Please fix this error by creating a new artifact with the corrected code.

Kodari AI
KodariJul 6 at 9:41 am 6

The PlotSquared Bukkit event classes aren’t compiling because the dependency isn’t resolving locally. Let me rewrite the plugin to use PlotSquared’s core API directly — this is the proper v6 approach anyway.

No Java/Gradle available in this sandbox — the compilation error came from your environment. The com.plotsquared.bukkit.events classes don’t exist in your PlotSquared setup.

I’ll rewrite the plugin to use a periodic polling approach instead of Bukkit events. This is more robust — works with any PlotSquared version, no reflection hacks, no fragile event imports.

Now let me verify all files are consistent

All files are consistent. The fix replaced Bukkit-specific event imports (com.plotsquared.bukkit.events.*) with a polling approach that uses only PlotSquared Core API (com.plotsquared.core.*).

What changed:

  • PlotListener.java — Removed all Bukkit event imports. Now implements Listener with a single pollAndUpdate() method instead of per-event handlers.

  • PlotBorderExpander.java — Uses runTaskTimer(...) to poll every N ticks instead of depending on event classes that don’t exist in your PlotSquared build.

  • ConfigManager.java — Added getPollInterval() (default 200 ticks = 10s).

  • config.yml — Added poll-interval-ticks: 200 setting.

How it works:

  1. On enable, starts a repeating task (configurable interval, default 10 seconds)

  2. Each tick, scans all PlotAreas via PlotSquared.get().getPlotAreaManager().getAllPlotAreas()

  3. For each configured world, finds min/max X/Z of all owned base plots

  4. Sets the world border to a square encompassing those bounds + padding

  5. If no plots exist → resets to default-border-size at spawn

Commands: /plotborder recalc [world], /plotborder info [world], /plotborder reload

yanush.des

Плагін постійно надсилає в чат ці повідомлення, і в конфігу немає можливості відключати їх, чи можеш ти пофіксити цю проблему, адже чат за лічені секунди повністью перетворюється в спам

Приклад повідомлень: [PlotBorder] World border adjusted to 394 blocks (center: 51, -25)

Kodari AI
KodariJul 8 at 6:04 am 2

Готово. Три зміни:

  1. config.yml — broadcast-changes: false за замовчуванням, додано debug-logging: false

  2. ConfigManager.java — додано debugLogging(), getPollInterval(), broadcastChanges() тепер за замовчуванням false

  3. BorderManager.java — консольний лог загорнуто в if (configManager.debugLogging())

Після перезавантаження плагін більше не спамитиме ні в чат, ні в консоль. Якщо колі знадобиться увімкнути сповіщення для налагодження — увімкни broadcast-changes: true або debug-logging: true у config.yml.

yanush.des

Додай таку функцію, що коли гравець все ж якимось чином залітає за барєр. Припустімо блоків на 10, то її відразу телепортую на центр плота 0:0 у цьому світі. Бо барєр не зупиняє якщо гравесь використовує мод Axiom

Kodari AI
KodariJul 8 at 6:20 am 3

Готово. Додав новий клас AntiFlyListener:

  • Слухає PlayerMoveEvent (тільки якщо змінився блок X/Z) та PlayerTeleportEvent

  • Перевіряє, чи гравець вийшов за межі worldborder + border-cheat-distance

  • Якщо так — телепортує на плот (0,0) у цьому світі. Якщо плота (0,0) не існує — розраховує центр першого плота за розмірами PlotArea. Якщо й це не вдалося — на спавн світу

  • Надсилає гравцю повідомлення, чому його телепортувало

Налаштування в config.yml:

YAML
anti-fly:
  enabled: true          # увімкнути/вимкнути
  border-cheat-distance: 10  # блоків за кордон дозволено

Якщо хочеш відключити — постав enabled: false.

yanush.des

Чомусь я все ще можу літати за барєром, при включеній функції аксіома "No Clip", і мене не телепортує. Виправи це. Адже ця недоточність дає можливість літати за барєром і грузити чанки. І додатково якщо можеш, зроби так що за ці 10 секунд до телепортації, гравець не міг використовувати там команди, в часності /p claim. Адже в теорії він міг би вилитіти за барєр і забрати ділянку котра за барєром, чим самим іскуственно розширити межі барєра.

Kodari AI
KodariJul 8 at 6:34 am 7

Now I’ll update AntiFlyListener to add an active scan task (catches No Clip bypass), create a CommandBlocker listener, and update the main class.

Now create the CommandBlocker and update the main class to register everything:

Now create the CommandBlocker and update the main class:

Now update the main plugin class to register the CommandBlocker and start the scan task:

yanush.des

Світовий барєр розширується не коректно. Він зараз розширується в бік де була забрана нова ділянка. Мені потрібно щоб він розширювався рівномірно у всі боки. І не було перевісу в якусь одну із сторін. Тобто як тільки гравці займуть ближню лінію плотів біля барєру. Він автоматично розшириться в усі боки. Чи навіть якщо гравець зайняв лише один плот біля барєру (Почав нове коло плотів) то барєр всерівно буде розширено рівномірно, навіть біля ділянок які ще не зайняті.

Kodari AI
KodariJul 8 at 7:23 am 2

The problem is clear: the current code recalculates the bounding box center each time, so the center shifts toward wherever new plots are claimed. Instead, the border should keep a fixed center and expand equally in all directions based on the farthest plot from that center.

Now let me expose the reset command so admins can manually reset the center point

Готово. Зміни:

BorderManager.java — Нова логіка:

  1. Перший запуск: центр фіксується на середині всіх зайнятих плотів (як і раніше)

  2. Після цього центр НІКОЛИ не зміщується — тільки розмір збільшується

  3. Розмір розраховується як 2 × (найдальша відстань від центру до плота + padding)

  4. Це означає, що бар’єр розширюється рівномірно в усі боки, незалежно від того, з якого боку з’явилися нові плоти

BorderCommand.java — Додано /plotborder resetcenter — скидає зафіксований центр, щоб при наступному перерахунку він знову визначився від поточної середини плотів (на випадок, якщо треба змістити центр вручну).

yanush.des

Після рестарту сервера світовий барєр збився, і повернувся в якесь своє дивне розташування. Він повинен зберігати свій прогрес. І не ресетатись після кожного перезапуску

Kodari AI
KodariJul 8 at 7:49 am 1

The problem is fixedCenterX/fixedCenterZ are in-memory only — they reset to NaN on every restart, so the center is recalculated from the bounding box each time. I’ll persist them to a data.yml file

Готово. Тепер центр бар’єру зберігається в data.yml:

  • При першому розрахунку — центр визначається і зберігається на диск

  • Після рестарту — центр завантажується з data.yml, позиція не збивається

  • /plotborder resetcenter — видаляє збережений центр, при наступному розрахунку він визначиться заново

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
11 872
src/main/java/com/plotborder/PlotBorderExpander.java
package com.plotborder;

import com.plotborder.config.ConfigManager;
import com.plotborder.listener.PlotListener;
import com.plotborder.listener.AntiFlyListener;
import com.plotborder.listener.CommandBlocker;
import com.plotborder.manager.BorderManager;
import com.plotborder.command.BorderCommand;
import org.bukkit.plugin.java.JavaPlugin;

public class PlotBorderExpander extends JavaPlugin {

    private ConfigManager configManager;
    private BorderManager borderManager;
    private PlotListener plotListener;
    private BorderCommand borderCommand;
    private AntiFlyListener antiFlyListener;

    @Override
    public void onEnable() {
        saveDefaultConfig();

        this.configManager = new ConfigManager(this);
        this.borderManager = new BorderManager(this, configManager);
        this.plotListener = new PlotListener(this, borderManager, configManager);
        this.borderCommand = new BorderCommand(this, borderManager, configManager);
        this.antiFlyListener = new AntiFlyListener(this, configManager);

        getServer().getPluginManager().registerEvents(plotListener, this);
        getServer().getPluginManager().registerEvents(antiFlyListener, this);
        getServer().getPluginManager().registerEvents(new CommandBlocker(this, configManager, antiFlyListener), this);
        getCommand("plotborder").setExecutor(borderCommand);

        antiFlyListener.startScanTask();

        int pollInterval = configManager.getPollInterval();
        getServer().getScheduler().runTaskTimer(this, () -> {
            plotListener.pollAndUpdate();
        }, pollInterval, pollInterval);

        getLogger().info("Polling every " + pollInterval + " ticks (" + (pollInterval / 20) + "s).");
        getLogger().info("World borders initialized.");
    }

    @Override
    public void onDisable() {
    }

    public ConfigManager getConfigManager() {
        return configManager;
    }

    public BorderManager getBorderManager() {
        return borderManager;
    }
}