#help-development

1 messages · Page 969 of 1

rough drift
#

this is correct

lime narwhal
#

k, i'll try

quiet ice
#

If you did not put it in a subdir within the resources folder, that is correct - otherwise no.

lime narwhal
#

nah same error

#

there is no more directory in my ressources package

quiet ice
#

could you screenshot your project layout?

lime narwhal
#

so it should be good

#

yep

quiet ice
#

use mvn clean package to build your jar and maybe try to also drop the leading slash

lime narwhal
quiet ice
#

yeah, if you go the IDE route - first invoke clean, then the package goal

lime narwhal
#

wtf is happening

#

i have an error on plugin.yml now

#

"Jar does not contain plugin.yml"

quiet ice
#

well that narrows it down a bit. Could you paste the contents of the pom.xml?

lime narwhal
quiet ice
#

hm strange, I am not seeing any obvious defects (though I am slightly unnerved by the fact that the pom isn't 200 lines long :p)

lime narwhal
#

why it would be 200 lines XD

quiet ice
#

including the license file and other formalities, multi-release-jar stuff, the javadoc and source plugins and last but not least the maven-gpg-plugin all contribute to my minimum buildscript being rather long

lime narwhal
#

yea i see, but it worked like that too, plugin is working tho, just when i try to implements SQL connexion, it crash

#

@quiet ice no more idea to my issue ?

quiet ice
#

not really at this point in time

lime narwhal
#

are you ok to try with screenshare ?

quaint mantle
#

I have another question, the translations should be at resources folder or like a external folder at the main tree of the project for better maintenance? Keeping in mind I have multiple modules

inner mulch
#

how do i properly manage servers for a minigame for exmaple?

#

like how do ppl auto start them

#

did they code an external service for that?

haughty wind
slender elbow
#

k8s

inner mulch
#

🤨

haughty wind
#

or that

icy beacon
#

I misread this at first

tepid turret
#

get bukkit Sound.<sound> from NMS "entity.allay.item_take"

#

?

torn shuttle
#

question, how does entityspawnevent actually implement cancellable? does it create the entity and remove it if it gets cancelled?

#

because the event itself passes a valid entity

tepid turret
stiff sonnet
#

does anyone know a solution to this problem: I have two kinds of events, an EntityExplodeEvent and a BlockPhysicsEvent. When the explode event triggers, I'm giving the player all exploded blocks directly into the inventory. The problem is that the explosions seem to overlap, and I sometimes get a few blocks too many. Any idea how to tackle that?

echo basalt
#

Cancelling it just prevents it from being registered to the world and sent to players

#

Meaning it loses all references and can be GC'd

tepid turret
#

Also anyone know how to hide these messages
[EntityLookup] Failed to remove entity ChestBoat['Birch Boat with Chest'/426, uuid='a0fe2493-6705-4c4c-96b9-a78044977ecd', l='ServerLevel[world]', x=395.55, y=62.52, z=-216.04, cpos=[24, -14], tl=120, v=true, removed=DISCARDED] by uuid, current entity mapped: null

#

@ me with response please.

hushed spindle
#

fellas, Player#breakBlock() seems to be pretty heavy on the server when done more than normal. is there a better way to break blocks with natural drops?

#

preferably not just setting to air and dropping the drops manually because that doesnt play well with other plugins that might affect drops

cinder abyss
#

Hello, is there a more optimized way to do that?```java
@EventHandler
public void onItemPickup(EntityPickupItemEvent e){
if(!(e.getEntity() instanceof Player player)) return;

for(CraftingRecipe recipe : recipesConstructor.getRegisteredRecipes()){
    if(recipe instanceof ShapedRecipe shaped){
        if(shaped.getIngredientMap().containsValue(e.getItem().getItemStack())){
            player.discoverRecipe(shaped.getKey());
        }
    } else if(recipe instanceof ShapelessRecipe shapeless){
        if(shapeless.getIngredientList().contains(e.getItem().getItemStack())){
            player.discoverRecipe(shapeless.getKey());
        }
    }
}

}```

fringe yew
#

In my main file I have this code that is supposed to share the main class:

private static PermaVision instance;

public static PermaVision getInstance() {
    return instance;
}

and this in my onEnable method:

instance = this;

I'm getting this error when my other java file tries to access .getLogger()

java.lang.NullPointerException: Cannot invoke "co.uk.robuxtrex.pv2.PermaVision.getLogger()" because "this.main" is null
        at co.uk.robuxtrex.pv2.Modules.SendConsoleMessage(Modules.java:60) ~[?:?]
        at co.uk.robuxtrex.pv2.PermaVision.onEnable(PermaVision.java:42) ~[?:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321) ~[server.jar:git-Spigot-550ebace-7019900e2]
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:335) [server.jar:git-Spigot-550ebace-7019900e2]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:405) [server.jar:git-Spigot-550ebace-7019900e2]
        at org.bukkit.craftbukkit.v1_8_R1.CraftServer.loadPlugin(CraftServer.java:356) [server.jar:git-Spigot-550ebace-7019900e2]
        at org.bukkit.craftbukkit.v1_8_R1.CraftServer.enablePlugins(CraftServer.java:316) [server.jar:git-Spigot-550ebace-7019900e2]
        at net.minecraft.server.v1_8_R1.MinecraftServer.q(MinecraftServer.java:402) [server.jar:git-Spigot-550ebace-7019900e2]
        at net.minecraft.server.v1_8_R1.MinecraftServer.k(MinecraftServer.java:370) [server.jar:git-Spigot-550ebace-7019900e2]
        at net.minecraft.server.v1_8_R1.MinecraftServer.a(MinecraftServer.java:325) [server.jar:git-Spigot-550ebace-7019900e2]
        at net.minecraft.server.v1_8_R1.DedicatedServer.init(DedicatedServer.java:211) [server.jar:git-Spigot-550ebace-7019900e2]
        at net.minecraft.server.v1_8_R1.MinecraftServer.run(MinecraftServer.java:505) [server.jar:git-Spigot-550ebace-7019900e2]
        at java.base/java.lang.Thread.run(Thread.java:840) [?:?]
cinder abyss
fringe yew
#

hold up

rough drift
fringe yew
#

i think i may know why wait there

#

fixed it! it was because i was trying to get the main file as soon as the main method in the erroring file was run

#

therefore making it error because it was trying to get the plugin before it was enabled

#

thanks lol

cinder abyss
#

👍

hollow reef
#

is it possible to simulate a period of time to fully spread liquids in a chunk?

fringe yew
smoky anchor
#

My guess would be the ⚠️

fringe yew
#

would there be any way to silence it? since it's loading the file completely fine

smoky anchor
#

you can remove the ⚠️ from the config

hasty hamlet
#

@shadow night sorry, and thank you bro

smoky anchor
#

?services @hasty hamlet and don't DM random ppl

undone axleBOT
grave vale
#

hey, I was updating one of my plugins when I noticed hex codes don't work in vanilla mc's tab
anyone knows why? here's my hex util class if you need it https://paste.md-5.net/voveyedati.java
(repost from yesterday since it got burried with no answer)

tranquil glen
#

@grave vale Try changing your regex? Also you might be substringing incorrectly in the spigot branch

#

"&#([a-fA-F0-9]{6});"

#

Try that instead?

grave vale
#

Alright I'l ltry

tranquil glen
#

s = s.replace(color, net.md_5.bungee.api.ChatColor.of(color.substring(2, 8)) + "");

grave vale
#

let me just start my intellij

tranquil glen
#

And that for the substring

tranquil glen
grave vale
#

still doesn't work (with the regex you just edited)

tranquil glen
#

What's happening?

grave vale
#

this

#

basically nothing

tranquil glen
#

Let's see what ChatGPT has to say about this

#

lol

#

one sec

grave vale
#

hmmm 🤔

tranquil glen
#

I wonder if this works?

grave vale
#

I'll try

#

it changed nothing...

#

it just made this into a mcColor value

hollow reef
#

is it possible to simulate the spread of all liquids in a chunk?

stiff sonnet
#

does anyone know if it's possible to get the item entity from dropItemNaturally? I need to apply a scoreboard tag to it, but would like to not iterate over all possible entities to find the one that I care about

#

oh I found something: dropItemNatually has a consumer argument (and actually returns the item entity as well)

hot dune
#

Hello! How can I check that player got effect from insta heal/damage potions? EntityPotionEffectEvent doesn't work, but it works with other effects

#

Well, it works only with /effect command, but not with potions

hushed spindle
hushed spindle
#

ah yea

#

missed it

grave vale
grave vale
hot dune
#

Then I should get 3 events for each potion type? Splash, lingering and normal one

#

Well, thanks

lilac dagger
#

can i block ticks with this?

hushed spindle
lilac dagger
#

i'll probably have to try it soon

young knoll
#

Block ticks?

lilac dagger
#

no, entity

#

i have a falling block

#

but i'll see if i can do it without

#

i'll set no gravity and time and see how it goes

young knoll
#

What

worthy yarrow
#

uh... I'm having a real odd issue with potioneffects, any time I use the command it applies / removes the effect within the same frame. The toggling is working perfect... Am I just stoned or did I forget how to apply potion effects?

private final Set<Player> playersWithNightVision = new HashSet<>();

    @Override
    public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
        if (!(commandSender instanceof Player)){
            return false;
        }

        Player player = (Player) commandSender;

        if (!player.hasPermission("orchard.nightvision")){

            player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&cYou do not have permission to use this command!"));

            return false;
        }

        if (!playersWithNightVision.contains(player)) {
            player.sendMessage(ChatColor.GREEN + "Night Vision applied!");
            playersWithNightVision.add(player);
            player.addPotionEffect(PotionEffectType.NIGHT_VISION.createEffect(1, 32767));
        } else {
            player.sendMessage(ChatColor.RED + "Night Vision removed!");
            playersWithNightVision.remove(player);
            player.removePotionEffect(PotionEffectType.NIGHT_VISION);
        }
        return true;
    }```
#

I'm really upset I even have to ask about this... but I genuinely can't figure it out

#

Toggles every use of the command, so that works...

young knoll
#

tbf i've never seen createEffect before

worthy yarrow
#

Neither have I, idk if I'm like really high or what

young knoll
#

Anyway you have it inverted

#

It's duration then amplifier

worthy yarrow
#

...

#

breh

#

Please call me stupid so I feel better

young knoll
#

Javadocs op :p

ivory sleet
#

Well amplifier caps at like 255 or sth?

#

Right

young knoll
#

yes

worthy yarrow
#

as if I need level 255 night vision D:

young knoll
#

But it takes an int so idk what happens to said int

ivory sleet
#

32767 is a heck of a high amplifier

worthy yarrow
#

yeah it was inverted....

#

imagine

#

being

#

that

#

bricked up

young knoll
#

1 tick of nightvision 32767 please

worthy yarrow
#

Literally spent 15 minutes trying different toggling methods

young knoll
#

Also in modern versions you can use -1 (or PotionEffect.INFINITE_DURATION) for an infinite effect

worthy yarrow
#

ah good to know

young knoll
#

On older ones I would just do Integer.MAX_VALUE

worthy yarrow
#

I gotta stop going to sleep cooked and waking up cooking again

#

Out of everything I'm putting into this core, night vision is the one that stumped me D:

polar forge
#

Hey guys

#

So I was making a plugin, it’s about hover on top of a username, and it should tell u if the player is an User, Administrator or Moderator based on the LuckPerms group

#

It should display it as a hover text if u move ur mouse on the username in the chat

#

I’ll send the code I made

#

?paste

undone axleBOT
polar forge
#

This actually happens when I try the plugin (this code) it isn’t actually a hoverable text, the code placed it as an username, not as hover text

#

Here’s from the terminal

stiff sonnet
#
public ItemStackBuilder addLore(Component lore) {
            if (im.hasLore()) {
                im.lore().add(lore);
            }
            else {
                im.lore(Arrays.asList(lore));
            }
            return this;
        }

I'm using this to add lore to an item, but for some reason only the very last lore entry is actually visible on the item. Any idea what could be wrong? It's definitely entering the hasLore condition

lost matrix
stiff sonnet
#

.add shouldn't overwrite the lore though?

chrome beacon
#

also that's the Paper API

stiff sonnet
#

is it?

#

oh it is, whoops, will be asking paper then

lost matrix
compact haven
#

you need to send actual Components instead 😅

polar forge
#

Should I send it?

compact haven
#

sure

chrome beacon
#

You're never sending a message

polar forge
#

Which message

chrome beacon
#

hoverableMessage

polar forge
#

Could u please make an example? I don’t know where to place it

#

I’m stuck here since 5 hours :sob

chrome beacon
#

?

#

or if by example you mean write the thing for you then no

cedar current
#

What packets are needed to spawn a player?

#

(except for player info update and entity spawn)

lost matrix
#

Those two should od the trick

cedar current
#

turns out i had my locations and uuids messed up, thx 🙂

peak depot
#

what was the website for package naming reference?

cedar current
#

package or packet?

peak depot
#

packet

#

nah nvm nms im stupid

cedar current
#

oh yeah it doesn't have nms names i think

eternal oxide
#

?nms

peak depot
#

yeah there was a website with a wierd design and therse also a command for the website but i dont rember it

#

thanks

eternal oxide
#

or

#

?mappings

undone axleBOT
quaint mantle
#

When I call an event, a synchronous event, is it done on the same tick or is it called on next tick?

#
Bukkit.getPluginManager().callEvent(event);```
harsh echo
#

Build Tools failing to run

lost matrix
quaint mantle
#

Perfect

proven musk
#

is there any way to disable/check advanced tooltips on players

valid burrow
#

afaik

remote swallow
#

yes

earnest lark
#

how do i make a plugin that sends all packets recieved in chat

sullen marlin
#

That's a lot of packets

earnest lark
#

not rlly its for personal use

#

i am just testing a mod im developing and i need to see the packets but i cannot find a good tutorial on how to do this

young knoll
#

Sends them where

sullen canyon
#

any books recommendations for clean code/refactoring in java?

earnest lark
inner mulch
#

can i register permissions other than with the plugin.yml?

chrome beacon
proven musk
#

how would I change the result of a recipe

sullen canyon
proven musk
#

like make it so when you craft a wooden pickaxe it does my custom version

#

do I just have to remove and recreate it

chrome beacon
#

though the config.yml is the ideal way

chrome beacon
proven musk
#

is there a more sensible way

#

why cant I just set the result

chrome beacon
#

I mean have you tried modifying it

ivory sleet
#

since it puts canonical names and forms on common patterns in code

proven musk
chrome beacon
#

I mean mutating the ItemStack from getResult

proven musk
#

you can do that

#

hmmm

#

idk if that will work

chrome beacon
#

try it and see ig

proven musk
#

since the itemstack I want to set it to is one thats created with another method

#

unless theres a way to copy the value into it

lilac dagger
#

oh btw, if you do send them in chat, it'll cause a loop

earnest lark
#

just movement packets no chat packets

lilac dagger
#

then you can listen to the the moving packets

#

i don't know the names exactly, you will find them in protocollib

#

if you don't want to use nms you'll have to hook into netty, however it might be worse for you if you don't want to worry about version support

earnest lark
#

i dont think protocollib is updated to 1.20.4

chrome beacon
#

It is (get it on github)

earnest lark
twilit wharf
#

Lets say there are two players online. One is AFK, loading a set of chunks with entities in them. The other player, nearby, decides to fly off, deloading the entitys client side, but they are still loaded serverside (since the afk account is there). Is there an event or something I can use to track when that player unloads entities but the chunk remains loaded by anothe player?

tranquil glen
#

Not sure

#

You might be able to infer it by their distance?

young knoll
#

Maybe we should make events for that

#

I’ve seen it requested e few times :p

twilit wharf
#

It was mentioned on the forum

#

md_5 said it isnt being discussed currently (at least that is what he said 1 year ago)

eternal night
#

getting the PDC isn't. Getting the item meta you get the PDC from is meh

#

I mean, no ™️

#

its more of a "be smart about ItemStack#getItemMeta calls"

#

yea

#

like, if you can, don't call it twice

golden turret
#

i am using lombok in gradle, but when i run gradle javadoc the javadoc does not have any method (if i am using the @Getter, for example, the method is not on the javadoc). how can i fix it?

eternal night
#

save yourself a good amount of trouble and use the gradle plugin for lombok

#

configures lombok for you iirc and also properly setups delombok configurations needed for ^ javadoc and sourceJars

#

so you don't end up like bungeecord source jars OMEGALUL

golden turret
#

alright

#

thanks

eternal night
#

Specify the version to latest

#

that is about it

#

Yes

#

most are going to be fine ™️

#

shade is one of the ones where keeping it to latest is useful

eternal night
#

Is it? I could have sworn last time I used it ij was screaming at me that source and bytecode didn't match up

sullen marlin
eternal night
#

Oh yea, javadoc might

#

Are sources ?

sullen marlin
#

Not sure

#

Check and open a bug report;)

eternal night
#

😉

#

I'll check on it later

rocky quarry
#

Hi, I have this code to put a chest in the direction I want, but now I would like to keep the chest in the open position (i.e. have only the top of the chest open, like when a player open chest) but after searching I can't find anything )=

Block chestBlock1 = chestLocation1.getBlock();
        Chest chest1 = (Chest) chestBlock1.getState();
        chest1.getBlock().setData((byte) 3);
sullen marlin
#

What version

#

?jd

undone axleBOT
sullen marlin
#

Cast block state, call .open

#

Chest1.open()

rocky quarry
wet breach
#

This is why you should update

placid kraken
#

uhm

#

can you access shulker inventories from a itemmoveevent

#

or am i trippin and crazy

young knoll
#

Why wouldn’t you be able to

rough ibex
#

you can 🤡 all you want but 1.8 is dead

#

upgrade

eternal night
#

I think there is technically a maven plugin that handles that too? similar to gradle

#

dunno

#

not a ✨ maven ✨pro

young knoll
#

Just delombok the source itself

eternal night
#

results in this pretty picture

merry cove
#

why is it that when you cancel PlayerLeashEntityEvent it eats the lead?

#

unsure why that is built in ?

#

and how do I not do that lol

sullen marlin
#

Wdym eats the lead

wraith dragon
#

probably means the lead disappears

merry cove
#

yea, the lead disappears

#
    @EventHandler
    public void onLeash(PlayerLeashEntityEvent event) {
        Player player = event.getPlayer();
        ItemStack itemStack = player.getInventory().getItemInMainHand();
        if(itemStack.hasItemMeta() && hookHandler.isHook(itemStack)) { //Todo: the item vanishes.
            event.setCancelled(true);
        }
    }```
#

tried placing it back into the players inventory, but then he recieved two.

#

it's an odd ordeal the entire thing 😂

sullen marlin
#

From the inventory?

#

Open a bug report

#

?jira

undone axleBOT
tepid turret
#

Anyone know how to hide these messages?

[EntityLookup] Failed to remove entity EntityBoat['Birch Boat'/800, uuid='28bbf4fd-cddc-4bed-b693-b4ded6440cfe', l='ServerLevel[world]', x=636.62, y=63.00, z=-335.14, cpos=[39, -21], tl=0, v=true, removed=DISCARDED] by uuid, current entity mapped: null
potent ocean
#

add one

#

and then remove one

#

lmao

merry cove
#

can't release a plugin with that 😂

#

too embarassing

tepid turret
potent ocean
#

rather have a working version than a non working lol

potent ocean
tepid turret
#

Cool can i get the explaination then lols

potent ocean
#

Make a class that extends AbstractFilter (org.apache.logging.log4j.core.filter.AbstractFilter)

#

After that have a method where you can register the filter, should look something like this.

    public void registerFilter() {
        Logger logger = (Logger) LogManager.getRootLogger();
        logger.addFilter(this);
    }
#

and heres the rest

#
    @Override
    public Result filter(LogEvent event) {
        return event == null ? Result.NEUTRAL : isLoggable(event.getMessage().getFormattedMessage());
    }

    @Override
    public Result filter(Logger logger, Level level, Marker marker, Message msg, Throwable t) {
        return isLoggable(msg.getFormattedMessage());
    }

    @Override
    public Result filter(Logger logger, Level level, Marker marker, String msg, Object... params) {
        return isLoggable(msg);
    }

    @Override
    public Result filter(Logger logger, Level level, Marker marker, Object msg, Throwable t) {
        return msg == null ? Result.NEUTRAL : isLoggable(msg.toString());
    }

    private Result isLoggable(String msg) {
        if (msg != null) {
            if (msg.toLowerCase().contains("filtered string")) {
                return Result.DENY;
            }
        }
        return Result.NEUTRAL;
    }
#

"filtered string" should be whatever you don't wanna have logged

tepid turret
#

wow bro really just made it for me

#

so that would be [EntityLookup] ? yes

potent ocean
#

yeah

tepid turret
#

then i call this how?

potent ocean
#

if (msg.toLowerCase().contains("[entitylookup]")) {

potent ocean
tepid turret
#

does it take every single message?

potent ocean
#

it checks every single message

#

if it contains that string

#

it wont log

tepid turret
#

if its something sent in chat?

#

or no

potent ocean
#

don't think so

tepid turret
#

cool thanks 👍

#

bro really just spoonfed me a whole porridge

#

and im not complaining

tepid turret
# potent ocean don't think so

Not working???

    private Result isLoggable(String msg) {
        if (msg != null) {
            if (msg.toLowerCase().contains(" warn]: [entitylookup]")) {
                return Result.DENY;
            }
        }
        return Result.NEUTRAL;
    }
@Override
    public void onEnable() {
        // Plugin startup logic
        plugin = this;
        new Filter().registerFilter();

Filter is the name of the class

potent ocean
#

warn isnt actually IN the log

#

its just the message

#

so check if it contains

#

[entitylookup]

tepid turret
#

trying now

#

still appearing

#
    private Result isLoggable(String msg) {
        if (msg != null) {
            if (msg.toLowerCase().contains("[entitylookup]")) {
                return Result.DENY;
            }
        }
        return Result.NEUTRAL;
    }
#
package me.assailent.advancedboating.Utils;

import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.Logger;
import org.apache.logging.log4j.core.filter.AbstractFilter;
import org.apache.logging.log4j.message.Message;
import org.bukkit.Bukkit;

public class Filter extends AbstractFilter {
#

imports and line of class

#

org.bukkit.Bukkit is unused

potent ocean
#

make it "Failed to remove entity"

tepid turret
#

Trying

#

Works thanks

proven musk
#

will empty stacks always be a stack of air or will they be null

#

like if im using Inventory.getItem

potent ocean
#

i believe

proven musk
#

ok

#

inve been lied to

#

is there no easy way to tell if an itemstack is empty?

#

is there seriously not a method for this

tender shard
#

We need a guide to TAPER from maven to gradle

#

Slowly

quiet ice
#

TAPER?

placid kraken
#
   
@EventHandler
    public void onInventoryMove(InventoryMoveItemEvent event) {
        Inventory source = event.getSource();
        ItemStack transferredItem = event.getItem();

        if (isHopperInventory(source)) {
            if (transferredItem != null && isShulkerBox(transferredItem)) {
                BlockStateMeta meta = (BlockStateMeta) transferredItem.getItemMeta();
                if (meta != null && meta.getBlockState() instanceof ShulkerBox) {
                    ShulkerBox box = (ShulkerBox) meta.getBlockState();

                    for (ItemStack itemStack : box.getInventory().getContents()) {
                        if (itemStack != null) {
                            if (itemStack.getType() == Material.DIRT) {
                                Bukkit.broadcastMessage("Removed: " + itemStack);
                                itemStack.setAmount(0);
                                box.update();
                                Bukkit.broadcastMessage("It's air now!: " + itemStack);
                            }
                        }
                    }
                }
            }
        }
    }


    private boolean isHopperInventory(Inventory inventory) {
        return inventory.getHolder() instanceof org.bukkit.block.Hopper;
}

i know this looks shit, but why doesn't this update the shulkers inventory when moved from hopper, im losing my mind bc its not clearing it lmao

tepid turret
#

iirc

proven musk
#

nope

#

sometimes its air

#

I made my own method

tepid turret
#

ohp cool

proven musk
#

its very weird I have to imo

#

ItemStack.isEmpty() pls

tepid turret
#
for (int i = 0; i < 27; i++) {
            if (inventory.getItem(i) == null) {
                ItemStack itemStack = ItemStacks.createItemStack(items.getConfigurationSection("empty_item"), p);
                ItemMeta itemMetas = itemStack.getItemMeta();
                itemMetas.getPersistentDataContainer().set(unclickable, PersistentDataType.BOOLEAN, true);
                itemStack.setItemMeta(itemMetas);
                inventory.setItem(i, itemStack);
            }
        }

is functional for me

proven musk
#

inventory.getItem is null ig

#

but the cursor is air

#

very weird

tepid turret
#

yea idk

#

Inventory#getItem() return an ItemStack

#

so

#

ItemStack#equals(null);

#

whould work

proven musk
#

.equals(null) isn't a thing

#

if something is null it wont have an .equals functions

tepid turret
#

inventory.getItem(i).equals(null);

#

.equals is null safe

proven musk
#

my ide says it will always return true idk

tepid turret
#

intellij?

proven musk
#

ya

tepid turret
#

cuz mine says its fine

#

if (inventory.getItem(i) == null)

#

it prefers it to be that

proven musk
tepid turret
#

but
if (inventory.getItem(i).equals(null))

tepid turret
proven musk
#

12

tepid turret
#

weird

#

and im going to assume the inventory is bigger than 1 row?

proven musk
#

it works btw

#

but yes

#

i dont think intellj would know if it wasn't tho

tepid turret
#

maybe intellij remaps it?

#

or its the java version

proven musk
#

idk

#

it would be weird to me if .equals works on a null reference

tepid turret
#
        boat.getPersistentDataContainer().remove(keys.getEmpty());
        boat.getPersistentDataContainer().remove(keys.getClaimedKey());
        boat.getPersistentDataContainer().remove(keys.getNameKey());
        boat.getPersistentDataContainer().remove(keys.getOwnerKey());
        boat.getPersistentDataContainer().remove(keys.getStowedKey());
        boat.getPersistentDataContainer().remove(keys.getIdKey());

Is this syntax wrong or something

#

because they dont seem to be getting removed?

glad prawn
#

boat?

tepid turret
#

Entity boat;

tepid turret
placid kraken
#

literally i got everything my only problem is basically removing the item or really accessing the actual shulker inventory

#

idk why it's not removing anything 🤷‍♂️

tepid turret
#

i'd just get the inventory data and clear that

#

or just copy it and drop the inventory

placid kraken
#

well i was originally doing that, but im doing an item to test it now

#

it just wont update the inventory when it leaves the hopper/basically at the end of the event

#

originally was doing box.getInventory().clear(); and it just wasn't working

merry cove
sullen marlin
#

?jira

undone axleBOT
rough drift
#

can you convert PDC to a byte array

#

I don't see it implementing serializable so I guess not?

tepid turret
#

I'm making a boat stow/claiming plugin
Stowing serializes the boat as string and stores it in an SQL database then removes it.
When the boat is unloaded by the server
(Or unaccessable from World#getEntitiesByClass(Boat.class) )
I want the boat to be automatically stowed.

    @EventHandler
    private void stowOnUnload(EntitiesUnloadEvent e) {
        if (e.getEntities().isEmpty()) {
            return;
        }
        for (Entity entity : e.getEntities()) {
            if (!(entity instanceof Boat || entity instanceof ChestBoat)) {
                continue;
            }
            if (entity.getPersistentDataContainer().get(keys.getClaimedKey(), PersistentDataType.STRING) == null) {
                continue;
            }
            boatUtilities.Stow(Bukkit.getPlayer(entity.getPersistentDataContainer().get(keys.getClaimedKey(), PersistentDataType.STRING)), entity.getPersistentDataContainer().get(keys.getIdKey(), PersistentDataType.INTEGER));
        }
    }
#

that is my code but it fails tow ork.

#

to work*

quaint mantle
#

hmm what does not work, did you try to debug through?

smoky anchor
#

make some temp vars from the pdc, this last line is hard to read.

#

also, Stow is probably a function and if you're trying to follow the conventions it should strat with s
Are you storing the "owner" by player name ? If so, don't. Those change, use player UUID instead.

tepid turret
#

or messages sent to the player

tepid turret
#

Bukkit.getPlayer(String uuid)

#

iirc

#

nvm thats not how it works

#

converting String to uuid then running that

smoky anchor
smoky anchor
tepid turret
tepid turret
smoky anchor
#

just convert string to UUID, it's just one call

tepid turret
#

getPlayerFromUuid()

tepid turret
smoky anchor
smoky anchor
tepid turret
#

lmfao

smoky anchor
#

UUID.fromString(...) is too hard to write ?

tepid turret
#

yes

#

especially because my calls r already long and im making mess spaghetti code for testing

#

line from testing

#
Player p = Bukkit.getPlayer(UUID.fromString(entity.getPersistentDataContainer().get(keys.getClaimedKey(), PersistentDataType.STRING)));
smoky anchor
#

as I said, make variables

tepid turret
#

thats one of the small lines

smoky anchor
#

call it player, not p -> use descriptive names
split it the fuck up then
UUID playerUUID = ...;
and then get the player.

tepid turret
#

Long one from old testing (just seeing if the checks would function

if (entity.getPersistentDataContainer().has(keys.getClaimedKey()) && Objects.equals(entity.getPersistentDataContainer().get(keys.getClaimedKey(), PersistentDataType.STRING), p.getUniqueId().toString())) {
tepid turret
#

i have descriptive names for most things

#

except
players
events
exceptions

smoky anchor
#

sure, your code
But it is not descriptive
People have been yelled at for using e for events
(totally not me nu-uh)

tepid turret
#

player = p
events = e
exceptions = ex

tepid turret
quaint mantle
tender shard
#

why not just pass an UUID instead

tepid turret
tender shard
#

it got "hard" in its name

icy beacon
tender shard
#

why does everyone ignore the HARD disks

quaint mantle
tender shard
#

thank you!

smoky anchor
#

"There are only three hard things in Computer Science: cache invalidation, naming things, off-by-one errors and HARD disks"
-steve6472

There, hopefully includes everything.

tender shard
#

"There are only three hard things in Computer Science: cache invalidation, naming things, off-by-one errors and HARD disks"
~~ mnalex
~~ -steve6472

smoky anchor
#

XD

tender shard
#

stupid discord breaks wikipedia's ~~~~ quote formatting

smoky anchor
#
- mnalex
+ steve6472```
#

how do git formatting ree

tender shard
#

result: a baby?

tender shard
#

with ``` diff

smoky anchor
#

yeye, im dum

tender shard
#

IIRC unsing normal bash formatting int can also properly display all color codes

quaint mantle
#

discord's new font for code formatting made me confused a bit

tender shard
#

how id it prevoiously look? I'm on canary on both mac and windows and haven't noticed a new font

valid burrow
lost matrix
tender shard
#

can someone show a before/after pic?

#

to me it still looks like this on both mac and windows

lost matrix
lost matrix
valid burrow
tender shard
#

no difference

#

an someone who got the new font show a screenshot pls

dawn flower
#

what's the difference between Chunk#load and Chunk#setForceLoaded

tender shard
#

load loads it right now and then... it might unloaded anytime again

#

setForceLoaded makes it kept loaded

dawn flower
#

i dont want it to be unloaded

#

so setForceLoaded it is

tender shard
#

can't you use chunk tickets?

#

what's your version?

dawn flower
#

1.20.4

#

what r chunk tickets

dawn flower
#

oo

tender shard
# dawn flower what r chunk tickets

it's like setForceLoaded but different plugins can "add to it", the nit only gets get unloaded when all other plugins have removed their chunk ticket again too

dawn flower
#

good shit

tepid turret
#
                try {
                    p.playSound(p.getLocation(), Sound.valueOf(soundNms), volume, pitch);
                } catch (IllegalArgumentException e) {
                    Bukkit.getLogger().warning("Sound " + soundNms + " does not exist!");
                }
#

returns

#
[20:49:40 WARN]: Sound entity.allay.item_taken does not exist!
[20:49:40 WARN]: Sound block.enchantment_table.use does not exist!
#

soundNms = entity.allay.item_taken

#

and

#

block.enchantment_table.use

#

which both exist with /playsound

lost matrix
#

valueOf matches an Enum constant with a String. This only works if the String is identical to the Enum value.

tepid turret
#

So like with the command

/playsound block.enchantment_table.use

how do i get
BLOCK_ENCHANTMENT_TABLE_USE
from
block.enchantment_table.use

lost matrix
#

Those keys are used in registries. You need to construct a NamespacedKey and get the Sound from the sound registry.

#
    NamespacedKey soundKey = NamespacedKey.minecraft(soundName);
    Sound sound = Registry.SOUNDS.get(soundKey);
tepid turret
#

ohh gotchu

tepid turret
#

or is it the Register.SOUNDS.get(soundKey)

lost matrix
#

The registry will return null in that case

dawn flower
#
Set<Chunk> chunks = new HashSet<>();
int minX = Math.min(location1.getBlockX(), location2.getBlockX());
int maxX = Math.max(location1.getBlockX(), location2.getBlockX());
int minZ = Math.min(location1.getBlockZ(), location2.getBlockZ());
int maxZ = Math.max(location1.getBlockZ(), location2.getBlockZ());
for (int x = minX; x < maxX; x++) {
  for (int z = minZ; z < maxZ; z++) {
    Chunk chunk = new Location(location1.getWorld(), x, 0, z).getChunk();
    chunk.addPluginChunkTicket(this);
    chunks.add(chunk);
  }
}```
this aint no work
obsidian drift
#

Is there any good way of removing an entity when it is unloaded from the world? I tried removing on EntitiesUnloadEvent but for some reason EntitiesUnloadEvent#entities doesn't contain all the entities in the unloaded chunk?

vital sandal
#

this should launch people upward right ?

#

but in my case it didn't :l

dawn flower
#

don't cast it to player

#

and try normalising the vector

tender shard
tender shard
tender shard
ivory sleet
#

It should

tender shard
#

is the player maybe a passenger of another entity or sth

lost matrix
# dawn flower ```java Set<Chunk> chunks = new HashSet<>(); int minX = Math.min(location1.getBl...

You are essentially adding 256 chunk tickets per chunk with this. The X and Z of a chunk are vastly different thatn the X and Z of a Block.
A chunk contains 16x16 blocks, each block having a different X and Z while the chunk has the exact same X and Z still.
You can get the Chunks between two locations using a BoundingBox and my new World method: 😊

  public void loadChunksBetween(Location locA, Location locB) {
    World world = locA.getWorld();
    BoundingBox box = BoundingBox.of(locA, locB);
    world.getIntersectingChunks(box).forEach(chunk -> {

    });
  }

