fix Claim and Damage

This commit is contained in:
EmrageGHC 2025-02-23 15:43:47 +01:00
parent 090304ac8e
commit 19165efd15
3 changed files with 91 additions and 69 deletions

View file

@ -2,6 +2,7 @@ package me.freezy.plugins.papermc.blazesmp;
import lombok.Getter;
import me.freezy.plugins.papermc.blazesmp.command.*;
import me.freezy.plugins.papermc.blazesmp.command.util.SimpleCommand;
import me.freezy.plugins.papermc.blazesmp.listener.*;
import me.freezy.plugins.papermc.blazesmp.module.manager.Clans;
import me.freezy.plugins.papermc.blazesmp.module.manager.Homes;
@ -29,80 +30,86 @@ public final class BlazeSMP extends JavaPlugin {
private boolean isEndOpen;
@Override
public void onLoad() {
this.log = getSLF4JLogger();
public void onLoad() {
this.log = getSLF4JLogger();
this.log.info("Loading BlazeSMP...");
this.log.info("Loading BlazeSMP...");
this.log.info("Loading ProtectedBlocks...");
this.protectedBlocks = new ProtectedBlocks();
this.protectedBlocks.load();
this.log.info("Loaded ProtectedBlocks!");
this.log.info("Loading ProtectedBlocks...");
this.protectedBlocks = new ProtectedBlocks();
this.protectedBlocks.load();
this.log.info("Loaded ProtectedBlocks!");
this.log.info("Loading config...");
saveDefaultConfig();
this.configuration = getConfig();
saveConfig();
this.log.info("Loaded config!");
this.log.info("Loading config...");
saveDefaultConfig();
this.configuration = getConfig();
saveConfig();
this.log.info("Loaded config!");
this.log.info("Loading L4M4...");
L4M4.init();
this.log.info("Loaded L4M4!");
this.log.info("Loading L4M4...");
L4M4.init();
this.log.info("Loaded L4M4!");
this.log.info("Loaded BlazeSMP!");
}
this.log.info("Loaded BlazeSMP!");
}
@Override
public void onEnable() {
BlazeSMP.instance = this;
isEndOpen = getConfig().getBoolean("isEndOpen", false);
@Override
public void onEnable() {
BlazeSMP.instance = this;
isEndOpen = getConfig().getBoolean("isEndOpen", false);
this.log.info("Enabling BlazeSMP...");
this.log.info("Enabling BlazeSMP...");
this.getServer().getScheduler().runTaskLater(this, () -> {
this.log.info("Loading Clans...");
this.clans = new Clans();
this.clans.loadAllClans();
this.log.info("Loaded Clans!");
this.log.info("Loading Homes...");
this.homes = new Homes();
this.homes.load();
this.log.info("Loaded Homes!");
}, 20L);
this.log.info("Registering Commands...");
new ClanCommand().register();
new ReportCommand().register();
new ClaimCommand().register();
new HomeCommand().register();
new DiscordCommand().register();
new ReloadCommand().register();
new VanishCommand().register();
new EventCommand(this).register();
this.log.info("Registered Commands!");
this.getServer().getScheduler().runTaskLater(this, () -> {
this.log.info("Loading Homes...");
this.homes = new Homes();
this.homes.load();
this.log.info("Loaded Homes!");
}, 20L);
this.log.info("Registering EventListeners...");
PluginManager pm = getServer().getPluginManager();
pm.registerEvents(new PlayerJoinListener(), this);
pm.registerEvents(new PlayerChatListener(), this);
pm.registerEvents(new PlayerCommandBlockerListener(), this);
pm.registerEvents(new PlayerClaimListener(), this);
pm.registerEvents(new ChunkInventoryListener(), this);
pm.registerEvents(new PressurePlateListener(), this);
pm.registerEvents(new PlayerVsPlayerListener(clans), this);
pm.registerEvents(new EndPortalListener(this), this);
pm.registerEvents(new PvPListener(), this);
//pm.registerEvents(new ProtectedBlockListener(), this);
this.log.info("Registered EventListeners!");
this.getServer().getScheduler().runTaskLater(this, () -> {
this.log.info("Loading Clans...");
this.clans = new Clans();
this.clans.loadAllClans();
this.log.info("Loaded Clans!");
}, 40L);
this.log.info("Starting Timer tasks...");
this.nameUpdateTask = new PlayerNameUpdate().runTaskTimer(this, 0L, 20L);
this.tabListUpdateTask = new TabListTimer().runTaskTimer(this, 0L, 20L);
this.log.info("Started Timer tasks!");
this.log.info("Registering Commands...");
new ClanCommand().register();
new ReportCommand().register();
new ClaimCommand().register();
new HomeCommand().register();
new DiscordCommand().register();
new ReloadCommand().register();
new VanishCommand().register();
new EventCommand(this).register();
new RestartCommand().register();
this.log.info("Registered Commands!");
this.log.info("Enabled BlazeSMP!");
}
this.log.info("Registering EventListeners...");
PluginManager pm = getServer().getPluginManager();
pm.registerEvents(new PlayerJoinListener(), this);
pm.registerEvents(new PlayerChatListener(), this);
pm.registerEvents(new PlayerCommandBlockerListener(), this);
pm.registerEvents(new PlayerClaimListener(), this);
pm.registerEvents(new ChunkInventoryListener(), this);
pm.registerEvents(new PressurePlateListener(), this);
pm.registerEvents(new PlayerVsPlayerListener(clans), this);
pm.registerEvents(new EndPortalListener(this), this);
pm.registerEvents(new PvPListener(), this);
pm.registerEvents(new PlayerQuitListener(), this);
//pm.registerEvents(new ProtectedBlockListener(), this);
this.log.info("Registered EventListeners!");
this.log.info("Starting Timer tasks...");
this.nameUpdateTask = new PlayerNameUpdate().runTaskTimer(this, 0L, 20L);
this.tabListUpdateTask = new TabListTimer().runTaskTimer(this, 0L, 20L);
this.log.info("Started Timer tasks!");
this.log.info("Enabled BlazeSMP!");
}
@Override
public void onDisable() {

View file

@ -14,7 +14,10 @@ import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.*;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.UUID;
public class ClaimCommand extends SimpleCommand {
@ -50,14 +53,18 @@ public class ClaimCommand extends SimpleCommand {
int MAX_CLAIMS = 50;
if (playerClaims.size() >= MAX_CLAIMS) {
player.sendMessage(MiniMessage.miniMessage().deserialize(L4M4.get("error.max_claims_reached")));
System.out.println("Claim denied: max claims reached");
} else {
Chunk playerChunk = player.getLocation().getChunk();
if (clans.isChunkClaimed(playerChunk)) {
player.sendMessage(MiniMessage.miniMessage().deserialize(L4M4.get("error.chunk_already_claimed")));
System.out.println("Claim denied: chunk already claimed");
} else {
// claim too close to spawn 8 chunks
if (player.getX() < 152.0 && player.getZ() < 152.0) {
// claim too close to spawn 152 blocks in all directions
if (Math.abs(player.getX()) < 152.0 && Math.abs(player.getZ()) < 152.0) {
player.sendMessage(MiniMessage.miniMessage().deserialize(L4M4.get("error.chunk_too_close_to_spawn")));
System.out.println("Claim denied: chunk too close to spawn");
return true;
}
playerClaims.add(playerChunk);
@ -66,6 +73,7 @@ public class ClaimCommand extends SimpleCommand {
clans.setClanChunks(playerClan, existingClaims);
playerClan.save();
clans.saveAllClans();
System.out.println("Chunk claimed successfully");
}
}
return true;
@ -82,8 +90,10 @@ public class ClaimCommand extends SimpleCommand {
clans.setClanChunks(playerClan, existingClaims);
playerClan.save();
clans.saveAllClans();
System.out.println("Chunk unclaimed successfully");
} else {
player.sendMessage(MiniMessage.miniMessage().deserialize(L4M4.get("error.chunk_not_owned")));
System.out.println("Unclaim denied: chunk not owned");
}
return true;
}
@ -99,4 +109,4 @@ public class ClaimCommand extends SimpleCommand {
}
return List.of();
}
}
}