Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Double join messages / question about death messages #133

Closed
JessePesse123 opened this issue Nov 20, 2020 · 6 comments
Closed

Double join messages / question about death messages #133

JessePesse123 opened this issue Nov 20, 2020 · 6 comments

Comments

@JessePesse123
Copy link

Hi, we're having trouble with the join messages. When a player it always sends 2 join messages. Nothing is seen in the console. (except this marriage error:) `

>.... [19:44:20 ERROR]: Could not pass event AsyncPlayerChatEvent to Marriage v2.0.20
java.lang.NullPointerException: null
at com.lenis0012.bukkit.marriage2.listeners.ChatListener.onPlayerChatLate(ChatListener.java:82) ~[?:?]
at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor100.execute(Unknown Source) ~[?:?]
at org.bukkit.plugin.EventExecutor.lambda$create$1(EventExecutor.java:69) ~[patched_1.16.4.jar:git-Paper-284]
at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:76) ~[patched_1.16.4.jar:git-Paper-284]
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[patched_1.16.4.jar:git-Paper-284]
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:607) ~[patched_1.16.4.jar:git-Paper-284]
at net.minecraft.server.v1_16_R3.PlayerConnection.chat(PlayerConnection.java:1921) ~[patched_1.16.4.jar:git-Paper-284]
at net.minecraft.server.v1_16_R3.PlayerConnection.c(PlayerConnection.java:1836) ~[patched_1.16.4.jar:git-Paper-284]
at net.minecraft.server.v1_16_R3.PlayerConnection.a(PlayerConnection.java:1774) ~[patched_1.16.4.jar:git-Paper-284]
at net.minecraft.server.v1_16_R3.PacketPlayInChat$1.run(PacketPlayInChat.java:41) ~[patched_1.16.4.jar:git-Paper-284]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_262]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_262]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_262]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_262]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_262]`

But that error is sent with every message. Do you know what it could be?

@JessePesse123
Copy link
Author

In death messages: what placeholder do u need to use for the previously {killer_item}
?

@kangarko
Copy link
Owner

Thanks I will fix that error!

Use [item]

@JessePesse123
Copy link
Author

Hey, is there also a way to display the killer items name. Like if I name my sword Excalibur, rn it justs sends netherite sword

@kangarko
Copy link
Owner

Sure, but you'd need to code this in JavaScript, please ask people on Discord and someone may code this for you, you can paste it here and I will include it for everyone ;)

@c0wg0d
Copy link

c0wg0d commented Nov 28, 2020

Value: |-
    itemDisplayName();
    
    function itemDisplayName() {
        var itemName = player.getInventory().getItemInMainHand().getItemMeta().getDisplayName();
        var itemDefaultName = player.getInventory().getItemInMainHand().getType().name().toLowerCase().replaceAll('_', ' ');
        var textColor = '&a';
        var bracketColor = '&f';
    
        if (itemName != '') {
            return bracketColor + '[' + textColor + itemName + bracketColor + ']';
        } else {
            return bracketColor + '[' + textColor + itemDefaultName + bracketColor + ']';
        }
    }

@kangarko
Copy link
Owner

kangarko commented Nov 30, 2020

Thanks! However, some items do not have itemmeta nor displayname, here is a safe version, also works for 1.8.8:

# -------------------------------------------------------------------------------------------------
# ChatControl supports dynamic, high performance variables you create! They can be used across
# the plugin, for example in formatting your chat or death messages. Currently, the folder
# variables/ stores all custom variables in each separate yml file.
#
# Variables can not only be used to display information, but because you can write your own full
# code in JavaScript to display them, they can also do whatever you would wish for your
# players/server, such as sneaking in code to send sounds or spawn monsters.
#
# Coding this variable requires a little bit of JavaScript knowledge, see the link below.
#
# For documentation and help, please see this link:
# https://github.com/kangarko/ChatControl-Red/wiki/JavaScript-Variables
# -------------------------------------------------------------------------------------------------

# Where should this variable be used?
#
# FORMAT = used in your formats with {syntax}, players cannot use it
# MESSAGE = players can use it with [syntax] in their chat messages
Type: message

# The key we look for in the chat surrounded by [] brackets, example:
# chat message: "Hello everyone, I have an [item] in my hand" if your key is equal to "item"
Key: killer_item

# The value the key will be replaced to. This uses JavaScript.
Value: |-
    itemDisplayName();
    
    function itemDisplayName() {
        var item = player.getInventory().getItemInHand();
       
        var textColor = '&a';
        var bracketColor = '&f';
        var airName = 'fists';
    
        if (item.hasItemMeta() && item.getItemMeta().hasDisplayName()) {
            var itemName = player.getInventory().getItemInHand().getItemMeta().getDisplayName();
    
            return bracketColor + '[' + textColor + itemName + bracketColor + ']';
    
        } else {
          var wordUtils = Java.type("org.apache.commons.lang.WordUtils");
          
          var itemMaterial = player.getInventory().getItemInHand().getType().name();
          var itemDefaultName = wordUtils.capitalizeFully(itemMaterial.contains("AIR") ? airName : itemMaterial.replaceAll('_', ' '));
    
          return bracketColor + '[' + textColor + itemDefaultName + bracketColor + ']';
        }
    }

# What JavaScript condition must return true for this variable to show?
# You can put variables in here to get replaced.
Sender_Condition: ''

# What permission must the message sender have in order for this variable to display to him?
Sender_Permission: ''

# See Sender_Condition, except that we evaluate the JavaScript for each chat message receiver
# and only show the message to those receivers for which the condition returns true.
Receiver_Condition: ''

# What permission must the message receiver have in order for this variable to display to them?
Receiver_Permission: ''

# What texts should be displayed when we hover the mouse
# over this variable in the chat
Hover: []

# What ItemStack should be displayed when we hover the mouse over this variable in the chat
Hover_Item: player.getItemInHand()

# What website URL should be opened when we click with the mouse
# on this variable in the chat
Open_Url: ''

# What command should appear in the player command box on his screen
# if he clicks on this variable in the chat
Suggest_Command: ''

# What command should run as the sender when he clicks the mouse on this variable?
# Minecraft only supports 1 command!
Run_Command: ''

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants