#help-development

1 messages · Page 1437 of 1

paper viper
#

did you register the event

tardy delta
#

but what do people mean by register?

paper viper
spring walrus
#

As I said, Ill do what you recommended to me.. 😄 but it wont solve the problem 😄

opal juniper
#

It’s because the event handler calls it not ur code

paper viper
#

and the error

#

or else we can't help you

sharp bough
#

is there a way to fill an inv with a material if the slot is free? i could do a for i = 0 i < size and if the slot is free, but i wonder if theres something like fillWith

spring walrus
# paper viper also, the error likely caused from error on server startup caused your plugin to...
{
    @Override
    public void onEnable()
    {
        //check if files and databases exists etc
        new SetupDefaults(this);
        //register EventManager
        getServer().getPluginManager().registerEvents(new EventManager(), this);
        getCommand("stats").setExecutor(new stats());
        System.out.println("[FoxStats] Plugin enabled.");


        Plugin plugin = this;
        new BukkitRunnable() {
            @Override
            public void run() {
                DatabaseCleanup cleanup = new DatabaseCleanup();
                cleanup.runTaskTimer(plugin, 0, 72000L); //every hour check for available database cleanup
            }

        }.runTaskLater(this, 1);
    }

    @Override
    public void onDisable()
    {
        System.out.println("[FoxStats] Plugin disabled.");
    }
}```

and error here: ```[16:08:58 ERROR]: [FoxStats] FoxStats v0.0.1 BETA attempted to register an invalid EventHandler method signature "public void eu.skyfox.foxstats.events.EventManager.onPlayerHarvest(org.bukkit.event.player.PlayerHarvestBlockEvent,eu.skyfox.foxstats.storage.MySQL)" in class eu.skyfox.foxstats.events.EventManager ```
paper viper
#

you can only pass one argument in an eventhander method

#

which is the event itself

spring walrus
#

Than why the onBlockDropItem works fine? 😄

fringe imp
#

you're only passing that method the event

tardy delta
#

well I think it's easier for me to use an eventlistener class

spring walrus
#

Like, if I only leave @EventHandler public void onPlayerHarvest(PlayerHarvestBlockEvent e) { System.out.println("Harvest!"); }, it still does not execute, thats the weird thing.. 😅

#

oh wait

spring walrus
gaunt eagle
#

There is normally no reason not to send an actionbar to a player. Any idea?

spring walrus
#

athough it still does not do anything 😅

gaunt eagle
#

Is there a limited number of characters in the message? so it didn't work 🤔

quaint mantle
#

did you register the listener?

gaunt eagle
quaint mantle
#

yes

gaunt eagle
#

all code is

quaint mantle
#

well you didnt register the event

gaunt eagle
#

ah

#

!

quaint mantle
#

do getServer().getPluginManager().registerListener(this, this)

gaunt eagle
#

I gave up using NMS and turned to this. I forgot

sudden raft
#

i think you should use TextComponent.fromLegacyText

gaunt eagle
#

yeah, sorry my dumby xD

quaint mantle
#

its alright

gaunt eagle
#

yeah god thanks, working now. I just can't believe I spent 30 minutes doing this -_-

tardy delta
quaint mantle
#

oh sorry maybe its registerEvent

ivory sleet
#

registerEvents*

tardy delta
#

oh yea

quaint mantle
#

yeah sorry i didnt have my ide opened and didnt remember it

tardy delta
#

i hope that works 🥲

#

well uh its still not working

#
public class MagmaBuildNetwork extends JavaPlugin implements Listener {

    @Override
    public void onEnable() {
        getLogger().info("onEnable is called!");

        // This will throw a NullPointerException if you don't have the command defined in your plugin.yml file!
        this.getCommand("ignite").setExecutor(new PluginCommandExecutor(this));

        getServer().getPluginManager().registerEvents(this, this);

        saveDefaultConfig();
    }
    @Override
    public void onDisable() {
        getLogger().info("onDisable is called!");
    }

    @EventHandler
    public void onPlayerJoin(PlayerJoinEvent event) {
        event.getPlayer().sendMessage("Welcome to the server!");
    }
}

It gives me no welcome message..

#

someone who has ideas?

quaint mantle
#

does the plugin load?

tardy delta
#

yes

quaint mantle
#

do you export it into right directory?

tardy delta
#

which configuration do i need to use for that?

quaint mantle
#

wdym by configuration

tardy delta
#

never done before

quaint mantle
#

no you dont do this

tardy delta
#

uh

quaint mantle
#

press ctrl alt shift s and do artifacts

tardy delta
#

well there's nothing there

quaint mantle
#

well you need to create it

limpid drum
#

am i allowed to ask a question about intellj idea here

sleek pond
#

depends

#

but probably yes

#

!ask

#

bruh

#

?ask

queen dragonBOT
#

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.

gaunt eagle
#

Is it possible to add spigot.jar directly to pom without sending it to libs?

#

and how, can anybody help me ^^

quaint mantle
#

wdym by sending it to libs

gaunt eagle
sage dock
#

which is better to use mysql connection (regular) or mysql pool? For Minecraft Network

sleek pond
tardy delta
#

uhh for some reason the playerjoin still isnt working

public class MagmaBuildNetwork extends JavaPlugin implements Listener {

    @Override
    public void onDisable() {
        getLogger().info("onDisable is called!");
    }

    @Override
    public void onEnable() {
        getLogger().info("onEnable is called!");

        // This will throw a NullPointerException if you don't have the command defined in your plugin.yml file!
        this.getCommand("ignite").setExecutor(new PluginCommandExecutor(this));
        this.getServer().getPluginManager().registerEvents(this, this);

        saveDefaultConfig();
    }

    @EventHandler //THIS ONE

    public void onPlayerJoin(PlayerJoinEvent event) {
        Player p = event.getPlayer();
        event.setJoinMessage("&7[&a&l+&7] &b" + p.getName() + " &7joined the server.");
    }
}
quaint mantle
pulsar zenith
#

I know this might sound nooby but how can I have a hashmap be synchronized between classes? I currently have special items which have per-item cooldowns in their classes, so how can I set a value in the hashmap in those class so the cooldown goes away when I run a method from my commandhandler class?

quaint mantle
#

make the hashmap static

pulsar zenith
#

Ok, just making sure. Thanks

quaint mantle
#

then access it with ClassName.hashmap

summer scroll
#

oh no no no

sharp bough
#

does anyone have an example of a multipage inventory to display as many items as i want to?

summer scroll
#

static hashmap, oh no no no

sharp bough
#

with like an arrow that sends you to the next / previous page

summer scroll
#

So create a manager class.

pulsar zenith
#

Ok, so a class which will manage all of the cooldowns?

summer scroll
#

Yes.

pulsar zenith
#

Alright, so then how should I change the values of those cooldowns from my commandhandler class? Just use a getter-setter method?

summer scroll
#

Using dependency injection.

pulsar zenith
#

Alright thank you, Ill look into that.

tardy delta
#

can i use color codes inside the "onEnable is called":

@Override
    public void onEnable() {
        getLogger().info("onEnable is called!");
}```
quaint mantle
#

