#help-development

1 messages ¡ Page 1711 of 1

quaint mantle
#

records are so ugly

trail remnant
#

uh sort of?

ivory sleet
#

Why cache it?

#

its already cached

trail remnant
#

i just did what they told me to do 🤷‍♂️

quaint mantle
#
public record A(String name) {}

public class A {
    private final String name;

    public A(String name) {
        this.name = name;
    }

    public String name() {
        return name;
    }
}
quaint mantle
ivory sleet
#

the config values ofc

#

they're cached with an underlying linkedhashmap

trail remnant
quaint mantle
#

But getting spoonfed does not help you either

ashen flicker
#

You need to understand what an instance is. I’ll try to explain but you really should learn Java basics before getting into plugins. Because what you’ll realize is spigot is just an API, if you already know Java, you only have to figure out spigot, and spigot itself really isn’t that hard. It just requires some memorization. Every time a class is called as in “new classname” and instance of that class is made. A class is sort of like a blueprint for an object. If you call to your main class in other classes, but don’t reference a specific instance. Each main class you’re calling to will be different. Yea that’s probably not a great explanation

quaint mantle
#

plugin.yml is invalid

trail remnant
quaint mantle
#

No using your mind is spoonfeeding

native nexus
#
public class HuskyEssentials extends JavaPlugin {

    @Override
    public void onEnable() {

        Registries.Register(this,
                HomeManager.class,
                SpawnManager.class,
                WarpManager.class
        );

        Registries.Deserialize();
        Registries.Log(this);
    }

    @Override
    public void onDisable() {
        Registries.Serialize();
    }
}
``` Clean main class uwu
ivory sleet
#

C# !

ashen flicker
#

IIn a nut shell, if you don’t learn Java you’re gonna be asking questions in here constantly that don’t relate to the spigot api. It will be harder for you to make plugins.

trail remnant
ashen flicker
#

It’s not overkill it’s OO programming

trail remnant
#

i know basic java

native nexus
ivory sleet
#

Though ABK I'd strongly advocate to practice your self teaching skill

ashen flicker
#

I thought I knew basic Java until I actually took a course online. I realized I was wrong.

ivory sleet
quaint mantle
#

You forgot to invoke the initialzeEconomy method

trail remnant
#

so does anyone know what the issue is with my code or...??

quaint mantle
#

we've told you like 10 times

trail remnant
#

i already tried what someone said like i said before, still didnt work

#

and i said

quaint mantle
#

Plenty have said the answer already

trail remnant
#

^

native nexus
quaint mantle
#

Where did you invoke it?

trail remnant
#

onEnable

ivory sleet
quaint mantle
#

Ignore IntelliJ's autocorrect then

native nexus
#

I changed it back to camelCase dw

quaint mantle
#

this.setupEconomy() is fully valid with what you provided

eternal oxide
#

except his first return statement in setpEconomy() should be false not true

ivory sleet
eternal oxide
#

and he should be checking the return of setupEconomy()

trail remnant
#

i fixed that

quaint mantle
#

That too

#

But it would Just delay a CNFE

trail remnant
#

still getting the same errors

quaint mantle
#

He is getting an NPE

eternal oxide
#

do you actually have Vault and an eco plugin on yoru test server?

trail remnant
#

plugin.getEconomy().depositPlayer(p, Double.parseDouble(args[1]));

#

yeah

native nexus
eternal oxide
#

?paste your server latest.log (startup)

undone axleBOT
quaint mantle
#

Yea, you need an Eco plugin - vault alone does Not suffice

trail remnant
#

wdym?

#

im making the economy plugin?

ivory sleet
quaint mantle
#

You need to Register your Economy then

ivory sleet
#

I used to go with C# name conventions also back in the days

quaint mantle
#

So, fully different issue

trail remnant
#

what? your confusing me now

ivory sleet
#

I found some java source code of a plugin but it contained all sort of weird stuff which I ignorantly picked up

trail remnant
#

im using the vault api to make the economy plugin?

ashen flicker
#

Lol

#

So you’re gonna store the data yourself!

quaint mantle
#

Yes, but you need to Tell vault that you are the Eco plugin

ashen flicker
#

?*

eternal oxide
#

If you are making an eco plugin you are the provider. You should not be "getting" the provider from vault

quaint mantle
#

This is called registering

trail remnant
#

im using the vault api to give players money and stuff?

native nexus
ashen flicker
#

That’s a confusing way to put it. You just need to create an instance of economy in your main class. That’s it. You initialize the instance in a setup function. Vault shows you how to do it if you look it up.

quaint mantle
#

You need to implement all that

trail remnant
#

i do?

quaint mantle
#

Where?

eternal oxide
#

giving players money and stuff is not an eco plugin

trail remnant
trail remnant
quaint mantle
#

No, implemting the interface

#

Economy

trail remnant
#

how would i do that?

eternal oxide
#

its just a plugin. An eco plugin stores player balances and provides methods to add and remove money from them

quaint mantle
#

Then you are Not the Eco plugin

eternal oxide
#

You are just another plugin

#

you need an eco plugin on top of vault

trail remnant
#

RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);?

ashen flicker
#

If you already did that then you’re done, you’re fine: what’s your issue?

ivory sleet
trail remnant
#

im still getting errors when i try to use plugin.getEconomy()

quaint mantle
trail remnant
#
            return false;```
eternal oxide
#

You will get errors until you add an eco plugin to your server

native nexus
#

WAIT FUCK Don't look at Chat class in HuskyCore utilities

#

I must have been drunk

trail remnant
eternal oxide
#

iConomy, um, hundreds of others. I forget their names

quaint mantle
#

A Plugin implementing and registering an economy

native nexus
#

@ivory sleet fml

ivory sleet
native nexus
#

and yes I know I could use WordUtils but eh

trail remnant
#

but im trying to make a plugin that uses vault's api and create commands with it to give players money and stuff using vault, i would still need one?

quaint mantle
#

Yes

ivory sleet
#

I cant bother with all the utility libs

#

theres just so many

native nexus
#

Yeah same

ashen flicker
#

More fun to make your own utility api

quaint mantle
#

Vault does not do something like, e.g. storing the data - the Eco plugin does that

#

Vault is only an abstraction layer

trail remnant
#

alright thanks

#

welp iconomey didnt work

native nexus
#
public static BookBuilder newInstance() {
  return new BookBuilder();
}
``` I peeked into Guava's CacheBuilder source and I found out you could do this.
quaint mantle
#

Very usefull, 10/10

ivory sleet
#

Guava has a lot of static factory methods for their builders

native nexus
#

It's nice tbh, I know Mongo Java Drive has this also

ivory sleet
#

oo

#

didnt know that but ye

quasi flint
#

For broadcasting messages over bungee cord, I could just use the spit messaging channel, send it to my bungee, and then send it from there to every other server to bukkit.broadcast it from there or is that not possible?

solar sable
#

how to detect when someone say a specific word in chat?

young knoll
#

AsyncPlayerChatEvent

solar sable
#

and to detect a specific word for it like "hello" ?

young knoll
#

You can use .contains

solar sable
#

example please?

quasi flint
#

event.getMessage.contains

#

Smth like that

#

Along the lines

#

Ima not spoon feed

young knoll
#

I believe it can also take regex if you wish

solar sable
#

ah okay

#

and how to send a message after the "hello" is detected

young knoll
#

Use an if statement and player.sendMessage

solar sable
#

like so?

golden turret
#

?learnjava

undone axleBOT
solar sable
#

or like this

formal dome
#

how do i know the exact syntax for each library i need to shade into my jar file?

crisp arch
#

Difference between
Bukkit.getScheduler();
and
plugin.getServer().getScheduler();
?

solar sable
#

how to detect when a player says "Hello" and it would say "Hello" back?

crisp arch
young knoll
#

Not 100% true

crisp arch
#

i read that totally wrong my bad, async tasks not events i guess

carmine nacelle
#

what is bukkit api there other than getting the player? thats kinda required

crisp arch
#

sometimes the javadocs already have the answers to your question

solar sable
#

i just wanna detect a player chat event :/

unkempt peak
crisp arch
#

search box...

unkempt peak
#

lol

#

?docs

crisp arch
#

the search box was coded for a reason

#

use it lmfao

unkempt peak
#

!docs

young knoll
#

Various things are fine to run async, but it's easier to just tell people not to

solar sable
#

it said PlayerChatEvent cant use or something, lemme check

quaint mantle
unkempt peak
#

oh

#

i always forget the commands

crisp arch
solar sable
#

oh i cant read....

unkempt peak
#

use async

crisp arch
# solar sable or like this

also, i suggest you learn java before using any java libraries, we aren't here to teach you how to use java ;)

unkempt peak
#

yes

#

please

solar sable
#

what happens if i do use the deprecated btw?

crisp arch
#

when something is depcreated, it usually means that its gonna get removed soon

#

so dont use it, it will cause bugs *in the future

solar sable
#

aah

unkempt peak
#

its just warning but its depreciated for a good reason

solar sable
#

okay dokie

unkempt peak
#

especially the chat event though

#

please do not use it without async its very unsafe

#

you should always try to avoid depreciated things unless it is impossible to avoid

crisp arch
golden turret
#

plugin.getServer will return the server

unkempt peak
#

or codedred

golden turret
#

Bukkit.getScheduler will get the server.getScheduler()

unkempt peak
carmine nacelle
#

Anyone know how to get ALL bees that belong to a hive? not just the ones currently inside of it

#

(although I also need to get the ones currently inside it but dont see how to get the entities, only the count)

#

dont see it on the docs

solar sable
#

i am watching the one that MrPizzaGuy gave me

woeful crescent
#

Has anyone released a patch for the known issues with InventoryCloseEvent?

#

1.8 would be preferred

carmine nacelle
#

what issues

woeful crescent
#

It doesn't always get called when an inventory closes in some cases

#

Including when a player is teleported, leaves the game, etc. etc.

carmine nacelle
#

well ur talking about 1.8 here

#

nobody here supports 1.8 anymore

woeful crescent
#

Well

#

I mean I was asking about 1.8

#

I'm pretty sure the issues persist in other versions, but not completely

#

Alright you know what

#

Are there any Spigot forks that are actively supporting 1.8?

#

Because I would really like to be able to smoothly develop with better pvp properties and hitreg (what players usually prefer)

carmine nacelle
#

1.17.1 with OldCombatMechanics.

#

works nicely

woeful crescent
#

I still maintain that in the opinion of a hardcore pvper (not me, lol) authentic 1.8 is still far superior in terms of minor differences

#

Also I found one

golden turret
#

something that makes hard the 1.8 players migrate to the latest version is that change the weapons damage may be hard

#

which i want to edit

#

and if someone know how to edit it

#

help me 😭

#

i dont care i will need to modify the nms/craftbukkit code

young knoll
#

Just modify their attributes

golden turret
#

just googled it and a lot of people said that this is hardcoded

young knoll
#

Nope

#

Even if it is you could apply a modify to the base to get the desired result

golden turret
#

?

young knoll
golden turret
#

i dont want attribute

young knoll
#

What do you think controls the damage

golden turret
#

idk

#

i want to edit the base damage

woeful crescent
#

Do events (PlayerTeleportEvent, PlayerQuitEvent), etc fire before or after they ocurr?

#

Well, I really mean those events specifically

#

lol

golden turret
#

if they are cancelable

#

you have high chances to

woeful crescent
#

oof

#

so not quit?

#

I'm trying to make an InventoryCloseEvent patch

granite burrow
#

Is it possible to get a uuid from a players name?

ivory sleet
#

Yep

granite burrow
#

how can I go about doing that?

golden turret
#

2 options

#

if they are online you can use Bukkit.getPlayerExact

#

if offline

#

iterate Bukkit.getOfflinePlayers and be happy 🤡

#

how do i save a file one 1 time?

#

like, the plugin enables and save a config file

#

then i can delete it that it wont be created again

carmine nacelle
#

Anyone know how to get the honey level of a beehive..? there's no methods for it.

carmine nacelle
#

??????????????

#

thats all there is for blockdata.

quaint mantle
#

wrong beehive import

young knoll
#

getState != getData

carmine nacelle
quaint mantle
#
import org.bukkit.block.data.type.Beehive;

//

Beehive beehive = (Beehive) block.getBlockData();
// beehive.getHoneyLevel()
young knoll
#

Spigot has data and state reversed

#

Which is confusing

carmine nacelle
#

Yeah I got it thanks sir

#

I'm guessing there's not an event for that either, ill just have to keep checking it every tick for changes

quaint mantle
carmine nacelle
#

Is there a way to see what data changed?

quaint mantle
#

getBlockData / e.getTo().getBlockData

#

i'd try both

carmine nacelle
#

bet

#

prob be better than a task

lost matrix
quaint mantle
#

Scroll up smile

lost matrix
#

Ah. Hm. Check the current state and compare it one tick later...

quaint mantle
#

or do what i said

formal dome
#

how do i know the exact syntax for each library i need to shade into my jar file for my plugin.yml?

lost matrix
#

Yeah but this does not account for states

formal dome
#

for my plugin.yml

carmine nacelle
#

there isn't a getBlockData() for getTo()

lost matrix
carmine nacelle
#

ah.

#

so you cant compare what it was to what it is now.

#

F

#

Thats fine I guess a scheduler could work.

#

just not as efficiently

young knoll
#

try getBlock.getBlockData for the old data

#

Maybe

carmine nacelle
#

that just shows the new data

lost matrix
#

getBlock().getBlockData() <- Old
getBlockData() <- New

carmine nacelle
#

wot

lost matrix
#

getBlock() returns the Block that is about to be changed.
getBlockData() returns the data that is about to be placed on this Block.

carmine nacelle
#

yeah I get that

#

im just surprised

#

lemme try..

#

Could I check a specific value to see if it changed..?

young knoll
#

getHoneyLevel?

carmine nacelle
#
            BlockData oldData = block.getBlockData();
            BlockData newData = block.getBlockData();

            Beehive beehive = (Beehive) oldData;
#

like could that work?

#

I wanna run it ONLY when honey level changes.

young knoll
#

Right, so return if honey level is the same

lost matrix
#

Always make an instanceof check first

#

Another plugin could have spawned a falling block beehive

carmine nacelle
#
        if(block.getType().equals(Material.BEEHIVE)) {
            BlockData oldData = block.getBlockData();
            BlockData newData = block.getBlockData();

            Beehive beeHiveOld = (Beehive) oldData;
            Beehive beeHiveNew = (Beehive) newData;

            if(newData != oldData) {
                if(beeHiveNew.getHoneyLevel() != beeHiveOld.getHoneyLevel()) {
                    
                }
            }
        }
#

🤔

quaint mantle
#

==

#

you got those mixed up

lost matrix
#

Ah ok that should suffice

carmine nacelle
#

Mixed up how?

quaint mantle
#

Enum == Enum
!newData.equals(oldData)

carmine nacelle
#

if(!(newData.equals(oldData))) {

quaint mantle
#

useless parentheses

carmine nacelle
#

looks nicer

quaint mantle
#
if (!newData.equals(oldData))
carmine nacelle
#

i know

#

but aesthetic

#

ill change it just for u

quaint mantle
#

Ok

lost matrix
#

But it should always be true. The whole point of the event is that the BlockData changes

young knoll
#

You never know with the API

quaint mantle
#

^

young knoll
#

Although I’m still guilty of unchecked casts from human entity to player

carmine nacelle
#

😅

#

NPEs give me paranoia

#

same reason i check if items have itemmeta before checking the itemmeta

lost matrix
quaint mantle
#

HumanEntity should always be player

young knoll
#

Not really sure how hasItemMeta works

carmine nacelle
#

herobrine

quaint mantle
#

useless

young knoll
#

I’m pretty sure hasItemMeta can return false yet getItemMeta can still be called

lost matrix
young knoll
#

because getItemMeta creates it if it doesn’t exist

#

Unless it’s air

worldly ingot
#

getItemMeta() is going to create item meta if it doesn't exist. If you're fetching an item, you should always check if hasItemMeta

#

It's going to be faster

quaint mantle
#

what

young knoll
#

I usually just check isAir

quaint mantle
#

^

#

fastest

#

3 == checks

worldly ingot
#

No. What if there's just a plain diamond sword with no lore, name, damage, or anything else?

quaint mantle
#

its still not null

worldly ingot
#

I understand that... but why get the meta if you don't need it

quaint mantle
#

isAir calls hasItemMeta?

lost matrix
worldly ingot
#

If you want to check if an item has a certain name, if it does not have item meta, DO NOT CALL getItemMeta()

quaint mantle
#

sarcasm

#

faster by 2ns

lost matrix
#

Choco is talking about when you want to check the ItemMeta and dont want to modify it

quaint mantle
#

oh well yeah ofc why do that

young knoll
#

Yeah, like checking pdc values

quaint mantle
#
    /**
     * Get a copy of this ItemStack's {@link ItemMeta}.
     *
     * @return a copy of the current ItemStack's ItemData
     */
    @Nullable
    public ItemMeta getItemMeta() {
        return this.meta == null ? Bukkit.getItemFactory().getItemMeta(this.type) : this.meta.clone();
    }

    /**
     * Checks to see if any meta data has been defined.
     *
     * @return Returns true if some meta data has been set for this item
     */
    public boolean hasItemMeta() {
        return !Bukkit.getItemFactory().equals(meta, null);
    }
young knoll
#

Why does that need a special method

#

Rather than meta == null

quaint mantle
#

fr

#

makes no sense

#
    /**
     * Get a copy of this ItemStack's {@link ItemMeta}.
     *
     * @return a copy of the current ItemStack's ItemData
     */
    @Nullable
    public ItemMeta getItemMeta() {
        return this.meta == null ? null : meta.copy();
    }
young knoll
#

Does the method do something additional? Check for empty meta maybe?

lost matrix
young knoll
#

Yeah that’s the only reason I could think of

quaint mantle
#

im gonna rewrite this to make it 10x better

public boolean hasItemMeta() {
    return this.meta != null && !this.meta.isEmpty();
}
#

then a method in meta

#

isEmpty

formal dome
#

how do i know the exact syntax for each library i need to shade into my jar file for my plugin.yml? or at least drop me a link for gradle depedency shading

quaint mantle
#
public boolean isEmpty() {
    return !(this.hasDisplayName() || this.hasLore() || this.hasEnchants() || this.hasAttributeModifiers() || this.hasModelData() || this.hasLocalizedName()) && this.getItemFlags().isEmpty();
}
crisp arch
#

does spigot api have custom advancements?

#

im looking online, but nothing

young knoll
#

I think the unsafe class in bukkit let’s you add an advancement from a json string

#

Probably better to just extract a datapack from your jar

crisp arch
#

?

young knoll
#

You can bundle a zip file in your plugin jar and copy it to the world datapack folder

crisp arch
#

for the custom advancement?

#

no way to do it as a plugin alone?

young knoll
#

Like I said I believe there is a way in the unsafe class using a raw json string

crisp arch
#

unsafe class?

crisp arch
#

woah

#

deprecated?

#

is there a better way to do it if its deprecated?

young knoll
#

Don’t think so

crisp arch
#

hm

#

so its just deprecated because...?

lost matrix
#

Maybe its draft. Maybe its unstable.

crisp arch
#

hm

#

ok thanks

#

ill use it i guess

#

hope they fix this up and add a more stable solution

crisp arch
#

yea, but i don't really want to use an api right now

#

i guess ill use unsafevalues

#

thanks for the help ;D

young knoll
#

I guess it wouldn’t be too bad if you load it from a file

#

I wrote the raw string into my IDE and it was ugly

crisp arch
#

oh good idea

#
Parameters:
key - the unique advancement key

key?

young knoll
#

Every advancement has a unique key

torn oyster
#

return "Hello there".toString().toString()
hmmmm

young knoll
#

Yes you can call toString on a string

torn oyster
#

lmao

young knoll
#

You can also repeatedly call getPlayer on a player

young knoll
#

Because Object has a toString method, and every class, including string, extends from object

#

As for player, offline player has a getPlayer method, and player is an extension of offline player

lost matrix
carmine nacelle
#
    @EventHandler
    public void onHoneyLevelChange(EntityChangeBlockEvent event) {
        Block block = event.getBlock();

        Bukkit.broadcastMessage("Changed 1");

        if (block.getType().equals(Material.BEEHIVE)) {
            BlockData oldData = block.getBlockData();
            BlockData newData = block.getBlockData();

            Beehive beeHiveOld = (Beehive) oldData;
            Beehive beeHiveNew = (Beehive) newData;

            Bukkit.broadcastMessage("Changed 2");

            if (beeHiveNew.getHoneyLevel() != beeHiveOld.getHoneyLevel()) {
                for(CustomHive customHive : cadiaBees.hiveManager.getCustomHives()) {
                    if(customHive.getHiveLocation().equals(block.getLocation())) {
                        customHive.setHoneyLevel(beeHiveNew.getHoneyLevel());
                        for(Player allPlayers : Bukkit.getOnlinePlayers()) {
                            cadiaBees.cadiaCore.hologramManager.refreshHolo(allPlayers, cadiaBees.hiveManager.getHiveHolo(customHive));
                        }
                    }
                }
            }
        }
    }

So, I get Changed 1 but not Changed 2, any idea...?

young knoll
#

Have you tried outputting what block.getType returns

lost matrix
#

BEE_NEST

young knoll
#

Bee nest is the wild block

carmine nacelle
#

mine are hives

young knoll
#

Hive is the player made one

lost matrix
#

Ah. What does yours return?

carmine nacelle
#

..

#

AIR

#

😄

#

its either air or its not being called at all for the honey update

young knoll
#

I had it feeling it might not be

carmine nacelle
#

back to scheduler then I guess..

#

is that my only option at tihs point

quaint mantle
#

whats the difference between netty's write and writeAndFlush?

lost matrix
quaint mantle
#

when i only use write it still sends packet

lost matrix
#

Maybe the channel is set to auto flushing

quaint mantle
#

is there an option for this? or how to check that?

lost matrix
#

Check if the ChannelInboundHandler#channelWritabilityChanged() method is overwritten to call flush()

#

Usually netty doesnt auto flush and doesnt have an option for it unless the underlying implementation is changed.

carmine nacelle
#

Alright, sooo..

[20:44:57 WARN]: [CadiaBees] Task #6358 for CadiaBees v1.0 generated an exception
java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_17_R1.block.CraftBeehive cannot be cast to class org.bukkit.block.data.type.Beehive (org.bukkit.craftbukkit.v1_17_R1.block.CraftBeehive and org.bukkit.block.data.type.Beehive are in unnamed module of loader 'app')
        at com.squallz.CadiaBees.tasks.HoneyLevelTask$1.run(HoneyLevelTask.java:26) ~[CadiaBees.jar:?]
        at org.bukkit.craftbukkit.v1_17_R1.scheduler.CraftTask.run(CraftTask.java:101) ~[patched_1.17.1.jar:git-Paper-19

Getting this because I'm casting..

 Beehive beehive = (Beehive) blockAtHiveLoc.getState();

apparently you can't cast import org.bukkit.block.data.type.Beehive; to beehive blocks

#

yet I need to get the data from said block..

lost matrix
carmine nacelle
#

so then how do I get the data from the block?

lost matrix
#

Get the BlockData and cast it to the data Beehive or
get the BlockState and cast it to the state Beehive

quaint mantle
#

i dont see anything like channelWritabilityChanged in the code

lost matrix
quaint mantle
#

oh yea there is something

#

so basically calling flush from channel sends all packets right?

lost matrix
#

Yes

formal dome
lost matrix
carmine nacelle
#
Beehive beehive = (Beehive) blockAtHiveLoc.getBlockData();

import org.bukkit.block.data.type.Beehive;

#

🤔 not working still

formal dome
#

i just assume the way i did it was wrong but i can't figure out how i did it wrong. Thrown exception: ```org.bukkit.plugin.InvalidPluginException: java.lang.IllegalArgumentException: Bad artifact coordinates net.dv8tion.JDA:4.3.0_324, expected format is <groupId>:<artifactId>[:<extension>[:<classifier>]]:<version>

lost matrix
#

:

formal dome
#

gotcha

lost matrix
quaint mantle
# lost matrix Yes

i think the mystery is solved, i still have some packets being sent but thank you, i think that was it! 🙂

formal dome
swift karma
#

anyone really good with protocollib?

lost matrix
#

?ask

undone axleBOT
#

If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Create a thread in case the help channel you are using is already in use!

quaint mantle
#

thats paper

lost matrix
#
  1. Dont make it static
  2. This is not a spigot event
rugged topaz
#
LivingEntity mob = (LivingEntity) nearby;
                    Bukkit.getServer().getPluginManager().callEvent(new EntityDamageByEntityEvent(player, mob, EntityDamageEvent.DamageCause.ENTITY_ATTACK, 5));

calling the EntityDamageByEntityEvent should be enough to damage a mob right?

lost matrix
rugged topaz
#

then

#

hm

lost matrix
#

One moment ill write an example

young knoll
#

You can damage it with .damage

#

And you can supply an entity to simulate that entity doing the damage

lost matrix
#
  public void damageWithEvent(final LivingEntity attacker, final LivingEntity defender, final double amount, final DamageCause cause) {
    final EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(attacker, defender, cause, amount);
    Bukkit.getPluginManager().callEvent(event);
    if (event.isCancelled()) {
      return;
    }
    final double finalDmg = event.getDamage();
    defender.damage(finalDmg , attacker);
    defender.setLastDamageCause(event); // Not sure if this needs to be here
  }