Or you can manually calculate them using

  public void loadChunksBetween(Location locA, Location locB) {
    int minX = Math.min(locA.getBlockX(), locB.getBlockX()) >> 4;
    int maxX = Math.max(locA.getBlockX(), locB.getBlockX()) >> 4;
    int minZ = Math.min(locA.getBlockZ(), locB.getBlockZ()) >> 4;
    int maxZ = Math.max(locA.getBlockZ(), locB.getBlockZ()) >> 4;

    World world = locA.getWorld();
    for (int x = minX; x <= maxX; x += 16) {
      for (int z = minZ; z <= maxZ; z += 16) {
        Chunk chunk = world.getChunkAt(x, z);
        
      }
    }
  }

The >> 4 is equivalent to / 16

tender shard
tender shard
dawn flower
#

ic

tender shard
#

to me the code looks good and should work

lost matrix
# vital sandal

Add a debug statement and check if this method is even called. This should launch the player way up into the sky

tender shard
#

this

#

5 = 5 meters per second squared= should be like 50 blocks high after a few secs lol

dawn flower
vital sandal
young knoll
#

Try lower values

dawn flower
#

if i have a loaded chunk with no players in it and this animation is playing then it always returns the dying mob

#

if that doesn't make sense i basically killed the mob and instantly did /suicide and getting the nearest entity to that location returns the dying mob (the chunk has a ticket)

tender shard
#

I'm not really understanding what the issue/question is

dawn flower
#

i suck at explaining

#

basically spawning mobs in ticketed chunks that are supposed to not be loaded (aka have no players) doesn't really spawn them

#

also if a ticketed chunk has a dying mob and the chunk has no players then the dying mob never disappears and getting nearest entity at the dying mob's location returns the dying mob

#

i found Chunk#isEntitiesLoaded() this might be doing something

tepid turret
#

Saving lists in persistent data type?

dawn flower
#

PersistentDataType.LIST

tepid turret
#

Yea but what does this store to?

#

Likst

#

String example = entity.getPersistentDataContainer().get(keys.getExampleKey, PersistentDataType.STRING)

#

what type does it return?

dawn flower
#

a list is a list of objects iirc

tepid turret
#

cool

dawn flower
tepid turret
#

yes

#

yea

#

thats what its meant to do

#

isnt it

#

before i set it

#

entity.getPersistentDataContainter().set(keys.getExampleKey, PersistentDataType.STRING, "wahtever")

dawn flower
#

what r u trying to do?

tepid turret
#

So basically its a boat upgrade plugin

#

so this would be where the boat stores what upgrades it has

#

(it has to be stored on the entity)

dawn flower
#

ic

#

if all upgrades r the same but some boats cant be upgraded to a specific level, for example boat 1 can be upgraded 3 times but boat 2 can be upgraded 5 times then just store the upgraded boat stats and save how many times that boat can be upgraded in the pdc

lost matrix
#

I would recommend implementing a custom PersistentDataType<BoatData, T> which stores the entire object
at once, instead of tinkering with the default PDC types which are mainly used for trivial single values.

tepid turret
#

Is BoatData a class in that instance?

#

or?

dawn flower
#

boatdata is a custom class that u make

tepid turret
#

thats what i was asking :)

#

But then im assuming the boat data class would have getters in it or???

lost matrix
#

I assumed that you have a structure which loads your data from a PDC into a proper class and then stores it in a manager.
Eg

public class CustomBoatManager {
  private final Map<UUID, BoatData> liveBoatData;
}

When a boat is spawned, you load its data from a PDC into a BoatData instance and add it to the Manager with the Boats UUID.
Then when its unloaded, you remove the BoatData from the Manager and store it back into the PDC of the Boat.

tepid turret
#

No

#

basically all the data from the boats when its spawned is stored directly in PDC

#

and then it gets serialized into a string when despawned and saved to a databse

#

spawning it just deserializes that string and makes an exact carbon copy

lost matrix
#

You should prefer concrete class implementations over tinkering with random data in PDCs or Config files

tepid turret
#

Right but how would I do that?

lost matrix
#

PDC = PersistentDataContainer
It should be used as a persistent medium where possible.
If you use a Database already, then the PDC is kinda useless to you.

tepid turret
#

Basically the database is just a table

#

player | boat1 string | boat2 string | boat3 string

#

where boat(number) string is the serialization of the entity

#

the db is only storing the entity

#

no other data

#

(This is so players can easily trade spawned boats)

lost matrix
lost matrix
# tepid turret No because the way the database works.

You need more tables:
For your players

| UUID | BoatID | BoatID | ...
| UUID | BoatID | BoatID | ...
| UUID | BoatID | BoatID | ...

Then for the boats:

| Boat ID | BoatData |
| Boat ID | BoatData |
| Boat ID | BoatData |

Then you can simply move the BoatID between players.

tepid turret
#

not a thing?

lost matrix
#

What do you mean by that? What is not a thing.

tepid turret
tepid turret
lost matrix
#

It was...

smoky anchor
#

oh the bot died

tepid turret
#

nvm bot is just ded

ionic thicket
#

bruh

#

i'll just check it in older messages, sorry for interrupting

tepid turret
#

all g

#

we're talking abt pdc anyways

lost matrix
tepid turret
#

that seems like more pain to me

#

than whatever tf it is i got going on.

tender shard
#

?timer

#

@lost matrix is there a timer / remindme rcommand avalable?

tepid turret
lost matrix
#

What do you mean by "make UUIDs"
For the players you use their UUID and for Boats you can use their UUID. They both already have an assigned UUID.

tender shard
#

bot not dead, see:

#

?help

lost matrix
#

F

tepid turret
#

💀

tender shard
#

ok you're right

#

bot dead

#

lmao

tepid turret
tender shard
#

i have given worse advices here, trust me

tepid turret
#

?

#

wait sql supports hashmap or no

#

no

#

😭

#

serialize hashmap as string?

#

then deserialize it on usage?

lost matrix
#

What hashmap?

tepid turret
#

for boatdata

lost matrix
#

The map never gets serialized

tepid turret
#

U can store directly?

lost matrix
#

Only the values in your map

ionic thicket
#

can i put a pdc on an entity too? or just for itemstack ?

tepid turret
tepid turret
#

So

#

just in plain text

ionic thicket
#

well if he saw my plugin he would obliterate me out of the server

#

i'd get banned from Spigot itself

tepid turret
#

same but he is seeing it

#

| Assailent (Player) | 141490129414901490 (Boat uuid) | ...

#

then in boat table

#