How can I remove the anchor block explosion?

tardy delta
#

and cmd?

quaint mantle
#
    @EventHandler
    public void anchorExplode(BlockExplodeEvent event) {
        event.blockList().clear();
        log.info(event.getBlock().getType().toString());
        
        /*
         * This does blocks ALL block explode events
         * including beds.
         * This has to be fixed at some point, but
         * currently event.getBlock()
         * doesn't give the right block.
         */
    }
#

I can't use BlockExplodeEvent, because it happens before the explosison.

quaint mantle
#

Your terminal has to support ANSi color codes and V100

#

Which doesn't happen a lot

tardy delta
#

and ingame? bcs i now get this

quaint mantle
#

(cmd doesn't allow it to hapen easily too)

quaint mantle
tardy delta
#

well i want to use different colors so that would be a very long sentence

#

lets try then

quaint mantle
#

Wait a second

tardy delta
#

hu

quaint mantle
#

Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', "your string"));

#

Here you go

#

It's ChatColor.RED for red

#

BTW

tardy delta
#

oh

#

yea i know that

#

thanks

quaint mantle
#

Did you see this

tardy delta
#

yes

#

using it right now 🥲

livid tundra
#

is there a way to make something execute when an entity moves?

#

or on a tick?

pulsar zenith
#

Bukkit runnable or EntityMoveEvent

tardy delta
pulsar zenith
#

at least I think entitymoveevent exists

young knoll
#

That event does not exist

pulsar zenith
#

nope its only in paper

young knoll
#

For obvious reasons

pulsar zenith
#

in that case I would use a bukkitrunnable if you only need to run something every tick

livid tundra
#

how do you do that?

young knoll
#

It’s not in paper either

livid tundra
#

or it could be every second.

pulsar zenith
#

it is in paper

#

This fourm post has a great solution which worked for me

gaunt eagle
#

wait

pulsar zenith
gaunt eagle
#

I wanted to say is there a way to use it by adding something directly to pom.xml without adding it here

grim sage
#

Hey pls someone know how to restart the ender dragon fight as if a player placed the 4 ender crystal on the portal, I have tried to use dragonBattle.initiateRespawn() where dragonBattle is the battle linked to my World but it doesn’t work

rare rain
grim sage
quaint mantle
#

ig then just kick everyone out of the world and recreate it

young knoll
#

That will destroy any end farms

grim sage
#

Yeah

#

But what really annoy me is that there is a method for what I want to do but it doesn't work x)

cold tartan
#

im getting this error when i start my server up:

java.lang.NullPointerException: null
        at com.defiantburger.tutorial.tutorial.onEnable(tutorial.java:27) ~[?:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[patched_1.16.5.jar:git-Paper-651]
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:380) ~[patched_1.16.5.jar:git-Paper-651]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:483) ~[patched_1.16.5.jar:git-Paper-651]
        at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugin(CraftServer.java:501) ~[patched_1.16.5.jar:git-Paper-651]
        at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugins(CraftServer.java:415) ~[patched_1.16.5.jar:git-Paper-651]
        at net.minecraft.server.v1_16_R3.MinecraftServer.loadWorld(MinecraftServer.java:591) ~[patched_1.16.5.jar:git-Paper-651]
        at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:281) ~[patched_1.16.5.jar:git-Paper-651]
        at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1065) ~[patched_1.16.5.jar:git-Paper-651]
        at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:289) ~[patched_1.16.5.jar:git-Paper-651]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_291]
quaint mantle
#

hello, does anyone know how to make text that can appear over the toolbar?

cold tartan
quaint mantle
#

do you have top in plugin.yml?

cold tartan
#

ofc, i cant believe i forgot that

cold tartan
cold tartan
quaint mantle
quaint mantle
#

/ latest build

quaint mantle
#

soon gonna switch to 1.8.8

#

when do you wanna send the actionbar

quaint mantle
#

or, send it and remove when player goes out of vanish

#

okay you may wanna try player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("Message"));

#

Okay, let me try

#

ok

#

Anybdoy know the event for Enderdragon spawn

#

or just Entity spawn?

#

check for entityspawn and then if the entity is enderdragon

quaint mantle
#

Is there any way to make the text like a little transparent?

#

i dont think so

#

alright, thank you!

#

yw

compact haven
quaint mantle
compact haven
#

top -> CommandTop or TopCommand

#

top is lowercase, doesn tmeet convention

#

and command classes should start/end with Command

cold tartan
#

also, is there a way to detect the location that a raycast ends at?

proven sierra
#

Get the location of what it returns

quaint mantle
cold tartan
#

ray.getHitPosition?

#

I get a nullpointer exception w/ this code:

player.teleport(ray8.getHitBlock().getLocation());
#

because ray8 is null

#

but how would i get it to not be null

#

as far as I can tell i would have to check if its null, and if it is then get the location of ^ ^8 ^

#

which i think is 8 block directly ahead

quaint mantle
#

hello. i'm here about my vanish command again, how do i make it so the player that's vanishing is still visible to other staff members who have op for example or have a specific permission?

#

and for vanished players, add something like a [V] before their name to indicate that they're vanished

noble spire
#

.javadoc

#

?javadoc

noble spire
maiden briar
#

I saw you can register commands without plugin.yml into Bukkit, but is this also possible in Bungee?

maiden briar
#

This only shows which commands you can use

#

Then I'll need to look into their source

sage swift
#

literally third result bro

hoary tiger
#

I have this line of code, ((CraftWorld)event.getEntity().getWorld()).spawnEntity(event.getEntity().getLocation(), EntityType.type); But I would like to have a dynamic type is that possible? I have an onDeath event as my variable.

sage swift
#

whyyyyy are you casting it to craftworld

maiden briar
#

Will this also work without plugin.yml then?

sage swift
#

read the command tutorial

maiden briar
#

Ok...

hoary tiger
sage swift
#

no... you dont

hoary tiger
#

ok then how whould I do it? I'm sorry I kinda new to this

maiden briar
#

It didn't got mentioned "without plugin.yml", so it always work without plugin.yml?

sage swift
#

World has the method

hoary tiger
#

Alright I'll try