young knoll
#

The annoying part is I never found a way to damage an entity with a non-entity source

lost matrix
#

Actually not sure if the second one fires an event...

#

probably not

young knoll
#

Doesn’t allow you to specify a source

#

Like drowning

rugged topaz
#

ah thanks

carmine nacelle
#

If I set an entity to be a baby, how do I stop it from aging?

young knoll
#

setAgeLock

carmine nacelle
young knoll
#

Oh that’s nms

carmine nacelle
#

yeahh

young knoll
#

I think you just set it’s age to Short.MIN_VALUE

carmine nacelle
#

well, making it a baby works fine

#

it'll just age still though

young knoll
#

Pretty sure it’s still the short min value

#

Which is like -32k

vernal pier
#

How do I check if it’s the first time someone start up server with this plugin in on enable

#

Is it just checking the data folder exists

lost matrix
native nexus
lost matrix
#

You can also have a file inside your jar and modify it.

native nexus
#

Yeah like a properties file would be good!

lost matrix
#

You could also set a system property for the user i suppose 🤔

bitter dove
#

so... I want to store item to a database... readable... so base64encoding is not an option, but more like a way to stringify... So far I've manage to extract and make a string with weapons and tools with enchantments, but I need a simple way of checking if item in hand, is a tool or an block or something else? what is the best way? Material#isBlock()? what does Material#isItem() return?

lost matrix
lost matrix
bitter dove
#

i mean if the item in hand is block, it doesn't need to check for enchantment and so on.

lost matrix
#

How do you plan on storing custom NBT Data?

#

And PDCs

#

And some plugins might have extra data in block items.

bitter dove
#

so far, I simply just store name,amount,lore,enchantment and damage

lost matrix
#

So custom attributes are not supported

#

And item flags

bitter dove
#

😉

lost matrix
#

And potion effects for potions

#

and fireworks

bitter dove
#

not needed for my purpose

young knoll
#

You can probably make a method to encode it as json

#

Although I don’t know why you would want something to be human readable in a database

bitter dove
#

maybe because other application would have access to it 🙂

young knoll
#

Then those other applications should be able to convert it to a readable form

lost matrix
#

This other applications just need Spigot as a dependency and then they can use ItemStacks as they are...

young knoll
#

I suppose you could go with NoSQL to be a bit more readable

lost matrix
#
  public static String serialize(final ItemStack itemStack) {
    final NBTTagCompound tag = new NBTTagCompound();
    CraftItemStack.asNMSCopy(itemStack).save(tag);
    return tag.toString();
  }

Used like this:

  @Override
  public void onEnable() {
    final ItemStack stack = new ItemStack(Material.IRON_PICKAXE);
    final ItemMeta meta = stack.getItemMeta();

    meta.setDisplayName("§eSome Cool Name");
    meta.setLore(Arrays.asList("", "§7Im a cool pickaxe."));
    meta.setUnbreakable(true);
    meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS, ItemFlag.HIDE_DYE);
    final PersistentDataContainer container = meta.getPersistentDataContainer();
    container.set(NamespacedKey.fromString("test:key"), PersistentDataType.INTEGER, 256);

    stack.setItemMeta(meta);

    final String data = serialize(stack);
    System.out.println(data);
  }

Yields:

{Count:1b,id:"minecraft:iron_pickaxe",tag:{Damage:0,HideFlags:96,PublicBukkitValues:{"test:key":256},Unbreakable:1b,display:{Lore:['{"text":""}','{"extra":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"gray","text":"Im acool pickaxe."}],"text":""}'],Name:'{"extra":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"yellow","text":"Some Cool Name"}],"text":""}'}}}
bitter dove
#