|14141491241840 (boat uuid | ????? | ...

#

waht goes in ????

lost matrix
tepid turret
#

Wdym FishHook is the most important

#

why is it not red

ionic thicket
slender elbow
lost matrix
tepid turret
#

oh wait

#

ur asying

#

just get the data off of the physical boat

tender shard
tender shard
#

stored in an AbstractHorses' PDC

tepid turret
#

honestly probably safer than most crypto currencies

tender shard
#

true

tepid turret
smoky anchor
#

Is the abstract horse invincible tho ?

eternal oxide
tender shard
tender shard
#

if you somehow manage to acquire an ABstractHOrse instance that's not instance of anything else, it'd just throw NoSuchMethodError or whatever if you wanna damge it

smoky anchor
#

lmao

tender shard
#

it's like Thorns, but in code

#

"you wanna damage me bro? Nah, your code will fail instead"

#

IIRC not even kotlin allows constructing instances of abstract classes or interfaces unless ofc you just make up an anon class

#

but the anon class would have to override all abstract methods so that obv doesnt count

native ruin
#

Is it possible to store a bucket runnable or lambda specific behavior (the run method)

blazing ocean
slender elbow
#

just store the lambda in a variable? lol

blazing ocean
#

or just create a seperate function

#

i don't understand what they are trying to do here

native ruin
#

Hold on I'm thinking

icy beacon
#

?paste

#

cafebabe rly is dead

blazing ocean
spare prism
#

hello. im trying to make a system that would allow players to open shulker boxes in their inventory without placing them. it works and items get put into shulker boxes, however after I open a shulker like that once, I have a visual bug that my inventory doesn't get updated when I pickup items from ground. but if i open a shulker like that again, the inventory gets updated. how can i fix that?
code: https://pastebin.com/tw9T12kW

native ruin
blazing ocean
#

what do you want to persist

#

the GUIs?

native ruin
#

The behavior of the lambda

blazing ocean
#

you need a config/db for that

blazing ocean
icy beacon
#

if you parse your lambda from a set of instructions, save the instructions and parse them on startup

blazing ocean
#

^^

native ruin
#

Holy fuk, no way I didn't think of that

#

Thanks

quaint mantle
#

Quick showcase of a simple anti-cheat I made (still working on it)
(I've never used spigot before so it took me about 6 hours because I didn't wanna learn it lol)
I’ve never used or even learned Java,
So I feel like learning it by myself (no I didn’t to a tutorial idk I can’t. I haven’t learned any of the languages, I’m self taught lmao) in less than prolly 3 hours is pretty good

The reach is a little bit far because it only counts per block reach when the player could be slightly farther on a block and get falsely flagged

Basically everything besides inventory movement is just casting a ray from the players eyes and seeing if it hits the target

quaint mantle
rough drift
quaint mantle
rough drift
#

Also, there is a limited reach for survival/creative

#

with some extra to account for ping

quaint mantle
#

Wdym

rough drift
#

i.e. the server has a max reach, with a tiny bit of extra to account for lag

quaint mantle
#

Ohh yeah lol

quaint mantle
#

Idk that was a dumb question

rough drift
quaint mantle
quaint mantle
#

I don’t keep up with updates much lol

rough drift
#

an attribute

#

generic.max_reach iirc

quaint mantle
#

Ah so I should probably make it check for the servers max reach

#

But it has a config

#

I forgot to show it tho

rough drift
#

get the attribute of the player and use that

quaint mantle
#

But it’s like

#

Ya

#
actions:
     Reach:
          - “sendMessage: Potential Cheating”
#

Something like that

#

Actually almost exactly like that

#

Well I’m on vacation right now

#

lol

#

So I’ll cya!

gloomy onyx
#

H

river oracle
#

I

eternal oxide
#

T

ionic thicket
#

how to get persistent data container value of key:"x"

river oracle
#

The bots still down

#

One seck d

ionic thicket
#

i have seen this post somehting like 17 times

river oracle
river oracle
ionic thicket
#

you are right. thank you, i'm gonna check again

fringe yew
#

can you \n when you're sending a chat message?

river oracle
#

Aldo it's /n btw

fringe yew
#

you could just give me a yes or no?

river oracle
#

I'd lean towards no but I'd say their is a possibility

fringe yew
#

thank you

river oracle
fringe yew
#

alr

rough ibex
#

\n

river oracle
#

Fake programmer :<

blazing ocean
#

lol

fringe yew
#

lmao

blazing ocean
#

make it so you can do that then!

quaint mantle
#

how can i use raycast to damage all entities in the player's direction upto 10 blocks?

chrome beacon
#

Create multiple rays

#

When the first ray hits, create a new ray that ignored the hit entity

#

and keeps going until the next one

proud badge
#

Does # Text work in a resource's description? (to make the text larger, like in github)

gentle nexus
#

is there a way to add like an int value to a item stack which doesnt change the appearce of the item but it can be read by my code ?

gentle nexus
#

persistant data container ?

shadow night
#

Yee

gentle nexus
#

itemstack.getpdc.set(thatkey,type,value);
or will it save to the item meta

proud badge
#

damn its been like 30 mins since enabling 2fa yet im still getting this button

worthy yarrow
#

?pdc

#

Ok guess I’ll go fuck myself

short plover
#

rip cafebabe 😢

worthy yarrow
#

Spigot bot died ig

worthy yarrow
worthy yarrow
proud badge
proud badge
#

hi.

glad prawn
worthy yarrow
#

Idk why ?pdc giving me issues 😦

polar forge
#

Hi guys, could anyone help me? I’m making a Hover Username plugin and I would need help in TextComponents and mini messages

worthy yarrow
rapid vigil
polar forge
worthy yarrow
#

That’s so sad

worthy yarrow
polar forge
#

I don’t have prefixes nor suffixes

#

Just the username

#

U put ur mouse on top of a player’s username and u see some info about the player

#

That’s what I want to do with player.hasPermission

worthy yarrow
#

uhhhh

polar forge
#

Should I send the code I made till now?

worthy yarrow
#

iirc then you're going to intercept the chat event, and manipulate it based on the permission

polar forge
#

They told me I need to place some TextComponents and miniMessages

#

But I don’t know

quaint mantle
#

intercept the chat event

worthy yarrow
#

so if player.hasPermission("x") -> replace their message with what you want, ie: textComponent for the username to make it hoverable, then just put the rest of their message

#

you'll have to build the textcomponent to do what you want

#

but hoverables aren't that bad

worthy yarrow
#

Hoverable is apart of textComponent

#

pretty sure

polar forge
#

Yes but it does not need to replace anything

quaint mantle
#

it does

#

replace the plain username with the hoverable username

worthy yarrow
#

You have to manipulate the message in order to make the username with a hoverable attached to it

polar forge
worthy yarrow
#

the actual message the player sends doesnt change rather the format if you will

polar forge
#

It dosnt need to change

worthy yarrow
#

Yes it does

#

because you need to add a hoverable to the username

polar forge
quaint mantle
worthy yarrow
#

^

polar forge
#

How do I do that? If I may ask

#

Ok but in the example

#

They show it on a message

#

Not on an actual username

blazing ocean
#

let's go adventure bukkit

quaint mantle
#

true

#

watch this

polar forge
#

It’s on a message

#

Not on username

worthy yarrow
#
@EventHandler
    public void onPlayerChat(AsyncPlayerChatEvent event) {
        Player player = event.getPlayer();
        String playerName = player.getName();
        String message = event.getMessage();

        // Create a TextComponent for the player's username
        TextComponent usernameComponent = new TextComponent(playerName);
        usernameComponent.setColor(ChatColor.AQUA);
        usernameComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new BaseComponent[]{new TextComponent("Click to view player information")}));

        // Create a TextComponent for the message
        TextComponent messageComponent = new TextComponent(": " + message);
        messageComponent.setColor(ChatColor.WHITE);

        // Combine both components
        usernameComponent.addExtra(messageComponent);

        // Send the chat message
        event.setCancelled(true); // Cancel original message event
        getServer().broadcast(usernameComponent);
    }```
This may be ai generated but it's uh followable... there are some things that I would do differently, but from what I see this should work fine
polar forge
worthy yarrow
#

no, the hoverable is a part of that

#

The textComponent is how you're going to define the hoverable on the {userName}

quaint mantle
polar forge
#

I don’t really know how to implement it into my code

#

Bc it’s kinda different than mine

quaint mantle
#

username isnt an object its a string retrieved from player.getName(); method

polar forge
worthy yarrow
#

Username you can get from the event

quaint mantle
#

add them

#

you have the player object

#

add the line to extract the player's name

worthy yarrow
#

since you have the player object, you just player.getname

polar forge
#

I have Player player = event.getPlayer();

quaint mantle
#

man

polar forge
#

I should change it into event getname right?

worthy yarrow
#

right so now player.getName, retrieves the name of the player

#

no

#

You have the player object

#

you just need a new line that extracts the name

#

ie:

polar forge
#

So I should change it into player.getname?

quaint mantle
#

no

#

use the object to extract the name

worthy yarrow
#

String someName = player.getName;

polar forge
#

So I need to make a new string?

#

Like this: String p = player.getname?

quaint mantle
worthy yarrow
#

If it needs to be constant within that method yes, which i believe it does in your case

worthy yarrow
#

Otherwise when you already have the player object, most times you can just include player.getName, instead of making a new string object. But in your case I think the playerName should be a constant within the method

quaint mantle
#

you can even just String playerName = event.getPlayer().getName(); if you wont use the player object again

#

which is not the case

worthy yarrow
#

Usually you'll want the player object before you derive the name but thats more dependent on the event used

polar forge
quaint mantle
#

thats good

worthy yarrow
#

That will be fine

polar forge
#

Ok, now we need to add the actual textcomponent

worthy yarrow
#

Just follow the snippet, cuz I mean it's not bad just uh different

polar forge
#

Let’s make an update of the code

#

?paste

#

Oh

worthy yarrow
#

yeah bots dead

polar forge
#

It’s the listener class

#

Hi Ned

proud badge
#

also @polar forge why are you uploading a new resource every time you make a new update instead of updating the current one?

polar forge
worthy yarrow
#

It'd be pretty dumb if you couldn't haha, imagine needing to upload a new source every patch/update 💀

polar forge
#

Yea kinda annoying tbh

#

But let’s go further

#

So

#

I now need to add the textcomponent

polar forge
#

I’ll just follow the Example of ChatGpT

quaint mantle
#

he then uses pluginmanager to download it from spigot and test the code

polar forge
#

Yea

quaint mantle
#

i wouldnt have the patience

polar forge
quaint mantle
#

doing all this each time i update a line of my code

#

spigot isnt a version control platform

#

you could just build it and drag the jar in your server's plugins folder

#

instead of uploading each time

#

idk how md_5 feels about his storage being used like this 😭

polar forge
quaint mantle
#

just run the server locally

polar forge
#

That’s what I did yesterday when u told me

quaint mantle
#

when you change the code you click on the green run button on intellij idea

polar forge
#

So, it’s not something I’m not totally doing

quaint mantle
#

it will build a new jar, you go to the target folder and get the compiled jar, move it to the local server

polar forge
#

Yea that’s what I do

#

But let’s go further with TextComponents

clear elm
#

hey i copied an tutorial to make an 2nd config but my problem is that the 2nd config loads but is empty here are the code:

polar forge
#

So do I need to add the textcomponent to the end of the code or at the beginning?

#

I think at the end

clear elm
polar forge
clear elm
#

prob i can help what it the problem

polar forge
#

Hoverable Username

#

If u put ur mouse on top of an username u would get some info of the username

#

HoverText/hovermessages

clear elm
#

ah you mean in the chat?

#

if yes i cant help :/

polar forge
#

Yea

#

Rip

clear elm
#

do you think u can help me?

polar forge
#

Nop

#

Too difficult to me

#

Never did something with config

clear elm
#

:/

vast ledge
clear elm
vast ledge
#

Use ?paste for code please

#

?paste

quaint mantle
polar forge
vast ledge
#

The bot died?

clear elm
#

?paste

vast ledge
#

Beuhhh

quaint mantle
clear elm
#

how can i use it

polar forge
quaint mantle
quaint mantle
polar forge
#

^^^

clear elm
#

how can i send it from there

vast ledge
#

Sec egitto

polar forge
#

Sure Bad, take ur time

quaint mantle
polar forge
#

Then press save and send the link

clear elm
polar forge
#

The first one I would guess is a main class

clear elm
#

main the first class the 2nd

vast ledge
#

Sorry @polar forge taking a bit longer, broke my os

polar forge
#

Take ur time

vast ledge
#

Always surprises me how easily I can break things

polar forge
#

lol

vast ledge
#

Idk assaulted my fstab

quaint mantle
#

oh unix based os

vast ledge
#

as i was saying

#

i havent fully fixed it but i can use one monitor

polar forge
#

Noice

vast ledge
#
component = new TextComponent("ERROR - Missing Partition");
component.setHoverEvent(new HoverEvent(HoverEvent.Action.-, TextComponent.fromLegacyText("Text")))
player.spigot().sendMessage(component)
#

Theres the basic jist of it

polar forge
vast ledge
#

Yea, with your Text

polar forge
#

But my text differs from what ur permission is

vast ledge
#

wdym?

polar forge
#

Based on player.hasPermission()

vast ledge
#
TextComponent comp = new TextComponent(event.getMessage());
String hoverMessage = ChatColor.WHITE + "User";
if (player.hasPermission("moderator")) {
  hoverMessage = ChatColor.AQUA + "Moderator";
} else if (player.hasPermission("admin")) {
  hoverMessage = ChatColor.RED + "Administrator";
} else if (player.hasPermission("wood")) {
  hoverMessage = ChatColor.YELLOW + "Wood Kit";
} else if (player.hasPermission("wood-mod")) {
  hoverMessage = ChatColor.AQUA + "Moderator";
} else if (player.hasPermission("stone")) {
  hoverMessage = ChatColor.YELLOW + "Stone Kit";
} else if (player.hasPermission("stone-mod")) {
  hoverMessage = ChatColor.AQUA + "Moderator";
}
comp.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(hoverMessage)));
player.spigot().sendMessage(comp);
blazing ocean
polar forge
vast ledge
blazing ocean
#

ah lol

polar forge
#

Yea I always use if else

#

Else if*

blazing ocean
#

don't🙏

polar forge
blazing ocean
#

readability

polar forge
#

Oh

blazing ocean
#

but honestly i prefer kotlin when

polar forge
#

I think else if is more readable

#

And more schematically ordered

blazing ocean
#

it isn't

#

switch also orders it and is faster