#help-development

1 messages · Page 600 of 1

wet breach
#

without the need of having all of them

robust portal
#

^

flint coyote
#

Well you can still access the index of the list if you want a specific one

wet breach
#

yes but you need to still pull all of the list

robust portal
#

This is where I've gotten
Which outputs this

flint coyote
#

The list is "pulled" onEnable anyway. Configs are cached

robust portal
#

It's updating all of them.

wet breach
#

not saying your way is incorrect just pointing out the advantage of the other way

flint coyote
#

Yeah you don't have a section. You have a list

wet breach
flint coyote
#

So you have to update a list index

flint coyote
wet breach
#

still an object that isn't created automatically

flint coyote
#

I think it is actually however I could be wrong about that. I'd imagine the caching is object based and not string based

zealous comet
#

How I can create a list for if (block.getType() == ) { for all sign exist on minecraft ?

remote swallow
#

use tags

zealous comet
#

Tags ? Sorry Im new in Java ^^'

remote swallow
#

i can copy and paste correctly, totally

flint coyote
#

questionable link lmao

zealous comet
#

😂

remote swallow
#

just realised theres an ALL_SIGNS

#

so Tag.ALL_SIGNS.isTagged(block.getType())

remote swallow
#

tom scott is in it

zealous comet
#

So I do if (Tag.ALL_SIGNS.isTagged(block.getType())) ?

remote swallow
#

yeah

zealous comet
#

Ok thanks you !

robust portal
#

Instead of making a new one

remote swallow
lost schooner
remote swallow
#

or even just do getKeys(false) .size + 1

robust portal
#

@remote swallow

rare rover
#

okay

#

so

#

i got this doodoo code dont worry ima redo it

@Override
    public void run() {
        Map<UUID, Map<Material, List<PlayerGenerator>>> generators = GeneratorHandler.getPlayerGenerators();
        generators.entrySet().stream()
                .filter(entry -> Bukkit.getPlayer(entry.getKey()) != null)
                .forEach(entry -> {
                    Map<Material, List<PlayerGenerator>> playerGenerators = entry.getValue();
                    playerGenerators.forEach(((material, playerGenerators1) -> {
                        final int size = playerGenerators1.size() - 1;
                        final PlayerGenerator generator = playerGenerators1.get(size);
                        final Location location = generator.getLocation().clone().add(0, 0.6, 0);
                        final ItemStack item = getFormmatedItemStack(generator, size);
                        Bukkit.broadcastMessage(item.toString());
                        new BukkitRunnable() {
                            @Override
                            public void run() {
                                Item i = location.getWorld().dropItemNaturally(location, item);
                                i.setVelocity(new Vector());
                            }
                        }.runTask(plugin);
                    }));
                });
    }``` whenever the map is at 1 item it wont drop anything. `item.toString()` shows `COBBLESTONE` which is right but whenever i do `Bukkit.broadcastMessage(i.toString())` on the other thread it wont drop. It only works if there's 2 or more things in the map
#

and i can't figure it out

dry forum
#

whats the most efficent way to make an armorstand move along a certain block? ill probably have quite a few armorstands

robust portal
#

@remote swallow

#

There's gotta be a better way to do what I'm doing.

zenith gate
#

does anyone know of a resource on formating the data from this minecraft command: /data get entity ToastARG. Holds all the data on the player including the PDC and I need to look through it all, but it looks like shit and cant read it.

tender shard
#

then retrieve it using getMapList

zenith gate
opal juniper
#

is it not just nbt @zenith gate?

lost schooner
#

Why is my IntelliJ crashing every 20-30minutes completely randomly

robust portal
robust portal
zenith gate
orchid trout
opal juniper
#

yeah, i’m pretty sure you are looking at the SNBT data

#

there are probably online viewers for it

orchid trout
hazy parrot
#

he is syncing it with main thread infact

lost schooner
#
[16:18:28] [Server thread/INFO]: Left enchantments: {}
[16:18:28] [Server thread/INFO]: Right enchantments: {}

Why is leftEnchantments == rightEnchantments evaluating to false

orchid trout
#

he said whenever he does Bukkit broadcastMessage it wont drop

lost schooner
#

They're both Map<Enchantment, Integer>

young knoll
#

.equals

lost schooner
orchid trout
#

== compares instances

hazy parrot
young knoll
#

== compares memory location, .equals can be overridden to compare values

lost schooner
#

Should I always be using .equals for stuff

opal juniper
#

not always

hazy parrot
#

if you want to check if its same value, yes, if you want to check if its same object no

#

also you probably already figured, but you can't call .equals on primitives

vapid raft
#

Hey, I'd like to ask if this is a correct way to check someone's inventory
player.getInventory().getSize(), because despite if a player has something if his inv is empty, it outputs 41

quaint mantle
#

how do I get a NMS BlockState from a Material since byId is depprecated?

hazy parrot
#

what exactly you want to check

vapid raft
#

If a player has something in his/her inventory

#

In other words, if it's empty

orchid trout
#

a player object doesnt have pronouns

hazy parrot
vapid raft
#

Player as in the living thing behind the screen, but sure xD

vapid raft
robust portal
hazy parrot
orchid trout
#

why are you setting nextInt to nextInt?

#

and why are you looping through spawner.getKeys(true) and in the loop checking if spawned.getKeys(true) contains the current key

#

thats just r
redundant

robust portal
#

@hazy parrot How would I make it exist then?

#

Because this isnt working then

robust portal
remote swallow
#

set(nextInt + "x"

robust portal
#

When I start dealing with configs I lose brain cells

remote swallow
#

calling set(nextInt, nextInt) wont make a config section

robust portal
#

Ahhhhh

#

How would I make on then

remote swallow
#

there isnt really a need for it, just call spawner.set(nextInt + ".x", value)

robust portal
#

Ohhhhh

#

vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

#

Well it almost worked

remote swallow
#

i missed a dot

#

.x not just x

robust portal
#

Almost money agan

#

I think its looping to many times?

remote swallow
#

check ur code

robust portal
#

Sorry for the spoon feeding smh

remote swallow
#

you do it every loop

#

why are you even looping

#

public void saveNewSpawner(FileConfiguration config) {
      ConfigurationSection section = config.getConfigurationSection("spawnerlocations");
      int nextId = section.getKeys().size() + 1;
      spawner.set(stuff);
      save
}
robust portal
#

Ah truth be told I dont know lol I thought that was the only way to check ids

quaint tapir
#

how do I add an enchant to an item that isn't usually enchantable
FOR EXAMPLE: a stone block

worldly ingot
#

ItemMeta's #addUnsafeEnchant() should work fine

#

Sorry, just #addEnchant()

young knoll
#

Set the final param to true

robust portal
#

Works perfecylt thank you @remote swallow

dull schooner
#

hey, i made a plugin on paper, but my server is using spigot, can i use it anyway?

robust portal
#

@remote swallow Okay epic final question

#

How would I check if it exists at any of those locations

#

This is what I got

wet breach
dull schooner
#

and i dont remember using any specific paper api

young knoll
#

Then it probably uses paper specific api

dull schooner
#

let me see

#

lol, i got a class from paper imported automatically

#

i thought paper made compatibility to and from spigot

remote swallow
#

paper supports spigot plugins

robust portal
#

Epic would that be a cause of looping through everything?

remote swallow
# robust portal

if you need to check if its in it you might as well just save a list of locations

robust portal
#

Wdym

remote swallow
#

a List<Location>

robust portal
#

Well fuck how would I do that than

#

Again, very very new to coding plugins.

dull schooner
#

so, enchant name and level are the item lore, right?

#

can i change them while i'm enchanting?

robust portal
#

Do you have guide or something on stuff like that you can link me

remote swallow
#

set("spawnerlocations", list)

#

getList

robust portal
#

How would I create a list

remote swallow
#

new ArrayList

#

?learnjava

undone axleBOT
remote swallow
#

lists are probably one of the most common things you should know

robust portal
#

Something like this?

remote swallow
#

List<Location> locations = new ArrayList<>()
locations.addAll(config.getList("spawnerlocations"));

#

locations.add(block.getLocation)

robust portal
#

Ahhh

remote swallow
#

are you making custom spawners

robust portal
#

Kinda

remote swallow
#

just add the mob type to the pdc and handle spawning like that

robust portal
#

wat

remote swallow
#

?pdc

robust portal
#

Persistant Data Holders huh

#

So I pretty much just overcomplicated the fuck out of this huh

remote swallow
#

pretty much

robust portal
#

Spawners considered a tile entity yeaH?

young knoll
#

yes

robust portal
#

Alrighty, I think I've got it besides checking it?

#

Nvm

echo basalt
#

?arrowcode

undone axleBOT
robust portal
#

Will work on it

#

holy fuck I got it

#

@remote swallow Thank you so fucking much
@vivid cave Thank you so fucking much

ornate patio
#

I'm trying to boost a potion's level but for reason meta.hasCustomEffects() is always false

PotionMeta meta = (PotionMeta) holding.getItemMeta();
meta.getPersistentDataContainer().set(new NamespacedKey(plugin, "boostAmount"), PersistentDataType.INTEGER, multiplier);

// Boost effect level of potion
if (meta.hasCustomEffects()) {
    for (PotionEffect effect : meta.getCustomEffects()) {
        int newAmplifier = ((effect.getAmplifier() + 1) * multiplier) - 1;
        meta.addCustomEffect(new PotionEffect(effect.getType(), effect.getDuration(), newAmplifier), true);
    }
}

holding.setItemMeta(meta);

any ideas? I tried messing with getBasePotionData:

PotionType potionType = meta.getBasePotionData().getType();
if (potionType.isUpgradeable()) {
    meta.addCustomEffect(new PotionEffect(potionType.getEffectType(), ????), false);
}

But how am I supposed to get the original duration and amplifier?

dull schooner
young knoll
#

Yes but you would have to hide the original enchantments and then add your own to the lore

dull schooner
#

Cause i want to remove that enchant.level n

worldly ingot
#

Well, at least in that case you can create a resource pack to add new entries

dull schooner
robust portal
#

Dude persistant data containers are fucking awesome

dull schooner
#

wdym

ancient plank
#

PDC epic yes

dull schooner
young knoll
#

You hide them via ItemFlags

#

You can recreate them with basic lore

dull schooner
#

Im struggling with the recreation, how do i do that?

remote swallow
#

add gray lore to the start of the lore list if it has or, or a new list

dull schooner
#

I made an list with a text components, and insert a string, but that didnt change anything

young knoll
#

Yeah you just add grey text to the top of the lore

dull schooner
#

im trying the following, but's not working
ItemMeta meta = item.getItemMeta();
@Nullable List<Component> lore = item.lore();
if(lore == null){
lore = new ArrayList<>();
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
Map<Enchantment, Integer> enchants = item.getEnchantments();
for(Enchantment enchantment : enchants.keySet()){
String enchantName = enchantment.getKey().toString();
int enchantLevel = enchants.get(enchantment);
lore.add(Component.text(enchantName +" "+ enchantLevel));
}
item.lore(lore);
item.setItemMeta(meta);
}

#

it just dont give any lore at all

remote swallow
#

?wherami

#

?whereami

young knoll
#

You’re also only adding it if lore is null

#

It’s possible it already has lore

#

Or paper api returns an empty list rather than null, who knows

dull schooner
#

it is null

remote swallow
#

if (lore == null) lore = new ArrayList<>()

young knoll
#

I’ll do ya one better

remote swallow
#

no

#

you check if its null and cause an npe

young knoll
#

List lore = meta.hasLore ? meta.getLore : new ArrayList

remote swallow
#

shush

dull schooner
#

wow, i didnt knew that method

#

it's deprecated

young knoll
#

What’s deprecated

dull schooner
#

a method or class that was replaced by another

drowsy helm
#

lmao he means which method

dull schooner
#

but they dont delete from the code

#

he deleted the message

remote swallow
#

you are in the spigot discord

#

you are using the paper api

dull schooner
#

setLore()

remote swallow
#

you are in the wrong place

young knoll
#

I think it’s just lore in their api

dull schooner
#

everything from spigot i can use in paper, idk why would that be the case

young knoll
#

Also I didn’t delete anything

wet breach
#

Either ignore the deprecation to maintain compatibility or use paper specific api only

remote swallow
wet breach
#

Just because it is deprecated doesnt necessarily mean unusable

#

But yeah the above

dull schooner
remote swallow
#

im just directing you to the correct place for support

eternal oxide
#

Build against Spigot API and your plugin will run everywhere. Build against Paper and your plugin only runs on Paper

dull schooner
#

im jk

ancient plank
#

you can also read deprecation messages, they typically tell you why something is deprecated :)

dull schooner
ancient plank
#

i.e. a lot of methods on the paper api are deprecated because they have changed to use components instead of strings

dull schooner
#

i asked there and someone said i need to use datapacks for client side

#

i dont think that's a real answer

remote swallow
#

what would you need that for

young knoll
#

Datapacks aren’t even a client side thing

dull schooner
#

i asked how to rename enchantments, and an admin said "Only with a use of datapack which should be installed by a client"

dull schooner
#

thats why i think that cant be a real answer

remote swallow
#

im gonna take a while guess and say they meant resource packs

dull schooner
#

even if it was

#

that's just impracticable

remote swallow
#

server resource packs

dull schooner
#

in several servers some items have a lot of custom enchantments, i think that surely is a way to do that

remote swallow
#

yeah, with lore

#

or custom resource packs

dull schooner
remote swallow
#

so force the resource pack

young knoll
#

Or just

#

Get the lore working

dull schooner
#

im searching everywhere and i cant find the answer 😔

#

everything that i try just doesnt work

wet breach
echo basalt
#

?? why's it not finding papi

#

fuck gradle

#

not even scanning the repo

#

I'm fuckin blind lmao

orchid gazelle
#

Use maven

blazing flare
#

How does runTaskAsynchronously work precisely? Does it create a new thread each time, reuse an existing thread that isn't main thread if one is available, does it use the main thread at times, what's the dealio?

drowsy helm
#

You might be able to rummage around the bukkit scheduler src and see how it does it

wet breach
#

Unless its the only task needing to be run lol

buoyant viper
quiet ice
#

Repost of yesterday's question of mine:
Is anyone aware of some library that basically does regex on steriods? i.e. I'm looking for something that can evaluate something like follows:

{
  "priority": 100, 
  "validFor": {
    "locales": ["DEU", "FRA"],
    "patternMatches": "[\d\.]+(,\d+)?[KMGTY]?"
  },
  "value": {
    "pattern": "([\d\.]+)(?:,(\d+))?([KMGTY]?)",
    "transform": [
      {
        "validFor": {
          "ifNotPresent": ["{2}"]
        },
        "data": "0",
        "store": { "variable": "{2}", "as": "STRING", "via": "STORE" }
      }, {
        "concat": [ "{1}", ".", "{2}" ],
        "store": { "variable": "ret", "as": "DECIMAL", "via": "ADD" }
      }
    ],
    "return": "ret"
  }
}

I know, cursed beyond belief but without some cursed combination of sscanf (which would require the FFI anyways) and regex it is hard to do otherwise
Needn't be JSON and can also be another file format.

blazing flare
astral laurel
#

I want to make a gun but what I have won't work can you help me?

     Vector vec =  player.getEyeLocation().getDirection();
                        for(Player players: Bukkit.getOnlinePlayers()){
                            if(players.getLocation().getDirection().equals(vec)){
                                players.damage(2);
                            }
                        }```
maiden thicket
#

there is a method for that

astral laurel
#

how can i do that? (i don't find "targetentities")

maiden thicket
drowsy helm
#

the code you made will try and match any player looking in the same direction as the current player. It logically doesnt make sense

lost schooner
#

Does Java have any way to define custom methods on external types other than using a newtype pattern

astral laurel
#

thanks

lost schooner
#

yes

drowsy helm
#

no

lost schooner
#

😡

drowsy helm
#

other than extending it theres no way

lost schooner
#

Wdym extending it? Don't you have to extend in the original class def

#

Or can you extend interfaces in your own code

drowsy helm
#

yeah ofc

#

what are you trying to do?

lost schooner
#

Implement methods on ItemStack so I don't need a bunch of dangling static functions everywhere

drowsy helm
#

just use a util class

lost schooner
#

Well that's what I'm doing but it's getting mega bloated

#

I can refactor but idk

drowsy helm
#

sub util classes lol

lost schooner
#

where is my impl Trait

#

How do I figure out if an item is being renamed in an anvil? It seems the normal way to do this is to check the result item but if I'm trying to determine the result item how do I check for it?

drowsy helm
#

like they are actively typing the name in?

lost schooner
#

I suppose so, just an event handler for PrepareAnvilEvent

drowsy helm
#

yeah PrepareAnvilEvent is pretty much all you have

lost schooner
#

If only Spigot had a Rust API ;-;

drowsy helm
#

you can do a packet listener aswell

vital yacht
#

There’s something even better than Rust called Skript

lost schooner
drowsy helm
#

yeah ig

vital yacht
lost schooner
#

The anvil has its normal functionality which includes renaming items

#

You type a new name, the result becomes the left item with that name

#

However, when you're trying to figure out whether the user is trying to rename the item, you all of a sudden have to rely on the original functionality to reimplement itself

#

Because you can only check the name of the result item

#

There is no API call to query the name box

vital yacht
#

Can’t you check the name of the first item? I don’t get what you mean

lost schooner
#

You can check the name of the first item but you cannot determine what is in the name box

#

I would send an image but I cannot

drowsy helm
#

look at the link i sent

#

it does exatly that

lost schooner
lost schooner
drowsy helm
#

its a packet listener

#

whenever the player types something in, a packet is sent

lost schooner
#

I don't know where it would go or anything

#

This is my second day doing plugin development

drowsy helm
#

gotcha

vital yacht
lost schooner
#

I used to know Java but I forgot it over time

lost schooner
drowsy helm
#

has a getRenameText method

lost schooner
#

Whoah

#

Nice

#

That worked. Thanks a bunch

orchid gazelle
#

Can I somehow force-open the chat for a player?

drowsy helm
#

no

orchid gazelle
#

Or is it clientsided

#

oof

drowsy helm
#

you trying to force text input?

orchid gazelle
#

Yes

drowsy helm
#

yeah the closest you can get to that is a sign input ui

#

thats about it

vital yacht
#

What are you trying to do specifically?

orchid gazelle
#

But having to click on a rename field on an anvil and then having go click the item is... annoying as hell

orchid gazelle
orchid gazelle
#

Can I confirm with enter?

#

It switches the line with enter, but is that detectable?

drowsy helm
#

nah pretty sure they have to click it still

orchid gazelle
#

Thats sad

drowsy helm
#

unless a packet is sent for each keystroke

#

dont think it is

orchid gazelle
#

well maybe for line switched

#

But I don't know thaaat much about packets

drowsy helm
#

yeah no its sent as one chunk in a packet

#

so no way to detect enter being pressewd

orchid gazelle
#

Well but at least I can customize the UI right?

drowsy helm
#

with a resourcepack, yeah

orchid gazelle
#

With a resourcepack

#

Yeah

#

Alright thanks

vital sandal
#

I came into this err :l

#

for some reason it shows that

#

tried Invalidate Caches but no luck

tender shard
#

click the uppermost item on the list, then select everything from the console output and paste it

fluid river
#

yo guys

#

what u think about Penistone problem

#

jree fava

vital sandal
#

and it work for some reason

quiet ice
#

Good luck, you'll wait a lot longer than that

orchid gazelle
#

What does it include?

icy beacon
#

any way to decode these characters?

flint coyote
#

128 char cap of what?

icy beacon
#

better yet, any way to make cmd actually show them properly?

flint coyote
#

I see

paper cosmos
#

I can't fix this problem when building spigot server. I downloaded the file both pom and jar and put it in the work folder but it still gives me this error and can't see I downloaded it manually

[ERROR] Failed to execute goal on project spigot: Could not resolve dependencies for project org.spigotmc:spigot🫙1.20.1-R0.1-SNAPSHOT: Failed to collect dependencies at com.mojang:authlib🫙4.0.43: Failed to read artifact descriptor for com.mojang:authlib🫙4.0.43: Could not transfer artifact com.mojang:authlib:pom:4.0.43 from/to minecraft-libraries (https://libraries.minecraft.net/): Connection reset -> [Help 1]
What can I do? I have a bad internet but I can't fix it any time soon

flint coyote
#

Can you use mobile data?

icy beacon
paper cosmos
drowsy helm
flint coyote
paper cosmos
#

no, manually from libriries minecraft net

eternal oxide
#

did you install the authlib to your local maven repository?

#

Did you manage to download it manually?

left depot
#

How long can it take until spigot updatechecker api updated?

tender shard
#

the "new" one is basically instant

icy beacon
#

4 hours spent to figure out that i confused -= and =-

glad prawn
#

I want to prevent people from dropping a specific item, is it reasonable to use PDC for this?

sullen marlin
#

sure

shadow night
#

If you want it to be different for each player or be able to give any item that tag, then yes. Otherwise you could just add a config or something.

glad prawn
#

ok tks

#

ok tks again

kind prawn
#

what's the right way to log errors to console?
I don't want to pass the plugin to each class should I create functions for logging?

shadow night
#

You could make the logger static or just System.out.println() ig

left depot
tender shard
#

the legacy one, idk. why don't you use the new one?

left depot
#

yeah good question 😂

tender shard
steep plaza
#

hi

#

guys i have one qestion

#

how i can get player name

chrome beacon
#

Player#getName

steep plaza
chrome beacon
#

No

steep plaza
#

beacause i need i get a player name for put in a scoreboard

tender shard
#

then just call getName() on the player object

steep plaza
#

okok thx

quaint mantle
steep plaza
tender shard
#

?learnjava

undone axleBOT
tender shard
#

you don't know the basic stuff, e.g. difference between classes and objects/instances of classes

#

obviously, getName() is not a static method, it wouldn't make any sense

tender shard
steep plaza
#

ah okok

tender shard
#

you need to have an object of player, a specific player

steep plaza
#

sorry

#

but is my first time

tender shard
#

np lol

steep plaza
#

@tender shard its work

upper hazel
icy beacon
#

it uses packets magic somehow

#

yep

chrome beacon
#

You can take a look

alpine urchin
#

he’s afraid of packets

icy beacon
#

oh i remember this dude

#

he was trying to serialize an entire horse yesterday

#

of course he is afraid of packets

young knoll
#

They are just keeping an armorstand synced with the horse

tender shard
#

imho all packet libraries have the wrong name. ProtocolLib, PacketEvents... They should be called Customs!

icy beacon
#

for some reason

#

lol

tender shard
#

Customs deals with incoming and outgoing packets all day, why is no library called customs

icy beacon
#

what is this witchcraft

icy beacon
#

😄

#

but if we are serious

#

those libs just want to be descriptive

#

if i saw a lib named "customs" i would think of custom items, enchantments, entities

tender shard
icy beacon
#

def not packets

icy beacon
upper hazel
icy beacon
young knoll
#

The only packet usage seems to be hiding the passengers from eachother

icy beacon
#

oh

young knoll
#

Presumably because they would block your view

icy beacon
#

couldn't you just do that with bukkit api

#

player.cansee(player)

#

or smth

young knoll
#

Yes

icy beacon
#

then why is this with packets 😭

tender shard
#

that was added in 1.19.X

icy beacon
#

i thoguht it was there for a very long time

young knoll
#

It is

orchid gazelle
#

ho lee

young knoll
#

Yeah it’s been around forever

icy beacon
tender shard
#

oh then it was hideEntity

#

idk

young knoll
#

Yes hideEntity is new

soft hound
#

Would it be better to make my own economy plugin or just use Essentials since there's a lot of plugins supporting it ?

chrome beacon
#

If you want your own econ plugin make it support vault

#

Anyways I'd just use Essentials

soft hound
eternal oxide
#

I'd just implement Vault and let the server choose what eco they use

chrome beacon
#

It's been around for years

paper cosmos
eternal oxide
#

wrong

paper cosmos
#

where?

eternal oxide
#

you need to instal it to your local maven

paper cosmos
#

how does it look?

paper cosmos
#

except for the path to file I dont know what these fields are

soft hound
#

Would this be it ?

icy beacon
#

is this pdc or nbt?

#

i mean can i remove this using pdc or should i use nbtapi

eternal oxide
#

public bukkit values is pdc

icy beacon
#

ty

torn shuttle
#

hey nerds, remind me real quick, if I want to teleport a player when they get on should I do the player login event or the player join event?

eternal oxide
#

join

#

and teleport 1 tick later with runTask

torn shuttle
#

thanks, just this once I won't take all of your lunch money

worldly ingot
spare hazel
#

setDamageRewards(1);
Invalid method declaration; return type required

class:
public class Combat extends Skill implements ConfigurationSerializable {

theres a setDamageRewards Method on the Skill abstract class

worldly ingot
#

Okay, so you've marked it as @Override but the method signature is wrong

#

Skill#setDamageRewards() has a different return type than your Combat#setDamageRewards() implementation

spare hazel
#

no i want to use the mothod i created in the abstract class

worldly ingot
#

I'm going to need to see the entirety of both classes to actually understand what you're trying to do lol

#

?paste ideally

undone axleBOT
torn shuttle
#

the world creator is used even just for loading existing but currently unloaded worlds right?

#

or wrong?

spare hazel
#

oh nvm

torn shuttle
#

it looks right

#

ok

#

thanks

spare hazel
worldly ingot
#

You're calling it outside of any scope

spare hazel
#

public Combat(){
setDamageRewards(1);
}

worldly ingot
#

Yep

#

Beat me to it

spare hazel
worldly ingot
#

You're right. The constructor you just sent is what you should be doing

#

I suppose you have two constructors though so if you want to run it for both you can either put it in both constructors, or use an initializer block

spare hazel
worldly ingot
#
    public Combat(Map<String, Object> m){
        setXp((Integer) m.get("xp"));
        setLevel((Integer) m.get("level"));
        this.setDamageRewards(1);
    }

    public Combat(){
        this.setDamageRewards(1);
    }

// OR

    public Combat(Map<String, Object> m){
        this();
        setXp((Integer) m.get("xp"));
        setLevel((Integer) m.get("level"));
    }

    public Combat(){
        this.setDamageRewards(1);
    }

// OR

    {
        this.setDamageRewards(1);
    }

    public Combat(Map<String, Object> m){
        setXp((Integer) m.get("xp"));
        setLevel((Integer) m.get("level"));
    }

    public Combat(){}
#

Both will work

#

Edited in a third actually. Second one is probably best in case you choose to add more things to the default constructor

chilly hearth
#

i have downloaded the code from github i want to compile it into a plugin iam using intellJ what do i do after importing it ?

remote swallow
#

what code

chilly hearth
#

a source code of a plugin

remote swallow
#

send the link of its github

ionic terrace
#

Is it possible to refresh the values in a GUI without closing and reopening the inventory?

eternal oxide
#

yes

remote swallow
#

the code isnt actually on there

chilly hearth
#

oh

#

so i cant compile it ?

remote swallow
#

correct'

stark patio
#

Any ideas why popular plugins like LuckPerms, WorldEdit, "essentialsX, ... don't define any permissions to their commands in plugin.yml? Just courious about what the actual reason(s) could be.

chilly hearth
#

sad

ionic terrace
chilly hearth
remote swallow
chilly hearth
#

btw how do we add a new value in plugins ?

remote swallow
#

a new value where

chilly hearth
#

like making a plugin with a new value

remote swallow
#

what new value

chilly hearth
#

like coins for example

remote swallow
#

oh an economy plugin

#

just hook into valut

#

vault

chilly hearth
#

hm

#

is there an event for the new value ?

remote swallow
#

probably

chilly hearth
#

do u know the event ?

remote swallow
#

just had a look and it turns out vault doesnt have events

chilly hearth
#

so what they use

remote swallow
#

they handle it from econ responses probably

chilly hearth
#

econ response

#

?

chilly hearth
#

bruh

#

i still dont understand that lol

remote swallow
#

its returned when you call the add currency method

chilly hearth
#

oh you mean /pay

remote swallow
#

no, the api method

chilly hearth
#

i see

remote swallow
#

AbstractEconomy#depositPlayer(player, amount)

#

that returns an EconomyResponse

chilly hearth
#

so to create our own currency in a plugin we need to use their api ?

remote swallow
#

if you want it to work with most other plugins that use money sure

pseudo hazel
#

if you want to convert it back to other currencies, sure

chilly hearth
#

oh

#

is it allowed if we just edit it in vault plugin code and may add /withdraw

remote swallow
#

you cant add code to vault, vault is an api

#

you would need a plugin that hooks into vault

chilly hearth
#

alr and what about /withdraw

remote swallow
#

you make a command to hook vault and remove it from there bank, and give them something to do with said withdrew currency

chilly hearth
#

and in the code it will go like ?

eternal oxide
#

No one is writing it for you

remote swallow
#

im not spoonfeeding you it

chilly hearth
#

ah

spare hazel
#
import net.milkbowl.vault.economy.Economy;
import org.bukkit.plugin.RegisteredServiceProvider;

public class EconomyController {

    private static Economy econ = null;

    public static boolean setupEconomy() {
        if (HypixelSkillCore.getInstance().getServer().getPluginManager().getPlugin("Vault") == null) {
            return false;
        }
        RegisteredServiceProvider<Economy> rsp = HypixelSkillCore.getInstance().getServer().getServicesManager().getRegistration(Economy.class);
        if (rsp == null) {
            return false;
        }
        econ = rsp.getProvider();
        return econ != null;
    }

    public static Economy getEconomy() {
        return econ;
    }
}
chilly hearth
#

dam

spare hazel
#

replace HypixelSkillCore with your plugin name

#

make sure to create a way of obtaining the plugin instance

remote swallow
#

that gets current economy

#

if you want ur own economy its different

spare hazel
#

u should just use essentials for the currency

#

also call setupEconomy in on

#

Enable

chilly hearth
#

alr

remote swallow
#

deffo the forum post

spare hazel
sterile breach
#

yes that's why I'm hesitating between the 2

remote swallow
#

the forums for most stuff is always better

spare hazel
remote swallow
#

also kody simpson use inv holders which is the entirely wrong way to do it

sterile breach
#

ok down there I did kody simpson's I'm going to look at the other small question anyway, on kody simpson's when the menu is closed, it's not deleted from the list it seems to me?

spare hazel
#

is using skript bad when you know spigotapi? i know spigotapi but making a custom spawners plugin in spigotapi is too hard

remote swallow
remote swallow
chilly hearth
#

chill out lol

sterile breach
ionic terrace
spare hazel
sterile breach
#

oups sorry EpicEbic i speak to @spare hazel

spare hazel
chilly hearth
#

e

sterile breach
#

also players

spare hazel
#

doesnt seem that hard...

#

does skript have oop?

#

or json support?

sterile breach
#

the hardest part was more the page system etc... I used a var to find out which page I was on etc... I am still a beginner in the spigot api but one of my goals is to redo this plugin in spigot

sterile breach
glossy venture
#

but I dont think it has a way to define classes

ancient plank
#

spigot supa ez

chilly hearth
#

fr fr

steep plaza
#

'''
// Evento PlayerJoinEvent
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
String MondoGiocatore = player.getWorld().getName();
Inventory InventarioGiocatore = player.getInventory();

    if (MondoGiocatore.equals("world")) {
        // NON PRENDE NESSUN TIPO DI DANNO QUANDO IL GIOCATORE SI TROVA NELLA LOBBY
        PotionEffect invincibilityEffect = new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, Integer.MAX_VALUE, 4, false, false);
        player.addPotionEffect(invincibilityEffect);
        player.setFoodLevel(20);

        // TELETRASPORTO AL PUNTO DI SPAWN
        player.teleport(new Location(player.getWorld(), 735.500, 23, -1012.500));

        Bukkit.dispatchCommand(player, "ScoreboardLobby");
    }else {
        Bukkit.dispatchCommand(player, "NascondiScoreboardLobby");
        player.getActivePotionEffects().forEach(potionEffect -> {
            PotionEffectType effectType = potionEffect.getType();
            player.removePotionEffect(effectType);
        });

    }
}

'''
because when i change the world it doesn't hide the board

pseudo hazel
#

if you get to the point where you need classes in your skript files, just switch to java

cinder abyss
#

Hello, how can I make this in spigot for a ItemDisplay ?

chrome beacon
#

?

cinder abyss
#

/summon item_display {item_display:head}

wise mesa
cinder abyss
#

(make the item_display looks like a block)

wise mesa
#

oh wait

#

nvm

#

wrong thing

cinder abyss
#

okay thanks

wise mesa
#

here

#

oh someone else got it

karmic mural
#

Hey. I'm working on something where I interact a lot with the inventory. I see that there seems to be 41 items when I do player.getInventory().getContents(). Is there somewhere I can read about what exactly all these slots are? I've made the assumption that this is the 36 inventory slots, + offhand + armor slots, but is this incorrect?

#

I did think that it could potentially be the inventory crafting grid, too, but since they can't store anything the armor slots seem more likely

#

I realize now maybe PlayerInventory.getStorageContents() is what I should be using, huh?

wise mesa
#

i forget which ones are which but that is correct

humble lynx
wise mesa
#

there

karmic mural
#

Thank you @wise mesa @humble lynx

humble lynx
#

Depending on the event use e.getrawslot as well

tender shard
#

this is correct for Inventory.getItem(int)

#

getRawSlot might be different, usually that one starts to count at the top most slot - but not always lol

humble lynx
#

Yeah, using GUIs you have two separate slot numbers going on at the same time, so e.getRawSlot is a good reminder

haughty pewter
#

Hi, i made plugin which replaces insted of emeralds to diamons villager trade and now the villagers level not increasing and he not giving xp why??

young knoll
#

Did you set the villagerExperience value for your recipes?

haughty pewter
#

how i cen do it :D

chrome beacon
young knoll
#

It's also an option in the constructor

pseudo hazel
# steep plaza ??

I wasnt talking to you, but you just need to use paste or format the code using triple backticks `

haughty pewter
chilly hearth
#

a

#

i have installed the plugin minecraft development in intellj but when i do new project it doesnt show me the option of spoigt it shows bukkit bungecord etc

hazy parrot
#

I think they dropped support for spigot

#

Anyway don't use that plugin, it's trash

young knoll
#

Pretty sure you select bukkit and then spigot

#

But it defaults to paper iirc

chilly hearth
ocean hollow
#

Raycast works on DisplayEntity? it doesn't have a hitbox.

young knoll
#

Yes but only if you use the raySize option

buoyant viper
#

y

kind hatch
#

They didn't.

last sleet
#

Is there a way of listening to the inventoryclickevent after it has triggered? (After everything has finished)

#

I am trying to add more crafts to the vanilla anvil and I need the anvil with the items in it when the players adds a new one. I could technically handle everything myself, delete items and replace them in the anvil, but there surely is a better way?

flint coyote
last sleet
#

Yep I tried that

#

didn't seem to work...

#

I'm looking now into the event priority, perhaps that will work

#

nope it doesnt

#

BukkitScheduler scheduler = mainPlugin.getServer().getScheduler();
scheduler.scheduleSyncDelayedTask(mainPlugin, new Runnable() {
public void run() {
//code
}
},0);

flint coyote
#

You just create an itemStack with Material.POTION and then change the PotionMeta you can get by calling myItemStack.getItemMeta()

last sleet
#

this is the correct code for scheduling right?

flint coyote
#

Try with a 1 instead of a 0 although I'd expect that to be the same

last sleet
#

hm yea

#

ogh im dumb

#

well it works now, thanks xd

shadow night
#

Isn't the turtle master potion a combo of two potion effects?

flint coyote
#

yes

#

It does have its own texture though

paper cosmos
#

Where can I download a ready spigot server jar without building it?

flint coyote
#

Dunno if that's hardcoded into the client for that combination of potion effects

river oracle
#

?bt

undone axleBOT
paper cosmos
#

can you build it for me?)

river oracle
#

If you don't know how try using the wip Gui by contributhers here

river oracle
paper cosmos
#

damn, why?

river oracle
#

?dmca

undone axleBOT
river oracle
#

Long story

river oracle
#

It's a wip If you have any issues feel free to report them in the thread

#

It should be much easier than command line

flint coyote
#

Book formatting is such a pain

river oracle
#

Yes

flint coyote
#

At this point I'm not even trying to write pretty code and still I run into weird issues

river oracle
paper cosmos
river oracle
#

You'd be hardpressed to even get paper with internet that slow

paper cosmos
#

well, normally it can reach about 50KB/s

kind hatch
#

Yikes, you'll have to download even more once you get the jar. BuildTools clones git repos so it can build everything locally.

#

Just combine them.

if (GG >= 0 && GG <= 19) {
  // Do stuff
}
paper cosmos
kind hatch
#

Even if I was, you internet speed wouldn't download it in a fast manner. The final jar is like ~75MB

paper cosmos
#

my server folder is already 250Mb

kind hatch
#

No, but it just makes it easier to read. Plus less nesting.

hazy parrot
paper cosmos
#

with this internet I've downloaded intellijidea with all necessary stuuf for mc plugins, minecraft, discord, and three spider man movies

kind hatch
#

Then what's the issue with running BuildTools?

paper cosmos
#

[ERROR] Failed to execute goal on project spigot: Could not resolve dependencies for project org.spigotmc:spigot🫙1.20.1-R0.1-SNAPSHOT: Failed to collect dependencies at com.mojang:authlib🫙4.0.43: Failed to read artifact descriptor for com.mojang:authlib🫙4.0.43: Could not transfer artifact com.mojang:authlib:pom:4.0.43 from/to minecraft-libraries (https://libraries.minecraft.net/): Connection reset -> [Help 1]

#

I downloaded this authlib manually but I have no idea how to let the buildtools use it. It's impossib;e

#

this checking for secure connection on spigot site makes my life harder

#

I still can't see why you can't send me ready server jar

eternal oxide
#

illegal is why

kind hatch
#

Also, BuildTools primary purpose is to compile the server jars.
It can install the mappings via the --remapped flag, but past that, there shouldn't be any need for a manual lib import.

hard socket
#

can I show only one armor stand hand?

kind hatch
#

You should be able to get mojang related code through the spigot dependency. You are using maven right?

paper cosmos
#

yes, though I dont even know at which point of all this process I decide if I use maven

kind hatch
#

Maven is a dependency management tool. It removes the hassle of hunting down jar files and manually importing them.
You choose whether to use it at the start of your project.

paper cosmos
chilly hearth
ivory sleet
#

Can you show the error?

#

Nah

#

?paste just

undone axleBOT
kind hatch
# paper cosmos I don't understand what you said in the first sentence

If you use maven, you'll have a dependency section that contains

<dependency>
  <groupId>org.spigotmc</groupId>
  <artifactId>spigot-api</artifactId>
  <version>1.18.1-R0.1-SNAPSHOT</version>
  <scope>provided</scope>
</dependency>

You'll want to use the artifiactId of spigot for usage of NMS code.

ivory sleet
#

Verify and send

#

U select the text

#

And then u press enter

chilly hearth
kind hatch
chilly hearth
#

So it won't work with +?

kind hatch
#

Not if you're doing a comparison like that one.

chilly hearth
#

Oh ok

quiet ice
paper cosmos
trail coral
#

what do you think it is ?

quiet ice
#

What are you running the plugin with?

#

You know, the version of the server?

#

Well I guess that fixes your issue then. Glad to see you figured it out

ivory sleet
#

Oh yes branched programming

trail coral
#

bro

#

your plugin is 1.19

#

you server isnt

quiet ice
#

And what is it?

quiet ice
paper cosmos
quiet ice
#

Do a maven clean install or a gradle clean build

#

Also make sure you are using the right target+source/release version for your build

eternal oxide
#

CalamityScen was built for a newer java

#

your server is running 8

quiet ice
#

Given that you are probably using IJ: Go figure it out yourself.
For the CLI it would be mvn clean install and ./gradlew clean && ./gradlew build respectively

#

Under maven open the POM, click on the drop-down menu next to the "Run" button, go on "Run as..." and click "maven clean".

eternal oxide
#

in eclipse you can just use the project menu and select clean

quiet ice
#

Under gradle click on Window > Show View > Other > Gradle > Gradle Tasks.
Then execute the clean goal from there

kind hatch
# paper cosmos You know I have no idea what you mean by this. How do I use this information to ...

I'm going to assume that you don't have anything setup.

  1. Download BuildTools (Whether it through the link on the wiki or the link to the GUI that's in development)
  2. Run it. (java -jar BuildTools.jar --rev <THE VERSION YOU WANT> --remapped)
  3. Copy the completed jar to your server directory.
  4. Setup your maven project and include that dependency in your pom.xml
  5. Use the built in maven tools to package your plugin jar.

That's all you have to do. If you just want the server jar, stop at step 3.

quiet ice
paper cosmos
kind hatch
#

--remapped installs the remapped jars to your .m2 directory so that you can use the mojang mappings in your projects.

paper cosmos
#

How do you know all that?

lost schooner
#

How do I get the max durability on an item? I'm trying to add together durabilities but Damageable.getDamage() and Damageable.setDamage() only get how much the tool has been damaged rather than how much durability it has left

kind hatch
buoyant viper
#

just get good

paper cosmos
#

Is this Maven a part of Spigot or it is a different thing?

kind hatch
#

Completely separate. It's just a dependency management tool.

buoyant viper
#

Maven is a project management system Spigot uses

zenith gate
#

I can't get the EnchantItemEvent to trigger. the docs say Called when an ItemStack is successfully enchanted (currently at enchantment table) I am enchanting items, they are successful, but yet the event is never called upon.

@EventHandler
public void FrozenAspect(EnchantItemEvent event) {
    event.getEnchanter().sendMessage("I WAS CALLED");  
    Bukkit.getLogger().info("I WAS CALLED");
}

This is what I have and it never runs. I do have it registered.

paper cosmos
#

my brain melts when I see word dependency

buoyant viper
#

think of spigot(-api) as a dependency to ur plugin

#

well, dont think it just to think it, since it really is a dependency, but yeah

paper cosmos
#

you just used this word twice

#

also th word api

buoyant viper
#

dependency, its something ur plugin requires to compile/run

kind hatch
#

A dependency is something that you depend on.
I.E. your project depends on the Spigot API.
It cannot run without it.

buoyant viper
#

ur plugin is "dependent" on spigot-api

#

Spigot API is what lets ur plugin interface/use Spigot

lost schooner
dull schooner
#

hey, how do i check who's using the anvil?

#

cause the PrepareAnvilEvent doen't have a getPlayer method

#

i tried using InventoryOpenEvent, but i cant get the anvil in that case

zenith gate
#

getViewers()?

#

@dull schooner

dull schooner
#

a

#

thanks XD

zenith gate
#

np

ornate patio
#

I'm trying to boost a potion's level but for reason meta.hasCustomEffects() is always false

PotionMeta meta = (PotionMeta) holding.getItemMeta();
meta.getPersistentDataContainer().set(new NamespacedKey(plugin, "boostAmount"), PersistentDataType.INTEGER, multiplier);

// Boost effect level of potion
if (meta.hasCustomEffects()) {
    for (PotionEffect effect : meta.getCustomEffects()) {
        int newAmplifier = ((effect.getAmplifier() + 1) * multiplier) - 1;
        meta.addCustomEffect(new PotionEffect(effect.getType(), effect.getDuration(), newAmplifier), true);
    }
}

holding.setItemMeta(meta);

any ideas? I tried messing with getBasePotionData:

PotionType potionType = meta.getBasePotionData().getType();
if (potionType.isUpgradeable()) {
    meta.addCustomEffect(new PotionEffect(potionType.getEffectType(), ????), false);
}

But how am I supposed to get the original duration and amplifier?

young knoll
#

The only thing you can really use is PotionData#isExtended() and isUpgraded()

dull schooner
#

how do i get a Player from HumanEntity?

young knoll
#

Cast it

ornate patio
zenith gate
#

i would assume the orignal would be in the getBasePotionData

#

docs say Returns the potion data about the base potion

young knoll
#

The duration and level for those are fixed internally

#

And not accesible it seems

dull schooner
#

is there any way to show a text in front of the anvil gui?

zenith gate
#

wdym infront of the gui?

ornate patio
quaint mantle
#

How can one iterate through a chunk ?

#

all the locations

young knoll
#

3 nested loops

#

x and z are from 0 to 15 and y is from world.getMinHeight to world.getMaxHeight

ornate patio
#
public enum PotionStat {
    // 180 seconds = 3 minutes
    // 480 seconds = 8 minutes
    NIGHT_VISION(PotionEffectType.NIGHT_VISION, 180, 480),
    INVISIBILITY(PotionEffectType.INVISIBILITY, 180, 480),
    JUMP_BOOST(PotionEffectType.JUMP, 90, 180, 480, 0, 1),
    ...

    private final PotionEffectType potionEffectType;
    private final int shortenedDuration;
    private final int normalDuration;
    private final int extendedDuration;
    private final int normalAmplifier;
    private final int upgradedAmplifier;

    private PotionStat(PotionEffectType potionEffectType, int normalDuration, int extendedDuration) {
        this(potionEffectType, normalDuration, normalDuration, extendedDuration, 0, 0);
    }

    private PotionStat(PotionEffectType potionEffectType, int shortenedDuration, int normalDuration, int extendedDuration, int normalAmplifier, int upgradedAmplifier) {
        this.potionEffectType = potionEffectType;
        this.shortenedDuration = shortenedDuration * 20;
        this.normalDuration = normalDuration * 20;
        this.extendedDuration = extendedDuration * 20;
        this.normalAmplifier = normalAmplifier;
        this.upgradedAmplifier = upgradedAmplifier;
    }
#

this is fun

dull schooner
#
@EventHandler
  public void onAnvil(PrepareAnvilEvent event){
      AnvilInventory inventory = event.getInventory();
      int levelCost = inventory.getRepairCost();
      if (levelCost > 39) {
          Player player = (Player) event.getViewers().get(0);
          ChatColor chatColor;
          if (levelCost <= player.getLevel())
              chatColor = ChatColor.GREEN;
          else{
              chatColor = ChatColor.RED;
          }
          List<String> lore = new ArrayList<>();
          lore.add(chatColor + "Enchantment Cost: " + levelCost);
          ItemStack tempItem = inventory.getResult();
          if (tempItem != null) {
              tempItem.setLore(lore);
              inventory.setResult(tempItem);
          }
      }
    }```
Why isnt this working?
quaint mantle
young knoll
#

Do you need the exact location?

quaint mantle
young knoll
#

Because Chunk has methods that take releative location

quaint mantle
#

I do need exact locations

young knoll
#

Either way you should just have to multiple the chunk x and z by 16

#

And then add your 0-15

ornate patio
#

cause it has 2 effects

#

damnit

sterile breach
#

https://www.spigotmc.org/threads/a-modern-approach-to-inventory-guis.594005/

hello, I followed this tutorial to make my menu handler, but I find the handler "too developed". I mean, as far as click events etc. are concerned, I would prefer not to have a class inventory button but directly redefine the onCLick function in the menu itself, after that maybe it's really better and that it I just have to get used to it?

young knoll
quaint mantle
#

rn its 0..16?

soft hound
#

Is there an event that gets triggered when a cactus grows ?

#

like for example a specific "CropGrowthEvent" or something

dull schooner
young knoll
ornate patio
#

is it possible to get the vanilla potion duration and amplifier with NMS?

echo basalt
#

probably

#

Easiest way is to just loop through the potion registry and prnt out their duration and amplifiers

#

because it's all hardcoded

soft hound
#

Or just make a custom one ? 🙂

#

A quick question

#

I'm making a custom item, and it'll allow for it to have storage and the player to sell it.
Is there a way to make something like @EventHandler and call it from other classes, and when a player sells, it triggers ?

sterile breach
#

https://www.spigotmc.org/threads/a-modern-approach-to-inventory-guis.594005/

hello, I followed this tutorial to make my menu handler, but I find the handler "too developed". I mean, as far as click events etc. are concerned, I would prefer not to have a class inventory button but directly redefine the onCLick function in the menu itself, after that maybe it's really better and that it I just have to get used to it?

river oracle
#

?event-api

undone axleBOT
river oracle
ornate patio
young dome
prime epoch
#

Is it a good idea to store all the bounding boxes for peoples claims in one array?

#

im talking in terms of memory and stuff like that

chrome beacon
#

Only store what you need

soft hound
flint coyote
#

Is it always the case that Listeners that listen to events that have extended Events catch the extended Events, too?
I just noticed that's a thing when I got a EntityTargetLivingEntityEvent while listening to the EntityTargetEvent which broke my logic since I had a map that stored the EntityTargetEvent class and therefore did not find anything for the EntityTargetLivingEntityEvent class

#

Basically I have a central listener (inside an api) that has to delegate back to the registrator. Now I gotta find a solution for dealing with extended Events.
Just wanna know if that's consistent across all events

#

If someone got a solution I'd also take that but it's probably not that easy

wet breach
#

its basically the reason why there is some generic ones you can't cancel

#

but there is still some though where you could

flint coyote
#

Hmm that makes things a lot harder

wet breach
#

not necessarily, you could listen for the upper most one and uncancel

#

but, this is why there is a general etiquette devs should be following in regards to events. Such as not only using the appropriate events they need but as well as using the appropriate priorities and cancelling if its necessary. I will admit a lot of the times it is easier to just cancel and let the server handle that lmao

flint coyote
#

Well I basically have someone who's using the api create a function like that

@Override
    public Map<Class<? extends Event>, EventPriority> getEventsToRegister() {
        return Map.of(EntityTargetEvent.class, EventPriority.NORMAL);
    }

And prepare another function for receiving the listed events.

@Override
    public void handleEvent(Event event, EventPriority priority) {
        if (event instanceof EntityTargetEvent e) {
            onEntityTarget(e);
        }
    }

I now need to figure out a way to delegate back to the handleEvent even when I receive an EntityTargetLivingEntityEvent instead of the (registered) EntityTargetEvent. My approach so far was the following map:
Map<Class<? extends Event>, Map<EventPriority, TreeSet<RegionEvent>>> eventListeners = new HashMap<>(); where RegionEvent would be all Events (not bukkit events) that listen to a specific Event with the given Priority

#

Now that I can't be sure that I receive the exact Class that was registered, how shall I store and delegate correctly? I don't wanna listen to all super classes as I will then have to listen to EntityEvent and PlayerEvent.

echo basalt
#

mhm that's icky

flint coyote
#

yeah so far I don't really have an idea

wet breach
#

you actually can check if it is the exact class or not

flint coyote
#

Well I also wanna delegate the child events if the usual listener would receive them obviously

#

But even with reflection I would not know how to do that

wet breach
#

but, I think the simple solution would be to just add some information to your paremeters for the constructors

#

you can always tell the handle event which it is specifically

flint coyote
#

Not really since I only have one executor that has to delegate:

Map<Class<? extends Event>, Map<EventPriority, TreeSet<RegionEvent>>> eventListeners = new HashMap<>();
// .....................
@AllArgsConstructor
    private class CustomExecutor implements EventExecutor {

        private final EventPriority priority;

        @Override
        public void execute(@NotNull Listener listener, @NotNull Event event) {
            Map<EventPriority, TreeSet<RegionEvent>> regionEventMap = eventListeners.get(event.getClass());
            if (regionEventMap == null) {
                return;
            }
            TreeSet<RegionEvent> events = regionEventMap.get(priority);
            if (events == null) {
                return;
            }
            events.forEach(regionEvent -> regionEvent.handleEvent(event, priority));
        }
    }
#

I mean I do have one executor per Priority but they receive all types of events for that priority. And then using the map they get delegated to the right places

wet breach
#

you could check the event if it has a living entity or not

#

if it doesn't it is the top most event

#

if it does, its the living entity event

flint coyote
#

That applies to this event. What about all the others?

wet breach
#

as I said most others generally have a generic event you can't listen to or cancel

flint coyote
#
wet breach
#

those are the same as what I said

#

you could just check for specific thing being set or not

#

really the only difference between them

#

EntityTargetEvent fires regardless of the entity, EntityTargetLivingEntity just provides a more specific event based on that if the entity in question is a living one

#

but I don't see why it would make a difference which event you ultimately listened to on that because they both essentially contain the same information

flint coyote
#

I mean I can make an exception for that event and handle it explicitly instead of generic like I currently handle all events. The problem is that this is prone to breaking for other cases like this

wet breach
#

the bucket event is the same way

flint coyote
#

You can not listen to the PlayerBucketEvent directly though

#

However you can listen to the EntityTargetEvent - you just might get a specific one with LivingEntity

wet breach
#

you could always make a pr to change that

#

it could have been in error or not really thought about when it was added

#

that the generic event should have been abstract

#

and that there should have been 2 events under it

#

one for living entities and then another for all others

#

but unless that happens you are just going to have to actually look and see which events this issue applies to and make exception code for each

#

sucks, but there is really no other way if you really must know the specific event

prime epoch
#

is there a standard effecient way to know if a player has entered a claim? all the methods i can think of are really inefficient

wet breach
#

bounding box

prime epoch
# wet breach bounding box

i got the bounding boxes stored but im not sure how to know effeciently if a player has entered one. Ive tried to look for some resources but theyre doesnt seem to be much out there

flint coyote
prime epoch
wet breach
#

use player move event to check

#

and use a hashmap

prime epoch
#

this was my idea originally. alrigh thanks

wet breach
#

this is probably a sign your code is probably not structured appropriately

#

one of the downsides of programming 🙂

prime epoch
#

most likely its my first java and spigot project lmao

wet breach
#

this is why refactoring code is a thing lmao

prime epoch
#

ive pretty much restarted my project like 3 times but im fine with it. Learning innit

wet breach
#

well, before you worry about efficincy

#

first get it working

#

its far easier to work with and around something that is working, then just theory

flint coyote
prime epoch
#

Yeah true. Im just used to working with games differently

wet breach
#

if there is a matching key, then the value should be the claim

flint coyote
#

Store each block of a bounding box??

prime epoch
#

I'm going to use a Hashset with my claims class which looks like this

public class Claim {

    private Location corner_1;
    private Location corner_2;
    private BoundingBox bounding_box;

    public Claim(int corner_1_x, int corner_1_z, int corner_2_x, int corner_2_z) {
        World world = Bukkit.getWorld("world");
        this.corner_1 = new Location(world, corner_1_x, 0, corner_1_z);
        this.corner_2 = new Location(world, corner_2_x, 0, corner_2_z);

        this.bounding_box = new BoundingBox(corner_1_x, world.getMinHeight(), corner_1_z, corner_2_x, world.getMaxHeight(), corner_2_z);
    }
}```
#

and i'll just loop through each of them and see if the player is colliding

wet breach
#

well could, best not do that, still a bit tired. I would have to think about it a bit for an ideal solution

#

its probably going to take a double hashmap or even a multimap

flint coyote
prime epoch
wet breach
#

ah right you could go by chunks if you want

#

since you could use bitshifting to check the chunk a given location is in

#

you shift by 15

young knoll
#

Chunk are free spatial partitioning

#

Done by the game for you

wet breach
#

you have a valid chunk coord when its divisible by 16

flint coyote
#

Yeah you could only check regions that are in loaded chunks and use the chunkload/chunkunload event to update that list

prime epoch
prime epoch
wet breach
#

is your project public?

flint coyote
#

whose?

wet breach
#

you know if you toss it on github and routinely update it with your progress you might get some people willing to make pr's and the sorts 😛

#

also makes it easier to show what you have too

#

when you are stuck like this

flint coyote
#

Are you talking to AyPle or to me? lol

wet breach
#

yes

flint coyote
#

I see!

wet breach
#

Its directed to AyPle

#

lol

prime epoch
#

I can make my git repo public if you want to look at it

wet breach
#

since they are new to programming as they said

prime epoch
#

nah im not new to programming

flint coyote
#

Makes sense, yes

prime epoch
#

just spigot

wet breach
#

oh, well still applies all the same

wet breach
#

but also remember this though, just because you think it is inefficient or doesn't use the most efficient method, doesn't mean it really is inefficient. It could be efficient enough which is all that matters really until it really is an issue

prime epoch
#

Yeah just atm the server isn't that great so im trying to cut costs basically lol

wet breach
#

an example, looping through an array of 1k and using a hashmap of 1k keys. Obviously the hashmap would be faster but you would only notice this difference if you actually measured it in microseconds to see that.

#

but those microsecond differences don't matter because you wouldn't have a large enough server where microsecond optimizations really make a difference

tepid grove
#

i know basic java from a course i did and i really want to know how to develop plugins especially minigames, does anyone know a good tutorial for total spigot beggnners or a good way to learn?

shy forge
#

Best Practices: Added functionality without inheritance

prime epoch
prime epoch
#

alright thanks i'll start working on it again

wet breach
#

we are generally always here if you are need of more help 🙂

prime epoch
#

love 🙏

orchid trout
#

how attach sources of mojang mappings eclipse

remote swallow
#

with or without maven

orchid trout
#

maven

remote swallow
#

?nms

orchid trout
#

i follow that

remote swallow
#

does eclipse not have a bytecode decompiler

worldly ingot
#

It does

young knoll
#

It’s a plugin

worldly ingot
#

No it has a decompiler built in too, but the plugin is definitely much better because you can switch between a few different decompilers

young knoll
#

Huh TIL

#

I always used enhanced class decompiler

worldly ingot
#

Yeah I use it as well

ornate patio
#

anyone know how i can use nms to get all the vanilla potion durations and amplifiers

worldly ingot
#

They recently added support for Quiltflower which is nice

worldly ingot
remote swallow
#

do you have a pr open for it

young knoll
#

It also doesn’t have the durations

worldly ingot
#

Nah, the deenumification improves it

remote swallow
#

and do you have a pr to change the creative category stuff

worldly ingot
#

Change it how? They don't exist on the server anymore

remote swallow
#

been as some stuff is now in 2 categories

flint coyote
#

The creative menu is entirely clientside right? No scrollable custom inventories

worldly ingot
#

I think honestly the fact that it existed on the server to begin with was an oversight

young knoll
#

Tbf I’m surprised they did before

remote swallow
#

rip scott tom

young knoll
#

Bedrock has fancy GUIs

remote swallow
flint coyote
young knoll
#

I demand parity

torn shuttle