thanks i'll look into it

young knoll
#

Oh that is useful

#

Gotta remember that

lost matrix
#

Can also be deserialized

  public static ItemStack deserializeItemStack(final String string) {
    if (string == null || string.equals("empty")) {
      return null;
    }
    try {
      final NBTTagCompound comp = MojangsonParser.parse(string);
      final net.minecraft.world.item.ItemStack cis = net.minecraft.world.item.ItemStack.a(comp);
      return CraftItemStack.asBukkitCopy(cis);
    } catch (final CommandSyntaxException ex) {
      ex.printStackTrace();
    }
    return null;
  }
young knoll
#

Turn it into a persistent data type and you can get real meta

lost matrix
young knoll
#

Yeah

#

I know choco wrote a pdc type for that for someone

#

No idea what the repo is though

lost matrix
#

Ive used this approach in my machine plugin as all machines are TileStates and have PDCs. I dont need to manage any files or DBs 😄

young knoll
#

Technically that’s not really an issue for blocks either now that we have chunk pdcs

#

Unless you intend to use said block a lot

lost matrix
#

Its usually better to load the data into memory when the chunk loads and save it again when it unloads. This way you dont have to
access the PDC often as thats quite slow

young knoll
#

I figured it would just be a map in the backend

lost matrix
#

Accessing the PDC has a bit of overhead. And parsing it is also not cheap. Better to just Use an IntMap<CustomData> or something and then
lazily load the data into memory.

#

(IntMap because a relative block location inside a chunk can be stored in 32 bits)

young knoll
#

Does that apply in 1.17+

lost matrix
#

Yes i made sure that it also supports heights of up to 4096

young knoll
#

I imagine it would actually, 5 bits for x and z + 11 bits for y

#

Or 12, I don’t remember how high you can actually make the world without the render system dying

young knoll
#

Fair enough

#

Got extra room for y as well

lost matrix
#

2^16 so 65.536

young knoll
#

In case Mojang wants to add 65k tall worlds

#

Although at that point you probably want cubic chunks

lost matrix
#

The theoretical value that is now supported by the chunk format is actually substantially higher than what is actually implemented in vanilla

young knoll
#

I was around when the fabric guys messed with it after the snapshots

#

I don’t think they got past 4096

lost matrix
#

We will see. But imagine running 4k Blocks. It takes quite a bit of time. Having this in the y direction would be insane.

young knoll
#

Yeah

#

The render side isn’t too bad because the game can already cull in cubic chunks

#

But worldgen is the issue

lost matrix
#

Pretty sure someone will write a generator that generates the Nether right under the overworld so you can dig down to Hell 😄

young knoll
#

And memory footprint

lost matrix
#

Pre-generate the world. Memory footprint will be ok-ish.

#

But loading those chunks from disk... you better have an NVMe on your server.

young knoll
#

the hard max is 2048, because the section id is stored in a byte

#

There we go

lost matrix
#

😦

#

Where

young knoll
#

128 x 16 blocks per section

lost matrix
#

So 256 x 16 = 4096

young knoll
#

128

lost matrix
#

🤔

young knoll
#

Bytes are always signed in java

#

Although I would imagine negative section IDs would be fine so ¯_(ツ)_/¯

lost matrix
#

so from -2032 to 2048 then. Doesnt really make a dif

young knoll
#

Yeah at the most

#

Still plenty of space for all 3 dimensions

lost matrix
#

Noice. Cant wait for an Enderdragon to breach the ceiling and trash the whole server

young knoll
#

Note to self

#

Alter dragon path finding

#

Canonically the dimensions are meant to be separate, but seeing the end stacked on the overworld stacked on the nether would be cool

lost matrix
#

Hm the boss fight will be bugged as everyone in the world will constantly see the Health bar

young knoll
#

You could alter that too to be proximity based

#

Mixins fix everything, including Mojangs fuckup on world saving in the new versions :p

sullen marlin
#

there's already a broadcast channel?

pastel stag
#

the god himself speaks

tacit drift
#

Hello orange guy

naive jolt
#

can i not make custom items with spigot? I mean with textures

vernal pier
#

Isn’t that resource packs?

unkempt peak
#

Does any here have experience with JDA (Java Discord API)?

chrome beacon
#

Yeah

formal prawn
#

Hey, I need help regarding a particular logic. I created a plugin which tracks a player with a compass. It works fine until I have two or more targets at which the compass has to point. If there are two or more players who want the compass to face two different players, it won't. It would just face the latest target which was given by the player.

Main Class - https://paste.md-5.net/jowesivefi.java
Track the Target Class - https://paste.md-5.net/exocimojoz.java
Right Click to refresh target location Class - https://paste.md-5.net/azigasilim.java

native nexus
#

Static variable is the issue

opal juniper
#

also - that is a RightClickListener not a RightClickEvent

quaint mantle
#

How does Spigot register the functions called on an listener

#

Where does it get the key from

#

How does it know what event it is?

opal juniper
#

?eventapi

undone axleBOT
formal prawn
opal juniper
#

that’s not the issue

#

it’s just annoying me

formal prawn
#

and i am not making a public plugin...

quaint mantle
naive jolt
#

cause I dont want to replace a ingame item

naive jolt
formal prawn
naive jolt
#

didnt wanna just override your question

opal juniper
#

yes

#

if you want “custom”-ish items has the model data

dense remnant
#

How to get item durability?

ivory sleet
#

Damageable

#

from ItemMeta

naive jolt
opal juniper
#

well you set the data with the spigot api and then you need a resource pack for the actual texture

#

there is a method under player to set the resource pack

#

Player#setResourcePack

solar sable
#

i am trying to make it detect when someone say "hello" in chat and then reply to that hello with a "hey" but idk if this is the right way or not

dense remnant
#

Whats the non deprecated way of playerinteractevent#iscancelled ?

opal juniper
#

look at the message

#

it will tell you why @dense remnant

opal juniper
#

if not it will send regardless

dense remnant
white thicket
#

Hey guys, I am trying to connect my plugin to a discord bot

    public Discord() throws LoginException {
        String token = "";
        try {
            assert false;
            token = plugin.getConfig().getString("token");
        } catch(NullPointerException error) {
            Bukkit.getConsoleSender().sendMessage("[DiscordIntegration] Token not available");
        }
        if (token != null) {
            startBot(token);
            builder.addEventListener(this);
            botEnabled = true;
        } else {
            Bukkit.getConsoleSender().sendMessage("[DiscordIntegration] Failed to login to bot.");
        }
    }

    public void startBot(String args) throws LoginException {
        try {
            builder = JDABuilder.createDefault(args).build();
        } catch(NullPointerException error) {
            Bukkit.getConsoleSender().sendMessage("[DiscordIntegration] No token found. Put token in config and restart server");
        }
    }

In config I have provided the token but it still says [DiscordIntegration] Token not available on console

solar sable
#

its correct now

dense remnant
white thicket
dense remnant
solar sable
#

how to make it say "hey" after i say "hello"

tender shard
#

ah okay I got it

#

runn it in a delayed task

solar sable
#

how to?

tender shard
#

1 sec

#

for example:

#
@EventHandler
    public void onChat(AsyncPlayerChatEvent event) {
        if(event.getMessage().toLowerCase(Locale.ROOT).contains("hello")) {
            Bukkit.getScheduler().runTaskLater(this, () -> {   // <- "this" is the instance of your class that extends JavaPlugin
                event.getPlayer().sendMessage("hey");
            }, 20); // <- 20 means a delay of 20 ticks = 1 second
        }
    }
