mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
Add option for always showing item in player death messages
This commit is contained in:
@@ -1,46 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: MelnCat <melncatuwu@gmail.com>
|
|
||||||
Date: Tue, 22 Aug 2023 22:18:26 -0700
|
|
||||||
Subject: [PATCH] Add option for always showing item in player death messages
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/net/minecraft/world/damagesource/CombatTracker.java b/net/minecraft/world/damagesource/CombatTracker.java
|
|
||||||
index 10afc08930d7fe27ffa396ec5a10afb7769a3f0b..6853b91e047b92ae4042a26d6aad84874be11709 100644
|
|
||||||
--- a/net/minecraft/world/damagesource/CombatTracker.java
|
|
||||||
+++ b/net/minecraft/world/damagesource/CombatTracker.java
|
|
||||||
@@ -54,7 +54,7 @@ public class CombatTracker {
|
|
||||||
|
|
||||||
private Component getMessageForAssistedFall(Entity attacker, Component attackerDisplayName, String itemDeathTranslationKey, String deathTranslationKey) {
|
|
||||||
ItemStack itemStack = attacker instanceof LivingEntity livingEntity ? livingEntity.getMainHandItem() : ItemStack.EMPTY;
|
|
||||||
- return !itemStack.isEmpty() && itemStack.has(DataComponents.CUSTOM_NAME)
|
|
||||||
+ return !itemStack.isEmpty() && (org.purpurmc.purpur.PurpurConfig.playerDeathsAlwaysShowItem || itemStack.has(DataComponents.CUSTOM_NAME)) // Purpur
|
|
||||||
? Component.translatable(itemDeathTranslationKey, this.mob.getDisplayName(), attackerDisplayName, itemStack.getDisplayName())
|
|
||||||
: Component.translatable(deathTranslationKey, this.mob.getDisplayName(), attackerDisplayName);
|
|
||||||
}
|
|
||||||
diff --git a/net/minecraft/world/damagesource/DamageSource.java b/net/minecraft/world/damagesource/DamageSource.java
|
|
||||||
index ccdf9d40b767115e0e6db2c29af42f5ec4c40f85..3781bca61379516d537650c79c614933454fdcd8 100644
|
|
||||||
--- a/net/minecraft/world/damagesource/DamageSource.java
|
|
||||||
+++ b/net/minecraft/world/damagesource/DamageSource.java
|
|
||||||
@@ -219,7 +219,7 @@ public class DamageSource {
|
|
||||||
|
|
||||||
ItemStack itemstack1 = itemstack;
|
|
||||||
|
|
||||||
- return !itemstack1.isEmpty() && itemstack1.has(DataComponents.CUSTOM_NAME) ? Component.translatable(s + ".item", killed.getDisplayName(), ichatbasecomponent, itemstack1.getDisplayName()) : Component.translatable(s, killed.getDisplayName(), ichatbasecomponent);
|
|
||||||
+ return !itemstack1.isEmpty() && (org.purpurmc.purpur.PurpurConfig.playerDeathsAlwaysShowItem || itemstack1.has(DataComponents.CUSTOM_NAME)) ? Component.translatable(s + ".item", killed.getDisplayName(), ichatbasecomponent, itemstack1.getDisplayName()) : Component.translatable(s, killed.getDisplayName(), ichatbasecomponent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
diff --git a/src/main/java/org/purpurmc/purpur/PurpurConfig.java b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
|
||||||
index 535c7d6298ca62ea1bf808ac8deec1d2381b3831..ab672b9041ae40ba3e78bc5f9f465ee70e420993 100644
|
|
||||||
--- a/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
|
||||||
+++ b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
|
||||||
@@ -577,4 +577,9 @@ public class PurpurConfig {
|
|
||||||
block.fallDistanceMultiplier = fallDistanceMultiplier.floatValue();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
+
|
|
||||||
+ public static boolean playerDeathsAlwaysShowItem = false;
|
|
||||||
+ private static void playerDeathsAlwaysShowItem() {
|
|
||||||
+ playerDeathsAlwaysShowItem = getBoolean("settings.player-deaths-always-show-item", playerDeathsAlwaysShowItem);
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,14 @@
|
|||||||
--- a/net/minecraft/world/damagesource/CombatTracker.java
|
--- a/net/minecraft/world/damagesource/CombatTracker.java
|
||||||
+++ b/net/minecraft/world/damagesource/CombatTracker.java
|
+++ b/net/minecraft/world/damagesource/CombatTracker.java
|
||||||
|
@@ -54,7 +_,7 @@
|
||||||
|
|
||||||
|
private Component getMessageForAssistedFall(Entity entity, Component entityDisplayName, String hasWeaponTranslationKey, String noWeaponTranslationKey) {
|
||||||
|
ItemStack itemStack = entity instanceof LivingEntity livingEntity ? livingEntity.getMainHandItem() : ItemStack.EMPTY;
|
||||||
|
- return !itemStack.isEmpty() && itemStack.has(DataComponents.CUSTOM_NAME)
|
||||||
|
+ return !itemStack.isEmpty() && (org.purpurmc.purpur.PurpurConfig.playerDeathsAlwaysShowItem || itemStack.has(DataComponents.CUSTOM_NAME)) // Purpur - always show item in player death messages
|
||||||
|
? Component.translatable(hasWeaponTranslationKey, this.mob.getDisplayName(), entityDisplayName, itemStack.getDisplayName())
|
||||||
|
: Component.translatable(noWeaponTranslationKey, this.mob.getDisplayName(), entityDisplayName);
|
||||||
|
}
|
||||||
@@ -98,6 +_,15 @@
|
@@ -98,6 +_,15 @@
|
||||||
Component component = ComponentUtils.wrapInSquareBrackets(Component.translatable(string + ".link")).withStyle(INTENTIONAL_GAME_DESIGN_STYLE);
|
Component component = ComponentUtils.wrapInSquareBrackets(Component.translatable(string + ".link")).withStyle(INTENTIONAL_GAME_DESIGN_STYLE);
|
||||||
return Component.translatable(string + ".message", this.mob.getDisplayName(), component);
|
return Component.translatable(string + ".message", this.mob.getDisplayName(), component);
|
||||||
|
|||||||
@@ -46,7 +46,13 @@
|
|||||||
return damageSource;
|
return damageSource;
|
||||||
}
|
}
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
@@ -187,6 +_,15 @@
|
@@ -182,11 +_,20 @@
|
||||||
|
} else {
|
||||||
|
Component component = this.causingEntity == null ? this.directEntity.getDisplayName() : this.causingEntity.getDisplayName();
|
||||||
|
ItemStack itemStack = this.causingEntity instanceof LivingEntity livingEntity1 ? livingEntity1.getMainHandItem() : ItemStack.EMPTY;
|
||||||
|
- return !itemStack.isEmpty() && itemStack.has(DataComponents.CUSTOM_NAME)
|
||||||
|
+ return !itemStack.isEmpty() && (org.purpurmc.purpur.PurpurConfig.playerDeathsAlwaysShowItem || itemStack.has(DataComponents.CUSTOM_NAME)) // Purpur - always show item in player death messages
|
||||||
|
? Component.translatable(string + ".item", livingEntity.getDisplayName(), component, itemStack.getDisplayName())
|
||||||
: Component.translatable(string, livingEntity.getDisplayName(), component);
|
: Component.translatable(string, livingEntity.getDisplayName(), component);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -573,4 +573,9 @@ public class PurpurConfig {
|
|||||||
block.fallDistanceMultiplier = fallDistanceMultiplier.floatValue();
|
block.fallDistanceMultiplier = fallDistanceMultiplier.floatValue();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean playerDeathsAlwaysShowItem = false;
|
||||||
|
private static void playerDeathsAlwaysShowItem() {
|
||||||
|
playerDeathsAlwaysShowItem = getBoolean("settings.player-deaths-always-show-item", playerDeathsAlwaysShowItem);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user