PROMPT TẠO PLUGIN ZEMPIRECORE
Bạn là dev Java plugin Minecraft chuyên nghiệp. Hãy tạo plugin hoàn chỉnh tên ZEmpireCore cho server:
- Minecraft: 1.21.4
- Server: Leaf latest build
- Java: 25
- API: Paper/Leaf compatible
- Không dùng NMS nếu không cần
- Dữ liệu: SQLite mặc định, hỗ trợ MySQL
- Hỗ trợ PlaceholderAPI
- Tối ưu TPS, không scan toàn map liên tục
- Mọi gameplay phải chỉnh được trong config
Mục tiêu plugin:
Tạo hệ thống survival hậu tận thế kiểu Rust / ARK cho server Z Empire gồm:
- Claim block theo từng block
- Base Core vùng 100 block
- Build Tool 1x1 / 3x3 / 5x5
- Particle preview khi build
- Snap placement xây nối tiếp
- Block có HP
- Raid phá block bằng tool/explosive
- Crew + phân quyền
- Skill Tree dạng INVENTORY GUI
- Survival stats: nước, nhiệt độ, nhiễm bệnh, sanity, stamina, radiation
- Placeholder đầy đủ
==================================================
- CẤU TRÚC THƯ MỤC
==================================================
plugins/ZEmpireCore/ config.yml database.yml messages.yml placeholders.yml
claim/ claim.yml block_hp.yml
base/ base.yml limits.yml decay.yml
build/ build.yml materials.yml structures.yml particles.yml snapping.yml build_time.yml
raid/ raid.yml tools.yml explosives.yml
survival/ stats.yml stamina.yml infection.yml sanity.yml temperature.yml radiation.yml
skills/ levels.yml skilltree.yml builder.yml survivor.yml combat.yml raider.yml scavenger.yml medic.yml
crew/ crew.yml roles.yml limits.yml INVENTORY GUI.yml log.yml
INVENTORY GUI/ base_gui.yml skilltree_gui.yml crew_gui.yml
data/ database.db
==================================================
- DATABASE
==================================================
Tạo SQLite/MySQL tables:
players: uuid, name, level, exp, skill_points, used_skill_points, water, temperature, infection, sanity, stamina, radiation, bleeding, broken_leg, last_seen
claimed_blocks: world, x, y, z, owner_uuid, owner_type, crew_id, base_id, material_type, structure_type, current_hp, max_hp, placed_time, outside_block
bases: base_id, owner_uuid, owner_type, crew_id, world, core_x, core_y, core_z, radius, created_time, lowest_y, highest_y, block_count, decay_status, upkeep_until
skills: uuid, skill_id, level
crews: crew_id, crew_name, crew_tag, owner_uuid, level, exp, max_members, base_id, home_world, home_x, home_y, home_z, home_yaw, home_pitch, friendly_fire, open_join, description, created_time
crew_members: crew_id, uuid, name, role_id, role_priority, joined_time, last_online, contribution_exp, contribution_raid, contribution_build, contribution_loot
crew_invites: crew_id, target_uuid, inviter_uuid, created_time, expire_time
crew_logs: id, crew_id, actor_uuid, action, detail, created_time
==================================================
- CLAIM BLOCK
==================================================
Không dùng WorldGuard/Factions/GriefPrevention.
Mỗi block player đặt bằng Build Tool sẽ thành claim block.
Mỗi claim block lưu:
- owner_uuid
- owner_type: PLAYER hoặc CREW
- crew_id nếu có
- base_id nếu thuộc base
- material_type
- structure_type
- current_hp / max_hp
- outside_block true/false
Luật:
- Block ai đặt thì người đó/crew đó sở hữu.
- Người khác không phá tay được.
- Chỉ phá được bằng raid tool/explosive.
- Chủ block hoặc người có quyền crew mới được demolish/sửa/nâng cấp.
- Block ngoài base vẫn có HP, owner, nhưng không tạo base.
claim.yml: claim: enabled: true save-player-placed-blocks: true prevent-vanilla-break-owned-block: true allow-raid-damage: true outside-blocks: enabled: true create-base-zone: false count-as-base-block: false
==================================================
- BASE CORE
==================================================
Base không tự tạo khi đặt block.
Cơ chế:
- Player đặt block claim trước.
- Player đặt Base Core trên block claim của mình.
- Hệ thống tạo base chính tại Core.
- Core tạo vùng 100 block.
- Địch không thể đặt Core trong 100 block.
- Địch vẫn có thể đặt block thường trong vùng đó để raid/build cover.
- Block địch đặt trong vùng base người khác không tính là base của địch.
- Solo player chỉ có 1 base.
- Crew chỉ có 1 base.
base.yml: base: enabled: true core: structure-type: BASE_CORE radius: 100 min-distance-between-cores: 100 require-core-on-owned-claim-block: true prevent-enemy-core-inside-radius: true allow-enemy-normal-block-inside-radius: true limits: max-base-per-player: 1 max-base-per-crew: 1
limits.yml: limits: max-blocks-per-base: 2500 max-chests-per-base: 50 max-turrets-per-base: 12 max-doors-per-base: 80 max-height-from-lowest-block: 50 core-place-cooldown-seconds: 86400 base-disband-cooldown-seconds: 86400 prevent-same-ip-base-abuse: true
Giới hạn cao:
- Tính từ block thấp nhất của base.
- Block cao nhất không vượt quá 50 block.
==================================================
- BUILD TOOL
==================================================
Tạo item Build Tool.
Công dụng:
- Preview particle vùng build
- Đặt công trình
- Đổi size build
- Đổi loại công trình
- Xoay hướng
- Demolish block của mình/crew nếu có quyền
- Repair/upgrade block
Điều khiển:
- Chuột phải: đặt công trình
- Phím F: đổi size 1x1 -> 3x3 -> 5x5 -> 1x1
- Khi bấm F phải cancel swap hand, không đổi tay
- Shift + chuột trái: đổi loại công trình
- Shift + chuột phải: xoay công trình
- Chuột trái: demolish block đang nhìn nếu có quyền
build.yml: build: enabled: true tool: material: IRON_AXE custom-model-data: 900001 name: "7FF55☣ ʙᴜɪʟᴅ ᴛᴏᴏʟ" modes: [1x1, 3x3, 5x5] default-mode: 1x1 default-structure: FOUNDATION one-active-build-only: true cancel-build-if-damaged: true cancel-build-if-combat-tagged: true
Structure types:
FOUNDATION, FLOOR, WALL, HALF_WALL, DOOR_FRAME, WINDOW_FRAME, ROOF, RAMP, STAIR, PILLAR, FENCE, GATE, CEILING, BASE_CORE
==================================================
- BUILD PREVIEW PARTICLE
==================================================
Khi player cầm Build Tool:
- Hiện particle bao vùng chuẩn bị build.
- 1x1/3x3/5x5 hiện đúng vùng.
- Hợp lệ: xanh.
- Không hợp lệ: đỏ.
- Snap placement: xanh dương.
- Thiếu vật liệu: vàng.
- Chỉ hiện cho player đó.
- Update mỗi vài tick để tránh lag.
particles.yml: particles: enabled: true update-ticks: 4 max-preview-distance: 8 outline-only: true valid-color: "0,255,80" invalid-color: "255,40,40" snapping-color: "0,180,255" missing-material-color: "255,180,0"
==================================================
- CHỐNG BUILD CHÈN BLOCK
==================================================
Trước khi build:
- Check toàn bộ block sẽ bị đặt.
- Nếu block không phải AIR/allow-replace thì chặn.
- Không cho đè claim block.
- Không cho đè map cố định.
- Không cho build xuyên solid block.
- Không cho build trên liquid nếu config tắt.
placement: prevent-overlap: true allow-replace: [AIR, SHORT_GRASS, TALL_GRASS, SNOW] prevent-place-inside-solid: true prevent-place-on-liquid: true prevent-place-in-protected-map-structure: true
==================================================
- SNAP PLACEMENT
==================================================
Cơ chế xây nối tiếp:
- Nhìn vào cạnh block build hợp lệ sẽ gợi ý vị trí tiếp theo.
- Floor snap cạnh floor/foundation.
- Wall snap trên cạnh foundation/floor.
- Stair/Ramp snap theo hướng nhìn.
- Chuột phải là đặt ngay vị trí gợi ý.
- Snap không tự đặt nếu chưa click.
snapping.yml: snapping: enabled: true max-distance: 7 require-looking-at-build-block: true allow-snap-to-own-block: true allow-snap-to-crew-block: true allow-snap-to-enemy-block: false
==================================================
- BUILD TIME / QUEUE
==================================================
Để tránh lag:
- 1x1 đặt nhanh.
- 3x3 và 5x5 đặt từng block theo queue.
- Khi đang build chưa xong thì không được build cái khác.
- Bị đánh/combat tag thì hủy nếu config bật.
- Thiếu vật liệu thì hủy.
build_time.yml: build-time: enabled: true one-active-build-only: true mode-time: 1x1: 0.3 3x3: 2.5 5x5: 6.0 place-interval-ticks: 2 cancel-if-damaged: true cancel-if-combat-tagged: true cancel-if-no-material: true show-actionbar-progress: true
Skill Builder giảm thời gian build.
==================================================
- MATERIAL / BLOCK HP
==================================================
materials.yml: materials:
WOOD: block-material: OAK_PLANKS max-hp: 500 repair-item: OAK_LOG repair-per-item: 50 build-cost:
OAK_LOG: 5
STONE: block-material: STONE_BRICKS max-hp: 1500 repair-item: COBBLESTONE repair-per-item: 75 build-cost:
COBBLESTONE: 10
METAL: block-material: IRON_BLOCK max-hp: 3500 repair-item: IRON_INGOT repair-per-item: 100 build-cost:
IRON_INGOT: 8
REINFORCED_STEEL: block-material: NETHERITE_BLOCK max-hp: 7000 repair-item: NETHERITE_SCRAP repair-per-item: 150 build-cost:
NETHERITE_SCRAP: 4 IRON_INGOT: 16
==================================================
- RAID SYSTEM
==================================================
Block claim có HP. Địch chỉ phá bằng raid tool/explosive.
tools.yml: raid-tools:
WOOD:
IRON_AXE: 15 STONE_AXE: 8 C4: 500 ROCKET: 350 STONE:
IRON_PICKAXE: 10 DIAMOND_PICKAXE: 18 C4: 450 ROCKET: 400 METAL:
C4: 700 ROCKET: 550 EXPLOSIVE_AMMO: 20 REINFORCED_STEEL:
C4: 500 ROCKET: 750
Luật:
- Không phá map gốc.
- Hiện actionbar HP block khi đánh.
- HP <= 0 thì block vỡ và xóa data.
- Nếu block thuộc base thì giảm block_count.
==================================================
- DECAY / UPKEEP
==================================================
Base cần upkeep.
Hết upkeep thì decay.
decay.yml: decay: enabled: true grace-period-hours: 24 decay-start-after-hours: 24 abandoned-after-hours: 72 damage-percent-per-hour: 5 upkeep-items:
WOOD: OAK_LOG STONE: COBBLESTONE METAL: IRON_INGOT REINFORCED_STEEL: NETHERITE_SCRAP
==================================================
- SURVIVAL STATS
==================================================
Stats:
- Water
- Temperature
- Infection
- Sanity
- Stamina
- Radiation
- Bleeding
- Broken Leg
stats.yml: stats: update-ticks: 20 water: max: 100 default: 100 drain-per-minute: 1.2 damage-when-zero: 1.0 temperature: default: 37 min-safe: 34 max-safe: 40 infection: max: 100 default: 0 zombie-hit-add: 5 zombie-special-hit-add: 15 sanity: max: 100 default: 100 dark-drain-per-minute: 1 black-zone-drain-per-minute: 3 stamina: max: 100 default: 100 regen-per-second: 8 sprint-drain-per-second: 6 roll-cost: 25 radiation: max: 100 default: 0 damage-threshold: 70
Stamina:
- Sprint tốn stamina.
- Roll tốn stamina.
- Hết stamina thì không sprint/roll.
Infection:
- Zombie đánh có tỉ lệ tăng infection.
- Stage cao giảm regen, giảm stamina, mất máu.
- Cure item: ANTIBIOTIC, VACCINE.
Sanity:
- Giảm ở nơi tối, Black Zone, gần zombie/boss.
- Thấp gây âm thanh ảo, hiệu ứng mờ/nausea nếu config bật.
Temperature:
- Lạnh/nóng ảnh hưởng nước/máu.
- Campfire làm ấm.
Radiation:
- Lab/Military/Black Zone tăng radiation.
- Hazmat giảm nếu có hook item.
==================================================
- LEVEL / SKILL TREE
==================================================
Player max level 100.
Mỗi level +1 Skill Point.
EXP từ kill zombie, loot crate, build, repair, raid damage, boss, quest.
levels.yml: levels: max-level: 100 skill-points-per-level: 1 formula: base: 100 multiplier: 50 curve: 8 exp-sources: kill-zombie: 10 kill-special-zombie: 35 loot-common-crate: 5 loot-rare-crate: 25 build-block: 1 repair-block: 2 raid-damage-per-100: 3
Skill Tree INVENTORY GUI kiểu node giống YBA:
- Node khóa/chưa mở/đã mở.
- Node cha cần mở trước node con.
- Dùng chest INVENTORY GUI 6 rows.
- Có reset skill bằng item.
Nhánh:
- Builder
- Survivor
- Combat
- Raider
- Scavenger
- Medic
Builder skills: quick_hands: giảm thời gian build 5/10/15/20/35% material_saver: giảm cost build 3/6/9/12/15% repair_expert: tăng repair 10/20/30% structure_engineer: tăng HP block 2/4/6/8/10% mass_builder: mở 3x3/5x5 nếu config bật
Survivor:
- giảm mất nước
- chống nhiệt
- giảm mất sanity
- tăng stamina max
Combat:
- tăng damage zombie
- giảm recoil nếu hook được gun plugin
- tăng melee
Raider:
- tăng raid damage nhẹ
- giảm thời gian đặt explosive
Scavenger:
- tăng scrap loot
- tăng blueprint chance
Medic:
- tăng hồi máu
- giảm infection
- tăng hiệu quả thuốc
==================================================
- CREW SYSTEM
==================================================
Crew là team nội bộ.
Mỗi player chỉ ở 1 crew.
Mỗi crew chỉ có 1 base.
Nếu player có crew thì Base Core/base thuộc crew.
Nếu không có crew thì base thuộc cá nhân.
crew.yml: crew: enabled: true max-crew-per-player: 1 default-max-members: 6 one-base-per-crew: true allow-solo-player-base: true leave-crew-cooldown-seconds: 43200 create-crew-cooldown-seconds: 86400 friendly-fire-default: false
base-integration: if-player-has-crew: core-owner-type: CREW claim-block-owner-type: CREW if-player-no-crew: core-owner-type: PLAYER claim-block-owner-type: PLAYER outside-block-owner-type: PLAYER require-role-permission-to-build-in-crew-base: true require-role-permission-to-demolish-in-crew-base: true require-role-permission-to-open-storage: true
==================================================
- CREW ROLE / PHÂN QUYỀN
==================================================
Role mặc định:
OWNER:
- toàn quyền
- disband, rename, invite, kick, promote/demote
- đặt/xóa core
- build, demolish, repair, upgrade
- quản lý upkeep, storage, turret
DEPUTY:
- phó crew
- invite/kick người thấp quyền
- promote/demote người thấp quyền
- build/demolish/repair/upgrade nếu config bật
- không disband
OFFICER:
- invite
- build/repair
- dùng storage/cửa
- không phá base nếu permission false
BUILDER:
- build/repair/upgrade
- không kick/invite
- không phá base nếu permission false
MEMBER:
- thành viên thường
- dùng cửa/rương nếu cho phép
- không phá base team
RECRUIT:
- lính mới
- quyền thấp nhất
- không phá base
- không mở rương quan trọng
- không đặt turret
Mỗi role có permission: disband, rename, change_tag, invite, kick, promote, demote, place_core, remove_core, build, demolish_base_block, demolish_own_block, upgrade_block, repair_block, manage_upkeep, open_storage, use_door, use_turret, place_turret, remove_turret, manage_permissions
Khi thao tác base crew:
- BUILD cần build
- DEMOLISH cần demolish_base_block hoặc demolish_own_block
- UPGRADE cần upgrade_block
- REPAIR cần repair_block
- OPEN_STORAGE cần open_storage
- PLACE_TURRET cần place_turret
==================================================
- CREW LEVEL / LIMIT / CHAT / LOG
==================================================
Crew level max 5.
Level tăng max members.
limits.yml: limits: max-members-default: 6 max-members-by-crew-level: 1: 6 2: 8 3: 10 4: 12 5: 15 max-deputies: 2 max-officers: 4 prevent-same-ip-multi-crew-abuse: true
Crew EXP từ: kill zombie, loot crate, build, repair, raid damage, Horde Night.
Crew chat: /cc <message> /cc toggle
Format: "7FF55[ᴄʀᴇᴡ] &7[%crew_tag%] &f%player% &8» &f%message%"
Crew log ghi: create, disband, join, leave, kick, promote, demote, role change, core place/break, demolish block, raid damage, upkeep low, decay.
==================================================
- COMMANDS
==================================================
Player: /zempire /base /base info /base disband /base members /skills /skilltree /buildtool /stats
Crew: /crew /crew create <name> /crew disband /crew invite <player> /crew accept <crew> /crew deny <crew> /crew kick <player> /crew leave /crew promote <player> /crew demote <player> /crew role <player> <role> /crew info /crew members /crew online /crew chat <message> /cc <message> /crew tag <tag> /crew rename <name> /crew friendlyfire /crew home /crew sethome /crew base /crew permissions /crew log /crew top /crew level
Admin: /zecore reload /zecore givebuildtool <player> /zecore givecore <player> /zecore setlevel <player> <level> /zecore addexp <player> <amount> /zecore resetskills <player> /zecore debugblock /zecore removebase <base/player> /zecore crew setrole <player> <role> /zecore crew setlevel <crew> <level> /zecore crew addexp <crew> <amount>
Permissions: zempire.admin zempire.reload zempire.bypass zempire.buildtool zempire.base.create zempire.skills.open zempire.stats.view zempire.crew.create zempire.crew.admin
==================================================
- PLACEHOLDERAPI
==================================================
Tạo PlaceholderAPI Expansion.
Crew: %zempire_crew_name% %zempire_crew_tag% %zempire_crew_id% %zempire_crew_role% %zempire_crew_role_display% %zempire_crew_members% %zempire_crew_max_members% %zempire_crew_online% %zempire_crew_owner% %zempire_crew_level% %zempire_crew_exp% %zempire_crew_exp_required% %zempire_crew_base_id% %zempire_crew_base_status% %zempire_crew_base_blocks% %zempire_crew_base_upkeep_time% %zempire_crew_friendly_fire%
Alias ngắn: %crew_name% %crew_tag% %crew_role% %crew_members% %crew_online% %crew_owner% %crew_level% %crew_base_status%
Player: %zempire_level% %zempire_exp% %zempire_exp_required% %zempire_skill_points%
Survival: %zempire_water% %zempire_temperature% %zempire_infection% %zempire_sanity% %zempire_stamina% %zempire_radiation% %zempire_bleeding% %zempire_broken_leg%
Base: %zempire_base_id% %zempire_base_owner% %zempire_base_owner_type% %zempire_base_blocks% %zempire_base_block_limit% %zempire_base_height% %zempire_base_height_limit% %zempire_base_upkeep_time% %zempire_base_decay_status%
Build: %zempire_build_mode% %zempire_build_structure% %zempire_build_material% %zempire_build_valid% %zempire_build_progress%
Target block: %zempire_target_block_owner% %zempire_target_block_hp% %zempire_target_block_max_hp% %zempire_target_block_material% %zempire_target_block_structure% %zempire_target_block_is_raidable%
Nếu không có crew: crew_name = "Không có Crew" crew_tag = "-" crew_role = "-" crew_members = 0 crew_base_status = "Không có Base"
==================================================
- PERFORMANCE
==================================================
Bắt buộc:
- Không scan toàn world
- Chỉ xử lý qua event
- Cache claim block theo chunk
- Save database async
- Chunk unload thì flush data async
- Particle preview chỉ chạy khi cầm Build Tool
- Particle update mỗi 4 tick
- 5x5 build theo queue, không đặt 25 block cùng tick
- Survival update theo config, mặc định 20 tick
- Không dùng nhiều armorstand/entity để preview
Events cần xử lý:
PlayerInteractEvent PlayerSwapHandItemsEvent BlockPlaceEvent BlockBreakEvent EntityDamageByEntityEvent EntityExplodeEvent BlockExplodeEvent PlayerJoinEvent PlayerQuitEvent ChunkLoadEvent ChunkUnloadEvent InventoryClickEvent PlayerDeathEvent FoodLevelChangeEvent
==================================================
- PACKAGE CODE
==================================================
Package: com.zempire.core com.zempire.core.build com.zempire.core.base com.zempire.core.claim com.zempire.core.raid com.zempire.core.survival com.zempire.core.skills com.zempire.core.crew com.zempire.core.INVENTORY GUI com.zempire.core.storage com.zempire.core.commands com.zempire.core.hooks com.zempire.core.utils
Class chính cần có:
ZEmpireCorePlugin ConfigManager DatabaseManager MessageManager ClaimBlockManager BaseManager BuildManager BuildPreviewTask BuildTask RaidManager SurvivalManager LevelManager SkillTreeManager CrewManager CrewCommand CrewGui CrewRoleGui CrewLogManager PlaceholderManager
==================================================
- KẾT QUẢ CẦN TRẢ
==================================================
Xuất plugin hoàn chỉnh gồm:
- build.gradle hoặc pom.xml
- plugin.yml
- toàn bộ Java source
- toàn bộ config mặc định
- SQL schema
- hướng dẫn build jar
- hướng dẫn cài plugin
- hướng dẫn reload
- hướng dẫn thêm material mới
- hướng dẫn thêm structure mới
- hướng dẫn thêm skill mới
- hướng dẫn dùng placeholder
- hướng dẫn phân quyền crew
Không viết demo thiếu.
Không hardcode gameplay.
Không bỏ sót Claim Block, Base Core, Build Tool, Crew, Skill Tree, Survival Stats, PlaceholderAPI.
The compilation failed with this error:
Compilation failed with 100 error(s):
ERROR in src/main/java/com/zempire/core/ZEmpireCorePlugin.java at line 20: class ZEmpireCorePlugin is public, should be declared in a file named ZEmpireCorePlugin.java
public final class ZEmpireCorePlugin extends JavaPlugin {
^
ERROR in src/main/java/com/zempire/core/build/BuildPreviewTask.java at line 8: cannot find symbol
import com.cryptomorin.xseries.XParticle;
^
symbol: class XParticle
location: package com.cryptomorin.xseries
ERROR in src/main/java/com/zempire/core/build/BuildPreviewTask.java at line 28: cannot find symbol
XParticle.of(builds.isValidPreview(player) ? "END_ROD" : "SMOKE")
^
symbol: variable XParticle
location: class BuildPreviewTask
ERROR in src/main/java/com/zempire/core/build/BuildManager.java at line 150: cannot find symbol
return base == null || crews.hasPermission(player.getUniqueId(), "build") || base.getOwnerUuid().equals(player.getUniqueId().toString());
^
symbol: method getOwnerUuid()
location: variable base of type BaseData
ERROR in src/main/java/com/zempire/core/build/BuildManager.java at line 158: cannot find symbol
String current = structures.getOrDefault(0, "FOUNDATION");
^
symbol: method getOrDefault(int,String)
location: variable structures of type List<String>
ERROR in src/main/java/com/zempire/core/build/BuildManager.java at line 159: cannot find symbol
int index = Math.max(0, structures.indexOf(structures.getOrDefault(structures.indexOf(current) + 1, current)));
^
symbol: method getOrDefault(int,String)
location: variable structures of type List<String>
ERROR in src/main/java/com/zempire/core/claim/ClaimBlockManager.java at line 51: cannot find symbol
cache.put(key(claim.getWorld(), claim.getX(), claim.getY(), claim.getZ()), claim);
^
symbol: method getWorld()
location: variable claim of type ClaimBlock
ERROR in src/main/java/com/zempire/core/claim/ClaimBlockManager.java at line 51: cannot find symbol
cache.put(key(claim.getWorld(), claim.getX(), claim.getY(), claim.getZ()), claim);
^
symbol: method getX()
location: variable claim of type ClaimBlock
ERROR in src/main/java/com/zempire/core/claim/ClaimBlockManager.java at line 51: cannot find symbol
cache.put(key(claim.getWorld(), claim.getX(), claim.getY(), claim.getZ()), claim);
^
symbol: method getY()
location: variable claim of type ClaimBlock
ERROR in src/main/java/com/zempire/core/claim/ClaimBlockManager.java at line 51: cannot find symbol
cache.put(key(claim.getWorld(), claim.getX(), claim.getY(), claim.getZ()), claim);
^
symbol: method getZ()
location: variable claim of type ClaimBlock
ERROR in src/main/java/com/zempire/core/claim/ClaimBlockManager.java at line 55: cannot find symbol
statement.setString(1, claim.getWorld());
^
symbol: method getWorld()
location: variable claim of type ClaimBlock
ERROR in src/main/java/com/zempire/core/claim/ClaimBlockManager.java at line 56: cannot find symbol
statement.setInt(2, claim.getX());
^
symbol: method getX()
location: variable claim of type ClaimBlock
ERROR in src/main/java/com/zempire/core/claim/ClaimBlockManager.java at line 57: cannot find symbol
statement.setInt(3, claim.getY());
^
symbol: method getY()
location: variable claim of type ClaimBlock
ERROR in src/main/java/com/zempire/core/claim/ClaimBlockManager.java at line 58: cannot find symbol
statement.setInt(4, claim.getZ());
^
symbol: method getZ()
location: variable claim of type ClaimBlock
ERROR in src/main/java/com/zempire/core/claim/ClaimBlockManager.java at line 59: cannot find symbol
statement.setString(5, claim.getOwnerUuid());
^
symbol: method getOwnerUuid()
location: variable claim of type ClaimBlock
ERROR in src/main/java/com/zempire/core/claim/ClaimBlockManager.java at line 60: cannot find symbol
statement.setString(6, claim.getOwnerType());
^
symbol: method getOwnerType()
location: variable claim of type ClaimBlock
ERROR in src/main/java/com/zempire/core/claim/ClaimBlockManager.java at line 61: cannot find symbol
statement.setString(7, claim.getCrewId());
^
symbol: method getCrewId()
location: variable claim of type ClaimBlock
ERROR in src/main/java/com/zempire/core/claim/ClaimBlockManager.java at line 62: cannot find symbol
statement.setString(8, claim.getBaseId());
^
symbol: method getBaseId()
location: variable claim of type ClaimBlock
ERROR in src/main/java/com/zempire/core/claim/ClaimBlockManager.java at line 63: cannot find symbol
statement.setString(9, claim.getMaterialType());
^
symbol: method getMaterialType()
location: variable claim of type ClaimBlock
ERROR in src/main/java/com/zempire/core/claim/ClaimBlockManager.java at line 64: cannot find symbol
statement.setString(10, claim.getStructureType());
^
symbol: method getStructureType()
location: variable claim of type ClaimBlock
ERROR in src/main/java/com/zempire/core/claim/ClaimBlockManager.java at line 65: cannot find symbol
statement.setDouble(11, claim.getCurrentHp());
^
symbol: method getCurrentHp()
location: variable claim of type ClaimBlock
ERROR in src/main/java/com/zempire/core/claim/ClaimBlockManager.java at line 66: cannot find symbol
statement.setDouble(12, claim.getMaxHp());
^
symbol: method getMaxHp()
location: variable claim of type ClaimBlock
ERROR in src/main/java/com/zempire/core/claim/ClaimBlockManager.java at line 67: cannot find symbol
statement.setLong(13, claim.getPlacedTime());
^
symbol: method getPlacedTime()
location: variable claim of type ClaimBlock
ERROR in src/main/java/com/zempire/core/claim/ClaimBlockManager.java at line 68: cannot find symbol
statement.setBoolean(14, claim.isOutsideBlock());
^
symbol: method isOutsideBlock()
location: variable claim of type ClaimBlock
ERROR in src/main/java/com/zempire/core/claim/ClaimBlockManager.java at line 84: cannot find symbol
statement.setString(1, claim.getWorld());
^
symbol: method getWorld()
location: variable claim of type ClaimBlock
ERROR in src/main/java/com/zempire/core/claim/ClaimBlockManager.java at line 85: cannot find symbol
statement.setInt(2, claim.getX());
^
symbol: method getX()
location: variable claim of type ClaimBlock
ERROR in src/main/java/com/zempire/core/claim/ClaimBlockManager.java at line 86: cannot find symbol
statement.setInt(3, claim.getY());
^
symbol: method getY()
location: variable claim of type ClaimBlock
ERROR in src/main/java/com/zempire/core/claim/ClaimBlockManager.java at line 87: cannot find symbol
statement.setInt(4, claim.getZ());
^
symbol: method getZ()
location: variable claim of type ClaimBlock
ERROR in src/main/java/com/zempire/core/claim/ClaimBlockManager.java at line 96: cannot find symbol
return claim != null && claim.getOwnerUuid().equals(uuid.toString());
^
symbol: method getOwnerUuid()
location: variable claim of type ClaimBlock
ERROR in src/main/java/com/zempire/core/base/BaseManager.java at line 26: cannot find symbol
.filter(base -> base.getWorld().equals(location.getWorld().getName())
^
symbol: method getWorld()
location: variable base of type BaseData
ERROR in src/main/java/com/zempire/core/base/BaseManager.java at line 27: cannot find symbol
&& base.getCoreX() - base.getRadius() <= location.getBlockX()
^
symbol: method getCoreX()
location: variable base of type BaseData
ERROR in src/main/java/com/zempire/core/base/BaseManager.java at line 27: cannot find symbol
&& base.getCoreX() - base.getRadius() <= location.getBlockX()
^
symbol: method getRadius()
location: variable base of type BaseData
ERROR in src/main/java/com/zempire/core/base/BaseManager.java at line 28: cannot find symbol
&& base.getCoreX() + base.getRadius() >= location.getBlockX()
^
symbol: method getCoreX()
location: variable base of type BaseData
ERROR in src/main/java/com/zempire/core/base/BaseManager.java at line 28: cannot find symbol
&& base.getCoreX() + base.getRadius() >= location.getBlockX()
^
symbol: method getRadius()
location: variable base of type BaseData
ERROR in src/main/java/com/zempire/core/base/BaseManager.java at line 29: cannot find symbol
&& base.getCoreZ() - base.getRadius() <= location.getBlockZ()
^
symbol: method getCoreZ()
location: variable base of type BaseData
ERROR in src/main/java/com/zempire/core/base/BaseManager.java at line 29: cannot find symbol
&& base.getCoreZ() - base.getRadius() <= location.getBlockZ()
^
symbol: method getRadius()
location: variable base of type BaseData
ERROR in src/main/java/com/zempire/core/base/BaseManager.java at line 30: cannot find symbol
&& base.getCoreZ() + base.getRadius() >= location.getBlockZ())
^
symbol: method getCoreZ()
location: variable base of type BaseData
ERROR in src/main/java/com/zempire/core/base/BaseManager.java at line 30: cannot find symbol
&& base.getCoreZ() + base.getRadius() >= location.getBlockZ())
^
symbol: method getRadius()
location: variable base of type BaseData
ERROR in src/main/java/com/zempire/core/base/BaseManager.java at line 35: cannot find symbol
return bases.values().stream().filter(base -> base.getOwnerUuid().equals(owner.toString())).findFirst().orElse(null);
^
symbol: method getOwnerUuid()
location: variable base of type BaseData
ERROR in src/main/java/com/zempire/core/base/BaseManager.java at line 43: cannot find symbol
return bases.values().stream().noneMatch(base -> base.getWorld().equals(location.getWorld().getName())
^
symbol: method getWorld()
location: variable base of type BaseData
ERROR in src/main/java/com/zempire/core/base/BaseManager.java at line 44: cannot find symbol
&& base.getCoreX() - distance <= location.getBlockX()
^
symbol: method getCoreX()
location: variable base of type BaseData
ERROR in src/main/java/com/zempire/core/base/BaseManager.java at line 45: cannot find symbol
&& base.getCoreX() + distance >= location.getBlockX()
^
symbol: method getCoreX()
location: variable base of type BaseData
ERROR in src/main/java/com/zempire/core/base/BaseManager.java at line 46: cannot find symbol
&& base.getCoreZ() - distance <= location.getBlockZ()
^
symbol: method getCoreZ()
location: variable base of type BaseData
ERROR in src/main/java/com/zempire/core/base/BaseManager.java at line 47: cannot find symbol
&& base.getCoreZ() + distance >= location.getBlockZ());
^
symbol: method getCoreZ()
location: variable base of type BaseData
ERROR in src/main/java/com/zempire/core/base/BaseManager.java at line 54: cannot find symbol
core.getY(), core.getY(), 1, "ACTIVE", System.currentTimeMillis());
^
symbol: method getY()
location: variable core of type ClaimBlock
ERROR in src/main/java/com/zempire/core/base/BaseManager.java at line 54: cannot find symbol
core.getY(), core.getY(), 1, "ACTIVE", System.currentTimeMillis());
^
symbol: method getY()
location: variable core of type ClaimBlock
ERROR in src/main/java/com/zempire/core/base/BaseManager.java at line 53: cannot find symbol
core.getWorld(), core.getX(), core.getY(), core.getZ(), radius, System.currentTimeMillis(),
^
symbol: method getZ()
location: variable core of type ClaimBlock
ERROR in src/main/java/com/zempire/core/base/BaseManager.java at line 53: cannot find symbol
core.getWorld(), core.getX(), core.getY(), core.getZ(), radius, System.currentTimeMillis(),
^
symbol: method getY()
location: variable core of type ClaimBlock
ERROR in src/main/java/com/zempire/core/base/BaseManager.java at line 53: cannot find symbol
core.getWorld(), core.getX(), core.getY(), core.getZ(), radius, System.currentTimeMillis(),
^
symbol: method getX()
location: variable core of type ClaimBlock
ERROR in src/main/java/com/zempire/core/base/BaseManager.java at line 53: cannot find symbol
core.getWorld(), core.getX(), core.getY(), core.getZ(), radius, System.currentTimeMillis(),
^
symbol: method getWorld()
location: variable core of type ClaimBlock
ERROR in src/main/java/com/zempire/core/base/BaseManager.java at line 55: cannot find symbol
bases.put(base.getId(), base);
^
symbol: method getId()
location: variable base of type BaseData
ERROR in src/main/java/com/zempire/core/base/BaseManager.java at line 56: cannot find symbol
core.setBaseId(base.getId());
^
symbol: method getId()
location: variable base of type BaseData
ERROR in src/main/java/com/zempire/core/base/BaseManager.java at line 61: cannot find symbol
if (claim.getBaseId() == null) {
^
symbol: method getBaseId()
location: variable claim of type ClaimBlock
ERROR in src/main/java/com/zempire/core/base/BaseManager.java at line 64: cannot find symbol
BaseData base = bases.get(claim.getBaseId());
^
symbol: method getBaseId()
location: variable claim of type ClaimBlock
ERROR in src/main/java/com/zempire/core/base/BaseManager.java at line 68: cannot find symbol
base.setBlockCount(Math.max(0, base.getBlockCount() + amount));
^
symbol: method getBlockCount()
location: variable base of type BaseData
ERROR in src/main/java/com/zempire/core/base/BaseManager.java at line 69: cannot find symbol
base.setLowestY(Math.min(base.getLowestY(), claim.getY()));
^
symbol: method getLowestY()
location: variable base of type BaseData
ERROR in src/main/java/com/zempire/core/base/BaseManager.java at line 69: cannot find symbol
base.setLowestY(Math.min(base.getLowestY(), claim.getY()));
^
symbol: method getY()
location: variable claim of type ClaimBlock
ERROR in src/main/java/com/zempire/core/base/BaseManager.java at line 70: cannot find symbol
base.setHighestY(Math.max(base.getHighestY(), claim.getY()));
^
symbol: method getHighestY()
location: variable base of type BaseData
ERROR in src/main/java/com/zempire/core/base/BaseManager.java at line 70: cannot find symbol
base.setHighestY(Math.max(base.getHighestY(), claim.getY()));
^
symbol: method getY()
location: variable claim of type ClaimBlock
ERROR in src/main/java/com/zempire/core/base/BaseManager.java at line 82: cannot find symbol
statement.setString(1, base.getId());
^
symbol: method getId()
location: variable base of type BaseData
ERROR in src/main/java/com/zempire/core/base/BaseManager.java at line 83: cannot find symbol
statement.setString(2, base.getOwnerUuid());
^
symbol: method getOwnerUuid()
location: variable base of type BaseData
ERROR in src/main/java/com/zempire/core/base/BaseManager.java at line 84: cannot find symbol
statement.setString(3, base.getOwnerType());
^
symbol: method getOwnerType()
location: variable base of type BaseData
ERROR in src/main/java/com/zempire/core/base/BaseManager.java at line 85: cannot find symbol
statement.setString(4, base.getCrewId());
^
symbol: method getCrewId()
location: variable base of type BaseData
ERROR in src/main/java/com/zempire/core/base/BaseManager.java at line 86: cannot find symbol
statement.setString(5, base.getWorld());
^
symbol: method getWorld()
location: variable base of type BaseData
ERROR in src/main/java/com/zempire/core/base/BaseManager.java at line 87: cannot find symbol
statement.setInt(6, base.getCoreX());
^
symbol: method getCoreX()
location: variable base of type BaseData
ERROR in src/main/java/com/zempire/core/base/BaseManager.java at line 88: cannot find symbol
statement.setInt(7, base.getCoreY());
^
symbol: method getCoreY()
location: variable base of type BaseData
ERROR in src/main/java/com/zempire/core/base/BaseManager.java at line 89: cannot find symbol
statement.setInt(8, base.getCoreZ());
^
symbol: method getCoreZ()
location: variable base of type BaseData
ERROR in src/main/java/com/zempire/core/base/BaseManager.java at line 90: cannot find symbol
statement.setInt(9, base.getRadius());
^
symbol: method getRadius()
location: variable base of type BaseData
ERROR in src/main/java/com/zempire/core/base/BaseManager.java at line 91: cannot find symbol
statement.setLong(10, base.getCreatedTime());
^
symbol: method getCreatedTime()
location: variable base of type BaseData
ERROR in src/main/java/com/zempire/core/base/BaseManager.java at line 92: cannot find symbol
statement.setInt(11, base.getLowestY());
^
symbol: method getLowestY()
location: variable base of type BaseData
ERROR in src/main/java/com/zempire/core/base/BaseManager.java at line 93: cannot find symbol
statement.setInt(12, base.getHighestY());
^
symbol: method getHighestY()
location: variable base of type BaseData
ERROR in src/main/java/com/zempire/core/base/BaseManager.java at line 94: cannot find symbol
statement.setInt(13, base.getBlockCount());
^
symbol: method getBlockCount()
location: variable base of type BaseData
ERROR in src/main/java/com/zempire/core/base/BaseManager.java at line 95: cannot find symbol
statement.setString(14, base.getDecayStatus());
^
symbol: method getDecayStatus()
location: variable base of type BaseData
ERROR in src/main/java/com/zempire/core/base/BaseManager.java at line 96: cannot find symbol
statement.setLong(15, base.getUpkeepUntil());
^
symbol: method getUpkeepUntil()
location: variable base of type BaseData
ERROR in src/main/java/com/zempire/core/crew/CrewManager.java at line 44: constructor Crew in class Crew cannot be applied to given types;
Crew crew = new Crew(id, name, name.substring(0, Math.min(4, name.length())).toUpperCase(),
^
ERROR in src/main/java/com/zempire/core/crew/CrewManager.java at line 47: cannot find symbol
crew.getMembers().put(player.getUniqueId(), "OWNER");
^
symbol: method getMembers()
location: variable crew of type Crew
ERROR in src/main/java/com/zempire/core/crew/CrewManager.java at line 60: cannot find symbol
crew.getMembers().remove(player.getUniqueId());
^
symbol: method getMembers()
location: variable crew of type Crew
ERROR in src/main/java/com/zempire/core/crew/CrewManager.java at line 62: cannot find symbol
if (crew.getMembers().isEmpty()) {
^
symbol: method getMembers()
location: variable crew of type Crew
ERROR in src/main/java/com/zempire/core/crew/CrewManager.java at line 63: cannot find symbol
crews.remove(crew.getId());
^
symbol: method getId()
location: variable crew of type Crew
ERROR in src/main/java/com/zempire/core/crew/CrewManager.java at line 64: cannot find symbol
} else if (crew.getOwner().equals(player.getUniqueId())) {
^
symbol: method getOwner()
location: variable crew of type Crew
ERROR in src/main/java/com/zempire/core/crew/CrewManager.java at line 65: cannot find symbol
UUID next = crew.getMembers().keySet().iterator().next();
^
symbol: method getMembers()
location: variable crew of type Crew
ERROR in src/main/java/com/zempire/core/crew/CrewManager.java at line 66: cannot find symbol
crew.setOwner(next);
^
symbol: method setOwner(UUID)
location: variable crew of type Crew
ERROR in src/main/java/com/zempire/core/crew/CrewManager.java at line 67: cannot find symbol
crew.getMembers().put(next, "OWNER");
^
symbol: method getMembers()
location: variable crew of type Crew
ERROR in src/main/java/com/zempire/core/crew/CrewManager.java at line 88: cannot find symbol
format = format.replace("%crew_tag%", crew.getTag()).replace("%player%", sender.getName()).replace("%message%", message);
^
symbol: method getTag()
location: variable crew of type Crew
ERROR in src/main/java/com/zempire/core/crew/CrewManager.java at line 89: cannot find symbol
crew.getMembers().keySet().stream().map(Bukkit::getPlayer).filter(player -> player != null)
^
symbol: method getMembers()
location: variable crew of type Crew
ERROR in src/main/java/com/zempire/core/crew/CrewManager.java at line 102: cannot find symbol
crewStatement.setString(1, crew.getId());
^
symbol: method getId()
location: variable crew of type Crew
ERROR in src/main/java/com/zempire/core/crew/CrewManager.java at line 103: cannot find symbol
crewStatement.setString(2, crew.getName());
^
symbol: method getName()
location: variable crew of type Crew
ERROR in src/main/java/com/zempire/core/crew/CrewManager.java at line 104: cannot find symbol
crewStatement.setString(3, crew.getTag());
^
symbol: method getTag()
location: variable crew of type Crew
ERROR in src/main/java/com/zempire/core/crew/CrewManager.java at line 105: cannot find symbol
crewStatement.setString(4, crew.getOwner().toString());
^
symbol: method getOwner()
location: variable crew of type Crew
ERROR in src/main/java/com/zempire/core/crew/CrewManager.java at line 106: cannot find symbol
crewStatement.setInt(5, crew.getLevel());
^
symbol: method getLevel()
location: variable crew of type Crew
ERROR in src/main/java/com/zempire/core/crew/CrewManager.java at line 107: cannot find symbol
crewStatement.setDouble(6, crew.getExp());
^
symbol: method getExp()
location: variable crew of type Crew
ERROR in src/main/java/com/zempire/core/crew/CrewManager.java at line 108: cannot find symbol
crewStatement.setInt(7, crew.getMaxMembers());
^
symbol: method getMaxMembers()
location: variable crew of type Crew
ERROR in src/main/java/com/zempire/core/crew/CrewManager.java at line 109: cannot find symbol
crewStatement.setString(8, crew.getBaseId());
^
symbol: method getBaseId()
location: variable crew of type Crew
ERROR in src/main/java/com/zempire/core/crew/CrewManager.java at line 116: cannot find symbol
crewStatement.setBoolean(15, crew.isFriendlyFire());
^
symbol: method isFriendlyFire()
location: variable crew of type Crew
ERROR in src/main/java/com/zempire/core/crew/CrewManager.java at line 117: cannot find symbol
crewStatement.setBoolean(16, crew.isOpenJoin());
^
symbol: method isOpenJoin()
location: variable crew of type Crew
ERROR in src/main/java/com/zempire/core/crew/CrewManager.java at line 118: cannot find symbol
crewStatement.setString(17, crew.getDescription());
^
symbol: method getDescription()
location: variable crew of type Crew
ERROR in src/main/java/com/zempire/core/crew/CrewManager.java at line 121: cannot find symbol
memberStatement.setString(1, crew.getId());
^
symbol: method getId()
location: variable crew of type Crew
ERROR in src/main/java/com/zempire/core/build/BuildTask.java at line 53: cannot find symbol
claim.setBaseId(bases.find(location).getId());
^
symbol: method getId()
location: class BaseData
ERROR in src/main/java/com/zempire/core/hooks/PlaceholderManager.java at line 41: cannot find symbol
Crew crew = plugin.getCrewManager().get(player.getUniqueId());
^
symbol: method getCrewManager()
location: variable plugin of type ZEmpireCorePlugin
ERROR in src/main/java/com/zempire/core/hooks/PlaceholderManager.java at line 42: cannot find symbol
SurvivalStats stats = plugin.getSurvivalManager().get(player.getUniqueId());
^
symbol: method getSurvivalManager()
location: variable plugin of type ZEmpireCorePlugin
=== COMPILATION ERROR ANALYSIS ===
MISSING CLASSES:
- XParticle
ACTION: Create these classes or check imports
MISSING METHODS:
- getOwnerUuid()
- getOrDefault(int,String)
- getWorld()
- getX()
- getY()
- getZ()
- getOwnerType()
- getCrewId()
- getBaseId()
- getMaterialType()
- getStructureType()
- getCurrentHp()
- getMaxHp()
- getPlacedTime()
- isOutsideBlock()
- getCoreX()
- getRadius()
- getCoreZ()
- getId()
- getBlockCount()
- getLowestY()
- getHighestY()
- getCoreY()
- getCreatedTime()
- getDecayStatus()
- getUpkeepUntil()
- getMembers()
- getOwner()
- setOwner(UUID)
- getTag()
- getName()
- getLevel()
- getExp()
- getMaxMembers()
- isFriendlyFire()
- isOpenJoin()
- getDescription()
- getCrewManager()
- getSurvivalManager()
ACTION: Check method names and signatures
FILES TO INVESTIGATE:
- src/main/java/com/zempire/core/ZEmpireCorePlugin.java
- src/main/java/com/zempire/core/build/BuildPreviewTask.java
- src/main/java/com/zempire/core/build/BuildManager.java
- src/main/java/com/zempire/core/claim/ClaimBlockManager.java
- src/main/java/com/zempire/core/base/BaseManager.java
- src/main/java/com/zempire/core/crew/CrewManager.java
- src/main/java/com/zempire/core/build/BuildTask.java
- src/main/java/com/zempire/core/hooks/PlaceholderManager.java
Please fix this error by creating a new artifact with the corrected code.
Correct the main plugin artifact name and manager accessors.
Restore model constructors/getters/setters used by base, claim, and crew managers.
Fix the XSeries particle import and invalid list access.
Compile-check the corrected project and resolve any remaining errors.
The duplicate plugin source with zero-width characters is the primary artifact failure; I’m removing it so the correctly named plugin class is the only main entry point.
Remove the malformed duplicate plugin source.
Make the model APIs explicit while retaining Lombok annotations, so getters, setters, and constructors are available even when annotation processing is unavailable.
Keep the particle and structure-cycle fixes already applied, then run the project compiler.
The source models were relying on Lombok-generated APIs, while the failed build reports those APIs as absent. I’m making the model constructors/accessors explicit and deleting the malformed duplicate entry-point source.
The corrected artifact now has explicit model APIs and the XSeries particle package fix.Applied the compilation fixes:
Removed the malformed duplicate plugin source with zero-width characters.
Added explicit constructors, getters, and setters to:
BaseDataClaimBlockCrew
Corrected the XSeries import to
com.cryptomorin.xseries.particles.XParticle.Fixed invalid
List.getOrDefault(...)usage inBuildManager.Preserved the correct
ZEmpireCorePluginentry point and manager accessors.
The local environment does not have Gradle installed, so compilation could not be executed here.
package com.zempire.core.build;
import com.cryptomorin.xseries.XMaterial;
import com.zempire.core.ConfigManager;
import com.zempire.core.MessageManager;
import com.zempire.core.base.BaseManager;
import com.zempire.core.claim.ClaimBlockManager;
import com.zempire.core.crew.CrewManager;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.NamespacedKey;
import org.bukkit.plugin.java.JavaPlugin;
public final class BuildManager {
private final JavaPlugin plugin;
private final ConfigManager config;
private final MessageManager messages;
private final ClaimBlockManager claims;
private final BaseManager bases;
private final CrewManager crews;
private final NamespacedKey toolKey;
private final Map<UUID, Integer> modes = new ConcurrentHashMap<>();
private final Map<UUID, String> structures = new ConcurrentHashMap<>();
public BuildManager(JavaPlugin plugin, ConfigManager config, MessageManager messages, ClaimBlockManager claims,
BaseManager bases, CrewManager crews) {
this.plugin = plugin;
this.config = config;
this.messages = messages;
this.claims = claims;
this.bases = bases;
this.crews = crews;
toolKey = new NamespacedKey(plugin, "build_tool");
new BuildPreviewTask(plugin, this);
}
public ItemStack createTool() {
var file = config.get("build/build.yml");
ItemStack item = XMaterial.matchXMaterial(file.getString("build.tool.material", "IRON_AXE"))
.map(XMaterial::parseItem).orElse(null);
if (item == null) {
return null;
}
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(file.getString("build.tool.name", "&aBuild Tool"));
meta.setCustomModelData(file.getInt("build.tool.custom-model-data", 900001));
meta.getPersistentDataContainer().set(toolKey, PersistentDataType.BYTE, (byte) 1);
item.setItemMeta(meta);
return item;
}
public boolean isTool(ItemStack item) {
return item != null && item.hasItemMeta()
&& item.getItemMeta().getPersistentDataContainer().has(toolKey, PersistentDataType.BYTE);
}
public void swap(Player player, org.bukkit.event.player.PlayerSwapHandItemsEvent event) {
if (!isTool(player.getInventory().getItemInMainHand())) {
return;
}
event.setCancelled(true);
int next = (mode(player) + 1) % config.get("build/build.yml").getStringList("build.modes").size();
modes.put(player.getUniqueId(), next);
messages.send(player, "build-mode", "%mode%", modeName(player));
}
public void interact(PlayerInteractEvent event) {
Player player = event.getPlayer();
if (!isTool(event.getItem())) {
return;
}
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
if (player.isSneaking()) {
cycleStructure(player);
}
return;
}
if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.RIGHT_CLICK_AIR) {
return;
}
event.setCancelled(true);
if (player.isSneaking()) {
rotate(player);
return;
}
place(player, event.getClickedBlock(), event.getBlockFace());
}
private void place(Player player, org.bukkit.block.Block clicked, BlockFace face) {
Location origin = clicked == null ? player.getLocation().add(player.getLocation().getDirection().normalize().multiply(2))
: clicked.getLocation().add(face.getModX(), face.getModY(), face.getModZ());
String materialName = config.get("build/build.yml").getString("build.default-material", "WOOD");
String structure = structures.getOrDefault(player.getUniqueId(),
config.get("build/build.yml").getString("build.default-structure", "FOUNDATION"));
var materialSection = config.get("build/materials.yml").getConfigurationSection("materials." + materialName);
if (materialSection == null) {
return;
}
XMaterial material = XMaterial.matchXMaterial(materialSection.getString("block-material", "OAK_PLANKS")).orElse(null);
if (material == null || !valid(origin, player)) {
messages.send(player, "invalid-placement");
return;
}
List<Location> locations = positions(origin, player);
for (Location location : locations) {
if (!valid(location, player)) {
messages.send(player, "invalid-placement");
return;
}
}
double hp = materialSection.getDouble("max-hp", 500);
long delay = Math.max(1, Math.round(config.get("build/build_time.yml").getDouble(
"build-time.mode-time." + modeName(player), 0.3) * 20 / Math.max(1, locations.size())));
new BuildTask(player, locations, material, structure, hp, claims, bases).runTaskTimer(plugin, 0, delay);
messages.send(player, "build-started");
}
private List<Location> positions(Location origin, Player player) {
int size = Integer.parseInt(modeName(player).split("x")[0]);
List<Location> locations = new ArrayList<>();
int start = -(size / 2);
for (int x = start; x <= size / 2; x++) {
for (int z = start; z <= size / 2; z++) {
locations.add(origin.clone().add(x, 0, z));
}
}
return locations;
}
private boolean valid(Location location, Player player) {
if (!location.getWorld().getBlockAt(location).isEmpty()) {
return false;
}
if (claims.get(location) != null) {
return false;
}
var base = bases.find(location);
return base == null || crews.hasPermission(player.getUniqueId(), "build") || base.getOwnerUuid().equals(player.getUniqueId().toString());
}
private void cycleStructure(Player player) {
List<String> structures = config.get("build/structures.yml").getStringList("structures");
if (structures.isEmpty()) {
return;
}
String current = this.structures.getOrDefault(player.getUniqueId(), structures.get(0));
int index = structures.indexOf(current);
if (index < 0) {
index = 0;
}
int nextIndex = (index + 1) % structures.size();
this.structures.put(player.getUniqueId(), structures.get(nextIndex));
messages.send(player, "build-structure", "%structure%", structures.get(nextIndex)); }
private void rotate(Player player) {
messages.send(player, "build-rotated");
}
public Location previewLocation(Player player) {
if (player.getTargetBlockExact(8) == null) {
return player.getLocation().add(player.getLocation().getDirection().normalize().multiply(2));
}
return player.getTargetBlockExact(8).getLocation().add(0, 1, 0);
}
public boolean isValidPreview(Player player) {
Location location = previewLocation(player);
return location != null && valid(location, player);
}
public int mode(Player player) {
return modes.getOrDefault(player.getUniqueId(), 0);
}
public String modeName(Player player) {
List<String> modes = config.get("build/build.yml").getStringList("build.modes");
return modes.isEmpty() ? "1x1" : modes.get(Math.min(mode(player), modes.size() - 1));
}
}