solar sable
#

why is it when i changed "this" to the name of my class that extends JavaPlugin, it becomes static

tender shard
#

what do you mean with "it becomes static"?

#

you need a reference to your main class

#

for example by passing "this" to your listener class when you create the listener object

solar sable
tender shard
#

I'll show you another example in a minute

solar sable
#

this is my class that extends java plugin

tender shard
#

yeah I'll show you something in a minute

solar sable
#

okeh

tender shard
#

imagine this is your listener class, while "Test" is your Main class:

#
public class MyListener implements Listener {

    private final Test plugin;
    
    public MyListener(Test plugin) {
        this.plugin = plugin;
    }
    
}
#

In your onEnable, do this:

Bukkit.getPluginManager().registerEvents(new MyListener(this), this);
#

as you can see, we simply passed "this" to the Listener object, which then keeps it inside a variable "plugin"

#

so you can access the main instance of your plugin from your Listener

solar sable
#

so i need to add something here?

tender shard
#

tbh you should learn basic java if you still have questions

#

I explained you like every single detail

solar sable
#

yeh ik

tender shard
#

"Testing" has to be replaced with a variable that points to your main instance, like in the above example, "plugin"

#

in your "Replier" class, you need to create a constructor that takes an instance of your main class as parameter and then saves it inside this "plugin" variable

#

