#development

1 messages · Page 147 of 1

lyric gyro
#

I'm not in the CC team but afaik one of the future goals is to support multiple platforms

#

hellllloooooo i need help to make a server

dense drift
#

No need to spam every channel

brittle thunder
#

Chat Chat Chat

broken elbow
#

event triggered by ChatChat.

#

very creative name

#

I know

brittle thunder
#

Oh wait, its called chat chat?

#

🥲

broken elbow
#

because we're creative

#

like that

lyric gyro
#

Well, it's a chat event for ChatChat

#

So ChatChatChatEvent

broken elbow
#

as the cool kids say, our imagination is bussin or something

lyric gyro
#

Busy? KKPeepoMeiBoomer

broken elbow
#

no cap that shit is bussin

craggy timber
#

yeah it is that

broken elbow
#

e.getCaught() probably returns null

#

you might want to check that first before setting it to something else

slim estuary
#

I'm having an extremely odd issue.

I'm looping through my plugin's config which is similar to this:

tasks:
    break:
        - OAK_PLANKS:10
    place:
        - BIRCH_PLANKS:10

This is the loop I use to retrieve all of the items.

        HashMap<String, Integer> map = new HashMap<>();

        String path = "ages." + age.toString().toLowerCase() + ".tasks";

        for (String key : plugin.getConfig().getConfigurationSection(path).getKeys(false))
        {
            for (String material : plugin.getConfig().getConfigurationSection(path + "." + key).getKeys(false))
            {
                Bukkit.getServer().getConsoleSender().sendMessage(material); // Logs the items in order
                int amount = plugin.getConfig().getInt(path + "." + key + "." + material);
                map.put(key + "." + material, amount);
            }
        }

        Bukkit.getServer().getConsoleSender().sendMessage(map.toString()); // Incomplete map?

Whenever I print inside the loop, it prints all the items in the config; however, whenever I print the map itself, it only contains a few of the items. Can anyone help? Thanks

spiral prairie
slim estuary
#

Whoops, my bad. It's actually written like this:

tasks:
    break:
        OAK_PLANKS:10
    place:
        BIRCH_PLANKS:10
spiral prairie
#

should work

slim estuary
#

Inside the loop it will print these properly, I just don't know why the map is missing items.

spiral prairie
#

theres no reason it shouldnt work

sterile hinge
#

the key for the map might not be unique

broken elbow
#

but it can't not be unique

#

since yaml wouldn't let them

lyric gyro
#

pretty sure it can

#

it's configurable

sterile hinge
#

but tbh all that string concatenation stuff is just a huge source of issues

slim estuary
#

Hopefully helps

broken elbow
#

you have 47 items, tere's 47 items in the map

slim estuary
#

Hm, I guess I went to far on the trace. Let me see if I can find where it messes up later on.

slim estuary
#

Okay, it seems the issue was with how I was displaying them in my GUI, and I misread the console. Thanks for helping out! 🙂

urban temple
#
#config.yml
chat-format: "%luckperms_prefix% &7%player%&8: &f%message%"```

```java

//code
    @EventHandler
    public void ChatFormatting(AsyncPlayerChatEvent e){
        String msg = e.getMessage();
        Player p = e.getPlayer();
        if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
            msg = PlaceholderAPI.setPlaceholders(e.getPlayer(), msg);

            e.setFormat(ChatColor.translateAlternateColorCodes('&', getConfig().getString("chat-format")).replace("%player%", p.getDisplayName()).replace("%message%", msg));
        }else{
            e.setFormat(ChatColor.translateAlternateColorCodes('&', getConfig().getString("chat-format")).replace("%player%", p.getDisplayName()).replace("%message%", msg));
        }

    }```

whenever i use a placeholder from PAPI in Chat-format from config.yml it throws an error in the console and gets back to vanilla chat format, any idea why?
#

the error in console is Could not pass PlayerChatAsyncEvent event to ChatterPlus 1.0

broken elbow
urban temple
#

what do I have to do ?

broken elbow
#

well make sure your message doesn't contain % after its being parsed

urban temple
#

yea what exactly does parsed mean? ik I'm stupid

urban temple
broken elbow
#

that's what the setPlaceholder method does. it parses placeholders.

broken elbow
#

well I Mean the problem is most likely not in there. since if anyone adds % anywhere in their format, it will still start throwing. Best solution is to use paper instead of spigot. But if you don't want to, then check the format for % first, then remove them and maybe even show a warning in console

urban temple
#

yea I already use paper

broken elbow
#

well then use their AsyncChatEvent instead

urban temple
broken elbow
#

well you'll have to see how that works first. bcz it works completely different than AsyncPlayerChatEvent

urban temple
#

well that's kinda weird

#

thanks tho

torpid raft
#

everyone here uses gradle or maven to build their jars

#

rather than intellij's default sussy build tool

broken elbow
torpid raft
broken elbow
#

stop me

torpid raft
#

🛑

#

you'll need to add that package as a dependency

#

if you havent already

#

syntax seems right

#

is the package on maven central

#

maven central is the main and default repo for dependencies

#

thats where maven usually downloads all the external libraries from

#

tbh i dont think i understand the entirety of maven well enough to explain it well to you

#

id recommend watching a few video tutorials on it

#

nicee

odd prawn
#

Okay, maybe it's just me. But I swear this should work defective

    public static void openWarn(Player player, String reason) {
        ItemStack book = new ItemStack(Material.WRITTEN_BOOK);
        BookMeta meta = (BookMeta) book.getItemMeta();

        meta.addPage("Reason: " + reason);

        book.setItemMeta(meta);
        player.getInventory().addItem(book);
    }

Does somebody see what I did wrong?

#

When I open the book it just says * Invalid book tag *

#

Just set the build directory to your local server, it should overwrite it.

torpid raft
#

i geluess that would replace the jar but it wont update it, your server will still be running the old jar

#

that's also a very silly way of replacing it, if you're on linux you can just mv the new jar into the old one

leaden sinew
#

Does Bukkit.getScheduler().runTaskAsynchronously() create new threads?

winged pebble
#

Yeah

#

It's not on the main thread

lyric gyro
#

No it doesn't

#

It uses a thread pool

leaden sinew
#

Thanks!

mystic phoenix
#

Hey, I'm having some problems with p.setHealth();
for some reason it gives me an error when i use p.setHealth(0); or
p.setHealth(0.0); or p.setHealth(0.0D);. Does anyone know why?

lyric gyro
#

what error?

neat pierBOT
mystic phoenix
#

does anything show when you click on that?

lyric gyro
#

when I click on Barry's yes, lol

#

can you show the entire stack trace tho..

mystic phoenix
lyric gyro
dusky harness
mystic phoenix
dusky harness
#

can u send the entire class?

neat pierBOT
#
FAQ Answer:

Paste Services
When asking for help with a config/menu/code issue please use our paste bin:
(we prefer it over pastebin.com)
HelpChat Paste - How To Use

mystic phoenix
dusky harness
#

can u send line 29?

mystic phoenix
#

p.setHealth(0);

dusky harness
#

Huh

#

wait what

#

Oh I misread the exception

#

but hmm

#

was there any more to the stacktrace/error? or is that it

mystic phoenix
#

That's it.

lyric gyro
#

all I can think of is some other plugin / some listener in your plugin doing some dumb stuff in the death event causing it to blow up

#

but that looks very weird and incomplete

dusky harness
#

Usually EventException would lead to another error but not sure why it'd error in setHealth

#

Oh wait check in a player death listener

#

oh wait

#

Emily

#

already beat me to it

#

:((

mystic phoenix
#

Do you want to see the death listener?

dusky harness
#

sure

mystic phoenix
#

Well, it has a lot of code. So might be hard finding something.

#

It might be because I set the player health to 20 in the death listener.

dusky harness
#

so it shouldn't be related

mystic phoenix
#

No I also set player health.

dusky harness
#

still quite weird how the error doesn't contain what the actual error is

dusky harness
mystic phoenix
#

Yes.

dusky harness
#

oh

#

why?

mystic phoenix
#

So that the respawn screen doesn't show.

dusky harness
#

what version?

mystic phoenix
#

1.8.8

dusky harness
#

oh then theres a diff way

#

gimme a sec

mystic phoenix
#

Yes there is the spigot.respawn thing.

dusky harness
#

note that it doesn't work on newer versions though - or I think you can change some gamerule or smth

dusky harness
#

why not use that?

#

or maybe try setting health and all that a tick later

mystic phoenix
#

That teleports the player to the spawn point, I have a location in config.

dusky harness
mystic phoenix
#

I haven't tried that..

dusky harness
#

and if the spawn plugin overrides it, try a tick later

#

but respawn should call respawn event and so you should be able to do it on the same tick

#

anyways I gtg, but try that and see how it goes 👍

mystic phoenix
dusky harness
#

oh then try a tick later

mystic phoenix
#

Yeah, I'll try that.

dusky harness
#

but try same tick first

#

then if that doesn't work do a tick later

mystic phoenix
#

Yes!

#

Ty for helping!

#

Ty Emily as well.

dusky harness
#

🥰

urban temple
#

also, just removing the % doesnt work either

edgy lintel
urban temple
#

Ohh cause i though he meant like use paper on your server

#

but im using the Spigot API

#

thx ill try it

urban temple
sterile hinge
#

have you added the correct repo?

urban temple
#

yea

#
    <repositories>

        <repository>
            <id>papermc</id>
            <url>https://repo.papermc.io/repository/maven-public/</url>
        </repository>
        <repository>
            <id>placeholderapi</id>
            <url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>io.papermc.paper</groupId>
            <artifactId>paper-api</artifactId>
            <version>1.19.1-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>me.clip</groupId>
            <artifactId>placeholderapi</artifactId>
            <version>2.11.2</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>```
broken elbow
urban temple
#

tried that too, but I asked in spigot forums and I will later try cancelling the event and broadcasting a new message to the server using a custom format from the config

broken elbow
#

that's an option I guess, but you need to be careful as it might break compatibility with plugins like DiscordSRV, which rely on the uncanceled event and are listening for it with the MONITOR priority

urban temple
#

DiscordSRV Chat logging channels have their own formatting anyways

broken elbow
#

yeah but they won't be able to get the message at all if you cancel the event

#

is what I'm saying

urban temple
#

Ohhh

#

thanks for the info then

queen plank
smoky hound
#

thats the fix using gradle, but its probably pretty similar to fix for maven

queen plank
#

Ahh, that was it. I simply changed the version 3.2.4 -> 3.3.0, I thought the java version was the problem as I just changed it from 16 -> 17.

#

Thank you!

plush stirrup
#
public void getName(Player sender, String nick) {
        for (String key : OreNLore.getInstance().getPlayerNicks().getConfigurationSection("data.").getKeys(false)) {
            nickMap.put(UUID.fromString(key), OreNLore.getInstance().getPlayerNicks().getString("data." + key + ".nick"));
            if (nickMap.containsValue(nick)) {
                String realName = OreNLore.getInstance().getPlayerNicks().getString("data." + key + ".realname");
                sender.sendMessage(realName);
            } else {
                sender.sendMessage("doesn't exist");
            }
        }
    }```

I'm trying to loop through yaml file to get the realname of the player, but I only want to get the name of the player that's connected to the nick value. What steps should I take to ensure I can only get the real name of the player that's connected to the nick.

Here's my yaml file:
```yaml
data:
  fbfbfe36-a993-410f-abc9-85ea7fcf55b4:
    nick: InsideIntel
    realname: InsideIntel
  b0c6ef0c-2d98-4ae4-83cb-6fa1163be32d:
    nick: test
    realname: ChakyClan
#

right now I get an output of

InsideIntel
ChakyClan```
high edge
#

You loop through everything, and just display what's in it, you need to retrieve the nick and realname for your config entry, check if it matches, if it does break the loop and return, and if it doesn't, continue the loop

plush stirrup
high edge
#

Not really, you just check if your nicks map contains the given nickname, however it doesn't check to which player it belongs to

plush stirrup
#

In that case, do i even need the .nick and .realname in the yaml file being i can get the player name from the uuid itself?

#

or is it better to do it this way

high edge
#

Well yes, since if you want persistency, you need to somehow link the player to the nickname, you wouldn't really need the realname, since you can just use uuid and get their name through the player instance

plush stirrup
#

now time to figure out how to do this, been trying to figure out how to just send one players name

#

alr, thx for ur help, i hope i can figure this out, my brain doesn't like yaml files

high edge
#

Some pseudo code that will help you a bit probably

String getName(sender, nickname) {
  loop (your entire list of config data) {
    nickname = the nickname retrieved from your current loop iteration

    if (nicknames dont't match) {
       continue the loop
    }

    otherwise return the realname for this player using the uuid key value, with Bukkit#getPlayer(uuid)#getName
  }
}
#

Hopefully that makes sense

#

You'd also only need something like this in your storage

data:
  uuid: 
    nickname: 
  uuid: 
    nickname:
#

(also, don't forget to strip the strings of color and formatting)

plush stirrup
#

oh ofc ofc

#

thx again

high edge
#

np, good luck

plush stirrup
high edge
#

Well you wouldn't, since you wouldn't really be able to tell which player you're targetting

plush stirrup
#

Well

#

for if players have the same nick, I want to send both of the players, not just one

#

or well all of the players i guess

high edge
#

Well then have it return a set of players, you'd do the same as now, just not break the loop

shell moon
#

Is is possible to detect when player opens his inventory?

#

(i've read that its client side, so no packet is sent, aka cannot be detected)

dense drift
#

Nope

shell moon
dense drift
#

Which is bs

shell moon
#

ikr

#

i wanna make a conbination of actions "keys"

#

to open player storage (like backpacks or vaults)

#

which conbinations do you think would be good to use

dense drift
#

Combination?

shell moon
#

(looking for more than 1 conbination)

#

i mean, first idea was when player sneak and inmediately opens inventory

#

but since its not possible to detect, idea is not valid

#

conbinations like: double shifting

#

or shifting and clicking, etc

dense drift
#

Some use the knowledge book from player's inventory

shell moon
#

like a shortcut to open inventories

#

any idea about actions

#

like sneaking (not jumping please)

#

and that stuff

#

damn, sneak + open player inventory was such good idea

#

they only way would be using mods to detect key pressed

topaz gust
shell moon
#

what?

#

but player open (its) inventory is client side

topaz gust
#

What?

shell moon
#

player pressing E to open his inventory is client side

topaz gust
#

d; OpenInventoryEvent

uneven lanternBOT
#
public class InventoryOpenEvent
extends InventoryEvent
implements Cancellable```
InventoryOpenEvent has 1 extensions, 1 implementations, 1 all implementations, and  6 methods.
Description:

Represents a player related inventory event

topaz gust
#

^

shell moon
#

i know there is an open inventory event

#

but all forums i read says it's client side

#

when opening player inventory

icy shadow
#

yeah i think it is until they click something

shell moon
#

yes, but the idea is listeing to open inventory, not clicking it

#

that breaks the magic

#

so idk what other key combinations to use

#

since E is not an option

#

any good idea?

topaz gust
#

Did you actually try InventoryOpenEvent?

#

Or just read some stuff about it?

shell moon
#

I read about it, like in more than 10 posts

topaz gust
#

Okay

shell moon
lyric gyro
#

A player opening their own inventory isn't something the server receives, yeah

#

The client just does not send the info and the server considers it to be "open at all times"

topaz gust
#

But you can detect with anti cheats if it’s open or not

#

With packets

lyric gyro
#

Not quite

#

Only if they're moving stuff around the inventory and also moving in the world

#

Which applies to any inventory really, since it doesn't make sense to move stuff in an inventory if you're moving in the world

shell moon
worn jasper
#

some people use F, you could use sneak + F

#

and by F, I mean to switch items to your offhand

neat pierBOT
winged pebble
#

You can use RecipeChoice.ExactChoice

lyric gyro
#

rip

hoary scarab
#

List<Recipe> recipes = Bukkit.getRecipesFor(item); is what I use.

#

1.8.8 -> 1.19

#

As long as the items were added to bukkits recipe list and aren't added as a result during an event the code I provided should work.

#

If its your recipe... Add it to the list properly.

#

How do you add the recipe?

#

Ok then you aren't doing what I said xD

bitter basin
#

Lets say I send a packet to hide an entity from a player, once they tp to another world and then tp back, the entity is now visible, do i just check if the player is near the entity and resend the packet or send the packet every second or smth

#

cause i think they can also walk out of render distance and back in and they can see the entity again

#

and i dont wanna check nearby entities every tick or move event

proud pebble
#

you can set the result as an itemstack, but you cannot set an ingredient as an itemstack

radiant ember
#

hey im trying to make a config.yml to change the message, but it shows this error

neat pierBOT
high edge
sterile hinge
#

I guess either main.getConfig().getString("fly-enabled") or main.getConfig().getString("fly-disabled") returns null, hard to say as you stripped too much context

west socket
#

Anyone know how to forcefully perform a thread dump on a spigot server

#

Or with ptero panel?

sterile hinge
#

like the jstack output?

west socket
#

Whats that?

#

Is that what it outputs on a server crash?

sterile hinge
#

no, it's just all the stacktraces

west socket
#

For all the active threads?

sterile hinge
#

yeah, active and waiting, both jvm and application threads

west socket
#

Yeah thats what I want

#

Do you know how I could forcefully display that info?

sterile hinge
#

well jstack is nice if you want to run it from outside the server

west socket
#

Sorry, is that a java program?

sterile hinge
#

yes

west socket
#

Hmm, I'm not sure if I would be able to set that up

#

Theres no way I could do that from within a plugin?

sterile hinge
#

there are different ways for that

#

like there is Thread#dumpStack() and Thread#getAllStackTraces

west socket
#

Essentially, my issue is that Java is creating way too many threads and causing my server to "crash"

#

So I need to analyze the threads to see what's creating so many

west socket
sterile hinge
west socket
#

Ill look into it, thanks

sterile hinge
merry knoll
#

after the initial disable you do