added combatlog
This commit is contained in:
@@ -2,6 +2,7 @@ package com.bitnix.dirtpvp;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -19,7 +20,9 @@ import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerToggleFlightEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
@@ -39,6 +42,7 @@ public final class DirtPVPPlugin extends JavaPlugin implements Listener, TabExec
|
||||
private final Map<UUID, BukkitTask> expiryTasks = new HashMap<>();
|
||||
private final Map<UUID, Boolean> previousAllowFlight = new HashMap<>();
|
||||
private final Set<UUID> notifyToggledOff = new HashSet<>();
|
||||
private final Set<UUID> combatLogged = new HashSet<>();
|
||||
private final List<KillRewardRule> killRewardRules = new ArrayList<>();
|
||||
|
||||
private long combatDurationTicks;
|
||||
@@ -66,6 +70,12 @@ public final class DirtPVPPlugin extends JavaPlugin implements Listener, TabExec
|
||||
|
||||
private boolean killRewardsEnabled;
|
||||
|
||||
private boolean combatLogEnabled;
|
||||
private boolean combatLogDropInventoryOnLogout;
|
||||
private boolean combatLogClearInventoryOnLogout;
|
||||
private boolean combatLogKillPlayerOnLogout;
|
||||
private boolean combatLogLightningEffect;
|
||||
|
||||
private boolean notificationsEnabled;
|
||||
private boolean notifyConsole;
|
||||
private boolean requireNotifyPermission;
|
||||
@@ -75,6 +85,7 @@ public final class DirtPVPPlugin extends JavaPlugin implements Listener, TabExec
|
||||
private boolean notifyOnFlightBlock;
|
||||
private boolean notifyOnKillReward;
|
||||
private boolean notifyOnKillRewardBlockedByIp;
|
||||
private boolean notifyOnCombatLog;
|
||||
|
||||
private String prefix;
|
||||
private String msgCombatStartDamaged;
|
||||
@@ -87,6 +98,8 @@ public final class DirtPVPPlugin extends JavaPlugin implements Listener, TabExec
|
||||
private String msgNotifyFlightBlocked;
|
||||
private String msgNotifyKillReward;
|
||||
private String msgNotifyKillRewardBlockedByIp;
|
||||
private String msgCombatLogSelf;
|
||||
private String msgNotifyCombatLog;
|
||||
private String msgReloadSuccess;
|
||||
private String msgNoPermission;
|
||||
private String msgNotifyEnabled;
|
||||
@@ -123,6 +136,7 @@ public final class DirtPVPPlugin extends JavaPlugin implements Listener, TabExec
|
||||
combatUntil.clear();
|
||||
previousAllowFlight.clear();
|
||||
notifyToggledOff.clear();
|
||||
combatLogged.clear();
|
||||
killRewardRules.clear();
|
||||
}
|
||||
|
||||
@@ -142,8 +156,8 @@ public final class DirtPVPPlugin extends JavaPlugin implements Listener, TabExec
|
||||
this.disableFlightOnJoinIfTagged = config.getBoolean("flight.disable-on-join-if-tagged", true);
|
||||
this.restoreFlightAfterCombat = config.getBoolean("flight.restore-flight-after-combat", false);
|
||||
|
||||
this.opBypass = config.getBoolean("bypass.op-bypass", true);
|
||||
this.permissionBypass = config.getBoolean("bypass.permission-bypass", true);
|
||||
this.opBypass = config.getBoolean("bypass.op-bypass", false);
|
||||
this.permissionBypass = config.getBoolean("bypass.permission-bypass", false);
|
||||
this.bypassPermission = config.getString("bypass.permission", "dirtpvp.bypass");
|
||||
|
||||
this.anyDamage = config.getBoolean("tag-triggers.any-damage", true);
|
||||
@@ -194,6 +208,12 @@ public final class DirtPVPPlugin extends JavaPlugin implements Listener, TabExec
|
||||
}
|
||||
}
|
||||
|
||||
this.combatLogEnabled = config.getBoolean("combat-log.enabled", true);
|
||||
this.combatLogDropInventoryOnLogout = config.getBoolean("combat-log.drop-inventory-on-logout", true);
|
||||
this.combatLogClearInventoryOnLogout = config.getBoolean("combat-log.clear-inventory-on-logout", true);
|
||||
this.combatLogKillPlayerOnLogout = config.getBoolean("combat-log.kill-player-on-logout", false);
|
||||
this.combatLogLightningEffect = config.getBoolean("combat-log.lightning-effect", false);
|
||||
|
||||
this.notificationsEnabled = config.getBoolean("notifications.enabled", true);
|
||||
this.notifyConsole = config.getBoolean("notifications.notify-console", false);
|
||||
this.requireNotifyPermission = config.getBoolean("notifications.require-permission", true);
|
||||
@@ -203,6 +223,7 @@ public final class DirtPVPPlugin extends JavaPlugin implements Listener, TabExec
|
||||
this.notifyOnFlightBlock = config.getBoolean("notifications.send-on-flight-block", false);
|
||||
this.notifyOnKillReward = config.getBoolean("notifications.send-on-kill-reward", false);
|
||||
this.notifyOnKillRewardBlockedByIp = config.getBoolean("notifications.send-on-kill-reward-blocked-by-ip", false);
|
||||
this.notifyOnCombatLog = config.getBoolean("notifications.send-on-combat-log", true);
|
||||
|
||||
this.prefix = color(config.getString("messages.prefix", "&8[&6DirtPVP&8] &r"));
|
||||
this.msgCombatStartDamaged = color(config.getString("messages.combat-start-damaged", "&cFlight disabled: you were damaged and are now in combat for &e%time%&c seconds."));
|
||||
@@ -215,6 +236,8 @@ public final class DirtPVPPlugin extends JavaPlugin implements Listener, TabExec
|
||||
this.msgNotifyFlightBlocked = color(config.getString("messages.notify-flight-blocked", "&e%player% &7tried to fly while in combat."));
|
||||
this.msgNotifyKillReward = color(config.getString("messages.notify-kill-reward", "&eExecuted kill reward '&f%reward%&e' for &f%killer% &7after killing &f%victim%&7."));
|
||||
this.msgNotifyKillRewardBlockedByIp = color(config.getString("messages.notify-kill-reward-blocked-by-ip", "&cSkipped kill reward '&f%reward%&c' for &f%killer% &7because killer/victim IP matched."));
|
||||
this.msgCombatLogSelf = color(config.getString("messages.combat-log-self", "&cYou logged out during combat and lost your inventory."));
|
||||
this.msgNotifyCombatLog = color(config.getString("messages.notify-combat-log", "&c%player% logged out during combat and dropped their inventory."));
|
||||
this.msgReloadSuccess = color(config.getString("messages.reload-success", "&aDirtPVP config reloaded."));
|
||||
this.msgNoPermission = color(config.getString("messages.no-permission", "&cYou do not have permission."));
|
||||
this.msgNotifyEnabled = color(config.getString("messages.notify-enabled", "&aYou will now receive DirtPVP notifications."));
|
||||
@@ -360,6 +383,51 @@ public final class DirtPVPPlugin extends JavaPlugin implements Listener, TabExec
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onQuit(PlayerQuitEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!combatLogEnabled) {
|
||||
return;
|
||||
}
|
||||
if (!isWorldEnabled(player.getWorld())) {
|
||||
return;
|
||||
}
|
||||
if (shouldIgnore(player)) {
|
||||
return;
|
||||
}
|
||||
if (!isInCombat(player.getUniqueId())) {
|
||||
return;
|
||||
}
|
||||
|
||||
combatLogged.add(player.getUniqueId());
|
||||
|
||||
Location location = player.getLocation();
|
||||
|
||||
if (combatLogLightningEffect) {
|
||||
player.getWorld().strikeLightningEffect(location);
|
||||
}
|
||||
|
||||
if (combatLogDropInventoryOnLogout) {
|
||||
dropPlayerInventory(player, location);
|
||||
}
|
||||
|
||||
if (combatLogClearInventoryOnLogout) {
|
||||
clearPlayerInventory(player);
|
||||
}
|
||||
|
||||
if (combatLogKillPlayerOnLogout) {
|
||||
player.setHealth(0.0);
|
||||
}
|
||||
|
||||
if (notifyOnCombatLog) {
|
||||
notifyStaff(msgNotifyCombatLog.replace("%player%", player.getName()));
|
||||
}
|
||||
|
||||
player.sendMessage(withPrefix(msgCombatLogSelf));
|
||||
clearCombatState(player.getUniqueId());
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onFlightToggle(PlayerToggleFlightEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
@@ -387,6 +455,10 @@ public final class DirtPVPPlugin extends JavaPlugin implements Listener, TabExec
|
||||
public void onJoin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (combatLogged.remove(player.getUniqueId())) {
|
||||
clearPlayerInventory(player);
|
||||
}
|
||||
|
||||
if (!disableFlightOnJoinIfTagged) {
|
||||
return;
|
||||
}
|
||||
@@ -494,6 +566,46 @@ public final class DirtPVPPlugin extends JavaPlugin implements Listener, TabExec
|
||||
}
|
||||
}
|
||||
|
||||
private void dropPlayerInventory(Player player, Location location) {
|
||||
ItemStack[] contents = player.getInventory().getContents();
|
||||
ItemStack[] armor = player.getInventory().getArmorContents();
|
||||
ItemStack offhand = player.getInventory().getItemInOffHand();
|
||||
|
||||
for (ItemStack item : contents) {
|
||||
if (item != null && !item.getType().isAir()) {
|
||||
player.getWorld().dropItemNaturally(location, item.clone());
|
||||
}
|
||||
}
|
||||
|
||||
for (ItemStack item : armor) {
|
||||
if (item != null && !item.getType().isAir()) {
|
||||
player.getWorld().dropItemNaturally(location, item.clone());
|
||||
}
|
||||
}
|
||||
|
||||
if (offhand != null && !offhand.getType().isAir()) {
|
||||
player.getWorld().dropItemNaturally(location, offhand.clone());
|
||||
}
|
||||
}
|
||||
|
||||
private void clearPlayerInventory(Player player) {
|
||||
player.getInventory().clear();
|
||||
player.getInventory().setArmorContents(null);
|
||||
player.getInventory().setItemInOffHand(null);
|
||||
player.updateInventory();
|
||||
}
|
||||
|
||||
private void clearCombatState(UUID uuid) {
|
||||
combatUntil.remove(uuid);
|
||||
|
||||
BukkitTask task = expiryTasks.remove(uuid);
|
||||
if (task != null) {
|
||||
task.cancel();
|
||||
}
|
||||
|
||||
previousAllowFlight.remove(uuid);
|
||||
}
|
||||
|
||||
private void disableFlightNow(Player player) {
|
||||
if (player.isFlying()) {
|
||||
player.setFlying(false);
|
||||
|
||||
@@ -8,8 +8,8 @@ flight:
|
||||
restore-flight-after-combat: false
|
||||
|
||||
bypass:
|
||||
op-bypass: true
|
||||
permission-bypass: true
|
||||
op-bypass: false
|
||||
permission-bypass: false
|
||||
permission: "dirtpvp.bypass"
|
||||
|
||||
tag-triggers:
|
||||
@@ -29,28 +29,43 @@ blocked-commands:
|
||||
- "spawn"
|
||||
- "home"
|
||||
- "rt"
|
||||
- "rtp"
|
||||
- "wild"
|
||||
- "tpa"
|
||||
- "tpahere"
|
||||
- "cmi spawn"
|
||||
- "cmi home"
|
||||
- "cmi rt"
|
||||
- "cmi rtp"
|
||||
- "cmi wild"
|
||||
- "cmi tpa"
|
||||
- "cmi tpahere"
|
||||
|
||||
kill-rewards:
|
||||
enabled: false
|
||||
enabled: true
|
||||
rewards:
|
||||
money:
|
||||
# money:
|
||||
# enabled: true
|
||||
# ip-check: true
|
||||
# commands:
|
||||
# - "eco give %killer% 1000"
|
||||
shards:
|
||||
enabled: true
|
||||
ip-check: true
|
||||
commands:
|
||||
- "eco give %killer% 1000"
|
||||
shards:
|
||||
enabled: false
|
||||
ip-check: true
|
||||
commands:
|
||||
- "shards give %killer% 5"
|
||||
broadcast:
|
||||
enabled: false
|
||||
ip-check: false
|
||||
commands:
|
||||
- "broadcast &e%killer% &7killed &e%victim%&7."
|
||||
- "shards give %killer% 10"
|
||||
# broadcast:
|
||||
# enabled: false
|
||||
# ip-check: false
|
||||
# commands:
|
||||
# - "broadcast &e%killer% &7killed &e%victim%&7."
|
||||
|
||||
combat-log:
|
||||
enabled: true
|
||||
drop-inventory-on-logout: true
|
||||
clear-inventory-on-logout: true
|
||||
kill-player-on-logout: false
|
||||
lightning-effect: false
|
||||
|
||||
notifications:
|
||||
enabled: true
|
||||
@@ -62,6 +77,7 @@ notifications:
|
||||
send-on-flight-block: false
|
||||
send-on-kill-reward: false
|
||||
send-on-kill-reward-blocked-by-ip: false
|
||||
send-on-combat-log: true
|
||||
|
||||
messages:
|
||||
prefix: "&8[&6DirtPVP&8] &r"
|
||||
@@ -75,9 +91,13 @@ messages:
|
||||
notify-command-blocked: "&e%player% &7tried to use &f/%command% &7while in combat."
|
||||
notify-combat-tagged: "&e%player% &7was combat tagged."
|
||||
notify-flight-blocked: "&e%player% &7tried to fly while in combat."
|
||||
|
||||
notify-kill-reward: "&eExecuted kill reward '&f%reward%&e' for &f%killer% &7after killing &f%victim%&7."
|
||||
notify-kill-reward-blocked-by-ip: "&cSkipped kill reward '&f%reward%&c' for &f%killer% &7because killer/victim IP matched."
|
||||
|
||||
combat-log-self: "&cYou logged out during combat and lost your inventory."
|
||||
notify-combat-log: "&c%player% logged out during combat and dropped their inventory."
|
||||
|
||||
reload-success: "&aDirtPVP config reloaded."
|
||||
no-permission: "&cYou do not have permission."
|
||||
notify-enabled: "&aYou will now receive DirtPVP notifications."
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
+35
-15
@@ -8,8 +8,8 @@ flight:
|
||||
restore-flight-after-combat: false
|
||||
|
||||
bypass:
|
||||
op-bypass: true
|
||||
permission-bypass: true
|
||||
op-bypass: false
|
||||
permission-bypass: false
|
||||
permission: "dirtpvp.bypass"
|
||||
|
||||
tag-triggers:
|
||||
@@ -29,28 +29,43 @@ blocked-commands:
|
||||
- "spawn"
|
||||
- "home"
|
||||
- "rt"
|
||||
- "rtp"
|
||||
- "wild"
|
||||
- "tpa"
|
||||
- "tpahere"
|
||||
- "cmi spawn"
|
||||
- "cmi home"
|
||||
- "cmi rt"
|
||||
- "cmi rtp"
|
||||
- "cmi wild"
|
||||
- "cmi tpa"
|
||||
- "cmi tpahere"
|
||||
|
||||
kill-rewards:
|
||||
enabled: false
|
||||
enabled: true
|
||||
rewards:
|
||||
money:
|
||||
# money:
|
||||
# enabled: true
|
||||
# ip-check: true
|
||||
# commands:
|
||||
# - "eco give %killer% 1000"
|
||||
shards:
|
||||
enabled: true
|
||||
ip-check: true
|
||||
commands:
|
||||
- "eco give %killer% 1000"
|
||||
shards:
|
||||
enabled: false
|
||||
ip-check: true
|
||||
commands:
|
||||
- "shards give %killer% 5"
|
||||
broadcast:
|
||||
enabled: false
|
||||
ip-check: false
|
||||
commands:
|
||||
- "broadcast &e%killer% &7killed &e%victim%&7."
|
||||
- "shards give %killer% 10"
|
||||
# broadcast:
|
||||
# enabled: false
|
||||
# ip-check: false
|
||||
# commands:
|
||||
# - "broadcast &e%killer% &7killed &e%victim%&7."
|
||||
|
||||
combat-log:
|
||||
enabled: true
|
||||
drop-inventory-on-logout: true
|
||||
clear-inventory-on-logout: true
|
||||
kill-player-on-logout: false
|
||||
lightning-effect: false
|
||||
|
||||
notifications:
|
||||
enabled: true
|
||||
@@ -62,6 +77,7 @@ notifications:
|
||||
send-on-flight-block: false
|
||||
send-on-kill-reward: false
|
||||
send-on-kill-reward-blocked-by-ip: false
|
||||
send-on-combat-log: true
|
||||
|
||||
messages:
|
||||
prefix: "&8[&6DirtPVP&8] &r"
|
||||
@@ -75,9 +91,13 @@ messages:
|
||||
notify-command-blocked: "&e%player% &7tried to use &f/%command% &7while in combat."
|
||||
notify-combat-tagged: "&e%player% &7was combat tagged."
|
||||
notify-flight-blocked: "&e%player% &7tried to fly while in combat."
|
||||
|
||||
notify-kill-reward: "&eExecuted kill reward '&f%reward%&e' for &f%killer% &7after killing &f%victim%&7."
|
||||
notify-kill-reward-blocked-by-ip: "&cSkipped kill reward '&f%reward%&c' for &f%killer% &7because killer/victim IP matched."
|
||||
|
||||
combat-log-self: "&cYou logged out during combat and lost your inventory."
|
||||
notify-combat-log: "&c%player% logged out during combat and dropped their inventory."
|
||||
|
||||
reload-success: "&aDirtPVP config reloaded."
|
||||
no-permission: "&cYou do not have permission."
|
||||
notify-enabled: "&aYou will now receive DirtPVP notifications."
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#Generated by Maven
|
||||
#Sun Jun 14 18:05:11 EDT 2026
|
||||
#Sat Jun 20 12:16:51 EDT 2026
|
||||
artifactId=DirtPVP
|
||||
groupId=com.bitnix
|
||||
version=1.0
|
||||
|
||||
Reference in New Issue
Block a user