maiden briar
#

And now without caps pls

sage swift
#

what do you mean by dynamic type

#

EntityType.values().get(random.nextInt(EntityType.values().size()))

#

will choose a random entity type

#

but obviously that includes players and ender dragons

#

so you would be better off making a list of the ones you want to spawn

hoary tiger
#

Sorry, I have a Listener that listens for a animal deathEvent. I from the event, I need to spawn that Entity again. And yes I will remove players from the code

sage swift
#

better yet, put it in the config

#

ohhh

hoary tiger
#

I kinda want all mobs to "respawn"

sage swift
#

well the event should be able to get the entity type

quaint mantle
#

hello, some people have told me to use hash over arraylist

#

How do i make a hashlist??

sage swift
#

no such thing as a hashlist

onyx shale
#

thats... not..

cold tartan
#

how do you make explosions not destroy blocks?

onyx shale
#

List<T> list = new ArrayList();

sage swift
#

there's hashset which is probably what you're talking about

#

BlockExplodeEvent

quaint mantle
#

yes, sorry i've been creating plugins for 1 month only now. never heard of hash before

onyx shale
#

Set<T> listAsSet = new HashSet();

cold tartan
#

just for a specific explosion

sage swift
#

if you spawn it in yourself you can set whether it blows up blocks

onyx shale
#

not much different between a list and a hashset,the list has a nice index you can use,the set doesnt allow duplicates

sage swift
#

8 createExplosion methods

quaint mantle
#

and apparently arraylist can't do that

onyx shale
#

you can

#

you just store theyr uuid

#

and do the checking urself

quaint mantle
#

they told me that hash is better though

#

so i'm kinda confused here

sage swift
#

what is "hash"

#

you mean set?

quaint mantle
#

yes

hoary tiger
sage swift
#

event.getEntity.getType

quaint mantle
#

"
No, like I said
An ArrayList is not good
Use a HashSet<UUID>
"

#

you probably should use arraylist @quaint mantle

sage swift
#

yes thats a set

#

and you should use the set

#

because you won't be storing values twice

#

nor will you need them in any specific order

quaint mantle
#

alright

#

thank you

sage swift
#

its much more efficient for your use case

quaint mantle
#

the hashset?

sage swift
#

the set yes

quaint mantle
#

hashset is like 3900ns faster lol

#

why wouldnt you use it in this case

#

Okay, let me try it tho

sage swift
#

because he didnt know about it

cold tartan
#

how do you make explosions bounce you upwards?

sage swift
#

put them below the player

quaint mantle
#

do they not already

split panther
#
  1. use Minecraft default behavior
#
  1. math
cold tartan
quaint mantle
#

the thing that makes sure when a new player joins, staff stay hidden broke..

player.hidePlayer(plugin, plugin.invisible_list.get(i));

#

the .get

onyx shale
#

as i said above

quaint mantle
#

you gotta use a list for that i think

quaint mantle
#

okay, 2 people have told me to use array and 2 have told me to use hash

sage swift
#

you dont need to iterate through them like that

quaint mantle
#

what?

sage swift
#

here's what you do hold on i type

split panther
quaint mantle
split panther
#

great 👍

