Skip to content

Commit b85b837

Browse files
committed
Move protection messages to action bar
1 parent 0572b22 commit b85b837

7 files changed

Lines changed: 11 additions & 9 deletions

File tree

pvpmanager/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ ext {
6969
'project.groupId' : project.group,
7070
'project.version' : project.version,
7171
'project.description': project.description,
72-
'config.version' : '201',
72+
'config.version' : '204',
7373
'database.version' : '1'
7474
]
7575
}

pvpmanager/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<url>https://github.com/ChanceSD/PvPManager</url>
1717

1818
<properties>
19-
<config.version>203</config.version>
19+
<config.version>204</config.version>
2020
<database.version>1</database.version>
2121
<argLine/>
2222
</properties>

pvpmanager/src/main/java/me/chancesd/pvpmanager/setting/Conf.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ public enum Conf {
146146
HEALTH_BELOW_NAME(ConfSection.OTHER_SETTINGS, "Show health under name.Enabled", true, Boolean.class),
147147
HEALTH_BELOW_NAME_SYMBOL(ConfSection.OTHER_SETTINGS, "Show health under name.Display Name", ChatUtils::colorize, String.class, String.class),
148148

149+
PROTECTION_MESSAGES_TO_ACTIONBAR(ConfSection.OTHER_SETTINGS, "Protection Messages to Action Bar", bool -> MCVersion.isAtLeast(MCVersion.V1_10) && bool, Boolean.class, Boolean.class),
150+
149151
// Disable on hit
150152
DISABLE_FLY(ConfSection.DISABLE_ON_HIT, "Fly", true, Boolean.class),
151153
RESTORE_FLY(ConfSection.DISABLE_ON_HIT, "Restore Fly", true, Boolean.class),

pvpmanager/src/main/java/me/chancesd/pvpmanager/setting/Lang.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,11 @@ private static String findKeyBefore(final String targetKey) {
361361
public static void messageProtection(final ProtectionResult result, final Player player, final Player attacked) {
362362
final String message = getProtectionMessage(result, attacked);
363363
final CombatPlayer receiver = plugin.getPlayerManager().get(player);
364-
receiver.message(message);
364+
if (Conf.PROTECTION_MESSAGES_TO_ACTIONBAR.asBool()) {
365+
receiver.sendActionBar(message, 500);
366+
} else {
367+
receiver.message(message);
368+
}
365369
}
366370

367371
public static String getProtectionMessage(final ProtectionResult result, final Player attacked) {

pvpmanager/src/main/java/me/chancesd/pvpmanager/tasks/RegionCheckTask.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import me.chancesd.pvpmanager.player.CombatPlayer;
1717
import me.chancesd.pvpmanager.setting.Lang;
1818
import me.chancesd.sdutils.scheduler.ScheduleUtils;
19-
import me.chancesd.sdutils.utils.Log;
2019

2120
public class RegionCheckTask extends BukkitRunnable implements Listener {
2221

pvpmanager/src/main/resources/config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,8 @@ Other Settings:
266266
PvP Blood: true
267267
# Ignore hits from snowballs, eggs, fishing rod and others
268268
Ignore No Damage Hits: true
269+
# Send protection messages (PvP disabled, newbie protection, etc.) to action bar instead of chat
270+
Protection Messages to Action Bar: true
269271
# Player Drop Mode -> What happens to a player's drops and exp on death
270272
# The options are 'ALWAYS' - (PvPManager does nothing, feature is disabled, usually best to avoid conflicts with death chest plugins, etc),
271273
# mode 'DROP' - (Players drop items when killed in PvP but not in PvE),

pvpmanager/src/test/java/me/chancesd/pvpmanager/listener/EntityListenerTest.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import me.chancesd.pvpmanager.manager.PlayerManager;
3333
import me.chancesd.pvpmanager.player.CombatPlayer;
3434
import me.chancesd.pvpmanager.player.ProtectionType;
35-
import me.chancesd.pvpmanager.setting.Lang;
3635
import me.chancesd.pvpmanager.setting.Conf;
3736
import me.chancesd.pvpmanager.utils.CombatUtils;
3837

@@ -204,7 +203,6 @@ final void cancelNewbie() {
204203
createAttack(false);
205204

206205
assertEquals(ProtectionType.NEWBIE, ph.checkProtection(attacker, defender).type());
207-
verify(attacker, times(2)).sendMessage(Lang.NEWBIE_PROTECTION_ON_HIT.msg());
208206

209207
verify(mockEvent).setCancelled(true);
210208
verify(projMockEvent).setCancelled(true);
@@ -216,7 +214,6 @@ final void cancelPvPDisabled() {
216214
createAttack(false);
217215

218216
assertEquals(ProtectionType.PVPDISABLED, ph.checkProtection(attacker, defender).type());
219-
verify(attacker, times(2)).sendMessage(Lang.ATTACK_DENIED_OTHER.msg(defender.getName()));
220217

221218
verify(mockEvent).setCancelled(true);
222219
verify(projMockEvent).setCancelled(true);
@@ -316,7 +313,6 @@ final void tntAttack() {
316313
assertTrue(CombatUtils.isPvP(tntEvent));
317314

318315
callEvent(tntEvent);
319-
// Verify combat tagging behavior for TNT attacks
320316
assertTrue(combatAttacker.isInCombat());
321317
assertTrue(combatDefender.isInCombat());
322318
}
@@ -330,7 +326,6 @@ final void areaEffectCloudAttack() {
330326
assertTrue(CombatUtils.isPvP(cloudEvent));
331327

332328
callEvent(cloudEvent);
333-
// Verify combat tagging for area effect clouds
334329
assertTrue(combatAttacker.isInCombat());
335330
assertTrue(combatDefender.isInCombat());
336331
}

0 commit comments

Comments
 (0)