diff --git a/pvpmanager/src/main/java/me/NoChance/PvPManager/Dependencies/GroupDependency.java b/pvpmanager/src/main/java/me/NoChance/PvPManager/Dependencies/GroupDependency.java
index 2dc0d1aa..b1395f6c 100644
--- a/pvpmanager/src/main/java/me/NoChance/PvPManager/Dependencies/GroupDependency.java
+++ b/pvpmanager/src/main/java/me/NoChance/PvPManager/Dependencies/GroupDependency.java
@@ -2,6 +2,8 @@
import org.bukkit.entity.Player;
+import me.NoChance.PvPManager.Dependencies.Interfaces.Dependency;
+
/**
* Represents a plugin that groups players in clans/factions/teams/etc.
* Allows checking if two players can attack each other or not.
diff --git a/pvpmanager/src/main/java/me/NoChance/PvPManager/Dependencies/Hooks/LibsDisguisesHook.java b/pvpmanager/src/main/java/me/NoChance/PvPManager/Dependencies/Hooks/LibsDisguisesHook.java
index 3d1e14ea..4c982bee 100644
--- a/pvpmanager/src/main/java/me/NoChance/PvPManager/Dependencies/Hooks/LibsDisguisesHook.java
+++ b/pvpmanager/src/main/java/me/NoChance/PvPManager/Dependencies/Hooks/LibsDisguisesHook.java
@@ -4,7 +4,6 @@
import me.NoChance.PvPManager.Dependencies.BaseDependency;
import me.NoChance.PvPManager.Dependencies.Hook;
-import me.chancesd.sdutils.utils.Log;
import me.NoChance.PvPManager.Dependencies.Interfaces.DisguiseDependency;
import me.libraryaddict.disguise.DisguiseAPI;
@@ -12,7 +11,6 @@ public class LibsDisguisesHook extends BaseDependency implements DisguiseDepende
public LibsDisguisesHook(final Hook hook) {
super(hook);
- Log.debug(DisguiseAPI.getSelfDisguiseId() + ""); // throw exception if not found
}
@Override
diff --git a/pvpmanager/src/main/java/me/NoChance/PvPManager/Dependencies/Hooks/SimpleClansHook.java b/pvpmanager/src/main/java/me/NoChance/PvPManager/Dependencies/Hooks/SimpleClansHook.java
index a8139818..86d87dfd 100644
--- a/pvpmanager/src/main/java/me/NoChance/PvPManager/Dependencies/Hooks/SimpleClansHook.java
+++ b/pvpmanager/src/main/java/me/NoChance/PvPManager/Dependencies/Hooks/SimpleClansHook.java
@@ -6,10 +6,7 @@
import me.NoChance.PvPManager.Dependencies.DependencyException;
import me.NoChance.PvPManager.Dependencies.Hook;
import me.NoChance.PvPManager.Dependencies.GroupDependency;
-import me.NoChance.PvPManager.Player.CancelResult;
import me.NoChance.PvPManager.Dependencies.ForceToggleDependency;
-import me.NoChance.PvPManager.Dependencies.Hook;
-import me.NoChance.PvPManager.Dependencies.Interfaces.PvPDependency;
import me.NoChance.PvPManager.Player.ProtectionType;
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
diff --git a/pvpmanager/src/main/java/me/NoChance/PvPManager/Dependencies/Interfaces/WorldGuardDependency.java b/pvpmanager/src/main/java/me/NoChance/PvPManager/Dependencies/Interfaces/WorldGuardDependency.java
index 7b708d4b..3e253b3d 100644
--- a/pvpmanager/src/main/java/me/NoChance/PvPManager/Dependencies/Interfaces/WorldGuardDependency.java
+++ b/pvpmanager/src/main/java/me/NoChance/PvPManager/Dependencies/Interfaces/WorldGuardDependency.java
@@ -8,6 +8,7 @@
import com.sk89q.worldguard.protection.flags.StateFlag.State;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
+import me.NoChance.PvPManager.Dependencies.GroupDependency;
import me.NoChance.PvPManager.Managers.PlayerHandler;
public interface WorldGuardDependency extends GroupDependency, RegionDependency {
diff --git a/pvpmanager/src/main/java/me/NoChance/PvPManager/Listeners/EntityListener.java b/pvpmanager/src/main/java/me/NoChance/PvPManager/Listeners/EntityListener.java
index fd4f48d4..a38d4e06 100644
--- a/pvpmanager/src/main/java/me/NoChance/PvPManager/Listeners/EntityListener.java
+++ b/pvpmanager/src/main/java/me/NoChance/PvPManager/Listeners/EntityListener.java
@@ -43,7 +43,6 @@
import me.NoChance.PvPManager.Settings.Settings;
import me.NoChance.PvPManager.Utils.CombatUtils;
import me.chancesd.pvpmanager.setting.Permissions;
-import me.NoChance.PvPManager.Utils.MCVersion;
import me.chancesd.sdutils.utils.MCVersion;
public class EntityListener implements Listener {
diff --git a/pvpmanager/src/main/java/me/NoChance/PvPManager/Listeners/PlayerListener.java b/pvpmanager/src/main/java/me/NoChance/PvPManager/Listeners/PlayerListener.java
index 13fa27fa..06c1a700 100644
--- a/pvpmanager/src/main/java/me/NoChance/PvPManager/Listeners/PlayerListener.java
+++ b/pvpmanager/src/main/java/me/NoChance/PvPManager/Listeners/PlayerListener.java
@@ -150,7 +150,7 @@ public final void onPlayerDeath(final PlayerDeathEvent event) {
// Player died in combat, process that
if (killer != null && !killer.equals(player)) {
final PvPlayer pKiller = playerHandler.get(killer);
- handlePvPDeath(player, pvPlayer, killer, pKiller);
+ handlePvPDeath(player, pvPlayer, killer, pKiller, event);
}
if (pvPlayer.isInCombat()) {
@@ -170,7 +170,7 @@ public final void onPlayerDeath(final PlayerDeathEvent event) {
playerHandler.handlePlayerDrops(event, player, killer);
}
- private void handlePvPDeath(final Player player, final PvPlayer pvPlayer, final Player killer, final PvPlayer pKiller) {
+ private void handlePvPDeath(final Player player, final PvPlayer pvPlayer, final Player killer, final PvPlayer pKiller, final PlayerDeathEvent event) {
if (Settings.isKillAbuseEnabled() && !pKiller.hasPerm(Permissions.EXEMPT_KILL_ABUSE)) {
pKiller.addVictim(player);
}
@@ -181,6 +181,12 @@ private void handlePvPDeath(final Player player, final PvPlayer pvPlayer, final
if (Settings.getMoneyPenalty() > 0) {
pvPlayer.applyPenalty();
}
+ if (Settings.getExpSteal() > 0) {
+ final int expWon = pKiller.giveExp(pvPlayer);
+ event.setDroppedExp(0);
+ event.setNewExp(player.getTotalExperience() - expWon);
+ pvPlayer.message(Messages.getExpStolen(pKiller.getName(), String.valueOf(expWon)));
+ }
CombatUtils.executeCommands(Settings.getCommandsOnKill(), killer, killer.getName(), player.getName());
}
}
diff --git a/pvpmanager/src/main/java/me/NoChance/PvPManager/Player/EcoPlayer.java b/pvpmanager/src/main/java/me/NoChance/PvPManager/Player/EcoPlayer.java
index 581572a9..5bcd6af5 100644
--- a/pvpmanager/src/main/java/me/NoChance/PvPManager/Player/EcoPlayer.java
+++ b/pvpmanager/src/main/java/me/NoChance/PvPManager/Player/EcoPlayer.java
@@ -27,7 +27,8 @@ private boolean withdrawMoney(final double amount) {
private void depositMoney(final double amount) {
final EconomyResponse response = economy.depositPlayer(getPlayer(), amount);
- Log.debug("Deposit money to " + getName() + " - Response: " + response.type + " " + response.amount + " " + response.balance + " " + response.errorMessage);
+ Log.debug("Deposit money to " + getName() + " - Response: " + response.type + " " + response.amount + " " + response.balance + " "
+ + response.errorMessage);
}
public final void applyFine() {
@@ -62,6 +63,25 @@ public final void giveReward(final EcoPlayer victim) {
message(Messages.getMoneyReward(victim.getPlayer().getName(), CombatUtils.formatTo2Digits(moneyWon)));
}
+ public final int giveExp(final EcoPlayer victim) {
+ int expWon = 0;
+ final int exp = victim.getPlayer().getTotalExperience();
+ if (Settings.getExpSteal() <= 1) {
+ expWon = (int) (Settings.getExpSteal() * exp);
+ } else {
+ expWon = exp;
+ }
+ setExp(getPlayer().getTotalExperience() + expWon);
+ message(Messages.getExpWon(victim.getPlayer().getName(), String.valueOf(expWon)));
+ return expWon;
+ }
+
+ public final void setExp(final int exp) {
+ getPlayer().setExp(0);
+ getPlayer().setLevel(0);
+ getPlayer().giveExp(exp);
+ }
+
private double getMoneyPercentage(final double percentage) {
if (percentage > 1)
return percentage;
diff --git a/pvpmanager/src/main/java/me/NoChance/PvPManager/Settings/Messages.java b/pvpmanager/src/main/java/me/NoChance/PvPManager/Settings/Messages.java
index 1634b04f..99e40126 100644
--- a/pvpmanager/src/main/java/me/NoChance/PvPManager/Settings/Messages.java
+++ b/pvpmanager/src/main/java/me/NoChance/PvPManager/Settings/Messages.java
@@ -67,6 +67,8 @@ public class Messages {
private static String moneyReward;
private static String moneyPenalty;
private static String moneySteal;
+ private static String expWon;
+ private static String expStolen;
private static Locale locale;
private static String tagTimeLeft;
private static String tagNotInCombat;
@@ -212,6 +214,8 @@ private static void getMessages() {
moneyReward = getString("Money_Reward");
moneyPenalty = getString("Money_Penalty");
moneySteal = getString("Money_Steal");
+ expWon = getString("Exp_Won");
+ expStolen = getString("Exp_Stolen");
pvpListTitle = getString("PvPList_Title");
pvpListEnabled = getString("PvPList_Enabled");
pvpListDisabled = getString("PvPList_Disabled");
@@ -327,6 +331,10 @@ public static String replaceMoney(final String message, final String money) {
return message.replace("%money%", money);
}
+ public static String replaceExp(final String message, final String exp) {
+ return message.replace("%exp%", exp);
+ }
+
public static String getPrefix() {
return prefix;
}
@@ -481,6 +489,14 @@ public static String getMoneySteal(final String name, final String money) {
return replaceMoney(replacePlayer(moneySteal, name), money);
}
+ public static String getExpStolen(final String name, final String exp) {
+ return replaceExp(replacePlayer(expStolen, name), exp);
+ }
+
+ public static String getExpWon(final String name, final String exp) {
+ return replaceExp(replacePlayer(expWon, name), exp);
+ }
+
public static Locale getLocale() {
return locale;
}
diff --git a/pvpmanager/src/main/java/me/NoChance/PvPManager/Settings/Settings.java b/pvpmanager/src/main/java/me/NoChance/PvPManager/Settings/Settings.java
index f6914a89..b1404c5d 100644
--- a/pvpmanager/src/main/java/me/NoChance/PvPManager/Settings/Settings.java
+++ b/pvpmanager/src/main/java/me/NoChance/PvPManager/Settings/Settings.java
@@ -74,6 +74,7 @@ public enum DropMode {
private static double moneyPenalty;
private static double moneyReward;
private static boolean moneySteal;
+ private static double expSteal;
private static String nameTagPrefix;
private static String nameTagSuffix;
private static boolean newbieGodMode;
@@ -171,7 +172,7 @@ public static void initizalizeVariables(final YamlConfiguration c) {
recyclePotionBottles = generalSection.getBoolean("Recycling.Potion Bottle", false);
recycleMilkBucket = generalSection.getBoolean("Recycling.Milk Bucket", false);
healthBelowName = generalSection.getBoolean("Show health under name.Enabled", true);
- healthBelowNameSymbol = generalSection.getString("Show health under name.Display Name", "❤");
+ healthBelowNameSymbol = ChatUtils.colorize(generalSection.getString("Show health under name.Display Name", "&c❤"));
worldsExcluded = new HashSet<>(getList(generalSection.getStringList("World Exclusions")));
borderHoppingVulnerable = borderHoppingSection.getBoolean("Vulnerable", true);
@@ -258,6 +259,7 @@ public static void initizalizeVariables(final YamlConfiguration c) {
setMoneyReward(playerKillsSection.getDouble("Money Reward", 10));
setMoneyPenalty(playerKillsSection.getDouble("Money Penalty", 10));
moneySteal = playerKillsSection.getBoolean("Money Steal", false);
+ expSteal = playerKillsSection.getDouble("Exp Steal", 0.0);
commandsOnKill = getCommandList(playerKillsSection.getStringList("Commands On Kill"));
playerKillsWGExclusions = new HashSet<>(getList(playerKillsSection.getStringList("WorldGuard Exclusions")));
@@ -558,6 +560,10 @@ public static boolean isMoneySteal() {
return moneySteal;
}
+ public static double getExpSteal() {
+ return expSteal;
+ }
+
public static boolean isUntagEnemy() {
return untagEnemy;
}
diff --git a/pvpmanager/src/main/java/me/NoChance/PvPManager/Utils/CombatUtils.java b/pvpmanager/src/main/java/me/NoChance/PvPManager/Utils/CombatUtils.java
index f93b4f09..0639b3a5 100644
--- a/pvpmanager/src/main/java/me/NoChance/PvPManager/Utils/CombatUtils.java
+++ b/pvpmanager/src/main/java/me/NoChance/PvPManager/Utils/CombatUtils.java
@@ -209,7 +209,7 @@ public static boolean isWorldExcluded(final String worldName) {
}
public static boolean hasHarmfulPotion(final AreaEffectCloud areaCloud) {
- if (isVersionAtLeast(Settings.getMinecraftVersion(), "1.20.2")) {
+ if (MCVersion.isAtLeast(MCVersion.V1_20_2)) {
final PotionType basePotionType = areaCloud.getBasePotionType();
if (basePotionType == null)
return false;
diff --git a/pvpmanager/src/main/java/me/chancesd/pvpmanager/player/nametag/BukkitNameTag.java b/pvpmanager/src/main/java/me/chancesd/pvpmanager/player/nametag/BukkitNameTag.java
index 495ac48a..ea394619 100644
--- a/pvpmanager/src/main/java/me/chancesd/pvpmanager/player/nametag/BukkitNameTag.java
+++ b/pvpmanager/src/main/java/me/chancesd/pvpmanager/player/nametag/BukkitNameTag.java
@@ -3,8 +3,10 @@
import java.util.UUID;
import org.bukkit.ChatColor;
+import org.bukkit.scoreboard.Criteria;
import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective;
+import org.bukkit.scoreboard.RenderType;
import org.bukkit.scoreboard.Scoreboard;
import org.bukkit.scoreboard.Team;
@@ -84,11 +86,15 @@ private void setup() {
// set pvp tag if player has pvp nametags on
setPvP(pvPlayer.hasPvPEnabled());
}
- if (Settings.isHealthBelowName() && health == null) {
+ if (Settings.isHealthBelowName() && (health == null || scoreboard.getObjective(HEALTHOBJ) == null)) {
if (scoreboard.getObjective(HEALTHOBJ) != null) {
health = scoreboard.getObjective(HEALTHOBJ);
+ } else if (MCVersion.isAtLeast(MCVersion.V1_19)) {
+ health = scoreboard.registerNewObjective(HEALTHOBJ, Criteria.HEALTH, Settings.getHealthBelowNameSymbol(), RenderType.HEARTS);
+ health.setDisplaySlot(DisplaySlot.BELOW_NAME);
} else {
- health = scoreboard.registerNewObjective(HEALTHOBJ, "health", Settings.getHealthBelowNameSymbol());
+ health = scoreboard.registerNewObjective(HEALTHOBJ, "health");
+ health.setDisplayName(Settings.getHealthBelowNameSymbol());
health.setDisplaySlot(DisplaySlot.BELOW_NAME);
}
}
diff --git a/pvpmanager/src/main/java/me/chancesd/pvpmanager/storage/Database.java b/pvpmanager/src/main/java/me/chancesd/pvpmanager/storage/Database.java
index 50722435..9553021b 100644
--- a/pvpmanager/src/main/java/me/chancesd/pvpmanager/storage/Database.java
+++ b/pvpmanager/src/main/java/me/chancesd/pvpmanager/storage/Database.java
@@ -44,7 +44,7 @@ protected Database(final DatabaseFactory databaseFactory, final DatabaseConfigBu
final HikariConfig config = new HikariConfig();
if (databaseType == DatabaseType.SQLITE) {
// Use SQLITE
- if (MCVersion.isLessThan(MCVersion.V1_9)) {
+ if (MCVersion.isLowerThan(MCVersion.V1_9)) {
try {
Class.forName("org.sqlite.JDBC"); // got to do this for 1.8 sigh
config.setConnectionTestQuery("SELECT 1;");
diff --git a/pvpmanager/src/main/resources/config.yml b/pvpmanager/src/main/resources/config.yml
index fa29b605..a83478db 100644
--- a/pvpmanager/src/main/resources/config.yml
+++ b/pvpmanager/src/main/resources/config.yml
@@ -15,8 +15,6 @@
# mode 'TRANSFER' - (Same as 'DROP' but transfer items(not exp) directly to killer's inventory without drops)
# mode 'CLEAR' - (Clear all drops and exp on death, this deletes everything on death so make sure it is what you want)
# Ignore No Damage Hits -> Ignore hits from snowballs, eggs, fishing rod and others
-# Show health under name -> Show player health, uses scoreboards so might conflict with other plugins
-# World Exclusions -> List of worlds where PvPManager will have no effect
General:
# Changes messages language, options are - EN | BG | DE | ES | FI | FR | HR | IT | JA | KO | PL | pt_BR | RU | TR | zh_TW | ZH
Locale: EN
@@ -33,9 +31,11 @@ General:
Recycling:
Potion Bottle: false
Milk Bucket: false
+ # Show player health, uses scoreboards so might conflict with other plugins
Show health under name:
Enabled: true
- Display Name: '❤'
+ Display Name: '&c❤'
+ # List of worlds where PvPManager will have no effect
World Exclusions:
- 'example'
@@ -198,6 +198,8 @@ Player Kills:
Money Reward: 0.0
Money Penalty: 0.0
Money Steal: false
+ # Similar to how money steal works, get a percentage of XP from the player you killed, 1 for 100% (0 to disable)
+ Exp Steal: 0.0
# Commands to execute on kill ( is the killer, is the victim, - is the item material in hand)
Commands On Kill:
- 'examplecommand killed with
- '
diff --git a/pvpmanager/src/main/resources/locale/messages.properties b/pvpmanager/src/main/resources/locale/messages.properties
index 939d1622..c173f588 100644
--- a/pvpmanager/src/main/resources/locale/messages.properties
+++ b/pvpmanager/src/main/resources/locale/messages.properties
@@ -54,15 +54,17 @@ Respawn_Protection_Other = %prefix%&4 %player% has respawn protection!
World_Protection = %prefix% &4PvP is disabled in this world!
# AFK Protection
-AFK_Protection = &6[&8PvPManager&6]&4 This player can't be attacked while AFK
+AFK_Protection = %prefix% &4This player can't be attacked while AFK
# Global Protection
-Global_Protection = &6[&8PvPManager&6]&4 PvP combat is globally disabled
+Global_Protection = %prefix% &4PvP combat is globally disabled
# Player Kills
Money_Reward = &2You got %money% coins for killing player %player%!
Money_Penalty = &cYou lost %money% coins for getting killed!
Money_Steal = &c%player% stole %money% coins from you!
+Exp_Won = %prefix% &aYou got &e%exp% &aexperience for killing &c%player%&a!
+Exp_Stolen = %prefix% &c%player% &6stole &e%exp% &6experience from you!
# Kill Abuse
Kill_Abuse_Warning = %prefix% &cYou will be punished if you kill this player again! Please stop.
@@ -81,7 +83,7 @@ Error_Not_Newbie = %prefix% &cYou are not a newbie!
Error_PvP_Cooldown = %prefix% &cYou can't toggle PvP yet! Wait %time%.
Error_PvPToggle_NoPvP = %prefix% &cYou are blocked from having PvP enabled
Error_PvPToggle_ForcePvP = %prefix% &cYou are blocked from having PvP disabled
-PvPToggle_Admin_Changed = &6[&8PvPManager&6] &2PvP state for &6%p &2was changed to %state
+PvPToggle_Admin_Changed = %prefix% &2PvP state for &6%p &2was changed to %state
PvPToggle_Already_Disabled = %prefix% &4You already have PvP disabled!
PvPToggle_Already_Enabled = %prefix% &4You already have PvP enabled!
# PvPInfo Command
diff --git a/pvpmanager/src/test/java/me/NoChance/PvPManager/Managers/DependencyTest.java b/pvpmanager/src/test/java/me/NoChance/PvPManager/Managers/DependencyTest.java
index 94950173..f97ae033 100644
--- a/pvpmanager/src/test/java/me/NoChance/PvPManager/Managers/DependencyTest.java
+++ b/pvpmanager/src/test/java/me/NoChance/PvPManager/Managers/DependencyTest.java
@@ -12,6 +12,7 @@
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.AdditionalMatchers;
import org.mockito.ArgumentMatchers;
import org.mockito.Mockito;
@@ -35,7 +36,7 @@ public static void setupClass() {
void allEnabled() {
final JavaPlugin plugin = Mockito.mock(JavaPlugin.class);
when(plugin.getDescription()).thenReturn(new PluginDescriptionFile("Plugin", "1.0", "plugin"));
- when(server.getPluginManager().getPlugin(ArgumentMatchers.anyString())).thenReturn(plugin);
+ when(server.getPluginManager().getPlugin(AdditionalMatchers.not(ArgumentMatchers.eq("Towny")))).thenReturn(plugin);
assertEquals(server.getPluginManager().getPlugin("PvPManager"), plugin);
new DependencyManager();
}