sage swift
#
for (Player vanished : plugin.invisibleSet) {
  evt.getPlayer().hidePlayer(vanished);
}```
#

that will get the objects themselves without having to use the indices

#

which you had been using as i

quaint mantle
#
    public void PlayerJoin(PlayerJoinEvent e){
        Player player = e.getPlayer();
        for (int i = 0; i < plugin.invisible_list.size(); i++ ){
            player.hidePlayer(plugin, plugin.invisible_list.get(i));
        }
    }
#

this is my check event

sage swift
#

and i just told you what to do

quaint mantle
#

alright

sage swift
#

dont need the i in the for loop

cold tartan
#

is there a way to launch a player the direction they are looking?

split panther
#

yes

#

addVelocity to them

#

calculate velocity by getting the direction they're looking at (I assume it's a unit vector) and multiply by how fass you want them to go

sage swift
#

there is no easy way to do it i don't think

#

you'll have to construct a vector with the player's pitch and yaw

split panther
#

no, you can just get it from Player class

quaint mantle
#

no you dont

#

just multiply their velocity

sage swift
#

what if theyre facing one way and moving backwards

#

thats not what you need

quaint mantle
#

i've done this before

#

1 sec ill fidn my code ofr it

split panther
quaint mantle
#

^

grim sage
#

Hey pls someone know how to restart the ender dragon fight as if a player placed the 4 ender crystal on the portal, I have tried to use dragonBattle.initiateRespawn() where dragonBattle is the battle linked to my World but it doesn’t work

sage swift
#

he wants the player to go in the direction the player is facing...

#

not moving

quaint mantle
#

public HashSet<Player> invisible_list = new HashSet<>();

#

am i doing it right?

#

nvm

#

i realised

#

hashet<uuid

sage swift
#

no, use UUID

quaint mantle
#

?

#

right

#

yea

#

But in my vanish code idk how to grab the uuid

sage swift
#

at the start, you can also put just public Set<UUID>

#

Entity#getUniqueId

quaint mantle
#

will the getuniqueid output a string?

grim sage
#

Yes but if I do that I will have to replace all crystal and to re create a boss bar :/

quaint mantle
#

no you dont

sage swift
split panther
quaint mantle
#

doesnt the dragon rely on the crystals you made?

#

Player player = (Player) sender;

#

this get's my player

#

idk how to make it get an uuid

split panther
#

^ make sure to check that player is a sender there

sage swift
#

in a command yes

#

player.getUniqueId

#

:]

cold tartan
#

got the launch thing

quaint mantle
#

geez y'all are so helpful towards new people to programming hahah

#

not like this another server that barked at me to go to the right section just because i asked for some help

split panther
#

[deleted message]
wrong channel

grim sage
quaint mantle
onyx shale
#

it can go the other end rather quick

#

if it comes to java basics

paper viper
#

if that is the case than yeah then go learn

#

lol

grim sage
#

When I just spawn a dragon there is no boss bar and crystals doesn’t appears

split panther
#

deleted though

#

it's now in general if you're curious 😆

quaint mantle
#

i feel so retarded...

split panther
#

nah

quaint mantle
#

I know its an easy fix but idk how do do it

onyx shale
#

meh its wrong channel if someone needs help or smthn

quaint mantle
#

the uniqueid part

onyx shale
#

usually all channels turn to shitfest

#

as it does rn

split panther
#

lol

hoary tiger
#

Yeah this server is so helpful

quaint mantle
#

yes, im just stupid

sage swift
#

except for me

#

im mean

quaint mantle
# sage swift except for me

yes, its not helpful for you because nobody can help you. youre too smart. and your issues are out-of everyones leagues

sage swift
#

honestly yeah no one helps me with my problems anymore

quaint mantle
#

it's confirmed that people who have numbers after their names are usually the smartest

sage swift
#

there are 10000 of me

quaint mantle
#

dam

split panther
#

😮

quaint mantle
#

10k bigbrains

quaint mantle
sage swift
#

i tutor 👀

quaint mantle
#

i'll probably need to buy a course soon since i cant even get this uuid

quaint mantle
sage swift
#

whats happening with the uuid

quaint mantle
#

i'm learning minecraft plugin development mainly because i have a powerful server at home that I want to put-to use and make a mc server on it.

split panther
#

most course probably won't mention UUID
but you should know data structure stuff though
UUID is just a class after you're familiar with Java

quaint mantle
sage swift
#

so all entities have a UUID

quaint mantle
#

yes

wraith rapids
#

powerful server isn't enough

sage swift
#

you can get the entity through Entity#getUniqueId

#

since Player is an Entity it has getUniqueId as well

wraith rapids
#

you'll also need an UPS and a high end internet connection

quaint mantle
wraith rapids
#

number of cores doesn't matter

sage swift
#

to get the player from the uuid, you can do Bukkit.getPlayer(UUID)

wraith rapids
#

amount of physical memory hardly matters

#

what's the single thread rating

#

network bandwidth also doesn't matter, latency is more important

split panther
wraith rapids
#

well, for smaller servers anyway

split panther
#

but yeah, single core performance is more important than amount of cores

quaint mantle
#

How do i see that?

wraith rapids
#

many people run bigger servers on single core or dual core systems

quaint mantle
#

it's an i7-9700K

wraith rapids
#

for smaller servers dedicated core solutions are preferred over having multiple shared cores

#

especially on spigot

#

since splögget doesn't leverage threading as much as the alternatives do

quaint mantle
#

oh wait

hoary tiger
#

So sorry to interupt but for the spawn entity method how would I add PDC?

split panther
#

Bukkit is static

sage swift
#

Entity#getPersistentDataContainer

sage swift
#

then you can set the value of a NamespacedKey which basically makes it so you dont interfere with other plugins' data

wraith rapids
#

since it's persistent you'll also have to specify a data type which handles serialization to a primitive type

quaint mantle
#

Player player = Bukkit.getPlayer(UUID);

sage swift
#

yes

quaint mantle
#

:O

#

ah yes, a new error

#
'add(java.util.UUID)' in 'java.util.HashSet' cannot be applied to '(org.bukkit.entity.Player)'
sage swift
#

you're adding the player

#

need to add the uuid

hoary tiger
#

Alright you guys are the best 😄

wraith rapids
#

your set contains UUIDs, you're trying to add a Player

quaint mantle
#

Wha

#

add this player.getUniqueId() instead of player

split panther
#

set.add(player) -> set.add(player.getUniqueId())

cold tartan
#

do you guys know why this isnt working?

@EventHandler
    public static void onDamage(EntityDamageEvent event) {
        LivingEntity entity = (LivingEntity) event.getEntity();
        if (entity.getHealth() - event.getDamage() < 1) {
            event.setCancelled(true);
            entity.sendMessage("You almost died!!!");
        }
    }
young knoll
#

no

#

0 is dead

#

less then 1 will show as half a heart

#

Also event.getFinalDamage

#

Heath is a double

#

The game just rounds it to half hearts

cold tartan
#

ty

quaint mantle
#

@young knoll

#

if two halves of an egg equal a whole egg, what does a pound of butter weigh?

young knoll
#

13

quaint mantle
#

What

young knoll
#

What

quaint mantle
#

if two halves of an egg equal a whole egg, what does a pound of butter weigh

young knoll
#

About 0.45 kilograms

quaint mantle
#

nah

#

it has to be exact

young knoll
#

0.453592

quaint mantle
#

Good job

split panther
#

0.45359237

young knoll
#

Just to double check, spigot does not have a creeper ignite event, does it

onyx shale
#

it might

split panther
#

why I have feeling that it's not?

#

idk

onyx shale
split panther
#

I have been doing backend for too long

young knoll
#

That isn't an event

split panther
#

that's a method :3

onyx shale
#

ah yeah

#

seems like not

young knoll
#

And sadly ExplosionPrimeEvent runs at the end of the fuse, not the start

split panther
#

yeah, I think I had that problem before

quaint mantle
young knoll
#

What does that have to do with creepers

quaint mantle
#

oh my bad

young knoll
#

Guess I either need to listen for outgoing packets (maybe) or use paperlib

#

Or not be lazy and try to pr it to upstream

onyx shale
#

just add an extra check on the tick

young knoll
#

Don't really want to replace the entity

#

Ehhhh

onyx shale
#

well in that case

#

the other one... has... a ... event...

young knoll
#

I'm aware

#

Hence my though of PRing to upstream

onyx shale
#

you think it would be accepted tho?

quaint mantle
#

Player player = p.getUniqueId();

#

omgg

#

what am i doing wronggg

#

i hate this

onyx shale
#

UUId =/= Player

quaint mantle
#

waht?

onyx shale
#

look at the method and see what it returns

young knoll
quaint mantle
onyx shale
#

it does return a UUID

eternal oxide
#

Then don;t store it as a Player. Store it as a UUID

quaint mantle
#

Why is it a red underline then D:

onyx shale
#

yet ur trying to store it in a Player

wraith rapids
#

learn java

onyx shale
#

object

quaint mantle
onyx shale
#

or that

onyx shale
#

didnt want to go straight to it

eternal oxide
#

Look at your line of code again.

quaint mantle
#

i didn't know going from discord bot creating to minecraft plugin developing would be so confusing

wraith rapids
#

it isn't

onyx shale
#

what language is discord?

#

cause i know its literally almost everything

quaint mantle
#

java

wraith rapids
#

you just have no clue what you're doing with the language you're writing in

wraith rapids
#

this is java 101

quaint mantle
#

that solved alot

wraith rapids
#

you are calling a method with a return type of UUID and trying to assign the returned value into a variable of type Player

young knoll
#

You can write discord bots in a lot of languages

wraith rapids
#

Player is not a supertype of UUID

eternal oxide
#

Sometimes you can be blind to the simplest of mistakes

sharp bough
# onyx shale

hey noob question, when you do this. what does that mean?

#

what would this. be in that case?

wraith rapids
#

it means this object

quaint mantle
#

thank you! @eternal oxide

onyx shale
#

thats overriding nms,each entity calls a tick method so it does something

#

for example a entity will call tick to move,to find a target or smthng

#

this can be overridden to add extra logic

wraith rapids
#

this.fieldname is synonymous with just fieldname

#

unless there is a variable by the same name in the same scope

onyx shale
#

oh hes talking about

#

nvm

wraith rapids
#

i have no clue what he's talking about, I can't see replies

onyx shale
#

he tagged my nms photo

wraith rapids
#

but i assume he's talking about the this keyword in the screenshots you sent

onyx shale
#

seems like it

wraith rapids
#

the answer to "what is this" involves understanding oop

sharp bough
#

like if i have something like

public void onclick(InventoryClickEvent evet)
this.getWhoClicked

would return the player that clicked the inv

wraith rapids
#

there is no simple explanation

#

other than that it just refers to the current object

onyx shale
#

i guess simplest would be this points to current instance

wraith rapids
#

but without understanding oop it means nothing

onyx shale
#

wich as he said,instance is oop

wraith rapids
#

because you'll think in terms of classes

#

and not objects

#

this returns the object the method is called on

sharp bough
#

hm ig i just have to make a new file and test it

#

bruteforce it

onyx shale
#

not good practice

#

just go with a tutorial

wraith rapids
#

in onEnable, this refers to the instance of your main class that bukkit constructs

#

basically look up some oop explanation or tutorial somewhere

gaunt eagle
#

Has .watch() been depraced? any idea?

#

i wanna do NPC things like that

#

(1.16.5)

eternal oxide
#

look at your error

gaunt eagle
#

oh sorry i miss it

#

just weird error

quiet ice
#

are you sure that method still exists?

eternal oxide
#

a method with that footprint does not exist

gaunt eagle
#

method? I don't already have such a method

#

Not using DataWatcher class for npc's?

eternal oxide
#

It is saying the method watcher(int, byte) does not exist

quiet ice
#

the last argument looks like a magic variable to me, perhaps that got replaced

gaunt eagle
#

wtf, the guy in my guide video was using it quite normally, our codes are the same

quiet ice
#

The versions are not though#

gaunt eagle
#

I'll check again to see if there is a place I missed

quiet ice
#

Times change

gaunt eagle
#

i'm 1.16.5

quiet ice
#

you see, 1.13 did a lot of improvements on a lot of issues

#

This means magic values are more or less gone and I bet this is an instance of it

#

Try to look into the class and find a more appropriate method that looks similar in what it does

gaunt eagle
#

oh, wish luck for me -_-

maiden briar
#

I am trying to register a command without plugin.yml, but now I just get "command not found"

public void registerCommand(Command command)
    {
        System.out.println("Registering " + command.getName());
        org.bukkit.command.Command bukkitCommand = new org.bukkit.command.Command(command.getName())
        {
            @Override
            public boolean execute(CommandSender sender, String label, String[] args)
            {
                command.handle(new BukkitCommandSender(sender, chatFormat, pluginLoader), label, args);
                return true;
            }

            @Override
            public List<String> tabComplete(CommandSender sender, String label, String[] args) throws IllegalArgumentException
            {
                return command.tabComplete(new BukkitCommandSender(sender, chatFormat, pluginLoader), label, args);
            }
        };

        bukkitCommand.setAliases(command.getAliases());
        bukkitCommand.setPermission(command.getPermission());
        bukkitCommand.setPermissionMessage(command.getNoPermissionMessage());

        ReflectedObject commandMap = new ReflectedObject(bukkitPluginLoader.getServer()).get("commandMap");
        commandMap.getMethod("register").invoke(commandMap, command.getName(), bukkitCommand);

        registeredCommands.add(command);
    }
#

Command is my own class, org.bukkit.command.Command is bukkit's class

quaint mantle
#

Why not

#

CustomCommand

maiden briar
#

Idk, I need to get better names for some classes indeed

wispy fossil
#

name them letters of the alphabet in order of when you create them

maiden briar
#

Haha ok

#

But my issue?

#

Oh I see, I made a mistake: I only need the name and the command itself in the method, no commandMap

#

But weird that I didn't get any stacktrace

#

Not yet working....

maiden briar
severe folio
#

why are you reflectively invoking the register method when you can just use reflection to get an instance of SimpleCommandMap (which afaik isnt version dependant)

public static SimpleCommandMap getCommandMap() {
    Field cmdMap = Bukkit.getServer().getClass().getDeclaredField("commandMap");
    boolean cmdMapAccessible = cmdMap.isAccessible();

    cmdMap.setAccessible(true);
    SimpleCommandMap commandMap = (SimpleCommandMap) cmdMap.get(Bukkit.getServer());
    cmdMap.setAccessible(cmdMapAccessible);
    
    return commandMap;
    
}```
#

