q2xcs
๐Ÿ“Ž 1 file 2,629 chars
๐Ÿ“„
pasted-code-1776587768457.txt
txt 163 lines
โ–ถ
# LifestealCore (All-in-One Zone + Warp + Spawn Plugin)

**Package:** `net.qxcs.dev`

---

## ๐ŸŽฏ Purpose

Create a Minecraft plugin (Java, Paper/Folia 1.2.11+) that includes: 

* Zone restriction system (Safezone & PvP Build)
* Spawn system with delayed teleport
* Warp system with dynamic tab completion
* Fully optimized and Folia-safe

---

## ๐Ÿง  Core System: Zone Modes

### ๐ŸŸข SAFEZONE

Players **CANNOT**:

* Break blocks
* Place blocks
* PvP
* Interact/place armor stands
* Place/edit signs
* Use/sign books
* Use buckets
* Use flint and steel

---

### ๐Ÿ”ด PVP_BUILD

Players **CAN**:

* PvP
* Place blocks

Players **CANNOT**:

* Break blocks *(unless placed-block tracking allows it)*

---

## โš™๏ธ Config (config.yml)

```yaml
mode-type: WORLD

worlds:
  spawn:
    mode: SAFEZONE
  arena:
    mode: PVP_BUILD

settings:
  allow-breaking-placed-blocks: true
  teleport-delay: 5 # seconds

messages:
  no-break: "&cYou cannot break blocks here!"
  no-place: "&cYou cannot place blocks here!"
  no-pvp: "&cPvP is disabled here!"
  teleporting: "&eTeleporting in &c%time% &e(DO NOT MOVE)"
  teleported: "&aTeleported!"
  moved-cancel: "&cTeleport cancelled because you moved!"
```

---

## ๐Ÿ“ Spawn System

### Commands:

* `/setspawn`

  * Saves current location to config

* `/spawn`

  * Teleports player to spawn with delay

### โณ Teleport Behavior

* Uses configurable delay
* Sends **action bar message every second**:

  ```
  Teleporting in X (DO NOT MOVE)
  ```
* If player **moves**, teleport is **cancelled**
* After countdown โ†’ teleport to spawn

---

## ๐ŸŒ Warp System

### Commands:

* `/setwarp `

  * Saves player location as warp

* `/warp `

  * Teleports with SAME delay system as `/spawn`

* `/delwarp `

  * Deletes a warp

---

## ๐Ÿ”ค Tab Completion (IMPORTANT)

* `/warp ` โ†’ shows all warp names dynamically
* `/delwarp ` โ†’ shows all warp names dynamically
* **DO NOT hardcode warp names**
* Must load from storage (config/file)

---

## ๐Ÿ” Permissions

```
lifestealcore.bypass
lifestealcore.admin
```

---
 

---
 
```

---

## ๐Ÿงต Folia Compatibility (VERY IMPORTANT)

* DO NOT use BukkitRunnable
* Use Folia scheduler / region-safe tasks
* Ensure thread safety (teleport + tracking)

---

## ๐Ÿš€ Performance

* Cache world โ†’ mode lookup
* Efficient warp storage
* Clean task cancellation
* Avoid memory leaks

---

## ๐Ÿ’ฌ Extra

* `/lifestealcore reload`
* Use Adventure API for action bar
* Clean, modular code
Kodari AI
KodariApr 19 at 8:40 am 26,512 (v2)

Iโ€™ll create a comprehensive all-in-one zone, spawn, and warp plugin with Folia support.

LifestealCore
All-in-one zone restriction, spawn, and warp system for Paper/Folia servers. Features dynamic world-based zone modes (SAFEZONE with full protection, PVP_BUILD allowing combat and building), delayed teleportation with movement cancellation, placed-block tracking, and dynamic warp management with tab completion. Includes action bar countdown, permission-based bypass, and hot-reload support.

Iโ€™ll create a comprehensive zone, spawn, and warp plugin with full Folia support

Perfect! Iโ€™ve created a comprehensive all-in-one zone, spawn, and warp plugin with full Folia support. The plugin includes:

Core Features:

  • Zone System: SAFEZONE (full protection) and PVP_BUILD (allows PvP & building, blocks breaking except placed blocks)

  • Spawn System: /spawn with delayed teleport, /setspawn to set location

  • Warp System: /warp, /setwarp, /delwarp with dynamic tab completion

  • Placed Block Tracking: Tracks placed blocks in PVP_BUILD zones for selective breaking

Technical Highlights:

  • Folia-Safe: All operations use FoliaLib schedulers (no BukkitRunnable)

  • Action Bar Countdown: Shows real-time countdown during teleport

  • Movement Detection: Cancels teleport if player moves

  • Adventure API: Modern text components for all messages

  • XSeries: Cross-version compatibility for materials

  • Hot-Reload: /lifestealcore reload reloads everything

  • Permission System: Bypass and admin permissions

  • Config-Driven: World modes, delays, and messages all configurable

All classes properly use @Getter Lombok annotations, managers are initialized in the correct order, and all method calls have matching definitions!

q2xcs

Add a option on the mode-type region use worldguard API to use it,

Kodari AI
KodariApr 19 at 8:51 am 13,955 (v2)

Iโ€™ll add WorldGuard region support as a new mode-type option. Let me first read the relevant files to understand the current implementation.

Now Iโ€™ll add WorldGuard region support. This will allow using regions instead of worlds for zone modes.

Perfect! Iโ€™ve added WorldGuard region support with the following changes:

New Features:

  • ModeType enum: Choose between WORLD (world-based zones) or REGION (WorldGuard region-based zones)

  • Region-based zone modes: Define zone modes for specific WorldGuard regions instead of entire worlds

  • Priority handling: If multiple regions overlap, uses the highest priority regionโ€™s mode

  • Graceful fallback: Works even if WorldGuard isnโ€™t installed (defaults to SAFEZONE)

Config Options:

YAML
# Use WORLD for world-based zones or REGION for WorldGuard regions
mode-type: WORLD  # or REGION

# For world-based zones (mode-type: WORLD)
worlds:
  world:
    mode: SAFEZONE
  world_nether:
    mode: PVP_BUILD

# For region-based zones (mode-type: REGION)
regions:
  spawn:
    mode: SAFEZONE
  arena:
    mode: PVP_BUILD
  pvp-zone:
    mode: PVP_BUILD

Technical Details:

  • Uses WorldGuard API 7.0.9+ with proper BukkitAdapter conversions

  • Checks for WorldGuard availability at runtime

  • All zone checks now use Location instead of just World

  • Region modes are cached for performance

  • Highest priority region wins when multiple regions overlap

  • Falls back to SAFEZONE if no matching region is found

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
manifest.kod
Code
23 1,110
src/main/java/net/qxcs/dev/LifestealCore.java
package net.qxcs.dev;

import com.tcoded.folialib.FoliaLib;
import lombok.Getter;
import net.qxcs.dev.command.*;
import net.qxcs.dev.config.ConfigManager;
import net.qxcs.dev.listener.ZoneListener;
import net.qxcs.dev.spawn.SpawnManager;
import net.qxcs.dev.teleport.TeleportManager;
import net.qxcs.dev.warp.WarpManager;
import net.qxcs.dev.zone.PlacedBlockManager;
import net.qxcs.dev.zone.ZoneManager;
import org.bukkit.Bukkit;
import org.bukkit.command.PluginCommand;
import org.bukkit.plugin.java.JavaPlugin;

@Getter
public class LifestealCore extends JavaPlugin {
    private FoliaLib foliaLib;
    private ConfigManager configManager;
    private ZoneManager zoneManager;
    private PlacedBlockManager placedBlockManager;
    private SpawnManager spawnManager;
    private WarpManager warpManager;
    private TeleportManager teleportManager;
    
    @Override
    public void onEnable() {
        foliaLib = new FoliaLib(this);
        
        configManager = new ConfigManager(this);
        zoneManager = new ZoneManager(configManager);
        placedBlockManager = new PlacedBlockManager(this);
        spawnManager = new SpawnManager(configManager);
        warpManager = new WarpManager(configManager);
        teleportManager = new TeleportManager(foliaLib, configManager);
        
        registerCommands();
        registerListeners();
        
        getLogger().info("LifestealCore has been enabled!");
    }
    
    @Override
    public void onDisable() {
        if (foliaLib != null) {
            foliaLib.getScheduler().cancelAllTasks();
        }
        
        if (placedBlockManager != null) {
            placedBlockManager.save();
        }
        
        getLogger().info("LifestealCore has been disabled!");
    }
    
    private void registerCommands() {
        setCommandExecutor("spawn", new SpawnCommand(this));
        setCommandExecutor("setspawn", new SetSpawnCommand(this));
        
        WarpCommand warpCommand = new WarpCommand(this);
        setCommandExecutor("warp", warpCommand);
        setTabCompleter("warp", warpCommand);
        
        setCommandExecutor("setwarp", new SetWarpCommand(this));
        
        DelWarpCommand delWarpCommand = new DelWarpCommand(this);
        setCommandExecutor("delwarp", delWarpCommand);
        setTabCompleter("delwarp", delWarpCommand);
        
        setCommandExecutor("lifestealcore", new LifestealCoreCommand(this));
    }
    
    private void registerListeners() {
        Bukkit.getPluginManager().registerEvents(new ZoneListener(this), this);
    }
    
    private void setCommandExecutor(String name, org.bukkit.command.CommandExecutor executor) {
        PluginCommand command = getCommand(name);
        if (command != null) {
            command.setExecutor(executor);
        }
    }
    
    private void setTabCompleter(String name, org.bukkit.command.TabCompleter completer) {
        PluginCommand command = getCommand(name);
        if (command != null) {
            command.setTabCompleter(completer);
        }
    }
}