(you could also use a static getter in your main class but I wouldn't recommend that until you know what you are actually doing, because otherwise things will get messy soon)

#

@solar sable Example:

#

Main class:

#

Listener:

quasi flint
#

?learnjava

undone axleBOT
solar sable
#

i did what you told me @tender shard but this is what it shows

quasi flint
#

show code and learn java

solar sable
quasi flint
#

theres a shit ton of red

ivory sleet
#

Test is not the same type as Testing

quasi flint
#

maybe fix that?

#

make the Test to ur Mainclass

#

name

solar sable
quasi flint
solar sable
#

changed the Test to Testing

quasi flint
#

understand it

#

learn java

#

ur passing the paramter testing but trying to use plugin?!

#

this.plugin = testing

#

please for gods love learn java

ivory sleet
#

Yeah I agree, you should probably visit some basic Java syntax tutorial which explains different variable types and such

#

If you do it properly it shouldn't take that long to get a decent understanding of it as well

quasi flint
#

like a week or 2

#

at most

ivory sleet
#

Just a max of 30 min should be enough to understand the concept of variables

quasi flint
#

yea

#

a week to fully understand and use it right

#

properly

ivory sleet
#

Depends on what you define as fully

quasi flint
#

like not the bare basics

#

maybe a bit depper n shit

ivory sleet
#

There's no strict line where we can separate basics with more intermediate knowledge I'd argue for

#

but yeah

lost matrix
quasi flint
#

hell nahxD

next stratus
ivory sleet
#

chill odin

#

guy's quite new to Java 😄

next stratus
#

?

solar sable
#

i know this isnt the place to ask but most people use it here so imma ask anyways, how to change the .jar file version? i tried to change to 2.0 but didnt work lol so it kinda just stayed at 1.0

next stratus
#

sorry, i always speak my my mind

sullen marlin
#

jar version???

quasi flint
#

plugin.yml

solar sable
next stratus
#

hi md_5

solar sable
#

didnt work

quasi flint
lost matrix
solar sable
#

well my plugin .jar kinda just shows testing-1.0.jar everytime i change it so

quasi flint
#

well worry about that when u have to

#

first fix ur errors and things

solar sable
#

yup

#

will do

quasi flint
#

good

#

have fun

wide flicker
#

If you're compiling with Gradle or Maven, it's likely the version set in its config that needs changed

lyric sonnet
#

how can i run my plugin from intelliJ itself?

quasi flint
#

not sure tho

wide flicker
#

It is possible, but you have to set up a server environment inside the project

lyric sonnet
#

so for every change, and every value i want to change i need to rebuild the jar and restart the server?

wide flicker
#

That or create a fake sever to run it on

wide flicker
lyric sonnet
#

i just want to be able to press the run button, have it compile my plugin, put it in the correct folder, start the server, and allow me to join

lyric sonnet
#

i have chosen for gradle

lost matrix
#

Too bad. I got a script that scrapes the jar name from the pom, compiles the plugin, copies the jar and starts the server.

#
@echo off

SET serverLocation=C:\Users\flo\Desktop\DESK\1.17Spigot

call mvn clean install

set "artifactId="
for /f "tokens=3 delims=<>" %%a in ('find /i "<artifactId>" ^< "pom.xml"') do (
  set "artifactId=%%a"
  If not [%artifactId%]==[""] (
    goto :end1
  )
)
:end1


set "version="
for /f "tokens=3 delims=<>" %%a in ('find /i "<version>" ^< "pom.xml"') do (
  set "version=%%a"
  If not [%version%]==[""] (
    goto :end2
  )
)
:end2

SET jarName=%artifactId%-%version%.jar
SET jarPath=target\%jarName%

SET serverPluginLoc=%serverLocation%\plugins

xcopy %jarPath% %serverPluginLoc% /Y

SET serverStartScript=%serverLocation%\start.bat

cd %serverLocation%

%serverStartScript%

You just need to figure out how to scrape artifactId and version from your gradle file and change the serverLocation variable.

tender shard
lyric sonnet
#

i am just wondering

#

how is it more difficult to run a plugin from intelliJ

#

than both server and client side mod launchers

tender shard
# solar sable

I explained like exactly what you had to do, but you just ignored everything of it it and instead just copy pasted everything? of course that won't work

lost matrix
lyric sonnet
#

a mod requires the modloader to be started first

#

that is also third party

quaint mantle
#

Hi
If i code a plugon will people who decompile it be able to see information in the jar and code files

#

Such as ip
Name
Or name of pc user or any info at all
Or just the code

chrome beacon
#

Only code

quaint mantle
#

Thanks <3

quaint mantle
#

im trying to make a hologram plugin with NMS
any idea of how to update it ? like set a new text
or sending another metadatapacket but i dont have the dataWatcher of the armorstand
and i only got the id

#

or getting an armorstand from id

#

if i somehow send the metadata packet again

#

will it get updated ?

tacit drift
#

how should i calculate cps?

#

clicks/time in seconds since started?

golden turret
golden turret
golden turret
#

ik you will use variables

tacit drift
#

my head is going to be blown

#

let's see what's going to result

quaint mantle
#

i guess just listen for click
add to a hasmap
reset the hashmap every second

#

I GUESS

#

will it work ?

tacit drift
#

that would be extremly resource intensive

golden turret
#

ask me later

tender shard
golden turret
#

i will be out for now

ivory sleet
#

What’s so resource intensive about it?

tender shard
#

nothing imho^^

tacit drift
#

adding to a hashmap and resetting it every second

tender shard
#

how is that resource intensive?

#

maybe when you are running it on a 0.1MHz calculator

tacit drift
#

☠️

ivory sleet
#

In worst case use a concurrent hashmap and do it async but I doubt you need that

tacit drift
#

yeah i am doing this for an android app, learning stuff

quaint mantle
#

?paste

undone axleBOT
quaint mantle
#

Previously using jdk8, I was using maven ant and antcontrib in order to copy my built artifacts into my local test servers.
https://gitlab.com/lasersenigma/lasersenigma/-/blob/master/core/pom.xml#L305
I did all this because I wanted each developer to be able to modify his own local test servers locations inside a gitignored file ("build.xml")
So I only gitted the example file build-example.xml:
https://gitlab.com/lasersenigma/lasersenigma/-/blob/master/core/build-example.xml

After updating to Spigot1.17 and updating accordingly to openjdk16 I couldn't use all this setup anymore because of the lact of tools.jar (com.sun:tools) which is a system dependency (coming from "<jdkpath>/lib" directory and which have been removed from the latest versions of the java jdk. this file is required by ant.). I could still have included it manually but then I would have had issues with my gitlab-ci.yml. So I tried to exclude it :

        <dependency>
            <groupId>org.apache.ant</groupId>
            <artifactId>ant</artifactId>
            <version>1.10.11</version>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <artifactId>tools</artifactId>
                    <groupId>com.sun</groupId>
                </exclusion>
            </exclusions>
        </dependency>

but then I have another issue when running ('org.apache.tools.ant.util.FileUtils org.apache.tools.ant.util.FileUtils.getFileUtils()')

So I'm looking for a solution to one of those problems :

  • specifically continue using ant and antcontrib (so this means fixing the com.sun:tools:1.8 missing issue but without including it from the jdk).
  • using another way to copy built artifact to my local test servers while keeping the ability to modify those locations in a gitignored file.

Please advice 🙂

#

I suppose I could add some vars to maven properties (in a gitignored file) and use it with some maven copy plugin or something alike ?

quaint mantle
#

But it seems it could not be done if I want to put multiple target directories. It would also be unable to delete the previously built jar if the version changes.

opal juniper
#

use the async one

#

AsyncPlayerChatEvent

lost matrix
#

Player -> Player message or any message a Player receives

#

Do you want to change the message a player sends in the chat or do you want an arbitrary message to be modified? (From a plugin for example)

opal juniper
#

gonna be harder i imagine but probably packet stuff

lost matrix
#

With ProtocolLib its something like this:

public class MessageListener extends PacketAdapter {

  public MessageListener(final Plugin plugin) {
    super(plugin, Server.CHAT);
  }

  @Override
  public void onPacketSending(final PacketEvent event) {
    final PacketContainer container = event.getPacket();
    final StructureModifier<WrappedChatComponent> chatStructMod = container.getChatComponents();
    chatStructMod.modify(0, current -> {
      String json = current.getJson();
      // Change component here
    });
  }
}

Reference this:
https://wiki.vg/Protocol#Chat_Message_.28clientbound.29

#

But getting this to work wont be easy.

#

Nope. I dont know how to handle this packet out of the blue. I would have to take a look at the PacketPlayOutChat and play around a bit.

#

On this page you can read about the general usage of PacketAdapters

#

Its maybe an array of components. Not sure.

    StructureModifier<WrappedChatComponent[]> componentsStruct = event.getPacket().getChatComponentArrays();
minor garnet
#

hey the player camera rotation is on euler angle ?

lost matrix
minor garnet
#

hm

#

its because i need make a vector3 from it

vernal pier
#

player.getDirection()?

fast path
#

Is there a easier way to clone a block from a to b(clone all info & other)

Like chest loottable ,etc
(I don’t want write all type of them)

So is possible to do it?
Like use nms or?

tender shard
fast path
#

Different location.

tender shard
#

so?

fast path
#

Hmm.

#

There is no block.setState

#

Only state.update

#

If I can set block state to another location then update,that will work too.

tender shard
#

hm yeah you're right

quaint mantle
#

Is there a way to create a Listener from a String?

#

e.g the string is "BlockItemDrop", it creates an BlockItemDropListener

fast path
#

Hm

#

Let me think.

#

You can use reflection to get Listener

#

And use something like eval to dispatch code.

solar sable
#

is a there a javadoc for learning how to use scoreboards?

#

nvm i found it

fast path
#

Google is ur friend:/

solar sable
#

i said i already found it .-.

fast path
#

Just tips.-.

solar sable
#

is there a better way to do this? what i want to do is everytime a player drops an item, it will say in chat what the player dropped

white thicket
fast path
#

What do you mean?

fast path
#

Or just some special item.

white thicket
fast path
#

Sorry not:/

white thicket
#

oh ok

solar sable
fast path
#

What?

solar sable
#

i dont believe its easy as that

fast path
#

Uh

#

So you want say when everything drop or just special type item drop?

fast path
opal juniper
fast path
#

In fact I think that stupid way

#

If message is same.

warm wedge
fast path
#

ArrayList<Material> anythingYouWantFilter=new ArrayList<>(Arrays.asList(Material.DIAMOND,Material.EMERALD);

//event listener
if(anythingYouWantFilter.contains(/.../.getType())){
e.getPlayer().sendMessage(“you dropped a “+/.../.getType().name +”!!”);
}

fast path
quaint mantle
#

leme create a thread for this

tardy delta
#

is this correct that this is two times the same?

crisp arch
#

Can someone walk me through custom achievements using Bukkit.getUnsafe()?
Spigot doesn't really have much on it

tardy delta
#

wait what originals:

quaint mantle
#

Okay I've got a practical question, I'm making an mysql plugin where i save a few player stats like mob kills player kills time played etc, what would be the right thing to do, query update db after certain event like a kill, or do I store everything in hashmaps to then on quit event query update. I'm not that familiar with the quit event don't want to cause logout lockups so my bet would be updating after any event. Thoughts ?

solar sable
lost matrix
#

And dont use if-else or a switch statement as that will scale horribly

tardy delta
#
@EventHandler
public static void onDrop(PlayerDropEvent e) {
  Player player = e.getPlayer();
  String str;
  switch (e.getItemDrop.getItemStack().getType()) {
    case Stone:
      str = "Stone";
      // etc
  }
  player.sendMessage("You dropped a " + str);
}
#

something like that?

tardy flame
lost matrix
tardy flame
#

You should stop

tardy delta
#

what does that toReadableString do?

solar sable
lost matrix
# tardy flame You should stop
  public static String toReadableString(final Material material) {
    return StringUtils.capitalize(material.name().replace("_", " ").toLowerCase());
  }

  @EventHandler
  public void onDrop(final PlayerDropItemEvent event) {
    final Player player = event.getPlayer();
    final ItemStack drop = event.getItemDrop().getItemStack();
    final String itemStr = toReadableString(drop.getType());
    final int amount = drop.getAmount();
    player.sendMessage("§9Test > §fYou dropped §9x%d %s".formatted(amount, itemStr));
  }

There. No switch case needed.

tardy flame
tardy flame
#

Just some items, as he posted it

solar sable
#

no that is perfect actuallly

tardy flame
#

Oh

#

:cringe:

solar sable
#

i do want everything

lost matrix
solar sable
#

thanks

#

okay i gtg now

#

see ya guys

#

thanks to all of you <<33

#

❤️

silk tusk
#

How would I deal a specific kind of damage to an entity? like if I want my plugin to deal 5 points of harming damage

lost matrix
tardy delta
#

uh i'll look that up

lost matrix
silk tusk
#

That seems to do void damage, at least in terms of death messages

lost matrix
# silk tusk That seems to do void damage, at least in terms of death messages
  public void damageWithEvent(final LivingEntity defender, final double amount, final DamageCause cause) {
    final EntityDamageEvent event = new EntityDamageEvent(defender, cause, amount);
    Bukkit.getPluginManager().callEvent(event);
    if (event.isCancelled()) {
      return;
    }
    final double finalDmg = event.getDamage();
    defender.setLastDamageCause(event);
    defender.damage(finalDmg);
  }
silk tusk
#

ah ok

tardy delta
#

if i understand correctly you can continue a loop with the given label

#

so a labeled break and continue

silk tusk
lost matrix
#

Hmm.

lusty cipher
#

does spigot have something like onReload so I can handle it properly?

lost matrix
lusty cipher
#

does reloading disable it tho?

lost matrix
#

iirc then reloading should disable and re-enable all plugins.

lost matrix
eternal oxide
silk tusk
lusty cipher
silk tusk
vernal pier
silk tusk
#

I was able to successfully use ((CraftLivingEntity) entity).getHandle().damageEntity(DamageSource.o, (float) event.getAmount()); but obviously I'd rather avoid nms

tardy delta
#

bump

novel totem
#

Player gets killed event

lusty cipher
#

in CommandExecutor#onCommand, is there no better way to get the player than this?

Player player = Bukkit.getPlayer(sender.getName());
#

oh fuck

#

Player inherits CommandSender

#

can I just cast it?

hoary rover
#

yes

#

but first check sender instanceof Player

tardy delta
#

404 not found smh

ancient ridge
#

how to put buldtool in my sever

crisp arch
#
void setArmorContents​(@NotNull ItemStack[] items)

what order is the array?

#

boots first or helmet first?

ancient ridge
#

who me

crisp arch
ancient ridge
#

how to put buldtool in my sever

crisp arch
#

are you talking about worledit

tardy delta
#

you mean adding it as a dependency?

crisp arch
tardy delta
#

no

ancient ridge
#

it is showing like this

tardy delta
#

thats nothing

#

ignore that

crisp arch
#

this channel is for help on scripting plugins. for your question, ask #help-server

hasty prawn
#

scripting plugins PauseChamp

#

You can add -DIReallyKnowWhatIAmDoingISwear to JVM arguments to make it not do that

crisp arch
hasty prawn
#

Probably not but idk how else to explain it LOL

crisp arch
#

lol considering this is how he talks, either hes a troll or he has no idea what hes doing

tardy delta
crisp arch
#

its an ItemStack[] array, so theres an order right?

#

is it {helmet, chestplate, leggings, boots}
or {boots, leggings, chestplate, helmet}?

hasty prawn
#

The latter

crisp arch
#

oh ok thx

hasty prawn
#

Even if it does it backwards, just reverse it.

crisp arch
tardy delta
#

why cant i message a player in the join event? i cancelled it with 1 tick

ancient ridge
#

can u look in help-server

#

plz

tardy delta
#

just this in the player join event

Bukkit.getScheduler().runTaskLater(plugin, () -> Utils.message(player, "&aWelcome to the server &b " + player.getName()), 1L);
hasty prawn
#

Is your Join event firing

tardy delta
#

yes

hasty prawn
#

You know is firing or you're just assuming that it is

tardy delta
#

i know it is

hasty prawn
#

What does Utils.message do

tardy delta
#

messages a player with translated chatcolors

quaint mantle
#

You don't need to do that.

#

Use text component in player send message

ancient ridge
#

can u look in help-server

#

plz

tardy delta
#

:/

#

wdym with textcomponent?

quaint mantle
#

Chatcolor.translateAlternateChatcolors('&', "message")

tardy delta
#

well yea that

hasty prawn
#

I assume that's what Utils.message is doing

#

Send that method Fourteen

tardy delta
#

that makes no sense it always works

quaint mantle
#

Or use Chatcolor.red "" ,... x)

quaint mantle
tardy delta
#

yes

#

ill debug it

#

okay it gets logged

#

but no message

#

maybe because i join too late

crimson terrace
#

try sending the message a little later?

tardy delta
#

probably

crimson terrace
#

that one tick probably isnt enough after joining for your chat to realize its been sent a message

novel totem
#

How do I make so that player heads are named and look like the person who died?

crimson terrace
#

edit the head that drops

#

I assume youre listening to playerDeathEvent?

novel totem
#

yea

crimson terrace
#

for the name you can just set the displayname of the head youre dropping to the event.getPlayer().getName() or whatever it is

#

as for the looks im not sure

quaint mantle
#

When I use p.getLocation().getWorld() I can't use the getName() method. I'm using the latest version, does anyone know what it is?

#

how to get the (x) element of an arraylist

#

i guess .get method

tardy delta
#

yes

#
if (uses.merge(uuid, 1, Integer::sum) > 2) { // uses is a hashmap```
this means if the hashmap contains uuid and it has a value it increments that value by 1 and checks if that result is > 2?
#

so it executes uses.put(uuid, uses.get(uuid) + 1) if the value if present

#

and then checks

#

well i'm trying to shorten my code but still need quite alot

ivory sleet
#

Yeah but usually I avoid using those higher order functions

#

Whilst they sure make the code a little bit cleaner it’s also some overhead in terms of speed

#

Only reason to use it for me is if the map is supposed to be used in a multi threaded environment

tardy delta
#

poh

ivory sleet
#

Though don’t worry

#

The speed here is negligible in difference

ashen flicker
#

Clean code is more important in my opinion than speed. Computers are so fast today that we are allowed to prioritize clean code, and we should.

hasty prawn
#

^^ To an extent atleast, if the clean code is noticeably slower, then we should probably prioritize performance.

ashen flicker
#

Yea but you really shouldn’t have that problem if you do it right. Clean code is really just abstraction and extraction. It really shouldn’t slow performance that often.

tardy delta
#

i'm just trying to clean my spaghetti up

ivory sleet
#

Thing is

#

You can just extract a method which operates as the merge without being a higher order function and then it’s going to be clean enough.

ashen flicker
#

Code should read like butter, and should he polite to someone reading it that didn’t make it.

ancient plank
#

I can't read butter

open imp
#

hey there i am facing an issue with my server while playing bedwars the error shown is Internal Exception: io.netty.handler.codec.EncoderException: java.lang.NullPointerException: Cannot invoke "org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil.ints.IntList.size()" because "intlist" is null can someone help me with this issue

ivory sleet
#

Send the stacktrace

open imp
#

what do u mean by stacktrace

#

i have no idea about that

hasty prawn
#

Send everything that it printed when it errored

open imp
#

[21:47:03] [Server thread/INFO]: panda3 lost connection: Internal Exception: io.netty.handler.codec.EncoderException: java.lang.NullPointerException: Cannot invoke "org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil.ints.IntList.size()" because "intlist" is null

#

[21:47:03] [Server thread/WARN]: java.lang.NoSuchMethodException: net.minecraft.network.protocol.game.PacketPlayOutEntityDestroy.<init>(int)

#

is this what u have asked me

quaint mantle
tardy delta
#

it's internal

open imp
#

what can i do to solve it

digital rain
#

i need quick help with this

#

the blue lines are the ones getting errored

chrome beacon
#

And what is the error

digital rain
quaint mantle
#

Is your command in plugin.yml?

chrome beacon
#

What is line 33

tardy delta
#

use a switch please

digital rain
tardy delta
#

lore == null?

#

item == null?

digital rain
#

nah i pass the itemstack via the thing

#

at least thats what it was always doing