something like that

maiden briar
#

Oh yes the SimpleCommandMap is not with version

severe folio
#

(I didnt catch the relevant exceptions, make sure to do that)

maiden briar
#

Yes I will do

severe folio
#

👍

maiden briar
#

I must do 😄

#

Ok working now, thanks for the help!

cerulean harbor
#

i think my plugin is somehow causing IO exceptions, can someone please take a look?

quaint mantle
#

let us just know the errors somehow

opal juniper
blazing scarab
#

show errors and code

sage swift
#

isnt there a way to make an item only able to interact with certain blocks? or is that adventure mode

sage swift
quaint mantle
severe folio
#

{CanDestroy:["minecraft:stone"]}

sage swift
#

is there something in spigot api for that

severe folio
#

im not actually sure lmao

cold tartan
#

for EntityDamageEvent how would u check if the damager is an instance of player?

quiet ice
#

instanceof Player

cold tartan
#

ik

#

but event. doesnt show the damager

quiet ice
#

use the EntityDamageByEntityEvent

cold tartan
#

ok

quiet ice
#

or something like that, idk

severe folio
#

EntityDamageByEntityEvent and event.getDamager() instanceof Player

sharp bough
#

so im trying to implement a reload cmmand, this is what i have so far

                if (checkPerm(player, "chest.reload")) {
                    new Reload().reload();
                }
            }```
wich works perfectly, unless i do saveConfig in the time that i edit and save, how could i force it somehow, should i remove all the saveConfig in my code so it doesnt update?
#

and only save config on disable

#

or reload

severe folio
#

whats the point in saving config.yml on reload, it'd just overwrite any changes somebody makes, wouldnt it?

sharp bough
#

yea ig

#

i could remove all saveConfig

#

so when i reload

#

oh wait i sent the wrong code

#

lmao

#
        Main.get().saveDefaultConfig();
        Main.get().reloadConfig();
    }```
eternal oxide
#

store teh file modification time in memory when you load the config. When you reload if the file modification time is different to that in memory it was altered so you can load instead of save

onyx shale
#

anyone got a way to move multiple armorstand based on a base armorstand rotation?

sharp bough
#

how do i get the file modification time

eternal oxide
#

when you load the config you read its file modification attribute and store that in memory.

#

You can then compare teh files attribute any time you want to see if the file has been modified since you last read it

wispy fossil
sage swift
#

why do you say teh instead of the

opal juniper
karmic sapphire
#

Greetings dear developers, any knows what sound plays when a item get bone mealed?

quaint mantle
#

not sure

#

same

karmic sapphire
quaint mantle
#

nope

quaint mantle
#

mb

cold tartan
#

i a null pointer exception when this event is called for some reason:

sage swift
opal juniper
cold tartan
opal juniper
#

where does it say the error is

#

like copy the error

karmic sapphire
cold tartan
opal juniper
sage swift
#

so whats on line 40

#

and why is the class lowercase

cold tartan
sage swift
#

well its wrong

#

thats besides the point, show line 40

opal juniper
#

yeah

cold tartan
#

this is on line 40:

if (wands.contains(event.getItem().getItemMeta())) {
sage swift
#

so the item is null

#

or wands is null

karmic sapphire
opal juniper
#

oh, so there is a few things

sage swift
#

or the item is air which doesnt have a meta

cold tartan
#

this is wands:

ArrayList<ItemMeta> wands = new ArrayList<ItemMeta>();
        wands.add(itemManager.explosion_wand.getItemMeta());
        wands.add(itemManager.growth_wand.getItemMeta());
        wands.add(itemManager.bounce_wand.getItemMeta());
karmic sapphire
#

thanks for the help everyone

severe folio
sage swift
#

so wands is not null

#

check if the player is right clicking with an empty hand

opal juniper
sage swift
#

ie check if getItem is null

#

if (evt.getItem() == null || evt.getItem().getType() == Material.AIR) return;

#

there you go

sage swift
#

but you really should not be using item meta to find your item

cold tartan
#

how should i?

sage swift
#

pdc

#

check for a specific tag

opal juniper
#

Which is Persistant Data Container if you didn't know

cold tartan
#

so like how would i add that

severe folio
opal juniper
#

gl!

cold tartan
#

what is

pluginInstance

#

in NamespacedKey key = new NamespacedKey(pluginInstance, "our-custom-key");

severe folio
#

an instance of your class that extends JavaPlugin

cold tartan
#

k so like:

public class tutorial extends JavaPlugin {
#

that?

severe folio
#

yea

cold tartan
#

so what would it look like in that line?

severe folio
#

you need an instance of it, so like, ```java

private static MyPlugin instance;

public void onEnable() {
instance = this;

// the rest of your onEnable
}

public static MyPlugin getInstance() {
return instance;
}

severe folio
#

using the example i specified, NamespacedKey(pluginInstance, "our-custom-key"); would become NamespacedKey(MyPlugin.getInstance(), "our-custom-key");

severe folio
#

also, i'd recommend making all your classes start with an Uppercase letter

cold tartan
#

hmmmmm

#

now it doesnt work at all

#

but there arent any errors

#

nvm

#

it was a typo in a string

hollow canopy
#

Guys I tried to make a dash thing and I wrote this

#

`public void dash(PlayerInteractEvent e) {

        Player player = e.getPlayer();
                
        if(player.getInventory().getItemInMainHand().getType() == Material.SHIELD){ 
            
            if(e.getAction() == Action.RIGHT_CLICK_AIR) {
             Vector vector = player.getLocation().getDirection();
             vector = vector.multiply(1);
             player.setVelocity(vector);
             }
        }`
#

there is no error in eclipse but it is not working

severe folio
#

Multiplying by 1 will just make it the same

#

1 lot of 1 is 1

#

(1*1 = 1)

dry beacon
#

I'm trying to replace a block at a certain location and I'm not sure why but it's not working. The block stays the same even though sysout outprints OBSIDIAN Could someone please help me out? ```java
Block b = player.getTargetBlock(null, 5); // targeted player block
Location loc = b.getLocation();

if (b.getType().equals(Material.CHIPPED_ANVIL) || b.getType().equals(Material.DAMAGED_ANVIL)) {
loc.getBlock().setType(Material.OBSIDIAN); // I try setting to obsidian

  System.out.println("Block set to:" + b.getType().toString());

}```
Here's the full class if anyone wants to check it out https://pastebin.com/NWhpzqbg

severe folio
#

you get the blockdata before setting the block to obsidian, and then set it back to whetever it was, which im guessing changes the material back

dry beacon
#

Hmm, I need the block data to save the block direction though

onyx shale
#

loc.getBlock() why cast it again to block

#

if you alrdy have a block reference just above?

hollow canopy
#

@severe folio nothing changed I change the multiply thing to 2

#

still same

onyx shale
#

well you need to consider its on interact event

onyx shale
#

so if you stand still and click smthng you basically have no velocity 0,0,0

severe folio
onyx shale
#

try moving and do what you want

#

and see how your flying

hollow canopy
#

still same when I fly or move

hollow canopy
onyx shale
#

wait

#

ur getting the direction

#

try player.getVelocity

hollow canopy
#

Vector vector = player.getLocation().getDirection().getVelocity();

#

like this?

onyx shale
#

player.getvelocity

stiff topaz
#

In a list of arguments how can I get the first and last arg

sage swift
#

pretty sure @severe folio told you how to solve it lmao

severe folio
#
@EventHandler
public void myEvent(SomeEvent event){
  // ...
}

and did you register it with Bukkit.getPluginManager().registerEvents(listener, plugin) in your onEnable or wherever you register them.

severe folio
#

check the length of the array first

hollow canopy
#

`public void onEnable() {
getLogger().info("Ekstra Silahlar Aktif");
Bukkit.getPluginManager().registerEvents(this, this);

}`
#

I am using register thing like this

onyx shale
#

some snippet from a scroll

#

this will leap the player

#

in the direction his facing

#

works both moving or standing still

#

multiply the power,setY how high

severe folio
# hollow canopy I am using register thing like this

Firstly, move the event to a separate listener class. Listening for events in the main class is bad practice (afaik)
Secondly, ensure you have the @EventHandler annotation above the event method.
Thirdly, use player.getVelocity() instead of the direction.

hollow canopy
#

ahh

#

I forgot @eventhandler

#

I see

cold pawn
#

I dunno if im going crazy but I ran a plugin I just made and in console it said I did not specify the main class "aight ez fix" I went in a checked and I have specified the main class again but when I ran it the second time it still says the same thing I tried renaming classes and making the main class path shorter but it still syas the same thing is there a reason why?

onyx shale
#

is the package also right?

cold pawn
#

yes it is

onyx shale
#

post a pic of the structure

sage swift
#

and the plugin.yml

cold pawn
hollow canopy
#

thanks @severe folio @onyx shale my problem solved

onyx shale
#

your package structure looks fkd

#

try main.java.fun...

cold pawn
#

how?

sage swift
#

no

#

it looks fine

opal juniper
onyx shale
#

hierarchy should start from src

sage swift
#

how are you compiling?

cold pawn
sage swift
#

not for main class name, stellrow

opal juniper
onyx shale
#

ro.Stellrow.BetterPets.BetterPets

cold pawn
#

Im using maven so it klinda dose that for u automatically so ..

sage swift
#

how are you building it

cold pawn
sage swift
#

how are you compiling the plugin

onyx shale
#

how do you create the jar

#

basically

quaint mantle
#

hello everyone, how do I get the location of a respawn anchor if a player has set one?

sage swift
#

that's a good question

cold pawn
#

I go to project structure make a new artifact and defined the output location or is there smthing else im suppose to do??

quaint mantle
#

thank you gecko

onyx shale
#

seems player doesnt directly access it

#

only respawnevent

#

so i geuss you need to go into nms

cold pawn
#

what I dont get is I did it for this pic works completely fine and I followed the same steps I did and all so wtf?

twilit cliff
#

Using ProtocolLib, how can I get the whole message being typed in a TAB_COMPLETE packet?

dusty herald
dusty herald
#

show me the error

cold pawn
onyx shale
#

hmm how does the anchor work? you have to click it or smthng?

foggy bough
#

will this code work: ```java

import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitScheduler;

public class Main extends JavaPlugin {

private Main plugin;

@Override
public void onEnable() {
    
}    

public void onDisable() {

    
}

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if(label.equalsIgnoreCase("TNTSpawn")) {
        if(sender instanceof Player) {
            Player player = (Player) sender;
            Location loc = player.getLocation();
            World world = player.getWorld();
            BukkitScheduler timer = player.getServer().getScheduler();
            timer.scheduleSyncRepeatingTask(plugin, new Runnable() {

                @Override
                public void run() {
                    world.spawnEntity(loc, EntityType.PRIMED_TNT);
                    
                }}, 0L, 100L);
            return true;
        }
        
        else {
            sender.sendMessage("Nope!");
            return true;
        }
    }
    return false;
}

}```?

dusty herald
eternal night
#

No 🥳 it won't

dusty herald
#

You also need to specify the api-version

sage swift
#

not necessarily

dusty herald
#

now i must leave

#

i mean it bitches at me if i dont gecko Kek

#

and i use an up-to-date api

sage swift
#

yeah but it'll work

onyx shale
#

holy the nms code for anchor is so convoluted

gaunt eagle
#

The NPC can be created wherever I want, but I still get this error. any idea?

dusty herald
#

not many experts on ProtocolLib here Kek

#

I use it but I am far from being an expert

somber hull
#

How do i send messages to webhooks
or would a bot be easier?

hollow canopy
# gaunt eagle

class java.lang.byte cannot be cast to class java.lang.byte

somber hull
#

you are a god

#

trhank you

hollow canopy
gaunt eagle
#

xD

gaunt eagle
hybrid spoke
#

you can't cast like that

#

thats the solution

hollow canopy
#

😄

hybrid spoke
#

you r trying to set a boolean to a byte

hollow canopy
#

which line did you tried to set a byte

gaunt eagle
hollow canopy
#

I dont know this type of listeners so I cant tell something correct

#

why did you use 127 for it

#

whats the purpose of (byte) 127

#

I made a thing like this if a weapon or anything contains Lore "Tırpan" it will deal damage the neabry entities.But When I try to add knockback to the entities A error occurs in the console called "x is finite"

sage swift
#

```java
code here
```

#

?paste or this

queen dragonBOT
sage swift
#

whyyyy does everyone use lore to find their needed item

#

so janky

hollow canopy
minor garnet
opal juniper
hollow canopy
#

Because I am new

#

And started with it

sage swift
minor garnet
#

spigot i think

#

because i can export others nms class

hoary tiger
#

How do i check if my event entity is 10 blocks away from the player?

onyx shale
#

location.distance(location)

sage swift
#

Location#distanceSquared < 100

hollow canopy
#

entities.setVelocity(entities.getVelocity().add(entities.getLocation().toVector().subtract(whoHit.getLocation().toVector()).normalize().multiply(knockback)));

#

this is my knockback code

hoary tiger
#

sorry what does #mean>

onyx shale
#

and thats a stroke

sage swift
#

on an instance of the object

#

meaning you'll need to get the entity's location and perform the "distanceSquared" method on that location object

hollow canopy
#

x is finite means 2/0 or 3/0

#

How can I fix that?

hoary tiger
#

ok Thanks!

somber hull
#

What type would a config be?

#

Just FIle?

sage swift
#

FileConfiguration?

hollow canopy
sage swift
#

split the line up into multiple and see which part causes the error

eternal oxide
hollow canopy
#

add(entities.getLocation().toVector().subtract(whoHit.getLocation().toVector()).normalize().multiply(knockback)));

#

ohh

eternal oxide
#

subtract is NOT dividing

hollow canopy
#

Yeah my bad my bad

#

sorry

#

so whats the problem

eternal oxide
#

no clue, whats your error?

hollow canopy
#

did you saw my code

eternal oxide
#

yes

hollow canopy
#

okey

eternal oxide
#

you have shown no error

hollow canopy
#

x is finite

#

error occurs in the console

severe folio
#

send the stacktrace

hollow canopy
#

when I use the weapon

eternal oxide
#

you have no x

hollow canopy
#

thats the confusion 😦

eternal oxide
#

show me an actual error, not some guess at it

sage swift
#

well it probably means x as in a number in a method used with Location

eternal oxide
#

x is finite is no java error I've ever seen

#

show me the actual log error

hollow canopy
#

okey

#

I will send the command line in the console with paste.md

#

when I hit a mob

severe folio
#

x not finite

sage swift
#

yeah he knows

#

line 54, youre somehow getting infinity

#

within setVelocity is a function that gets you infinity

eternal oxide
#

yep (Main.java:54)

hollow canopy
#

entities.setVelocity(entities.getVelocity().add(entities.getLocation().toVector().subtract(whoHit.getLocation().toVector()).normalize().multiply(knockback)))

#

this is the code

sage swift
#

yeah probably because you're adding and subtracting the locations as vectors

#

wait no nvm

eternal oxide
#

you are trying to implement some kind of knockback?

hollow canopy
#

yeah

#

without knockback

#

it looks bad

#

I tried to make aoe damage weapon

#

like scythe

#

I want to knock neabry entities

compact haven
#

why dont you

#

turn those into some local variables

eternal oxide
#

try java entities.setVelocity(entities.getLocation().toVector().subtract(whoHit.getLocation().toVector()).normalize().multiply(knockback));

hollow canopy
eternal oxide
#

but set your knockback to 1

hollow canopy
#

still same

eternal oxide
#

can;t be the same

hollow canopy
#

still bro I am so confused

sage swift
#

what is knockback

hollow canopy
#

float knockback = 1;

eternal oxide
#

That code I gave you above is simple vector math between two locations

hollow canopy
#

sometimes it can work @eternal oxide

eternal oxide
#

Well, there is nothing at all wrong with that vector/velocity math

#

Mine, not yours 😉

#

What do you mean by sometimes?

hollow canopy
#

I mean it works but not correctly

#

I am trying to figure

muted idol
#

hey is there anybody that could help me with running methods over servers using the bungeecord messaging system?. for example if a player joins server 1 it runs a method on server 2

eternal oxide
#

what do you mean by not correctly? As they they knockback but the wrong direction?

hollow canopy
#

Sometimes knockbacks and damages others

muted idol
hollow canopy
#

But still occur that x not finite error

eternal oxide
sage swift
#

does that include the player entity maybe

eternal oxide
#

yes

muted idol
#

@sage swift do you think you could help me?

sage swift
#

no

#

i help no one

#

i am the worst

muted idol
#

lmao emotional support?

#

i see

hollow canopy
#

should I descrease range @eternal oxide

eternal oxide
#

you should exclude the player from your entity list

hollow canopy
#

But my server will be pve and pvp

sage swift
#

the player that hit

#

so you dont knock yourself back

hollow canopy
#

oh

#

I tried that

#

But I didnt make it

#

if (!(entities instanceof Damageable))
continue;

#

I am using this for exclue item frame dropped item etc.

#

It will be a spoonfeed but can you guys send example?

sage swift
#

if (entity.getUniqueId().equals(source.getUniqueId())) continue;

#

dont call the single entity entities please it's really confusing

hollow canopy
#

its a list

sage swift
#

no, "whoHitted2" is a list

hollow canopy
#

List<Entity> whoWasHitted2 = whoWasHitted.getNearbyEntities(3,3,3);

sage swift
#

entities is an entity

hollow canopy
#

for(Entity entities : whoWasHitted2)

#

But it works on every mob

sage swift
#

like im saying, entities is a singular entity

hollow canopy
#

it says source cannot be resolved

#

and entity cannot be resolved

sage swift
#

it

#

it's pseudocode

#

you can convert it into your variables

#

it's not even really pseudocode

#

im saying you want to compare the uuid of the entity to the uuid of the entity that hit and see if they are the same

#

if they are, skip over and continue in the for loop

hollow canopy
#

if (entity.getUniqueId(whoHit).equals(source.getUniqueId(Player)))

sage swift
#

why are you putting something in getUniqueId

#

it doesnt need anything passed in

#

you call it on the entity itself

#

whoHit.getUniqueId

#

😬

hollow canopy
#

last question

#

if (whoHit.getUniqueId().equals(entities.getUniqueId()))

#

is this right..

#

sorry for overasking

sage swift
#

mhm

hollow canopy
#

still same

#

bruh

muted idol
#

hey @eternal oxide you think you could help me with my issue?

sage swift
# hollow canopy bruh
    @EventHandler
    public void on(EntityDamageByEntityEvent evt) {
        if (evt.getDamager().getType() != EntityType.PLAYER) return;
        if (!(evt.getEntity() instanceof LivingEntity)) return;
        Player player = (Player) evt.getDamager();
        if (!player.getInventory().getItemInMainHand().getItemMeta().getPersistentDataContainer().has(identifyingKey, PersistentDataType.BYTE)) return;
        for (Entity entity : evt.getEntity().getNearbyEntities(3, 3, 3)) {
            if (!(entity instanceof LivingEntity)) continue;
            if (player.getUniqueId().equals(entity.getUniqueId())) continue;
            ((LivingEntity) entity).damage(1, player);
            // knockback code
        }
    }``` is a little cleaner and easier to follow in my opinion
fierce salmon
#

how do you get the item meta of an item?

sage swift
#

item.getItemMeta()

#

🤯

fierce salmon
#

then I want to say if (event.getItemMeta().equals(ItemMetaoffishingrod)) {

#

how would i do that

sage swift
#

nooooooooooo

#

stop comparing metas for your custom items AAAAA

fierce salmon
#

its not custom

sage swift
fierce salmon
#

i just want to see if the item is a fishing rod

sage swift
#

if you want to see if it's a fishing rod get its type

severe folio
sage swift
#

ItemStack#getType

#

if (item.getType() != Material.FISHING_ROD) return;

fierce salmon
#

ok thx

gaunt eagle
#

Anyone know how to fix this?

sage swift
#

hmmm

#

what does it want

#

what are you giving it

gaunt eagle
#

I did not understand exactly what and how to add

gaunt eagle
sage swift
#

probably use Bukkit.getWorld("world") and then get the WorldServer from that

hollow canopy
#

@sage swift ...getPersistentDataContainer().has(identifyingKey, PersistentDataType.BYTE)) return; what is the meaning of this?

sage swift
#

a better way of identifying your custom item

hollow canopy
#

where I should write my lore?

sage swift
#

you don't need to

#

it's an nbt tag that doesnt show up for the player

#

and it doesnt require the meta to be exactly the same

hollow canopy
#

but I want to run the skill if a item has Scythe lore

#

I didnt understand very well

sage swift
#

give the item a tag that identifies that it's a custom item

onyx shale
#

we rly need a more simplified guide to pdc

#

so everyone.. everyone can get how it works

sage swift
#

eg. ItemMeta#getPersistentDataContainer().set(new NamespacedKey(plugin, "scythe"), PersistentDataType.BYTE, (byte) 1);

#

this will set an nbt tag on the item

onyx shale
#

dang gecko getting his spoon outduke

gaunt eagle
sage swift
#

and when you later need to figure out whether it's the correct item you can use ItemMeta#getPersistentDataContainer().has(new NamespacedKey(plugin, "scythe"))

#

WorldServer is just the nms world

hollow canopy
#

Ahh I see now

onyx shale
#

WorldServer world = ((CraftWorld)Bukkit.getWorld("world")).getHandle();